hal_board_cfg.h
来自「Zigbee2007.rar」· C头文件 代码 · 共 355 行 · 第 1/2 页
H
355 行
/* Select SMCLK = XT2 - MCLK = XT2 */ \
BCSCTL2 |= (SELS | SELM1); \
\
/* XT2 range select 3 to 16MHz, 10pf */ \
BCSCTL3 |= (XCAP0 | XCAP1 | XT2S1); \
\
/* wait for oscillator to stabilize */ \
for (;;) \
{ \
uint8 i; \
uint8 fault; \
\
/* clear oscillator fault flag */ \
IFG1 &= ~OFIFG; \
fault = 0; \
\
/* once fault flag is clear */ \
/* several times in a row, continue. */ \
for (i=0; i<10; i++) \
{ \
fault = fault + (IFG1 & OFIFG); \
} \
if (fault == 0) break; \
} \
} \
else if (x == HAL_CLOCK_TYPE_DCO) \
{ \
/* Setup the GPIOs for DCO calibration */ \
/* P1.1 and P1.4 outputs. */ \
P1DIR |= 0x12; \
\
/* P1.4 SMCLK output */ \
P1SEL |= 0x10; \
\
/* P2.0 output */ \
P2DIR |= 0x01; \
\
/* P2.0 ACLK output */ \
P2SEL |= 0x01; \
\
/* delay for ACLK startup */ \
{ \
uint16 i; \
for (i=0; i<0xFFFF; i++) {}; \
} \
\
/* Set DCO at 6MHz */ \
HAL_ASSERT(TI_SetDCO(TI_DCO_6MHZ) == 0); \
} \
else \
{ \
/* Unknown clock type */ \
HAL_ASSERT(0); \
} \
\
/* Turn on the timer clock; keep 32KHz running */ \
__bis_SR_register(SCG0); \
\
}
/* ----------- Board Initialization ---------- */
#define HAL_BOARD_INIT() \
{ \
/* initialize MCU clocks */ \
HAL_CLOCK_INIT(HAL_CLOCK_TYPE); \
\
/* set direction for GPIO outputs */ \
LED1_DDR |= LED1_BV; \
LED2_DDR |= LED2_BV; \
LED3_DDR |= LED3_BV; \
LED4_DDR |= LED4_BV; \
\
/* reset does not affect GPIO state */ \
HAL_TURN_OFF_LED1(); \
HAL_TURN_OFF_LED2(); \
HAL_TURN_OFF_LED3(); \
HAL_TURN_OFF_LED4(); \
\
/* disable watchdog timer */ \
WDTCTL = WDTPW | WDTHOLD; \
}
/* ----------- Debounce ---------- */
#define HAL_DEBOUNCE(expr) { int i; for (i=0; i<500; i++) { if (!(expr)) i = 0; } }
/* ----------- Push Buttons ---------- */
#define HAL_PUSH_BUTTON1() (PUSH1_POLARITY (PUSH1_PORT & PUSH1_BV))
#define HAL_PUSH_BUTTON2() (PUSH2_POLARITY (PUSH2_PORT & PUSH2_BV))
#define HAL_PUSH_BUTTON3() (PUSH3_POLARITY (PUSH3_PORT & PUSH3_BV))
#define HAL_PUSH_BUTTON4() (PUSH4_POLARITY (PUSH4_PORT & PUSH4_BV))
#define HAL_PUSH_BUTTON5() (PUSH5_POLARITY (PUSH5_PORT & PUSH5_BV))
#define HAL_PUSH_BUTTON6() (PUSH6_POLARITY (PUSH6_PORT & PUSH6_BV))
#define HAL_PUSH_BUTTON7() (PUSH7_POLARITY (PUSH7_PORT & PUSH7_BV))
/* ----------- LED's ---------- */
#define HAL_TURN_OFF_LED1() st( LED1_PORT &= ~LED1_BV; )
#define HAL_TURN_OFF_LED2() st( LED2_PORT &= ~LED2_BV; )
#define HAL_TURN_OFF_LED3() st( LED3_PORT &= ~LED3_BV; )
#define HAL_TURN_OFF_LED4() st( LED4_PORT &= ~LED4_BV; )
#define HAL_TURN_ON_LED1() st( LED1_PORT |= LED1_BV; )
#define HAL_TURN_ON_LED2() st( LED2_PORT |= LED2_BV; )
#define HAL_TURN_ON_LED3() st( LED3_PORT |= LED3_BV; )
#define HAL_TURN_ON_LED4() st( LED4_PORT |= LED4_BV; )
#define HAL_TOGGLE_LED1() st( LED1_PORT ^= LED1_BV; )
#define HAL_TOGGLE_LED2() st( LED2_PORT ^= LED2_BV; )
#define HAL_TOGGLE_LED3() st( LED3_PORT ^= LED3_BV; )
#define HAL_TOGGLE_LED4() st( LED4_PORT ^= LED4_BV; )
#define HAL_STATE_LED1() (LED1_PORT & LED1_BV)
#define HAL_STATE_LED2() (LED2_PORT & LED2_BV)
#define HAL_STATE_LED3() (LED3_PORT & LED3_BV)
#define HAL_STATE_LED4() (LED4_PORT & LED4_BV)
/* ------------------------------------------------------------------------------------------------
* Driver Configuration
* ------------------------------------------------------------------------------------------------
*/
/* Set to TRUE enable ADC usage, FALSE disable it */
#ifndef HAL_ADC
#define HAL_ADC TRUE
#endif
/* Set to TRUE enable LCD usage, FALSE disable it */
#ifndef HAL_LCD
#define HAL_LCD TRUE
#endif
/* Set to TRUE enable LED usage, FALSE disable it */
#ifndef HAL_LED
#define HAL_LED TRUE
#endif
#if (!defined BLINK_LEDS) && (HAL_LED == TRUE)
#define BLINK_LEDS
#endif
/* Set to TRUE enable KEY usage, FALSE disable it */
#ifndef HAL_KEY
#define HAL_KEY TRUE
#endif
/* Set to TRUE enable UART usage, FALSE disable it */
#ifndef HAL_UART
#if (defined ZAPP_P1) || (defined ZAPP_P2) || (defined ZTOOL_P1) || (defined ZTOOL_P2)
#define HAL_UART TRUE
#else
#define HAL_UART FALSE
#endif /* ZAPP, ZTOOL */
#endif /* HAL_UART */
/* ------------------------------------------------------------------------------------------------
* Interrupt Configuration
* ------------------------------------------------------------------------------------------------
*/
/* ----------- timer interrupts ---------- */
#define INTERRUPT_TIMERB_OC_CC0() HAL_ISR_FUNCTION( haBoardTimerB0Isr, TIMERB0_VECTOR )
#define INTERRUPT_TIMERB_OC_CC1_6() HAL_ISR_FUNCTION( haBoardTimerB1Isr, TIMERB1_VECTOR )
/* ----------- UART interrupts ---------- */
#define INTERRUPT_UART_RX_READY() HAL_ISR_FUNCTION( halBoardUart1RxReadyIsr, USCIAB0RX_VECTOR )
#define INTERRUPT_UART_TX_READY() HAL_ISR_FUNCTION( halBoardUart1TxReadyIsr, USCIAB0TX_VECTOR )
/* ----------- key interrupts ---------- */
#define INTERRUPT_KEYBD() HAL_ISR_FUNCTION( halBoardPort1Isr, PORT2_VECTOR )
/*******************************************************************************************************
*/
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?