From 9fea26e455c47bc2e59b494ae09422684493601e Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Thu, 8 Nov 2012 14:54:41 -0500 Subject: [PATCH 1/3] stm32/usart: Add enable_/disable_error_interrupt --- include/libopencm3/stm32/usart.h | 2 ++ lib/stm32/usart.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/libopencm3/stm32/usart.h b/include/libopencm3/stm32/usart.h index 088e67b3..9994002c 100644 --- a/include/libopencm3/stm32/usart.h +++ b/include/libopencm3/stm32/usart.h @@ -371,6 +371,8 @@ void usart_enable_rx_interrupt(u32 usart); void usart_disable_rx_interrupt(u32 usart); void usart_enable_tx_interrupt(u32 usart); void usart_disable_tx_interrupt(u32 usart); +void usart_enable_error_interrupt(u32 usart); +void usart_disable_error_interrupt(u32 usart); bool usart_get_flag(u32 usart, u32 flag); bool usart_get_interrupt_source(u32 usart, u32 flag); diff --git a/lib/stm32/usart.c b/lib/stm32/usart.c index 5cf861b5..454df419 100644 --- a/lib/stm32/usart.c +++ b/lib/stm32/usart.c @@ -398,6 +398,27 @@ void usart_disable_tx_interrupt(u32 usart) USART_CR1(usart) &= ~USART_CR1_TXEIE; } +/*-----------------------------------------------------------------------------*/ +/** @brief USART Error Interrupt Enable. + +@param[in] usart unsigned 32 bit. USART block register address base @ref usart_reg_base +*/ + +void usart_enable_error_interrupt(u32 usart) +{ + USART_CR3(usart) |= USART_CR3_EIE; +} + +/*-----------------------------------------------------------------------------*/ +/** @brief USART Error Interrupt Disable. + +@param[in] usart unsigned 32 bit. USART block register address base @ref usart_reg_base +*/ + +void usart_disable_error_interrupt(u32 usart) +{ + USART_CR3(usart) &= ~USART_CR3_EIE; +} /*---------------------------------------------------------------------------*/ /** @brief USART Read a Status Flag. From a43f1d0844447416a5ede0dcf76fd5b2d1d96d23 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Tue, 13 Nov 2012 16:44:52 -0500 Subject: [PATCH 2/3] stm32/f4/memorymap.h: Fix ADC offsets --- include/libopencm3/stm32/f4/memorymap.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/libopencm3/stm32/f4/memorymap.h b/include/libopencm3/stm32/f4/memorymap.h index 0a22ad4b..76258382 100644 --- a/include/libopencm3/stm32/f4/memorymap.h +++ b/include/libopencm3/stm32/f4/memorymap.h @@ -75,8 +75,9 @@ #define USART6_BASE (PERIPH_BASE_APB2 + 0x1400) /* PERIPH_BASE_APB2 + 0x1800 (0x4001 1800 - 0x4001 1FFF): Reserved */ #define ADC1_BASE (PERIPH_BASE_APB2 + 0x2000) -#define ADC2_BASE (PERIPH_BASE_APB2 + 0x2000) -#define ADC3_BASE (PERIPH_BASE_APB2 + 0x2000) +#define ADC2_BASE (PERIPH_BASE_APB2 + 0x2100) +#define ADC3_BASE (PERIPH_BASE_APB2 + 0x2200) +#define ADC_COMMON_BASE (PERIPH_BASE_APB2 + 0x2300) /* PERIPH_BASE_APB2 + 0x2400 (0x4001 2400 - 0x4001 27FF): Reserved */ #define SDIO_BASE (PERIPH_BASE_APB2 + 0x2800) /* PERIPH_BASE_APB2 + 0x2C00 (0x4001 2C00 - 0x4001 2FFF): Reserved */ From 08a14a9d9e9f8acb5e38a422ca7d84a3ce0b02ef Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Tue, 13 Nov 2012 17:20:05 -0500 Subject: [PATCH 3/3] stm32/f4/adc: DMA can always be used with ADC2 I can't find any evidence in the manual to support this comment's claim. --- lib/stm32/f4/adc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/stm32/f4/adc.c b/lib/stm32/f4/adc.c index 7475fac8..aef49a44 100644 --- a/lib/stm32/f4/adc.c +++ b/lib/stm32/f4/adc.c @@ -435,17 +435,12 @@ void adc_set_right_aligned(u32 adc) /*-----------------------------------------------------------------------------*/ /** @brief ADC Enable DMA Transfers -Only available for ADC1 through DMA1 channel1, and ADC3 through DMA2 channel5. -ADC2 will use DMA if it is set as slave in dual mode with ADC1 in DMA transfer -mode. - @param[in] adc Unsigned int32. ADC block register address base @ref adc_reg_base */ void adc_enable_dma(u32 adc) { - if ((adc == ADC1) | (adc == ADC3)) - ADC_CR2(adc) |= ADC_CR2_DMA; + ADC_CR2(adc) |= ADC_CR2_DMA; } /*-----------------------------------------------------------------------------*/ @@ -456,8 +451,7 @@ void adc_enable_dma(u32 adc) void adc_disable_dma(u32 adc) { - if ((adc == ADC1) | (adc == ADC3)) - ADC_CR2(adc) &= ~ADC_CR2_DMA; + ADC_CR2(adc) &= ~ADC_CR2_DMA; } /*-----------------------------------------------------------------------------*/