配置:
主函数:
#include "ti_msp_dl_config.h"
volatile uint8_t gEchoData = 0;
int main(void)
{
SYSCFG_DL_init();
NVIC_ClearPendingIRQ(UART_0_INST_INT_IRQN); //先清除中断,防止直接进中断
NVIC_EnableIRQ(UART_0_INST_INT_IRQN); //允许中断
DL_SYSCTL_enableSleepOnExit(); //可不要
while (1) {
__WFI(); //可不要
}
}
void UART_0_INST_IRQHandler(void)
{
switch (DL_UART_Main_getPendingInterrupt(UART_0_INST)) {
case DL_UART_MAIN_IIDX_RX:
DL_GPIO_togglePins(GPIO_LEDS_PORT,
GPIO_LEDS_USER_LED_1_PIN | GPIO_LEDS_USER_TEST_PIN);
gEchoData = DL_UART_Main_receiveData(UART_0_INST);
DL_UART_Main_transmitData(UART_0_INST, gEchoData); //发送函数
break;
default:
break;
}
}