int main(void) { gd_eval_led_init(LED1); eclic_global_interrupt_enable(); eclic_priority_group_set(ECLIC_PRIGROUP_LEVEL3_PRIO1); eclic_irq_enable(USART0_IRQn, 1, 0); gd_eval_com_init(EVAL_COM0); usart_interrupt_enable(USART0, USART_INT_RBNE); printf("\r\n 串口测试程序-发送0开灯-发送1关灯 \r\n"); while(RESET == usart_flag_get(EVAL_COM0, USART_FLAG_TC)){ } while(1){ if(rx_buffer=='0'){ gd_eval_led_on(LED1); printf("\r\n 已开灯 \r\n"); while(RESET == usart_flag_get(EVAL_COM0, USART_FLAG_TC)){ } rx_buffer=0; } if(rx_buffer=='1'){ gd_eval_led_off(LED1); rx_buffer=0; printf("\r\n 已关灯 \r\n"); while(RESET == usart_flag_get(EVAL_COM0, USART_FLAG_TC)){ } } } } int _put_char(int ch) { usart_data_transmit(EVAL_COM0, (uint8_t) ch ); while ( usart_flag_get(EVAL_COM0, USART_FLAG_TBE)== RESET){ } return ch; }
void USART0_IRQHandler(void) { if(RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_RBNE)){ /* read one byte from the receive data register */ rx_buffer = (int)usart_data_receive(USART0); } }
总体来说开发方式都大差不差,就是这个eclipsec环境有点摸不懂,请教一下debug里哪能看寄存器数据?