As David request

This commit is contained in:
dino
2021-03-17 17:02:33 +01:00
committed by David Sidrane
parent 7c8b7fa44d
commit 44b2e0b729
2 changed files with 6 additions and 4 deletions

View File

@@ -116,6 +116,7 @@
# error "ADC STM32_PLL2P_FREQUENCY too high - no divisor found "
#endif
#define ADC3_INTERNAL_TEMP_SENSOR_CHANNEL 18 //define to map the internal temperature channel.
int px4_arch_adc_init(uint32_t base_address)
{
@@ -276,8 +277,10 @@ uint32_t px4_arch_adc_sample(uint32_t base_address, unsigned channel)
{
irqstate_t flags = px4_enter_critical_section();
if (channel > PX4_ADC_ADC3_CHANNEL_OFFSET) {
channel = channel - PX4_ADC_ADC3_CHANNEL_OFFSET;
/* Add a channel mapping for ADC3 on the H7 */
if (channel == PX4_ADC_INTERNAL_TEMP_SENSOR_CHANNEL) {
channel = ADC3_INTERNAL_TEMP_SENSOR_CHANNEL;
base_address = STM32_ADC3_BASE;
}

View File

@@ -62,8 +62,7 @@ int stm32h7_flash_lock(size_t addr);
int stm32h7_flash_unlock(size_t addr);
int stm32h7_flash_writeprotect(size_t block, bool enabled);
#define stm32_flash_lock() stm32h7_flash_lock(PX4_FLASH_BASE)
#define PX4_ADC_ADC3_CHANNEL_OFFSET 7
#define PX4_ADC_ADC3_BASE STM32_ADC3_BASE
#define PX4_ADC_INTERNAL_TEMP_SENSOR_CHANNEL (18 + PX4_ADC_ADC3_CHANNEL_OFFSET) //Valid for ADC3 on H7x3
#define PX4_ADC_INTERNAL_TEMP_SENSOR_CHANNEL (20) //Valid for ADC3 on H7x3
__END_DECLS