| | |
| | | #define UWB_OPEN_COUNT 1 // UWB每次开启持续时间(秒) |
| | | #define UWB_MEASUREMENT_INTERVAL 3 // 正常状态测距周期 |
| | | #define UWB_MEASUREMENT_INTERVAL_SLEEP 60 // 休眠状态测距周期 |
| | | #define INACTIVE_TIMEOUT 30 // 无步数变化超时时间(秒) |
| | | #define INACTIVE_TIMEOUT 6 |
| | | // 无步数变化超时时间(秒) |
| | | |
| | | |
| | | void test_Delay_us(uint16_t time); |
| | |
| | | input5v_time=1; |
| | | // g_start_send_flag=1; |
| | | HIDO_TimerTick(); |
| | | // lora_tx_flag++; |
| | | lora_tx_flag++; |
| | | uwb_time_count++; |
| | | jibu_flag=1; |
| | | jishu_flag=1; |
| | |
| | | io_pin_mux_set(LORA_MOSI, IO_FUNC2); |
| | | io_pin_mux_set(LORA_MISO, IO_FUNC2); |
| | | io_pin_mux_set(LORA_CLK, IO_FUNC2); |
| | | io_pin_mux_set(LORA_DIO, IO_FUNC0); |
| | | io_pin_mux_set(LORA_DIO, IO_FUNC0); |
| | | |
| | | |
| | | //ADC |
| | | io_pin_mux_set(ADC_PIN, IO_FUNC1); |
| | | io_pin_mux_set(ADC_PIN, IO_FUNC1); |
| | | io_pull_set(ADC_PIN, IO_HIGH_Z, IO_PULL_UP_NONE); |
| | | |
| | | //串口0 |
| | | io_pin_mux_set(UART0_RX, IO_FUNC4); |
| | | io_pin_mux_set(UART0_RX, IO_FUNC4); |
| | | io_pin_mux_set(UART0_TX, IO_FUNC4); |
| | | uart_open(UART_ID0, &test_uart_cfg); |
| | | uart_receive(UART_ID0,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart0_receive_callback);//开启dma |
| | | uart_receive(UART_ID0,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart0_receive_callback);//开启dma |
| | | |
| | | //串口1 |
| | | io_pin_mux_set(UART1_RX, IO_FUNC4); |
| | | io_pin_mux_set(UART1_RX, IO_FUNC4); |
| | | io_pin_mux_set(UART1_TX, IO_FUNC4); |
| | | |
| | | board_debug_console_open(TRACE_PORT_UART1,BAUD_115200); |
| | | uart_receive(UART_ID1,m_EUART_DMA_RXBuf_1,USART_RX_BUF_SIZE,uart1_receive_callback);//开启dma |
| | | board_debug_console_open(TRACE_PORT_UART1,BAUD_115200); |
| | | uart_receive(UART_ID1,m_EUART_DMA_RXBuf_1,USART_RX_BUF_SIZE,uart1_receive_callback);//开启dma |
| | | |
| | | //PA控制引脚开启 |
| | | io_pin_mux_set(IO_PIN_9, IO_FUNC6); |
| | | io_pin_mux_set(IO_PIN_10, IO_FUNC6); |
| | | |
| | | io_pin_mux_set(IO_PIN_4, IO_FUNC0); |
| | | gpio_pin_set_dir(IO_PIN_4 , GPIO_DIR_OUT, 1); |
| | | // io_pull_set(IO_PIN_4, IO_HIGH_Z, IO_PULL_UP_NONE); |
| | | |
| | | } |
| | | void spi_init() |
| | | { |
| | |
| | | // PCA9555_Set_One_Value_Output(IO_KONG,0); |
| | | // delay_us(10000); |
| | | // PCA9555_Set_One_Value_Output(IO_KONG,1); |
| | | PCA9555_Set_One_Value_Output(BT_IRQ,0); |
| | | PCA9555_Set_One_Value_Output(BT_IRQ,0); |
| | | delay_us(10000); |
| | | PCA9555_Set_One_Value_Output(BT_IRQ,1); |
| | | CloseUWB(); |
| | |
| | | // PCA9555_Set_One_Value_Output(IO_KONG,0); |
| | | // delay_us(10000); |
| | | // PCA9555_Set_One_Value_Output(IO_KONG,1); |
| | | PCA9555_Set_One_Value_Output(BT_IRQ,0); |
| | | PCA9555_Set_One_Value_Output(BT_IRQ,0); |
| | | delay_us(10000); |
| | | PCA9555_Set_One_Value_Output(BT_IRQ,1); |
| | | CloseUWB(); |
| | |
| | | int main(void) |
| | | { |
| | | board_clock_run(); |
| | | boot_deinit(); |
| | | boot_deinit(); |
| | | |
| | | // Reset reason |
| | | reset_cause_get(); |
| | |
| | | |
| | | Board_LORA_NVIC_Init(Lora_irq_handler); |
| | | |
| | | IIC2_Init(); |
| | | IIC2_Init(); |
| | | Accelerometer_Init(); |
| | | |
| | | PCA9555_init(); |
| | | pca_input_detection_init(pca_handler); |
| | | adc_open(&usr_adc_cfg); |
| | | Lora_1268_Init(); |
| | | PCA9555_init(); |
| | | pca_input_detection_init(pca_handler); |
| | | adc_open(&usr_adc_cfg); |
| | | Lora_1268_Init(); |
| | | SwitchLoraSettings(478,7,22); |
| | | Program_Init(); |
| | | power_init(); |
| | |
| | | Uwbinit(); |
| | | while (1) |
| | | { |
| | | |
| | | if(jibu_flag) |
| | | { |
| | | jibu_flag=0; |