6626的UART1使用示例
void example_uart_int(void) { drv_pin_init(pin_config, sizeof(pin_config) / sizeof(pin_config[0])); usart_config_t usart_cfg = { .baudrate = 115200, .flow_control = USART_FLOW_CONTROL_NONE, .data_bit = USART_DATA_BIT_8, .stop_bit = USART_STOP_BIT_1, .parity = USART_PARITY_NONE, }; drv_usart_init(OM_USART1, &usart_cfg); drv_usart_register_isr_callback(OM_USART1, test_usart_cb); drv_usart_read_int(OM_USART1, NULL, 0); } 2.UART1的休眠配置 // enter deep sleep void user_uart_rx_sleep_set(void) { // Init GPIO drv_gpio_init(rx_gpio_config, sizeof(rx_gpio_config) / sizeof(rx_gpio_config[0])); drv_pmu_wakeup_pin_set(BITMASK(PAD_UART1_RXD), PMU_PIN_WAKEUP_LOW_LEVEL); OM_LOG_DEBUG("\n rx_sleep RX"); pm_sleep_allow(PM_ID_USART1); } 3.UART1的唤醒设置 void user_uart_wakeup_int(void) { example_uart_int(); pm_sleep_prevent(PM_ID_USART1); // OM_LOG_DEBUG("\n uart waikeu RX"); evt_timer_set(&evt_timer_uart1, 5000, EVT_TIMER_ONE_SHOT, evt_uart1_enter_sleep_handler, NULL); } 4.UART1在simple初始化流程 example_uart_int(); // test uart tx memcpy(send_data, "hello\r\n", 7); drv_usart_write_int(OM_USART1, (uint8_t *)send_data, 7); user_uart_rx_sleep_set(); 5.唤醒回调函数阻止睡眠 void user_uart_wakeup_int(void) { example_uart_int(); pm_sleep_prevent(PM_ID_USART1); // OM_LOG_DEBUG("\n uart waikeu RX"); evt_timer_set(&evt_timer_uart1, 5000, EVT_TIMER_ONE_SHOT, evt_uart1_enter_sleep_handler, NULL); } 附件是示例main.c文件 |