master
bookshiyi 2020-07-15 18:26:22 +08:00
parent 83eee65ba1
commit 5e594244e9
30 changed files with 6965 additions and 344 deletions

View File

@ -43,6 +43,7 @@
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.186388616" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.186388616" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/include"/> <listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/include"/>
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/> <listOptionValue builtIn="false" value="../USB_DEVICE/Target"/>
<listOptionValue builtIn="false" value="../Middlewares/Coulomb"/>
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Core/Inc"/> <listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Core/Inc"/>
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2"/> <listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2"/>
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3"/> <listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3"/>
@ -53,7 +54,6 @@
<listOptionValue builtIn="false" value="../USB_DEVICE/App"/> <listOptionValue builtIn="false" value="../USB_DEVICE/App"/>
<listOptionValue builtIn="false" value="../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy"/> <listOptionValue builtIn="false" value="../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy"/>
<listOptionValue builtIn="false" value="../Drivers/STM32F1xx_HAL_Driver/Inc"/> <listOptionValue builtIn="false" value="../Drivers/STM32F1xx_HAL_Driver/Inc"/>
<listOptionValue builtIn="false" value="../Middlewares/Coulomb"/>
</option> </option>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1357480259" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/> <inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1357480259" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
</tool> </tool>

File diff suppressed because one or more lines are too long

View File

@ -6,7 +6,7 @@
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/> <provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1128470378273516651" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true"> <provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-851227371371128580" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/> <language-scope id="org.eclipse.cdt.core.g++"/>
</provider> </provider>
@ -18,7 +18,7 @@
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/> <provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1128470378273516651" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true"> <provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-851227371371128580" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/> <language-scope id="org.eclipse.cdt.core.g++"/>
</provider> </provider>

10
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,10 @@
{
"files.associations": {
"*.tpp": "cpp",
"*.cu": "cpp",
"*.tcu": "cpp",
"*.json": "json",
"*.txt": "txt",
"navikit.h": "c"
}
}

View File

@ -60,7 +60,7 @@
#define configTICK_RATE_HZ ((TickType_t)1000) #define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES ( 56 ) #define configMAX_PRIORITIES ( 56 )
#define configMINIMAL_STACK_SIZE ((uint16_t)128) #define configMINIMAL_STACK_SIZE ((uint16_t)128)
#define configTOTAL_HEAP_SIZE ((size_t)4096) #define configTOTAL_HEAP_SIZE ((size_t)8192)
#define configMAX_TASK_NAME_LEN ( 32 ) #define configMAX_TASK_NAME_LEN ( 32 )
#define configUSE_TRACE_FACILITY 1 #define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0 #define configUSE_16_BIT_TICKS 0

58
Core/Inc/adc.h Normal file
View File

@ -0,0 +1,58 @@
/**
******************************************************************************
* File Name : ADC.h
* Description : This file provides code for the configuration
* of the ADC instances.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __adc_H
#define __adc_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
extern ADC_HandleTypeDef hadc1;
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
void MX_ADC1_Init(void);
/* USER CODE BEGIN Prototypes */
/* USER CODE END Prototypes */
#ifdef __cplusplus
}
#endif
#endif /*__ adc_H */
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

56
Core/Inc/dma.h Normal file
View File

@ -0,0 +1,56 @@
/**
******************************************************************************
* File Name : dma.h
* Description : This file contains all the function prototypes for
* the dma.c file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __dma_H
#define __dma_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* DMA memory to memory transfer handles -------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
void MX_DMA_Init(void);
/* USER CODE BEGIN Prototypes */
/* USER CODE END Prototypes */
#ifdef __cplusplus
}
#endif
#endif /* __dma_H */
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -58,57 +58,120 @@ void Error_Handler(void);
/* USER CODE END EFP */ /* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/
#define PWR_BUTTON_Pin GPIO_PIN_2 #define SYS_POWER_LED_CTL_Pin GPIO_PIN_2
#define PWR_BUTTON_GPIO_Port GPIOE #define SYS_POWER_LED_CTL_GPIO_Port GPIOE
#define PWR_BUTTON_EXTI_IRQn EXTI2_IRQn #define SYS_CUSTOM_BTN_Pin GPIO_PIN_3
#define LED_RUN_Pin GPIO_PIN_3 #define SYS_CUSTOM_BTN_GPIO_Port GPIOE
#define LED_RUN_GPIO_Port GPIOE #define SYS_CUSTOM_BTN_EXTI_IRQn EXTI3_IRQn
#define SYS_WKUP_Pin GPIO_PIN_0 #define PMB_PS_ON_Pin GPIO_PIN_4
#define SYS_WKUP_GPIO_Port GPIOA #define PMB_PS_ON_GPIO_Port GPIOE
#define USB3_VBUS_CTL_3_Pin GPIO_PIN_12 #define PMB_CHRG_STAT2_Pin GPIO_PIN_5
#define USB3_VBUS_CTL_3_GPIO_Port GPIOE #define PMB_CHRG_STAT2_GPIO_Port GPIOE
#define PMG_CHRG_STAT1_Pin GPIO_PIN_6
#define PMG_CHRG_STAT1_GPIO_Port GPIOE
#define PMB_CHRG_SHDN_Pin GPIO_PIN_0
#define PMB_CHRG_SHDN_GPIO_Port GPIOC
#define PMB_TEMP_SEN_EN_Pin GPIO_PIN_1
#define PMB_TEMP_SEN_EN_GPIO_Port GPIOC
#define PMB_TEMP_SEN_ALT_Pin GPIO_PIN_2
#define PMB_TEMP_SEN_ALT_GPIO_Port GPIOC
#define PMB_CLOULOMB_ALCC_Pin GPIO_PIN_3
#define PMB_CLOULOMB_ALCC_GPIO_Port GPIOC
#define SYS_POWER_BTN_Pin GPIO_PIN_0
#define SYS_POWER_BTN_GPIO_Port GPIOA
#define SYS_POWER_BTN_EXTI_IRQn EXTI0_IRQn
#define MON_24V0_DIV16_Pin GPIO_PIN_3
#define MON_24V0_DIV16_GPIO_Port GPIOA
#define MON_5V0_DIV8_Pin GPIO_PIN_4
#define MON_5V0_DIV8_GPIO_Port GPIOA
#define MON_12V0_DIV8_Pin GPIO_PIN_5
#define MON_12V0_DIV8_GPIO_Port GPIOA
#define MON_BKP_BAT_DIV8_Pin GPIO_PIN_6
#define MON_BKP_BAT_DIV8_GPIO_Port GPIOA
#define MON_MAIN_PWR_DIV16_Pin GPIO_PIN_7
#define MON_MAIN_PWR_DIV16_GPIO_Port GPIOA
#define SYS_RUN_LED_CTL_Pin GPIO_PIN_4
#define SYS_RUN_LED_CTL_GPIO_Port GPIOC
#define SYS_BUZZ_CTL_Pin GPIO_PIN_5
#define SYS_BUZZ_CTL_GPIO_Port GPIOC
#define SYS_FAN_CTL_1_Pin GPIO_PIN_8
#define SYS_FAN_CTL_1_GPIO_Port GPIOE
#define SYS_FAN_SNS_1_Pin GPIO_PIN_9
#define SYS_FAN_SNS_1_GPIO_Port GPIOE
#define SYS_FAN_CTL_2_Pin GPIO_PIN_10
#define SYS_FAN_CTL_2_GPIO_Port GPIOE
#define SYS_FAN_SNS_2_Pin GPIO_PIN_11
#define SYS_FAN_SNS_2_GPIO_Port GPIOE
#define SYS_FAN_CTL_3_Pin GPIO_PIN_12
#define SYS_FAN_CTL_3_GPIO_Port GPIOE
#define SYS_FAN_SNS_3_Pin GPIO_PIN_13
#define SYS_FAN_SNS_3_GPIO_Port GPIOE
#define IIC2_SCL_Pin GPIO_PIN_10
#define IIC2_SCL_GPIO_Port GPIOB
#define IIC2_SDA_Pin GPIO_PIN_11
#define IIC2_SDA_GPIO_Port GPIOB
#define USB2_VBUS_CTL_1_Pin GPIO_PIN_12
#define USB2_VBUS_CTL_1_GPIO_Port GPIOB
#define USB2_VBUS_CTL_2_Pin GPIO_PIN_13
#define USB2_VBUS_CTL_2_GPIO_Port GPIOB
#define USB2_VBUS_CTL_3_Pin GPIO_PIN_14
#define USB2_VBUS_CTL_3_GPIO_Port GPIOB
#define USB2_VBUS_CTL_4_Pin GPIO_PIN_15
#define USB2_VBUS_CTL_4_GPIO_Port GPIOB
#define USB2_VBUS_CTL_5_Pin GPIO_PIN_8
#define USB2_VBUS_CTL_5_GPIO_Port GPIOD
#define USB2_VBUS_CTL_6_Pin GPIO_PIN_9
#define USB2_VBUS_CTL_6_GPIO_Port GPIOD
#define USB3_VBUS_CTL_5_Pin GPIO_PIN_10
#define USB3_VBUS_CTL_5_GPIO_Port GPIOD
#define USB3_VBUS_CTL_6_Pin GPIO_PIN_11
#define USB3_VBUS_CTL_6_GPIO_Port GPIOD
#define USB3_VBUS_CTL_1_Pin GPIO_PIN_12
#define USB3_VBUS_CTL_1_GPIO_Port GPIOD
#define USB3_VBUS_CTL_2_Pin GPIO_PIN_13 #define USB3_VBUS_CTL_2_Pin GPIO_PIN_13
#define USB3_VBUS_CTL_2_GPIO_Port GPIOE #define USB3_VBUS_CTL_2_GPIO_Port GPIOD
#define USB3_VBUS_CTL_1_Pin GPIO_PIN_14 #define USB3_VBUS_CTL_3_Pin GPIO_PIN_14
#define USB3_VBUS_CTL_1_GPIO_Port GPIOE #define USB3_VBUS_CTL_3_GPIO_Port GPIOD
#define USB3_VBUS_CTL_4_Pin GPIO_PIN_15 #define USB3_VBUS_CTL_4_Pin GPIO_PIN_15
#define USB3_VBUS_CTL_4_GPIO_Port GPIOE #define USB3_VBUS_CTL_4_GPIO_Port GPIOD
#define ENUM_CTL_Pin GPIO_PIN_8 #define USB2_FS_ENUM_CTL_Pin GPIO_PIN_8
#define ENUM_CTL_GPIO_Port GPIOA #define USB2_FS_ENUM_CTL_GPIO_Port GPIOA
#define USB2_DM_G7_Pin GPIO_PIN_11 #define USB2_FS_DM_Pin GPIO_PIN_11
#define USB2_DM_G7_GPIO_Port GPIOA #define USB2_FS_DM_GPIO_Port GPIOA
#define USB2_DP_G7_Pin GPIO_PIN_12 #define USB2_FS_DP_Pin GPIO_PIN_12
#define USB2_DP_G7_GPIO_Port GPIOA #define USB2_FS_DP_GPIO_Port GPIOA
#define SYS_SWDIO_Pin GPIO_PIN_13 #define SYS_SWDIO_Pin GPIO_PIN_13
#define SYS_SWDIO_GPIO_Port GPIOA #define SYS_SWDIO_GPIO_Port GPIOA
#define SYS_SWCLK_Pin GPIO_PIN_14 #define SYS_SWCLK_Pin GPIO_PIN_14
#define SYS_SWCLK_GPIO_Port GPIOA #define SYS_SWCLK_GPIO_Port GPIOA
#define USB2_VBUS_CTL_1_Pin GPIO_PIN_2 #define SOC_U2_HUB_PWR_CTL_Pin GPIO_PIN_12
#define USB2_VBUS_CTL_1_GPIO_Port GPIOD #define SOC_U2_HUB_PWR_CTL_GPIO_Port GPIOC
#define USB2_VBUS_CTL_2_Pin GPIO_PIN_3 #define SOC_U3_HUB_PWR_CTL_Pin GPIO_PIN_0
#define USB2_VBUS_CTL_2_GPIO_Port GPIOD #define SOC_U3_HUB_PWR_CTL_GPIO_Port GPIOD
#define USB2_VBUS_CTL_3_Pin GPIO_PIN_4 #define SOC_U3_HOST_PWR_CTL_Pin GPIO_PIN_1
#define USB2_VBUS_CTL_3_GPIO_Port GPIOD #define SOC_U3_HOST_PWR_CTL_GPIO_Port GPIOD
#define USB2_VBUS_CTL_4_Pin GPIO_PIN_5 #define SOC_U3_GEC_PWR_CTL_Pin GPIO_PIN_2
#define USB2_VBUS_CTL_4_GPIO_Port GPIOD #define SOC_U3_GEC_PWR_CTL_GPIO_Port GPIOD
#define USB2_VBUS_CTL_5_Pin GPIO_PIN_6 #define SOC_GE_SW_PWR_CTL_Pin GPIO_PIN_3
#define USB2_VBUS_CTL_5_GPIO_Port GPIOD #define SOC_GE_SW_PWR_CTL_GPIO_Port GPIOD
#define USB2_VBUS_CTL_6_Pin GPIO_PIN_7 #define SOM_POWER_EN_Pin GPIO_PIN_4
#define USB2_VBUS_CTL_6_GPIO_Port GPIOD #define SOM_POWER_EN_GPIO_Port GPIOD
#define SOM_SHUTDOWN_REQ_Pin GPIO_PIN_5
#define SOM_SHUTDOWN_REQ_GPIO_Port GPIOD
#define SOM_SLEEP_WAKE_Pin GPIO_PIN_6
#define SOM_SLEEP_WAKE_GPIO_Port GPIOD
#define SOM_FORCE_RECOVERY_Pin GPIO_PIN_7
#define SOM_FORCE_RECOVERY_GPIO_Port GPIOD
#define SYS_SWO_Pin GPIO_PIN_3 #define SYS_SWO_Pin GPIO_PIN_3
#define SYS_SWO_GPIO_Port GPIOB #define SYS_SWO_GPIO_Port GPIOB
#define BUZZ_CTL_Pin GPIO_PIN_6 #define SOM_SYS_RESET_Pin GPIO_PIN_4
#define BUZZ_CTL_GPIO_Port GPIOB #define SOM_SYS_RESET_GPIO_Port GPIOB
#define CHRG_STATUS_Pin GPIO_PIN_7 #define SOM_MOD_SLEEP_Pin GPIO_PIN_5
#define CHRG_STATUS_GPIO_Port GPIOB #define SOM_MOD_SLEEP_GPIO_Port GPIOB
#define COULOMB_SCL_Pin GPIO_PIN_8 #define IIC1_SCL_Pin GPIO_PIN_8
#define COULOMB_SCL_GPIO_Port GPIOB #define IIC1_SCL_GPIO_Port GPIOB
#define COULOMB_SDA_Pin GPIO_PIN_9 #define IIC1_SDA_Pin GPIO_PIN_9
#define COULOMB_SDA_GPIO_Port GPIOB #define IIC1_SDA_GPIO_Port GPIOB
#define COULOMB_ALCC_Pin GPIO_PIN_0
#define COULOMB_ALCC_GPIO_Port GPIOE
#define BAT_RELAY_CTL_Pin GPIO_PIN_1
#define BAT_RELAY_CTL_GPIO_Port GPIOE
/* USER CODE BEGIN Private defines */ /* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */ /* USER CODE END Private defines */

View File

@ -10,10 +10,99 @@
#include "stdbool.h" #include "stdbool.h"
typedef enum
{
shutdown, //only mcu runing
runing, //all function runing
sleep //SOCs and FANs are stop
}sta_t;
typedef struct typedef struct
{ {
bool system_runing; //系统是否开机 struct{
bool pwr_button_pushed; //开关是否被按下 sta_t last_sta; //last system state
sta_t sta; //current system state
bool power_btn; //开关是否被按下
bool custom_btn;
bool pwr_led;
bool run_led;
}sys;
struct{
bool fan_1;
bool fan_2;
bool fan_3;
}status;
struct{
bool mod_sleep;
bool power_en;
bool shutdown_req;
bool sys_reset;
bool force_recovery;
bool sleep_wake;
}som;//som power management
struct{
float out_24v_div16;
float out_5v_div8;
float out_12v_div8;
float bkp_bat_div8;
float main_pwr_div16;
bool pmb_temp_sen_en;
bool pmb_temp_sen_alt;
bool pmb_coulomb_alcc;
bool pmb_chrg_stat2;
bool pmg_chrg_stat1;
struct{
float voltage;
float current;
float cap;
float temp;
}coulomb;
}pmb;//power management board
struct{
bool u2_vbus_1;
bool u2_vbus_2;
bool u2_vbus_3;
bool u2_vbus_4;
bool u2_vbus_5;
bool u2_vbus_6;
bool u3_vbus_1;
bool u3_vbus_2;
bool u3_vbus_3;
bool u3_vbus_4;
bool u3_vbus_5;
bool u3_vbus_6;
}port;
struct{
bool u2_hub_pwr;
bool u3_hub_pwr;
bool u3_host_pwr;
bool u3_gec_pwr;
bool ge_sw_pwr;
}soc;
struct{
bool fan_valid_1;
bool fan_valid_2;
bool fan_valid_3;
}fan;
struct {
float sensor_1;
float sensor_2;
float sensor_3;
}temp;
}NaviKit_t; }NaviKit_t;
extern NaviKit_t NaviKit; extern NaviKit_t NaviKit;

View File

@ -33,7 +33,7 @@
*/ */
#define HAL_MODULE_ENABLED #define HAL_MODULE_ENABLED
/*#define HAL_ADC_MODULE_ENABLED */ #define HAL_ADC_MODULE_ENABLED
/*#define HAL_CRYP_MODULE_ENABLED */ /*#define HAL_CRYP_MODULE_ENABLED */
/*#define HAL_CAN_MODULE_ENABLED */ /*#define HAL_CAN_MODULE_ENABLED */
/*#define HAL_CAN_LEGACY_MODULE_ENABLED */ /*#define HAL_CAN_LEGACY_MODULE_ENABLED */
@ -41,7 +41,7 @@
/*#define HAL_CORTEX_MODULE_ENABLED */ /*#define HAL_CORTEX_MODULE_ENABLED */
/*#define HAL_CRC_MODULE_ENABLED */ /*#define HAL_CRC_MODULE_ENABLED */
/*#define HAL_DAC_MODULE_ENABLED */ /*#define HAL_DAC_MODULE_ENABLED */
/*#define HAL_DMA_MODULE_ENABLED */ #define HAL_DMA_MODULE_ENABLED
/*#define HAL_ETH_MODULE_ENABLED */ /*#define HAL_ETH_MODULE_ENABLED */
/*#define HAL_FLASH_MODULE_ENABLED */ /*#define HAL_FLASH_MODULE_ENABLED */
#define HAL_GPIO_MODULE_ENABLED #define HAL_GPIO_MODULE_ENABLED
@ -83,7 +83,7 @@
* (when HSE is used as system clock source, directly or through the PLL). * (when HSE is used as system clock source, directly or through the PLL).
*/ */
#if !defined (HSE_VALUE) #if !defined (HSE_VALUE)
#define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */ #define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */ #endif /* HSE_VALUE */
#if !defined (HSE_STARTUP_TIMEOUT) #if !defined (HSE_STARTUP_TIMEOUT)

View File

@ -56,7 +56,10 @@ void DebugMon_Handler(void);
void PVD_IRQHandler(void); void PVD_IRQHandler(void);
void FLASH_IRQHandler(void); void FLASH_IRQHandler(void);
void RCC_IRQHandler(void); void RCC_IRQHandler(void);
void EXTI2_IRQHandler(void); void EXTI0_IRQHandler(void);
void EXTI3_IRQHandler(void);
void DMA1_Channel1_IRQHandler(void);
void ADC1_2_IRQHandler(void);
void TIM1_UP_IRQHandler(void); void TIM1_UP_IRQHandler(void);
void I2C1_EV_IRQHandler(void); void I2C1_EV_IRQHandler(void);
void I2C1_ER_IRQHandler(void); void I2C1_ER_IRQHandler(void);

View File

@ -31,12 +31,14 @@
/* USER CODE END Includes */ /* USER CODE END Includes */
extern UART_HandleTypeDef huart4; extern UART_HandleTypeDef huart4;
extern UART_HandleTypeDef huart1;
/* USER CODE BEGIN Private defines */ /* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */ /* USER CODE END Private defines */
void MX_UART4_Init(void); void MX_UART4_Init(void);
void MX_USART1_UART_Init(void);
/* USER CODE BEGIN Prototypes */ /* USER CODE BEGIN Prototypes */

144
Core/Src/adc.c Normal file
View File

@ -0,0 +1,144 @@
/**
******************************************************************************
* File Name : ADC.c
* Description : This file provides code for the configuration
* of the ADC instances.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "adc.h"
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
ADC_HandleTypeDef hadc1;
DMA_HandleTypeDef hdma_adc1;
/* ADC1 init function */
void MX_ADC1_Init(void)
{
ADC_ChannelConfTypeDef sConfig = {0};
/** Common config
*/
hadc1.Instance = ADC1;
hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
hadc1.Init.ContinuousConvMode = ENABLE;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.NbrOfConversion = 1;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_3;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
}
void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(adcHandle->Instance==ADC1)
{
/* USER CODE BEGIN ADC1_MspInit 0 */
/* USER CODE END ADC1_MspInit 0 */
/* ADC1 clock enable */
__HAL_RCC_ADC1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**ADC1 GPIO Configuration
PA3 ------> ADC1_IN3
PA4 ------> ADC1_IN4
PA5 ------> ADC1_IN5
PA6 ------> ADC1_IN6
PA7 ------> ADC1_IN7
*/
GPIO_InitStruct.Pin = MON_24V0_DIV16_Pin|MON_5V0_DIV8_Pin|MON_12V0_DIV8_Pin|MON_BKP_BAT_DIV8_Pin
|MON_MAIN_PWR_DIV16_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* ADC1 DMA Init */
/* ADC1 Init */
hdma_adc1.Instance = DMA1_Channel1;
hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;
hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_adc1.Init.Mode = DMA_CIRCULAR;
hdma_adc1.Init.Priority = DMA_PRIORITY_LOW;
if (HAL_DMA_Init(&hdma_adc1) != HAL_OK)
{
Error_Handler();
}
__HAL_LINKDMA(adcHandle,DMA_Handle,hdma_adc1);
/* USER CODE BEGIN ADC1_MspInit 1 */
/* USER CODE END ADC1_MspInit 1 */
}
}
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle)
{
if(adcHandle->Instance==ADC1)
{
/* USER CODE BEGIN ADC1_MspDeInit 0 */
/* USER CODE END ADC1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_ADC1_CLK_DISABLE();
/**ADC1 GPIO Configuration
PA3 ------> ADC1_IN3
PA4 ------> ADC1_IN4
PA5 ------> ADC1_IN5
PA6 ------> ADC1_IN6
PA7 ------> ADC1_IN7
*/
HAL_GPIO_DeInit(GPIOA, MON_24V0_DIV16_Pin|MON_5V0_DIV8_Pin|MON_12V0_DIV8_Pin|MON_BKP_BAT_DIV8_Pin
|MON_MAIN_PWR_DIV16_Pin);
/* ADC1 DMA DeInit */
HAL_DMA_DeInit(adcHandle->DMA_Handle);
/* ADC1 interrupt Deinit */
HAL_NVIC_DisableIRQ(ADC1_2_IRQn);
/* USER CODE BEGIN ADC1_MspDeInit 1 */
/* USER CODE END ADC1_MspDeInit 1 */
}
}
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

58
Core/Src/dma.c Normal file
View File

@ -0,0 +1,58 @@
/**
******************************************************************************
* File Name : dma.c
* Description : This file provides code for the configuration
* of all the requested memory to memory DMA transfers.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "dma.h"
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/*----------------------------------------------------------------------------*/
/* Configure DMA */
/*----------------------------------------------------------------------------*/
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/**
* Enable DMA controller clock
*/
void MX_DMA_Init(void)
{
/* DMA controller clock enable */
__HAL_RCC_DMA1_CLK_ENABLE();
}
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -89,6 +89,20 @@ const osThreadAttr_t CoulombRead_attributes = {
.priority = (osPriority_t) osPriorityLow, .priority = (osPriority_t) osPriorityLow,
.stack_size = 128 * 4 .stack_size = 128 * 4
}; };
/* Definitions for StateSwitchTask */
osThreadId_t StateSwitchTaskHandle;
const osThreadAttr_t StateSwitchTask_attributes = {
.name = "StateSwitchTask",
.priority = (osPriority_t) osPriorityLow,
.stack_size = 128 * 4
};
/* Definitions for SOMPowerManageTask */
osThreadId_t SOMPowerManageTaskHandle;
const osThreadAttr_t SOMPowerManageTask_attributes = {
.name = "SOMPowerManageTask",
.priority = (osPriority_t) osPriorityLow,
.stack_size = 128 * 4
};
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */ /* USER CODE BEGIN FunctionPrototypes */
@ -99,6 +113,8 @@ void StartLedBlinkTask(void *argument);
void StartIWDGRefreshTask(void *argument); void StartIWDGRefreshTask(void *argument);
void StartButtonDetect(void *argument); void StartButtonDetect(void *argument);
void StartCoulombRead(void *argument); void StartCoulombRead(void *argument);
void StartStateSwitchTask(void *argument);
void StartSOMPowerManageTask(void *argument);
extern void MX_USB_DEVICE_Init(void); extern void MX_USB_DEVICE_Init(void);
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */ void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
@ -145,6 +161,12 @@ void MX_FREERTOS_Init(void) {
/* creation of CoulombRead */ /* creation of CoulombRead */
CoulombReadHandle = osThreadNew(StartCoulombRead, NULL, &CoulombRead_attributes); CoulombReadHandle = osThreadNew(StartCoulombRead, NULL, &CoulombRead_attributes);
/* creation of StateSwitchTask */
StateSwitchTaskHandle = osThreadNew(StartStateSwitchTask, NULL, &StateSwitchTask_attributes);
/* creation of SOMPowerManageTask */
SOMPowerManageTaskHandle = osThreadNew(StartSOMPowerManageTask, NULL, &SOMPowerManageTask_attributes);
/* USER CODE BEGIN RTOS_THREADS */ /* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */ /* add threads, ... */
@ -166,7 +188,7 @@ void StartDefaultTask(void *argument)
/* USER CODE BEGIN StartDefaultTask */ /* USER CODE BEGIN StartDefaultTask */
NaviKit_var_init(); NaviKit_var_init();
HAL_GPIO_WritePin(ENUM_CTL_GPIO_Port,ENUM_CTL_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(USB2_FS_ENUM_CTL_GPIO_Port,USB2_FS_ENUM_CTL_Pin, GPIO_PIN_SET);
Beep(50); Beep(50);
/* Infinite loop */ /* Infinite loop */
for(;;) for(;;)
@ -190,15 +212,67 @@ void StartLedBlinkTask(void *argument)
/* Infinite loop */ /* Infinite loop */
for(;;) for(;;)
{ {
if(HAL_GPIO_ReadPin(LED_RUN_GPIO_Port,LED_RUN_Pin) == GPIO_PIN_SET)
{//LED处于熄灭状态 if(NaviKit.sys.sta == runing)
osDelay(NaviKit.system_runing ? 300 : 2000); {
HAL_GPIO_WritePin(LED_RUN_GPIO_Port,LED_RUN_Pin,GPIO_PIN_RESET);//点亮 if(HAL_GPIO_ReadPin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin))
HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin,GPIO_PIN_RESET);//turn on power led
if(HAL_GPIO_ReadPin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin) == GPIO_PIN_SET)//sys run led is off
{
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_RESET);//turn on sys run led
osDelay(50);
} }
else else
{//LED处于点亮状态 {
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_SET);//turn off sys run led
osDelay(300);
}
}
else if(NaviKit.sys.sta == shutdown)
{
if(!HAL_GPIO_ReadPin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin))
HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin,GPIO_PIN_SET);//turn off power led
if(HAL_GPIO_ReadPin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin) == GPIO_PIN_SET)//sys run led is off
{
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_RESET);//turn on sys run led
osDelay(20); osDelay(20);
HAL_GPIO_WritePin(LED_RUN_GPIO_Port,LED_RUN_Pin,GPIO_PIN_SET);//熄灭 }
else
{
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_SET);//turn off sys run led
osDelay(2000);
}
}
else if(NaviKit.sys.sta == sleep)
{
for(uint16_t i=0;i<20;i++)
{//20 light level
for(uint16_t j=0;j<4;j++)
{//the time length of every light level
HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin,GPIO_PIN_SET);
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_SET);
osDelay(i);
HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin,GPIO_PIN_RESET);
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_RESET);
osDelay(20-i);
}
}
for(uint16_t i=0;i<20;i++)
{
for(uint16_t j=0;j<4;j++)
{
HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin,GPIO_PIN_SET);
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_SET);
osDelay(20-i);
HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin,GPIO_PIN_RESET);
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_RESET);
osDelay(i);
}
}
} }
} }
/* USER CODE END StartLedBlinkTask */ /* USER CODE END StartLedBlinkTask */
@ -238,59 +312,50 @@ void StartButtonDetect(void *argument)
/* Infinite loop */ /* Infinite loop */
for(;;) for(;;)
{ {
//长按检测 //长按<EFBFBD>???????<3F>???????
if(NaviKit.pwr_button_pushed == true) if(NaviKit.sys.power_btn == true)
{//按键被按下 {//power btn has been pushed
osDelay(2000); osDelay(2000);
if(NaviKit.pwr_button_pushed == true) if(NaviKit.sys.power_btn == true)
{//仍被按下 {//power btn has been pushed more than 2000 ms
if(NaviKit.system_runing == true) if(NaviKit.sys.sta == runing)
{//当前处于开机状态,进行关机操作 {//system is runing now, user request to shutdown
NaviKit.system_runing = false; enter_shutdown_state();
printf("shutdown \n");
Beep(50);
HAL_GPIO_WritePin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, GPIO_PIN_RESET);
Beep(40);
osDelay(500);
HAL_GPIO_WritePin(BAT_RELAY_CTL_GPIO_Port ,BAT_RELAY_CTL_Pin, GPIO_PIN_RESET);
} }
else else if(NaviKit.sys.sta == shutdown)
{//当前处于关机状态,进行开机操作 {//system is shutdown now , user request to power on
NaviKit.system_runing = true; enter_runing_state();
Beep(40); printf("power on \n");
HAL_GPIO_WritePin(BAT_RELAY_CTL_GPIO_Port ,BAT_RELAY_CTL_Pin, GPIO_PIN_SET); Beep(200);
osDelay(500); osDelay(500);
HAL_GPIO_WritePin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin, GPIO_PIN_SET); }
osDelay(100); }
HAL_GPIO_WritePin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin, GPIO_PIN_SET); else
osDelay(100); {
HAL_GPIO_WritePin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin, GPIO_PIN_SET); if(NaviKit.sys.sta == runing)
osDelay(100); {
HAL_GPIO_WritePin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin, GPIO_PIN_SET); enter_sleep_state();
osDelay(100); }
HAL_GPIO_WritePin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin, GPIO_PIN_SET); else if(NaviKit.sys.sta == sleep)
osDelay(100); {
HAL_GPIO_WritePin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin, GPIO_PIN_SET); enter_runing_state();
osDelay(100); }
HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, GPIO_PIN_SET);
osDelay(100); }
HAL_GPIO_WritePin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin, GPIO_PIN_SET); }
osDelay(100); if(NaviKit.sys.custom_btn == true )
HAL_GPIO_WritePin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin, GPIO_PIN_SET); {//custom button has been pushed
osDelay(100); osDelay(2000);
HAL_GPIO_WritePin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin, GPIO_PIN_SET); if(NaviKit.sys.custom_btn == true )
osDelay(100); {//custom button has been pushed over 2000 ms
HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, GPIO_PIN_SET); if(NaviKit.sys.sta == runing)
{
// restart();
} }
} }
} }
@ -324,7 +389,7 @@ void StartCoulombRead(void *argument)
{ {
coulomb_read_status_and_config(); coulomb_read_status_and_config();
coulomb_read_status_raw_to_actual(); coulomb_read_status_raw_to_actual();
if(NaviKit.system_runing) if(NaviKit.sys.sta)
osDelay(500); osDelay(500);
else else
osDelay(5000); osDelay(5000);
@ -332,8 +397,193 @@ void StartCoulombRead(void *argument)
/* USER CODE END StartCoulombRead */ /* USER CODE END StartCoulombRead */
} }
/* USER CODE BEGIN Header_StartStateSwitchTask */
/**
* @brief Function implementing the StateSwitchTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartStateSwitchTask */
void StartStateSwitchTask(void *argument)
{
/* USER CODE BEGIN StartStateSwitchTask */
/* Infinite loop */
for(;;)
{
if(NaviKit.sys.last_sta != NaviKit.sys.sta)
switch(NaviKit.sys.sta)
{
case shutdown:
{
}break;
case runing:
{
}break;
case sleep:
{
}break;
}
osDelay(10);
}
/* USER CODE END StartStateSwitchTask */
}
/* USER CODE BEGIN Header_StartSOMPowerManageTask */
/**
* @brief Function implementing the SOMPowerManageTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartSOMPowerManageTask */
void StartSOMPowerManageTask(void *argument)
{
/* USER CODE BEGIN StartSOMPowerManageTask */
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END StartSOMPowerManageTask */
}
/* Private application code --------------------------------------------------*/ /* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */ /* USER CODE BEGIN Application */
void sys_start()
{
}
//power off by button pushed
void force_sys_stop()
{
Beep(40);
}
//module request to stop
void sys_stop()
{
if(HAL_GPIO_ReadPin(SOM_SHUTDOWN_REQ_GPIO_Port,SOM_SHUTDOWN_REQ_Pin) == GPIO_PIN_SET)
{
//1.the last step of normal power off process
//2.Thermal shutdown
//3.vdd_in's wave more than 5% of 5.0V
HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port,SOM_POWER_EN_Pin,GPIO_PIN_RESET);
}
}
void enter_shutdown_state()
{
HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port ,SOM_POWER_EN_Pin, GPIO_PIN_RESET); osDelay(100);
for(uint8_t i=0;i<100;i++)
{
if(HAL_GPIO_ReadPin(SOM_SHUTDOWN_REQ_GPIO_Port,SOM_SHUTDOWN_REQ_Pin))
osDelay(10);
}
HAL_GPIO_WritePin(SOC_U3_HUB_PWR_CTL_GPIO_Port,SOC_U3_HUB_PWR_CTL_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(SOC_U2_HUB_PWR_CTL_GPIO_Port,SOC_U2_HUB_PWR_CTL_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(SOC_U3_HOST_PWR_CTL_GPIO_Port,SOC_U3_HOST_PWR_CTL_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(SOC_GE_SW_PWR_CTL_GPIO_Port,SOC_GE_SW_PWR_CTL_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(SOC_U3_GEC_PWR_CTL_GPIO_Port,SOC_U3_GEC_PWR_CTL_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_6_GPIO_Port,USB3_VBUS_CTL_6_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_5_GPIO_Port,USB3_VBUS_CTL_5_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_1_GPIO_Port,SYS_FAN_CTL_1_Pin,GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_2_GPIO_Port,SYS_FAN_CTL_2_Pin,GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_3_GPIO_Port,SYS_FAN_CTL_3_Pin,GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(PMB_PS_ON_GPIO_Port ,PMB_PS_ON_Pin, GPIO_PIN_RESET); osDelay(100);
NaviKit.sys.sta = shutdown;
}
void enter_sleep_state()
{
// HAL_GPIO_WritePin(SOC_U3_HUB_PWR_CTL_GPIO_Port,SOC_U3_HUB_PWR_CTL_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(SOC_U2_HUB_PWR_CTL_GPIO_Port,SOC_U2_HUB_PWR_CTL_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(SOC_U3_HOST_PWR_CTL_GPIO_Port,SOC_U3_HOST_PWR_CTL_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(SOC_GE_SW_PWR_CTL_GPIO_Port,SOC_GE_SW_PWR_CTL_Pin, GPIO_PIN_RESET); osDelay(100);
// HAL_GPIO_WritePin(SOC_U3_GEC_PWR_CTL_GPIO_Port,SOC_U3_GEC_PWR_CTL_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin, GPIO_PIN_RESET); osDelay(100);
// HAL_GPIO_WritePin(USB3_VBUS_CTL_6_GPIO_Port,USB3_VBUS_CTL_6_Pin, GPIO_PIN_RESET); osDelay(100);
// HAL_GPIO_WritePin(USB3_VBUS_CTL_5_GPIO_Port,USB3_VBUS_CTL_5_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin, GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_1_GPIO_Port,SYS_FAN_CTL_1_Pin,GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_2_GPIO_Port,SYS_FAN_CTL_2_Pin,GPIO_PIN_RESET); osDelay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_3_GPIO_Port,SYS_FAN_CTL_3_Pin,GPIO_PIN_RESET); osDelay(100);
NaviKit.sys.sta = sleep;
}
void enter_runing_state()
{
NaviKit.sys.sta = runing;
Beep(40);
HAL_GPIO_WritePin(PMB_PS_ON_GPIO_Port ,PMB_PS_ON_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_1_GPIO_Port,SYS_FAN_CTL_1_Pin,GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_2_GPIO_Port,SYS_FAN_CTL_2_Pin,GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_3_GPIO_Port,SYS_FAN_CTL_3_Pin,GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(SOC_U3_HUB_PWR_CTL_GPIO_Port,SOC_U3_HUB_PWR_CTL_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(SOC_U2_HUB_PWR_CTL_GPIO_Port,SOC_U2_HUB_PWR_CTL_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(SOC_U3_HOST_PWR_CTL_GPIO_Port,SOC_U3_HOST_PWR_CTL_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(SOC_GE_SW_PWR_CTL_GPIO_Port,SOC_GE_SW_PWR_CTL_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(SOC_U3_GEC_PWR_CTL_GPIO_Port,SOC_U3_GEC_PWR_CTL_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_5_GPIO_Port,USB3_VBUS_CTL_5_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_6_GPIO_Port,USB3_VBUS_CTL_6_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, GPIO_PIN_SET); osDelay(100);
HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port ,SOM_POWER_EN_Pin, GPIO_PIN_SET); osDelay(100);
}
@ -342,8 +592,8 @@ void StartCoulombRead(void *argument)
PUTCHAR_PROTOTYPE PUTCHAR_PROTOTYPE
{ {
while(HAL_UART_GetState(&huart4) == HAL_UART_STATE_BUSY_TX){} while(HAL_UART_GetState(&huart1) == HAL_UART_STATE_BUSY_TX){}
HAL_UART_Transmit(&huart4,(uint8_t *)&ch,1,0xffff); HAL_UART_Transmit(&huart1,(uint8_t *)&ch,1,0xffff);
return ch; return ch;
} }
#endif #endif

View File

@ -45,78 +45,129 @@ void MX_GPIO_Init(void)
/* GPIO Ports Clock Enable */ /* GPIO Ports Clock Enable */
__HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOE, LED_RUN_Pin|USB3_VBUS_CTL_3_Pin|USB3_VBUS_CTL_2_Pin|USB3_VBUS_CTL_1_Pin HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port, SYS_POWER_LED_CTL_Pin, GPIO_PIN_SET);
|USB3_VBUS_CTL_4_Pin|BAT_RELAY_CTL_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(ENUM_CTL_GPIO_Port, ENUM_CTL_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOE, PMB_PS_ON_Pin|SYS_FAN_CTL_1_Pin|SYS_FAN_CTL_2_Pin|SYS_FAN_CTL_3_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOD, USB2_VBUS_CTL_1_Pin|USB2_VBUS_CTL_2_Pin|USB2_VBUS_CTL_3_Pin|USB2_VBUS_CTL_4_Pin HAL_GPIO_WritePin(GPIOC, PMB_CHRG_SHDN_Pin|PMB_TEMP_SEN_EN_Pin|SYS_RUN_LED_CTL_Pin|SYS_BUZZ_CTL_Pin
|USB2_VBUS_CTL_5_Pin|USB2_VBUS_CTL_6_Pin, GPIO_PIN_RESET); |SOC_U2_HUB_PWR_CTL_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(BUZZ_CTL_GPIO_Port, BUZZ_CTL_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOB, IIC2_SCL_Pin|IIC2_SDA_Pin|USB2_VBUS_CTL_1_Pin|USB2_VBUS_CTL_2_Pin
|USB2_VBUS_CTL_3_Pin|USB2_VBUS_CTL_4_Pin|SOM_SYS_RESET_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin : PtPin */ /*Configure GPIO pin Output Level */
GPIO_InitStruct.Pin = PWR_BUTTON_Pin; HAL_GPIO_WritePin(GPIOD, USB2_VBUS_CTL_5_Pin|USB2_VBUS_CTL_6_Pin|USB3_VBUS_CTL_5_Pin|USB3_VBUS_CTL_6_Pin
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; |USB3_VBUS_CTL_1_Pin|USB3_VBUS_CTL_2_Pin|USB3_VBUS_CTL_3_Pin|USB3_VBUS_CTL_4_Pin
GPIO_InitStruct.Pull = GPIO_PULLUP; |SOC_U3_HUB_PWR_CTL_Pin|SOC_U3_HOST_PWR_CTL_Pin|SOC_U3_GEC_PWR_CTL_Pin|SOC_GE_SW_PWR_CTL_Pin
HAL_GPIO_Init(PWR_BUTTON_GPIO_Port, &GPIO_InitStruct); |SOM_POWER_EN_Pin|SOM_SLEEP_WAKE_Pin|SOM_FORCE_RECOVERY_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(USB2_FS_ENUM_CTL_GPIO_Port, USB2_FS_ENUM_CTL_Pin, GPIO_PIN_RESET);
/*Configure GPIO pins : PEPin PEPin PEPin PEPin /*Configure GPIO pins : PEPin PEPin PEPin PEPin
PEPin PEPin */ PEPin */
GPIO_InitStruct.Pin = LED_RUN_Pin|USB3_VBUS_CTL_3_Pin|USB3_VBUS_CTL_2_Pin|USB3_VBUS_CTL_1_Pin GPIO_InitStruct.Pin = SYS_POWER_LED_CTL_Pin|PMB_PS_ON_Pin|SYS_FAN_CTL_1_Pin|SYS_FAN_CTL_2_Pin
|USB3_VBUS_CTL_4_Pin|BAT_RELAY_CTL_Pin; |SYS_FAN_CTL_3_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/*Configure GPIO pin : PtPin */ /*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = ENUM_CTL_Pin; GPIO_InitStruct.Pin = SYS_CUSTOM_BTN_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(SYS_CUSTOM_BTN_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : PEPin PEPin */
GPIO_InitStruct.Pin = PMB_CHRG_STAT2_Pin|PMG_CHRG_STAT1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/*Configure GPIO pins : PCPin PCPin PCPin PCPin
PCPin */
GPIO_InitStruct.Pin = PMB_CHRG_SHDN_Pin|PMB_TEMP_SEN_EN_Pin|SYS_RUN_LED_CTL_Pin|SYS_BUZZ_CTL_Pin
|SOC_U2_HUB_PWR_CTL_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(ENUM_CTL_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*Configure GPIO pins : PCPin PCPin */
GPIO_InitStruct.Pin = PMB_TEMP_SEN_ALT_Pin|PMB_CLOULOMB_ALCC_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = SYS_POWER_BTN_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(SYS_POWER_BTN_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : PEPin PEPin PEPin */
GPIO_InitStruct.Pin = SYS_FAN_SNS_1_Pin|SYS_FAN_SNS_2_Pin|SYS_FAN_SNS_3_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/*Configure GPIO pins : PBPin PBPin PBPin PBPin
PBPin PBPin PBPin */
GPIO_InitStruct.Pin = IIC2_SCL_Pin|IIC2_SDA_Pin|USB2_VBUS_CTL_1_Pin|USB2_VBUS_CTL_2_Pin
|USB2_VBUS_CTL_3_Pin|USB2_VBUS_CTL_4_Pin|SOM_SYS_RESET_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);
/*Configure GPIO pins : PDPin PDPin PDPin PDPin /*Configure GPIO pins : PDPin PDPin PDPin PDPin
PDPin PDPin */ PDPin PDPin PDPin PDPin
GPIO_InitStruct.Pin = USB2_VBUS_CTL_1_Pin|USB2_VBUS_CTL_2_Pin|USB2_VBUS_CTL_3_Pin|USB2_VBUS_CTL_4_Pin PDPin PDPin PDPin PDPin
|USB2_VBUS_CTL_5_Pin|USB2_VBUS_CTL_6_Pin; PDPin PDPin PDPin */
GPIO_InitStruct.Pin = USB2_VBUS_CTL_5_Pin|USB2_VBUS_CTL_6_Pin|USB3_VBUS_CTL_5_Pin|USB3_VBUS_CTL_6_Pin
|USB3_VBUS_CTL_1_Pin|USB3_VBUS_CTL_2_Pin|USB3_VBUS_CTL_3_Pin|USB3_VBUS_CTL_4_Pin
|SOC_U3_HUB_PWR_CTL_Pin|SOC_U3_HOST_PWR_CTL_Pin|SOC_U3_GEC_PWR_CTL_Pin|SOC_GE_SW_PWR_CTL_Pin
|SOM_POWER_EN_Pin|SOM_SLEEP_WAKE_Pin|SOM_FORCE_RECOVERY_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
/*Configure GPIO pin : PtPin */ /*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = BUZZ_CTL_Pin; GPIO_InitStruct.Pin = USB2_FS_ENUM_CTL_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(BUZZ_CTL_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(USB2_FS_ENUM_CTL_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : PtPin */ /*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = CHRG_STATUS_Pin; GPIO_InitStruct.Pin = SOM_SHUTDOWN_REQ_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(CHRG_STATUS_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(SOM_SHUTDOWN_REQ_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : PtPin */ /*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = COULOMB_ALCC_Pin; GPIO_InitStruct.Pin = SOM_MOD_SLEEP_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(COULOMB_ALCC_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(SOM_MOD_SLEEP_GPIO_Port, &GPIO_InitStruct);
/* EXTI interrupt init*/ /* EXTI interrupt init*/
HAL_NVIC_SetPriority(EXTI2_IRQn, 5, 0); HAL_NVIC_SetPriority(EXTI0_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(EXTI2_IRQn); HAL_NVIC_EnableIRQ(EXTI0_IRQn);
HAL_NVIC_SetPriority(EXTI3_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(EXTI3_IRQn);
} }
@ -124,21 +175,36 @@ void MX_GPIO_Init(void)
void Beep(uint32_t time_ms) void Beep(uint32_t time_ms)
{ {
HAL_GPIO_WritePin(BUZZ_CTL_GPIO_Port,BUZZ_CTL_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(SYS_BUZZ_CTL_GPIO_Port,SYS_BUZZ_CTL_Pin, GPIO_PIN_RESET);
osDelay(time_ms); osDelay(time_ms);
HAL_GPIO_WritePin(BUZZ_CTL_GPIO_Port,BUZZ_CTL_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(SYS_BUZZ_CTL_GPIO_Port,SYS_BUZZ_CTL_Pin, GPIO_PIN_SET);
} }
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{ {
if(GPIO_Pin==PWR_BUTTON_Pin) if(GPIO_Pin==SYS_POWER_BTN_Pin)
{ {
if(HAL_GPIO_ReadPin(PWR_BUTTON_GPIO_Port, PWR_BUTTON_Pin)==GPIO_PIN_SET) if(HAL_GPIO_ReadPin(SYS_POWER_BTN_GPIO_Port, SYS_POWER_BTN_Pin)==GPIO_PIN_SET)
{//Rising edge trigger {//Rising edge trigger
NaviKit.pwr_button_pushed = false; NaviKit.sys.power_btn = true;
printf("pwr_btn pushed \n");
} }
if(HAL_GPIO_ReadPin(PWR_BUTTON_GPIO_Port, PWR_BUTTON_Pin)==GPIO_PIN_RESET) if(HAL_GPIO_ReadPin(SYS_POWER_BTN_GPIO_Port, SYS_POWER_BTN_Pin)==GPIO_PIN_RESET)
{//falling edge trigger {//falling edge trigger
NaviKit.pwr_button_pushed = true; NaviKit.sys.power_btn = false;
printf("pwr_btn poped \n");
}
}
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;
printf("cus_btn poped \n");
}
if(HAL_GPIO_ReadPin(SYS_CUSTOM_BTN_GPIO_Port, SYS_CUSTOM_BTN_Pin)==GPIO_PIN_RESET)
{//falling edge trigger
NaviKit.sys.custom_btn = true;
printf("cus_btn pushed \n");
} }
} }

View File

@ -21,6 +21,27 @@
#include "i2c.h" #include "i2c.h"
/* USER CODE BEGIN 0 */ /* USER CODE BEGIN 0 */
I2C_HandleTypeDef hi2c2;
/* I2C1 init function */
void MX_I2C2_Init(void)
{
hi2c1.Instance = I2C2;
hi2c1.Init.ClockSpeed = 100000;
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c2) != HAL_OK)
{
Error_Handler();
}
}
/* USER CODE END 0 */ /* USER CODE END 0 */
@ -61,7 +82,7 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)
PB8 ------> I2C1_SCL PB8 ------> I2C1_SCL
PB9 ------> I2C1_SDA PB9 ------> I2C1_SDA
*/ */
GPIO_InitStruct.Pin = COULOMB_SCL_Pin|COULOMB_SDA_Pin; GPIO_InitStruct.Pin = IIC1_SCL_Pin|IIC1_SDA_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
@ -70,12 +91,6 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)
/* I2C1 clock enable */ /* I2C1 clock enable */
__HAL_RCC_I2C1_CLK_ENABLE(); __HAL_RCC_I2C1_CLK_ENABLE();
/* I2C1 interrupt Init */
HAL_NVIC_SetPriority(I2C1_EV_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(I2C1_EV_IRQn);
HAL_NVIC_SetPriority(I2C1_ER_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(I2C1_ER_IRQn);
/* USER CODE BEGIN I2C1_MspInit 1 */ /* USER CODE BEGIN I2C1_MspInit 1 */
/* USER CODE END I2C1_MspInit 1 */ /* USER CODE END I2C1_MspInit 1 */
@ -97,7 +112,7 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* i2cHandle)
PB8 ------> I2C1_SCL PB8 ------> I2C1_SCL
PB9 ------> I2C1_SDA PB9 ------> I2C1_SDA
*/ */
HAL_GPIO_DeInit(GPIOB, COULOMB_SCL_Pin|COULOMB_SDA_Pin); HAL_GPIO_DeInit(GPIOB, IIC1_SCL_Pin|IIC1_SDA_Pin);
/* I2C1 interrupt Deinit */ /* I2C1 interrupt Deinit */
HAL_NVIC_DisableIRQ(I2C1_EV_IRQn); HAL_NVIC_DisableIRQ(I2C1_EV_IRQn);

View File

@ -21,6 +21,8 @@
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "main.h" #include "main.h"
#include "cmsis_os.h" #include "cmsis_os.h"
#include "adc.h"
#include "dma.h"
#include "i2c.h" #include "i2c.h"
#include "iwdg.h" #include "iwdg.h"
#include "usart.h" #include "usart.h"
@ -54,6 +56,7 @@
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void); void SystemClock_Config(void);
void MX_FREERTOS_Init(void); void MX_FREERTOS_Init(void);
static void MX_NVIC_Init(void);
/* USER CODE BEGIN PFP */ /* USER CODE BEGIN PFP */
/* USER CODE END PFP */ /* USER CODE END PFP */
@ -91,9 +94,15 @@ int main(void)
/* Initialize all configured peripherals */ /* Initialize all configured peripherals */
MX_GPIO_Init(); MX_GPIO_Init();
MX_DMA_Init();
MX_I2C1_Init(); MX_I2C1_Init();
MX_IWDG_Init(); MX_IWDG_Init();
MX_UART4_Init(); MX_UART4_Init();
MX_ADC1_Init();
MX_USART1_UART_Init();
/* Initialize interrupts */
MX_NVIC_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
//HAL_IWDG_Refresh(&hiwdg); //HAL_IWDG_Refresh(&hiwdg);
printf("Core initial successfully\n"); printf("Core initial successfully\n");
@ -137,7 +146,7 @@ void SystemClock_Config(void)
RCC_OscInitStruct.Prediv1Source = RCC_PREDIV1_SOURCE_HSE; RCC_OscInitStruct.Prediv1Source = RCC_PREDIV1_SOURCE_HSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL4;
RCC_OscInitStruct.PLL2.PLL2State = RCC_PLL_NONE; RCC_OscInitStruct.PLL2.PLL2State = RCC_PLL_NONE;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{ {
@ -148,16 +157,17 @@ void SystemClock_Config(void)
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{ {
Error_Handler(); Error_Handler();
} }
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC|RCC_PERIPHCLK_USB;
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV3; PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV8;
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV2;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{ {
Error_Handler(); Error_Handler();
@ -170,6 +180,41 @@ void SystemClock_Config(void)
__HAL_RCC_PLLI2S_ENABLE(); __HAL_RCC_PLLI2S_ENABLE();
} }
/**
* @brief NVIC Configuration.
* @retval None
*/
static void MX_NVIC_Init(void)
{
/* ADC1_2_IRQn interrupt configuration */
HAL_NVIC_SetPriority(ADC1_2_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
/* RCC_IRQn interrupt configuration */
HAL_NVIC_SetPriority(RCC_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(RCC_IRQn);
/* FLASH_IRQn interrupt configuration */
HAL_NVIC_SetPriority(FLASH_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(FLASH_IRQn);
/* PVD_IRQn interrupt configuration */
HAL_NVIC_SetPriority(PVD_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(PVD_IRQn);
/* I2C1_EV_IRQn interrupt configuration */
HAL_NVIC_SetPriority(I2C1_EV_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(I2C1_EV_IRQn);
/* I2C1_ER_IRQn interrupt configuration */
HAL_NVIC_SetPriority(I2C1_ER_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(I2C1_ER_IRQn);
/* UART4_IRQn interrupt configuration */
HAL_NVIC_SetPriority(UART4_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(UART4_IRQn);
/* OTG_FS_IRQn interrupt configuration */
HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
/* DMA1_Channel1_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
}
/* USER CODE BEGIN 4 */ /* USER CODE BEGIN 4 */

View File

@ -10,6 +10,6 @@
NaviKit_t NaviKit; NaviKit_t NaviKit;
void NaviKit_var_init() void NaviKit_var_init()
{ {
NaviKit.pwr_button_pushed = false; NaviKit.sys.sta = shutdown;
NaviKit.system_runing = false; NaviKit.sys.last_sta = shutdown;
} }

View File

@ -75,15 +75,6 @@ void HAL_MspInit(void)
HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0);
/* Peripheral interrupt init */ /* Peripheral interrupt init */
/* PVD_IRQn interrupt configuration */
HAL_NVIC_SetPriority(PVD_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(PVD_IRQn);
/* FLASH_IRQn interrupt configuration */
HAL_NVIC_SetPriority(FLASH_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(FLASH_IRQn);
/* RCC_IRQn interrupt configuration */
HAL_NVIC_SetPriority(RCC_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(RCC_IRQn);
/** NOJTAG: JTAG-DP Disabled and SW-DP Enabled /** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
*/ */

View File

@ -59,6 +59,8 @@
/* External variables --------------------------------------------------------*/ /* External variables --------------------------------------------------------*/
extern PCD_HandleTypeDef hpcd_USB_OTG_FS; extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
extern DMA_HandleTypeDef hdma_adc1;
extern ADC_HandleTypeDef hadc1;
extern I2C_HandleTypeDef hi2c1; extern I2C_HandleTypeDef hi2c1;
extern UART_HandleTypeDef huart4; extern UART_HandleTypeDef huart4;
extern TIM_HandleTypeDef htim1; extern TIM_HandleTypeDef htim1;
@ -206,17 +208,59 @@ void RCC_IRQHandler(void)
} }
/** /**
* @brief This function handles EXTI line2 interrupt. * @brief This function handles EXTI line0 interrupt.
*/ */
void EXTI2_IRQHandler(void) void EXTI0_IRQHandler(void)
{ {
/* USER CODE BEGIN EXTI2_IRQn 0 */ /* USER CODE BEGIN EXTI0_IRQn 0 */
/* USER CODE END EXTI2_IRQn 0 */ /* USER CODE END EXTI0_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
/* USER CODE BEGIN EXTI2_IRQn 1 */ /* USER CODE BEGIN EXTI0_IRQn 1 */
/* USER CODE END EXTI2_IRQn 1 */ /* USER CODE END EXTI0_IRQn 1 */
}
/**
* @brief This function handles EXTI line3 interrupt.
*/
void EXTI3_IRQHandler(void)
{
/* USER CODE BEGIN EXTI3_IRQn 0 */
/* USER CODE END EXTI3_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_3);
/* USER CODE BEGIN EXTI3_IRQn 1 */
/* USER CODE END EXTI3_IRQn 1 */
}
/**
* @brief This function handles DMA1 channel1 global interrupt.
*/
void DMA1_Channel1_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Channel1_IRQn 0 */
/* USER CODE END DMA1_Channel1_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_adc1);
/* USER CODE BEGIN DMA1_Channel1_IRQn 1 */
/* USER CODE END DMA1_Channel1_IRQn 1 */
}
/**
* @brief This function handles ADC1 and ADC2 global interrupts.
*/
void ADC1_2_IRQHandler(void)
{
/* USER CODE BEGIN ADC1_2_IRQn 0 */
/* USER CODE END ADC1_2_IRQn 0 */
HAL_ADC_IRQHandler(&hadc1);
/* USER CODE BEGIN ADC1_2_IRQn 1 */
/* USER CODE END ADC1_2_IRQn 1 */
} }
/** /**

View File

@ -24,6 +24,7 @@
/* USER CODE END 0 */ /* USER CODE END 0 */
UART_HandleTypeDef huart4; UART_HandleTypeDef huart4;
UART_HandleTypeDef huart1;
/* UART4 init function */ /* UART4 init function */
void MX_UART4_Init(void) void MX_UART4_Init(void)
@ -42,6 +43,25 @@ void MX_UART4_Init(void)
Error_Handler(); Error_Handler();
} }
}
/* USART1 init function */
void MX_USART1_UART_Init(void)
{
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
} }
void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
@ -71,13 +91,39 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/* UART4 interrupt Init */
HAL_NVIC_SetPriority(UART4_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(UART4_IRQn);
/* USER CODE BEGIN UART4_MspInit 1 */ /* USER CODE BEGIN UART4_MspInit 1 */
/* USER CODE END UART4_MspInit 1 */ /* USER CODE END UART4_MspInit 1 */
} }
else if(uartHandle->Instance==USART1)
{
/* USER CODE BEGIN USART1_MspInit 0 */
/* USER CODE END USART1_MspInit 0 */
/* USART1 clock enable */
__HAL_RCC_USART1_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/**USART1 GPIO Configuration
PB6 ------> USART1_TX
PB7 ------> USART1_RX
*/
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
__HAL_AFIO_REMAP_USART1_ENABLE();
/* USER CODE BEGIN USART1_MspInit 1 */
/* USER CODE END USART1_MspInit 1 */
}
} }
void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
@ -103,6 +149,24 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
/* USER CODE END UART4_MspDeInit 1 */ /* USER CODE END UART4_MspDeInit 1 */
} }
else if(uartHandle->Instance==USART1)
{
/* USER CODE BEGIN USART1_MspDeInit 0 */
/* USER CODE END USART1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_USART1_CLK_DISABLE();
/**USART1 GPIO Configuration
PB6 ------> USART1_TX
PB7 ------> USART1_RX
*/
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7);
/* USER CODE BEGIN USART1_MspDeInit 1 */
/* USER CODE END USART1_MspDeInit 1 */
}
} }
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,710 @@
/**
******************************************************************************
* @file stm32f1xx_hal_adc_ex.h
* @author MCD Application Team
* @brief Header file of ADC HAL extension module.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F1xx_HAL_ADC_EX_H
#define __STM32F1xx_HAL_ADC_EX_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal_def.h"
/** @addtogroup STM32F1xx_HAL_Driver
* @{
*/
/** @addtogroup ADCEx
* @{
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup ADCEx_Exported_Types ADCEx Exported Types
* @{
*/
/**
* @brief ADC Configuration injected Channel structure definition
* @note Parameters of this structure are shared within 2 scopes:
* - Scope channel: InjectedChannel, InjectedRank, InjectedSamplingTime, InjectedOffset
* - Scope injected group (affects all channels of injected group): InjectedNbrOfConversion, InjectedDiscontinuousConvMode,
* AutoInjectedConv, ExternalTrigInjecConvEdge, ExternalTrigInjecConv.
* @note The setting of these parameters with function HAL_ADCEx_InjectedConfigChannel() is conditioned to ADC state.
* ADC state can be either:
* - For all parameters: ADC disabled (this is the only possible ADC state to modify parameter 'ExternalTrigInjecConv')
* - For all except parameters 'ExternalTrigInjecConv': ADC enabled without conversion on going on injected group.
*/
typedef struct
{
uint32_t InjectedChannel; /*!< Selection of ADC channel to configure
This parameter can be a value of @ref ADC_channels
Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability.
Note: On STM32F1 devices with several ADC: Only ADC1 can access internal measurement channels (VrefInt/TempSensor)
Note: On STM32F10xx8 and STM32F10xxB devices: A low-amplitude voltage glitch may be generated (on ADC input 0) on the PA0 pin, when the ADC is converting with injection trigger.
It is advised to distribute the analog channels so that Channel 0 is configured as an injected channel.
Refer to errata sheet of these devices for more details. */
uint32_t InjectedRank; /*!< Rank in the injected group sequencer
This parameter must be a value of @ref ADCEx_injected_rank
Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel setting (or parameter number of conversions can be adjusted) */
uint32_t InjectedSamplingTime; /*!< Sampling time value to be set for the selected channel.
Unit: ADC clock cycles
Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits).
This parameter can be a value of @ref ADC_sampling_times
Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
Note: In case of usage of internal measurement channels (VrefInt/TempSensor),
sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
Refer to device datasheet for timings values, parameters TS_vrefint, TS_temp (values rough order: 5us to 17.1us min). */
uint32_t InjectedOffset; /*!< Defines the offset to be subtracted from the raw converted data (for channels set on injected group only).
Offset value must be a positive number.
Depending of ADC resolution selected (12, 10, 8 or 6 bits),
this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF, 0x3FF, 0xFF or 0x3F respectively. */
uint32_t InjectedNbrOfConversion; /*!< Specifies the number of ranks that will be converted within the injected group sequencer.
To use the injected group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
This parameter must be a number between Min_Data = 1 and Max_Data = 4.
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
configure a channel on injected group can impact the configuration of other channels previously set. */
FunctionalState InjectedDiscontinuousConvMode; /*!< Specifies whether the conversions sequence of injected group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
This parameter can be set to ENABLE or DISABLE.
Note: For injected group, number of discontinuous ranks increment is fixed to one-by-one.
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
configure a channel on injected group can impact the configuration of other channels previously set. */
FunctionalState AutoInjectedConv; /*!< Enables or disables the selected ADC automatic injected group conversion after regular one
This parameter can be set to ENABLE or DISABLE.
Note: To use Automatic injected conversion, discontinuous mode must be disabled ('DiscontinuousConvMode' and 'InjectedDiscontinuousConvMode' set to DISABLE)
Note: To use Automatic injected conversion, injected group external triggers must be disabled ('ExternalTrigInjecConv' set to ADC_SOFTWARE_START)
Note: In case of DMA used with regular group: if DMA configured in normal mode (single shot) JAUTO will be stopped upon DMA transfer complete.
To maintain JAUTO always enabled, DMA must be configured in circular mode.
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
configure a channel on injected group can impact the configuration of other channels previously set. */
uint32_t ExternalTrigInjecConv; /*!< Selects the external event used to trigger the conversion start of injected group.
If set to ADC_INJECTED_SOFTWARE_START, external triggers are disabled.
If set to external trigger source, triggering is on event rising edge.
This parameter can be a value of @ref ADCEx_External_trigger_source_Injected
Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behaviour in case of another parameter update on the fly)
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
configure a channel on injected group can impact the configuration of other channels previously set. */
}ADC_InjectionConfTypeDef;
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
/**
* @brief Structure definition of ADC multimode
* @note The setting of these parameters with function HAL_ADCEx_MultiModeConfigChannel() is conditioned to ADCs state (both ADCs of the common group).
* State of ADCs of the common group must be: disabled.
*/
typedef struct
{
uint32_t Mode; /*!< Configures the ADC to operate in independent or multi mode.
This parameter can be a value of @ref ADCEx_Common_mode
Note: In dual mode, a change of channel configuration generates a restart that can produce a loss of synchronization. It is recommended to disable dual mode before any configuration change.
Note: In case of simultaneous mode used: Exactly the same sampling time should be configured for the 2 channels that will be sampled simultaneously by ACD1 and ADC2.
Note: In case of interleaved mode used: To avoid overlap between conversions, maximum sampling time allowed is 7 ADC clock cycles for fast interleaved mode and 14 ADC clock cycles for slow interleaved mode.
Note: Some multimode parameters are fixed on STM32F1 and can be configured on other STM32 devices with several ADC (multimode configuration structure can have additional parameters).
The equivalences are:
- Parameter 'DMAAccessMode': On STM32F1, this parameter is fixed to 1 DMA channel (one DMA channel for both ADC, DMA of ADC master). On other STM32 devices with several ADC, this is equivalent to parameter 'ADC_DMAACCESSMODE_12_10_BITS'.
- Parameter 'TwoSamplingDelay': On STM32F1, this parameter is fixed to 7 or 14 ADC clock cycles depending on fast or slow interleaved mode selected. On other STM32 devices with several ADC, this is equivalent to parameter 'ADC_TWOSAMPLINGDELAY_7CYCLES' (for fast interleaved mode). */
}ADC_MultiModeTypeDef;
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
/**
* @}
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup ADCEx_Exported_Constants ADCEx Exported Constants
* @{
*/
/** @defgroup ADCEx_injected_rank ADCEx rank into injected group
* @{
*/
#define ADC_INJECTED_RANK_1 0x00000001U
#define ADC_INJECTED_RANK_2 0x00000002U
#define ADC_INJECTED_RANK_3 0x00000003U
#define ADC_INJECTED_RANK_4 0x00000004U
/**
* @}
*/
/** @defgroup ADCEx_External_trigger_edge_Injected ADCEx external trigger enable for injected group
* @{
*/
#define ADC_EXTERNALTRIGINJECCONV_EDGE_NONE 0x00000000U
#define ADC_EXTERNALTRIGINJECCONV_EDGE_RISING ((uint32_t)ADC_CR2_JEXTTRIG)
/**
* @}
*/
/** @defgroup ADC_External_trigger_source_Regular ADC External trigger selection for regular group
* @{
*/
/*!< List of external triggers with generic trigger name, independently of */
/* ADC target, sorted by trigger name: */
/*!< External triggers of regular group for ADC1&ADC2 only */
#define ADC_EXTERNALTRIGCONV_T1_CC1 ADC1_2_EXTERNALTRIG_T1_CC1
#define ADC_EXTERNALTRIGCONV_T1_CC2 ADC1_2_EXTERNALTRIG_T1_CC2
#define ADC_EXTERNALTRIGCONV_T2_CC2 ADC1_2_EXTERNALTRIG_T2_CC2
#define ADC_EXTERNALTRIGCONV_T3_TRGO ADC1_2_EXTERNALTRIG_T3_TRGO
#define ADC_EXTERNALTRIGCONV_T4_CC4 ADC1_2_EXTERNALTRIG_T4_CC4
#define ADC_EXTERNALTRIGCONV_EXT_IT11 ADC1_2_EXTERNALTRIG_EXT_IT11
#if defined (STM32F103xE) || defined (STM32F103xG)
/*!< External triggers of regular group for ADC3 only */
#define ADC_EXTERNALTRIGCONV_T2_CC3 ADC3_EXTERNALTRIG_T2_CC3
#define ADC_EXTERNALTRIGCONV_T3_CC1 ADC3_EXTERNALTRIG_T3_CC1
#define ADC_EXTERNALTRIGCONV_T5_CC1 ADC3_EXTERNALTRIG_T5_CC1
#define ADC_EXTERNALTRIGCONV_T5_CC3 ADC3_EXTERNALTRIG_T5_CC3
#define ADC_EXTERNALTRIGCONV_T8_CC1 ADC3_EXTERNALTRIG_T8_CC1
#endif /* STM32F103xE || defined STM32F103xG */
/*!< External triggers of regular group for all ADC instances */
#define ADC_EXTERNALTRIGCONV_T1_CC3 ADC1_2_3_EXTERNALTRIG_T1_CC3
#if defined (STM32F101xE) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC)
/*!< Note: TIM8_TRGO is available on ADC1 and ADC2 only in high-density and */
/* XL-density devices. */
/* To use it on ADC or ADC2, a remap of trigger must be done from */
/* EXTI line 11 to TIM8_TRGO with macro: */
/* __HAL_AFIO_REMAP_ADC1_ETRGREG_ENABLE() */
/* __HAL_AFIO_REMAP_ADC2_ETRGREG_ENABLE() */
/* Note for internal constant value management: If TIM8_TRGO is available, */
/* its definition is set to value for ADC1&ADC2 by default and changed to */
/* value for ADC3 by HAL ADC driver if ADC3 is selected. */
#define ADC_EXTERNALTRIGCONV_T8_TRGO ADC1_2_EXTERNALTRIG_T8_TRGO
#endif /* STM32F101xE || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
#define ADC_SOFTWARE_START ADC1_2_3_SWSTART
/**
* @}
*/
/** @defgroup ADCEx_External_trigger_source_Injected ADCEx External trigger selection for injected group
* @{
*/
/*!< List of external triggers with generic trigger name, independently of */
/* ADC target, sorted by trigger name: */
/*!< External triggers of injected group for ADC1&ADC2 only */
#define ADC_EXTERNALTRIGINJECCONV_T2_TRGO ADC1_2_EXTERNALTRIGINJEC_T2_TRGO
#define ADC_EXTERNALTRIGINJECCONV_T2_CC1 ADC1_2_EXTERNALTRIGINJEC_T2_CC1
#define ADC_EXTERNALTRIGINJECCONV_T3_CC4 ADC1_2_EXTERNALTRIGINJEC_T3_CC4
#define ADC_EXTERNALTRIGINJECCONV_T4_TRGO ADC1_2_EXTERNALTRIGINJEC_T4_TRGO
#define ADC_EXTERNALTRIGINJECCONV_EXT_IT15 ADC1_2_EXTERNALTRIGINJEC_EXT_IT15
#if defined (STM32F103xE) || defined (STM32F103xG)
/*!< External triggers of injected group for ADC3 only */
#define ADC_EXTERNALTRIGINJECCONV_T4_CC3 ADC3_EXTERNALTRIGINJEC_T4_CC3
#define ADC_EXTERNALTRIGINJECCONV_T8_CC2 ADC3_EXTERNALTRIGINJEC_T8_CC2
#define ADC_EXTERNALTRIGINJECCONV_T5_TRGO ADC3_EXTERNALTRIGINJEC_T5_TRGO
#define ADC_EXTERNALTRIGINJECCONV_T5_CC4 ADC3_EXTERNALTRIGINJEC_T5_CC4
#endif /* STM32F103xE || defined STM32F103xG */
/*!< External triggers of injected group for all ADC instances */
#define ADC_EXTERNALTRIGINJECCONV_T1_CC4 ADC1_2_3_EXTERNALTRIGINJEC_T1_CC4
#define ADC_EXTERNALTRIGINJECCONV_T1_TRGO ADC1_2_3_EXTERNALTRIGINJEC_T1_TRGO
#if defined (STM32F101xE) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC)
/*!< Note: TIM8_CC4 is available on ADC1 and ADC2 only in high-density and */
/* XL-density devices. */
/* To use it on ADC1 or ADC2, a remap of trigger must be done from */
/* EXTI line 11 to TIM8_CC4 with macro: */
/* __HAL_AFIO_REMAP_ADC1_ETRGINJ_ENABLE() */
/* __HAL_AFIO_REMAP_ADC2_ETRGINJ_ENABLE() */
/* Note for internal constant value management: If TIM8_CC4 is available, */
/* its definition is set to value for ADC1&ADC2 by default and changed to */
/* value for ADC3 by HAL ADC driver if ADC3 is selected. */
#define ADC_EXTERNALTRIGINJECCONV_T8_CC4 ADC1_2_EXTERNALTRIGINJEC_T8_CC4
#endif /* STM32F101xE || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
#define ADC_INJECTED_SOFTWARE_START ADC1_2_3_JSWSTART
/**
* @}
*/
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
/** @defgroup ADCEx_Common_mode ADC Extended Dual ADC Mode
* @{
*/
#define ADC_MODE_INDEPENDENT 0x00000000U /*!< ADC dual mode disabled (ADC independent mode) */
#define ADC_DUALMODE_REGSIMULT_INJECSIMULT ((uint32_t)( ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Combined regular simultaneous + injected simultaneous mode, on groups regular and injected */
#define ADC_DUALMODE_REGSIMULT_ALTERTRIG ((uint32_t)( ADC_CR1_DUALMOD_1 )) /*!< ADC dual mode enabled: Combined regular simultaneous + alternate trigger mode, on groups regular and injected */
#define ADC_DUALMODE_INJECSIMULT_INTERLFAST ((uint32_t)( ADC_CR1_DUALMOD_1 | ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Combined injected simultaneous + fast interleaved mode, on groups regular and injected (delay between ADC sampling phases: 7 ADC clock cycles (equivalent to parameter "TwoSamplingDelay" set to "ADC_TWOSAMPLINGDELAY_7CYCLES" on other STM32 devices)) */
#define ADC_DUALMODE_INJECSIMULT_INTERLSLOW ((uint32_t)( ADC_CR1_DUALMOD_2 )) /*!< ADC dual mode enabled: Combined injected simultaneous + slow Interleaved mode, on groups regular and injected (delay between ADC sampling phases: 14 ADC clock cycles (equivalent to parameter "TwoSamplingDelay" set to "ADC_TWOSAMPLINGDELAY_7CYCLES" on other STM32 devices)) */
#define ADC_DUALMODE_INJECSIMULT ((uint32_t)( ADC_CR1_DUALMOD_2 | ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Injected simultaneous mode, on group injected */
#define ADC_DUALMODE_REGSIMULT ((uint32_t)( ADC_CR1_DUALMOD_2 | ADC_CR1_DUALMOD_1 )) /*!< ADC dual mode enabled: Regular simultaneous mode, on group regular */
#define ADC_DUALMODE_INTERLFAST ((uint32_t)( ADC_CR1_DUALMOD_2 | ADC_CR1_DUALMOD_1 | ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Fast interleaved mode, on group regular (delay between ADC sampling phases: 7 ADC clock cycles (equivalent to parameter "TwoSamplingDelay" set to "ADC_TWOSAMPLINGDELAY_7CYCLES" on other STM32 devices)) */
#define ADC_DUALMODE_INTERLSLOW ((uint32_t)(ADC_CR1_DUALMOD_3 )) /*!< ADC dual mode enabled: Slow interleaved mode, on group regular (delay between ADC sampling phases: 14 ADC clock cycles (equivalent to parameter "TwoSamplingDelay" set to "ADC_TWOSAMPLINGDELAY_7CYCLES" on other STM32 devices)) */
#define ADC_DUALMODE_ALTERTRIG ((uint32_t)(ADC_CR1_DUALMOD_3 | ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Alternate trigger mode, on group injected */
/**
* @}
*/
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
/**
* @}
*/
/* Private constants ---------------------------------------------------------*/
/** @addtogroup ADCEx_Private_Constants ADCEx Private Constants
* @{
*/
/** @defgroup ADCEx_Internal_HAL_driver_Ext_trig_src_Regular ADC Extended Internal HAL driver trigger selection for regular group
* @{
*/
/* List of external triggers of regular group for ADC1, ADC2, ADC3 (if ADC */
/* instance is available on the selected device). */
/* (used internally by HAL driver. To not use into HAL structure parameters) */
/* External triggers of regular group for ADC1&ADC2 (if ADCx available) */
#define ADC1_2_EXTERNALTRIG_T1_CC1 0x00000000U
#define ADC1_2_EXTERNALTRIG_T1_CC2 ((uint32_t)( ADC_CR2_EXTSEL_0))
#define ADC1_2_EXTERNALTRIG_T2_CC2 ((uint32_t)( ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
#define ADC1_2_EXTERNALTRIG_T3_TRGO ((uint32_t)(ADC_CR2_EXTSEL_2 ))
#define ADC1_2_EXTERNALTRIG_T4_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
#define ADC1_2_EXTERNALTRIG_EXT_IT11 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 ))
#if defined (STM32F101xE) || defined (STM32F103xE) || defined (STM32F103xG)
/* Note: TIM8_TRGO is available on ADC1 and ADC2 only in high-density and */
/* XL-density devices. */
#define ADC1_2_EXTERNALTRIG_T8_TRGO ADC1_2_EXTERNALTRIG_EXT_IT11
#endif
#if defined (STM32F103xE) || defined (STM32F103xG)
/* External triggers of regular group for ADC3 */
#define ADC3_EXTERNALTRIG_T3_CC1 ADC1_2_EXTERNALTRIG_T1_CC1
#define ADC3_EXTERNALTRIG_T2_CC3 ADC1_2_EXTERNALTRIG_T1_CC2
#define ADC3_EXTERNALTRIG_T8_CC1 ADC1_2_EXTERNALTRIG_T2_CC2
#define ADC3_EXTERNALTRIG_T8_TRGO ADC1_2_EXTERNALTRIG_T3_TRGO
#define ADC3_EXTERNALTRIG_T5_CC1 ADC1_2_EXTERNALTRIG_T4_CC4
#define ADC3_EXTERNALTRIG_T5_CC3 ADC1_2_EXTERNALTRIG_EXT_IT11
#endif
/* External triggers of regular group for ADC1&ADC2&ADC3 (if ADCx available) */
#define ADC1_2_3_EXTERNALTRIG_T1_CC3 ((uint32_t)( ADC_CR2_EXTSEL_1 ))
#define ADC1_2_3_SWSTART ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
/**
* @}
*/
/** @defgroup ADCEx_Internal_HAL_driver_Ext_trig_src_Injected ADC Extended Internal HAL driver trigger selection for injected group
* @{
*/
/* List of external triggers of injected group for ADC1, ADC2, ADC3 (if ADC */
/* instance is available on the selected device). */
/* (used internally by HAL driver. To not use into HAL structure parameters) */
/* External triggers of injected group for ADC1&ADC2 (if ADCx available) */
#define ADC1_2_EXTERNALTRIGINJEC_T2_TRGO ((uint32_t)( ADC_CR2_JEXTSEL_1 ))
#define ADC1_2_EXTERNALTRIGINJEC_T2_CC1 ((uint32_t)( ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0))
#define ADC1_2_EXTERNALTRIGINJEC_T3_CC4 ((uint32_t)(ADC_CR2_JEXTSEL_2 ))
#define ADC1_2_EXTERNALTRIGINJEC_T4_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0))
#define ADC1_2_EXTERNALTRIGINJEC_EXT_IT15 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 ))
#if defined (STM32F101xE) || defined (STM32F103xE) || defined (STM32F103xG)
/* Note: TIM8_CC4 is available on ADC1 and ADC2 only in high-density and */
/* XL-density devices. */
#define ADC1_2_EXTERNALTRIGINJEC_T8_CC4 ADC1_2_EXTERNALTRIGINJEC_EXT_IT15
#endif
#if defined (STM32F103xE) || defined (STM32F103xG)
/* External triggers of injected group for ADC3 */
#define ADC3_EXTERNALTRIGINJEC_T4_CC3 ADC1_2_EXTERNALTRIGINJEC_T2_TRGO
#define ADC3_EXTERNALTRIGINJEC_T8_CC2 ADC1_2_EXTERNALTRIGINJEC_T2_CC1
#define ADC3_EXTERNALTRIGINJEC_T8_CC4 ADC1_2_EXTERNALTRIGINJEC_T3_CC4
#define ADC3_EXTERNALTRIGINJEC_T5_TRGO ADC1_2_EXTERNALTRIGINJEC_T4_TRGO
#define ADC3_EXTERNALTRIGINJEC_T5_CC4 ADC1_2_EXTERNALTRIGINJEC_EXT_IT15
#endif /* STM32F103xE || defined STM32F103xG */
/* External triggers of injected group for ADC1&ADC2&ADC3 (if ADCx available) */
#define ADC1_2_3_EXTERNALTRIGINJEC_T1_TRGO 0x00000000U
#define ADC1_2_3_EXTERNALTRIGINJEC_T1_CC4 ((uint32_t)( ADC_CR2_JEXTSEL_0))
#define ADC1_2_3_JSWSTART ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0))
/**
* @}
*/
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/** @defgroup ADCEx_Private_Macro ADCEx Private Macro
* @{
*/
/* Macro reserved for internal HAL driver usage, not intended to be used in */
/* code of final user. */
/**
* @brief For devices with 3 ADCs: Defines the external trigger source
* for regular group according to ADC into common group ADC1&ADC2 or
* ADC3 (some triggers with same source have different value to
* be programmed into ADC EXTSEL bits of CR2 register).
* For devices with 2 ADCs or less: this macro makes no change.
* @param __HANDLE__: ADC handle
* @param __EXT_TRIG_CONV__: External trigger selected for regular group.
* @retval External trigger to be programmed into EXTSEL bits of CR2 register
*/
#if defined (STM32F103xE) || defined (STM32F103xG)
#define ADC_CFGR_EXTSEL(__HANDLE__, __EXT_TRIG_CONV__) \
(( (((__HANDLE__)->Instance) == ADC3) \
)? \
( ( (__EXT_TRIG_CONV__) == ADC_EXTERNALTRIGCONV_T8_TRGO \
)? \
(ADC3_EXTERNALTRIG_T8_TRGO) \
: \
(__EXT_TRIG_CONV__) \
) \
: \
(__EXT_TRIG_CONV__) \
)
#else
#define ADC_CFGR_EXTSEL(__HANDLE__, __EXT_TRIG_CONV__) \
(__EXT_TRIG_CONV__)
#endif /* STM32F103xE || STM32F103xG */
/**
* @brief For devices with 3 ADCs: Defines the external trigger source
* for injected group according to ADC into common group ADC1&ADC2 or
* ADC3 (some triggers with same source have different value to
* be programmed into ADC JEXTSEL bits of CR2 register).
* For devices with 2 ADCs or less: this macro makes no change.
* @param __HANDLE__: ADC handle
* @param __EXT_TRIG_INJECTCONV__: External trigger selected for injected group.
* @retval External trigger to be programmed into JEXTSEL bits of CR2 register
*/
#if defined (STM32F103xE) || defined (STM32F103xG)
#define ADC_CFGR_JEXTSEL(__HANDLE__, __EXT_TRIG_INJECTCONV__) \
(( (((__HANDLE__)->Instance) == ADC3) \
)? \
( ( (__EXT_TRIG_INJECTCONV__) == ADC_EXTERNALTRIGINJECCONV_T8_CC4 \
)? \
(ADC3_EXTERNALTRIGINJEC_T8_CC4) \
: \
(__EXT_TRIG_INJECTCONV__) \
) \
: \
(__EXT_TRIG_INJECTCONV__) \
)
#else
#define ADC_CFGR_JEXTSEL(__HANDLE__, __EXT_TRIG_INJECTCONV__) \
(__EXT_TRIG_INJECTCONV__)
#endif /* STM32F103xE || STM32F103xG */
/**
* @brief Verification if multimode is enabled for the selected ADC (multimode ADC master or ADC slave) (applicable for devices with several ADCs)
* @param __HANDLE__: ADC handle
* @retval Multimode state: RESET if multimode is disabled, other value if multimode is enabled
*/
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
#define ADC_MULTIMODE_IS_ENABLE(__HANDLE__) \
(( (((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2) \
)? \
(ADC1->CR1 & ADC_CR1_DUALMOD) \
: \
(RESET) \
)
#else
#define ADC_MULTIMODE_IS_ENABLE(__HANDLE__) \
(RESET)
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
/**
* @brief Verification of condition for ADC start conversion: ADC must be in non-multimode, or multimode with handle of ADC master (applicable for devices with several ADCs)
* @param __HANDLE__: ADC handle
* @retval None
*/
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
#define ADC_NONMULTIMODE_OR_MULTIMODEMASTER(__HANDLE__) \
(( (((__HANDLE__)->Instance) == ADC2) \
)? \
((ADC1->CR1 & ADC_CR1_DUALMOD) == RESET) \
: \
(!RESET) \
)
#else
#define ADC_NONMULTIMODE_OR_MULTIMODEMASTER(__HANDLE__) \
(!RESET)
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
/**
* @brief Check ADC multimode setting: In case of multimode, check whether ADC master of the selected ADC has feature auto-injection enabled (applicable for devices with several ADCs)
* @param __HANDLE__: ADC handle
* @retval None
*/
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
#define ADC_MULTIMODE_AUTO_INJECTED(__HANDLE__) \
(( (((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2) \
)? \
(ADC1->CR1 & ADC_CR1_JAUTO) \
: \
(RESET) \
)
#else
#define ADC_MULTIMODE_AUTO_INJECTED(__HANDLE__) \
(RESET)
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
/**
* @brief Set handle of the other ADC sharing the common multimode settings
* @param __HANDLE__: ADC handle
* @param __HANDLE_OTHER_ADC__: other ADC handle
* @retval None
*/
#define ADC_COMMON_ADC_OTHER(__HANDLE__, __HANDLE_OTHER_ADC__) \
((__HANDLE_OTHER_ADC__)->Instance = ADC2)
/**
* @brief Set handle of the ADC slave associated to the ADC master
* On STM32F1 devices, ADC slave is always ADC2 (this can be different
* on other STM32 devices)
* @param __HANDLE_MASTER__: ADC master handle
* @param __HANDLE_SLAVE__: ADC slave handle
* @retval None
*/
#define ADC_MULTI_SLAVE(__HANDLE_MASTER__, __HANDLE_SLAVE__) \
((__HANDLE_SLAVE__)->Instance = ADC2)
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
#define IS_ADC_INJECTED_RANK(CHANNEL) (((CHANNEL) == ADC_INJECTED_RANK_1) || \
((CHANNEL) == ADC_INJECTED_RANK_2) || \
((CHANNEL) == ADC_INJECTED_RANK_3) || \
((CHANNEL) == ADC_INJECTED_RANK_4))
#define IS_ADC_EXTTRIGINJEC_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGINJECCONV_EDGE_NONE) || \
((EDGE) == ADC_EXTERNALTRIGINJECCONV_EDGE_RISING))
/** @defgroup ADCEx_injected_nb_conv_verification ADCEx injected nb conv verification
* @{
*/
#define IS_ADC_INJECTED_NB_CONV(LENGTH) (((LENGTH) >= 1U) && ((LENGTH) <= 4U))
/**
* @}
*/
#if defined (STM32F100xB) || defined (STM32F100xE) || defined (STM32F101x6) || defined (STM32F101xB) || defined (STM32F102x6) || defined (STM32F102xB) || defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC)
#define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
((REGTRIG) == ADC_SOFTWARE_START))
#endif
#if defined (STM32F101xE)
#define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
((REGTRIG) == ADC_SOFTWARE_START))
#endif
#if defined (STM32F101xG)
#define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
((REGTRIG) == ADC_SOFTWARE_START))
#endif
#if defined (STM32F103xE) || defined (STM32F103xG)
#define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC1) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC3) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_CC1) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC1) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC3) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
((REGTRIG) == ADC_SOFTWARE_START))
#endif
#if defined (STM32F100xB) || defined (STM32F100xE) || defined (STM32F101x6) || defined (STM32F101xB) || defined (STM32F102x6) || defined (STM32F102xB) || defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC)
#define IS_ADC_EXTTRIGINJEC(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
((REGTRIG) == ADC_INJECTED_SOFTWARE_START))
#endif
#if defined (STM32F101xE)
#define IS_ADC_EXTTRIGINJEC(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4) || \
((REGTRIG) == ADC_INJECTED_SOFTWARE_START))
#endif
#if defined (STM32F101xG)
#define IS_ADC_EXTTRIGINJEC(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
((REGTRIG) == ADC_INJECTED_SOFTWARE_START))
#endif
#if defined (STM32F103xE) || defined (STM32F103xG)
#define IS_ADC_EXTTRIGINJEC(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_CC4) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC3) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC2) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_CC4) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4) || \
((REGTRIG) == ADC_INJECTED_SOFTWARE_START))
#endif
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
#define IS_ADC_MODE(MODE) (((MODE) == ADC_MODE_INDEPENDENT) || \
((MODE) == ADC_DUALMODE_REGSIMULT_INJECSIMULT) || \
((MODE) == ADC_DUALMODE_REGSIMULT_ALTERTRIG) || \
((MODE) == ADC_DUALMODE_INJECSIMULT_INTERLFAST) || \
((MODE) == ADC_DUALMODE_INJECSIMULT_INTERLSLOW) || \
((MODE) == ADC_DUALMODE_INJECSIMULT) || \
((MODE) == ADC_DUALMODE_REGSIMULT) || \
((MODE) == ADC_DUALMODE_INTERLFAST) || \
((MODE) == ADC_DUALMODE_INTERLSLOW) || \
((MODE) == ADC_DUALMODE_ALTERTRIG) )
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup ADCEx_Exported_Functions
* @{
*/
/* IO operation functions *****************************************************/
/** @addtogroup ADCEx_Exported_Functions_Group1
* @{
*/
/* ADC calibration */
HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef* hadc);
/* Blocking mode: Polling */
HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef* hadc);
HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef* hadc);
HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
/* Non-blocking mode: Interruption */
HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef* hadc);
HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef* hadc);
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
/* ADC multimode */
HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length);
HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef *hadc);
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
/* ADC retrieve conversion value intended to be used with polling or interruption */
uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank);
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef *hadc);
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
/* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption) */
void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc);
/**
* @}
*/
/* Peripheral Control functions ***********************************************/
/** @addtogroup ADCEx_Exported_Functions_Group2
* @{
*/
HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef* hadc,ADC_InjectionConfTypeDef* sConfigInjected);
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef *hadc, ADC_MultiModeTypeDef *multimode);
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __STM32F1xx_HAL_ADC_EX_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1027,7 +1027,7 @@ void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd)
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
hpcd->SuspendCallback(hpcd); hpcd->SuspendCallback(hpcd);
#else #else
//HAL_PCD_SuspendCallback(hpcd); HAL_PCD_SuspendCallback(hpcd);
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
} }
__HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_USBSUSP); __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_USBSUSP);

View File

@ -297,5 +297,5 @@ bool coulomb_read_status_and_config()
bool coulomb_read_alcc() bool coulomb_read_alcc()
{ {
return HAL_GPIO_ReadPin(COULOMB_ALCC_GPIO_Port,COULOMB_ALCC_Pin); return HAL_GPIO_ReadPin(PMB_CLOULOMB_ALCC_GPIO_Port,PMB_CLOULOMB_ALCC_Pin);
} }

View File

@ -1,4 +1,11 @@
#MicroXplorer Configuration settings - do not modify #MicroXplorer Configuration settings - do not modify
ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_3
ADC1.ContinuousConvMode=ENABLE
ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ContinuousConvMode
ADC1.NbrOfConversionFlag=1
ADC1.Rank-0\#ChannelRegularConversion=1
ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5
ADC1.master=1
ARM.CMSIS.5.6.0.CMSISJjCORE=true ARM.CMSIS.5.6.0.CMSISJjCORE=true
ARM.CMSIS.5.6.0.CMSISJjDSP=Library ARM.CMSIS.5.6.0.CMSISJjDSP=Library
ARM.CMSIS.5.6.0.CMSISJjNNOoLib=true ARM.CMSIS.5.6.0.CMSISJjNNOoLib=true
@ -22,13 +29,26 @@ ARM.CMSIS.5.6.0.DeviceJjOSOoTickJjPrivateOoTimer=true
ARM.CMSIS.5.6.0.DeviceJjStartup=COoStartup ARM.CMSIS.5.6.0.DeviceJjStartup=COoStartup
ARM.CMSIS.5.6.0.IPParameters=CMSISJjCORE,CMSISJjNNOoLib,DeviceJjIRQOoControllerJjGIC,DeviceJjOSOoTickJjPrivateOoTimer,CMSISOoDriverJjUSARTJjCustom,CMSISOoDriverJjSPIJjCustom,CMSISOoDriverJjSAIJjCustom,CMSISOoDriverJjI2CJjCustom,CMSISOoDriverJjCANJjCustom,CMSISOoDriverJjFlashJjCustom,CMSISOoDriverJjMCIJjCustom,CMSISOoDriverJjNANDJjCustom,CMSISOoDriverJjEthernetJjCustom,CMSISOoDriverJjEthernetOoMACJjCustom,CMSISOoDriverJjEthernetOoPHYJjCustom,CMSISOoDriverJjUSBOoDeviceJjCustom,CMSISOoDriverJjUSBOoHostJjCustom,CMSISOoDriverJjWiFiJjCustom,CMSISJjDSP,DeviceJjStartup ARM.CMSIS.5.6.0.IPParameters=CMSISJjCORE,CMSISJjNNOoLib,DeviceJjIRQOoControllerJjGIC,DeviceJjOSOoTickJjPrivateOoTimer,CMSISOoDriverJjUSARTJjCustom,CMSISOoDriverJjSPIJjCustom,CMSISOoDriverJjSAIJjCustom,CMSISOoDriverJjI2CJjCustom,CMSISOoDriverJjCANJjCustom,CMSISOoDriverJjFlashJjCustom,CMSISOoDriverJjMCIJjCustom,CMSISOoDriverJjNANDJjCustom,CMSISOoDriverJjEthernetJjCustom,CMSISOoDriverJjEthernetOoMACJjCustom,CMSISOoDriverJjEthernetOoPHYJjCustom,CMSISOoDriverJjUSBOoDeviceJjCustom,CMSISOoDriverJjUSBOoHostJjCustom,CMSISOoDriverJjWiFiJjCustom,CMSISJjDSP,DeviceJjStartup
ARM.CMSIS.5.6.0_SwParameter=CMSISOoDriverJjUSARTJjCustom\:true;DeviceJjOSOoTickJjPrivateOoTimer\:true;CMSISOoDriverJjUSBOoDeviceJjCustom\:true;CMSISOoDriverJjCANJjCustom\:true;CMSISJjCORE\:true;CMSISOoDriverJjFlashJjCustom\:true;CMSISOoDriverJjNANDJjCustom\:true;CMSISOoDriverJjEthernetJjCustom\:true;CMSISOoDriverJjEthernetOoMACJjCustom\:true;CMSISOoDriverJjUSBOoHostJjCustom\:true;CMSISOoDriverJjSAIJjCustom\:true;CMSISOoDriverJjWiFiJjCustom\:true;CMSISJjDSP\:Library;CMSISOoDriverJjSPIJjCustom\:true;CMSISOoDriverJjMCIJjCustom\:true;CMSISOoDriverJjEthernetOoPHYJjCustom\:true;DeviceJjIRQOoControllerJjGIC\:true;CMSISJjNNOoLib\:true;DeviceJjStartup\:COoStartup;CMSISOoDriverJjI2CJjCustom\:true; ARM.CMSIS.5.6.0_SwParameter=CMSISOoDriverJjUSARTJjCustom\:true;DeviceJjOSOoTickJjPrivateOoTimer\:true;CMSISOoDriverJjUSBOoDeviceJjCustom\:true;CMSISOoDriverJjCANJjCustom\:true;CMSISJjCORE\:true;CMSISOoDriverJjFlashJjCustom\:true;CMSISOoDriverJjNANDJjCustom\:true;CMSISOoDriverJjEthernetJjCustom\:true;CMSISOoDriverJjEthernetOoMACJjCustom\:true;CMSISOoDriverJjUSBOoHostJjCustom\:true;CMSISOoDriverJjSAIJjCustom\:true;CMSISOoDriverJjWiFiJjCustom\:true;CMSISJjDSP\:Library;CMSISOoDriverJjSPIJjCustom\:true;CMSISOoDriverJjMCIJjCustom\:true;CMSISOoDriverJjEthernetOoPHYJjCustom\:true;DeviceJjIRQOoControllerJjGIC\:true;CMSISJjNNOoLib\:true;DeviceJjStartup\:COoStartup;CMSISOoDriverJjI2CJjCustom\:true;
FREERTOS.FootprintOK=true Dma.ADC1.0.Direction=DMA_PERIPH_TO_MEMORY
Dma.ADC1.0.Instance=DMA1_Channel1
Dma.ADC1.0.MemDataAlignment=DMA_MDATAALIGN_WORD
Dma.ADC1.0.MemInc=DMA_MINC_ENABLE
Dma.ADC1.0.Mode=DMA_CIRCULAR
Dma.ADC1.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD
Dma.ADC1.0.PeriphInc=DMA_PINC_DISABLE
Dma.ADC1.0.Priority=DMA_PRIORITY_LOW
Dma.ADC1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
Dma.Request0=ADC1
Dma.RequestsNb=1
FREERTOS.FootprintOK=false
FREERTOS.HEAP_NUMBER=4
FREERTOS.INCLUDE_xTaskGetCurrentTaskHandle=1 FREERTOS.INCLUDE_xTaskGetCurrentTaskHandle=1
FREERTOS.INCLUDE_xTaskGetHandle=1 FREERTOS.INCLUDE_xTaskGetHandle=1
FREERTOS.IPParameters=Tasks01,configMAX_TASK_NAME_LEN,configUSE_TICKLESS_IDLE,INCLUDE_xTaskGetCurrentTaskHandle,INCLUDE_xTaskGetHandle,configUSE_APPLICATION_TASK_TAG,FootprintOK,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,configGENERATE_RUN_TIME_STATS,configUSE_STATS_FORMATTING_FUNCTIONS,configUSE_TRACE_FACILITY FREERTOS.IPParameters=Tasks01,configMAX_TASK_NAME_LEN,configUSE_TICKLESS_IDLE,INCLUDE_xTaskGetCurrentTaskHandle,INCLUDE_xTaskGetHandle,configUSE_APPLICATION_TASK_TAG,FootprintOK,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,configGENERATE_RUN_TIME_STATS,configUSE_STATS_FORMATTING_FUNCTIONS,configUSE_TRACE_FACILITY,HEAP_NUMBER,configTOTAL_HEAP_SIZE
FREERTOS.Tasks01=defaultTask,24,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL;LedBlinkTask,8,128,StartLedBlinkTask,Default,NULL,Dynamic,NULL,NULL;IWDGRefreshTask,40,128,StartIWDGRefreshTask,Default,NULL,Dynamic,NULL,NULL;ButtonDetect,8,128,StartButtonDetect,Default,NULL,Dynamic,NULL,NULL;CoulombRead,8,128,StartCoulombRead,Default,NULL,Dynamic,NULL,NULL FREERTOS.Tasks01=defaultTask,24,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL;LedBlinkTask,8,128,StartLedBlinkTask,Default,NULL,Dynamic,NULL,NULL;IWDGRefreshTask,40,128,StartIWDGRefreshTask,Default,NULL,Dynamic,NULL,NULL;ButtonDetect,8,128,StartButtonDetect,Default,NULL,Dynamic,NULL,NULL;CoulombRead,8,128,StartCoulombRead,Default,NULL,Dynamic,NULL,NULL;StateSwitchTask,8,128,StartStateSwitchTask,Default,NULL,Dynamic,NULL,NULL;SOMPowerManageTask,8,128,StartSOMPowerManageTask,Default,NULL,Dynamic,NULL,NULL
FREERTOS.configGENERATE_RUN_TIME_STATS=0 FREERTOS.configGENERATE_RUN_TIME_STATS=0
FREERTOS.configMAX_TASK_NAME_LEN=32 FREERTOS.configMAX_TASK_NAME_LEN=32
FREERTOS.configTOTAL_HEAP_SIZE=8192
FREERTOS.configUSE_APPLICATION_TASK_TAG=0 FREERTOS.configUSE_APPLICATION_TASK_TAG=0
FREERTOS.configUSE_IDLE_HOOK=0 FREERTOS.configUSE_IDLE_HOOK=0
FREERTOS.configUSE_MALLOC_FAILED_HOOK=0 FREERTOS.configUSE_MALLOC_FAILED_HOOK=0
@ -43,95 +63,136 @@ IWDG.Prescaler=IWDG_PRESCALER_16
IWDG.Reload=0xfff IWDG.Reload=0xfff
KeepUserPlacement=false KeepUserPlacement=false
Mcu.Family=STM32F1 Mcu.Family=STM32F1
Mcu.IP0=FREERTOS Mcu.IP0=ADC1
Mcu.IP1=I2C1 Mcu.IP1=DMA
Mcu.IP2=IWDG Mcu.IP10=USB_DEVICE
Mcu.IP3=NVIC Mcu.IP11=USB_OTG_FS
Mcu.IP4=RCC Mcu.IP2=FREERTOS
Mcu.IP5=SYS Mcu.IP3=I2C1
Mcu.IP6=UART4 Mcu.IP4=IWDG
Mcu.IP7=USB_DEVICE Mcu.IP5=NVIC
Mcu.IP8=USB_OTG_FS Mcu.IP6=RCC
Mcu.IPNb=9 Mcu.IP7=SYS
Mcu.IP8=UART4
Mcu.IP9=USART1
Mcu.IPNb=12
Mcu.Name=STM32F107V(B-C)Tx Mcu.Name=STM32F107V(B-C)Tx
Mcu.Package=LQFP100 Mcu.Package=LQFP100
Mcu.Pin0=PE2 Mcu.Pin0=PE2
Mcu.Pin1=PE3 Mcu.Pin1=PE3
Mcu.Pin10=PA11 Mcu.Pin10=PC3
Mcu.Pin11=PA12 Mcu.Pin11=PA0-WKUP
Mcu.Pin12=PA13 Mcu.Pin12=PA3
Mcu.Pin13=PA14 Mcu.Pin13=PA4
Mcu.Pin14=PC10 Mcu.Pin14=PA5
Mcu.Pin15=PC11 Mcu.Pin15=PA6
Mcu.Pin16=PD2 Mcu.Pin16=PA7
Mcu.Pin17=PD3 Mcu.Pin17=PC4
Mcu.Pin18=PD4 Mcu.Pin18=PC5
Mcu.Pin19=PD5 Mcu.Pin19=PE8
Mcu.Pin2=OSC_IN Mcu.Pin2=PE4
Mcu.Pin20=PD6 Mcu.Pin20=PE9
Mcu.Pin21=PD7 Mcu.Pin21=PE10
Mcu.Pin22=PB3 Mcu.Pin22=PE11
Mcu.Pin23=PB6 Mcu.Pin23=PE12
Mcu.Pin24=PB7 Mcu.Pin24=PE13
Mcu.Pin25=PB8 Mcu.Pin25=PB10
Mcu.Pin26=PB9 Mcu.Pin26=PB11
Mcu.Pin27=PE0 Mcu.Pin27=PB12
Mcu.Pin28=PE1 Mcu.Pin28=PB13
Mcu.Pin29=VP_FREERTOS_VS_CMSIS_V2 Mcu.Pin29=PB14
Mcu.Pin3=OSC_OUT Mcu.Pin3=PE5
Mcu.Pin30=VP_IWDG_VS_IWDG Mcu.Pin30=PB15
Mcu.Pin31=VP_SYS_VS_tim1 Mcu.Pin31=PD8
Mcu.Pin32=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS Mcu.Pin32=PD9
Mcu.Pin4=PA0-WKUP Mcu.Pin33=PD10
Mcu.Pin5=PE12 Mcu.Pin34=PD11
Mcu.Pin6=PE13 Mcu.Pin35=PD12
Mcu.Pin7=PE14 Mcu.Pin36=PD13
Mcu.Pin8=PE15 Mcu.Pin37=PD14
Mcu.Pin9=PA8 Mcu.Pin38=PD15
Mcu.PinsNb=33 Mcu.Pin39=PA8
Mcu.Pin4=PE6
Mcu.Pin40=PA11
Mcu.Pin41=PA12
Mcu.Pin42=PA13
Mcu.Pin43=PA14
Mcu.Pin44=PC10
Mcu.Pin45=PC11
Mcu.Pin46=PC12
Mcu.Pin47=PD0
Mcu.Pin48=PD1
Mcu.Pin49=PD2
Mcu.Pin5=OSC_IN
Mcu.Pin50=PD3
Mcu.Pin51=PD4
Mcu.Pin52=PD5
Mcu.Pin53=PD6
Mcu.Pin54=PD7
Mcu.Pin55=PB3
Mcu.Pin56=PB4
Mcu.Pin57=PB5
Mcu.Pin58=PB6
Mcu.Pin59=PB7
Mcu.Pin6=OSC_OUT
Mcu.Pin60=PB8
Mcu.Pin61=PB9
Mcu.Pin62=VP_FREERTOS_VS_CMSIS_V2
Mcu.Pin63=VP_IWDG_VS_IWDG
Mcu.Pin64=VP_SYS_VS_tim1
Mcu.Pin65=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS
Mcu.Pin7=PC0
Mcu.Pin8=PC1
Mcu.Pin9=PC2
Mcu.PinsNb=66
Mcu.ThirdParty0=ARM.CMSIS.5.6.0 Mcu.ThirdParty0=ARM.CMSIS.5.6.0
Mcu.ThirdPartyNb=1 Mcu.ThirdPartyNb=1
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32F107VCTx Mcu.UserName=STM32F107VCTx
MxCube.Version=5.6.0 MxCube.Version=5.6.1
MxDb.Version=DB.5.0.60 MxDb.Version=DB.5.0.60
NVIC.ADC1_2_IRQn=true\:5\:0\:false\:true\:true\:1\:true\:true\:true
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.DMA1_Channel1_IRQn=true\:5\:0\:false\:true\:true\:9\:true\:false\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.EXTI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true NVIC.EXTI0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true
NVIC.FLASH_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true NVIC.EXTI3_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true
NVIC.FLASH_IRQn=true\:5\:0\:false\:true\:true\:3\:true\:true\:true
NVIC.ForceEnableDMAVector=true NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.I2C1_ER_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true NVIC.I2C1_ER_IRQn=true\:5\:0\:false\:true\:true\:6\:true\:true\:true
NVIC.I2C1_EV_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true NVIC.I2C1_EV_IRQn=true\:5\:0\:false\:true\:true\:5\:true\:true\:true
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true NVIC.OTG_FS_IRQn=true\:5\:0\:false\:true\:true\:8\:true\:false\:true
NVIC.PVD_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true NVIC.PVD_IRQn=true\:5\:0\:false\:true\:true\:4\:true\:true\:true
NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.RCC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:false NVIC.RCC_IRQn=true\:5\:0\:false\:true\:true\:2\:true\:true\:false
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false
NVIC.TIM1_UP_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true NVIC.TIM1_UP_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
NVIC.TimeBase=TIM1_UP_IRQn NVIC.TimeBase=TIM1_UP_IRQn
NVIC.TimeBaseIP=TIM1 NVIC.TimeBaseIP=TIM1
NVIC.UART4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true NVIC.UART4_IRQn=true\:5\:0\:false\:true\:true\:7\:true\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
OSC_IN.Mode=HSE-External-Oscillator OSC_IN.Mode=HSE-External-Oscillator
OSC_IN.Signal=RCC_OSC_IN OSC_IN.Signal=RCC_OSC_IN
OSC_OUT.Mode=HSE-External-Oscillator OSC_OUT.Mode=HSE-External-Oscillator
OSC_OUT.Signal=RCC_OSC_OUT OSC_OUT.Signal=RCC_OSC_OUT
PA0-WKUP.GPIOParameters=GPIO_Label PA0-WKUP.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI
PA0-WKUP.GPIO_Label=SYS_WKUP PA0-WKUP.GPIO_Label=SYS_POWER_BTN
PA0-WKUP.Mode=SYS_WakeUp0 PA0-WKUP.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING
PA0-WKUP.Signal=SYS_WKUP PA0-WKUP.GPIO_PuPd=GPIO_PULLDOWN
PA0-WKUP.Locked=true
PA0-WKUP.Signal=GPXTI0
PA11.GPIOParameters=GPIO_Label PA11.GPIOParameters=GPIO_Label
PA11.GPIO_Label=USB2_DM_G7 PA11.GPIO_Label=USB2_FS_DM
PA11.Locked=true PA11.Locked=true
PA11.Mode=Device_Only PA11.Mode=Device_Only
PA11.Signal=USB_OTG_FS_DM PA11.Signal=USB_OTG_FS_DM
PA12.GPIOParameters=GPIO_Label PA12.GPIOParameters=GPIO_Label
PA12.GPIO_Label=USB2_DP_G7 PA12.GPIO_Label=USB2_FS_DP
PA12.Locked=true PA12.Locked=true
PA12.Mode=Device_Only PA12.Mode=Device_Only
PA12.Signal=USB_OTG_FS_DP PA12.Signal=USB_OTG_FS_DP
@ -145,98 +206,231 @@ PA14.GPIO_Label=SYS_SWCLK
PA14.Locked=true PA14.Locked=true
PA14.Mode=Trace_Asynchronous_SW PA14.Mode=Trace_Asynchronous_SW
PA14.Signal=SYS_JTCK-SWCLK PA14.Signal=SYS_JTCK-SWCLK
PA3.GPIOParameters=GPIO_Label
PA3.GPIO_Label=MON_24V0_DIV16
PA3.Locked=true
PA3.Signal=ADCx_IN3
PA4.GPIOParameters=GPIO_Label
PA4.GPIO_Label=MON_5V0_DIV8
PA4.Locked=true
PA4.Signal=ADCx_IN4
PA5.GPIOParameters=GPIO_Label
PA5.GPIO_Label=MON_12V0_DIV8
PA5.Locked=true
PA5.Signal=ADCx_IN5
PA6.GPIOParameters=GPIO_Label
PA6.GPIO_Label=MON_BKP_BAT_DIV8
PA6.Locked=true
PA6.Signal=ADCx_IN6
PA7.GPIOParameters=GPIO_Label
PA7.GPIO_Label=MON_MAIN_PWR_DIV16
PA7.Locked=true
PA7.Signal=ADCx_IN7
PA8.GPIOParameters=PinState,GPIO_Label,GPIO_ModeDefaultOutputPP PA8.GPIOParameters=PinState,GPIO_Label,GPIO_ModeDefaultOutputPP
PA8.GPIO_Label=ENUM_CTL PA8.GPIO_Label=USB2_FS_ENUM_CTL
PA8.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP PA8.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
PA8.Locked=true PA8.Locked=true
PA8.PinState=GPIO_PIN_RESET PA8.PinState=GPIO_PIN_RESET
PA8.Signal=GPIO_Output PA8.Signal=GPIO_Output
PB10.GPIOParameters=GPIO_Label
PB10.GPIO_Label=IIC2_SCL
PB10.Locked=true
PB10.Signal=GPIO_Output
PB11.GPIOParameters=GPIO_Label
PB11.GPIO_Label=IIC2_SDA
PB11.Locked=true
PB11.Signal=GPIO_Output
PB12.GPIOParameters=GPIO_Label
PB12.GPIO_Label=USB2_VBUS_CTL_1
PB12.Locked=true
PB12.Signal=GPIO_Output
PB13.GPIOParameters=GPIO_Label
PB13.GPIO_Label=USB2_VBUS_CTL_2
PB13.Locked=true
PB13.Signal=GPIO_Output
PB14.GPIOParameters=GPIO_Label
PB14.GPIO_Label=USB2_VBUS_CTL_3
PB14.Locked=true
PB14.Signal=GPIO_Output
PB15.GPIOParameters=GPIO_Label
PB15.GPIO_Label=USB2_VBUS_CTL_4
PB15.Locked=true
PB15.Signal=GPIO_Output
PB3.GPIOParameters=GPIO_Label PB3.GPIOParameters=GPIO_Label
PB3.GPIO_Label=SYS_SWO PB3.GPIO_Label=SYS_SWO
PB3.Mode=Trace_Asynchronous_SW PB3.Mode=Trace_Asynchronous_SW
PB3.Signal=SYS_TRACESWO PB3.Signal=SYS_TRACESWO
PB6.GPIOParameters=GPIO_Label PB4.GPIOParameters=GPIO_Label
PB6.GPIO_Label=BUZZ_CTL PB4.GPIO_Label=SOM_SYS_RESET
PB4.Locked=true
PB4.Signal=GPIO_Output
PB5.GPIOParameters=GPIO_Label
PB5.GPIO_Label=SOM_MOD_SLEEP
PB5.Locked=true
PB5.Signal=GPIO_Input
PB6.Locked=true PB6.Locked=true
PB6.Signal=GPIO_Output PB6.Mode=Asynchronous
PB7.GPIOParameters=GPIO_Label PB6.Signal=USART1_TX
PB7.GPIO_Label=CHRG_STATUS
PB7.Locked=true PB7.Locked=true
PB7.Signal=GPIO_Input PB7.Mode=Asynchronous
PB7.Signal=USART1_RX
PB8.GPIOParameters=GPIO_Label PB8.GPIOParameters=GPIO_Label
PB8.GPIO_Label=COULOMB_SCL PB8.GPIO_Label=IIC1_SCL
PB8.Locked=true PB8.Locked=true
PB8.Mode=I2C PB8.Mode=I2C
PB8.Signal=I2C1_SCL PB8.Signal=I2C1_SCL
PB9.GPIOParameters=GPIO_Label PB9.GPIOParameters=GPIO_Label
PB9.GPIO_Label=COULOMB_SDA PB9.GPIO_Label=IIC1_SDA
PB9.Locked=true PB9.Locked=true
PB9.Mode=I2C PB9.Mode=I2C
PB9.Signal=I2C1_SDA PB9.Signal=I2C1_SDA
PC0.GPIOParameters=GPIO_Label
PC0.GPIO_Label=PMB_CHRG_SHDN
PC0.Locked=true
PC0.Signal=GPIO_Output
PC1.GPIOParameters=GPIO_Label
PC1.GPIO_Label=PMB_TEMP_SEN_EN
PC1.Locked=true
PC1.Signal=GPIO_Output
PC10.Locked=true PC10.Locked=true
PC10.Mode=Asynchronous PC10.Mode=Asynchronous
PC10.Signal=UART4_TX PC10.Signal=UART4_TX
PC11.Locked=true PC11.Locked=true
PC11.Mode=Asynchronous PC11.Mode=Asynchronous
PC11.Signal=UART4_RX PC11.Signal=UART4_RX
PC12.GPIOParameters=GPIO_Label
PC12.GPIO_Label=SOC_U2_HUB_PWR_CTL
PC12.Locked=true
PC12.Signal=GPIO_Output
PC2.GPIOParameters=GPIO_Label
PC2.GPIO_Label=PMB_TEMP_SEN_ALT
PC2.Locked=true
PC2.Signal=GPIO_Input
PC3.GPIOParameters=GPIO_Label
PC3.GPIO_Label=PMB_CLOULOMB_ALCC
PC3.Locked=true
PC3.Signal=GPIO_Input
PC4.GPIOParameters=GPIO_Label
PC4.GPIO_Label=SYS_RUN_LED_CTL
PC4.Locked=true
PC4.Signal=GPIO_Output
PC5.GPIOParameters=GPIO_Label
PC5.GPIO_Label=SYS_BUZZ_CTL
PC5.Locked=true
PC5.Signal=GPIO_Output
PD0.GPIOParameters=GPIO_Label
PD0.GPIO_Label=SOC_U3_HUB_PWR_CTL
PD0.Locked=true
PD0.Signal=GPIO_Output
PD1.GPIOParameters=GPIO_Label
PD1.GPIO_Label=SOC_U3_HOST_PWR_CTL
PD1.Locked=true
PD1.Signal=GPIO_Output
PD10.GPIOParameters=GPIO_Label
PD10.GPIO_Label=USB3_VBUS_CTL_5
PD10.Locked=true
PD10.Signal=GPIO_Output
PD11.GPIOParameters=GPIO_Label
PD11.GPIO_Label=USB3_VBUS_CTL_6
PD11.Locked=true
PD11.Signal=GPIO_Output
PD12.GPIOParameters=GPIO_Label
PD12.GPIO_Label=USB3_VBUS_CTL_1
PD12.Locked=true
PD12.Signal=GPIO_Output
PD13.GPIOParameters=GPIO_Label
PD13.GPIO_Label=USB3_VBUS_CTL_2
PD13.Locked=true
PD13.Signal=GPIO_Output
PD14.GPIOParameters=GPIO_Label
PD14.GPIO_Label=USB3_VBUS_CTL_3
PD14.Locked=true
PD14.Signal=GPIO_Output
PD15.GPIOParameters=GPIO_Label
PD15.GPIO_Label=USB3_VBUS_CTL_4
PD15.Locked=true
PD15.Signal=GPIO_Output
PD2.GPIOParameters=GPIO_Label PD2.GPIOParameters=GPIO_Label
PD2.GPIO_Label=USB2_VBUS_CTL_1 PD2.GPIO_Label=SOC_U3_GEC_PWR_CTL
PD2.Locked=true PD2.Locked=true
PD2.Signal=GPIO_Output PD2.Signal=GPIO_Output
PD3.GPIOParameters=GPIO_Label PD3.GPIOParameters=GPIO_Label
PD3.GPIO_Label=USB2_VBUS_CTL_2 PD3.GPIO_Label=SOC_GE_SW_PWR_CTL
PD3.Locked=true PD3.Locked=true
PD3.Signal=GPIO_Output PD3.Signal=GPIO_Output
PD4.GPIOParameters=GPIO_Label PD4.GPIOParameters=GPIO_Label
PD4.GPIO_Label=USB2_VBUS_CTL_3 PD4.GPIO_Label=SOM_POWER_EN
PD4.Locked=true PD4.Locked=true
PD4.Signal=GPIO_Output PD4.Signal=GPIO_Output
PD5.GPIOParameters=GPIO_Label PD5.GPIOParameters=GPIO_Label
PD5.GPIO_Label=USB2_VBUS_CTL_4 PD5.GPIO_Label=SOM_SHUTDOWN_REQ
PD5.Locked=true PD5.Locked=true
PD5.Signal=GPIO_Output PD5.Signal=GPIO_Input
PD6.GPIOParameters=GPIO_Label PD6.GPIOParameters=GPIO_Label
PD6.GPIO_Label=USB2_VBUS_CTL_5 PD6.GPIO_Label=SOM_SLEEP_WAKE
PD6.Locked=true PD6.Locked=true
PD6.Signal=GPIO_Output PD6.Signal=GPIO_Output
PD7.GPIOParameters=GPIO_Label PD7.GPIOParameters=GPIO_Label
PD7.GPIO_Label=USB2_VBUS_CTL_6 PD7.GPIO_Label=SOM_FORCE_RECOVERY
PD7.Locked=true PD7.Locked=true
PD7.Signal=GPIO_Output PD7.Signal=GPIO_Output
PE0.GPIOParameters=GPIO_Label PD8.GPIOParameters=GPIO_Label
PE0.GPIO_Label=COULOMB_ALCC PD8.GPIO_Label=USB2_VBUS_CTL_5
PE0.Locked=true PD8.Locked=true
PE0.Signal=GPIO_Input PD8.Signal=GPIO_Output
PE1.GPIOParameters=GPIO_Label PD9.GPIOParameters=GPIO_Label
PE1.GPIO_Label=BAT_RELAY_CTL PD9.GPIO_Label=USB2_VBUS_CTL_6
PE1.Locked=true PD9.Locked=true
PE1.Signal=GPIO_Output PD9.Signal=GPIO_Output
PE10.GPIOParameters=GPIO_Label
PE10.GPIO_Label=SYS_FAN_CTL_2
PE10.Locked=true
PE10.Signal=GPIO_Output
PE11.GPIOParameters=GPIO_Label
PE11.GPIO_Label=SYS_FAN_SNS_2
PE11.Locked=true
PE11.Signal=GPIO_Input
PE12.GPIOParameters=GPIO_Label PE12.GPIOParameters=GPIO_Label
PE12.GPIO_Label=USB3_VBUS_CTL_3 PE12.GPIO_Label=SYS_FAN_CTL_3
PE12.Locked=true PE12.Locked=true
PE12.Signal=GPIO_Output PE12.Signal=GPIO_Output
PE13.GPIOParameters=GPIO_Label PE13.GPIOParameters=GPIO_Label
PE13.GPIO_Label=USB3_VBUS_CTL_2 PE13.GPIO_Label=SYS_FAN_SNS_3
PE13.Locked=true PE13.Locked=true
PE13.Signal=GPIO_Output PE13.Signal=GPIO_Input
PE14.GPIOParameters=GPIO_Label PE2.GPIOParameters=PinState,GPIO_Label
PE14.GPIO_Label=USB3_VBUS_CTL_1 PE2.GPIO_Label=SYS_POWER_LED_CTL
PE14.Locked=true
PE14.Signal=GPIO_Output
PE15.GPIOParameters=GPIO_Label
PE15.GPIO_Label=USB3_VBUS_CTL_4
PE15.Locked=true
PE15.Signal=GPIO_Output
PE2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI
PE2.GPIO_Label=PWR_BUTTON
PE2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING
PE2.GPIO_PuPd=GPIO_PULLUP
PE2.Locked=true PE2.Locked=true
PE2.Signal=GPXTI2 PE2.PinState=GPIO_PIN_SET
PE3.GPIOParameters=GPIO_Label PE2.Signal=GPIO_Output
PE3.GPIO_Label=LED_RUN PE3.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI
PE3.GPIO_Label=SYS_CUSTOM_BTN
PE3.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING
PE3.GPIO_PuPd=GPIO_PULLUP
PE3.Locked=true PE3.Locked=true
PE3.Signal=GPIO_Output PE3.Signal=GPXTI3
PE4.GPIOParameters=GPIO_Label
PE4.GPIO_Label=PMB_PS_ON
PE4.Locked=true
PE4.Signal=GPIO_Output
PE5.GPIOParameters=GPIO_PuPd,GPIO_Label
PE5.GPIO_Label=PMB_CHRG_STAT2
PE5.GPIO_PuPd=GPIO_PULLUP
PE5.Locked=true
PE5.Signal=GPIO_Input
PE6.GPIOParameters=GPIO_PuPd,GPIO_Label
PE6.GPIO_Label=PMG_CHRG_STAT1
PE6.GPIO_PuPd=GPIO_PULLUP
PE6.Locked=true
PE6.Signal=GPIO_Input
PE8.GPIOParameters=GPIO_Label
PE8.GPIO_Label=SYS_FAN_CTL_1
PE8.Locked=true
PE8.Signal=GPIO_Output
PE9.GPIOParameters=GPIO_Label
PE9.GPIO_Label=SYS_FAN_SNS_1
PE9.Locked=true
PE9.Signal=GPIO_Input
PinOutPanel.RotationAngle=0 PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=true ProjectManager.AskForMigrate=true
ProjectManager.BackupPrevious=false ProjectManager.BackupPrevious=false
@ -264,39 +458,56 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=STM32CubeIDE ProjectManager.TargetToolchain=STM32CubeIDE
ProjectManager.ToolChainLocation= ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=true ProjectManager.UnderRoot=true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-true,3-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,4-MX_I2C1_Init-I2C1-false-HAL-true,5-MX_IWDG_Init-IWDG-false-HAL-true,6-MX_UART4_Init-UART4-false-HAL-true ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-true,4-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,5-MX_I2C1_Init-I2C1-false-HAL-true,6-MX_IWDG_Init-IWDG-false-HAL-true,7-MX_UART4_Init-UART4-false-HAL-true,8-MX_ADC1_Init-ADC1-false-HAL-true,9-MX_USART1_UART_Init-USART1-false-HAL-true
RCC.ADCFreqValue=36000000 RCC.ADCFreqValue=3000000
RCC.AHBFreq_Value=72000000 RCC.ADCPresc=RCC_ADCPCLK2_DIV8
RCC.AHBCLKDivider=RCC_SYSCLK_DIV2
RCC.AHBFreq_Value=24000000
RCC.APB1CLKDivider=RCC_HCLK_DIV2 RCC.APB1CLKDivider=RCC_HCLK_DIV2
RCC.APB1Freq_Value=36000000 RCC.APB1Freq_Value=12000000
RCC.APB1TimFreq_Value=72000000 RCC.APB1TimFreq_Value=24000000
RCC.APB2Freq_Value=72000000 RCC.APB2Freq_Value=24000000
RCC.APB2TimFreq_Value=72000000 RCC.APB2TimFreq_Value=24000000
RCC.EnbaleCSS=true RCC.EnbaleCSS=true
RCC.FCLKCortexFreq_Value=72000000 RCC.FCLKCortexFreq_Value=24000000
RCC.FamilyName=M RCC.FamilyName=M
RCC.HCLKFreq_Value=72000000 RCC.HCLKFreq_Value=24000000
RCC.I2S2Freq_Value=72000000 RCC.HSE_VALUE=12000000
RCC.I2S3Freq_Value=72000000 RCC.I2S2Freq_Value=48000000
RCC.IPParameters=ADCFreqValue,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,EnbaleCSS,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,I2S2Freq_Value,I2S3Freq_Value,MCOFreq_Value,PLL2CLKoutputFreqValue,PLL2VCOoutputFreqValue,PLL3CLKoutputFreqValue,PLL3VCOoutputFreqValue,PLLCLKFreq_Value,PLLMUL,Prediv2,Prediv2FreqValue,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value,VCOOutput2Freq_Value RCC.I2S3Freq_Value=48000000
RCC.MCOFreq_Value=72000000 RCC.IPParameters=ADCFreqValue,ADCPresc,AHBCLKDivider,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,EnbaleCSS,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,I2S2Freq_Value,I2S3Freq_Value,MCOFreq_Value,PLL2CLKoutputFreqValue,PLL2VCOoutputFreqValue,PLL3CLKoutputFreqValue,PLL3VCOoutputFreqValue,PLLCLKFreq_Value,Prediv2,Prediv2FreqValue,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value,USBPrescaler,VCOOutput2Freq_Value
RCC.PLL2CLKoutputFreqValue=32000000 RCC.MCOFreq_Value=48000000
RCC.PLL2VCOoutputFreqValue=64000000 RCC.PLL2CLKoutputFreqValue=48000000
RCC.PLL3CLKoutputFreqValue=32000000 RCC.PLL2VCOoutputFreqValue=96000000
RCC.PLL3VCOoutputFreqValue=64000000 RCC.PLL3CLKoutputFreqValue=48000000
RCC.PLLCLKFreq_Value=72000000 RCC.PLL3VCOoutputFreqValue=96000000
RCC.PLLMUL=RCC_PLL_MUL9 RCC.PLLCLKFreq_Value=48000000
RCC.Prediv2=RCC_HSE_PREDIV2_DIV2 RCC.Prediv2=RCC_HSE_PREDIV2_DIV2
RCC.Prediv2FreqValue=4000000 RCC.Prediv2FreqValue=6000000
RCC.SYSCLKFreq_VALUE=72000000 RCC.SYSCLKFreq_VALUE=48000000
RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
RCC.TimSysFreq_Value=72000000 RCC.TimSysFreq_Value=24000000
RCC.USBFreq_Value=48000000 RCC.USBFreq_Value=48000000
RCC.VCOOutput2Freq_Value=8000000 RCC.USBPrescaler=RCC_USBCLKSOURCE_PLL_DIV2
SH.GPXTI2.0=GPIO_EXTI2 RCC.VCOOutput2Freq_Value=12000000
SH.GPXTI2.ConfNb=1 SH.ADCx_IN3.0=ADC1_IN3,IN3
SH.ADCx_IN3.ConfNb=1
SH.ADCx_IN4.0=ADC1_IN4,IN4
SH.ADCx_IN4.ConfNb=1
SH.ADCx_IN5.0=ADC1_IN5,IN5
SH.ADCx_IN5.ConfNb=1
SH.ADCx_IN6.0=ADC1_IN6,IN6
SH.ADCx_IN6.ConfNb=1
SH.ADCx_IN7.0=ADC1_IN7,IN7
SH.ADCx_IN7.ConfNb=1
SH.GPXTI0.0=GPIO_EXTI0
SH.GPXTI0.ConfNb=1
SH.GPXTI3.0=GPIO_EXTI3
SH.GPXTI3.ConfNb=1
UART4.IPParameters=VirtualMode UART4.IPParameters=VirtualMode
UART4.VirtualMode=Asynchronous UART4.VirtualMode=Asynchronous
USART1.IPParameters=VirtualMode
USART1.VirtualMode=VM_ASYNC
USB_DEVICE.CLASS_NAME_FS=CDC USB_DEVICE.CLASS_NAME_FS=CDC
USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,CLASS_NAME_FS,USBD_DEBUG_LEVEL USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,CLASS_NAME_FS,USBD_DEBUG_LEVEL
USB_DEVICE.USBD_DEBUG_LEVEL=3 USB_DEVICE.USBD_DEBUG_LEVEL=3

View File

@ -73,8 +73,6 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
__HAL_RCC_USB_OTG_FS_CLK_ENABLE(); __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
/* Peripheral interrupt init */ /* Peripheral interrupt init */
HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
/* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */
/* USER CODE END USB_OTG_FS_MspInit 1 */ /* USER CODE END USB_OTG_FS_MspInit 1 */