yincheng.zhong
2024-01-29 4691492f913d0730703f8fcdacd0a02d455d65a1
Src/main.c
@@ -33,7 +33,7 @@
#define NSH1 0x0001
#define GP   0x0002
#define FLASH_HARDWARE_VERSION_MAP      (uint32_t)0x08004F00    //硬件版本号和批次信息位置
//#define DEBUG_MODE
#define DEBUG_MODE
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -289,7 +289,7 @@
    hardware_pici = STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+2);
    hardware_type = STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+4);
    //deca_sleep(1000);
    g_com_map[VERSION] = (1<<8)|39;
    g_com_map[VERSION] = (1<<8)|7;
    active_flag = g_com_map[ACTIVE_INDEX];
    module_power = g_com_map[POWER];
    imu_enable=g_com_map[IMU_ENABLE];
@@ -303,7 +303,7 @@
    slot_startcount=tyncpoll_time*1000/LPTIMER_LSB;
    lastpoll_time=tyncpoll_time;
    tag_frequency = 1000/g_com_map[COM_INTERVAL];
    bigslot_num = TOTAL_SLOTNUM/tag_frequency;
//    bigslot_num = TOTAL_SLOTNUM/tag_frequency;
    total_slotnum = 1000/g_com_map[COM_INTERVAL];
    nomovesleeptime = g_com_map[NOMOVESLEEP_TIME];
    if(active_flag==0)
@@ -909,6 +909,8 @@
}
extern uint8_t tx_near_msg[80],stationary_flag;
float key_keeptime;
uint16_t current_count1;
uint16_t lpcount1;
void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim)
{
    static uint8_t i=0;
@@ -916,6 +918,16 @@
    g_start_send_flag=1;
    current_slotnum++;
//   SetNextPollTime(tyncpoll_time);
    current_count1=HAL_LPTIM_ReadCounter(&hlptim1);
    lpcount1 = current_count1+32.768*g_com_map[COM_INTERVAL];;
    if(lpcount1>=32768)
    {
        lpcount1 -=32768;
    }
    __HAL_LPTIM_COMPARE_SET(&hlptim1, lpcount1);
    nomove_count+=(float)g_com_map[COM_INTERVAL]/1000;
    if(motor_keeptime>0)
    {
@@ -943,7 +955,7 @@
    }
    if(nomove_count>=nomovesleeptime-1&&imu_enable)
    {
        tx_near_msg[TAGSTATE] = tx_near_msg[TAGSTATE]|GOINGSLEEPBIT;
//        tx_near_msg[TAGSTATE] = tx_near_msg[TAGSTATE]|GOINGSLEEPBIT;
    }
    if(nomove_count>nomovesleeptime&&imu_enable)
    {