diff --git a/demos/ARMCM3-STM32F103-GCC/board.h b/demos/ARMCM3-STM32F103-GCC/board.h index 680668cc2..ef1ecbdaf 100644 --- a/demos/ARMCM3-STM32F103-GCC/board.h +++ b/demos/ARMCM3-STM32F103-GCC/board.h @@ -123,13 +123,13 @@ /* * IO pins assignments. */ -#define GPIOA_BUTTON (1 << 0) +#define GPIOA_BUTTON IOPORT_BIT(0) -#define GPIOC_MMCWP (1 << 6) -#define GPIOC_MMCCP (1 << 7) -#define GPIOC_CANCNTL (1 << 10) -#define GPIOC_DISC (1 << 11) -#define GPIOC_LED (1 << 12) +#define GPIOC_MMCWP IOPORT_BIT(6) +#define GPIOC_MMCCP IOPORT_BIT(7) +#define GPIOC_CANCNTL IOPORT_BIT(10) +#define GPIOC_DISC IOPORT_BIT(11) +#define GPIOC_LED IOPORT_BIT(12) /* * All inputs with pullups unless otherwise specified. diff --git a/demos/ARMCM3-STM32F103-GCC/main.c b/demos/ARMCM3-STM32F103-GCC/main.c index ec59c4ffd..01e4eaab5 100644 --- a/demos/ARMCM3-STM32F103-GCC/main.c +++ b/demos/ARMCM3-STM32F103-GCC/main.c @@ -21,6 +21,7 @@ #include #include "board.h" +#include "ioports.h" #include "stm32_serial.h" /* @@ -30,9 +31,9 @@ static WORKING_AREA(waThread1, 128); static msg_t Thread1(void *arg) { while (TRUE) { - GPIOC->BRR = GPIOC_LED; + chPortClear(IOPORT_C, GPIOC_LED); chThdSleepMilliseconds(500); - GPIOC->BSRR = GPIOC_LED; + chPortSet(IOPORT_C, GPIOC_LED); chThdSleepMilliseconds(500); } return 0; @@ -54,7 +55,7 @@ int main(int argc, char **argv) { * sleeping in a loop and check the button state. */ while (TRUE) { - if (GPIOA->IDR & GPIOA_BUTTON) + if (chPortRead(IOPORT_A) & GPIOA_BUTTON) TestThread(&COM2); chThdSleepMilliseconds(500); } diff --git a/docs/src/main.dox b/docs/src/main.dox index 6eda34beb..fee2af8e5 100644 --- a/docs/src/main.dox +++ b/docs/src/main.dox @@ -401,6 +401,11 @@ *

Reading or writing on pins associated to other functionalities

* The behavior is not specified. * + *

Usage

+ * The use of I/O ports requires the inclusion of the header file @p ioports.h, + * this file is not automatically included @o ch.h like the other header + * files. + * * @ingroup IO */ diff --git a/readme.txt b/readme.txt index bf22eac06..29fcab5cc 100644 --- a/readme.txt +++ b/readme.txt @@ -70,6 +70,7 @@ GNU-Linux-GCC - ChibiOS/RT simulator for x86 Linux systems, it is interface for digital I/O operations, this should help to create more portable applications and, in general, make easier to work with ChibiOS/RT on multiple architectures. +- NEW: Port driver for STM32. - Documentation section reorganization and fixes. - Changed the STM32 demo stack sizes, it was incorrectly adjusted in version 1.3.0 but it did not create problems (not a bug).