| | |
| | | } |
| | | if(GPIO_Pin == GPIO_PIN_1)//按键 |
| | | { |
| | | SystemClock_Config(); |
| | | anjian_flag=1; |
| | | } |
| | | if(GPIO_Pin == GPIO_PIN_0)//加速度 |
| | | { |
| | | SystemClock_Config(); |
| | | stationary_flag =0; |
| | | stationary_num=0; |
| | | } |
| | |
| | | data_length1=data_length+9; |
| | | // UART_PushFrame(send_frame1, data_length+9); |
| | | } |
| | | #define BleRxBufferSize 1 |
| | | uint8_t aRxBuffer[1],group_id,GPSRxBuffer[BleRxBufferSize]; |
| | | uint8_t ble_rx_success_flag; |
| | | uint8_t fangzhijinrushuimian_flag; |
| | | uint8_t GPS_zhongzhuandate[200]; |
| | | uint8_t GPS_zhongzhuannum; |
| | | uint8_t GPS_GGAdate[200]={1,2,3,4,5,6,7,8,9}; |
| | | uint8_t GPSchangdu; |
| | | uint8_t Close_RMC[20]="$CCMSG,RMC,1,0,*04\r\n"; |
| | | uint8_t Close_GSA[20]="$CCMSG,GSA,1,0,*0D\r\n"; |
| | | uint8_t Close_GSV[20]="$CCMSG,GSV,1,0,*1A\r\n"; |
| | | uint8_t Close_GLL[20]="$CCMSG,GLL,1,0,*1F\r\n"; |
| | | uint8_t Close_TXT[20]="$CCMSG,TXT,1,0,*00\r\n"; |
| | | uint8_t gps_ceju=0; |
| | | uint8_t no_yingdaflag; |
| | | void Lora_Tx_Poll() |
| | | { |
| | |
| | | // Lora_tx_mode(); |
| | | // if(usart_send[2]==0x99) |
| | | // {LED_TB_ON;} |
| | | Radio.Send( usart_send, 15+Lora_tx_ancnum*4); |
| | | Radio.Send( usart_send, 15+Lora_tx_ancnum*4+GPSchangdu); |
| | | Lora_tx_ancnum=0; |
| | | GPSchangdu=0; |
| | | memset(Lora_tx_ancdist,0,sizeof(Lora_tx_ancdist)); |
| | | memset(Lora_tx_ancid,0,sizeof(Lora_tx_ancid)); |
| | | memset(GPS_GGAdate,0,sizeof(GPS_GGAdate)); |
| | | anjian_flag=0; |
| | | } |
| | | } |
| | |
| | | HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4); |
| | | __HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_4, 60); |
| | | } |
| | | #define BleRxBufferSize 1 |
| | | uint8_t aRxBuffer[1],group_id,BleRxBuffer[BleRxBufferSize]; |
| | | uint8_t ble_rx_success_flag; |
| | | uint8_t fangzhijinrushuimian_flag; |
| | | uint8_t ble_rxzhongzhuandate[200]; |
| | | uint8_t ble_zhongzhuannum; |
| | | uint8_t ble_rxdate[200]={1,2,3,4,5,6,7,8,9}; |
| | | uint8_t changdu; |
| | | uint8_t Close_RMC[20]="$CCMSG,RMC,1,0,*04\r\n"; |
| | | uint8_t Close_GSA[20]="$CCMSG,GSA,1,0,*0D\r\n"; |
| | | uint8_t Close_GSV[20]="$CCMSG,GSV,1,0,*1A\r\n"; |
| | | uint8_t Close_GLL[20]="$CCMSG,GLL,1,0,*1F\r\n"; |
| | | uint8_t Close_TXT[20]="$CCMSG,TXT,1,0,*00\r\n"; |
| | | uint8_t gps_ceju=0; |
| | | void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) |
| | | { |
| | | //HAL_UART_Transmit(&huart1,&ble_zhongzhuannum,1,1000); |
| | | { |
| | | ble_rxzhongzhuandate[ble_zhongzhuannum]=BleRxBuffer[0]; |
| | | ble_zhongzhuannum++; |
| | | if(ble_rxzhongzhuandate[ble_zhongzhuannum-1]==0x0A&&ble_rxzhongzhuandate[ble_zhongzhuannum-2]==0x0D) |
| | | GPS_zhongzhuandate[GPS_zhongzhuannum]=GPSRxBuffer[0]; |
| | | GPS_zhongzhuannum++; |
| | | if(GPS_zhongzhuandate[GPS_zhongzhuannum-1]==0x0A&&GPS_zhongzhuandate[GPS_zhongzhuannum-2]==0x0D) |
| | | { |
| | | // HAL_UART_Transmit(&hlpuart1,ble_rxdate,5,1000); |
| | | memcpy(ble_rxdate,ble_rxzhongzhuandate,ble_zhongzhuannum); |
| | | changdu= ble_zhongzhuannum; |
| | | memset(ble_rxzhongzhuandate,0,sizeof(ble_rxzhongzhuandate)); |
| | | ble_zhongzhuannum=0; |
| | | memcpy(GPS_GGAdate,GPS_zhongzhuandate,GPS_zhongzhuannum); |
| | | GPSchangdu= GPS_zhongzhuannum; |
| | | memset(GPS_zhongzhuandate,0,sizeof(GPS_zhongzhuandate)); |
| | | GPS_zhongzhuannum=0; |
| | | fangzhijinrushuimian_flag=0; |
| | | ble_rx_success_flag=1; |
| | | if(changdu>40) |
| | | if(GPSchangdu>40) |
| | | { |
| | | if(state5v==0) |
| | | LED2_TB_ON; |
| | |
| | | LED2_TR_ON; |
| | | } |
| | | } |
| | | HAL_UART_Receive_IT(&hlpuart1, (uint8_t *)BleRxBuffer, 1); |
| | | HAL_UART_Receive_IT(&hlpuart1, (uint8_t *)GPSRxBuffer, 1); |
| | | } |
| | | } |
| | | uint8_t ble_rxdate111[3]={0x11,0x22,0x33}; |
| | | void HAL_UARTEx_WakeupCallback(UART_HandleTypeDef *huart) |
| | | { |
| | | SystemClock_Config(); |
| | | UsartInit(); |
| | | // HAL_UART_Transmit(&hlpuart1,(uint8_t*)ble_rxdate111,3,1000); |
| | | //// huart->RxState = HAL_UART_STATE_BUSY_RX; |
| | | // ble_rxzhongzhuandate[ble_zhongzhuannum]=BleRxBuffer[0]; |
| | |
| | | // } |
| | | // if(lp_time>3) |
| | | fangzhijinrushuimian_flag=1; |
| | | HAL_UART_Receive_IT(&hlpuart1, (uint8_t *)BleRxBuffer, 1); |
| | | HAL_UART_Receive_IT(&hlpuart1, (uint8_t *)GPSRxBuffer, 1); |
| | | // HAL_UART_Transmit(&hlpuart1,ble_rxdate,2,1000); |
| | | } |
| | | void Ble_rx_Poll() |
| | |
| | | |
| | | // |
| | | // } |
| | | HAL_UART_Transmit(&huart1,ble_rxdate,changdu,1000); |
| | | memset(ble_rxdate,0,sizeof(ble_rxdate)); |
| | | changdu=0; |
| | | Delay_Ms(100); |
| | | // HAL_UART_Transmit(&huart1,ble_rxdate,changdu,1000); |
| | | // memset(ble_rxdate,0,sizeof(ble_rxdate)); |
| | | // changdu=0; |
| | | // Delay_Ms(100); |
| | | // memset(ble_rxdate,0,sizeof(ble_rxdate)); |
| | | } |
| | | } |
| | |
| | | usart_send[1]=0xaa; |
| | | bat_percent=Get_VDDVlotage(); |
| | | GetLoratx_frequency(); |
| | | HAL_UART_Receive_IT(&hlpuart1, (uint8_t *)BleRxBuffer, 1); |
| | | HAL_UART_Receive_IT(&hlpuart1, (uint8_t *)GPSRxBuffer, 1); |
| | | HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_SET); //开GPS电源 |
| | | Delay_Ms(1000); |
| | | HAL_UART_Transmit(&hlpuart1,Close_RMC,22,1000); |
| | |
| | | //Lora_rx_open(); |
| | | // Lora_Tx_Poll(); |
| | | Lora_Tx_Poll(); |
| | | Ble_rx_Poll(); |
| | | // Ble_rx_Poll(); |
| | | // HAL_IWDG_Refresh(&hiwdg); |
| | | IdleTask(); |
| | | // Lora_rece_error=0; |