mirror of https://github.com/ARMmbed/mbed-os.git
STM32H7: enable dual analogic pad
parent
538552adea
commit
b289d5a08f
|
|
@ -43,7 +43,7 @@ void analogin_init(analogin_t *obj, PinName pin)
|
||||||
// ADC Internal Channels "pins" (Temperature, Vref, Vbat, ...)
|
// ADC Internal Channels "pins" (Temperature, Vref, Vbat, ...)
|
||||||
// are described in PinNames.h and PeripheralPins.c
|
// are described in PinNames.h and PeripheralPins.c
|
||||||
// Pin value must be between 0xF0 and 0xFF
|
// Pin value must be between 0xF0 and 0xFF
|
||||||
if ((pin < 0xF0) || (pin >= 0x100)) {
|
if ((pin < 0xF0) || (pin >= ALT0)) {
|
||||||
// Normal channels
|
// Normal channels
|
||||||
// Get the peripheral name from the pin and assign it to the object
|
// Get the peripheral name from the pin and assign it to the object
|
||||||
obj->handle.Instance = (ADC_TypeDef *)pinmap_peripheral(pin, PinMap_ADC);
|
obj->handle.Instance = (ADC_TypeDef *)pinmap_peripheral(pin, PinMap_ADC);
|
||||||
|
|
@ -60,6 +60,21 @@ void analogin_init(analogin_t *obj, PinName pin)
|
||||||
MBED_ASSERT(obj->handle.Instance != (ADC_TypeDef *)NC);
|
MBED_ASSERT(obj->handle.Instance != (ADC_TypeDef *)NC);
|
||||||
MBED_ASSERT(function != (uint32_t)NC);
|
MBED_ASSERT(function != (uint32_t)NC);
|
||||||
|
|
||||||
|
#if defined(ALTC)
|
||||||
|
if (pin == PA_0C) {
|
||||||
|
HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PA0, SYSCFG_SWITCH_PA0_OPEN);
|
||||||
|
}
|
||||||
|
if (pin == PA_1C) {
|
||||||
|
HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PA1, SYSCFG_SWITCH_PA1_OPEN);
|
||||||
|
}
|
||||||
|
if (pin == PC_2C) {
|
||||||
|
HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PC2, SYSCFG_SWITCH_PC2_OPEN);
|
||||||
|
}
|
||||||
|
if (pin == PC_3C) {
|
||||||
|
HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PC3, SYSCFG_SWITCH_PC3_OPEN);
|
||||||
|
}
|
||||||
|
#endif /* ALTC */
|
||||||
|
|
||||||
obj->channel = STM_PIN_CHANNEL(function);
|
obj->channel = STM_PIN_CHANNEL(function);
|
||||||
obj->differential = STM_PIN_INVERTED(function);
|
obj->differential = STM_PIN_INVERTED(function);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,9 +135,24 @@ void gpio_init(gpio_t *obj, PinName pin)
|
||||||
// Enable GPIO clock
|
// Enable GPIO clock
|
||||||
GPIO_TypeDef *gpio = Set_GPIO_Clock(port_index);
|
GPIO_TypeDef *gpio = Set_GPIO_Clock(port_index);
|
||||||
|
|
||||||
|
#if defined(ALTC)
|
||||||
|
if (pin == PA_0C) {
|
||||||
|
HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PA0, SYSCFG_SWITCH_PA0_CLOSE);
|
||||||
|
}
|
||||||
|
if (pin == PA_1C) {
|
||||||
|
HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PA1, SYSCFG_SWITCH_PA1_CLOSE);
|
||||||
|
}
|
||||||
|
if (pin == PC_2C) {
|
||||||
|
HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PC2, SYSCFG_SWITCH_PC2_CLOSE);
|
||||||
|
}
|
||||||
|
if (pin == PC_3C) {
|
||||||
|
HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PC3, SYSCFG_SWITCH_PC3_CLOSE);
|
||||||
|
}
|
||||||
|
#endif /* ALTC */
|
||||||
|
|
||||||
// Fill GPIO object structure for future use
|
// Fill GPIO object structure for future use
|
||||||
obj->mask = gpio_set(pin);
|
obj->mask = gpio_set(pin);
|
||||||
obj->gpio = gpio;
|
obj->gpio = gpio;
|
||||||
obj->ll_pin = ll_pin_defines[STM_PIN(obj->pin)];
|
obj->ll_pin = ll_pin_defines[STM_PIN(obj->pin)];
|
||||||
obj->reg_in = &gpio->IDR;
|
obj->reg_in = &gpio->IDR;
|
||||||
obj->reg_set = &gpio->BSRR;
|
obj->reg_set = &gpio->BSRR;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue