aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/include
Commit message (Collapse)AuthorAgeFilesLines
* Add STM32F2 I2C support.Marti Bolivar2014-11-241-13/+2
| | | | | | | Untested, but fixes the build and at least provides the correct register map and base pointers. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Revert "- tx and rx callbacks for each module"Marti Bolivar2014-01-102-66/+0
| | | | | | | | This reverts commit da01c80f24dc9c43ff951ea9fd283abb4628ceb7. Reverting pull request #54, which breaks examples/i2c-mcp4725-dac.cpp. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Revert "I2C slave support cleanups."Marti Bolivar2014-01-102-11/+4
| | | | | | | | This reverts commit 39cd07a640ee87b7937738d36f17019b2865bfae. Reverting pull request #54, which breaks examples/i2c-mcp4725-dac.cpp. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Revert "Added I2C slave echo example in examples folder. Using another ↵Marti Bolivar2014-01-101-1/+0
| | | | | | | | | | maple, write a byte and then read." This reverts commit 594724951553a882758c11497a4f03828b4f43e6. Reverting pull request #54, which breaks examples/i2c-mcp4725-dac.cpp. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Merge pull request #54 from ginge/masterMarti Bolivar2013-07-262-1/+75
|\ | | | | Added i2c slave support
| * Added I2C slave echo example in examples folder. Using another maple, write ↵Barry Carter2012-09-051-0/+1
| | | | | | | | | | | | | | | | | | | | a byte and then read. Slight tidy up. Reformatted CREDITS file to be in correct order. Added a note about buffer overrun Signed-off-by:- Barry Carter <barry.carter@gmail.com>
| * I2C slave support cleanups.Barry Carter2012-09-042-4/+11
| | | | | | | | | | | | | | | | | | | | Added fix for corner case where badly behaving master doesn't NACK and we don't get the callbacks fires. Removed my own name from several places and added attribution to the correct place. Updated include comments to reference the fact it now supports I2C slave Signed-off-by:- Barry Carter <barry.carter@gmail.com>
| * - tx and rx callbacks for each moduleBarry Carter2012-09-032-0/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Callbacks can be called after each read/write cycle or per byte - Each I2C module can have different callbacks - General call support also working - Supports master and slave at same time. Also works with multimaster Usage: i2c_msg msg; char buffer[255]; main() { i2c_slave_enable(I2C1, I2C_FAST_MODE | I2C_SLAVE_DUAL_ADDRESS | I2C_SLAVE_GENERAL_CALL | I2C_SLAVE_USE_RX_BUFFER); // init slave mode. Enables master too i2c_slave_attach_recv_handler(I2C1, pmsg, funcrx); // attach receive handler i2c_slave_attach_transmit_handler(I2C1, pmsg, functx); // attach transmit handler i2c_slave_set_own_address(I2C1, 0x10); // set addresss 1 i2c_slave_set_own_address2(I2C1, 0x20); // set addresss 2 } void funcrx(i2c_msg *msg) { printf("length is %d.\n", msg->length); char return_data = msg0>data[0]; } void functx(i2c_msg *dev) { msg->data[0] = 0x01; msg->data[1] = 0x02; msg->data[2] = 0x03; msg->data[3] = 0x04; msg->data[4] = 0x05; msg->length = 5; } All code derived from datasheets and libmaple. Signed-off-by:- Barry Carter <barry.carter@gmail.com>
* | Merge remote-tracking branch 'wesen/bug/usb-resume'Marti Bolivar2013-04-261-0/+1
|\ \
| * | Preserve previous usb state when suspending / restore on resumeManuel Odendahl2013-04-261-0/+1
| | | | | | | | | | | | Signed-off-by: Manuel Odendahl <wesen@ruinwesen.com>
* | | Handle sending 0 byte packets.Manuel Odendahl2013-01-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Added a flag to see if we are currently waiting on an interrupt to acknowledge the sending of the current IN packet. Added a method usb_cdcacm_is_transmitting() to check for that flag. Signed-off-by: Manuel Odendahl <wesen@ruinwesen.com>
* | | Move endpoint definitions to include files (they are now needed outside in ↵Manuel Odendahl2013-01-171-0/+21
|/ / | | | | | | | | | | usb_serial.cpp) Signed-off-by: Manuel Odendahl <wesen@ruinwesen.com>
* | "Callback versions of functions now take voidArgumentFuncPtr. We can ↵Aditya Gaddam2012-09-021-1/+1
| | | | | | | | | | | | probably use voidFuncPtr instead, but this way people can see that the function expects something different. Existing functions haven't changed in signature. Signed-off-by: Aditya Gaddam <adityagaddam@gmail.com>"
* | "Added ability to set callbacks for interrupts that get an argument. This ↵Aditya Gaddam2012-08-312-0/+6
|/ | | | | | argument can be the instance that needs to handle the interrupt, or just a random argument you might find useful later. Suggestions from mbolivar and iperry from pull53 on libmaple were taken into account. Signed-off-by: Aditya Gaddam <adityagaddam@gmail.com>"
* Revert "Re-work the constraints on delay_us(). Ask GCC to allocate a register"Marti Bolivar2012-08-221-4/+4
| | | | | | | | This reverts commit 715a63dccb3a39d7d0502fb39b900c8302a60a87. It fails to build using the 2010 CodeSourcery toolchain, which is still the latest officially supported version. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Re-work the constraints on delay_us(). Ask GCC to allocate a registerMichael Hope2012-08-221-4/+4
| | | | | | | instead of forcing r0. Use the same operand as input and output to remove the move. Signed-off-by: Michael Hope <michael.hope@linaro.org>
* Make PRIMASK set/clear functions __always_inline.Marti Bolivar2012-08-141-2/+2
| | | | | | | This is just to ensure that -Os doesn't prevent these from getting inlined. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* usb_cdcacm.h: Add convenience for declaring device descriptor.Marti Bolivar2012-08-041-0/+21
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* <libmaple/usb.h>: Fix usb_descriptor_string.Marti Bolivar2012-08-041-3/+3
| | | | | | uint16 is the wrong type for the bString array. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Move contents of usb_descriptors.h to <libmaple/usb.h>.Marti Bolivar2012-08-041-1/+94
| | | | | | | | These form and name of structs etc. is basically determined by the USB spec and the libmaple style guide, so there's little reason for them to change, and less reason for them to stay hidden. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Prep usb_descriptors.h for removal.Marti Bolivar2012-08-041-0/+19
| | | | | | | | | | | | Just change names and things to fit the libmaple style. Its contents will move to the top-level <libmaple/usb.h> header next. This API is still unstable, but we need to expose pieces of it in order to get the Maple-specific pieces of usb_cdcacm.c into Wirish. Adjust uses of the API appropriately. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* usb_cdcacm: Expose line coding state.Marti Bolivar2012-08-041-0/+27
| | | | | | | This was already supported, so just move the line coding structure to the header and add some functions for accessing the current values. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* usb_cdcacm: various fixups.Marti Bolivar2012-08-041-25/+0
| | | | | | | | | | Mark internal state static. Properly reset the RX/TX state on USB reset. Choose better names for countTx and newBytes. Move the exposed configuration back into the .c; this information is not beneficial to hooks. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* usb_cdcacm: Rename "notification" -> "management".Marti Bolivar2012-08-011-4/+4
| | | | | | This keeps things in line with the specification, helping readability. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Move bootloader details out of libmaple.h.Marti Bolivar2012-07-311-8/+0
| | | | | | Finally! Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Move bootloader reset signal detection to Wirish.Marti Bolivar2012-07-311-1/+0
| | | | | | | | Use usb_cdcacm hooks to move the DTR edge and "1EAF" magic packet detection to usb_serial.cpp. We'll later be able to extend this system to support Leonardo-style reset signalling. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* usb_cdcacm: Add usb_cdcacm_peek().Marti Bolivar2012-07-311-0/+1
| | | | | | | | | | | We need this so the bootloader reset signal detector can look ahead in the byte stream without stealing bytes from the user when "1EAF" isn't received. While we're doing this, take the time to fix a bunch of RX-related code (dead code removal, adding volatile, etc.) Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* usb_cdcacm: Add hook system.Marti Bolivar2012-07-311-0/+13
| | | | | | | | Provide hooks so users can reach into the CDC ACM callbacks with their own code. We'll use this to move the bootloader reset signals to Wirish. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* usb_cdcacm: Expose some internal configuration and values.Marti Bolivar2012-07-311-0/+42
| | | | | | | | | Mark the API as unstable so people don't rely on these too hard. (This header is not part of the official libmaple docs). We'll need some of this configuration elsewhere later, and it doesn't make much sense to expose it piecemeal. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* <libmaple/scb.h>: Add FIXME to check for F2 compatibility.Marti Bolivar2012-07-131-0/+4
| | | | Signed-off-by: Marti Bolivar <mbolivar@lozenge.(none)>
* <libmaple/scb.h>: Don't use BIT().Marti Bolivar2012-07-131-60/+60
| | | | | | Also, assert copyright LeafLabs 2012. Signed-off-by: Marti Bolivar <mbolivar@lozenge.(none)>
* <libmaple/scb.h>: Assert LeafLabs copyright.Marti Bolivar2012-07-131-0/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@lozenge.(none)>
* Doxygen hacks and fixups.Marti Bolivar2012-06-284-14/+11
| | | | | | | | - Shut Doxygen up in various places - Fix some genuine docs bugs - Ignore sources we're not responsible for 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_dev: deprecate .gpio_port.Marti Bolivar2012-06-221-1/+18
| | | | | | | | | | | | | 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>
* I2C: Deprecate I2C_REMAP flag.Marti Bolivar2012-06-221-1/+1
| | | | | | | | 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-221-0/+18
| | | | | | | | | 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>
* I2C: Add i2c_config_gpios(), i2c_master_release_bus().Marti Bolivar2012-06-221-0/+25
| | | | | | 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.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-221-1/+16
| | | | | | | | | | | | | | | 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-222-27/+80
| | | | | | | 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-221-16/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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.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>