aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/ARMCM3-STM32F103-GCC/board.c2
-rw-r--r--ports/ARMCM3-STM32F103/ioports_lld.h10
-rw-r--r--src/templates/ioports_lld.h8
3 files changed, 19 insertions, 1 deletions
diff --git a/demos/ARMCM3-STM32F103-GCC/board.c b/demos/ARMCM3-STM32F103-GCC/board.c
index d3e776d1a..7ce9248cd 100644
--- a/demos/ARMCM3-STM32F103-GCC/board.c
+++ b/demos/ARMCM3-STM32F103-GCC/board.c
@@ -61,7 +61,7 @@ void hwinit0(void) {
/*
* I/O ports initialization as specified in board.h.
*/
- RCC->APB2ENR = 0x0000003D; // Ports A-D enabled, AFIO enabled.
+ ioport_init();
GPIOA->CRL = VAL_GPIOACRL;
GPIOA->CRH = VAL_GPIOACRH;
GPIOA->ODR = VAL_GPIOAODR;
diff --git a/ports/ARMCM3-STM32F103/ioports_lld.h b/ports/ARMCM3-STM32F103/ioports_lld.h
index 2194c3869..fd028e4d3 100644
--- a/ports/ARMCM3-STM32F103/ioports_lld.h
+++ b/ports/ARMCM3-STM32F103/ioports_lld.h
@@ -108,6 +108,16 @@ typedef GPIO_TypeDef * ioportid_t;
/*===========================================================================*/
/**
+ * @brief GPIO ports subsystem initialization.
+ * @details Ports A-D enabled, AFIO enabled.
+ */
+#define ioport_init() { \
+ RCC->APB2ENR |= RCC_APB2ENR_AFIOEN | RCC_APB2ENR_IOPAEN | \
+ RCC_APB2ENR_IOPBEN | RCC_APB2ENR_IOPCEN | \
+ RCC_APB2ENR_IOPDEN; \
+}
+
+/**
* @brief Writes a bits mask on a I/O port.
*
* @param[in] port the port identifier
diff --git a/src/templates/ioports_lld.h b/src/templates/ioports_lld.h
index 708efc8b7..a046446f5 100644
--- a/src/templates/ioports_lld.h
+++ b/src/templates/ioports_lld.h
@@ -66,6 +66,14 @@ typedef uint32_t ioportid_t;
/*===========================================================================*/
/**
+ * @brief I/O ports subsystem initialization.
+ *
+ * @note This function is not invoked by a system API, it should be invoked
+ * from the system initialization code.
+ */
+#define ioport_init()
+
+/**
* @brief Writes a bits mask on a I/O port.
*
* @param[in] port the port identifier