From 45a6b7dc5a1758cb2bc49b0d76effa381043d297 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 19 Aug 2009 13:11:25 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1082 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/ports/GCC/ARMCM3/STM32F103/serial_lld.c | 16 +++++++++++++++- os/ports/GCC/ARMCM3/nvic.c | 15 +++++++++++++++ os/ports/GCC/ARMCM3/nvic.h | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) (limited to 'os/ports/GCC/ARMCM3') diff --git a/os/ports/GCC/ARMCM3/STM32F103/serial_lld.c b/os/ports/GCC/ARMCM3/STM32F103/serial_lld.c index 5e4bcce99..bf06195be 100644 --- a/os/ports/GCC/ARMCM3/STM32F103/serial_lld.c +++ b/os/ports/GCC/ARMCM3/STM32F103/serial_lld.c @@ -45,6 +45,15 @@ SerialDriver COM2; SerialDriver COM3; #endif +/** @brief Driver default configuration.*/ +static const SerialDriverConfig default_config = +{ + 38400, + 0, + USART_CR2_STOP1_BITS | USART_CR2_LINEN, + 0 +}; + /*===========================================================================*/ /* Low Level Driver local functions. */ /*===========================================================================*/ @@ -222,10 +231,15 @@ void sd_lld_init(void) { * @brief Low level serial driver configuration and (re)start. * * @param[in] sdp pointer to a @p SerialDriver object - * @param[in] config the architecture-dependent serial driver configuration + * @param[in] config the architecture-dependent serial driver configuration. + * If this parameter is set to @p NULL then a default + * configuration is used. */ void sd_lld_start(SerialDriver *sdp, const SerialDriverConfig *config) { + if (config == NULL) + config = &default_config; + #if USE_STM32_USART1 if (&COM1 == sdp) { RCC->APB2ENR |= RCC_APB2ENR_USART1EN; diff --git a/os/ports/GCC/ARMCM3/nvic.c b/os/ports/GCC/ARMCM3/nvic.c index 4a11cbb39..e992427fd 100644 --- a/os/ports/GCC/ARMCM3/nvic.c +++ b/os/ports/GCC/ARMCM3/nvic.c @@ -32,6 +32,7 @@ * * @param n the interrupt number * @param prio the interrupt priority + * * @note The parameters are not tested for correctness. */ void NVICEnableVector(uint32_t n, uint32_t prio) { @@ -41,6 +42,20 @@ void NVICEnableVector(uint32_t n, uint32_t prio) { NVIC_ISER(n >> 5) = 1 << (n & 0x1F); } +/** + * @brief Disables an interrupt handler. + * + * @param n the interrupt number + * + * @note The parameters are not tested for correctness. + */ +void NVICDisableVector(uint32_t n) { + unsigned sh = (n & 3) << 3; + + NVIC_ICER(n >> 5) = 1 << (n & 0x1F); + NVIC_IPR(n >> 2) = NVIC_IPR(n >> 2) & ~(0xFF << sh); +} + /** * @brief Changes the priority of a system handler. * diff --git a/os/ports/GCC/ARMCM3/nvic.h b/os/ports/GCC/ARMCM3/nvic.h index 9d2b79606..54437aa62 100644 --- a/os/ports/GCC/ARMCM3/nvic.h +++ b/os/ports/GCC/ARMCM3/nvic.h @@ -180,6 +180,7 @@ typedef struct { extern "C" { #endif void NVICEnableVector(uint32_t n, uint32_t prio); + void NVICDisableVector(uint32_t n); void NVICSetSystemHandlerPriority(uint32_t handler, uint32_t prio); #ifdef __cplusplus } -- cgit v1.2.3