📄 structure.c
字号:
//******************************************************************************
//
// 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
//
//******************************************************************************
#include "structure.h"
//PinOsc P1.0
const struct Element element0 = {
.inputPxselRegister = (uint8_t *)&P1SEL,
.inputPxsel2Register = (uint8_t *)&P1SEL2,
.inputBits = BIT0,
.maxResponse = 121+655,
.threshold = 121
};
const struct Element element1 = {
.inputPxselRegister = (uint8_t *)&P1SEL,
.inputPxsel2Register = (uint8_t *)&P1SEL2,
.inputBits = BIT1,
.maxResponse = 121+655,
.threshold = 121
};
const struct Element element2 = {
.inputPxselRegister = (uint8_t *)&P1SEL,
.inputPxsel2Register = (uint8_t *)&P1SEL2,
.inputBits = BIT2,
.maxResponse = 121+655,
.threshold = 121
};
const struct Element element3 = {
.inputPxselRegister = (uint8_t *)&P1SEL,
.inputPxsel2Register = (uint8_t *)&P1SEL2,
.inputBits = BIT3,
.maxResponse = 121+655,
.threshold = 121
};
const struct Element element4 = {
.inputPxselRegister = (uint8_t *)&P1SEL,
.inputPxsel2Register = (uint8_t *)&P1SEL2,
.inputBits = BIT4,
.maxResponse = 121+655,
.threshold = 121
};
const struct Element element5 = {
.inputPxselRegister = (uint8_t *)&P1SEL,
.inputPxsel2Register = (uint8_t *)&P1SEL2,
.inputBits = BIT5,
.maxResponse = 121+655,
.threshold = 121
};
//PinOsc P2.0
const struct Element element6 = {
.inputPxselRegister = (uint8_t *)&P2SEL,
.inputPxsel2Register = (uint8_t *)&P2SEL2,
.inputBits = BIT0,
.maxResponse = 121+655,
.threshold = 121
};
const struct Element element7 = {
.inputPxselRegister = (uint8_t *)&P2SEL,
.inputPxsel2Register = (uint8_t *)&P2SEL2,
.inputBits = BIT1,
.maxResponse = 121+655,
.threshold = 121
};
const struct Element element8 = {
.inputPxselRegister = (uint8_t *)&P2SEL,
.inputPxsel2Register = (uint8_t *)&P2SEL2,
.inputBits = BIT2,
.maxResponse = 121+655,
.threshold = 121
};
const struct Element element9 = {
.inputPxselRegister = (uint8_t *)&P2SEL,
.inputPxsel2Register = (uint8_t *)&P2SEL2,
.inputBits = BIT3,
.maxResponse = 121+655,
.threshold = 121
};
const struct Element elementA = {
.inputPxselRegister = (uint8_t *)&P2SEL,
.inputPxsel2Register = (uint8_t *)&P2SEL2,
.inputBits = BIT4,
.maxResponse = 121+655,
.threshold = 121
};
const struct Element elementB = {
.inputPxselRegister = (uint8_t *)&P2SEL,
.inputPxsel2Register = (uint8_t *)&P2SEL2,
.inputBits = BIT5,
.maxResponse = 121+655,
.threshold = 121
};
const struct Element elementC = {
.inputPxselRegister = (uint8_t *)&P2SEL,
.inputPxsel2Register = (uint8_t *)&P2SEL2,
.inputBits = BIT6,
.maxResponse = 121+655,
.threshold = 121
};
const struct Element elementD = {
.inputPxselRegister = (uint8_t *)&P2SEL,
.inputPxsel2Register = (uint8_t *)&P2SEL2,
.inputBits = BIT7,
.maxResponse = 121+655,
.threshold = 121
};
//*** Sensor *******************************************************/
// This defines the grouping of sensors, the method to measure change in
// capacitance, and the function of the group
const struct Sensor wheel =
{
.halDefinition = fRO_PINOSC_TA0_SW,
.numElements = 6,
.baseOffset = 0,
// Pointer to elements
.arrayPtr[0] = &element0, // point to first element
.arrayPtr[1] = &element1, // point to first element
.arrayPtr[2] = &element2, // point to first element
.arrayPtr[3] = &element3, // point to first element
.arrayPtr[4] = &element4, // point to first element
.arrayPtr[5] = &element5, // point to first element
// Timer Information
.accumulationCycles= 2000 //number of oscillator (RO) cycles
};
const struct Sensor slider =
{
.halDefinition = fRO_PINOSC_TA0_SW,
.numElements = 6,
.baseOffset = 6, // the first six elements are the wheel
// Pointer to elements
.arrayPtr[0] = &element6, // point to first element
.arrayPtr[1] = &element7, // point to first element
.arrayPtr[2] = &element8, // point to first element
.arrayPtr[3] = &element9, // point to first element
.arrayPtr[4] = &elementA, // point to first element
.arrayPtr[5] = &elementB, // point to first element
// Timer Information
.accumulationCycles= 2000 //number of oscillator (RO) cycles
};
const struct Sensor buttons =
{
.halDefinition = RO_PINOSC_TA0_WDTp,
.numElements = 2,
.baseOffset = 12, // the first 12 elements are the wheel and slider
// Pointer to elements
.arrayPtr[0] = &elementC, // point to first element
.arrayPtr[1] = &elementD, // point to first element
.measGateSource= GATE_WDT_ACLK,
.accumulationCycles= WDTp_GATE_64
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -