Kind of working current monitoring. Value scale looks right but unsure about channel assignment
This commit is contained in:
@ -36,9 +36,8 @@ void can_sendloop() {
|
||||
ftcan_transmit(TX_STATUS_MSG_ID, status_data, 7);
|
||||
|
||||
uint8_t data[8];
|
||||
return;
|
||||
if (additionaltxcouter < 4) {
|
||||
switch (additionaltxcouter) {
|
||||
|
||||
switch (additionaltxcouter) {
|
||||
case 0:
|
||||
|
||||
data[0] = current_measurements_adc_val.always_on >> 8;
|
||||
@ -91,13 +90,19 @@ return;
|
||||
ftcan_transmit(CUR_CHANNELS_4_ID, data, 8);
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
|
||||
data[0] = current_measurements_adc_val.lv_v >> 8;
|
||||
data[1] = current_measurements_adc_val.lv_v && 0xFF;
|
||||
ftcan_transmit(LV_SENS_ID, data, 2);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
additionaltxcouter++;
|
||||
} else {
|
||||
additionaltxcouter = 0;
|
||||
}
|
||||
|
||||
additionaltxcouter = (additionaltxcouter+1) % 5;
|
||||
|
||||
}
|
||||
|
||||
void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t* data) {
|
||||
|
||||
@ -10,29 +10,30 @@
|
||||
|
||||
volatile union adc1_channels {
|
||||
struct {
|
||||
uint16_t isense12; // acu
|
||||
uint16_t isense11; // epsc
|
||||
uint16_t isense6; // radiator fans
|
||||
uint16_t isense13; // tsac fans
|
||||
uint16_t isense5; // gss and lidar
|
||||
uint16_t isense3; // sdc and always on
|
||||
uint16_t isense7; // misc and inverters
|
||||
uint16_t isense5; // LiDAR | GSS (DSEL7)
|
||||
uint16_t isense3; // AlwaysOn | SDC (DSEL4)
|
||||
uint16_t isense7; // Misc | Inverters (DSEL5)
|
||||
uint16_t isense9; // DRS
|
||||
uint16_t isense12; // ACU
|
||||
uint16_t isense11; // EPSC = ELIAS
|
||||
uint16_t isense6; // Radiator Fans
|
||||
uint16_t isense13; // TSAC Fans
|
||||
} adcbank1;
|
||||
|
||||
uint16_t adcbuffer[7]; // array 7*16 bit
|
||||
uint16_t adcbuffer[8]; // array 8*16 bit
|
||||
|
||||
} adc_channels1;
|
||||
// ADC's anpassen adc1 - 9, adc2 ist halt 5 , buffer anpassen und namen auch ( isense usw)
|
||||
volatile union adc2_channels {
|
||||
struct {
|
||||
uint16_t isense2; // ebs valve a and ebs valve b
|
||||
uint16_t isense1; // ebs cs valve
|
||||
uint16_t isense10; // hyr aggregat
|
||||
uint16_t isense4; // cooling pump and reserved
|
||||
|
||||
uint16_t isense2; // EBS A | EBS B (DSEL3)
|
||||
uint16_t isense1; // EBS CS
|
||||
uint16_t isense10; // Hydraulic Aggregate
|
||||
uint16_t isense4; // Water Pump | Reserved (DSEL8)
|
||||
uint16_t lv_sens; // LV voltage
|
||||
} adcbank1;
|
||||
|
||||
uint16_t adcbuffer[4];
|
||||
uint16_t adcbuffer[5];
|
||||
|
||||
} adc_channels2;
|
||||
|
||||
@ -46,82 +47,97 @@ ADC_HandleTypeDef* adc2;
|
||||
|
||||
void currentMonitor_init(ADC_HandleTypeDef* hadc1, ADC_HandleTypeDef* hadc2, // init ist initilisierung
|
||||
TIM_HandleTypeDef* trigtim) {
|
||||
HAL_GPIO_WritePin(DSEL_3_GPIO_Port, DSEL_3_Pin, adcbank2); //DSELs zu adc's neu zuordnen
|
||||
HAL_GPIO_WritePin(DSEL_4_GPIO_Port, DSEL_4_Pin, adcbank2);
|
||||
HAL_GPIO_WritePin(DSEL_3_GPIO_Port, DSEL_3_Pin, adcbank2);
|
||||
HAL_GPIO_WritePin(DSEL_4_GPIO_Port, DSEL_4_Pin, adcbank1);
|
||||
HAL_GPIO_WritePin(DSEL_5_GPIO_Port, DSEL_5_Pin, adcbank1);
|
||||
HAL_GPIO_WritePin(DSEL_7_GPIO_Port, DSEL_7_Pin, adcbank1);
|
||||
HAL_GPIO_WritePin(DSEL_8_GPIO_Port, DSEL_8_Pin, adcbank2);
|
||||
adc1 = hadc1;
|
||||
adc2 = hadc2;
|
||||
HAL_TIM_Base_Start(trigtim);
|
||||
HAL_ADC_Start_DMA(hadc1, (uint32_t*)adc_channels1.adcbuffer, 7);
|
||||
HAL_ADC_Start_DMA(hadc2, (uint32_t*)adc_channels2.adcbuffer, 7); // wie adc mit dma geht , red mit jasper
|
||||
HAL_ADC_Start_DMA(hadc1, (uint32_t*)adc_channels1.adcbuffer, 8);
|
||||
HAL_ADC_Start_DMA(hadc2, (uint32_t*)adc_channels2.adcbuffer, 5); // wie adc mit dma geht , red mit jasper
|
||||
}
|
||||
|
||||
uint8_t currentMonitor_checklimits() { return 0; }
|
||||
|
||||
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) {
|
||||
|
||||
if (hadc == adc1) {
|
||||
|
||||
if (adcbank1 == GPIO_PIN_RESET) {
|
||||
|
||||
current_measurements_adc_val.lidar =
|
||||
adc_channels1.adcbank1.isense5 * CURR_SENSE_FACTOR_7_5A;
|
||||
current_measurements_adc_val.always_on =
|
||||
adc_channels1.adcbank1.isense3 * CURR_SENSE_FACTOR_5A;
|
||||
current_measurements_adc_val.misc =
|
||||
adc_channels1.adcbank1.isense7 * CURR_SENSE_FACTOR_7_5A;
|
||||
|
||||
adcbank1 = GPIO_PIN_SET;
|
||||
|
||||
} else {
|
||||
|
||||
current_measurements_adc_val.gss =
|
||||
adc_channels1.adcbank1.isense5 * CURR_SENSE_FACTOR_7_5A;
|
||||
current_measurements_adc_val.sdc =
|
||||
adc_channels1.adcbank1.isense3 * CURR_SENSE_FACTOR_5A;
|
||||
current_measurements_adc_val.inverters =
|
||||
adc_channels1.adcbank1.isense7 * CURR_SENSE_FACTOR_7_5A;
|
||||
|
||||
adcbank1 = GPIO_PIN_RESET;
|
||||
|
||||
}
|
||||
|
||||
current_measurements_adc_val.servos =
|
||||
adc_channels1.adcbank1.isense9 * CURR_SENSE_FACTOR_21A;
|
||||
current_measurements_adc_val.acu =
|
||||
adc_channels1.adcbank1.isense12 * CURR_SENSE_FACTOR_31A;
|
||||
current_measurements_adc_val.epsc =
|
||||
adc_channels1.adcbank1.isense11 * CURR_SENSE_FACTOR_21A;
|
||||
current_measurements_adc_val.radiator_fans =
|
||||
adc_channels1.adcbank1.isense6 * CURR_SENSE_FACTOR_21A;
|
||||
current_measurements_adc_val.tsac_fans =
|
||||
adc_channels1.adcbank1.isense13 * CURR_SENSE_FACTOR_31A;
|
||||
|
||||
HAL_GPIO_WritePin(DSEL_4_GPIO_Port, DSEL_4_Pin, adcbank1);
|
||||
HAL_GPIO_WritePin(DSEL_5_GPIO_Port, DSEL_5_Pin, adcbank1);
|
||||
HAL_GPIO_WritePin(DSEL_7_GPIO_Port, DSEL_7_Pin, adcbank1);
|
||||
|
||||
}
|
||||
else
|
||||
if (hadc == adc2) {
|
||||
|
||||
if (adcbank2 == GPIO_PIN_RESET) {
|
||||
current_measurements_adc_val.ebsvalve_a =
|
||||
|
||||
current_measurements_adc_val.ebsvalve_a =
|
||||
adc_channels2.adcbank1.isense2 * CURR_SENSE_FACTOR_5A;
|
||||
current_measurements_adc_val.cooling_pump =
|
||||
adc_channels2.adcbank1.isense4 * CURR_SENSE_FACTOR_7_5A;
|
||||
adcbank2 = GPIO_PIN_SET;
|
||||
} else {
|
||||
current_measurements_adc_val.ebsvalve_b =
|
||||
adc_channels2.adcbank1.isense2 * CURR_SENSE_FACTOR_5A;
|
||||
current_measurements_adc_val.reserved =
|
||||
adc_channels2.adcbank1.isense4 * CURR_SENSE_FACTOR_7_5A;
|
||||
adcbank2 = GPIO_PIN_RESET;
|
||||
}
|
||||
current_measurements_adc_val.ebs_cs_valve =
|
||||
adc_channels2.adcbank1.isense1 * CURR_SENSE_FACTOR_5A;
|
||||
current_measurements_adc_val.aggregat =
|
||||
adc_channels2.adcbank1.isense10 * CURR_SENSE_FACTOR_21A;
|
||||
|
||||
HAL_GPIO_WritePin(DSEL_3_GPIO_Port, DSEL_3_Pin,
|
||||
adcbank2);
|
||||
HAL_GPIO_WritePin(DSEL_8_GPIO_Port, DSEL_8_Pin,
|
||||
adcbank2);
|
||||
adcbank2 = GPIO_PIN_SET;
|
||||
|
||||
} else {
|
||||
|
||||
current_measurements_adc_val.ebsvalve_b =
|
||||
adc_channels2.adcbank1.isense2 * CURR_SENSE_FACTOR_5A;
|
||||
current_measurements_adc_val.reserved =
|
||||
adc_channels2.adcbank1.isense4 * CURR_SENSE_FACTOR_7_5A;
|
||||
|
||||
adcbank2 = GPIO_PIN_RESET;
|
||||
|
||||
}
|
||||
|
||||
current_measurements_adc_val.ebs_cs_valve =
|
||||
adc_channels2.adcbank1.isense1 * CURR_SENSE_FACTOR_5A;
|
||||
current_measurements_adc_val.aggregat =
|
||||
adc_channels2.adcbank1.isense10 * CURR_SENSE_FACTOR_21A;
|
||||
current_measurements_adc_val.lv_v =
|
||||
adc_channels2.adcbank1.lv_sens * LV_SENSE_FACTOR;
|
||||
|
||||
HAL_GPIO_WritePin(DSEL_3_GPIO_Port, DSEL_3_Pin, adcbank2);
|
||||
HAL_GPIO_WritePin(DSEL_8_GPIO_Port, DSEL_8_Pin, adcbank2);
|
||||
|
||||
}
|
||||
|
||||
if (hadc == adc1) {
|
||||
if (adcbank1 == GPIO_PIN_RESET) {
|
||||
current_measurements_adc_val.sdc=
|
||||
adc_channels1.adcbank1.isense3 * CURR_SENSE_FACTOR_5A;
|
||||
current_measurements_adc_val.misc=
|
||||
adc_channels1.adcbank1.isense7 * CURR_SENSE_FACTOR_7_5A;
|
||||
current_measurements_adc_val.gss=
|
||||
adc_channels1.adcbank1.isense5 * CURR_SENSE_FACTOR_7_5A;
|
||||
|
||||
adcbank1 = GPIO_PIN_SET;
|
||||
} else {
|
||||
current_measurements_adc_val.always_on =
|
||||
adc_channels1.adcbank1.isense3 * CURR_SENSE_FACTOR_5A;
|
||||
current_measurements_adc_val.inverters =
|
||||
adc_channels1.adcbank1.isense7 * CURR_SENSE_FACTOR_7_5A;
|
||||
current_measurements_adc_val.lidar=
|
||||
adc_channels1.adcbank1.isense5 * CURR_SENSE_FACTOR_7_5A;
|
||||
adcbank1 = GPIO_PIN_RESET;
|
||||
}
|
||||
current_measurements_adc_val.acu=
|
||||
adc_channels1.adcbank1.isense12 * CURR_SENSE_FACTOR_31A;
|
||||
current_measurements_adc_val.epsc =
|
||||
adc_channels1.adcbank1.isense11 * CURR_SENSE_FACTOR_21A;
|
||||
current_measurements_adc_val.tsac_fans =
|
||||
adc_channels1.adcbank1.isense13 * CURR_SENSE_FACTOR_31A;
|
||||
current_measurements_adc_val.radiator_fans=
|
||||
adc_channels1.adcbank1.isense6 * CURR_SENSE_FACTOR_21A;
|
||||
|
||||
HAL_GPIO_WritePin(DSEL_4_GPIO_Port, DSEL_4_Pin,
|
||||
adcbank1);
|
||||
HAL_GPIO_WritePin(DSEL_5_GPIO_Port, DSEL_5_Pin,
|
||||
adcbank1);
|
||||
HAL_GPIO_WritePin(DSEL_7_GPIO_Port, DSEL_7_Pin,
|
||||
adcbank1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// current monitoring c und h anpassen
|
||||
}
|
||||
@ -279,7 +279,7 @@ static void MX_ADC1_Init(void)
|
||||
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
|
||||
hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T6_TRGO;
|
||||
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
|
||||
hadc1.Init.NbrOfConversion = 7;
|
||||
hadc1.Init.NbrOfConversion = 8;
|
||||
hadc1.Init.DMAContinuousRequests = ENABLE;
|
||||
hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV;
|
||||
hadc1.Init.LowPowerAutoWait = DISABLE;
|
||||
@ -299,10 +299,10 @@ static void MX_ADC1_Init(void)
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_1;
|
||||
sConfig.Channel = ADC_CHANNEL_2;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_1;
|
||||
sConfig.SingleDiff = ADC_SINGLE_ENDED;
|
||||
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
|
||||
sConfig.SamplingTime = ADC_SAMPLETIME_61CYCLES_5;
|
||||
sConfig.OffsetNumber = ADC_OFFSET_NONE;
|
||||
sConfig.Offset = 0;
|
||||
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||
@ -312,6 +312,7 @@ static void MX_ADC1_Init(void)
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_3;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_2;
|
||||
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||
{
|
||||
@ -320,6 +321,7 @@ static void MX_ADC1_Init(void)
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_4;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_3;
|
||||
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||
{
|
||||
@ -328,6 +330,7 @@ static void MX_ADC1_Init(void)
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_5;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_4;
|
||||
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||
{
|
||||
@ -336,6 +339,7 @@ static void MX_ADC1_Init(void)
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_6;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_5;
|
||||
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||
{
|
||||
@ -344,6 +348,7 @@ static void MX_ADC1_Init(void)
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_7;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_6;
|
||||
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||
{
|
||||
@ -352,11 +357,21 @@ static void MX_ADC1_Init(void)
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_8;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_7;
|
||||
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_9;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_8;
|
||||
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN ADC1_Init 2 */
|
||||
|
||||
/* USER CODE END ADC1_Init 2 */
|
||||
@ -392,7 +407,7 @@ static void MX_ADC2_Init(void)
|
||||
hadc2.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
|
||||
hadc2.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T6_TRGO;
|
||||
hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT;
|
||||
hadc2.Init.NbrOfConversion = 7;
|
||||
hadc2.Init.NbrOfConversion = 5;
|
||||
hadc2.Init.DMAContinuousRequests = ENABLE;
|
||||
hadc2.Init.EOCSelection = ADC_EOC_SEQ_CONV;
|
||||
hadc2.Init.LowPowerAutoWait = DISABLE;
|
||||
@ -407,7 +422,7 @@ static void MX_ADC2_Init(void)
|
||||
sConfig.Channel = ADC_CHANNEL_1;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_1;
|
||||
sConfig.SingleDiff = ADC_SINGLE_ENDED;
|
||||
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
|
||||
sConfig.SamplingTime = ADC_SAMPLETIME_61CYCLES_5;
|
||||
sConfig.OffsetNumber = ADC_OFFSET_NONE;
|
||||
sConfig.Offset = 0;
|
||||
if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
|
||||
@ -417,6 +432,7 @@ static void MX_ADC2_Init(void)
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_2;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_2;
|
||||
if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
|
||||
{
|
||||
@ -425,6 +441,7 @@ static void MX_ADC2_Init(void)
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_3;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_3;
|
||||
if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
|
||||
{
|
||||
@ -433,6 +450,7 @@ static void MX_ADC2_Init(void)
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_4;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_4;
|
||||
if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
|
||||
{
|
||||
@ -441,27 +459,12 @@ static void MX_ADC2_Init(void)
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_5;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_5;
|
||||
if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Rank = ADC_REGULAR_RANK_6;
|
||||
if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
sConfig.Rank = ADC_REGULAR_RANK_7;
|
||||
if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN ADC2_Init 2 */
|
||||
|
||||
/* USER CODE END ADC2_Init 2 */
|
||||
@ -769,6 +772,9 @@ static void MX_GPIO_Init(void)
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(DSEL_8_GPIO_Port, DSEL_8_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOB, GSS_GPIO_Pin|DSEL_3_Pin|DSEL_4_Pin|DSEL_5_Pin
|
||||
|DSEL_6_Pin|DSEL_7_Pin, GPIO_PIN_RESET);
|
||||
@ -776,6 +782,13 @@ static void MX_GPIO_Init(void)
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOC, STATUS_LED1_Pin|STATUS_LED2_Pin|STATUS_LED3_Pin|STATUS_LED4_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin : DSEL_8_Pin */
|
||||
GPIO_InitStruct.Pin = DSEL_8_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(DSEL_8_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : GSS_GPIO_Pin DSEL_3_Pin DSEL_4_Pin DSEL_5_Pin
|
||||
DSEL_6_Pin DSEL_7_Pin */
|
||||
GPIO_InitStruct.Pin = GSS_GPIO_Pin|DSEL_3_Pin|DSEL_4_Pin|DSEL_5_Pin
|
||||
|
||||
@ -106,26 +106,32 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
|
||||
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOF_CLK_ENABLE();
|
||||
/**ADC1 GPIO Configuration
|
||||
PC0 ------> ADC1_IN6
|
||||
PC1 ------> ADC1_IN7
|
||||
PC2 ------> ADC1_IN8
|
||||
PC3 ------> ADC1_IN9
|
||||
PA0 ------> ADC1_IN1
|
||||
PA1 ------> ADC1_IN2
|
||||
PA2 ------> ADC1_IN3
|
||||
PA3 ------> ADC1_IN4
|
||||
PF4 ------> ADC1_IN5
|
||||
*/
|
||||
GPIO_InitStruct.Pin = isense12_Pin|isense11_Pin|isense6_Pin|isense13_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = DSEL_8_Pin|isense5_Pin|isense3_Pin|isense7_Pin;
|
||||
GPIO_InitStruct.Pin = isense5_Pin|isense3_Pin|isense7_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = isense9_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(isense9_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* ADC1 DMA Init */
|
||||
/* ADC1 Init */
|
||||
hdma_adc1.Instance = DMA1_Channel1;
|
||||
@ -143,6 +149,9 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
|
||||
|
||||
__HAL_LINKDMA(hadc,DMA_Handle,hdma_adc1);
|
||||
|
||||
/* ADC1 interrupt Init */
|
||||
HAL_NVIC_SetPriority(ADC1_2_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
|
||||
/* USER CODE BEGIN ADC1_MspInit 1 */
|
||||
|
||||
/* USER CODE END ADC1_MspInit 1 */
|
||||
@ -172,10 +181,10 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_4;
|
||||
GPIO_InitStruct.Pin = LV_sens_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
HAL_GPIO_Init(LV_sens_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* ADC2 DMA Init */
|
||||
/* ADC2 Init */
|
||||
@ -194,6 +203,9 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
|
||||
|
||||
__HAL_LINKDMA(hadc,DMA_Handle,hdma_adc2);
|
||||
|
||||
/* ADC2 interrupt Init */
|
||||
HAL_NVIC_SetPriority(ADC1_2_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
|
||||
/* USER CODE BEGIN ADC2_MspInit 1 */
|
||||
|
||||
/* USER CODE END ADC2_MspInit 1 */
|
||||
@ -225,17 +237,29 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
|
||||
PC1 ------> ADC1_IN7
|
||||
PC2 ------> ADC1_IN8
|
||||
PC3 ------> ADC1_IN9
|
||||
PA0 ------> ADC1_IN1
|
||||
PA1 ------> ADC1_IN2
|
||||
PA2 ------> ADC1_IN3
|
||||
PA3 ------> ADC1_IN4
|
||||
PF4 ------> ADC1_IN5
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOC, isense12_Pin|isense11_Pin|isense6_Pin|isense13_Pin);
|
||||
|
||||
HAL_GPIO_DeInit(GPIOA, DSEL_8_Pin|isense5_Pin|isense3_Pin|isense7_Pin);
|
||||
HAL_GPIO_DeInit(GPIOA, isense5_Pin|isense3_Pin|isense7_Pin);
|
||||
|
||||
HAL_GPIO_DeInit(isense9_GPIO_Port, isense9_Pin);
|
||||
|
||||
/* ADC1 DMA DeInit */
|
||||
HAL_DMA_DeInit(hadc->DMA_Handle);
|
||||
|
||||
/* ADC1 interrupt DeInit */
|
||||
/* USER CODE BEGIN ADC1:ADC1_2_IRQn disable */
|
||||
/**
|
||||
* Uncomment the line below to disable the "ADC1_2_IRQn" interrupt
|
||||
* Be aware, disabling shared interrupt may affect other IPs
|
||||
*/
|
||||
/* HAL_NVIC_DisableIRQ(ADC1_2_IRQn); */
|
||||
/* USER CODE END ADC1:ADC1_2_IRQn disable */
|
||||
|
||||
/* USER CODE BEGIN ADC1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END ADC1_MspDeInit 1 */
|
||||
@ -260,10 +284,20 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, isense2_Pin|isense1_Pin|isense10_Pin|isense4_Pin);
|
||||
|
||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_4);
|
||||
HAL_GPIO_DeInit(LV_sens_GPIO_Port, LV_sens_Pin);
|
||||
|
||||
/* ADC2 DMA DeInit */
|
||||
HAL_DMA_DeInit(hadc->DMA_Handle);
|
||||
|
||||
/* ADC2 interrupt DeInit */
|
||||
/* USER CODE BEGIN ADC2:ADC1_2_IRQn disable */
|
||||
/**
|
||||
* Uncomment the line below to disable the "ADC1_2_IRQn" interrupt
|
||||
* Be aware, disabling shared interrupt may affect other IPs
|
||||
*/
|
||||
/* HAL_NVIC_DisableIRQ(ADC1_2_IRQn); */
|
||||
/* USER CODE END ADC2:ADC1_2_IRQn disable */
|
||||
|
||||
/* USER CODE BEGIN ADC2_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END ADC2_MspDeInit 1 */
|
||||
@ -477,6 +511,9 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
|
||||
/* USER CODE END TIM6_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_TIM6_CLK_ENABLE();
|
||||
/* TIM6 interrupt Init */
|
||||
HAL_NVIC_SetPriority(TIM6_DAC_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);
|
||||
/* USER CODE BEGIN TIM6_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM6_MspInit 1 */
|
||||
@ -580,6 +617,9 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
|
||||
/* USER CODE END TIM6_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM6_CLK_DISABLE();
|
||||
|
||||
/* TIM6 interrupt DeInit */
|
||||
HAL_NVIC_DisableIRQ(TIM6_DAC_IRQn);
|
||||
/* USER CODE BEGIN TIM6_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM6_MspDeInit 1 */
|
||||
|
||||
@ -57,7 +57,10 @@
|
||||
/* External variables --------------------------------------------------------*/
|
||||
extern DMA_HandleTypeDef hdma_adc1;
|
||||
extern DMA_HandleTypeDef hdma_adc2;
|
||||
extern ADC_HandleTypeDef hadc1;
|
||||
extern ADC_HandleTypeDef hadc2;
|
||||
extern CAN_HandleTypeDef hcan;
|
||||
extern TIM_HandleTypeDef htim6;
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
@ -215,6 +218,21 @@ void DMA1_Channel1_IRQHandler(void)
|
||||
/* USER CODE END DMA1_Channel1_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles ADC1 and ADC2 interrupts.
|
||||
*/
|
||||
void ADC1_2_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN ADC1_2_IRQn 0 */
|
||||
|
||||
/* USER CODE END ADC1_2_IRQn 0 */
|
||||
HAL_ADC_IRQHandler(&hadc1);
|
||||
HAL_ADC_IRQHandler(&hadc2);
|
||||
/* USER CODE BEGIN ADC1_2_IRQn 1 */
|
||||
|
||||
/* USER CODE END ADC1_2_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles USB low priority or CAN_RX0 interrupts.
|
||||
*/
|
||||
@ -257,6 +275,20 @@ void CAN_SCE_IRQHandler(void)
|
||||
/* USER CODE END CAN_SCE_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Timer 6 interrupt and DAC underrun interrupts.
|
||||
*/
|
||||
void TIM6_DAC_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN TIM6_DAC_IRQn 0 */
|
||||
|
||||
/* USER CODE END TIM6_DAC_IRQn 0 */
|
||||
HAL_TIM_IRQHandler(&htim6);
|
||||
/* USER CODE BEGIN TIM6_DAC_IRQn 1 */
|
||||
|
||||
/* USER CODE END TIM6_DAC_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles DMA2 channel1 global interrupt.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user