-
- #include "ti_msp_dl_config.h"
- #include "OLED.h"
- #include "stdio.h"
-
-
-
-
- volatile unsigned int delay_times = 0;
-
-
-
- //搭配滴答定时器实现的精确ms延时
- void delay_ms(unsigned int ms)
- {
- delay_times = ms;
- while( delay_times != 0 );
- }
-
-
-
-
- int a=0;
- volatile uint8_t gEchoData = 0;
-
-
- int main(void)
- {
-
- uint8_t str[64];
-
-
- SYSCFG_DL_init();
- //NVIC_EnableIRQ(TIMER_0_INST_INT_IRQN);
- // DL_TimerA_startCounter(TIMER_0_INST);
-
- delay_ms(500) ;
- OLED_Init();
- OLED_Fill(0x00);
-
- NVIC_ClearPendingIRQ(UART_2_INST_INT_IRQN); //先清除中断,防止直接进中断
- NVIC_EnableIRQ(UART_2_INST_INT_IRQN);
-
-
-
-
-
-
- while (1)
- {
- sprintf((char *)str, "%d", a);
- OLED_ShowStr(0,4, str,2);
-
-
- }
- }
-
-
- void UART_2_INST_IRQHandler(void)
- {
- switch (DL_UART_Main_getPendingInterrupt(UART_2_INST)) {
- case DL_UART_MAIN_IIDX_RX:
- gEchoData = DL_UART_Main_receiveData(UART_2_INST);
- if (gEchoData==0x00)
- {
- a=0;
-
- }
-
- if (gEchoData==0x01)
- {
- a=1;
-
- }
-
-
- if (gEchoData==0x05)
- {
- a=2;
-
- }
-
- if (gEchoData==0x07)
- {
- a=3;
-
- }
-
- if (gEchoData==0x03)
- {
- a=4;
-
- }
-
-
-
- break;
- default:
- break;
- }
- }
-
-
-
- void SysTick_Handler(void)
- {
- if( delay_times != 0 )
- {
- delay_times--;
- }
- }
-
-
配置:大部分与OLED那一篇文章相同,另外加上这些:


