attribute((section("ram_code"))) void user_entry_after_sleep_imp(void)
{
pmu_set_pin_to_CPU(GPIO_PORT_A, (1<<GPIO_BIT_0));
system_set_port_pull(1 << LOG_UART_RX_PORT_SEL, GPIO_PULL_UP, true);
system_set_port_mux(LOG_UART_RX_PORT_SEL/8, LOG_UART_RX_PORT_SEL%8, 4);
system_set_port_mux(LOG_UART_TX_PORT_SEL/8, LOG_UART_TX_PORT_SEL%8, 4);
//system_set_port_mux(GPIO_PORT_A, GPIO_BIT_0, PORTA0_FUNC_UART0_RXD);
//system_set_port_mux(GPIO_PORT_A, GPIO_BIT_1, PORTA1_FUNC_UART0_TXD);
uart_init(UART0, 1152);
fr_uart_enableIrq(UART0, Uart_irq_erbfi);
/* RC calibration start. Ensure the accuracy of sleep wake time */
pmu_calibration_start(PMU_CALI_SEL_RCLFOSC, LP_RC_CALIB_CNT);
uart_putc_noint_no_wait(UART0, 'w');
co_delay_100us(1);
pmu_set_pin_to_CPU(GPIO_PORT_C, (1<<GPIO_BIT_2));
pmu_set_pin_to_CPU(GPIO_PORT_C, (1<<GPIO_BIT_3));
__SYSTEM_UART1_CLK_ENABLE();
system_set_port_pull(GPIO_PC2,GPIO_PULL_UP,true);
/* set PC2 and PC3 for AT command interface */
system_set_port_mux(GPIO_PORT_C, GPIO_BIT_2, PORTA2_FUNC_UART1_RXD);
system_set_port_mux(GPIO_PORT_C, GPIO_BIT_3, PORTA3_FUNC_UART1_TXD);
Uart1_handle.UARTx = Uart1;
Uart1_handle.Init.BaudRate = gAT_buff_env.uart_param.BaudRate;
Uart1_handle.Init.DataLength = gAT_buff_env.uart_param.DataLength;
Uart1_handle.Init.StopBits = gAT_buff_env.uart_param.StopBits;
Uart1_handle.Init.Parity = gAT_buff_env.uart_param.Parity;
Uart1_handle.Init.FIFO_Mode = UART_FIFO_ENABLE;
uart_init_ex(&Uart1_handle);
/*enable recv and line status interrupt*/
__UART_INT_LINE_STATUS_ENABLE(Uart1_handle.UARTx);
__UART_INT_RX_ENABLE(Uart1_handle.UARTx);
NVIC_EnableIRQ(UART1_IRQn);
NVIC_SetPriority(UART1_IRQn, 1);
NVIC_EnableIRQ(PMU_IRQn);
}
attribute((section("ram_code"))) void user_entry_before_sleep_imp(void)
{
pmu_calibration_stop();
uart_putc_noint_no_wait(UART0, 's');
co_delay_100us(1);
pmu_set_pin_to_PMU(GPIO_PORT_A, (1<<GPIO_BIT_0));
pmu_set_pin_dir(GPIO_PORT_A, (1<<GPIO_BIT_0), GPIO_DIR_IN);
pmu_set_pin_pull(GPIO_PORT_A, (1<<GPIO_BIT_0),GPIO_PULL_DOWN);//GPIO_PULL_NONE
pmu_set_pin_to_PMU(GPIO_PORT_C, (1<<GPIO_BIT_2));
pmu_set_pin_dir(GPIO_PORT_C, (1<<GPIO_BIT_2), GPIO_DIR_IN);
pmu_set_pin_pull(GPIO_PORT_C, (1<<GPIO_BIT_2),GPIO_PULL_UP);
pmu_set_pin_to_PMU(GPIO_PORT_C, (1<<GPIO_BIT_3));
pmu_set_pin_dir(GPIO_PORT_C, (1<<GPIO_BIT_3), GPIO_DIR_IN);
pmu_set_pin_pull(GPIO_PORT_C, (1<<GPIO_BIT_3),GPIO_PULL_UP);
}
进入后退出休眠模式初始化了2个串口,这样的话休眠过程连接蓝牙就很慢,去掉打印ws就快不少,还可以怎么优化呢?