📄 main.c
字号:
//******************************************************************************
//******************************************************************************
// RO_PINOSC_TA0 example
// RO method capactiance measurement using PinOsc IO and TimerA0
//
// Schematic Description:
//
// MSP430G2452
// +---------------+
// |
// C--------|P1.0
// C--------|P1.1
// C--------|P1.2
// C--------|P1.3
// C--------|P1.4
// C--------|P1.5
// |
// C----------|P2.0
// C----------|P2.1
// C----------|P2.2
// C----------|P2.3
// C----------|P2.4
// C----------|P2.5
// |
// C----------|P2.6
// C----------|P2.7
//
// The measurement window is accumulation_cycles/ACLK. The ACLK is
// used to generate a capture event via the internal connection CCIOB.
// The counts within the TA0R that have accumulated during the
// measurement window represents the capacitance of the element.
// This peripheral configuration frees up the WDTp peripheral for other
// uses, but requires an active polling of the CCI0B capture event. The
// polling can be replaced with an ISR to improve power consumption.
//
//******************************************************************************
#include "CTS_Layer.h"
#define NUM_SEN 14
uint16_t dCnt[NUM_SEN];
struct Element* keypressed;
const struct Element* address_list[NUM_SEN] =
{
&element0,
&element1,
&element2,
&element3,
&element4,
&element5,
&element6,
&element7,
&element8,
&element9,
&elementA,
&elementB,
&elementC,
&elementD
};
// Main Function
void main(void)
{
uint8_t i;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO
TI_CAPT_Init_Baseline(&keypad);
TI_CAPT_Update_Baseline(&keypad,5);
// Main loop starts here
while (1)
{
keypressed = (struct Element *)TI_CAPT_Buttons(&keypad);
if(keypressed)
{
for(i=0; i<NUM_SEN; i++)
{
if (keypressed == address_list[i])
{
__no_operation();
}
}
}
}
} // End Main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -