WXK
2024-03-08 1d51ac11e1da7c9b55da8c8b3a7e3756cc5f4ad8
Src/main.c
@@ -37,6 +37,8 @@
#include <stdlib.h>
#include "WS2812.h"
#include "syn6288.h"
#include "dw_mbx_tag.h"
#include "GPS.h"
#define NSH1 0x0001
#define GP   0x0002
#define FLASH_HARDWARE_VERSION_MAP      (uint32_t)0x08004F00    //硬件版本号和批次信息位置
@@ -69,7 +71,6 @@
/* Private variables ---------------------------------------------------------*/
 ADC_HandleTypeDef hadc;
DMA_HandleTypeDef hdma_adc;
IWDG_HandleTypeDef hiwdg;
@@ -204,20 +205,6 @@
float motor_keeptime;
void IdleTask(void)
{
//if(huart1.Instance->ISR&USART_ISR_FE)
//   {
//   SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader
////   }
//    if(du_flag==1)
//    {
//    du_flag=0;
//
//    }
//    if(xie_flag==1)
//    {
//    xie_flag=0;
//    memcpy((uint8_t*)&g_com_map + pack_index, mUsartReceivePack, pack_datalen);
//    }
   if(HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin))
   {
           
@@ -232,11 +219,9 @@
      }
      if(bat_percent>99)
      {
    powerled=GREEN;
    Set4LEDColor(powerled,loraled,gpsled,uwbled);
            powerled=GREEN;
      }else{
    powerled=RED;
    Set4LEDColor(powerled,loraled,gpsled,uwbled);
            powerled=RED;
      }      
   }else{
        if(state5v==1)
@@ -244,11 +229,6 @@
            state5v=0;
            UsartDeInit();
        }
//    powerled=LEDOFF;
//    Set4LEDColor(powerled,loraled,gpsled,uwbled);
//    gpsled=LEDOFF;
//    Set4LEDColor(powerled,loraled,gpsled,uwbled);
//   }
}
        if(g_com_map[MAP_SIGN_INDEX]!=0x55AA||g_com_map[COM_INTERVAL]==0)
      {
@@ -261,34 +241,7 @@
u16 total_slotnum,current_slotnum;
extern int32_t offsettimeus;
//u16 last_lpcount = 0;
void SetNextPollTime(u16 time)
{
  int32_t lpcount1,lptime1,target_time1;
int32_t last_lpcount1;
//   if(current_slotnum>=total_slotnum)
//      current_slotnum-=total_slotnum;
//
//   target_time=((current_slotnum*g_com_map[COM_INTERVAL])+time)*1000;
//   //if(target_time<90000)
//   {
//      lptime=target_time-offsettimeus;
//      lpcount = lptime/LPTIMER_LSB;
//   if(lpcount>LPTIMER_1S_COUNT)
//      lpcount-=LPTIMER_1S_COUNT;
//   if(lpcount<0)
//   {
//   lpcount+=LPTIMER_1S_COUNT;
//   }
    last_lpcount1=HAL_LPTIM_ReadCounter(&hlptim1);
    lpcount1 = last_lpcount1+32.768*time;
    while(lpcount1>LPTIMER_1S_COUNT)
    {
        lpcount1-=LPTIMER_1S_COUNT;
    }
//    last_lpcount = lpcount;
   __HAL_LPTIM_COMPARE_SET(&hlptim1, lpcount1+32768);
}
/* 返回ch字符在sign数组中的序号 */
int getIndexOfSigns(char ch)
@@ -324,19 +277,9 @@
    return sum;
}
    
u32 Loratx_frequency;
u8 active_flag,nomovesleeptime;
void GetLoratx_frequency(void)
{
Loratx_frequency=470000000;
srand(HAL_LPTIM_ReadCounter(&hlptim1));
        Loratx_frequency=((rand()%5)+470)*1000000;
        if(470000000<=Loratx_frequency&&Loratx_frequency<480000000)
        g_com_map[NEARBASE_ID1]=1136+(Loratx_frequency/1000000-470);
        if(480000000<=Loratx_frequency&&Loratx_frequency<490000000)
        g_com_map[NEARBASE_ID1]=1152+(Loratx_frequency/1000000-480);
Loratx_frequency=470000000;
}
void Program_Init(void)
{   float temp;
   uint16_t temp2;
@@ -356,13 +299,13 @@
//    //   g_com_map[MAX_REPORT_ANC_NUM]=1;
//    //   g_com_map[NOMOVESLEEP_TIME]=10;
//    #endif
    g_com_map[GROUP_ID]=5;
    g_com_map[GROUP_ID]=1;
//    g_com_map[COM_INTERVAL] = 1000;
    if(g_com_map[COM_INTERVAL]<1000)
    {g_com_map[COM_INTERVAL] = 1000;}
    active_flag = g_com_map[ACTIVE_INDEX];
    module_power = g_com_map[POWER];
    g_com_map[IMU_ENABLE] = 0;
//    g_com_map[IMU_ENABLE] = 0;
   imu_enable=g_com_map[IMU_ENABLE];
   motor_enable=g_com_map[MOTOR_ENABLE];
@@ -376,11 +319,11 @@
    tag_frequency = 1000/g_com_map[COM_INTERVAL];
   total_slotnum = 1000/g_com_map[COM_INTERVAL];
    nomovesleeptime = g_com_map[NOMOVESLEEP_TIME];
   if(active_flag==0)
   {
      imu_enable=1;
      nomovesleeptime =10;
   }
//   if(active_flag==0)
//   {
//      imu_enable=1;
//      nomovesleeptime =10;
//   }
 //   g_com_map[COM_INTERVAL]=100;
      if(g_com_map[COM_INTERVAL]==0)
@@ -394,10 +337,6 @@
   current_slotnum=1;
//   current_time=GetLPTime();
      if (HAL_LPTIM_TimeOut_Start_IT(&hlptim1, LPTIMER_1S_COUNT, 0) != HAL_OK)  //system time is 1010ms   1 puls=30.518us
  {
    Error_Handler();
  }
//        if (HAL_LPTIM_TimeOut_Start_IT(&hlptim1, LPTIMER_1S_COUNT, slot_startcount) != HAL_OK)  //system time is 1010ms   1 puls=30.518us
//  {
//    Error_Handler();
@@ -477,28 +416,22 @@
    if(GPIO_Pin == RADIO_DIO1_Pin)
    {
        SystemClock_Config();
//        HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_SET);
//        HAL_GPIO_WritePin(RADIO_NSS_GPIO_Port, RADIO_NSS_Pin, GPIO_PIN_RESET); //片选lora有效
//        l_bIsVibration = HIDO_TRUE;
//        nomove_time=0;
//        printf("RXD :77777\r\n");
        irq_num++;
        RadioIrqProcess();
    }
    if(GPIO_Pin == GPIO_PIN_1)//按键
    {
        SystemClock_Config();
         SystemClock_Config();
      anjian_flag=1;
    }
    if(GPIO_Pin == GPIO_PIN_0)//加速度
    {
        SystemClock_Config();
     stationary_flag =0;
        stationary_num=0;
   if(chongqi_flag==1)
   {
   HAL_NVIC_SystemReset();
   }
         SystemClock_Config();
        if(chongqi_flag==1)
        {
        HAL_NVIC_SystemReset();
        }
      nomove_count = 0;
    }
}
extern void Lora_tx_zubao( void );
@@ -508,84 +441,16 @@
extern uint16_t lora_yingda_num;
uint8_t lora_tx_flag;
uint8_t lora_txanchor_power_flag;
extern uint16_t Lora_tx_ancid[50];
extern uint16_t Lora_tx_ancdist[50];
extern uint8_t Lora_tx_anc_electricity[50];
u8 lora_seq_nb1;
static uint8_t send_frame1[EUART_RX_BUF_SIZE];
uint8_t data_length1;
void LoraSendComMap(uint8_t data_length, uint8_t index)
{
   uint16_t checksum = 0;
   send_frame1[0] = 0x55;
   send_frame1[1] = 0xAA;
   send_frame1[2] = 0x39;
   send_frame1[3] = data_length+5;
   send_frame1[4] = 3;
   send_frame1[5] = index;
   send_frame1[6] = data_length;
   memcpy(&send_frame1[7], &g_com_map[index], data_length);
   for(int i = 0; i<(data_length+5); i++)
   {
      checksum += send_frame1[2+i];
   }
   checksum = Checksum_u16(&send_frame1[2],5+data_length);
   memcpy(&send_frame1[7+data_length],&checksum,2);
   data_length1=data_length+9;
//   UART_PushFrame(send_frame1, data_length+9);
}
extern uint8_t GPSchangdu;
uint8_t no_yingdaflag;
extern  uint8_t GPS_GGAdate[200];
uint8_t GPS_GGAdate111[200]="报警";
void Lora_Tx_Poll()
{
    if(lora_tx_flag)
    {
        lora_tx_flag=0;
//        SYN_FrameInfo(0,GPS_GGAdate111);
//        while(1);
       if(du_flag==1)
       {
    Lora47X_Init();
    du_flag=0;
    Radio.Send( send_frame1, data_length1);
        no_yingdaflag=1;
       }
       else
       {
        Lora47X_Init();
        if(bat_percent>20)
        {
    loraled=BLUE;
//    Set4LEDColor(powerled,loraled,gpsled,uwbled);
        }
        else
        {
    loraled=RED;
//    Set4LEDColor(powerled,loraled,gpsled,uwbled);
        }
    lora_seq_nb2++;
    Lora_tx_zubao();
    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;
        //        delay_ms(10);
//            loraled=LEDOFF;
//    Set4LEDColor(powerled,loraled,gpsled,uwbled);
//        HAL_UART_Transmit(&huart1,usart_send,15+Lora_tx_ancnum*4+GPSchangdu,3000);
       }
    }
}
void MX_ADC1_Init()
{
MX_ADC_Init();
    MX_ADC_Init();
}
void GPS_Close_Init()
{
@@ -610,35 +475,33 @@
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 GPSchangdu;
uint8_t GPS_GGAdate[200]={1,2,3,4,5,6,7,8,9};
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) 
{
    {
    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(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(GPSchangdu>40)
        {
            gpsled=BLUE;
//    Set4LEDColor(powerled,loraled,gpsled,uwbled);
        }
        else
        {
            gpsled=RED;
//    Set4LEDColor(powerled,loraled,gpsled,uwbled);
        }
    }
//        GPS_RecvFsm(GPSRxBuffer[0]);
        GPS_Recv_Poll(GPSRxBuffer[0]);
//    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(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(GPSchangdu>40)
//        {
//            gpsled=BLUE;
//        }
//        else
//        {
//            gpsled=RED;
//        }
//    }
    HAL_UART_Receive_IT(&hlpuart1, (uint8_t *)GPSRxBuffer, 1);
    }
}
@@ -661,13 +524,6 @@
    HAL_UART_Receive_IT(&hlpuart1, (uint8_t *)GPSRxBuffer, 1);
//    HAL_UART_Transmit(&hlpuart1,ble_rxdate,2,1000);
}
//void GPS_rx_Poll()
//{
//  if(ble_rx_success_flag)
//  {
//  ble_rx_success_flag=0;
//  }
//}
extern uint8_t  yuyin_no_sleep_flag;
extern uint8_t yuyin_sendflag;
extern uint8_t xiafayuyin_data[200];
@@ -678,8 +534,8 @@
    if(yuyin_sendflag)
    {
    yuyin_sendflag=0;
    SYN_FrameInfo(0,yuyin_yinliang);//设置音量等级V10
    delay_ms(10);
  //  SYN_FrameInfo(0,yuyin_yinliang);//设置音量等级V10
   // delay_ms(10);
    SYN_FrameInfo(0,xiafayuyin_data); //播放内容
//    HAL_UART_Receive_IT(&huart6, &Get_Uart6_data, 1);
    memset(xiafayuyin_data,0,sizeof(xiafayuyin_data)); 
@@ -711,15 +567,16 @@
          }
      }
}
uint8_t usart5_state;
uint8_t gotosleep_flag;
uint8_t usart5_state,flag_onesecond;
void Jingzhi_Poll(void)
{
          powerled=LEDOFF;
          loraled=LEDOFF;
          gpsled=LEDOFF;
          uwbled=LEDOFF;
      HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET); //GuanGPS and lora 电源
      HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET); //guan uwb 电源
          HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET); //GuanGPS and lora 电源
          HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET); //guan uwb 电源
          HAL_SPI_DeInit(&hspi1);
          HAL_GPIO_WritePin( RADIO_NSS_GPIO_Port, RADIO_NSS_Pin,GPIO_PIN_RESET);//lora  cs
          HAL_GPIO_WritePin( GPIOA, GPIO_PIN_4,GPIO_PIN_RESET);//uwb cs
@@ -727,13 +584,37 @@
          Usart5DeInit();
          LpusartDeInit();
          HAL_ADC_DeInit(&hadc);
//          __HAL_RCC_GPIOA_CLK_DISABLE();
//          __HAL_RCC_GPIOB_CLK_DISABLE();
//          __HAL_RCC_GPIOC_CLK_DISABLE();
//          __HAL_RCC_GPIOD_CLK_DISABLE();
//          __HAL_RCC_GPIOE_CLK_DISABLE();
          Set4LEDColor_Off(); //关led总电源
          chongqi_flag=1;
}
void OneSecondTask(void)
{
    if(flag_onesecond==1)
    {
        flag_onesecond = 0;
    }
}
uint8_t debugnum;
uint8_t Lora_send_flag;
void Lora_Send_Poll(void)
{
        if(Lora_send_flag)
        {
            debugnum++;
        Lora_send_flag=0;
//        LedTask();
            loraled=BLUE;
        LoraReportPoll();
        flag_onesecond = 1;
          powerled=LEDOFF;
//          loraled=LEDOFF;
          gpsled=LEDOFF;
          uwbled=LEDOFF;
//Set4LEDColor_Off();
        }
}
/* USER CODE END 0 */
@@ -781,31 +662,33 @@
//delay_ms(1000);
    Program_Init();
    LIS3DH_Data_Init();
#ifdef _USE_BAR
BarInit();
#endif
    Dw1000_Init();
    Dw1000_App_Init();
    //   HardWareTypeDiffConfig();
    dwt_configuresleep(DWT_PRESRV_SLEEP | DWT_CONFIG, DWT_WAKE_CS | DWT_WAKE_WK| DWT_SLP_EN);
    dwt_entersleep();
     if(HAL_UART_Receive_DMA(&huart1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE))
    {
     Error_Handler();
    }
    Delay_Ms(2);
    Delay_Ms(10);
    bat_percent=Get_VDDVlotage();
    GetLoratx_frequency();
    delay_ms(2000);
    GPS_Close_Init();
    LIS3DH_Data_Init();
    delay_ms(1000);
    GPS_Close_Init();
    HAL_UART_Receive_IT(&hlpuart1, (uint8_t *)GPSRxBuffer, 1);
    Set4LEDColor(RED,RED,RED,RED);
    HAL_Delay(500);
    Set4LEDColor(GREEN,GREEN,GREEN,GREEN);
    HAL_Delay(500);
    Set4LEDColor_Off();
//    Lora47X_Init();
//    Radio.Sleep();
    HAL_Delay(500);
    LoraInit();
    if (HAL_LPTIM_TimeOut_Start_IT(&hlptim1, LPTIMER_1S_COUNT, 0) != HAL_OK)  //system time is 1010ms   1 puls=30.518us
  {
    Error_Handler();
  }
  /* USER CODE END 2 */
  /* Infinite loop */
@@ -815,27 +698,17 @@
    /* USER CODE END WHILE */
    /* USER CODE BEGIN 3 */
//Lora_rx_open();
//      Lora_Tx_Poll();
      if(stationary_flag==1)
      if(gotosleep_flag==1)
      {
          Jingzhi_Poll();
          HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
      }
      else
      {
      Lora_Tx_Poll();
          IdleTask();
      TTSchaxun_Busy();
      OneSecondTask();
      IdleTask();
      PowerDownDetect();
//      Ble_rx_Poll();
//    HAL_IWDG_Refresh(&hiwdg);
//      Lora_rece_error=0;
//   Radio.IrqProcess( ); // Process Radio IRQ
//     Anchor_App();
      Lora_Send_Poll();
    #ifndef DEBUG_MODE   
    if(!HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin))   
  {      
@@ -856,7 +729,7 @@
          }
  }
    #endif
    }
      }
  }
  /* USER CODE END 3 */
}
@@ -947,7 +820,7 @@
  hadc.Init.OversamplingMode = DISABLE;
  hadc.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
  hadc.Init.Resolution = ADC_RESOLUTION_12B;
  hadc.Init.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
  hadc.Init.SamplingTime = ADC_SAMPLETIME_160CYCLES_5;
  hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;
  hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  hadc.Init.ContinuousConvMode = DISABLE;
@@ -969,14 +842,6 @@
  */
  sConfig.Channel = ADC_CHANNEL_1;
  sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;
  if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
  {
    Error_Handler();
  }
  /** Configure for the selected ADC regular channel to be converted.
  */
  sConfig.Channel = ADC_CHANNEL_VREFINT;
  if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
  {
    Error_Handler();
@@ -1215,9 +1080,6 @@
  __HAL_RCC_DMA1_CLK_ENABLE();
  /* DMA interrupt init */
  /* DMA1_Channel1_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
  /* DMA1_Channel2_3_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(DMA1_Channel2_3_IRQn, 1, 0);
  HAL_NVIC_EnableIRQ(DMA1_Channel2_3_IRQn);
@@ -1307,7 +1169,7 @@
  /*Configure GPIO pins : SCL_Pin SDA_Pin */
  GPIO_InitStruct.Pin = SCL_Pin|SDA_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
@@ -1341,7 +1203,7 @@
  HAL_NVIC_SetPriority(EXTI0_1_IRQn, 2, 0);
  HAL_NVIC_EnableIRQ(EXTI0_1_IRQn);
  HAL_NVIC_SetPriority(EXTI4_15_IRQn, 2, 0);
  HAL_NVIC_SetPriority(EXTI4_15_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);
}
@@ -1378,74 +1240,35 @@
uint8_t lora_yingdatime;
extern uint8_t lora_chongfuyingda_flag;
uint16_t no_data_chongqi_num;
uint16_t anchor_send_num;
uint8_t no_yingdatime;
#define YUYINSTOP_TIME 10
void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim)
{
//    uint8_t pinlv;
    SystemClock_Config();
    lp_time++;
    anchor_send_num++;
    no_data_chongqi_num++;
    stationary_num++;
    Set4LEDColor(powerled,loraled,gpsled,uwbled);
//    if(Beepchixutime>0)
//    {
//        Beepchixutime--;
//        if(Beepchixutime==0)
//        {Beep_Off();}
//    }
    if(no_yingdaflag==1)
    {
    no_yingdatime++;
        if(no_yingdatime>=5)
        {
            no_yingdaflag=0;
            no_yingdatime=0;
        }
    }
    if( no_data_chongqi_num>600)
    {NVIC_SystemReset();}
    SetNextPollTime(0);
//    if(lora_yingda_flag)
//    {
//    lora_yingdatime++;
//        if(lora_yingdatime>=2)
//        {lora_yingdatime=0;
//        lora_yingda_flag=0;
//          Lora_tx_mode();
//            Radio.Send( usart_send, 2);
//        }
//    }
//    else
//    {
//    pinlv=g_com_map[COM_MAP_SIZE]/1000;
    if(lp_time%(g_com_map[COM_INTERVAL]/1000)==0)
    {
    lora_tx_flag=1;
    lora_txanchor_power_flag=0;
//    }
    if(anchor_send_num>=3600)
    {anchor_send_num=0;
    lora_txanchor_power_flag=1;
        lora_tx_flag=0;
        bat_percent=Get_VDDVlotage();
    }
    }
    if(stationary_num>=30)
    {stationary_num=0;
    stationary_flag=1;
    }
    HAL_IWDG_Refresh(&hiwdg);
Set4LEDColor(powerled,loraled,gpsled,uwbled);
    yuyinzidongguan_time++;
    if(yuyinzidongguan_time>10)
    if(yuyinzidongguan_time>YUYINSTOP_TIME)
    {
    yuyinzidongguan_time=0;
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET);
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_12, GPIO_PIN_RESET); 
    yuyin_no_sleep_flag=0;
    }
    Lora_send_flag=1;
    if(nomove_count++>g_com_map[STATIONARY_TIME])
    {
        stationary_flag = 1;
    } else {
        stationary_flag = 0;
    }
    if(nomove_count>=g_com_map[NOMOVESLEEP_TIME]-1&&imu_enable)
    {
        gotosleep_flag=1;
    } else {
        gotosleep_flag=0;
    }
}
/* USER CODE END 4 */