aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple
Commit message (Collapse)AuthorAgeFilesLines
* Slightly improve and generify the USB infrastructure.Marti Bolivar2012-06-039-49/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The good news is that <libmaple/usb.h> and <libmaple/usb_cdcacm.h> did turn out generic enough in what they specify to go on unchanged. However, we can't just go on assuming that there's USB just because we're on an F1. Now that there's value line in the tree, we need to be more careful (value line F1s don't have USB peripherals). To that end, make all the F1 board-includes/*.mk files specify what line their MCU is with an MCU_F1_LINE variable. Use that to hack libmaple/usb/rules.mk so we only try to build the USB module under appropriate circumstances. While we're at it, add a vector_symbols.inc for value line MCUs under support/ld/. We need this to get the target-config.mk modifications implied by the addition of MCU_F1_LINE. We'll fix up some other performance-line-isms under libmaple/stm32f1 in a separate commit. Also in libmaple/usb/: - Move everything into a new stm32f1 directory. Due to aforementioned rules.mk hacks, there is no immediate need for an stm32f2 directory (USB support doesn't exist there). - Update the README for style and content. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple_types.h: Add __unused.Marti Bolivar2012-06-031-0/+1
| | | | | | We'll need this soon. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* F2: Add usart_get_af().Marti Bolivar2012-06-032-17/+30
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Globally switch style for GPIO config routines.Marti Bolivar2012-06-039-30/+77
| | | | | | | | | | | | | | | | | | | | 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 <mbolivar@leaflabs.com>
* STM32F2: Add timer_get_af().Marti Bolivar2012-06-032-0/+52
| | | | | | | | Pull some code out of the F2 pinMode() into a utility function. This feels generally useful enough to be exposed to the users (it will, for example, make it easier to implement input capture in a clean way). Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Add timer_has_cc_channel().Marti Bolivar2012-06-022-0/+29
| | | | | | | | | This is a convenience function for deciding whether a timer supports a particular capture/compare channel. It's necessary because of those nuisance "general purpose" timers that only have a subset of the channels. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Sort the rcc_clk_id enumerators semi-alphabetically.Marti Bolivar2012-06-022-77/+77
| | | | | | | | | | | | | | | | Only semi-alphabetically because peripherals are kept together (so the UARTs sort as if they were USARTs). Advantages: - It lets us play numeric comparison and lookup-table hacks, as we now have the property that the rcc_clk_ids for a given peripheral are a contiguous range of integers. - It will hopefully let the compiler emit faster/smaller code for switches over a dev->clk_id. - It's better intuitively. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Oops; don't break the build on F1.Marti Bolivar2012-06-021-1/+0
| | | | | | That was dumb. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/adc.h: Fixup for Doxygen.Marti Bolivar2012-06-011-1/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/stm32.h: Add STM32_TIMER_MASK, STM32_HAVE_TIMER.Marti Bolivar2012-06-013-4/+48
| | | | | | | | | | | | | | | | | | Feature-test macros for dealing with the fact that timer support has holes. STM32_TIMER_MASK is a bitmask where bit n is set when TIMERn is present. STM32_HAVE_TIMER(n) just tests whether bit n is set in STM32_TIMER_MASK. This is necessary because e.g. the STM32F100RB has timers 1-4, 6, 7, and 15-17. Because of this, the usual STM32_NR_whatever won't work, and we use a bitmask instead. For F1 performance line (F103s), STM32_TIMER_MASK can be derived from the density. For F1 value line, I'm not as sure, so just add it for the single MCU we support (the STM32F100RB). Same story for F2: add it for the STM32F207IC. We can fix this up later if necessary. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* stm32f2/usart.c: Change some FIXMEs to TODOs.Marti Bolivar2012-06-011-6/+7
| | | | | | I think these are probably unchanged, but we need to make sure. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Bring back HardwareSerial.Marti Bolivar2012-06-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | To make this happen, we need to have <board/board.h> 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 <libmaple/usart.h> 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 <libmaple/usart.h> it in HardwareSerial.cpp instead. Assert some copyrights. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* stm32f2/gpio.c: Fix some bugs.Marti Bolivar2012-05-311-3/+3
| | | | | | | Make gpioh.regs actually point to GPIOH_BASE. Properly AND out flag bits in gpio_set_modef(). Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* <libmaple/gpio.h>: Fix gpio_write_bit().Marti Bolivar2012-05-311-1/+1
| | | | | | | It's exactly wrong -- val=0 makes the pin high, and val=1 makes it low. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/usart_private.c: Add missing include.Marti Bolivar2012-05-311-0/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* STM32F1: Fix nvic_irq_disable_all() on some MCUs.Marti Bolivar2012-05-311-8/+6
| | | | | | | | | | The current implementation only disables the first 64 IRQ lines. This covers all the chips we currently support, but it'll be a nasty surprise if anyone decides to add e.g. connectivity line MCUs (which have more IRQs) in the future. We already have the infrastructure to fix it in a clean way, so we might as well do it now. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* nvic.h: Doxygen: nvic_irq_num is target dependent.Marti Bolivar2012-05-312-2/+2
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/nvic.h: Doxygen tweak.sMarti Bolivar2012-05-311-6/+18
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/nvic.h: Fix typo.Marti Bolivar2012-05-311-1/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* stm32f1/rcc.c: Move Doyxgen.Marti Bolivar2012-05-311-10/+1
| | | | | | This is a workaround for Breathe. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* series/rcc.h: Lose BIT().Marti Bolivar2012-05-312-360/+370
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/rcc.c: Fix typo.Marti Bolivar2012-05-311-1/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/rcc.h: Doxygen.Marti Bolivar2012-05-311-1/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* stm32f2/rcc.h: Remove a TODO.Marti Bolivar2012-05-311-7/+0
| | | | | | That never worked out. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* stm32f2/rcc.h: Add FIXME for rcc_rtc_divider.Marti Bolivar2012-05-311-1/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* stm32f2/rcc.h: Fix typo.Marti Bolivar2012-05-311-1/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* stm32f1/rcc.h: Add a FIXME.Marti Bolivar2012-05-311-0/+2
| | | | | | Having a separate struct is stupid. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* RCC: DoxygenMarti Bolivar2012-05-315-138/+105
| | | | | | | Various changes to Doxygen structure, to help leaflabs-docs make sense of everything. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* rcc.c: Fix typo.Marti Bolivar2012-05-311-1/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/rcc.h: Doxygen workarounds.Marti Bolivar2012-05-311-3/+3
| | | | | | | We need the arguments to be the same name everywhere, or Breathe/Doxygen get confused. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/fsmc.h: Better Doxygen for memory bank bases.Marti Bolivar2012-05-311-9/+29
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/fsmc.h: Don't use BIT().Marti Bolivar2012-05-311-23/+23
| | | | | | | As fsmc.h doesn't include util.h or libmaple.h, these usages are actually in error. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* stm32f2/fsmc.c: Cosmetics.Marti Bolivar2012-05-311-1/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/iwdg.h: Remove BIT() usages.Marti Bolivar2012-05-311-3/+2
| | | | | | This cleans up another unnecessary <libmaple/util.h> dependency. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Don't try to build some libmaple files.Marti Bolivar2012-05-311-2/+2
| | | | | | We can't do these on F2 right now. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Lose <libmaple/util.h> dependency in series/flash.h headers.Marti Bolivar2012-05-092-48/+48
| | | | | | Switch from BIT(...) to (1U << ...). Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* flash.h: Doxygen.Marti Bolivar2012-05-093-2/+5
| | | | | | | Document FLASH_BASE once. This is due to restrictions in the documentation build system. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Change __DOXYGEN_PREDEFINED_HACK to __DOXYGEN__.Marti Bolivar2012-05-092-6/+5
| | | | | | avr-gcc does it this way. Seems ok to me. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Make usart_irq() __always_inline.Marti Bolivar2012-05-081-1/+1
| | | | | | | Compiling with -Os can prevent this from inlining, and it's an IRQ handler, so the space is worth spending. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Mark Doxygen for Flash register maps as series-specific.Marti Bolivar2012-05-082-2/+2
| | | | | | | This will let help us verify that we got the right thing when we pull it out of of Doxygen XML for the official HTML documentation. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/util.h: Doxygen cosmetics.Marti Bolivar2012-05-081-1/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/flash.h: Doxygen for flash_enable_features().Marti Bolivar2012-05-081-4/+14
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/flash.h: Deprecate flash_enable_prefetch().Marti Bolivar2012-05-081-0/+3
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/flash.c: Update Doxygen for flash_set_latency().Marti Bolivar2012-05-081-3/+5
| | | | | | Update for STM32F2 support. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Fix a bunch of Doxygen file-level comments.Marti Bolivar2012-05-0865-85/+92
| | | | | | | | | | | | | 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 <mbolivar@leaflabs.com>
* libmaple/flash.h: Fix Doxygen @fileMarti Bolivar2012-05-081-1/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* libmaple/util.h: Doxygen fixups.Marti Bolivar2012-05-081-3/+3
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* ring_buffer.h: Fix Doxygen @file.Marti Bolivar2012-05-081-1/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* stm32f1: stm32.h: Tweak STM32_F1_LINE_xxx for mnemonic value.Marti Bolivar2012-05-081-6/+6
| | | | | | | | | | Change the values of the STM32_F1_LINE_xxx macros to match the part number better (so performance line, or F103s, now have STM32_F1_LINE_PERFORMANCE==3, F100s have STM32_F1_LINE_VALUE==0, etc.). This will hopefully make debugging or error checking easier for someone at some point. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* stm32f1: stm32.h: Doxygen.Marti Bolivar2012-05-081-5/+5
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>