summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriabdalkader <i.abdalkader@gmail.com>2023-10-16 17:20:40 +0200
committerDamien George <damien@micropython.org>2023-11-03 16:27:10 +1100
commite5014a4d7953808355c1882a65d6d7824cdd0001 (patch)
tree0575e6513372f79ec7851be397042fc04f1722de
parentb6a977848407a4ced45d118cf926bd915cc89dfb (diff)
stm32: Add configuration options for analog switches.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
-rw-r--r--ports/stm32/boards/ARDUINO_GIGA/mpconfigboard.h6
-rw-r--r--ports/stm32/boards/ARDUINO_NICLA_VISION/board_init.c5
-rw-r--r--ports/stm32/boards/ARDUINO_NICLA_VISION/mpconfigboard.h7
-rw-r--r--ports/stm32/boards/ARDUINO_PORTENTA_H7/mpconfigboard.h6
-rw-r--r--ports/stm32/system_stm32.c14
5 files changed, 33 insertions, 5 deletions
diff --git a/ports/stm32/boards/ARDUINO_GIGA/mpconfigboard.h b/ports/stm32/boards/ARDUINO_GIGA/mpconfigboard.h
index a9b8cbfc7..ec9bbed5e 100644
--- a/ports/stm32/boards/ARDUINO_GIGA/mpconfigboard.h
+++ b/ports/stm32/boards/ARDUINO_GIGA/mpconfigboard.h
@@ -104,6 +104,12 @@ void GIGA_board_low_power(int mode);
// SMPS configuration
#define MICROPY_HW_PWR_SMPS_CONFIG (PWR_LDO_SUPPLY)
+// Configure the analog switches for dual-pad pins.
+#define MICROPY_HW_ANALOG_SWITCH_PA0 (SYSCFG_SWITCH_PA0_OPEN)
+#define MICROPY_HW_ANALOG_SWITCH_PA1 (SYSCFG_SWITCH_PA1_OPEN)
+#define MICROPY_HW_ANALOG_SWITCH_PC2 (SYSCFG_SWITCH_PC2_OPEN)
+#define MICROPY_HW_ANALOG_SWITCH_PC3 (SYSCFG_SWITCH_PC3_OPEN)
+
// There is an external 32kHz oscillator
#define RTC_ASYNCH_PREDIV (0)
#define RTC_SYNCH_PREDIV (0x7fff)
diff --git a/ports/stm32/boards/ARDUINO_NICLA_VISION/board_init.c b/ports/stm32/boards/ARDUINO_NICLA_VISION/board_init.c
index ed8c60927..ec78b09de 100644
--- a/ports/stm32/boards/ARDUINO_NICLA_VISION/board_init.c
+++ b/ports/stm32/boards/ARDUINO_NICLA_VISION/board_init.c
@@ -65,11 +65,6 @@ void NICLAV_board_early_init(void) {
}
#endif
- // Make sure PC2 and PC3 and PC2_C and PC3_C pads are connected
- // through the analog switch for ULPI NXT and DIR pins.
- HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PC2, SYSCFG_SWITCH_PC2_CLOSE);
- HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PC3, SYSCFG_SWITCH_PC3_CLOSE);
-
#if MICROPY_HW_USB_HS_ULPI3320
// Make sure UPLI is Not in low-power mode.
ulpi_leave_low_power();
diff --git a/ports/stm32/boards/ARDUINO_NICLA_VISION/mpconfigboard.h b/ports/stm32/boards/ARDUINO_NICLA_VISION/mpconfigboard.h
index 7cb3d85d3..3cae9b25f 100644
--- a/ports/stm32/boards/ARDUINO_NICLA_VISION/mpconfigboard.h
+++ b/ports/stm32/boards/ARDUINO_NICLA_VISION/mpconfigboard.h
@@ -107,6 +107,13 @@ void NICLAV_board_osc_enable(int enable);
// SMPS configuration
#define MICROPY_HW_PWR_SMPS_CONFIG (PWR_LDO_SUPPLY)
+// Configure the analog switches for dual-pad pins.
+#define MICROPY_HW_ANALOG_SWITCH_PA0 (SYSCFG_SWITCH_PA0_OPEN)
+#define MICROPY_HW_ANALOG_SWITCH_PA1 (SYSCFG_SWITCH_PA1_OPEN)
+// PC2_C and PC3_C, which are connected to ULPI NXT and DIR pins.
+#define MICROPY_HW_ANALOG_SWITCH_PC2 (SYSCFG_SWITCH_PC2_CLOSE)
+#define MICROPY_HW_ANALOG_SWITCH_PC3 (SYSCFG_SWITCH_PC3_CLOSE)
+
// There is an external 32kHz oscillator
#define RTC_ASYNCH_PREDIV (0)
#define RTC_SYNCH_PREDIV (0x7fff)
diff --git a/ports/stm32/boards/ARDUINO_PORTENTA_H7/mpconfigboard.h b/ports/stm32/boards/ARDUINO_PORTENTA_H7/mpconfigboard.h
index 349ca9e00..133158c60 100644
--- a/ports/stm32/boards/ARDUINO_PORTENTA_H7/mpconfigboard.h
+++ b/ports/stm32/boards/ARDUINO_PORTENTA_H7/mpconfigboard.h
@@ -109,6 +109,12 @@ void PORTENTA_board_osc_enable(int enable);
// SMPS configuration
#define MICROPY_HW_PWR_SMPS_CONFIG (PWR_SMPS_1V8_SUPPLIES_LDO)
+// Configure the analog switches for dual-pad pins.
+#define MICROPY_HW_ANALOG_SWITCH_PA0 (SYSCFG_SWITCH_PA0_OPEN)
+#define MICROPY_HW_ANALOG_SWITCH_PA1 (SYSCFG_SWITCH_PA1_OPEN)
+#define MICROPY_HW_ANALOG_SWITCH_PC2 (SYSCFG_SWITCH_PC2_OPEN)
+#define MICROPY_HW_ANALOG_SWITCH_PC3 (SYSCFG_SWITCH_PC3_OPEN)
+
// There is an external 32kHz oscillator
#define RTC_ASYNCH_PREDIV (0)
#define RTC_SYNCH_PREDIV (0x7fff)
diff --git a/ports/stm32/system_stm32.c b/ports/stm32/system_stm32.c
index de1897b4a..2cff36c3a 100644
--- a/ports/stm32/system_stm32.c
+++ b/ports/stm32/system_stm32.c
@@ -587,6 +587,20 @@ MP_WEAK void SystemClock_Config(void) {
// Enable the Debug Module in low-power modes.
DBGMCU->CR |= (DBGMCU_CR_DBG_SLEEPD1 | DBGMCU_CR_DBG_STOPD1 | DBGMCU_CR_DBG_STANDBYD1);
#endif
+
+ // Configure the analog switches
+ #ifdef MICROPY_HW_ANALOG_SWITCH_PA0
+ HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PA0, MICROPY_HW_ANALOG_SWITCH_PA0);
+ #endif
+ #ifdef MICROPY_HW_ANALOG_SWITCH_PA1
+ HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PA1, MICROPY_HW_ANALOG_SWITCH_PA1);
+ #endif
+ #ifdef MICROPY_HW_ANALOG_SWITCH_PC2
+ HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PC2, MICROPY_HW_ANALOG_SWITCH_PC2);
+ #endif
+ #ifdef MICROPY_HW_ANALOG_SWITCH_PC3
+ HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PC3, MICROPY_HW_ANALOG_SWITCH_PC3);
+ #endif
}
#endif