From d65e5e6b0d687a87abfad5f92a27e5920314f0fa Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 4 Dec 2012 15:02:49 +0000 Subject: Serial support for STM32F3xx. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4871 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARMCM4-STM32F303-DISCOVERY/Makefile | 2 +- demos/ARMCM4-STM32F303-DISCOVERY/halconf.h | 2 +- demos/ARMCM4-STM32F303-DISCOVERY/main.c | 15 ++++++++++----- demos/ARMCM4-STM32F303-DISCOVERY/mcuconf.h | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 7 deletions(-) (limited to 'demos') diff --git a/demos/ARMCM4-STM32F303-DISCOVERY/Makefile b/demos/ARMCM4-STM32F303-DISCOVERY/Makefile index 1c85a2ecb..f78da4d33 100644 --- a/demos/ARMCM4-STM32F303-DISCOVERY/Makefile +++ b/demos/ARMCM4-STM32F303-DISCOVERY/Makefile @@ -70,7 +70,7 @@ include $(CHIBIOS)/os/hal/platforms/STM32F3xx/platform.mk include $(CHIBIOS)/os/hal/hal.mk include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F3xx/port.mk include $(CHIBIOS)/os/kernel/kernel.mk -#include $(CHIBIOS)/test/test.mk +include $(CHIBIOS)/test/test.mk # Define linker script file here LDSCRIPT= $(PORTLD)/STM32F303xc.ld diff --git a/demos/ARMCM4-STM32F303-DISCOVERY/halconf.h b/demos/ARMCM4-STM32F303-DISCOVERY/halconf.h index 91d295ccf..c9b3ad25a 100644 --- a/demos/ARMCM4-STM32F303-DISCOVERY/halconf.h +++ b/demos/ARMCM4-STM32F303-DISCOVERY/halconf.h @@ -129,7 +129,7 @@ * @brief Enables the SERIAL subsystem. */ #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL FALSE +#define HAL_USE_SERIAL TRUE #endif /** diff --git a/demos/ARMCM4-STM32F303-DISCOVERY/main.c b/demos/ARMCM4-STM32F303-DISCOVERY/main.c index 3ff8b8820..587d1f694 100644 --- a/demos/ARMCM4-STM32F303-DISCOVERY/main.c +++ b/demos/ARMCM4-STM32F303-DISCOVERY/main.c @@ -20,7 +20,7 @@ #include "ch.h" #include "hal.h" -//#include "test.h" +#include "test.h" /* * This is a periodic thread that does absolutely nothing except flashing @@ -74,7 +74,13 @@ int main(void) { halInit(); chSysInit(); - /* TODO: inialize serial driver 1 or 2 */ + /* + * Activates the serial driver 1 using the driver default configuration. + * PA9(TX) and PA10(RX) are routed to USART1. + */ + sdStart(&SD1, NULL); + palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(7)); + palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7)); /* * Creates the example thread. @@ -87,9 +93,8 @@ int main(void) { * pressed the test procedure is launched. */ while (TRUE) { - /* TODO */ -// if (palReadPad(GPIOA, GPIOA_BUTTON)) -// TestThread(&SD2); + if (palReadPad(GPIOA, GPIOA_BUTTON)) + TestThread(&SD1); chThdSleepMilliseconds(500); } } diff --git a/demos/ARMCM4-STM32F303-DISCOVERY/mcuconf.h b/demos/ARMCM4-STM32F303-DISCOVERY/mcuconf.h index df98fd919..1b0d1243e 100644 --- a/demos/ARMCM4-STM32F303-DISCOVERY/mcuconf.h +++ b/demos/ARMCM4-STM32F303-DISCOVERY/mcuconf.h @@ -66,3 +66,17 @@ #define STM32_RTCSEL STM32_RTCSEL_LSI #define STM32_USB_CLOCK_REQUIRED TRUE #define STM32_USBPRE STM32_USBPRE_DIV1P5 + +/* + * SERIAL driver system settings. + */ +#define STM32_SERIAL_USE_USART1 TRUE +#define STM32_SERIAL_USE_USART2 FALSE +#define STM32_SERIAL_USE_USART3 FALSE +#define STM32_SERIAL_USE_UART4 FALSE +#define STM32_SERIAL_USE_UART5 FALSE +#define STM32_SERIAL_USART1_PRIORITY 12 +#define STM32_SERIAL_USART2_PRIORITY 12 +#define STM32_SERIAL_USART3_PRIORITY 12 +#define STM32_SERIAL_UART4_PRIORITY 12 +#define STM32_SERIAL_UART5_PRIORITY 12 -- cgit v1.2.3