FT23 Firmware beginnings
This commit is contained in:
@ -26,26 +26,60 @@
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PTD */
|
||||
|
||||
/*
|
||||
* VAL_ 1040 Mission_selection
|
||||
* 1 "MissionSelection_acceleration"
|
||||
* 2 "MissionSelection_skidpad"
|
||||
* 3 "MissionSelection_trackdrive"
|
||||
* 4 "MissionSelection_braketest"
|
||||
* 5 "MissionSelection_inspection"
|
||||
* 6 "MissionSelection_autocross"
|
||||
* 7 "MissionSelection_manual";
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
M_NONE = 0,
|
||||
M_ACCEL = 1,
|
||||
M_SKIDPAD = 2,
|
||||
M_TRACKDRIVE = 3,
|
||||
M_EBSTEST = 4,
|
||||
M_INSPECTION = 5,
|
||||
M_AUTOX = 6,
|
||||
M_MANUAL = 7
|
||||
} mission_t;
|
||||
|
||||
// BITFIELDS ARE LSB FIRST!
|
||||
|
||||
typedef union {
|
||||
uint8_t raw[1];
|
||||
struct {
|
||||
bool as_driving_mode : 1;
|
||||
bool as_close_sdc : 1;
|
||||
bool watchdog : 1;
|
||||
uint8_t _padding : 5;
|
||||
} signals;
|
||||
bool heartbeat : 1;
|
||||
bool asb_error : 1;
|
||||
bool as_driving_mode : 1;
|
||||
mission_t as_mission : 3;
|
||||
unsigned int _padding : 1;
|
||||
} __attribute__((packed)) signals;
|
||||
} rx_data_t;
|
||||
|
||||
typedef union {
|
||||
uint8_t raw[1];
|
||||
uint8_t raw[2];
|
||||
struct {
|
||||
bool sdc_in : 1;
|
||||
bool asms_state : 1;
|
||||
bool sdc_state_1 : 1;
|
||||
bool sdc_state_2 : 1;
|
||||
bool sdc_state_3 : 1;
|
||||
bool heartbeat_ok : 1;
|
||||
bool sdc_ready : 1;
|
||||
bool ts_start : 1;
|
||||
uint8_t _padding : 5;
|
||||
} signals;
|
||||
bool ts_start_muxed : 1;
|
||||
bool sdc_in : 1;
|
||||
// -- byte border
|
||||
bool latch_init_open : 1;
|
||||
bool latch_closed : 1;
|
||||
bool latch_reopened : 1;
|
||||
mission_t as_mission : 3;
|
||||
unsigned int _padding : 2;
|
||||
} __attribute__((packed)) signals;
|
||||
} tx_data_t;
|
||||
|
||||
/* USER CODE END PTD */
|
||||
@ -53,12 +87,10 @@ typedef union {
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
#define CAN_ID_RX 0x10
|
||||
#define CAN_ID_TX 0x11
|
||||
#define CAN_ID_RX 0x00F
|
||||
#define CAN_ID_TX 0x010
|
||||
|
||||
// Wait 20ms. Needs to be less than watchdog period!
|
||||
#define RX_UPDATE_PERIOD 20
|
||||
// Defined in DBC. Should be multiple of RX_UPDATE_PERIOD
|
||||
// Defined in DBC?
|
||||
#define TX_UPDATE_PERIOD 100
|
||||
|
||||
/* USER CODE END PD */
|
||||
@ -69,11 +101,13 @@ typedef union {
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
ADC_HandleTypeDef hadc1;
|
||||
|
||||
CAN_HandleTypeDef hcan;
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
rx_data_t RxData;
|
||||
rx_data_t rxData;
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
@ -81,6 +115,7 @@ rx_data_t RxData;
|
||||
void SystemClock_Config(void);
|
||||
static void MX_GPIO_Init(void);
|
||||
static void MX_CAN_Init(void);
|
||||
static void MX_ADC1_Init(void);
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
@ -119,14 +154,16 @@ int main(void)
|
||||
/* Initialize all configured peripherals */
|
||||
MX_GPIO_Init();
|
||||
MX_CAN_Init();
|
||||
MX_ADC1_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
// Init data as LOW
|
||||
memset(&RxData, 0, sizeof(rx_data_t));
|
||||
memset(&rxData, 0, sizeof(rx_data_t));
|
||||
|
||||
if (HAL_CAN_Start(&hcan) != HAL_OK)
|
||||
Error_Handler();
|
||||
|
||||
/*
|
||||
CAN_FilterTypeDef canfilterconfig;
|
||||
|
||||
canfilterconfig.FilterActivation = CAN_FILTER_ENABLE;
|
||||
@ -143,32 +180,40 @@ int main(void)
|
||||
if (HAL_CAN_ConfigFilter(&hcan, &canfilterconfig) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
*/
|
||||
|
||||
if (HAL_CAN_ActivateNotification(&hcan, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK)
|
||||
Error_Handler();
|
||||
|
||||
CAN_TxHeaderTypeDef TxHeader;
|
||||
uint32_t TxMailbox;
|
||||
tx_data_t TxData;
|
||||
CAN_TxHeaderTypeDef txHeader;
|
||||
uint32_t txMailbox;
|
||||
tx_data_t txData;
|
||||
|
||||
memset(&TxData, 0, sizeof(tx_data_t));
|
||||
memset(&txData, 0, sizeof(tx_data_t));
|
||||
|
||||
// Prep the tx frame
|
||||
TxHeader.IDE = CAN_ID_STD;
|
||||
TxHeader.StdId = CAN_ID_TX;
|
||||
TxHeader.RTR = CAN_RTR_DATA;
|
||||
TxHeader.DLC = 1;
|
||||
txHeader.IDE = CAN_ID_STD;
|
||||
txHeader.StdId = CAN_ID_TX;
|
||||
txHeader.RTR = CAN_RTR_DATA;
|
||||
txHeader.DLC = 2;
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
|
||||
uint32_t counter = 0;
|
||||
//HAL_GPIO_TogglePin(AS_close_SDC_GPIO_Port, AS_close_SDC_Pin);
|
||||
|
||||
uint16_t mission2led[] = {ASB_Error_Pin, AMI_ACCEL_Pin, AMI_SKIDPAD_Pin, AMI_TRACKDRIVE_Pin, AMI_EBSTEST_Pin, AMI_INSPECTION_Pin, AMI_AUTOX_Pin, AMI_MANUAL_Pin};
|
||||
unsigned int mission_order[] = {M_MANUAL, M_ACCEL, M_SKIDPAD, M_AUTOX, M_TRACKDRIVE, M_EBSTEST, M_INSPECTION};
|
||||
|
||||
unsigned int mission_idx = 0;
|
||||
bool pAMC = false;
|
||||
|
||||
while (true) {
|
||||
|
||||
// Write out all values received via interrupt to the pins
|
||||
/*
|
||||
HAL_GPIO_WritePin(GPIOA, AS_driving_mode_Pin, RxData.signals.as_driving_mode);
|
||||
HAL_GPIO_WritePin(GPIOA, AS_close_SDC_Pin, RxData.signals.as_close_sdc);
|
||||
HAL_GPIO_WritePin(GPIOA, Watchdog_Pin, RxData.signals.watchdog);
|
||||
@ -191,9 +236,75 @@ int main(void)
|
||||
counter = 0;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
// Slow the loop
|
||||
HAL_Delay(RX_UPDATE_PERIOD);
|
||||
/*
|
||||
* Values to read:
|
||||
* [ ] TSActivateMUXed
|
||||
* [ ] ASMS
|
||||
* [ ] INITIAL_OPEN
|
||||
* [ ] CLOSED
|
||||
* [ ] REOPENED
|
||||
* [ ] WD_OK
|
||||
* [ ] SDC_is_ready
|
||||
* [ ] SDC_in_3V3
|
||||
* [ ] LV_SENSE_1
|
||||
* [ ] LV_SENSE_2
|
||||
* [x] AMC
|
||||
*
|
||||
* Values to write:
|
||||
* [ ] AS_close_SDC
|
||||
* [ ] (Watchdog)
|
||||
* [ ] ASB_Error
|
||||
* [x] AMI_<Mission>
|
||||
*/
|
||||
|
||||
bool TS_activate_MUXed = HAL_GPIO_ReadPin(TS_activate_MUXed_GPIO_Port, TS_activate_MUXed_Pin) == GPIO_PIN_SET;
|
||||
bool ASMS = HAL_GPIO_ReadPin(ASMS_GPIO_Port, ASMS_Pin) == GPIO_PIN_SET;
|
||||
bool WD_OK = HAL_GPIO_ReadPin(WD_OK_GPIO_Port, WD_OK_Pin) == GPIO_PIN_SET;
|
||||
bool SDC_is_ready = HAL_GPIO_ReadPin(SDC_is_ready_GPIO_Port, SDC_is_ready_Pin) == GPIO_PIN_SET;
|
||||
bool SDC_in_3V3 = HAL_GPIO_ReadPin(SDC_in_3V3_GPIO_Port, SDC_in_3V3_Pin) == GPIO_PIN_SET;
|
||||
bool LV_SENSE_1 = HAL_GPIO_ReadPin(LV_SENSE_1_GPIO_Port, LV_SENSE_1_Pin) == GPIO_PIN_SET;
|
||||
bool LV_SENSE_2 = HAL_GPIO_ReadPin(LV_SENSE_2_GPIO_Port, LV_SENSE_2_Pin) == GPIO_PIN_SET;
|
||||
|
||||
bool INITIAL_OPEN = HAL_GPIO_ReadPin(INITIAL_OPEN_GPIO_Port, INITIAL_OPEN_Pin) == GPIO_PIN_SET;
|
||||
bool CLOSED = HAL_GPIO_ReadPin(CLOSED_GPIO_Port, CLOSED_Pin) == GPIO_PIN_SET;
|
||||
bool REOPENED = HAL_GPIO_ReadPin(REOPENED_GPIO_Port, REOPENED_Pin) == GPIO_PIN_SET;
|
||||
|
||||
bool AMC = HAL_GPIO_ReadPin(AMC_GPIO_Port, AMC_Pin) == GPIO_PIN_SET;
|
||||
if (AMC < pAMC) {
|
||||
|
||||
HAL_GPIO_WritePin(GPIOB, mission2led[mission_order[mission_idx]], GPIO_PIN_RESET);
|
||||
|
||||
mission_idx++;
|
||||
mission_idx %= 7;
|
||||
|
||||
}
|
||||
|
||||
HAL_GPIO_WritePin(GPIOB, mission2led[mission_order[mission_idx]], GPIO_PIN_SET);
|
||||
|
||||
tx_data_t txData = {
|
||||
.signals = {
|
||||
.asms_state = ASMS,
|
||||
.sdc_state_1 = LV_SENSE_1,
|
||||
.sdc_state_2 = LV_SENSE_2,
|
||||
.sdc_state_3 = SDC_in_3V3,
|
||||
.heartbeat_ok = WD_OK,
|
||||
.sdc_ready = SDC_is_ready,
|
||||
.sdc_in = SDC_in_3V3,
|
||||
.latch_init_open = INITIAL_OPEN,
|
||||
.latch_closed = CLOSED,
|
||||
.latch_reopened = REOPENED,
|
||||
.as_mission = mission_order[mission_idx]
|
||||
}
|
||||
};
|
||||
|
||||
if (HAL_CAN_AddTxMessage(&hcan, &txHeader, txData.raw, &txMailbox) != HAL_OK)
|
||||
Error_Handler();
|
||||
|
||||
pAMC = AMC;
|
||||
|
||||
HAL_Delay(TX_UPDATE_PERIOD);
|
||||
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
@ -210,6 +321,7 @@ void SystemClock_Config(void)
|
||||
{
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
|
||||
|
||||
/** Initializes the RCC Oscillators according to the specified parameters
|
||||
* in the RCC_OscInitTypeDef structure.
|
||||
@ -217,11 +329,14 @@ void SystemClock_Config(void)
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
||||
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL4;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** Initializes the CPU, AHB and APB buses clocks
|
||||
*/
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||
@ -235,6 +350,70 @@ void SystemClock_Config(void)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC1;
|
||||
PeriphClkInit.Adc1ClockSelection = RCC_ADC1PLLCLK_DIV1;
|
||||
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ADC1 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_ADC1_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN ADC1_Init 0 */
|
||||
|
||||
/* USER CODE END ADC1_Init 0 */
|
||||
|
||||
ADC_ChannelConfTypeDef sConfig = {0};
|
||||
|
||||
/* USER CODE BEGIN ADC1_Init 1 */
|
||||
|
||||
/* USER CODE END ADC1_Init 1 */
|
||||
|
||||
/** Common config
|
||||
*/
|
||||
hadc1.Instance = ADC1;
|
||||
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
|
||||
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
|
||||
hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
|
||||
hadc1.Init.ContinuousConvMode = DISABLE;
|
||||
hadc1.Init.DiscontinuousConvMode = DISABLE;
|
||||
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
|
||||
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
|
||||
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
|
||||
hadc1.Init.NbrOfConversion = 1;
|
||||
hadc1.Init.DMAContinuousRequests = DISABLE;
|
||||
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
|
||||
hadc1.Init.LowPowerAutoWait = DISABLE;
|
||||
hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
|
||||
if (HAL_ADC_Init(&hadc1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_11;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_1;
|
||||
sConfig.SingleDiff = ADC_DIFFERENTIAL_ENDED;
|
||||
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
|
||||
sConfig.OffsetNumber = ADC_OFFSET_NONE;
|
||||
sConfig.Offset = 0;
|
||||
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN ADC1_Init 2 */
|
||||
|
||||
/* USER CODE END ADC1_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -288,27 +467,38 @@ static void MX_GPIO_Init(void)
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOA, AS_close_SDC_Pin|AS_driving_mode_Pin|Watchdog_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOB, AMI_EBSTEST_Pin|AMI_INSPECTION_Pin|ASB_Error_Pin|AMI_TRACKDRIVE_Pin
|
||||
|AMI_AUTOX_Pin|AMI_SKIDPAD_Pin|AMI_ACCEL_Pin|AMI_MANUAL_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pins : SDC_is_ready_Pin SDC_in_3V3_Pin */
|
||||
GPIO_InitStruct.Pin = SDC_is_ready_Pin|SDC_in_3V3_Pin;
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOA, AS_close_SDC_Pin|Watchdog_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pins : TS_activate_MUXed_Pin ASMS_Pin INITIAL_OPEN_Pin CLOSED_Pin
|
||||
REOPENED_Pin WD_OK_Pin SDC_is_ready_Pin SDC_in_3V3_Pin
|
||||
AMC_Pin */
|
||||
GPIO_InitStruct.Pin = TS_activate_MUXed_Pin|ASMS_Pin|INITIAL_OPEN_Pin|CLOSED_Pin
|
||||
|REOPENED_Pin|WD_OK_Pin|SDC_is_ready_Pin|SDC_in_3V3_Pin
|
||||
|AMC_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : AS_close_SDC_Pin AS_driving_mode_Pin Watchdog_Pin */
|
||||
GPIO_InitStruct.Pin = AS_close_SDC_Pin|AS_driving_mode_Pin|Watchdog_Pin;
|
||||
/*Configure GPIO pins : AMI_EBSTEST_Pin AMI_INSPECTION_Pin ASB_Error_Pin AMI_TRACKDRIVE_Pin
|
||||
AMI_AUTOX_Pin AMI_SKIDPAD_Pin AMI_ACCEL_Pin AMI_MANUAL_Pin */
|
||||
GPIO_InitStruct.Pin = AMI_EBSTEST_Pin|AMI_INSPECTION_Pin|ASB_Error_Pin|AMI_TRACKDRIVE_Pin
|
||||
|AMI_AUTOX_Pin|AMI_SKIDPAD_Pin|AMI_ACCEL_Pin|AMI_MANUAL_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 : AS_close_SDC_Pin Watchdog_Pin */
|
||||
GPIO_InitStruct.Pin = AS_close_SDC_Pin|Watchdog_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : TS_activate_MUXed_Pin */
|
||||
GPIO_InitStruct.Pin = TS_activate_MUXed_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||
HAL_GPIO_Init(TS_activate_MUXed_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 4 */
|
||||
@ -316,16 +506,16 @@ static void MX_GPIO_Init(void)
|
||||
// CAN RX interrupt handler
|
||||
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) {
|
||||
|
||||
CAN_RxHeaderTypeDef RxHeader;
|
||||
uint8_t RxBuffer[8];
|
||||
CAN_RxHeaderTypeDef rxHeader;
|
||||
uint8_t rxBuffer[8];
|
||||
|
||||
// Read frame from HW into buffer
|
||||
if (HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO0, &RxHeader, RxBuffer) != HAL_OK)
|
||||
if (HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO0, &rxHeader, rxBuffer) != HAL_OK)
|
||||
Error_Handler();
|
||||
|
||||
// Copy into the bitfield if it's for us
|
||||
if (RxHeader.StdId == CAN_ID_RX)
|
||||
RxData.raw[0] = RxBuffer[0];
|
||||
if (rxHeader.StdId == CAN_ID_RX)
|
||||
rxData.raw[0] = rxBuffer[0];
|
||||
|
||||
}
|
||||
|
||||
@ -362,4 +552,3 @@ void assert_failed(uint8_t *file, uint32_t line)
|
||||
/* USER CODE END 6 */
|
||||
}
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
|
||||
@ -76,6 +76,69 @@ void HAL_MspInit(void)
|
||||
/* USER CODE END MspInit 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ADC MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param hadc: ADC handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(hadc->Instance==ADC1)
|
||||
{
|
||||
/* USER CODE BEGIN ADC1_MspInit 0 */
|
||||
|
||||
/* USER CODE END ADC1_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_ADC1_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
/**ADC1 GPIO Configuration
|
||||
PB0 ------> ADC1_IN11
|
||||
PB1 ------> ADC1_IN12
|
||||
*/
|
||||
GPIO_InitStruct.Pin = LV_SENSE_1_Pin|LV_SENSE_2_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN ADC1_MspInit 1 */
|
||||
|
||||
/* USER CODE END ADC1_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ADC MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param hadc: ADC handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
|
||||
{
|
||||
if(hadc->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
|
||||
PB0 ------> ADC1_IN11
|
||||
PB1 ------> ADC1_IN12
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOB, LV_SENSE_1_Pin|LV_SENSE_2_Pin);
|
||||
|
||||
/* USER CODE BEGIN ADC1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END ADC1_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CAN MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
@ -149,4 +212,3 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan)
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
|
||||
@ -215,4 +215,3 @@ void USB_LP_CAN_RX0_IRQHandler(void)
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user