Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
281 changes: 0 additions & 281 deletions src/current_sense/hardware_specific/stm32/stm32_adc_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,6 @@

extern ADC_HandleTypeDef hadc[];

int _adcToIndex(ADC_TypeDef *AdcHandle){
if(AdcHandle == ADC1) return 0;
#ifdef ADC2 // if ADC2 exists
else if(AdcHandle == ADC2) return 1;
#endif
#ifdef ADC3 // if ADC3 exists
else if(AdcHandle == ADC3) return 2;
#endif
#ifdef ADC4 // if ADC4 exists
else if(AdcHandle == ADC4) return 3;
#endif
#ifdef ADC5 // if ADC5 exists
else if(AdcHandle == ADC5) return 4;
#endif
return 0;
}
int _adcToIndex(ADC_HandleTypeDef *AdcHandle){
return _adcToIndex(AdcHandle->Instance);
}


ADC_TypeDef* _indexToADC(uint8_t index){
switch (index) {
case 0:
return ADC1;
break;
#ifdef ADC2 // if ADC2 exists
case 1:
return ADC2;
break;
#endif
#ifdef ADC3 // if ADC3 exists
case 2:
return ADC3;
break;
#endif
#ifdef ADC4 // if ADC4 exists
case 3:
return ADC4;
break;
#endif
#ifdef ADC5 // if ADC5 exists
case 4:
return ADC5;
break;
#endif
}
return nullptr;
}

int _findIndexOfEntry(PinName pin) {
// remove the ALT if it is there
Expand Down Expand Up @@ -256,238 +207,6 @@ uint32_t _getADCChannel(PinName pin, ADC_TypeDef *AdcHandle )
return channel;
}

uint32_t _getADCInjectedRank(uint8_t ind){
switch (ind) {
#ifdef ADC_INJECTED_RANK_1
case 0:
return ADC_INJECTED_RANK_1;
#endif
#ifdef ADC_INJECTED_RANK_2
case 1:
return ADC_INJECTED_RANK_2;
#endif
#ifdef ADC_INJECTED_RANK_3
case 2:
return ADC_INJECTED_RANK_3;
#endif
#ifdef ADC_INJECTED_RANK_4
case 3:
return ADC_INJECTED_RANK_4;
#endif
default:
return 0;
}
}

uint32_t _getADCRegularRank(uint8_t ind)
{
switch (ind) {
#ifdef ADC_REGULAR_RANK_1
case 0:
return ADC_REGULAR_RANK_1;
#endif
#ifdef ADC_REGULAR_RANK_2
case 1:
return ADC_REGULAR_RANK_2;
#endif
#ifdef ADC_REGULAR_RANK_3
case 2:
return ADC_REGULAR_RANK_3;
#endif
#ifdef ADC_REGULAR_RANK_4
case 3:
return ADC_REGULAR_RANK_4;
#endif
#ifdef ADC_REGULAR_RANK_5
case 4:
return ADC_REGULAR_RANK_5;
#endif
#ifdef ADC_REGULAR_RANK_6
case 5:
return ADC_REGULAR_RANK_6;
#endif
#ifdef ADC_REGULAR_RANK_7
case 6:
return ADC_REGULAR_RANK_7;
#endif
#ifdef ADC_REGULAR_RANK_8
case 7:
return ADC_REGULAR_RANK_8;
#endif
#ifdef ADC_REGULAR_RANK_9
case 8:
return ADC_REGULAR_RANK_9;
#endif
#ifdef ADC_REGULAR_RANK_10
case 9:
return ADC_REGULAR_RANK_10;
#endif
#ifdef ADC_REGULAR_RANK_11
case 10:
return ADC_REGULAR_RANK_11;
#endif
#ifdef ADC_REGULAR_RANK_12
case 11:
return ADC_REGULAR_RANK_12;
#endif
#ifdef ADC_REGULAR_RANK_13
case 12:
return ADC_REGULAR_RANK_13;
#endif
#ifdef ADC_REGULAR_RANK_14
case 13:
return ADC_REGULAR_RANK_14;
#endif
#ifdef ADC_REGULAR_RANK_15
case 14:
return ADC_REGULAR_RANK_15;
#endif
#ifdef ADC_REGULAR_RANK_16
case 15:
return ADC_REGULAR_RANK_16;
#endif
default:
return 0;
}
}

uint32_t _getADCChannel(uint8_t ind)
{
switch (ind)
{
#ifdef ADC_CHANNEL_0
case 0:
return ADC_CHANNEL_0;
#endif
#ifdef ADC_CHANNEL_1
case 1:
return ADC_CHANNEL_1;
#endif
#ifdef ADC_CHANNEL_2
case 2:
return ADC_CHANNEL_2;
#endif
#ifdef ADC_CHANNEL_3
case 3:
return ADC_CHANNEL_3;
#endif
#ifdef ADC_CHANNEL_4
case 4:
return ADC_CHANNEL_4;
#endif
#ifdef ADC_CHANNEL_5
case 5:
return ADC_CHANNEL_5;
#endif
#ifdef ADC_CHANNEL_6
case 6:
return ADC_CHANNEL_6;
#endif
#ifdef ADC_CHANNEL_7
case 7:
return ADC_CHANNEL_7;
#endif
#ifdef ADC_CHANNEL_8
case 8:
return ADC_CHANNEL_8;
#endif
#ifdef ADC_CHANNEL_9
case 9:
return ADC_CHANNEL_9;
#endif
#ifdef ADC_CHANNEL_10
case 10:
return ADC_CHANNEL_10;
#endif
#ifdef ADC_CHANNEL_11
case 11:
return ADC_CHANNEL_11;
#endif
#ifdef ADC_CHANNEL_12
case 12:
return ADC_CHANNEL_12;
#endif
#ifdef ADC_CHANNEL_13
case 13:
return ADC_CHANNEL_13;
#endif
#ifdef ADC_CHANNEL_14
case 14:
return ADC_CHANNEL_14;
#endif
#ifdef ADC_CHANNEL_15
case 15:
return ADC_CHANNEL_15;
#endif
#ifdef ADC_CHANNEL_16
case 16:
return ADC_CHANNEL_16;
#endif
#ifdef ADC_CHANNEL_17
case 17:
return ADC_CHANNEL_17;
#endif
#ifdef ADC_CHANNEL_18
case 18:
return ADC_CHANNEL_18;
#endif
#ifdef ADC_CHANNEL_19
case 19:
return ADC_CHANNEL_19;
#endif
#ifdef ADC_CHANNEL_20
case 20:
return ADC_CHANNEL_20;
#endif
#ifdef ADC_CHANNEL_21
case 21:
return ADC_CHANNEL_21;
#endif
#ifdef ADC_CHANNEL_22
case 22:
return ADC_CHANNEL_22;
#endif
#ifdef ADC_CHANNEL_23
case 23:
return ADC_CHANNEL_23;
#endif
#ifdef ADC_CHANNEL_24
case 24:
return ADC_CHANNEL_24;
#endif
#ifdef ADC_CHANNEL_25
case 25:
return ADC_CHANNEL_25;
#endif
#ifdef ADC_CHANNEL_26
case 26:
return ADC_CHANNEL_26;
#endif
#ifdef ADC_CHANNEL_27
case 27:
return ADC_CHANNEL_27;
#endif
#ifdef ADC_CHANNEL_28
case 28:
return ADC_CHANNEL_28;
#endif
#ifdef ADC_CHANNEL_29
case 29:
return ADC_CHANNEL_29;
#endif
#ifdef ADC_CHANNEL_30
case 30:
return ADC_CHANNEL_30;
#endif
#ifdef ADC_CHANNEL_31
case 31:
return ADC_CHANNEL_31;
#endif
default:
return 0;
}
}


// returns 0 if no interrupt is needed, 1 if interrupt is needed
uint32_t _initTimerInterruptDownsampling(Stm32CurrentSenseParams* cs_params, STM32DriverParams* driver_params, Stm32AdcInterruptConfig& adc_interrupt_config){
Expand Down
Loading
Loading