📄 main.c
字号:
//******************************************************************************
// fRO_PINOSC_TA0_SW example
// fRO method capactiance measurement using the PinOsc and TimerA0
//
// 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
//
// Charge and Discharge Cycle
// +
// + +
// + +
// + +
// + +
// Start Timer After n cycles Stop Timer
//
// The TAR reister value is the number of SW loops (function of MCLK)
// within n charge and discharge cycles. This value is directly
// proportional to the capacitance of the element measured. 'n' is
// defined by the variable accumulation_cycles.
// This method does not require the use of the WDTp peripheral.
// Higher resolutions can be achieved with higher clock speeds and
// larger accumulation cycles. This method provides faster scan rates
// at the expense of higher power consumption during the scans (higher
// clock frequencies).
//
//******************************************************************************
#include "CTS_Layer.h"
struct Element * keypressed;
uint8_t sliderPosition;
uint8_t wheelPosition;
// Main Function
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
TI_CAPT_Init_Baseline(&wheel);
TI_CAPT_Update_Baseline(&wheel,5);
TI_CAPT_Init_Baseline(&slider);
TI_CAPT_Update_Baseline(&slider,5);
TI_CAPT_Init_Baseline(&buttons);
TI_CAPT_Update_Baseline(&buttons,5);
// Main loop starts here
while (1)
{
keypressed = (struct Element *)TI_CAPT_Buttons(&buttons);
if(keypressed)
{
if(keypressed == (struct Element*)&elementC)
{
__no_operation();
}
if(keypressed == (struct Element*)&elementD)
{
__no_operation();
}
}
sliderPosition = TI_CAPT_Slider(&slider);
if(sliderPosition != (uint8_t)ILLEGAL_SLIDER_WHEEL_POSITION)
{
__no_operation();
}
wheelPosition = TI_CAPT_Wheel(&wheel);
if(wheelPosition != (uint8_t)ILLEGAL_SLIDER_WHEEL_POSITION)
{
__no_operation();
}
}
} // End Main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -