⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 structure.c

📁 launchpad msp430官方示例
💻 C
字号:
//******************************************************************************
//
// MSP40F2011
// 4 elements configured as a 64 point slider.
//
//******************************************************************************

#include "structure.h"

// P1.2, CA2
const struct Element element0 = {
              .inputBits =  P2CA2,  // CA2
              .maxResponse = 250,
              .threshold = 80
};
//P1.3, CA3
const struct Element element1 = {
              .inputBits = P2CA1+P2CA2, // CA3
              .maxResponse = 300,
              .threshold = 60
};
//P1.4, CA4
const struct Element element2 = {
              .inputBits = P2CA3,    //CA4
              .maxResponse = 280,
              .threshold = 80
};
//P1.5, CA5
const struct Element element3 = {
              .inputBits = P2CA1+P2CA3, //CA5
              .maxResponse = 250,
              .threshold = 60
};

//*** Sensor         *******************************************************/
// This defines the grouping of sensors, the method to measure change in
// capacitance, and the function of the group

const struct Sensor slider = 
{ 
                  .halDefinition = RO_COMPAp_TA0_WDTp,
                  .numElements = 4,
                  .baseOffset = 0,
                  .points = 80,
				  .sensorThreshold = 75,
                  // Pointer to elements
                  .arrayPtr[0] = &element0,  // point to first element 
                  .arrayPtr[1] = &element1,    
                  .arrayPtr[2] = &element2,    
                  .arrayPtr[3] = &element3,    

                  // Reference Information
                  // CAOUT is P1.7
                  // TACLK is P1.0
                  .caoutDirRegister = (unsigned char *)&P1DIR,  // PxDIR
                  .caoutSelRegister = (unsigned char *)&P1SEL,  // PxSEL
                  .txclkDirRegister = (unsigned char *)&P1DIR,  // PxDIR
                  .txclkSelRegister = (unsigned char *)&P1SEL,  // SxSEL
                  .caoutBits = BIT7, // BITy
                  .txclkBits = BIT0,
                  .refPxoutRegister = (unsigned char *)&P1OUT,
                  .refPxdirRegister = (unsigned char *)&P1DIR,
                  .refBits = BIT6,           // BIT6
                  .refCactl2Bits = P2CA4,   // CACTL2-> P2CA4 , CA1
                  .capdBits = (BIT1+BIT2+BIT3+BIT4+BIT5),
                  
                  // Timer Information
                  .measGateSource= GATE_WDT_SMCLK,     //  0->SMCLK, 1-> ACLK
                  //.accumulationCycles= WDTp_GATE_32768                     // 32768
                  //.accumulationCycles= WDTp_GATE_8192                     // 8192
                  .accumulationCycles = WDTp_GATE_512              // 512
                  //.accumulationCycles= WDTp_GATE_64                     // 64                  
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -