aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Merge branch 'wip-family-support'Marti Bolivar2012-06-26268-5439/+17325
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merge the long-lived (too long; future changes like these will need to proceed more incrementally) development branch of libmaple, containing experimental STM32F2 and STM32F1 value line support, into master. This required many changes to the structure of the library. The most important structural reorganizations occurred in: - 954f9e5: moves public headers to include directories - 3efa313: uses "series" instead of "family" - c0d60e3: adds board files to the build system, to make it easier to add new boards - 096d86c: adds build logic for targeting different STM32 series (e.g. STM32F1, STM32F2) This last commit in particular (096d86c) is the basis for the repartitioning of libmaple into portable sections, which work on all supported MCUs, and nonportable sections, which are segregated into separate directories and contain all series-specific code. Moving existing STM32F1-only code into libmaple/stm32f1 and wirish/stm32f1, along with adding equivalents under .../stm32f2 directories, was the principal project of this branch. Important API changes occur in several places. Existing code is still expected to work on STM32F1 targets, but there have been many deprecations. A detailed changelog explaining the situation needs to be prepared. F2 and F1 value line support is not complete; the merge is proceeding prematurely in this respect. We've been getting more libmaple patches from the community lately, and I'm worried that the merge conflicts with the old tree structure will become painful to manage. Conflicts: Makefile Resolved Makefile conflicts manually; this required propagating -Xlinker usage into support/make/target-config.mk. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * STM32F1: Bring back HardwareSPI.Marti Bolivar2012-06-262-3/+6
| | | | | | | | | | | | We're going to merge into master without F2 support for this. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * Bring back and fix up util.c functionality.Marti Bolivar2012-06-264-77/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rip out the existing nonportable pieces, and shove them under wirish/stm32f1, using weak symbols so users who only want libmaple proper don't end up with build errors. Add stubbed-out (and only partially functional) definitions for F2 targets under wirish/stm32f2. The behavior on F103 targets is the same as it was before (though the assertion framework has always been broken and badly needs replacement, that awaits another commit). We additionally now skip re-enabling USB on F1 targets without USB, to make things work on value line MCUs. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * util.c: Fix Doxygen header.Marti Bolivar2012-06-261-1/+1
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * Bring back the libraries.Marti Bolivar2012-06-261-6/+6
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * Bring back throb().Marti Bolivar2012-06-261-2/+2
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * stm32f1: gpio.h: Add another hack mode macro.Marti Bolivar2012-06-261-0/+1
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * libmaple/util.c: Add FIXMEs.Marti Bolivar2012-06-261-0/+2
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * I2C: Move CCR/TRISE config helper back to libmaple/i2c.c.Marti Bolivar2012-06-222-37/+41
| | | | | | | | | | | | | | | | | | | | | | | | We can implement it in terms of _i2c_bus_clk() instead of hard-coding STM32_PCLK1. This might be overkill, since I2C peripherals are slow and thus likely to be on APB1 for all STM32 devices (that is the case for F2/F4, for instance), but if we're going to have _i2c_bus_clk(), we might as well respect it. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * <libmaple/i2c.h>: Add I2C_CCR_DUTY bit value definitions.Marti Bolivar2012-06-221-1/+3
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * i2c-mcp4725-dac.cpp: Fix whitespace.Marti Bolivar2012-06-221-59/+59
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * Add I2C example for MCP4725 DAC.Marti Bolivar2012-06-221-0/+145
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * libmaple/stm32f1/i2c.c: Add Doxygen file header.Marti Bolivar2012-06-221-0/+5
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * i2c_dev: deprecate .gpio_port.Marti Bolivar2012-06-224-23/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | This won't work on F2, which at times has SDA and SCL on different ports (e.g. I2C3 SDA on PC9, SCL on PA8). Add .sda_port and .scl_port replacements, which are used when the now-deprecated .gpio_port is null. Use them correctly everywhere, with some new i2c_private.h helper functionality. Sigh. The F1 I2C code tries too hard to guess what you wanted; it's not porting well at all. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * STM32F1: i2c_config_gpios(): Do afio_remap() if we should.Marti Bolivar2012-06-221-0/+4
| | | | | | | | | | | | This should help avoid surprising some users. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * I2C: Move nonportable CCR/TRISE configuration.Marti Bolivar2012-06-223-33/+44
| | | | | | | | | | | | Do this via new private _i2c_set_ccr_trise(). Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * I2C: Deprecate I2C_REMAP flag.Marti Bolivar2012-06-223-7/+26
| | | | | | | | | | | | | | | | This is ad-hoc and nonportable. If you really want I2C mapped elsewhere, then mess with the I2C device fields and call afio_remap() yourself. (This is also cleaner for F2). Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * I2C: Move F1-only errata workarounds out of libmaple/i2c.c.Marti Bolivar2012-06-224-30/+57
| | | | | | | | | | | | | | | | | | The IRQ priority hack is unnecessary on targets with properly functioning I2C IRQ handlers, so we shouldn't use it unless we have to. Add a mechanism so a series header can provide such a hack if necessary. Have the F1 series header use this mechanism. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * libmaple/i2c.c: Cosmetics.Marti Bolivar2012-06-221-188/+190
| | | | | | | | | | | | Move private API to bottom of file. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * libmaple/i2c.c: Keep authorship straight.Marti Bolivar2012-06-221-0/+1
| | | | | | | | | | | | | | I'm going to be moving a lot of code around without changing it soon, so git blame will be unreliable. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * I2C: Add i2c_config_gpios(), i2c_master_release_bus().Marti Bolivar2012-06-223-6/+43
| | | | | | | | | | | | These are necessary to pull out some calls to gpio_set_mode(). Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * <libmaple/i2c.h>: Fix Doxygen.Marti Bolivar2012-06-221-3/+3
| | | | | | | | | | | | | | Existing Doxygen was commenting I2C_IRQ_ERROR instead of i2c_enable_irq(), as desired. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * libmaple/i2c.h: Better comments.Marti Bolivar2012-06-221-2/+16
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * libmaple/i2c.c: Replace throb() with ASSERT(0).Marti Bolivar2012-06-221-1/+1
| | | | | | | | | | | | Calling throb() directly like that breaks the abstraction. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * I2C: I don't think 10-bit addressing works.Marti Bolivar2012-06-221-0/+3
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * <libmaple/i2c.h>: Move low-level routines to end of file.Marti Bolivar2012-06-221-71/+73
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * I2C: Fix Doxygen F1-isms.Marti Bolivar2012-06-221-3/+6
| | | | | | | | | | | | | | | | I'm not sure these functions should even exist in their present form,, but I don't understand the code well enough to make a real fix. For now, just replace references to RM0008 with "chip reference manual". Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * i2c_set_input_clk(): fix an F1-ism.Marti Bolivar2012-06-222-1/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | i2c_set_input_clk()'s documentation says that the maximum peripheral clock frequency is 36 MHz, but that's a hard-coded magic number. The actual limit is the device's APB frequency or 46 MHz, whichever is lower (F2 and F4 share the 46 MHz limit). Fix the documentation to reflect that fact, and add an internal series-provided function to get the maximum clock frequency for a device. To help users porting to F2, have i2c_set_input_clk() assert-check that the provided frequency is less than that maximum value and the hard 46 MHz limit. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * Move i2c_dev and i2c_state into new i2c_common.h.Marti Bolivar2012-06-223-31/+84
| | | | | | | | | | | | | | This is necessary to add series-specific infrastructure to clean up some F1-isms in <libmaple/i2c.h>'s inline functions. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * libmaple/i2c.h: Cosmetics.Marti Bolivar2012-06-221-1/+4
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * I2C: Restore on F1, refactoring prep for F2.Marti Bolivar2012-06-227-63/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bring back <libmaple/i2c.h> support on STM32F1 with a view towards how it'll be implemented on STM32F2. There are still many F1-isms in libmaple/i2c.c and <libmaple/i2c.h>, to be dealt with subsequently. Move device declarations and base pointer definitions to a new F1 <series/i2c.h>. The register maps and bit definitions themselves are identical on both series, so leave them in the libmaple header. Add i2c_private.h, which contains: - I2C_DEV(), a convenience macro for defining an i2c_dev, and - declarations for the event and error IRQ handlers. The IRQ handlers are large, and I2C is slow anyway, so I see no reason to make them inline in the private header (as we do for some other peripherals). We just expose the existing ones that were formerly static in libmaple/i2c.c, but prefix the names with underscore. Move the device declarations and IRQ handlers into new stm32f1/i2c.c. These use the i2c_private.h API. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * libmaple/i2c.c: Cosmetics.Marti Bolivar2012-06-221-2/+0
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * <libmaple/i2c.h>: Cosmetics.Marti Bolivar2012-06-221-6/+6
| | | | | | | | | | | | Put CCR definitions after SR2, to keep them in register map order. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * <libmaple/i2c.h>: Cosmetics.Marti Bolivar2012-06-221-20/+20
| | | | | | | | | | | | | | Reorder register bit definitions by descending bit number, for consistency with the rest of the library. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * <libmaple/i2c.h>: Add missing register bit defns.Marti Bolivar2012-06-221-0/+22
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * libmaple/i2c.h: Assert LeafLabs copyright.Marti Bolivar2012-06-221-0/+1
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * Fix I2C_CR2_FREQ bit definition.Marti Bolivar2012-06-221-1/+1
| | | | | | | | | | | | The existing value clobbers the entire register. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * libmaple/i2c.h: Cosmetics.Marti Bolivar2012-06-221-1/+1
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * libmaple/i2c.h: Don't use BIT().Marti Bolivar2012-06-221-40/+40
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * <libmaple/dma.h>: Assert LeafLabs copyright.Marti Bolivar2012-06-211-0/+1
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * Port test-usart-dma.cpp for STM32F2.Marti Bolivar2012-06-151-0/+9
| | | | | | | | | | | | Too ugly? Meh. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * Implement DMA tube API on STM32F2.Marti Bolivar2012-06-154-2/+1315
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * Port test-usart-dma.cpp to use tube API.Marti Bolivar2012-06-151-13/+61
| | | | | | | | | | | | | | | | This is straightforward. Do it in a verbose style with lots of comments, so we can use this patch as an example for how to port existing DMA code. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * Implement DMA tube API on STM32F1.Marti Bolivar2012-06-152-4/+60
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * DMA: prep for F2 with new "tube" API.Marti Bolivar2012-06-156-366/+1038
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To prepare for STM32F2/F4 DMA support, introduce a new libmaple DMA API, and move some code around to make priority level and interrupt handling more generic. The new API is based on a new set of types (dma_tube, struct dma_tube_reg_map, enum dma_request_src, enum dma_cfg_flags, and struct dma_tube_config). The central abstraction is the dma_tube type. STM32F2/F4 use DMA streams to control dataflow, and STM32F1 uses channels. dma_tube stands for whichever is appropriate for the current target. Dealing with tubes allows for configuring and using DMA with opaque tube values in the same source, instead of (as with ST's firmware) requiring two separate codebases. The new API is also more user-friendly, as it doesn't require knowing which DMA address registers to set and which configuration register flags go along with them. It now suffices to specify the source and destination for the DMA transfer, along with their sizes. This avoids confusion (e.g. for memory-to-memory transfers, data flows from the peripheral address register to the memory register, which might be surprising on F2, which has two memory address registers). The old API (based on enum dma_mode_flags and dma_setup_transfer()) is still available on F1, but deprecate it. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * test-usart-dma.cpp: tweaks.Marti Bolivar2012-06-131-16/+17
| | | | | | | | | | | | | | Touch up comments, change some function names, and don't set something to zero which already is. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * examples/test-usart-dma.cpp: Use HardwareSerial::c_dev().Marti Bolivar2012-06-131-18/+19
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * examples/test-usart-dma.cpp: Cleanups and comments.Marti Bolivar2012-06-131-49/+78
| | | | | | | | | | | | | | | | Someone pointed to this example on the DMA page in the wiki, so it's probably worth making it more clear what's going on. Remove unused code, add comments, and move things around for better exposition. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * HardwareTimer: add a c_dev().Marti Bolivar2012-06-131-0/+8
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
| * HardwareSPI: add a c_dev().Marti Bolivar2012-06-131-0/+8
| | | | | | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>