| | |
| | | |
| | | #define NSH1 0x0001 |
| | | #define GP 0x0002 |
| | | //#define DEBUG_MODE |
| | | #define DEBUG_MODE |
| | | /* USER CODE END Includes */ |
| | | |
| | | /* Private typedef -----------------------------------------------------------*/ |
| | |
| | | //motor_state = 1; |
| | | if(g_com_map[MOTOR_ENABLE]) |
| | | { |
| | | static u8 motor5s_state = 0; |
| | | static u8 motor5s_state = 0,outside_count=0; |
| | | if(motorskip_flag==0) |
| | | { |
| | | if(motor_state==1) |
| | | if(motor_state==2) |
| | | { |
| | | outside_count =0; |
| | | if(motor5s_state) |
| | | { |
| | | if(motor5s_timer>4) |
| | |
| | | } |
| | | } |
| | | }else{ |
| | | motor5s_state = 1; |
| | | motor5s_timer = 0; |
| | | if(outside_count++>3) |
| | | { |
| | | motor5s_state = 1; |
| | | motor5s_timer = 0; |
| | | } |
| | | } |
| | | }else{ |
| | | if(motor5s_timer>7200) //2个小时 7200 |
| | |
| | | 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] = (2<<8)|4; |
| | | g_com_map[VERSION] = (2<<8)|8; |
| | | |
| | | // g_com_map[DEV_ID]=0x7; |
| | | #ifdef DEBUG_MODE |
| | | // g_com_map[DEV_ROLE]=1; |
| | | g_com_map[DEV_ID]=0x4009; |
| | | // g_com_map[DEV_ID]=0x4009; |
| | | // g_com_map[ACTIVE_INDEX]=1; |
| | | // g_com_map[COM_INTERVAL]=50; |
| | | // g_com_map[MAX_REPORT_ANC_NUM]=1; |
| | |
| | | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
| | | HAL_GPIO_Init(BAT_MEAS_GND_GPIO_Port, &GPIO_InitStruct); |
| | | |
| | | /*Configure GPIO pin : USER_KEY_Pin */ |
| | | GPIO_InitStruct.Pin = USER_KEY_Pin; |
| | | /*Configure GPIO pins : USER_KEY_Pin PB14 */ |
| | | GPIO_InitStruct.Pin = USER_KEY_Pin|GPIO_PIN_14; |
| | | GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; |
| | | GPIO_InitStruct.Pull = GPIO_PULLUP; |
| | | HAL_GPIO_Init(USER_KEY_GPIO_Port, &GPIO_InitStruct); |
| | | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| | | |
| | | /*Configure GPIO pin : INPUT_5V_Pin */ |
| | | GPIO_InitStruct.Pin = INPUT_5V_Pin; |
| | |
| | | /* EXTI interrupt init*/ |
| | | HAL_NVIC_SetPriority(EXTI0_1_IRQn, 1, 0); |
| | | HAL_NVIC_EnableIRQ(EXTI0_1_IRQn); |
| | | |
| | | HAL_NVIC_SetPriority(EXTI4_15_IRQn, 1, 0); |
| | | HAL_NVIC_EnableIRQ(EXTI4_15_IRQn); |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | if(!GET_USERKEY) |
| | | if(!GET_USERKEY||!HAL_GPIO_ReadPin(USER_KEY_GPIO_Port,GPIO_PIN_14)) |
| | | { |
| | | key_keeptime+=lptimedelay; |
| | | if(key_keeptime>=3) |
| | | { |
| | | JianXieMotorProcess(); |
| | | userkey_state = 1; |
| | | } |
| | | if(key_keeptime>=KEY_KEEPRESET_TIME) |