zhyinch
2020-12-23 f520882cbe60829964cbed519ce4fb0484f90cd9
Src/main.c
@@ -135,8 +135,7 @@
            MOTOR_ON;      
         }else{
            MOTOR_OFF;   
         }
         }
         break;
      case 2:
         MOTOR_ON;   
@@ -210,8 +209,8 @@
u16 current_slotnum;
extern int32_t offsettimeus;
#define FIXSLOT
#define FIXSLOTPOS  1
//#define FIXSLOT
#define FIXSLOTPOS  2
u16 slotpos_intoatl;
uint16_t bigslot_num;
uint8_t fix_slotpos =FIXSLOTPOS; 
@@ -221,13 +220,14 @@
{
#ifdef FIXSLOT
   fix_slotpos =0;// g_com_map[ALARM_DISTANCE1];
//   fix_slotpos =FIXSLOTPOS;
   fix_slotpos = g_com_map[ALARM_DISTANCE1];
   slotpos = fix_slotpos;
   tagslotpos = fix_slotpos;
#endif
   if(current_slotnum>=tag_frequency)
      current_slotnum-=tag_frequency;
   while(current_slotnum>=tag_frequency)
   {   current_slotnum-=tag_frequency;}
   slotpos_intoatl = current_slotnum*bigslot_num+slotpos;
   if(current_slotnum==19)
@@ -236,7 +236,7 @@
   
   //if(target_time<90000)
   {
      lptime=target_time-offsettimeus-10000;
      lptime=target_time-offsettimeus+1200;
      lpcount = lptime/LPTIMER_LSB;
   if(lpcount>LPTIMER_1S_COUNT)
      lpcount-=LPTIMER_1S_COUNT;
@@ -255,7 +255,8 @@
   Usart1ParseDataCallback = UsartParseDataHandler;
   parameter_init();
   //deca_sleep(1000);
   g_com_map[VERSION] = 0x020f;
   g_com_map[VERSION] = 0x0212;
//   g_com_map[DEV_ID]=0x11;
#ifdef DEBUG_MODE
//   g_com_map[DEV_ROLE]=1;
   //   g_com_map[DEV_ID]=0x11;
@@ -267,7 +268,7 @@
#endif
//g_com_map[NOMOVESLEEP_TIME]=10;
//   g_com_map[IMU_ENABLE]=0;
//    g_com_map[COM_INTERVAL]=50;
//    g_com_map[COM_INTERVAL]=1000;
   active_flag = g_com_map[ACTIVE_INDEX];
   if(active_flag==0)
   { g_com_map[COM_INTERVAL]=1000;
@@ -306,9 +307,9 @@
    Error_Handler();
  }
//g_com_map[NOMOVESLEEP_TIME]=5;
   printf("标签ID: %d .\r\n",dev_id);
   printf("通讯间隔: %d ms.\r\n",g_com_map[COM_INTERVAL]);
   printf("单次通讯基站数量: %d个.\r\n",g_com_map[MAX_REPORT_ANC_NUM]);
//   printf("标签ID: %d .\r\n",dev_id);
//   printf("通讯间隔: %d ms.\r\n",g_com_map[COM_INTERVAL]);
//   printf("单次通讯基站数量: %d个.\r\n",g_com_map[MAX_REPORT_ANC_NUM]);
   
//   printf("DEVICE PAIRID: %d .\r\n",g_com_map[PAIR_ID]);
@@ -671,16 +672,16 @@
    Error_Handler();
  }
  /* USER CODE BEGIN USART1_Init 2 */
       GPIO_InitStruct.Pin = GPIO_PIN_9;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_PULLUP;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF4_USART1;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  if(HAL_UART_Receive_IT(&huart1, (uint8_t *)aRxBuffer, 1) != HAL_OK)
  {
    Error_Handler();
  }
//       GPIO_InitStruct.Pin = GPIO_PIN_9;
//    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
//    GPIO_InitStruct.Pull = GPIO_PULLUP;
//    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
//    GPIO_InitStruct.Alternate = GPIO_AF4_USART1;
//    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
//  if(HAL_UART_Receive_IT(&huart1, (uint8_t *)aRxBuffer, 1) != HAL_OK)
//  {
//    Error_Handler();
//  }
   Usart1InitVariables();
  /* USER CODE END USART1_Init 2 */
@@ -829,7 +830,7 @@
}
extern u16 tagslotpos;
extern uint8_t tx_near_msg[80],stationary_flag,gotosleep_flag;
float key_keeptime;
float key_keeptime,motor_keeptime;
extern float motor_ontime;
void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim)
{
@@ -839,6 +840,13 @@
   current_slotnum++;
   SetNextPollTime(tagslotpos);
   nomove_count+=(float)g_com_map[COM_INTERVAL]/1000;
   if(motor_keeptime>0)
   {
      motor_state = 2;
   motor_keeptime-=(float)g_com_map[COM_INTERVAL]/1000;
   }else{
      motor_state = 0;
   }
   if(active_flag==0)
   {
   if(!GET_USERKEY)