From 8020fc3d67244318840a337811f2f8a33185603a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 2 Jun 2009 10:42:49 +0000 Subject: [PATCH] Added initialization function to the I/O port low level driver. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1014 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARMCM3-STM32F103-GCC/board.c | 2 +- ports/ARMCM3-STM32F103/ioports_lld.h | 10 ++++++++++ src/templates/ioports_lld.h | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) 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 @@ -107,6 +107,16 @@ typedef GPIO_TypeDef * ioportid_t; /* functions, please put them in a file named ioports_lld.c if so. */ /*===========================================================================*/ +/** + * @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. * 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 @@ -65,6 +65,14 @@ typedef uint32_t ioportid_t; /* functions, please put them in a file named ioports_lld.c if so. */ /*===========================================================================*/ +/** + * @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. *