| | |
| | | float motor_keeptime; |
| | | void IdleTask(void) |
| | | {u16 current_time; |
| | | if(huart1.Instance->ISR&USART_ISR_FE) |
| | | { |
| | | SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader |
| | | } |
| | | //if(huart1.Instance->ISR&USART_ISR_FE) |
| | | // { |
| | | // SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader |
| | | // } |
| | | if(HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)) |
| | | { |
| | | |
| | |
| | | LED_LG_OFF; |
| | | // } |
| | | } |
| | | if(g_com_map[MAP_SIGN_INDEX]!=0x55AA||g_com_map[COM_INTERVAL]==0) |
| | | if(g_com_map[MAP_SIGN_INDEX]!=0x55AA||g_com_map[COM_INTERVAL]==0) |
| | | { |
| | | SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader |
| | | SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader |
| | | } |
| | | |
| | | } |
| | |
| | | // { |
| | | // lpcount+=LPTIMER_1S_COUNT; |
| | | // } |
| | | lpcount = last_lpcount+32768/tag_frequency; |
| | | lpcount = last_lpcount+32768/tag_frequency-time*LPTIMER_LSB; |
| | | while(lpcount>LPTIMER_1S_COUNT) |
| | | { |
| | | lpcount-=LPTIMER_1S_COUNT; |
| | |
| | | |
| | | void HardWareTypeDiffConfig(void) |
| | | { |
| | | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
| | | //hardware_type=2; |
| | | if(hardware_type == 0) |
| | | hardware_type = 1; |
| | | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
| | | //hardware_type=2; |
| | | if(hardware_type == 0) |
| | | hardware_type = 1; |
| | | switch(hardware_type) |
| | | { |
| | | case 1: |
| | | |
| | | HAL_GPIO_WritePin(GPIOB, MOTOR_Pin, GPIO_PIN_SET); |
| | | GPIO_InitStruct.Pin = MOTOR_Pin; |
| | | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
| | | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| | | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
| | | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| | | GPIO_InitStruct.Pin = MOTOR_Pin; |
| | | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
| | | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| | | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
| | | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| | | break; |
| | | case 2: |
| | | MX_TIM2_Init(); |
| | |
| | | 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)|47; |
| | | g_com_map[VERSION] = (1<<8)|58; |
| | | |
| | | #ifdef DEBUG_MODE |
| | | // g_com_map[GROUP_ID]=21; |
| | | // g_com_map[GROUP_ID]=21; |
| | | // g_com_map[DEV_ID]=4; |
| | | // g_com_map[COM_INTERVAL]=100; |
| | | // g_com_map[MAX_REPORT_ANC_NUM]=1; |
| | | // g_com_map[NOMOVESLEEP_TIME]=10; |
| | | #endif |
| | | |
| | | g_com_map[GROUP_ID]=2; |
| | | 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; |
| | | imu_enable=g_com_map[IMU_ENABLE]; |
| | | motor_enable=g_com_map[MOTOR_ENABLE]; |
| | | |
| | |
| | | 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("固件版本: 免布线基站 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff); |
| | | memcpy(g_com_map2,g_com_map,COM_MAP_SIZE); |
| | | // printf("DEVICE PAIRID: %d .\r\n",g_com_map[PAIR_ID]); |
| | | // printf("DEVICE ALARM DISTANCE: 1.%d 2.%d 3.%d .\r\n",g_com_map[ALARM_DISTANCE1],g_com_map[ALARM_DISTANCE2],g_com_map[ALARM_DISTANCE3]); |
| | | |
| | |
| | | } |
| | | if(m_bEUARTTxEn==0&&waitusart_timer==0) |
| | | { |
| | | if(memcmp(g_com_map2,g_com_map,COM_MAP_SIZE)!=0) |
| | | if(memcmp(g_com_map2,g_com_map,200)!=0) |
| | | { |
| | | SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; |
| | | } |
| | |
| | | } |
| | | extern uint8_t tx_near_msg[80],stationary_flag; |
| | | float key_keeptime; |
| | | extern float freqlost_count; |
| | | extern float freqlost_count,range_lost_time; |
| | | void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim) |
| | | { |
| | | static uint8_t i=0; |
| | |
| | | g_start_send_flag=1; |
| | | current_slotnum++; |
| | | freqlost_count+=1/(float)tag_frequency; |
| | | range_lost_time +=1/(float)tag_frequency; |
| | | |
| | | if(freqlost_count>FREQ_LOST_TIME) |
| | | { |
| | | tag_frequency = NOTAG_FREQ; |
| | | } |
| | | SetNextPollTime(tyncpoll_time); |
| | | if(range_lost_time<1||freqlost_count>FREQ_LOST_TIME) |
| | | { |
| | | SetNextPollTime(0); |
| | | }else{ |
| | | SetNextPollTime(5); |
| | | } |
| | | nomove_count+=1/(float)tag_frequency; |
| | | if(motor_keeptime>0) |
| | | { |