aboutsummaryrefslogtreecommitdiffstats
path: root/wirish
Commit message (Collapse)AuthorAgeFilesLines
...
* wirish/syscalls.c: Assert LeafLabs copyright.Marti Bolivar2012-06-071-0/+1
| | | | | | _sbrk() is new in 2011, and there've been changes in 2012. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* wirish/syscalls.c: Weaken I/O related function defs.Marti Bolivar2012-06-071-12/+12
| | | | | | For overriding. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Move syscalls.c into Wirish.Marti Bolivar2012-06-072-0/+170
| | | | | | libmaple takes orders, it doesn't give them. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* maple/board.cpp: Demo weakness of boardInit().Marti Bolivar2012-06-071-0/+5
| | | | | | | This shows people what to do to write boardInit(), but also how to save work if they don't need it. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* maple/board.cpp: Use PMAP_ROW().Marti Bolivar2012-06-071-45/+55
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* board_private.h: Add PMAP_ROW() convenience macro.Marti Bolivar2012-06-071-0/+4
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* maple/board.cpp: Add more explanatory comments.Marti Bolivar2012-06-071-0/+16
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* isButtonPressed(): Take a pin and pressedLevel argument.Marti Bolivar2012-06-072-4/+5
| | | | | | | This allows dealing with push-buttons on pins other than BOARD_BUTTON_PIN. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* <wirish/boards.h>: Add BOARD_BUTTON_PRESSED_LEVEL.Marti Bolivar2012-06-072-3/+11
| | | | | | | | | | This allows boards to override the logic level of a pressed button. All Maple boards have a pressed button read HIGH, but if the opposite convention is used, isButtonPressed() will infinite loop. Make isButtonPressed() respect this setting. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* wirish/boards.h: Optionally derive SYSTICK_RELOAD_VAL.Marti Bolivar2012-06-071-0/+3
| | | | | | It's stupid to make everyone keep this around. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* STM32F2: Allow boards to override PLL configuration.Marti Bolivar2012-06-071-6/+20
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* HardwareSerial.cpp: Fix "#warn" -> "#warning".Marti Bolivar2012-06-071-1/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* wirish: Weaken boards_private.h definitions.Marti Bolivar2012-06-072-28/+36
| | | | | | | This lets users override them conveniently if our decisions don't suit. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Provide wirish::priv::series_init() on F1.Marti Bolivar2012-06-072-10/+7
| | | | | | This lets us remove the weak definition in boards.cpp. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Remove a completed FIXME comment.Marti Bolivar2012-06-071-3/+0
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* STM32F2: Add EXTI support.Marti Bolivar2012-06-031-1/+1
| | | | | | | | Add series headers to keep the base pointers, and (on F2) use SYSCFG to tell exti_do_select() where the EXTI control registers are. No surprises. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* STM32F2: Turn on SYSCFG I/O compensation during init().Marti Bolivar2012-06-031-0/+3
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* STM32F2: Add SYSCFG support.Marti Bolivar2012-06-033-1/+16
| | | | | | Turn it on at init() time on F2. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Bring back EXTI on F1, with deprecations for gpio.h on F1.Marti Bolivar2012-06-032-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tested on Maple Mini with examples/mini-exti-test. Changes to Wirish are minor: use the new EXTI types exti_num and exti_cfg (see below) in place of now-deprecated variants in ext_interrupts.cpp. The way I originally did libmaple/exti.h was stupid, and fixing it turned out to be a little disruptive. libmaple/exti.h depends on libmaple/gpio.h (for AFIO), but that's a classic case of exposed implementation detail. So invert the dependency: make gpio.h depend on exti.h. Do this by adding exti_num and exti_cfg to exti.h; these respectively replace afio_exti_num and afio_exti_port. The afio_* variants are now deprecated. (Throw in a typedef and some macros at the bottom of the F1 series/gpio.h for backwards compatibility). Make exti_attach_interrupt() and exti_detach_interrupt() take exti_num/exti_cfg arguments instead of the afio_* variants. Make the EXTI dispatch routines __always_inline to defeat GCC -Os. Many renames throughout libmaple/stm32f1/ to stop using the deprecated names. Also move the previously F1-only gpio_exti_port() function into the public libmaple header. Reimplementing it in terms of rcc_clk_ids lets us deprecate the gpio_dev->exti_port field, which will save space in the future. While we're there, I notice that struct gpio_dev is defined once per series. That's dumb, as it misses the entire point of having device structs: they contain what's portable. So put the F1 version (which has the extra EXTI port field) into libmaple/gpio.h, and add the necessary exti_ports to libmaple/stm32f2/gpio.c. Sigh. We'll get rid of it eventually, at least. Clean up some other mistakes in gpio.h files as well (mostly removing util.h dependency). Sorry for the messy commit. For portability, add a new series-specific exti function, exti_select(). The F1 version in (new) libmaple/stm32f1/exti.c uses AFIO and some new private functionality in libmaple/exti.c and (new) libmaple/exti_private.h to make this convenient. We'll be able to do the SYSCFG equivalent on F2 without any trouble. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* wirish/ext_interrupts.cpp: Doxygen, copyright.Marti Bolivar2012-06-031-1/+2
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Slightly improve and generify the USB infrastructure.Marti Bolivar2012-06-034-8/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add BOARD_HAVE_SERIALUSB.Marti Bolivar2012-06-031-0/+6
| | | | | | Feature-test for SerialUSB support. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* <wirish/boards.h>: Add feature test macros for SPI.Marti Bolivar2012-06-031-2/+20
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Typo fix.Marti Bolivar2012-06-031-1/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Globally switch style for GPIO config routines.Marti Bolivar2012-06-032-11/+7
| | | | | | | | | | | | | | | | | | | | 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-031-31/+1
| | | | | | | | 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>
* STM32F2: fix pinMode() for PWM, PWM_OPEN_DRAIN.Marti Bolivar2012-06-031-2/+1
| | | | | | Make it so the call to gpio_set_modef() actually happens. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* HardwareTimer.cpp: cosmetics.Marti Bolivar2012-06-031-2/+1
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* HardwareTimer::setPeriod(): Don't use floating point.Marti Bolivar2012-06-031-3/+3
| | | | | | I can't believe we've been shipping this for so long. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* HardwareTimer.cpp: save some space with an rcc_clk_id hack.Marti Bolivar2012-06-031-97/+26
| | | | | | | | | | | | Since rcc_clk_ids for a peripheral now form a contiguous range by peripheral number, we can infer the rcc_clk_id for a timer given its number (e.g., can calculate RCC_TIMER2 given timerNum == 2). This lets us use timer_foreach() to avoid keeping a table of available timers in HardwareTimer.cpp. The implementation is hackish, but can be fixed up later if need be. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Bring back/tweak pwmWrite().Marti Bolivar2012-06-022-6/+9
| | | | | | Works on F1, doesn't on F2. Will figure that out next. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* boards.cpp: Improve the comments.Marti Bolivar2012-06-021-13/+13
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Bring timer initialization back to init().Marti Bolivar2012-06-024-52/+43
| | | | | | | | | | | | | | Turns out the F1 code was pretty portable after all, so take it from the F1 boards_setup.cpp and stick it back into boards.cpp. The only change needed was to add a call to the newly-minted timer_has_cc_channel() (and this is necessary on F103 XL-density, anyway). Also assert LeafLabs copyright in boards.cpp. We really need to do this throughout the library; it's basically been rewritten since Perry. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Oops; don't break the build on F1.Marti Bolivar2012-06-021-2/+2
| | | | | | That was dumb. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Preprocessor-fu to derive BOARD_HAVE_USARTn from <board/board.h>.Marti Bolivar2012-06-018-44/+22
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* <wirish/HardwareTimer.h> cosmetics.Marti Bolivar2012-06-011-5/+3
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Bring back HardwareTimer.Marti Bolivar2012-06-013-23/+104
| | | | | | | | | | | | | | Untested, but the timers work on F2 (see exampes/test-timers.cpp), so I'm hoping this is mostly OK. Note that there's an issue with TIMER2 and TIMER5 on F2: these timers have 32-bit counters, and the HardwareTimer methods are all based on uint16 (like on F1). I'm sorely tempted to keep this as-is; exposing the extra bits is just extra documentation, and the HardwareTimer interface is already way too complicated. The interface should still _work_; it just hides the fact that you're missing out on the extra bits for some of the timers. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Bring back analogRead().Marti Bolivar2012-06-012-6/+7
| | | | | | | Yay, it just worked! Still, while we're here, touch up the make-up on wirish_analog.cpp. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Bring back HardwareSerial.Marti Bolivar2012-06-0110-56/+126
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Bring back wirish/wirish_math.cpp.Marti Bolivar2012-05-311-1/+1
| | | | | | This is portable. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* wirish/rules.mk: Cosmetics.Marti Bolivar2012-05-311-10/+10
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Bring back wirish/Print.cpp.Marti Bolivar2012-05-311-1/+1
| | | | | | | The only nonportable parts of this file are based on the assumption that we're on ILP32. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Assert LeafLabs copyright in wirish/Print.cpp.Marti Bolivar2012-05-311-0/+1
| | | | | | | | This should get replaced with a clean-room MIT licensed version, but pieces of it are ours (notably the bugfixes to the floating point printing routines), so might as well do the copyright thing. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Replace shiftOut(), also fixing a possible bug.Marti Bolivar2012-05-312-32/+29
| | | | | | | | | | | | The current shiftOut() is borrowed from Arduino, and is in an LGPL file. Replace that file with a new MIT-licensed version containing a new implementation. The new version brings the clock line LOW before starting, to make sure that the first pulse is detected if the clock line was previously HIGH. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* examples/blinky.cpp works on F2.Marti Bolivar2012-05-314-60/+227
| | | | | | | | | | | | | | | | | | | | | | Only OUTPUT mode is tested; any other modes might work, but no guarantees. Bring back: - wirish/wirish_digital.cpp - wirish/cxxabi-compat.cpp - wirish/wirish_time.cpp Add new: - wirish/stm32f1/wirish_digital.cpp - wirish/stm32f2/wirish_digital.cpp Move pinMode() from wirish/wirish_digital.cpp into the file by the same basename in wirish/stm32f1. This implementation is tied to F1. Add an F2 implementation in wirish/stm32f2/wirish_digital.cpp. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* <wirish/wirish.h>: Don't include some files.Marti Bolivar2012-05-311-2/+2
| | | | | | These don't work on F2, so leave them out for now. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* wirish: Build board.cpp.Marti Bolivar2012-05-311-1/+1
| | | | | | | There's enough infrastructure for a basic board.cpp on STM32F2, so we might as well bring this back. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Fix a bunch of Doxygen file-level comments.Marti Bolivar2012-05-0813-23/+19
| | | | | | | | | | | | | 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>
* STM32VLDiscovery support filesAnton Eltchaninov2012-05-032-0/+195
| | | | | Signed-off-by: Anton Eltchaninov <anton.eltchaninov@gmail.com> Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* stm32.h: Various updates, mostly to help STM32F1 line support.Marti Bolivar2012-04-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add STM32_HAVE_USB feature test macro requirement for <series/stm32.h>. This will let us test if we've got a USB peripheral. wirish/stm32f1/boards_setup.cpp is set up to use this when turning on USB CDC ACM support at init() time. Rework the STM32F1 <series/stm32.h> to make it easier to support the various lines that subdivide that series. We don't really support anything besides performance line yet, but there's been enough enthusiasm for value and connectivity line support in the past that these hooks seem worth adding. This means adding an STM32_F1_LINE macro and STM32_F1_LINE_[PERFORMANCE,VALUE,ACCESS,CONNECTIVITY] macros for values that STM32_F1_LINE can take, and generalizing the rest of the file to begin taking this into account. Some TODOs remain, but filling these in is the responsibility of future libmaple porting efforts. One pleasant consequence of the F1 stm32.h rework is that the build system no longer has to tell us what density of F103 we're building for, so remove that from the relevant support/make/board-includes/ files. Add some tweaks to <libmaple/stm32.h> and the STM32F2 stm32.h header to make sure this went through properly, and continues to go through properly in the future.