2020-12-17 18:22:19 +08:00
|
|
|
/*
|
|
|
|
* @Description:
|
|
|
|
* @Date: 2020-04-17 13:16:16
|
|
|
|
* @LastEditors: CK.Zh
|
|
|
|
* @LastEditTime: 2020-12-17 17:29:07
|
|
|
|
* @FilePath: \NaviKit_stm32\Core\Src\navikit.c
|
|
|
|
*/
|
2020-04-17 15:55:14 +08:00
|
|
|
/*
|
|
|
|
* navikit.c
|
|
|
|
*
|
|
|
|
* Created on: Apr 17, 2020
|
|
|
|
* Author: oarap
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "navikit.h"
|
|
|
|
NaviKit_t NaviKit;
|
2020-04-27 16:58:16 +08:00
|
|
|
void NaviKit_var_init()
|
|
|
|
{
|
2020-07-15 18:26:22 +08:00
|
|
|
NaviKit.sys.sta = shutdown;
|
2020-08-05 19:22:37 +08:00
|
|
|
NaviKit.sys.next_sta = shutdown;
|
2020-04-27 16:58:16 +08:00
|
|
|
}
|
2020-08-25 19:33:15 +08:00
|
|
|
|
|
|
|
void Beep(uint32_t time_ms)
|
|
|
|
{
|
|
|
|
HAL_GPIO_WritePin(SYS_BUZZ_CTL_GPIO_Port,SYS_BUZZ_CTL_Pin, GPIO_PIN_RESET);
|
|
|
|
HAL_Delay(time_ms>>1);
|
|
|
|
HAL_GPIO_WritePin(SYS_BUZZ_CTL_GPIO_Port,SYS_BUZZ_CTL_Pin, GPIO_PIN_SET);
|
|
|
|
HAL_Delay(time_ms>>1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
|
|
|
|
{
|
|
|
|
if(hadc->Instance == ADC1)
|
|
|
|
{
|
2020-12-16 10:47:18 +08:00
|
|
|
float adc_17_voltage = 1.2 / NaviKit.pmb.rails.adc[1];//reference voltage
|
2020-08-26 18:13:51 +08:00
|
|
|
|
|
|
|
NaviKit.pmb.rails.out_24v = (float)(adc_17_voltage * NaviKit.pmb.rails.adc[2] * 16);
|
|
|
|
NaviKit.pmb.rails.out_5v = (float)(adc_17_voltage * NaviKit.pmb.rails.adc[3] * 8);
|
|
|
|
NaviKit.pmb.rails.out_12v = (float)(adc_17_voltage * NaviKit.pmb.rails.adc[4] * 8);
|
|
|
|
NaviKit.pmb.rails.bkp_bat = (float)(adc_17_voltage * NaviKit.pmb.rails.adc[5] * 8);
|
|
|
|
NaviKit.pmb.rails.main_pwr = (float)(adc_17_voltage * NaviKit.pmb.rails.adc[6] * 16);
|
2020-08-25 19:33:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-26 18:13:51 +08:00
|
|
|
void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc)
|
|
|
|
{
|
|
|
|
HAL_ADCEx_Calibration_Start(&hadc1);
|
|
|
|
}
|
2020-08-25 19:33:15 +08:00
|
|
|
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|
|
|
{
|
|
|
|
if(GPIO_Pin == SOM_SHUTDOWN_REQ_Pin)
|
|
|
|
{
|
2020-09-01 18:38:53 +08:00
|
|
|
if(HAL_GPIO_ReadPin(SOM_SHUTDOWN_REQ_GPIO_Port, SOM_SHUTDOWN_REQ_Pin)==GPIO_PIN_RESET)
|
|
|
|
{//falling edge trigger
|
2020-09-02 18:45:43 +08:00
|
|
|
if(NaviKit.sys.sta == running)
|
2020-09-07 18:50:29 +08:00
|
|
|
{//if jetson nano shutdown output low,the power_en should be set low less than 10us
|
|
|
|
HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port ,SOM_POWER_EN_Pin, GPIO_PIN_RESET);
|
|
|
|
NaviKit.sys.next_sta = shutdown;
|
2020-12-17 18:22:19 +08:00
|
|
|
Log(info,"som request to shutdown");
|
2020-08-25 19:33:15 +08:00
|
|
|
}
|
2020-09-07 18:50:29 +08:00
|
|
|
NaviKit.som.shutdown_req = true;
|
|
|
|
}
|
|
|
|
else{//Rising edge trigger
|
|
|
|
NaviKit.som.shutdown_req = false;
|
2020-08-25 19:33:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(GPIO_Pin == SYS_POWER_BTN_Pin)
|
|
|
|
{
|
|
|
|
if(HAL_GPIO_ReadPin(SYS_POWER_BTN_GPIO_Port, SYS_POWER_BTN_Pin)==GPIO_PIN_SET)
|
|
|
|
{//Rising edge trigger
|
|
|
|
NaviKit.sys.power_btn = true;
|
2020-12-17 18:22:19 +08:00
|
|
|
Log(debug,"power_btn pushed");
|
2020-12-18 12:46:59 +08:00
|
|
|
if(NaviKit.sys.sta==shutdown){
|
|
|
|
// osEnterRuningState();
|
|
|
|
}
|
2020-08-25 19:33:15 +08:00
|
|
|
}
|
|
|
|
if(HAL_GPIO_ReadPin(SYS_POWER_BTN_GPIO_Port, SYS_POWER_BTN_Pin)==GPIO_PIN_RESET)
|
|
|
|
{//falling edge trigger
|
|
|
|
NaviKit.sys.power_btn = false;
|
2020-12-17 18:22:19 +08:00
|
|
|
Log(debug,"power_btn released");
|
2020-08-25 19:33:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(GPIO_Pin == SYS_CUSTOM_BTN_Pin)
|
|
|
|
{
|
|
|
|
if(HAL_GPIO_ReadPin(SYS_CUSTOM_BTN_GPIO_Port, SYS_CUSTOM_BTN_Pin)==GPIO_PIN_SET)
|
|
|
|
{//Rising edge trigger
|
|
|
|
NaviKit.sys.custom_btn = false;
|
2020-12-17 18:22:19 +08:00
|
|
|
Log(debug,"custom_btn released");
|
2020-08-25 19:33:15 +08:00
|
|
|
}
|
|
|
|
if(HAL_GPIO_ReadPin(SYS_CUSTOM_BTN_GPIO_Port, SYS_CUSTOM_BTN_Pin)==GPIO_PIN_RESET)
|
|
|
|
{//falling edge trigger
|
|
|
|
NaviKit.sys.custom_btn = true;
|
2020-12-17 18:22:19 +08:00
|
|
|
Log(debug,"custom_btn pushed");
|
2020-08-25 19:33:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-12-18 12:46:59 +08:00
|
|
|
__weak void osEnterRuningState(){}
|
|
|
|
__weak void osEnterSleepState(){}
|
2020-08-26 18:13:51 +08:00
|
|
|
|
|
|
|
//write "bios update flag" to bkp register, and reset system
|
|
|
|
void enter_isp_state()
|
|
|
|
{
|
|
|
|
RTC_HandleTypeDef hrtc;
|
|
|
|
|
|
|
|
hrtc.Instance = RTC;
|
|
|
|
|
|
|
|
__HAL_RCC_PWR_CLK_ENABLE();
|
|
|
|
__HAL_RCC_BKP_CLK_ENABLE();
|
|
|
|
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_HSE_DIV128);
|
|
|
|
__HAL_RCC_RTC_ENABLE();
|
|
|
|
HAL_PWR_EnableBkUpAccess();
|
|
|
|
|
|
|
|
HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR1,0x32f2);
|
|
|
|
|
|
|
|
HAL_Delay(10);
|
|
|
|
if(HAL_RTCEx_BKUPRead(&hrtc,RTC_BKP_DR1) == 0x32f2)
|
|
|
|
{//write successful
|
2020-09-01 18:38:53 +08:00
|
|
|
Beep(500);
|
|
|
|
Beep(500);
|
2020-08-26 18:13:51 +08:00
|
|
|
Beep(500);
|
|
|
|
Beep(500);
|
|
|
|
Beep(500);
|
2020-12-17 18:22:19 +08:00
|
|
|
Log(info,"Enter to EC update state.");
|
|
|
|
Log(info,"System will reboot ,then run ISP automatic.");
|
2020-08-26 18:13:51 +08:00
|
|
|
HAL_NVIC_SystemReset();
|
|
|
|
}
|
|
|
|
else{
|
2020-12-17 18:22:19 +08:00
|
|
|
Log(error,"Backup register writen error, can not enter EC update state.");
|
2020-08-26 18:13:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-07 18:50:29 +08:00
|
|
|
//timeout:the time of wait
|
2020-09-07 18:53:33 +08:00
|
|
|
void enter_shutdown_state()
|
2020-08-26 18:13:51 +08:00
|
|
|
{
|
2020-12-17 18:22:19 +08:00
|
|
|
Log(info,"Enter to shutdown state");
|
2020-08-26 18:13:51 +08:00
|
|
|
Beep(50);
|
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port ,SOM_POWER_EN_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(SOC_U3_HUB_PWR_CTL_GPIO_Port,SOC_U3_HUB_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SOC_U2_HUB_PWR_CTL_GPIO_Port,SOC_U2_HUB_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SOC_U3_HOST_PWR_CTL_GPIO_Port,SOC_U3_HOST_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SOC_GE_SW_PWR_CTL_GPIO_Port,SOC_GE_SW_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SOC_U3_GEC_PWR_CTL_GPIO_Port,SOC_U3_GEC_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_6_GPIO_Port,USB3_VBUS_CTL_6_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_5_GPIO_Port,USB3_VBUS_CTL_5_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(SYS_FAN_CTL_1_GPIO_Port,SYS_FAN_CTL_1_Pin,GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SYS_FAN_CTL_2_GPIO_Port,SYS_FAN_CTL_2_Pin,GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SYS_FAN_CTL_3_GPIO_Port,SYS_FAN_CTL_3_Pin,GPIO_PIN_RESET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(PMB_PS_ON_GPIO_Port ,PMB_PS_ON_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-12-18 12:46:59 +08:00
|
|
|
MX_USB_DEVICE_DeInit();
|
2020-08-26 18:13:51 +08:00
|
|
|
}
|
2020-09-07 18:50:29 +08:00
|
|
|
|
2020-08-26 18:13:51 +08:00
|
|
|
void enter_sleep_state()
|
|
|
|
{
|
2020-12-17 18:22:19 +08:00
|
|
|
Log(info,"Enter to sleep state");
|
2020-08-26 18:13:51 +08:00
|
|
|
Beep(50);
|
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
// HAL_GPIO_WritePin(SOC_U3_HUB_PWR_CTL_GPIO_Port,SOC_U3_HUB_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SOC_U2_HUB_PWR_CTL_GPIO_Port,SOC_U2_HUB_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
// HAL_GPIO_WritePin(SOC_U3_HOST_PWR_CTL_GPIO_Port,SOC_U3_HOST_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SOC_GE_SW_PWR_CTL_GPIO_Port,SOC_GE_SW_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
// HAL_GPIO_WritePin(SOC_U3_GEC_PWR_CTL_GPIO_Port,SOC_U3_GEC_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
|
|
|
|
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
// HAL_GPIO_WritePin(USB3_VBUS_CTL_6_GPIO_Port,USB3_VBUS_CTL_6_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
// HAL_GPIO_WritePin(USB3_VBUS_CTL_5_GPIO_Port,USB3_VBUS_CTL_5_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
|
|
|
|
HAL_GPIO_WritePin(SYS_FAN_CTL_1_GPIO_Port,SYS_FAN_CTL_1_Pin,GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SYS_FAN_CTL_2_GPIO_Port,SYS_FAN_CTL_2_Pin,GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SYS_FAN_CTL_3_GPIO_Port,SYS_FAN_CTL_3_Pin,GPIO_PIN_RESET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void enter_runing_state()
|
|
|
|
{
|
|
|
|
|
2020-12-17 18:22:19 +08:00
|
|
|
Log(info,"Enter to runing state");
|
2020-08-26 18:13:51 +08:00
|
|
|
Beep(200);
|
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(SOM_FORCE_RECOVERY_GPIO_Port ,SOM_FORCE_RECOVERY_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(PMB_PS_ON_GPIO_Port ,PMB_PS_ON_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(SYS_FAN_CTL_1_GPIO_Port,SYS_FAN_CTL_1_Pin,GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SYS_FAN_CTL_2_GPIO_Port,SYS_FAN_CTL_2_Pin,GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SYS_FAN_CTL_3_GPIO_Port,SYS_FAN_CTL_3_Pin,GPIO_PIN_SET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(SOC_U3_HUB_PWR_CTL_GPIO_Port,SOC_U3_HUB_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SOC_U2_HUB_PWR_CTL_GPIO_Port,SOC_U2_HUB_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SOC_U3_HOST_PWR_CTL_GPIO_Port,SOC_U3_HOST_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SOC_GE_SW_PWR_CTL_GPIO_Port,SOC_GE_SW_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SOC_U3_GEC_PWR_CTL_GPIO_Port,SOC_U3_GEC_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_5_GPIO_Port,USB3_VBUS_CTL_5_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_6_GPIO_Port,USB3_VBUS_CTL_6_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port ,SOM_POWER_EN_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-12-18 12:46:59 +08:00
|
|
|
MX_USB_DEVICE_Init();
|
2020-08-26 18:13:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void enter_dfu_state()
|
|
|
|
{
|
|
|
|
|
2020-12-17 18:22:19 +08:00
|
|
|
Log(info,"Enter to dfu state");
|
2020-09-01 18:38:53 +08:00
|
|
|
Beep(500);
|
|
|
|
Beep(500);
|
|
|
|
Beep(500);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(SOM_FORCE_RECOVERY_GPIO_Port ,SOM_FORCE_RECOVERY_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(PMB_PS_ON_GPIO_Port ,PMB_PS_ON_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 19:06:33 +08:00
|
|
|
HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port ,SOM_POWER_EN_Pin, GPIO_PIN_SET); HAL_Delay(1000);
|
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(SYS_FAN_CTL_1_GPIO_Port,SYS_FAN_CTL_1_Pin,GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SYS_FAN_CTL_2_GPIO_Port,SYS_FAN_CTL_2_Pin,GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SYS_FAN_CTL_3_GPIO_Port,SYS_FAN_CTL_3_Pin,GPIO_PIN_SET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(SOC_U3_HUB_PWR_CTL_GPIO_Port,SOC_U3_HUB_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SOC_U2_HUB_PWR_CTL_GPIO_Port,SOC_U2_HUB_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
2020-09-07 19:06:33 +08:00
|
|
|
HAL_GPIO_WritePin(SOC_U3_HOST_PWR_CTL_GPIO_Port,SOC_U3_HOST_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(SOC_GE_SW_PWR_CTL_GPIO_Port,SOC_GE_SW_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(SOC_U3_GEC_PWR_CTL_GPIO_Port,SOC_U3_GEC_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
2020-09-07 18:53:33 +08:00
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_5_GPIO_Port,USB3_VBUS_CTL_5_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_6_GPIO_Port,USB3_VBUS_CTL_6_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
2020-09-07 19:06:33 +08:00
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
//
|
2020-09-07 18:53:33 +08:00
|
|
|
// HAL_GPIO_WritePin(SOM_FORCE_RECOVERY_GPIO_Port ,SOM_FORCE_RECOVERY_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
|
|
|
// HAL_GPIO_WritePin(SOM_SYS_RESET_GPIO_Port ,SOM_SYS_RESET_Pin, GPIO_PIN_RESET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
//
|
2020-09-07 18:53:33 +08:00
|
|
|
// HAL_Delay(5000);
|
|
|
|
// HAL_GPIO_WritePin(SOM_SYS_RESET_GPIO_Port ,SOM_SYS_RESET_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
|
|
|
// HAL_GPIO_WritePin(SOM_FORCE_RECOVERY_GPIO_Port ,SOM_FORCE_RECOVERY_Pin, GPIO_PIN_SET); HAL_Delay(100);
|
2020-08-26 18:13:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
}
|