From cb2f3071fcd49590499888c27c8f325699eafda9 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Tue, 15 Nov 2011 16:05:12 -0500 Subject: Move wirish/comm/*.cpp into wirish. The wirish/comm/ directory is stupid. Signed-off-by: Marti Bolivar --- wirish/HardwareSerial.cpp | 120 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 wirish/HardwareSerial.cpp (limited to 'wirish/HardwareSerial.cpp') diff --git a/wirish/HardwareSerial.cpp b/wirish/HardwareSerial.cpp new file mode 100644 index 0000000..a9eb763 --- /dev/null +++ b/wirish/HardwareSerial.cpp @@ -0,0 +1,120 @@ +/****************************************************************************** + * The MIT License + * + * Copyright (c) 2010 Perry Hung. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + *****************************************************************************/ + +/** + * @file HardwareSerial.cpp + * @brief Wirish serial port implementation. + */ + +#include + +#include +#include +#include + +#include + +#define TX1 BOARD_USART1_TX_PIN +#define RX1 BOARD_USART1_RX_PIN +#define TX2 BOARD_USART2_TX_PIN +#define RX2 BOARD_USART2_RX_PIN +#define TX3 BOARD_USART3_TX_PIN +#define RX3 BOARD_USART3_RX_PIN +#if defined STM32_HIGH_DENSITY && !defined(BOARD_maple_RET6) +#define TX4 BOARD_UART4_TX_PIN +#define RX4 BOARD_UART4_RX_PIN +#define TX5 BOARD_UART5_TX_PIN +#define RX5 BOARD_UART5_RX_PIN +#endif + +HardwareSerial Serial1(USART1, TX1, RX1, STM32_PCLK2); +HardwareSerial Serial2(USART2, TX2, RX2, STM32_PCLK1); +HardwareSerial Serial3(USART3, TX3, RX3, STM32_PCLK1); +#if defined(STM32_HIGH_DENSITY) && !defined(BOARD_maple_RET6) +HardwareSerial Serial4(UART4, TX4, RX4, STM32_PCLK1); +HardwareSerial Serial5(UART5, TX5, RX5, STM32_PCLK1); +#endif + +HardwareSerial::HardwareSerial(usart_dev *usart_device, + uint8 tx_pin, + uint8 rx_pin, + uint32 clock_speed) { + this->usart_device = usart_device; + this->clock_speed = clock_speed; + this->tx_pin = tx_pin; + this->rx_pin = rx_pin; +} + +/* + * Set up/tear down + */ + +void HardwareSerial::begin(uint32 baud) { + ASSERT(baud <= usart_device->max_baud); + + if (baud > usart_device->max_baud) { + return; + } + + const stm32_pin_info *txi = &PIN_MAP[tx_pin]; + const stm32_pin_info *rxi = &PIN_MAP[rx_pin]; + + gpio_set_mode(txi->gpio_device, txi->gpio_bit, GPIO_AF_OUTPUT_PP); + gpio_set_mode(rxi->gpio_device, rxi->gpio_bit, GPIO_INPUT_FLOATING); + + if (txi->timer_device != NULL) { + /* Turn off any PWM if there's a conflict on this GPIO bit. */ + timer_set_mode(txi->timer_device, txi->timer_channel, TIMER_DISABLED); + } + + usart_init(usart_device); + usart_set_baud_rate(usart_device, clock_speed, baud); + usart_enable(usart_device); +} + +void HardwareSerial::end(void) { + usart_disable(usart_device); +} + +/* + * I/O + */ + +uint8 HardwareSerial::read(void) { + return usart_getc(usart_device); +} + +uint32 HardwareSerial::available(void) { + return usart_data_available(usart_device); +} + +void HardwareSerial::write(unsigned char ch) { + usart_putc(usart_device, ch); +} + +void HardwareSerial::flush(void) { + usart_reset_rx(usart_device); +} -- cgit v1.2.3 From b5c11895b59fbfdc6dda9d26e02df053f8035ff2 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Tue, 8 May 2012 16:22:41 -0400 Subject: Fix a bunch of Doxygen file-level comments. Fix @file in many places. Also fix up the descriptions where it's appropriate. This standardizes the @file formatting across the library to explicitly include any parent directories up to the repository root. Besides being nice, this will hopefully let us manage Doxygen's XML output so as to make extracting series-specific pieces via Breathe in the leaflabs-docs repo possible. Signed-off-by: Marti Bolivar --- examples/test-usart-dma.cpp | 2 +- libmaple/dac.c | 2 +- libmaple/exti.c | 2 +- libmaple/gpio.c | 2 +- libmaple/i2c.c | 2 +- libmaple/include/libmaple/adc.h | 2 +- libmaple/include/libmaple/bitband.h | 2 +- libmaple/include/libmaple/bkp.h | 2 +- libmaple/include/libmaple/dac.h | 2 +- libmaple/include/libmaple/delay.h | 2 +- libmaple/include/libmaple/exti.h | 2 +- libmaple/include/libmaple/fsmc.h | 2 +- libmaple/include/libmaple/gpio.h | 2 +- libmaple/include/libmaple/i2c.h | 2 +- libmaple/include/libmaple/iwdg.h | 2 +- libmaple/include/libmaple/libmaple.h | 2 +- libmaple/include/libmaple/libmaple_types.h | 2 +- libmaple/include/libmaple/nvic.h | 2 +- libmaple/include/libmaple/pwr.h | 4 ++-- libmaple/include/libmaple/rcc.h | 2 +- libmaple/include/libmaple/scb.h | 2 +- libmaple/include/libmaple/spi.h | 2 +- libmaple/include/libmaple/systick.h | 3 +-- libmaple/include/libmaple/timer.h | 2 +- libmaple/include/libmaple/usart.h | 2 +- libmaple/include/libmaple/usb_cdcacm.h | 2 +- libmaple/include/libmaple/util.h | 2 +- libmaple/iwdg.c | 2 +- libmaple/nvic.c | 2 +- libmaple/pwr.c | 2 +- libmaple/stm32f1/adc.c | 4 ++-- libmaple/stm32f1/bkp.c | 4 ++-- libmaple/stm32f1/fsmc.c | 2 +- libmaple/stm32f1/gpio.c | 2 +- libmaple/stm32f1/include/series/adc.h | 2 +- libmaple/stm32f1/include/series/flash.h | 2 +- libmaple/stm32f1/include/series/gpio.h | 8 +++++--- libmaple/stm32f1/include/series/pwr.h | 2 +- libmaple/stm32f1/include/series/rcc.h | 4 ++-- libmaple/stm32f1/include/series/stm32.h | 2 +- libmaple/stm32f1/include/series/timer.h | 4 ++-- libmaple/stm32f1/include/series/usart.h | 4 ++-- libmaple/stm32f1/rcc.c | 2 +- libmaple/stm32f1/spi.c | 2 +- libmaple/stm32f1/timer.c | 2 +- libmaple/stm32f1/usart.c | 2 +- libmaple/stm32f2/adc.c | 4 ++-- libmaple/stm32f2/fsmc.c | 2 +- libmaple/stm32f2/gpio.c | 2 +- libmaple/stm32f2/include/series/adc.h | 4 ++-- libmaple/stm32f2/include/series/flash.h | 2 +- libmaple/stm32f2/include/series/gpio.h | 4 ++-- libmaple/stm32f2/include/series/pwr.h | 2 +- libmaple/stm32f2/include/series/rcc.h | 2 +- libmaple/stm32f2/include/series/stm32.h | 2 +- libmaple/stm32f2/include/series/timer.h | 4 ++-- libmaple/stm32f2/include/series/usart.h | 4 ++-- libmaple/stm32f2/rcc.c | 2 +- libmaple/stm32f2/timer.c | 2 +- libmaple/stm32f2/usart.c | 2 +- libmaple/syscalls.c | 8 +++++--- libmaple/systick.c | 4 ++-- libmaple/usart.c | 4 ++-- libmaple/usb/usb.c | 4 +++- libmaple/usb/usb_cdcacm.c | 8 +++++--- libmaple/util.c | 2 +- wirish/HardwareSerial.cpp | 2 +- wirish/boards.cpp | 2 +- wirish/ext_interrupts.cpp | 5 ++--- wirish/include/wirish/HardwareSPI.h | 2 +- wirish/include/wirish/HardwareSerial.h | 2 +- wirish/include/wirish/boards.h | 4 ++-- wirish/include/wirish/ext_interrupts.h | 5 ++--- wirish/include/wirish/io.h | 5 ++--- wirish/include/wirish/pwm.h | 5 ++--- wirish/include/wirish/wirish_debug.h | 2 +- wirish/include/wirish/wirish_math.h | 4 ++-- wirish/include/wirish/wirish_time.h | 2 +- wirish/include/wirish/wirish_types.h | 2 +- 79 files changed, 112 insertions(+), 109 deletions(-) (limited to 'wirish/HardwareSerial.cpp') diff --git a/examples/test-usart-dma.cpp b/examples/test-usart-dma.cpp index 8fbcccb..10ebe8b 100644 --- a/examples/test-usart-dma.cpp +++ b/examples/test-usart-dma.cpp @@ -1,5 +1,5 @@ /** - * @file test-usart-dma.cpp + * @file examples/test-usart-dma.cpp * @author Marti Bolivar * * Simple test of DMA used with a USART receiver. diff --git a/libmaple/dac.c b/libmaple/dac.c index efcba15..f630ac0 100644 --- a/libmaple/dac.c +++ b/libmaple/dac.c @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file dac.c + * @file libmaple/dac.c * @brief Digital to analog converter support. */ diff --git a/libmaple/exti.c b/libmaple/exti.c index 00e0df2..248c4b6 100644 --- a/libmaple/exti.c +++ b/libmaple/exti.c @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file exti.c + * @file libmaple/exti.c * @brief External interrupt control routines */ diff --git a/libmaple/gpio.c b/libmaple/gpio.c index 64b2d54..898007a 100644 --- a/libmaple/gpio.c +++ b/libmaple/gpio.c @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file gpio.c + * @file libmaple/gpio.c * @brief Generic STM32 GPIO support. */ diff --git a/libmaple/i2c.c b/libmaple/i2c.c index ae44532..3eca22a 100644 --- a/libmaple/i2c.c +++ b/libmaple/i2c.c @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file i2c.c + * @file libmaple/i2c.c * @brief Inter-Integrated Circuit (I2C) support. * * Currently, only master mode is supported. diff --git a/libmaple/include/libmaple/adc.h b/libmaple/include/libmaple/adc.h index 3cd3eb2..8d2f398 100644 --- a/libmaple/include/libmaple/adc.h +++ b/libmaple/include/libmaple/adc.h @@ -26,7 +26,7 @@ *****************************************************************************/ /** - * @file libmaple/adc.h + * @file libmaple/include/libmaple/adc.h * @author Marti Bolivar , * Perry Hung * @brief Analog-to-Digital Conversion (ADC) header. diff --git a/libmaple/include/libmaple/bitband.h b/libmaple/include/libmaple/bitband.h index 607e4eb..0980311 100644 --- a/libmaple/include/libmaple/bitband.h +++ b/libmaple/include/libmaple/bitband.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file bitband.h + * @file libmaple/include/libmaple/bitband.h * * @brief Bit-banding utility functions */ diff --git a/libmaple/include/libmaple/bkp.h b/libmaple/include/libmaple/bkp.h index edc1013..bb63a2f 100644 --- a/libmaple/include/libmaple/bkp.h +++ b/libmaple/include/libmaple/bkp.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file bkp.h + * @file libmaple/include/libmaple/bkp.h * @brief Backup register support (STM32F1 only). */ diff --git a/libmaple/include/libmaple/dac.h b/libmaple/include/libmaple/dac.h index 9bd74b4..047f874 100644 --- a/libmaple/include/libmaple/dac.h +++ b/libmaple/include/libmaple/dac.h @@ -26,7 +26,7 @@ *****************************************************************************/ /** - * @file libmaple/dac.h + * @file libmaple/include/libmaple/dac.h * @brief Digital to analog converter support. */ diff --git a/libmaple/include/libmaple/delay.h b/libmaple/include/libmaple/delay.h index f79655d..472a208 100644 --- a/libmaple/include/libmaple/delay.h +++ b/libmaple/include/libmaple/delay.h @@ -26,7 +26,7 @@ *****************************************************************************/ /** - * @file delay.h + * @file libmaple/include/libmaple/delay.h * @brief Delay implementation */ diff --git a/libmaple/include/libmaple/exti.h b/libmaple/include/libmaple/exti.h index 0a763d7..d7bfe51 100644 --- a/libmaple/include/libmaple/exti.h +++ b/libmaple/include/libmaple/exti.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file exti.h + * @file libmaple/include/libmaple/exti.h * @brief External interrupt control prototypes and defines */ diff --git a/libmaple/include/libmaple/fsmc.h b/libmaple/include/libmaple/fsmc.h index df211b2..01a6a3b 100644 --- a/libmaple/include/libmaple/fsmc.h +++ b/libmaple/include/libmaple/fsmc.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file fsmc.h + * @file libmaple/include/libmaple/fsmc.h * @brief Flexible static memory controller support. */ diff --git a/libmaple/include/libmaple/gpio.h b/libmaple/include/libmaple/gpio.h index 609320f..f7773c0 100644 --- a/libmaple/include/libmaple/gpio.h +++ b/libmaple/include/libmaple/gpio.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file gpio.h + * @file libmaple/include/libmaple/gpio.h * @brief General Purpose I/O (GPIO) interace. */ diff --git a/libmaple/include/libmaple/i2c.h b/libmaple/include/libmaple/i2c.h index 8a1485e..ffd0cfb 100644 --- a/libmaple/include/libmaple/i2c.h +++ b/libmaple/include/libmaple/i2c.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file i2c.h + * @file libmaple/include/libmaple/i2c.h * @brief Inter-Integrated Circuit (I2C) peripheral support */ diff --git a/libmaple/include/libmaple/iwdg.h b/libmaple/include/libmaple/iwdg.h index 80202d2..0aef8fd 100644 --- a/libmaple/include/libmaple/iwdg.h +++ b/libmaple/include/libmaple/iwdg.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file libmaple/iwdg.h + * @file libmaple/include/libmaple/iwdg.h * @author Michael Hope, Marti Bolivar * @brief Independent watchdog support. * diff --git a/libmaple/include/libmaple/libmaple.h b/libmaple/include/libmaple/libmaple.h index 60b23ed..f1a595e 100644 --- a/libmaple/include/libmaple/libmaple.h +++ b/libmaple/include/libmaple/libmaple.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file libmaple.h + * @file libmaple/include/libmaple/libmaple.h * @brief General include file for libmaple */ diff --git a/libmaple/include/libmaple/libmaple_types.h b/libmaple/include/libmaple/libmaple_types.h index 0a83795..0c22792 100644 --- a/libmaple/include/libmaple/libmaple_types.h +++ b/libmaple/include/libmaple/libmaple_types.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file libmaple_types.h + * @file libmaple/include/libmaple/libmaple_types.h * * @brief libmaple's types, and operations on types. */ diff --git a/libmaple/include/libmaple/nvic.h b/libmaple/include/libmaple/nvic.h index 1a1a4ed..86ac1cb 100644 --- a/libmaple/include/libmaple/nvic.h +++ b/libmaple/include/libmaple/nvic.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file nvic.h + * @file libmaple/include/libmaple/nvic.h * @brief Nested vectored interrupt controller support. * * Basic usage: diff --git a/libmaple/include/libmaple/pwr.h b/libmaple/include/libmaple/pwr.h index 2611587..e4b5b0d 100644 --- a/libmaple/include/libmaple/pwr.h +++ b/libmaple/include/libmaple/pwr.h @@ -25,8 +25,8 @@ *****************************************************************************/ /** - * @file pwr.h - * @brief Power control (PWR) defines. + * @file libmaple/include/libmaple/pwr.h + * @brief Power control (PWR). */ #ifndef _LIBMAPLE_PWR_H_ diff --git a/libmaple/include/libmaple/rcc.h b/libmaple/include/libmaple/rcc.h index b04f016..7c23f1b 100644 --- a/libmaple/include/libmaple/rcc.h +++ b/libmaple/include/libmaple/rcc.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file libmaple/rcc.h + * @file libmaple/include/libmaple/rcc.h * @brief Reset and Clock Control (RCC) interface. */ diff --git a/libmaple/include/libmaple/scb.h b/libmaple/include/libmaple/scb.h index 9c4ee15..1c7c5d7 100644 --- a/libmaple/include/libmaple/scb.h +++ b/libmaple/include/libmaple/scb.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file scb.h + * @file libmaple/include/libmaple/scb.h * @brief System control block header */ diff --git a/libmaple/include/libmaple/spi.h b/libmaple/include/libmaple/spi.h index 5b045a9..3805b2e 100644 --- a/libmaple/include/libmaple/spi.h +++ b/libmaple/include/libmaple/spi.h @@ -26,7 +26,7 @@ *****************************************************************************/ /** - * @file libmaple/spi.h + * @file libmaple/include/libmaple/spi.h * @author Marti Bolivar * @brief Serial Peripheral Interface (SPI) and Integrated * Interchip Sound (I2S) peripheral support. diff --git a/libmaple/include/libmaple/systick.h b/libmaple/include/libmaple/systick.h index 1731c85..551f800 100644 --- a/libmaple/include/libmaple/systick.h +++ b/libmaple/include/libmaple/systick.h @@ -25,8 +25,7 @@ *****************************************************************************/ /** - * @file systick.h - * + * @file libmaple/include/libmaple/systick.h * @brief System timer definitions */ diff --git a/libmaple/include/libmaple/timer.h b/libmaple/include/libmaple/timer.h index 0a34066..887b7eb 100644 --- a/libmaple/include/libmaple/timer.h +++ b/libmaple/include/libmaple/timer.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file libmaple/timer.h + * @file libmaple/include/libmaple/timer.h * @author Marti Bolivar * @brief Timer interface. */ diff --git a/libmaple/include/libmaple/usart.h b/libmaple/include/libmaple/usart.h index 42f9576..ad7eb51 100644 --- a/libmaple/include/libmaple/usart.h +++ b/libmaple/include/libmaple/usart.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file usart.h + * @file libmaple/include/libmaple/usart.h * @author Marti Bolivar , * Perry Hung * @brief USART definitions and prototypes diff --git a/libmaple/include/libmaple/usb_cdcacm.h b/libmaple/include/libmaple/usb_cdcacm.h index 2dbcbea..9d70758 100644 --- a/libmaple/include/libmaple/usb_cdcacm.h +++ b/libmaple/include/libmaple/usb_cdcacm.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file usb_cdcacm.h + * @file libmaple/include/libmaple/usb_cdcacm.h * @brief USB CDC ACM (virtual serial terminal) support */ diff --git a/libmaple/include/libmaple/util.h b/libmaple/include/libmaple/util.h index 78bc03d..60ca0d3 100644 --- a/libmaple/include/libmaple/util.h +++ b/libmaple/include/libmaple/util.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file util.h + * @file libmaple/include/libmaple/util.h * @brief Miscellaneous utility macros and procedures. */ diff --git a/libmaple/iwdg.c b/libmaple/iwdg.c index 6dd77fc..2456235 100644 --- a/libmaple/iwdg.c +++ b/libmaple/iwdg.c @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file iwdg.c + * @file libmaple/iwdg.c * @brief Independent watchdog (IWDG) support */ diff --git a/libmaple/nvic.c b/libmaple/nvic.c index e3f79a3..fe7c7bc 100644 --- a/libmaple/nvic.c +++ b/libmaple/nvic.c @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file nvic.c + * @file libmaple/nvic.c * @brief Nested vector interrupt controller support. */ diff --git a/libmaple/pwr.c b/libmaple/pwr.c index f934269..3cf170f 100644 --- a/libmaple/pwr.c +++ b/libmaple/pwr.c @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file pwr.c + * @file libmaple/pwr.c * @brief Power control (PWR) support. */ diff --git a/libmaple/stm32f1/adc.c b/libmaple/stm32f1/adc.c index 794c5c8..facc6bd 100644 --- a/libmaple/stm32f1/adc.c +++ b/libmaple/stm32f1/adc.c @@ -26,10 +26,10 @@ *****************************************************************************/ /** - * @file libmaple/stm32f1/include/series/adc.c + * @file libmaple/stm32f1/adc.c * @author Marti Bolivar , * Perry Hung - * @brief STM32F1-specific ADC support. + * @brief STM32F1 ADC support. */ #include diff --git a/libmaple/stm32f1/bkp.c b/libmaple/stm32f1/bkp.c index 62783e7..f435ff1 100644 --- a/libmaple/stm32f1/bkp.c +++ b/libmaple/stm32f1/bkp.c @@ -25,8 +25,8 @@ *****************************************************************************/ /** - * @file bkp.c - * @brief Backup register support. + * @file libmaple/stm32f1/bkp.c + * @brief STM32F1 Backup register support. */ #include diff --git a/libmaple/stm32f1/fsmc.c b/libmaple/stm32f1/fsmc.c index 8e01b5e..210f0be 100644 --- a/libmaple/stm32f1/fsmc.c +++ b/libmaple/stm32f1/fsmc.c @@ -26,7 +26,7 @@ *****************************************************************************/ /** - * @file stm32f1/fsmc.c + * @file libmaple/stm32f1/fsmc.c * @author Marti Bolivar , * Bryan Newbold * @brief STM32F1 FSMC support. diff --git a/libmaple/stm32f1/gpio.c b/libmaple/stm32f1/gpio.c index 01a4028..2cbe299 100644 --- a/libmaple/stm32f1/gpio.c +++ b/libmaple/stm32f1/gpio.c @@ -26,7 +26,7 @@ /** * @file libmaple/stm32f1/gpio.c - * @brief GPIO support for STM32F1 line. + * @brief STM32F1 GPIO support. */ #include diff --git a/libmaple/stm32f1/include/series/adc.h b/libmaple/stm32f1/include/series/adc.h index 007641a..774c97c 100644 --- a/libmaple/stm32f1/include/series/adc.h +++ b/libmaple/stm32f1/include/series/adc.h @@ -26,7 +26,7 @@ *****************************************************************************/ /** - * @file stm32f1/include/series/adc.h + * @file libmaple/stm32f1/include/series/adc.h * @author Marti Bolivar , * Perry Hung * @brief STM32F1 ADC header. diff --git a/libmaple/stm32f1/include/series/flash.h b/libmaple/stm32f1/include/series/flash.h index 5603176..0c70986 100644 --- a/libmaple/stm32f1/include/series/flash.h +++ b/libmaple/stm32f1/include/series/flash.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file libmaple/stm32f1/flash.h + * @file libmaple/stm32f1/include/series/flash.h * @brief STM32F1 Flash header. * * Provides register map, base pointer, and register bit definitions diff --git a/libmaple/stm32f1/include/series/gpio.h b/libmaple/stm32f1/include/series/gpio.h index c10244d..1f209fe 100644 --- a/libmaple/stm32f1/include/series/gpio.h +++ b/libmaple/stm32f1/include/series/gpio.h @@ -26,9 +26,11 @@ *****************************************************************************/ /** - * @file libmaple/stm32f1/gpio.h - * @brief General purpose I/O (GPIO) and Alternate Function I/O - * (AFIO) prototypes, defines, and inlined access functions. + * @file libmaple/stm32f1/include/series/gpio.h + * @brief STM32F1 GPIO support. + * + * General purpose I/O (GPIO) and Alternate Function I/O (AFIO) + * prototypes, defines, and support functions. */ #ifndef _LIBMAPLE_STM32F1_GPIO_H_ diff --git a/libmaple/stm32f1/include/series/pwr.h b/libmaple/stm32f1/include/series/pwr.h index d13ffa7..e143a8c 100644 --- a/libmaple/stm32f1/include/series/pwr.h +++ b/libmaple/stm32f1/include/series/pwr.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file stm32f1/pwr.h + * @file libmaple/stm32f1/include/series/pwr.h * @author Marti Bolivar * @brief STM32F1 Power control (PWR) support. */ diff --git a/libmaple/stm32f1/include/series/rcc.h b/libmaple/stm32f1/include/series/rcc.h index f60b07b..3e7f7c6 100644 --- a/libmaple/stm32f1/include/series/rcc.h +++ b/libmaple/stm32f1/include/series/rcc.h @@ -26,8 +26,8 @@ *****************************************************************************/ /** - * @file libmaple/stm32f1/rcc.h - * @brief STM32F1 reset and clock control (RCC) header. + * @file libmaple/stm32f1/include/series/rcc.h + * @brief STM32F1 reset and clock control (RCC) support. */ #ifndef _LIBMAPLE_STM32F1_RCC_H_ diff --git a/libmaple/stm32f1/include/series/stm32.h b/libmaple/stm32f1/include/series/stm32.h index 999abab..e6d3b19 100644 --- a/libmaple/stm32f1/include/series/stm32.h +++ b/libmaple/stm32f1/include/series/stm32.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file libmaple/stm32f1/stm32.h + * @file libmaple/stm32f1/include/series/stm32.h * @brief STM32F1 chip- and series-specific definitions. */ diff --git a/libmaple/stm32f1/include/series/timer.h b/libmaple/stm32f1/include/series/timer.h index 2551f70..8a64ffa 100644 --- a/libmaple/stm32f1/include/series/timer.h +++ b/libmaple/stm32f1/include/series/timer.h @@ -25,9 +25,9 @@ *****************************************************************************/ /** - * @file stm32f1/include/series/timer.h + * @file libmaple/stm32f1/include/series/timer.h * @author Marti Bolivar - * @brief STM32F1 timer sub-header. + * @brief STM32F1 timer support. */ #ifndef _LIBMAPLE_STM32F1_TIMER_H_ diff --git a/libmaple/stm32f1/include/series/usart.h b/libmaple/stm32f1/include/series/usart.h index 93a7728..d12a3e2 100644 --- a/libmaple/stm32f1/include/series/usart.h +++ b/libmaple/stm32f1/include/series/usart.h @@ -25,9 +25,9 @@ *****************************************************************************/ /** - * @file libmaple/stm32f1/usart.h + * @file libmaple/stm32f1/include/series/usart.h * @author Marti Bolivar - * @brief STM32F1 USART header. + * @brief STM32F1 USART support. */ #ifndef _LIBMAPLE_STM32F1_USART_H_ diff --git a/libmaple/stm32f1/rcc.c b/libmaple/stm32f1/rcc.c index aeedf66..ca81755 100644 --- a/libmaple/stm32f1/rcc.c +++ b/libmaple/stm32f1/rcc.c @@ -27,7 +27,7 @@ /** * @file libmaple/stm32f1/rcc.c - * @brief STM32F1 RCC routines. + * @brief STM32F1 RCC. */ #include diff --git a/libmaple/stm32f1/spi.c b/libmaple/stm32f1/spi.c index 45ff354..8b6e495 100644 --- a/libmaple/stm32f1/spi.c +++ b/libmaple/stm32f1/spi.c @@ -28,7 +28,7 @@ /** * @file libmaple/stm32f1/spi.c * @author Marti Bolivar - * @brief STM32F1 SPI/I2S support. + * @brief STM32F1 SPI/I2S. */ #include diff --git a/libmaple/stm32f1/timer.c b/libmaple/stm32f1/timer.c index 899abbc..002b9d6 100644 --- a/libmaple/stm32f1/timer.c +++ b/libmaple/stm32f1/timer.c @@ -27,7 +27,7 @@ /** * @file libmaple/stm32f1/timer.c * @author Marti Bolivar - * @brief STM32F1 timer support. + * @brief STM32F1 timer. */ /* Notes: diff --git a/libmaple/stm32f1/usart.c b/libmaple/stm32f1/usart.c index ee68082..eed420e 100644 --- a/libmaple/stm32f1/usart.c +++ b/libmaple/stm32f1/usart.c @@ -29,7 +29,7 @@ * @file libmaple/stm32f1/usart.c * @author Marti Bolivar , * Perry Hung - * @brief STM32F1 USART support. + * @brief STM32F1 USART. */ #include diff --git a/libmaple/stm32f2/adc.c b/libmaple/stm32f2/adc.c index a4c227e..0380736 100644 --- a/libmaple/stm32f2/adc.c +++ b/libmaple/stm32f2/adc.c @@ -25,8 +25,8 @@ *****************************************************************************/ /** - * @file libmaple/stm32f2/include/series/adc.c - * @brief STM32F2 ADC header. + * @file libmaple/stm32f2/adc.c + * @brief STM32F2 ADC. */ #include diff --git a/libmaple/stm32f2/fsmc.c b/libmaple/stm32f2/fsmc.c index 9b23eea..7f49cd8 100644 --- a/libmaple/stm32f2/fsmc.c +++ b/libmaple/stm32f2/fsmc.c @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file stm32f2/fsmc.c + * @file libmaple/stm32f2/fsmc.c * @author Marti Bolivar , * @brief STM32F2 FSMC support. */ diff --git a/libmaple/stm32f2/gpio.c b/libmaple/stm32f2/gpio.c index e441fbc..7479922 100644 --- a/libmaple/stm32f2/gpio.c +++ b/libmaple/stm32f2/gpio.c @@ -26,7 +26,7 @@ /** * @file libmaple/stm32f2/gpio.c - * @brief GPIO support for STM32F2 line. + * @brief STM32F2 GPIO. */ #include diff --git a/libmaple/stm32f2/include/series/adc.h b/libmaple/stm32f2/include/series/adc.h index 4f0cd6b..714179c 100644 --- a/libmaple/stm32f2/include/series/adc.h +++ b/libmaple/stm32f2/include/series/adc.h @@ -25,9 +25,9 @@ *****************************************************************************/ /** - * @file stm32f2/include/series/adc.h + * @file libmaple/stm32f2/include/series/adc.h * @author Marti Bolivar , - * @brief STM32F2 ADC header. + * @brief STM32F2 ADC support. */ #ifndef _LIBMAPLE_STM32F2_ADC_H_ diff --git a/libmaple/stm32f2/include/series/flash.h b/libmaple/stm32f2/include/series/flash.h index f48eea3..cfc6e6b 100644 --- a/libmaple/stm32f2/include/series/flash.h +++ b/libmaple/stm32f2/include/series/flash.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file libmaple/stm32f2/flash.h + * @file libmaple/stm32f2/include/series/flash.h * @brief STM32F2 Flash header. * * Provides register map, base pointer, and register bit definitions diff --git a/libmaple/stm32f2/include/series/gpio.h b/libmaple/stm32f2/include/series/gpio.h index 40c7292..9687247 100644 --- a/libmaple/stm32f2/include/series/gpio.h +++ b/libmaple/stm32f2/include/series/gpio.h @@ -25,8 +25,8 @@ *****************************************************************************/ /** - * @file libmaple/stm32f2/gpio.h - * @brief STM32F2 General Purpose I/O (GPIO) header. + * @file libmaple/stm32f2/include/series/gpio.h + * @brief STM32F2 GPIO support. */ #ifndef _LIBMAPLE_STM32F2_GPIO_H_ diff --git a/libmaple/stm32f2/include/series/pwr.h b/libmaple/stm32f2/include/series/pwr.h index dec2d76..96353a4 100644 --- a/libmaple/stm32f2/include/series/pwr.h +++ b/libmaple/stm32f2/include/series/pwr.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file stm32f2/pwr.h + * @file libmaple/stm32f2/include/series/pwr.h * @author Marti Bolivar * @brief STM32F2 Power control (PWR) support. */ diff --git a/libmaple/stm32f2/include/series/rcc.h b/libmaple/stm32f2/include/series/rcc.h index d797ba9..9c3fdd5 100644 --- a/libmaple/stm32f2/include/series/rcc.h +++ b/libmaple/stm32f2/include/series/rcc.h @@ -26,7 +26,7 @@ /** * @file libmaple/stm32f2/include/series/rcc.h - * @brief STM32F2 reset and clock control (RCC) header. + * @brief STM32F2 reset and clock control (RCC) support. */ /* diff --git a/libmaple/stm32f2/include/series/stm32.h b/libmaple/stm32f2/include/series/stm32.h index 5ab4c56..9e88a70 100644 --- a/libmaple/stm32f2/include/series/stm32.h +++ b/libmaple/stm32f2/include/series/stm32.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file libmaple/stm32f2/stm32.h + * @file libmaple/stm32f2/include/series/stm32.h * @brief STM32F2 chip- and series-specific definitions. */ diff --git a/libmaple/stm32f2/include/series/timer.h b/libmaple/stm32f2/include/series/timer.h index cf7cc15..0d959d0 100644 --- a/libmaple/stm32f2/include/series/timer.h +++ b/libmaple/stm32f2/include/series/timer.h @@ -25,9 +25,9 @@ *****************************************************************************/ /** - * @file stm32f2/include/series/timer.h + * @file libmaple/stm32f2/include/series/timer.h * @author Marti Bolivar - * @brief STM32F2 timer sub-header. + * @brief STM32F2 timer support. */ #ifndef _LIBMAPLE_STM32F2_TIMER_H_ diff --git a/libmaple/stm32f2/include/series/usart.h b/libmaple/stm32f2/include/series/usart.h index 9b18b9c..805a2b2 100644 --- a/libmaple/stm32f2/include/series/usart.h +++ b/libmaple/stm32f2/include/series/usart.h @@ -25,9 +25,9 @@ *****************************************************************************/ /** - * @file libmaple/stm32f2/usart.h + * @file libmaple/stm32f2/include/series/usart.h * @author Marti Bolivar - * @brief STM32F2 USART header. + * @brief STM32F2 USART support. */ #ifndef _LIBMAPLE_STM32F2_USART_H_ diff --git a/libmaple/stm32f2/rcc.c b/libmaple/stm32f2/rcc.c index 8a91f30..a13e56d 100644 --- a/libmaple/stm32f2/rcc.c +++ b/libmaple/stm32f2/rcc.c @@ -26,7 +26,7 @@ /** * @file libmaple/stm32f2/rcc.c - * @brief STM32F2 RCC routines. + * @brief STM32F2 RCC. */ #include diff --git a/libmaple/stm32f2/timer.c b/libmaple/stm32f2/timer.c index eed7810..3f9a8d2 100644 --- a/libmaple/stm32f2/timer.c +++ b/libmaple/stm32f2/timer.c @@ -27,7 +27,7 @@ /** * @file libmaple/stm32f2/timer.c * @author Marti Bolivar - * @brief STM32F2 timer support. + * @brief STM32F2 timers. */ #include diff --git a/libmaple/stm32f2/usart.c b/libmaple/stm32f2/usart.c index 364558c..e4fc9b1 100644 --- a/libmaple/stm32f2/usart.c +++ b/libmaple/stm32f2/usart.c @@ -27,7 +27,7 @@ /** * @file libmaple/stm32f2/usart.c * @author Marti Bolivar - * @brief STM32F2 USART support. + * @brief STM32F2 USART. */ #include diff --git a/libmaple/syscalls.c b/libmaple/syscalls.c index 86fd8e6..30a63bf 100644 --- a/libmaple/syscalls.c +++ b/libmaple/syscalls.c @@ -25,9 +25,11 @@ *****************************************************************************/ /** - * @file syscalls.c - * @brief Low level system routines used by Newlib for basic I/O and - * memory allocation. + * @file libmaple/syscalls.c + * @brief newlib stubs + * + * Low level system routines used by Newlib for basic I/O and memory + * allocation. */ #include diff --git a/libmaple/systick.c b/libmaple/systick.c index c6e3cbd..80c0c47 100644 --- a/libmaple/systick.c +++ b/libmaple/systick.c @@ -25,8 +25,8 @@ *****************************************************************************/ /** - * @file systick.c - * @brief System timer interrupt handler and initialization routines + * @file libmaple/systick.c + * @brief System timer (SysTick). */ #include diff --git a/libmaple/usart.c b/libmaple/usart.c index 1070aa2..253cf9f 100644 --- a/libmaple/usart.c +++ b/libmaple/usart.c @@ -25,10 +25,10 @@ *****************************************************************************/ /** - * @file usart.c + * @file libmaple/usart.c * @author Marti Bolivar , * Perry Hung - * @brief USART control routines + * @brief Portable USART routines */ #include diff --git a/libmaple/usb/usb.c b/libmaple/usb/usb.c index 6f23848..0130bab 100644 --- a/libmaple/usb/usb.c +++ b/libmaple/usb/usb.c @@ -25,8 +25,10 @@ *****************************************************************************/ /** - * @file usb.c + * @file libmaple/usb/usb.c * @brief USB support. + * + * This is a mess. What we need almost amounts to a ground-up rewrite. */ #include diff --git a/libmaple/usb/usb_cdcacm.c b/libmaple/usb/usb_cdcacm.c index 07d2bc8..6ef4806 100644 --- a/libmaple/usb/usb_cdcacm.c +++ b/libmaple/usb/usb_cdcacm.c @@ -25,10 +25,12 @@ *****************************************************************************/ /** - * @file usb_cdcacm.c + * @file libmaple/usb/usb_cdcacm.c + * @brief USB CDC ACM (a.k.a. virtual serial terminal, VCOM). * - * @brief USB CDC ACM (a.k.a. virtual serial terminal, VCOM) state and - * routines. + * FIXME: this works on the STM32F1 USB peripherals, and probably no + * place else. Nonportable bits really need to be factored out, and + * the result made cleaner. */ #include diff --git a/libmaple/util.c b/libmaple/util.c index 96050a1..ff100fe 100644 --- a/libmaple/util.c +++ b/libmaple/util.c @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file util.c + * @file libmaple/util.c * @brief Utility procedures for debugging, mostly an error LED fade * and messages dumped over a UART for failed asserts. */ diff --git a/wirish/HardwareSerial.cpp b/wirish/HardwareSerial.cpp index a9eb763..0f12e72 100644 --- a/wirish/HardwareSerial.cpp +++ b/wirish/HardwareSerial.cpp @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file HardwareSerial.cpp + * @file wirish/HardwareSerial.cpp * @brief Wirish serial port implementation. */ diff --git a/wirish/boards.cpp b/wirish/boards.cpp index 54807d3..51ff50e 100644 --- a/wirish/boards.cpp +++ b/wirish/boards.cpp @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file boards.cpp + * @file wirish/boards.cpp * @brief Generic board routines. * * This file is mostly interesting for the init() function, which diff --git a/wirish/ext_interrupts.cpp b/wirish/ext_interrupts.cpp index 8f8c768..a4a27c2 100644 --- a/wirish/ext_interrupts.cpp +++ b/wirish/ext_interrupts.cpp @@ -25,9 +25,8 @@ *****************************************************************************/ /** - * @file ext_interrupts.c - * - * @brief Wiring-like interface for external interrupts + * @file wirish/ext_interrupts.c + * @brief Wiring-like interface for external interrupts */ #include diff --git a/wirish/include/wirish/HardwareSPI.h b/wirish/include/wirish/HardwareSPI.h index ad95191..89cf166 100644 --- a/wirish/include/wirish/HardwareSPI.h +++ b/wirish/include/wirish/HardwareSPI.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file HardwareSPI.h + * @file wirish/include/wirish/HardwareSPI.h * @brief High-level SPI interface * * This is a "bare essentials" polling driver for now. diff --git a/wirish/include/wirish/HardwareSerial.h b/wirish/include/wirish/HardwareSerial.h index c25fd6e..1eaacb6 100644 --- a/wirish/include/wirish/HardwareSerial.h +++ b/wirish/include/wirish/HardwareSerial.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file HardwareSerial.h + * @file wirish/include/wirish/HardwareSerial.h * @brief Wirish serial port interface. */ diff --git a/wirish/include/wirish/boards.h b/wirish/include/wirish/boards.h index c762542..3c2740a 100644 --- a/wirish/include/wirish/boards.h +++ b/wirish/include/wirish/boards.h @@ -25,10 +25,10 @@ *****************************************************************************/ /** - * @file boards.h + * @file wirish/include/wirish/boards.h * @author Bryan Newbold , * Marti Bolivar - * @brief Board-specific pin information. + * @brief init() and board-specific pin information. */ #ifndef _WIRISH_BOARDS_H_ diff --git a/wirish/include/wirish/ext_interrupts.h b/wirish/include/wirish/ext_interrupts.h index 617e43d..03b8e97 100644 --- a/wirish/include/wirish/ext_interrupts.h +++ b/wirish/include/wirish/ext_interrupts.h @@ -25,9 +25,8 @@ *****************************************************************************/ /** - * @file ext_interrupts.h - * - * @brief Wiring-like external interrupt prototypes and types. + * @file wirish/include/wirish/ext_interrupts.h + * @brief Wiring-like external interrupt prototypes and types. */ #ifndef _WIRISH_EXT_INTERRUPTS_H_ diff --git a/wirish/include/wirish/io.h b/wirish/include/wirish/io.h index de56a49..b5fe3a8 100644 --- a/wirish/include/wirish/io.h +++ b/wirish/include/wirish/io.h @@ -25,9 +25,8 @@ *****************************************************************************/ /** - * @file io.h - * - * @brief Arduino-compatible digital pin I/O interface. + * @file wirish/include/wirish/io.h + * @brief Wiring-style pin I/O interface. */ #ifndef _WIRISH_IO_H_ diff --git a/wirish/include/wirish/pwm.h b/wirish/include/wirish/pwm.h index e7130fb..6631d42 100644 --- a/wirish/include/wirish/pwm.h +++ b/wirish/include/wirish/pwm.h @@ -25,9 +25,8 @@ *****************************************************************************/ /** - * @file pwm.h - * - * @brief Arduino-compatible PWM interface. + * @file wirish/include/wirish/pwm.h + * @brief Wiring-style PWM interface. */ #ifndef _WIRISH_PWM_H_ diff --git a/wirish/include/wirish/wirish_debug.h b/wirish/include/wirish/wirish_debug.h index c8bc077..cb1be3d 100644 --- a/wirish/include/wirish/wirish_debug.h +++ b/wirish/include/wirish/wirish_debug.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file wirish_debug.h + * @file wirish/include/wirish/wirish_debug.h * @brief High level debug port configuration */ diff --git a/wirish/include/wirish/wirish_math.h b/wirish/include/wirish/wirish_math.h index 3820cab..39f16a0 100644 --- a/wirish/include/wirish/wirish_math.h +++ b/wirish/include/wirish/wirish_math.h @@ -25,8 +25,8 @@ *****************************************************************************/ /** - * @file wirish_math.h - * @brief Includes ; provides Arduino-compatible math routines. + * @file wirish/include/wirish/wirish_math.h + * @brief Includes ; provides Wiring-compatible math routines. */ #ifndef _WIRISH_WIRISH_MATH_H_ diff --git a/wirish/include/wirish/wirish_time.h b/wirish/include/wirish/wirish_time.h index a81075c..1520b1e 100644 --- a/wirish/include/wirish/wirish_time.h +++ b/wirish/include/wirish/wirish_time.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file wirish_time.h + * @file wirish/include/wirish/wirish_time.h * @brief Timing and delay functions. */ diff --git a/wirish/include/wirish/wirish_types.h b/wirish/include/wirish/wirish_types.h index d70b26f..fce895e 100644 --- a/wirish/include/wirish/wirish_types.h +++ b/wirish/include/wirish/wirish_types.h @@ -25,7 +25,7 @@ *****************************************************************************/ /** - * @file wirish_types.h + * @file wirish/include/wirish/wirish_types.h * @author Marti Bolivar * @brief Wirish library type definitions. */ -- cgit v1.2.3 From d483f8fa0c7c1f65c926b24d6c66275953d03c4f Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Fri, 1 Jun 2012 01:10:47 -0400 Subject: Bring back HardwareSerial. To make this happen, we need to have tell us whether or not it's got each of the USARTs. Do that with BOARD_HAVE_USARTn, for n = 1,...,6. This lets us define HardwareSerial instances only when appropriate, and gets rid of some board-specific hacks we'd accumulated. The new now has a convenience function for determining the bus rate by using the appropriate STM32_PCLKx macro, so we can shave a uint32 per instance, which is nice given that they're all going to be in memory. This changes the constructor arguments, but the API only specifies the semantics of the predefined instances, so this is still backwards-compatible. (We should look into storing the instances in Flash -- they don't change, after all.) We don't actually need struct usart_dev's definition in HardwareSerial.h, so replace it with a forward declaration and include it in HardwareSerial.cpp instead. Assert some copyrights. Signed-off-by: Marti Bolivar --- libmaple/include/libmaple/usart.h | 1 + wirish/HardwareSerial.cpp | 98 ++++++++++++---------- wirish/boards/VLDiscovery/include/board/board.h | 6 ++ wirish/boards/maple/include/board/board.h | 9 +- wirish/boards/maple_RET6/include/board/board.h | 11 ++- wirish/boards/maple_mini/include/board/board.h | 6 ++ wirish/boards/maple_native/include/board/board.h | 6 ++ .../boards/olimex_stm32_h103/include/board/board.h | 6 ++ .../boards/st_stm3220g_eval/include/board/board.h | 12 ++- wirish/include/wirish/HardwareSerial.h | 26 ++++-- wirish/rules.mk | 2 +- 11 files changed, 127 insertions(+), 56 deletions(-) (limited to 'wirish/HardwareSerial.cpp') diff --git a/libmaple/include/libmaple/usart.h b/libmaple/include/libmaple/usart.h index ad7eb51..293d59e 100644 --- a/libmaple/include/libmaple/usart.h +++ b/libmaple/include/libmaple/usart.h @@ -395,6 +395,7 @@ typedef struct usart_dev { void usart_init(usart_dev *dev); +/* FIXME document this function */ struct gpio_dev; /* forward declaration */ void usart_async_gpio_cfg(usart_dev *udev, struct gpio_dev *rx_dev, uint8 rx, diff --git a/wirish/HardwareSerial.cpp b/wirish/HardwareSerial.cpp index 0f12e72..3f418e2 100644 --- a/wirish/HardwareSerial.cpp +++ b/wirish/HardwareSerial.cpp @@ -2,6 +2,7 @@ * The MIT License * * Copyright (c) 2010 Perry Hung. + * Copyright (c) 2011, 2012 LeafLabs, LLC. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -34,36 +35,36 @@ #include #include #include +#include -#include - -#define TX1 BOARD_USART1_TX_PIN -#define RX1 BOARD_USART1_RX_PIN -#define TX2 BOARD_USART2_TX_PIN -#define RX2 BOARD_USART2_RX_PIN -#define TX3 BOARD_USART3_TX_PIN -#define RX3 BOARD_USART3_RX_PIN -#if defined STM32_HIGH_DENSITY && !defined(BOARD_maple_RET6) -#define TX4 BOARD_UART4_TX_PIN -#define RX4 BOARD_UART4_RX_PIN -#define TX5 BOARD_UART5_TX_PIN -#define RX5 BOARD_UART5_RX_PIN -#endif +#define DEFINE_HWSERIAL(name, n) \ + HardwareSerial name(USART##n, \ + BOARD_USART##n##_TX_PIN, \ + BOARD_USART##n##_RX_PIN) -HardwareSerial Serial1(USART1, TX1, RX1, STM32_PCLK2); -HardwareSerial Serial2(USART2, TX2, RX2, STM32_PCLK1); -HardwareSerial Serial3(USART3, TX3, RX3, STM32_PCLK1); -#if defined(STM32_HIGH_DENSITY) && !defined(BOARD_maple_RET6) -HardwareSerial Serial4(UART4, TX4, RX4, STM32_PCLK1); -HardwareSerial Serial5(UART5, TX5, RX5, STM32_PCLK1); +#if BOARD_HAVE_USART1 +DEFINE_HWSERIAL(Serial1, 1); +#endif +#if BOARD_HAVE_USART2 +DEFINE_HWSERIAL(Serial2, 2); +#endif +#if BOARD_HAVE_USART3 +DEFINE_HWSERIAL(Serial3, 3); +#endif +#if BOARD_HAVE_UART4 +DEFINE_HWSERIAL(Serial4, 4); +#endif +#if BOARD_HAVE_UART5 +DEFINE_HWSERIAL(Serial5, 5); +#endif +#if BOARD_HAVE_USART6 +DEFINE_HWSERIAL(Serial6, 6); #endif HardwareSerial::HardwareSerial(usart_dev *usart_device, uint8 tx_pin, - uint8 rx_pin, - uint32 clock_speed) { + uint8 rx_pin) { this->usart_device = usart_device; - this->clock_speed = clock_speed; this->tx_pin = tx_pin; this->rx_pin = rx_pin; } @@ -72,31 +73,44 @@ HardwareSerial::HardwareSerial(usart_dev *usart_device, * Set up/tear down */ +#if STM32_MCU_SERIES == STM32_SERIES_F1 +/* F1 MCUs have no GPIO_AFR[HL], so turn off PWM if there's a conflict + * on this GPIO bit. */ +static void disable_timer_if_necessary(timer_dev *dev, uint8 ch) { + if (txi->timer_device != NULL) { + timer_set_mode(txi->timer_device, txi->timer_channel, TIMER_DISABLED); + } +} +#elif (STM32_MCU_SERIES == STM32_SERIES_F2) || \ + (STM32_MCU_SERIES == STM32_SERIES_F4) +#define disable_timer_if_necessary(dev, ch) ((void)0) +#else +#warn "Unsupported STM32 series; timer conflicts are possible" +#endif + void HardwareSerial::begin(uint32 baud) { - ASSERT(baud <= usart_device->max_baud); + ASSERT(baud <= this->usart_device->max_baud); - if (baud > usart_device->max_baud) { + if (baud > this->usart_device->max_baud) { return; } - const stm32_pin_info *txi = &PIN_MAP[tx_pin]; - const stm32_pin_info *rxi = &PIN_MAP[rx_pin]; + const stm32_pin_info *txi = &PIN_MAP[this->tx_pin]; + const stm32_pin_info *rxi = &PIN_MAP[this->rx_pin]; - gpio_set_mode(txi->gpio_device, txi->gpio_bit, GPIO_AF_OUTPUT_PP); - gpio_set_mode(rxi->gpio_device, rxi->gpio_bit, GPIO_INPUT_FLOATING); - - if (txi->timer_device != NULL) { - /* Turn off any PWM if there's a conflict on this GPIO bit. */ - timer_set_mode(txi->timer_device, txi->timer_channel, TIMER_DISABLED); - } + disable_timer_if_necessary(txi->timer_device, txi->timer_channel); - usart_init(usart_device); - usart_set_baud_rate(usart_device, clock_speed, baud); - usart_enable(usart_device); + usart_async_gpio_cfg(this->usart_device, + rxi->gpio_device, rxi->gpio_bit, + txi->gpio_device, txi->gpio_bit, + 0); + usart_init(this->usart_device); + usart_set_baud_rate(this->usart_device, USART_USE_PCLK, baud); + usart_enable(this->usart_device); } void HardwareSerial::end(void) { - usart_disable(usart_device); + usart_disable(this->usart_device); } /* @@ -104,17 +118,17 @@ void HardwareSerial::end(void) { */ uint8 HardwareSerial::read(void) { - return usart_getc(usart_device); + return usart_getc(this->usart_device); } uint32 HardwareSerial::available(void) { - return usart_data_available(usart_device); + return usart_data_available(this->usart_device); } void HardwareSerial::write(unsigned char ch) { - usart_putc(usart_device, ch); + usart_putc(this->usart_device, ch); } void HardwareSerial::flush(void) { - usart_reset_rx(usart_device); + usart_reset_rx(this->usart_device); } diff --git a/wirish/boards/VLDiscovery/include/board/board.h b/wirish/boards/VLDiscovery/include/board/board.h index 04d21c7..c54abc1 100644 --- a/wirish/boards/VLDiscovery/include/board/board.h +++ b/wirish/boards/VLDiscovery/include/board/board.h @@ -45,6 +45,12 @@ /* Number of USARTs/UARTs whose pins are broken out to headers */ #define BOARD_NR_USARTS 3 +#define BOARD_HAVE_USART1 1 +#define BOARD_HAVE_USART2 1 +#define BOARD_HAVE_USART3 1 +#define BOARD_HAVE_UART4 0 +#define BOARD_HAVE_UART5 0 +#define BOARD_HAVE_USART6 0 /* Default USART pin numbers (not considering AFIO remap) */ #define BOARD_USART1_TX_PIN 7 diff --git a/wirish/boards/maple/include/board/board.h b/wirish/boards/maple/include/board/board.h index 49f5b9a..ed89fee 100644 --- a/wirish/boards/maple/include/board/board.h +++ b/wirish/boards/maple/include/board/board.h @@ -39,8 +39,15 @@ #define BOARD_BUTTON_PIN 38 #define BOARD_LED_PIN 13 -/* Number of USARTs/UARTs whose pins are broken out to headers */ +/* Number of USARTs/UARTs whose pins are broken out to headers, and + * macros saying which ones they are. */ #define BOARD_NR_USARTS 3 +#define BOARD_HAVE_USART1 1 +#define BOARD_HAVE_USART2 1 +#define BOARD_HAVE_USART3 1 +#define BOARD_HAVE_UART4 0 +#define BOARD_HAVE_UART5 0 +#define BOARD_HAVE_USART6 0 /* Default USART pin numbers (not considering AFIO remap) */ #define BOARD_USART1_TX_PIN 7 diff --git a/wirish/boards/maple_RET6/include/board/board.h b/wirish/boards/maple_RET6/include/board/board.h index 1a0365a..3291498 100644 --- a/wirish/boards/maple_RET6/include/board/board.h +++ b/wirish/boards/maple_RET6/include/board/board.h @@ -36,17 +36,20 @@ #ifndef _BOARDS_MAPLE_RET6_H_ #define _BOARDS_MAPLE_RET6_H_ -/* A few of these values will seem strange given that it's a - * high-density board. */ - #define CYCLES_PER_MICROSECOND 72 #define SYSTICK_RELOAD_VAL 71999 /* takes a cycle to reload */ #define BOARD_BUTTON_PIN 38 #define BOARD_LED_PIN 13 -/* Note: UART4 and UART5 have pins which aren't broken out :( */ +/* UART4 and UART5 have pins which aren't broken out :( */ #define BOARD_NR_USARTS 3 +#define BOARD_HAVE_USART1 1 +#define BOARD_HAVE_USART2 1 +#define BOARD_HAVE_USART3 1 +#define BOARD_HAVE_UART4 0 +#define BOARD_HAVE_UART5 0 +#define BOARD_HAVE_USART6 0 #define BOARD_USART1_TX_PIN 7 #define BOARD_USART1_RX_PIN 8 #define BOARD_USART2_TX_PIN 1 diff --git a/wirish/boards/maple_mini/include/board/board.h b/wirish/boards/maple_mini/include/board/board.h index bfba46d..8ba91ce 100644 --- a/wirish/boards/maple_mini/include/board/board.h +++ b/wirish/boards/maple_mini/include/board/board.h @@ -43,6 +43,12 @@ #define BOARD_LED_PIN 33 #define BOARD_NR_USARTS 3 +#define BOARD_HAVE_USART1 1 +#define BOARD_HAVE_USART2 1 +#define BOARD_HAVE_USART3 1 +#define BOARD_HAVE_UART4 0 +#define BOARD_HAVE_UART5 0 +#define BOARD_HAVE_USART6 0 #define BOARD_USART1_TX_PIN 26 #define BOARD_USART1_RX_PIN 25 #define BOARD_USART2_TX_PIN 9 diff --git a/wirish/boards/maple_native/include/board/board.h b/wirish/boards/maple_native/include/board/board.h index 397afaf..a4f8896 100644 --- a/wirish/boards/maple_native/include/board/board.h +++ b/wirish/boards/maple_native/include/board/board.h @@ -43,6 +43,12 @@ #define BOARD_BUTTON_PIN 6 #define BOARD_NR_USARTS 5 +#define BOARD_HAVE_USART1 1 +#define BOARD_HAVE_USART2 1 +#define BOARD_HAVE_USART3 1 +#define BOARD_HAVE_UART4 1 +#define BOARD_HAVE_UART5 1 +#define BOARD_HAVE_USART6 0 #define BOARD_USART1_TX_PIN 24 #define BOARD_USART1_RX_PIN 25 #define BOARD_USART2_TX_PIN 50 diff --git a/wirish/boards/olimex_stm32_h103/include/board/board.h b/wirish/boards/olimex_stm32_h103/include/board/board.h index b312e26..46367ac 100644 --- a/wirish/boards/olimex_stm32_h103/include/board/board.h +++ b/wirish/boards/olimex_stm32_h103/include/board/board.h @@ -42,6 +42,12 @@ /* Number of USARTs/UARTs whose pins are broken out to headers */ #define BOARD_NR_USARTS 3 +#define BOARD_HAVE_USART1 1 +#define BOARD_HAVE_USART2 1 +#define BOARD_HAVE_USART3 1 +#define BOARD_HAVE_UART4 0 +#define BOARD_HAVE_UART5 0 +#define BOARD_HAVE_USART6 0 /* Default USART pin numbers (not considering AFIO remap) */ #define BOARD_USART1_TX_PIN 3 diff --git a/wirish/boards/st_stm3220g_eval/include/board/board.h b/wirish/boards/st_stm3220g_eval/include/board/board.h index 08b935e..f99a585 100644 --- a/wirish/boards/st_stm3220g_eval/include/board/board.h +++ b/wirish/boards/st_stm3220g_eval/include/board/board.h @@ -27,7 +27,11 @@ /** * @file wirish/boards/st_stm3220g_eval/include/board/board.h * @author Marti Bolivar - * @brief STM3220G-EVAL board header. + * @brief STM3220G-EVAL board stub header. + * + * This (and the corresponding board.cpp) needs to be fixed and + * fleshed out. Do it later? Maybe someone who wants support for this + * board will do it. */ #ifndef _BOARD_ST_STM3220G_EVAL_H_ @@ -40,6 +44,12 @@ #define BOARD_LED_PIN 0 #define BOARD_NR_USARTS 0 +#define BOARD_HAVE_USART1 0 +#define BOARD_HAVE_USART2 0 +#define BOARD_HAVE_USART3 0 +#define BOARD_HAVE_UART4 0 +#define BOARD_HAVE_UART5 0 +#define BOARD_HAVE_USART6 0 #define BOARD_NR_SPI 0 #define BOARD_NR_GPIO_PINS 6 #define BOARD_NR_PWM_PINS 0 diff --git a/wirish/include/wirish/HardwareSerial.h b/wirish/include/wirish/HardwareSerial.h index 1eaacb6..2b1e747 100644 --- a/wirish/include/wirish/HardwareSerial.h +++ b/wirish/include/wirish/HardwareSerial.h @@ -2,6 +2,7 @@ * The MIT License * * Copyright (c) 2010 Perry Hung. + * Copyright (c) 2011, 2012 LeafLabs, LLC. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -33,9 +34,9 @@ #define _WIRISH_HARDWARESERIAL_H_ #include -#include #include +#include /* * IMPORTANT: @@ -47,12 +48,13 @@ * the documentation accordingly. */ +struct usart_dev; + class HardwareSerial : public Print { public: - HardwareSerial(usart_dev *usart_device, + HardwareSerial(struct usart_dev *usart_device, uint8 tx_pin, - uint8 rx_pin, - uint32 clock_speed); + uint8 rx_pin); /* Set up/tear down */ void begin(uint32 baud); @@ -69,18 +71,28 @@ public: int txPin(void) { return this->tx_pin; } int rxPin(void) { return this->rx_pin; } private: - usart_dev *usart_device; + struct usart_dev *usart_device; uint8 tx_pin; uint8 rx_pin; - uint32 clock_speed; }; +#if BOARD_HAVE_USART1 extern HardwareSerial Serial1; +#endif +#if BOARD_HAVE_USART2 extern HardwareSerial Serial2; +#endif +#if BOARD_HAVE_USART3 extern HardwareSerial Serial3; -#if defined(STM32_HIGH_DENSITY) && !defined(BOARD_maple_RET6) +#endif +#if BOARD_HAVE_UART4 extern HardwareSerial Serial4; +#endif +#if BOARD_HAVE_UART5 extern HardwareSerial Serial5; #endif +#if BOARD_HAVE_USART6 +extern HardwareSerial Serial6; +#endif #endif diff --git a/wirish/rules.mk b/wirish/rules.mk index 903c817..4084448 100644 --- a/wirish/rules.mk +++ b/wirish/rules.mk @@ -22,6 +22,7 @@ sSRCS_$(d) := start.S cSRCS_$(d) := start_c.c cppSRCS_$(d) := boards.cpp cppSRCS_$(d) += cxxabi-compat.cpp +cppSRCS_$(d) += HardwareSerial.cpp cppSRCS_$(d) += Print.cpp cppSRCS_$(d) += wirish_digital.cpp cppSRCS_$(d) += wirish_math.cpp @@ -31,7 +32,6 @@ cppSRCS_$(d) += $(MCU_SERIES)/boards_setup.cpp cppSRCS_$(d) += $(MCU_SERIES)/wirish_digital.cpp cppSRCS_$(d) += $(WIRISH_BOARD_PATH)/board.cpp # TODO: revise these appropriately F2 and put them back in: -# HardwareSerial.cpp # HardwareSPI.cpp # HardwareTimer.cpp # usb_serial.cpp -- cgit v1.2.3 From 33b972e7e214e291bd62f83a0621fb87c267a9de Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Sat, 2 Jun 2012 19:39:47 -0400 Subject: Oops; don't break the build on F1. That was dumb. Signed-off-by: Marti Bolivar --- libmaple/stm32f1/include/series/stm32.h | 1 - wirish/HardwareSerial.cpp | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'wirish/HardwareSerial.cpp') diff --git a/libmaple/stm32f1/include/series/stm32.h b/libmaple/stm32f1/include/series/stm32.h index 59205c3..23c0591 100644 --- a/libmaple/stm32f1/include/series/stm32.h +++ b/libmaple/stm32f1/include/series/stm32.h @@ -119,7 +119,6 @@ extern "C" { # define STM32_NR_INTERRUPTS 60 # define STM32_TIMER_MASK 0x1FE /* TIMER1--TIMER8 */ # define STM32_HAVE_FSMC 1 -# endif # elif defined(STM32_XL_DENSITY) # define STM32_NR_INTERRUPTS 60 # define STM32_TIMER_MASK 0x7FFE /* TIMER1--TIMER14 */ diff --git a/wirish/HardwareSerial.cpp b/wirish/HardwareSerial.cpp index 3f418e2..75f5bbb 100644 --- a/wirish/HardwareSerial.cpp +++ b/wirish/HardwareSerial.cpp @@ -77,8 +77,8 @@ HardwareSerial::HardwareSerial(usart_dev *usart_device, /* F1 MCUs have no GPIO_AFR[HL], so turn off PWM if there's a conflict * on this GPIO bit. */ static void disable_timer_if_necessary(timer_dev *dev, uint8 ch) { - if (txi->timer_device != NULL) { - timer_set_mode(txi->timer_device, txi->timer_channel, TIMER_DISABLED); + if (dev != NULL) { + timer_set_mode(dev, ch, TIMER_DISABLED); } } #elif (STM32_MCU_SERIES == STM32_SERIES_F2) || \ -- cgit v1.2.3 From f5c37f28fd9be3bd8e2c7159a09891d5e571bc43 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Sun, 3 Jun 2012 02:11:07 -0400 Subject: Globally switch style for GPIO config routines. Stupidly, spi_gpio_cfg() didn't take a spi_dev* argument on F1, because it doesn't matter there. On F2, where we need to set an alternate function when configuring GPIOs for SPI, we need to know the dev. We can't add break backwards compatibility, so we need a new function. However, we've since added a bunch of foo_gpio_cfg() routines, and we don't want confusing asymmetry in the names. So a global style change is needed. (Fortunately, the new functions weren't part of a release, so it's no problem to change their names). Change all foo_gpio_cfg() routines to foo_config_gpios() (or foo_config_gpio(), if there's only one GPIO to configure). For backwards compatibility, make spi_gpio_cfg() on F1 an __always_inline call to spi_config_gpios(). Signed-off-by: Marti Bolivar --- examples/test-timers.cpp | 2 +- libmaple/include/libmaple/adc.h | 6 +++++- libmaple/include/libmaple/spi.h | 15 ++++++++------- libmaple/include/libmaple/usart.h | 19 ++++++++++++++----- libmaple/stm32f1/adc.c | 2 +- libmaple/stm32f1/include/series/spi.h | 32 ++++++++++++++++++++++++++++++++ libmaple/stm32f1/spi.c | 15 ++++++++------- libmaple/stm32f1/usart.c | 8 ++++---- libmaple/stm32f2/adc.c | 2 +- libmaple/stm32f2/usart.c | 8 ++++---- wirish/HardwareSPI.cpp | 10 +++------- wirish/HardwareSerial.cpp | 8 ++++---- 12 files changed, 85 insertions(+), 42 deletions(-) (limited to 'wirish/HardwareSerial.cpp') diff --git a/examples/test-timers.cpp b/examples/test-timers.cpp index 1f376b7..e646916 100644 --- a/examples/test-timers.cpp +++ b/examples/test-timers.cpp @@ -389,7 +389,7 @@ static void _delay(uint32 msec) { } static void init_usart(usart_dev *dev, gpio_dev *gdev, uint8 tx, uint8 rx) { - usart_async_gpio_cfg(dev, gdev, rx, gdev, tx, 0); + usart_config_gpios_async(dev, gdev, rx, gdev, tx, 0); usart_init(dev); usart_set_baud_rate(dev, USART_USE_PCLK, COMM_USART_BAUD); usart_enable(dev); diff --git a/libmaple/include/libmaple/adc.h b/libmaple/include/libmaple/adc.h index ff9a5e4..a500af7 100644 --- a/libmaple/include/libmaple/adc.h +++ b/libmaple/include/libmaple/adc.h @@ -262,10 +262,14 @@ extern void adc_foreach(void (*fn)(const adc_dev*)); struct gpio_dev; /** * @brief Configure a GPIO pin for ADC conversion. + * @param dev ADC device to use for conversion (currently ignored on + * all targets). * @param gdev GPIO device to configure. * @param bit Bit on gdev to configure for ADC conversion. */ -extern void adc_gpio_cfg(struct gpio_dev *gdev, uint8 bit); +extern void adc_config_gpio(const struct adc_dev *dev, + struct gpio_dev *gdev, + uint8 bit); /** * @brief Enable an ADC and configure it for single conversion mode. diff --git a/libmaple/include/libmaple/spi.h b/libmaple/include/libmaple/spi.h index 3805b2e..90e2036 100644 --- a/libmaple/include/libmaple/spi.h +++ b/libmaple/include/libmaple/spi.h @@ -224,13 +224,14 @@ struct gpio_dev; * @param miso_bit MISO pin's GPIO bit on comm_dev * @param mosi_bit MOSI pin's GPIO bit on comm_dev */ -void spi_gpio_cfg(uint8 as_master, - struct gpio_dev *nss_dev, - uint8 nss_bit, - struct gpio_dev *comm_dev, - uint8 sck_bit, - uint8 miso_bit, - uint8 mosi_bit); +extern void spi_config_gpios(spi_dev *dev, + uint8 as_master, + struct gpio_dev *nss_dev, + uint8 nss_bit, + struct gpio_dev *comm_dev, + uint8 sck_bit, + uint8 miso_bit, + uint8 mosi_bit); /** * @brief SPI mode configuration. diff --git a/libmaple/include/libmaple/usart.h b/libmaple/include/libmaple/usart.h index 293d59e..26a64d3 100644 --- a/libmaple/include/libmaple/usart.h +++ b/libmaple/include/libmaple/usart.h @@ -395,12 +395,21 @@ typedef struct usart_dev { void usart_init(usart_dev *dev); -/* FIXME document this function */ struct gpio_dev; /* forward declaration */ -void usart_async_gpio_cfg(usart_dev *udev, - struct gpio_dev *rx_dev, uint8 rx, - struct gpio_dev *tx_dev, uint8 tx, - unsigned flags); +/* FIXME [PRE 0.0.13] decide if flags are necessary */ +/** + * @brief Configure GPIOs for use as USART TX/RX. + * @param udev USART device to use + * @param rx_dev RX pin gpio_dev + * @param rx RX pin bit on rx_dev + * @param tx_dev TX pin gpio_dev + * @param tx TX pin bit on tx_dev + * @param flags Currently ignored + */ +extern void usart_config_gpios_async(usart_dev *udev, + struct gpio_dev *rx_dev, uint8 rx, + struct gpio_dev *tx_dev, uint8 tx, + unsigned flags); #define USART_USE_PCLK 0 void usart_set_baud_rate(usart_dev *dev, uint32 clock_speed, uint32 baud); diff --git a/libmaple/stm32f1/adc.c b/libmaple/stm32f1/adc.c index facc6bd..ecfbc1c 100644 --- a/libmaple/stm32f1/adc.c +++ b/libmaple/stm32f1/adc.c @@ -99,7 +99,7 @@ void adc_foreach(void (*fn)(const adc_dev*)) { #endif } -void adc_gpio_cfg(gpio_dev *gdev, uint8 bit) { +void adc_config_gpio(const adc_dev *ignored, gpio_dev *gdev, uint8 bit) { gpio_set_mode(gdev, bit, GPIO_INPUT_ANALOG); } diff --git a/libmaple/stm32f1/include/series/spi.h b/libmaple/stm32f1/include/series/spi.h index 167df0c..8cc4c4d 100644 --- a/libmaple/stm32f1/include/series/spi.h +++ b/libmaple/stm32f1/include/series/spi.h @@ -34,6 +34,8 @@ #ifndef _LIBMAPLE_STM32F1_SPI_H_ #define _LIBMAPLE_STM32F1_SPI_H_ +#include + #ifdef __cplusplus extern "C" { #endif @@ -63,6 +65,36 @@ extern struct spi_dev *SPI2; extern struct spi_dev *SPI3; #endif +/* + * Routines + */ + +/* spi_gpio_cfg(): Backwards compatibility shim to spi_config_gpios() */ +struct gpio_dev; +extern void spi_config_gpios(struct spi_dev*, uint8, + struct gpio_dev*, uint8, + struct gpio_dev*, uint8, uint8, uint8); +/** + * @brief Deprecated. Use spi_config_gpios() instead. + * @see spi_config_gpios() + */ +static __always_inline void spi_gpio_cfg(uint8 as_master, + struct gpio_dev *nss_dev, + uint8 nss_bit, + struct gpio_dev *comm_dev, + uint8 sck_bit, + uint8 miso_bit, + uint8 mosi_bit) { + /* We switched style globally to foo_config_gpios() and always + * taking a foo_dev* argument (that last bit is the important + * part) after this function was written. + * + * However, spi_config_gpios() just ignores the spi_dev* on F1, so + * we can still keep this around for older code. */ + spi_config_gpios(NULL, as_master, nss_dev, nss_bit, + comm_dev, sck_bit, miso_bit, mosi_bit); +} + #ifdef __cplusplus } #endif diff --git a/libmaple/stm32f1/spi.c b/libmaple/stm32f1/spi.c index 8b6e495..72f2ef4 100644 --- a/libmaple/stm32f1/spi.c +++ b/libmaple/stm32f1/spi.c @@ -69,13 +69,14 @@ spi_dev *SPI3 = &spi3; * Routines */ -void spi_gpio_cfg(uint8 as_master, - gpio_dev *nss_dev, - uint8 nss_bit, - gpio_dev *comm_dev, - uint8 sck_bit, - uint8 miso_bit, - uint8 mosi_bit) { +void spi_config_gpios(spi_dev *ignored, + uint8 as_master, + gpio_dev *nss_dev, + uint8 nss_bit, + gpio_dev *comm_dev, + uint8 sck_bit, + uint8 miso_bit, + uint8 mosi_bit) { if (as_master) { gpio_set_mode(nss_dev, nss_bit, GPIO_AF_OUTPUT_PP); gpio_set_mode(comm_dev, sck_bit, GPIO_AF_OUTPUT_PP); diff --git a/libmaple/stm32f1/usart.c b/libmaple/stm32f1/usart.c index eed420e..b3b849f 100644 --- a/libmaple/stm32f1/usart.c +++ b/libmaple/stm32f1/usart.c @@ -101,10 +101,10 @@ usart_dev *UART5 = &uart5; * Routines */ -void usart_async_gpio_cfg(usart_dev *udev, - gpio_dev *rx_dev, uint8 rx, - gpio_dev *tx_dev, uint8 tx, - unsigned flags) { +void usart_config_gpios_async(usart_dev *udev, + gpio_dev *rx_dev, uint8 rx, + gpio_dev *tx_dev, uint8 tx, + unsigned flags) { gpio_set_mode(rx_dev, rx, GPIO_INPUT_FLOATING); gpio_set_mode(tx_dev, tx, GPIO_AF_OUTPUT_PP); } diff --git a/libmaple/stm32f2/adc.c b/libmaple/stm32f2/adc.c index 0380736..a400d7b 100644 --- a/libmaple/stm32f2/adc.c +++ b/libmaple/stm32f2/adc.c @@ -74,7 +74,7 @@ void adc_foreach(void (*fn)(const adc_dev*)) { fn(ADC3); } -void adc_gpio_cfg(gpio_dev *gdev, uint8 bit) { +void adc_config_gpio(const adc_dev *ignored, gpio_dev *gdev, uint8 bit) { gpio_set_modef(gdev, bit, GPIO_MODE_ANALOG, GPIO_MODEF_PUPD_NONE); } diff --git a/libmaple/stm32f2/usart.c b/libmaple/stm32f2/usart.c index 2dd3afc..9a1acf3 100644 --- a/libmaple/stm32f2/usart.c +++ b/libmaple/stm32f2/usart.c @@ -107,10 +107,10 @@ usart_dev *USART6 = &usart6; * Routines */ -void usart_async_gpio_cfg(usart_dev *udev, - gpio_dev *rx_dev, uint8 rx, - gpio_dev *tx_dev, uint8 tx, - unsigned flags) { +void usart_config_gpios_async(usart_dev *udev, + gpio_dev *rx_dev, uint8 rx, + gpio_dev *tx_dev, uint8 tx, + unsigned flags) { gpio_af af; /* TODO: break this out into a user-facing function. */ switch (udev->clk_id) { diff --git a/wirish/HardwareSPI.cpp b/wirish/HardwareSPI.cpp index e1f186e..120cd67 100644 --- a/wirish/HardwareSPI.cpp +++ b/wirish/HardwareSPI.cpp @@ -283,13 +283,9 @@ static void configure_gpios(spi_dev *dev, bool as_master) { disable_pwm(misoi); disable_pwm(mosii); - spi_gpio_cfg(as_master, - nssi->gpio_device, - nssi->gpio_bit, - scki->gpio_device, - scki->gpio_bit, - misoi->gpio_bit, - mosii->gpio_bit); + spi_config_gpios(dev, as_master, nssi->gpio_device, nssi->gpio_bit, + scki->gpio_device, scki->gpio_bit, misoi->gpio_bit, + mosii->gpio_bit); } static const spi_baud_rate baud_rates[MAX_SPI_FREQS] __FLASH__ = { diff --git a/wirish/HardwareSerial.cpp b/wirish/HardwareSerial.cpp index 75f5bbb..7dccccf 100644 --- a/wirish/HardwareSerial.cpp +++ b/wirish/HardwareSerial.cpp @@ -100,10 +100,10 @@ void HardwareSerial::begin(uint32 baud) { disable_timer_if_necessary(txi->timer_device, txi->timer_channel); - usart_async_gpio_cfg(this->usart_device, - rxi->gpio_device, rxi->gpio_bit, - txi->gpio_device, txi->gpio_bit, - 0); + usart_config_gpios_async(this->usart_device, + rxi->gpio_device, rxi->gpio_bit, + txi->gpio_device, txi->gpio_bit, + 0); usart_init(this->usart_device); usart_set_baud_rate(this->usart_device, USART_USE_PCLK, baud); usart_enable(this->usart_device); -- cgit v1.2.3 From 89f375949b3df609b489d14b961940e4fed31038 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Tue, 5 Jun 2012 15:08:35 -0400 Subject: HardwareSerial.cpp: Fix "#warn" -> "#warning". Signed-off-by: Marti Bolivar --- wirish/HardwareSerial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wirish/HardwareSerial.cpp') diff --git a/wirish/HardwareSerial.cpp b/wirish/HardwareSerial.cpp index 7dccccf..e78156d 100644 --- a/wirish/HardwareSerial.cpp +++ b/wirish/HardwareSerial.cpp @@ -85,7 +85,7 @@ static void disable_timer_if_necessary(timer_dev *dev, uint8 ch) { (STM32_MCU_SERIES == STM32_SERIES_F4) #define disable_timer_if_necessary(dev, ch) ((void)0) #else -#warn "Unsupported STM32 series; timer conflicts are possible" +#warning "Unsupported STM32 series; timer conflicts are possible" #endif void HardwareSerial::begin(uint32 baud) { -- cgit v1.2.3