aboutsummaryrefslogtreecommitdiffstats
path: root/wirish
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* stm32f1 boards_setup.cpp: Allow overriding the PLL multiplier.Marti Bolivar2012-04-231-1/+10
| | | | | | | | | | Allow <board/board.h> to override the PLL multiplier by defining BOARD_RCC_PLLMUL. This should be useful for e.g. value line MCUs, which have slower clocks. It's also probably useful for people who have external oscillators different from the 8 MHz ones we use on all of our boards. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Resurrect ADC support.Marti Bolivar2012-04-114-39/+59
| | | | | | | | | | | | | Standard refactoring: add series headers for F1 and F2, along with series adc.c files. There are some issues relating to adc_extsel_event to hammer out later, but this will do for now. We also add some new portability interfaces to libmaple/adc.h in order for Wirish to use the same code to initialize the ADCs at init() time. As usual, F1 is untested. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* wirish/boards.cpp: Use __weak instead of GCC attribute.Marti Bolivar2012-04-111-1/+2
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* [FIXME] Resurrect boards.cpp for F2 and F1.Marti Bolivar2012-04-116-106/+363
| | | | | | | | | | | | | | | | FIXME: - F1 support currently appears to be failing in start_c.c, for some unknown reason. This will need to get sorted out later. Add a new wirish namespace, and a sub-namespace wirish::priv::. Put a bunch of board setup routines in this namespace, and declare them in new wirish/boards_private.h. boards.cpp uses this to perform initialization tasks in a portable way, with two new boards_setup.cpp files under wirish/stm32f1 and wirish/stm32f2 handling the series-specific details. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* [WIP] boards: Add st_stm3220g_eval.Marti Bolivar2012-04-112-0/+109
| | | | | | | This supports ST's STM3220G-EVAL, the standard "kitchen-sink" evaluation board for the STM32F2 series. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* [UNDO] Rip out everything but libmaple and Wirish startup code.Marti Bolivar2012-04-111-19/+19
| | | | | | | We'll need to bring all this functionality back online piecemeal as we add F2 support. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* boards.cpp: Remove implementation details from Doxygen comments.Marti Bolivar2012-04-111-6/+9
| | | | Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* wirish/boards.cpp: Use FLASH_SAFE_WAIT_STATES.Marti Bolivar2012-04-111-1/+1
| | | | | | | Do this instead of hard-coding a number of wait states to use in setupFlash(), which is called by init(). This helps future-proof. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Make USB its own submodule.Marti Bolivar2012-04-112-2/+2
| | | | | | | | | | | | | | | Add libmaple/usb/rules.mk, which compiles the USB FS device firmware submodule. Move the logic for compiling the USB stack from libmaple/rules.mk into libmaple/usb/rules.mk. Move libmaple/usb/usb_cdacm.h to libmaple/include/libmaple/. Its API is sufficiently general that we'll be able to port it over to USB OTG (either FS or HS) eventually, and that lets us include it from Wirish using the new style for libmaple headers. Fix the includes for public libmaple headers within libmaple/usb. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Move wirish/comm/*.cpp into wirish.Marti Bolivar2012-04-113-3/+2
| | | | | | The wirish/comm/ directory is stupid. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Move public headers to include directories; related cleanups.Marti Bolivar2012-04-1141-224/+187
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move libmaple/*.h to (new) libmaple/include/libmaple/. The new accepted way to include a libmaple header foo.h is with: #include <libmaple/foo.h> This is more polite in terms of the include namespace. It also allows us to e.g. implement the Arduino SPI library at all (which has header SPI.h; providing it was previously impossible on case-insensitive filesystems due to libmaple's spi.h). Similarly for Wirish. The old include style (#include "header.h") is now deprecated. libmaple/*.h: - Change include guard #defines from _FOO_H_ to _LIBMAPLE_FOO_H_. - Add license headers where they're missing - Add conditional extern "C" { ... } blocks where they're missing (they aren't always necessary, but we might was well do it against the future, while we're at it.). - Change includes from #include "foo.h" to #include <libmaple/foo.h>. - Move includes after extern "C". - Remove extra trailing newlines Note that this doesn't include the headers under libmaple/usb/ or libmaple/usb/usb_lib. These will get fixed later. libmaple/*.c: - Change includes from #include "foo.h" to #include <libmaple/foo.h>. Makefile: - Add I$(LIBMAPLE_PATH)/include/libmaple to GLOBAL_FLAGS. This allows for users (including Wirish) to migrate their code, but should go away ASAP, since it slows down compilation. Wirish: - Move wirish/**/*.h to (new) wirish/include/wirish/. This ignores the USB headers, which, as usual, are getting handled after everything else. - Similarly generify wirish/boards/ structure. For each supported board "foo", move wirish/boards/foo.h and wirish/boards/foo.cpp to wirish/boards/foo/include/board/board.h and wirish/boards/foo/board.cpp, respectively. Also remove the #ifdef hacks around the .cpp files. - wirish/rules.mk: put wirish/boards/foo/include in the include path (and add wirish/boards/foo/board.cpp to the list of sources to be compiled). This allows saying: #include <board/board.h> instead of the hack currently in place. We can allow the user to override this setting later to make adding custom board definitions easier. - Disable -Werror in libmaple/rules.mk, as the current USB warnings don't let the olimex_stm32_h103 board compile. We can re-enable -Werror once we've moved the board-specific bits out of libmaple proper. libraries, examples: - Update includes accordingly. - Miscellaneous cosmetic fixups. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Fix linking and C runtime initialization on F1.Marti Bolivar2012-04-111-9/+10
| | | | | | | | | | | | Reorder the .data and .rodata sections in common.inc. This seems necessary to get the linker to place the data ROM disk and the pointer to it in the right places. Switch from long long to int in start_c.c. I have no idea why this helps, but it does. F1 will crash if you don't do this. It will probably slow things down unnecessarily on F2, but I don't care. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Cosmetics.Marti Bolivar2012-04-112-41/+42
| | | | | | | | | Convert wirish/start.S and wirish/start_c.c to libmaple coding conventions. Whitespace and brace insertion changes only. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Remove "CS3" prefix from libmaple symbol names.Marti Bolivar2012-04-112-6/+63
| | | | | | | | | | | | | | | | | | | We're no longer even marginally compatible with CS3, so it's inappropriate to use that prefix in our names. Rename: __cs3_stm32_vector_table -> __stm32_vector_table. __cs3_stack -> __msp_init __cs3_reset -> __exc_reset __cs3_start_c -> start_c Also add an MIT license header and assert LeafLabs copyright over wirish/start.S and wirish/start_c.c. These files are modified from the original CodeSourcery versions, which were distributed under a license that permits modifications to be distributed under a different copyright and licensing terms than the originals. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Remove CS3-style initialization.Marti Bolivar2012-04-113-2/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove libcs3-related bits from support/ld. Break them out into libmaple proper and Wirish as appropriate: vector table definition and ISR declarations go into libmaple proper, and startup code goes into Wirish. Vector table symbols are included into common.inc from an STM32 family-specific directory under support/ld/stm32. This is a combination of 5 commits. Individual commit messages follow: libcs3_stm32_src: Don't depend on cs3.h. So we can use the existing toolchain. Move ISR decls/vector table into libmaple proper. This allows us to configure the vector table on a per-family basis. - Move support/ld/libcs3_stm32_src/stm32_isrs.S stm32_vector_table.S to libmaple/stm32f1/isrs_performance.S vector_table_performance.S, respectively. The directory libmaple/stm32f1/ is intended to hold all STM32F1-specific code within libmaple. Obviously, there's a lot of work to do before this becomes true. - support/ld/libcs3_stm32_src/Makefile: Don't try to compile stm32_isrs.S and stm32_vector_table.S anymore. - Add libmaple/stm32f1/rules.mk to include these new files in the standard libmaple build. - support/make/target-config.mk: Add LIBMAPLE_MODULE_FAMILY, which selects a directory to use as a family-specific libmaple submodule. - Makefile: Add LIBMAPLE_MODULE_FAMILY to LIBMAPLE_MODULES. Remove support/ld/libcs3_stm32_src and derived object files. From support/ld/libcs3_stm32_src, move start.S and start_c.c into Wirish. Modify wirish/rules.mk accordingly. Delete support/ld/libcs3_stm32_*_density.a. These are no longer necessary, as the relevant objects are included in the standard Wirish build. Remove the GROUP statements from the board linker scripts accordingly. Remove SEARCH_DIR(.) from common.inc; it's no longer necessary. Also fix up some comments that are now out of date. wirish/start_c.c: Don't use CS3-style memory initialization. Switch memory initialization to a simpler style of initializing .data if necessary, then zeroing .bss. Initializing .data is only necessary during Flash builds, since during RAM builds, LOADADDR(.data) == ADDR(.data). This makes libmaple completely incompatible with the CS3 startup sequence. Subsequent commits will clean up the namespace to reflect that fact. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* USB: API cleanups.Marti Bolivar2011-10-211-2/+2
| | | | | | | | | | Modify usb.h functions (changing their names in some cases) to also take a usblib_dev* argument, to fit in better with the rest of libmaple. Store an rcc_clk_id in struct usblib_dev for the same reason. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Fix micros() bug.Marti Bolivar2011-10-201-1/+1
| | | | | | Thanks to ala42 for the fix. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* wirish: Clean up includes; other fixups.Marti Bolivar2011-10-1812-29/+46
| | | | | | | | | | | | | | | | | | Clean up various core files' includes to fit this pattern: - Header files include what they use. - CPP files include their header first - Include order is libmaple proper headers, then wirish headers (modulo CPP rule above). wirish.h: Move HIGH and LOW to io.h, and the boolean and byte typedefs into wirish_types.h. These don't belong in wirish.h. Add include guards to wirish_debug.h. Oops. wirish_digital.cpp: Use standard bool instead of "boolean". Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* usb: Disentangle CDC ACM functionality.Marti Bolivar2011-10-182-10/+11
| | | | | | | | | | | | | | | | | | | | | Add new usb_cdcacm.h, which provides the virtual serial port API. This file (and new usb_cdcacm.c) consolidate the VCOM support, which was previously distributed through descriptors.[hc], usb.[hc], usb_callbacks.[hc], and usb_config.h. Add usb_init_usblib() to usb.h, as a way of initializing the USB peripheral in terms of the data structures required by usb_lib. This is used by the new usb_cdcacm_enable(). Create new usb_lib_globals.h, with declarations for the usb_lib global state which is most used throughout the rest of the libmaple USB stack. Remove descriptors.c and usb_callbacks.[hc]; they are no longer necessary. Update the USB README accordingly. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* usb: Cleanups and renames.Marti Bolivar2011-10-182-3/+3
| | | | | | | | | Rename setupUSB() and disableUSB() to usb_cdcacm_enable() and usb_cdcacm_disable(), respectively. Remove usbSendHello(). This shouldn't exist. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* usb: Move some board-specific configuration to Wirish.Marti Bolivar2011-10-187-3/+21
| | | | | | | | | Create new BOARD_USB_DISC_DEV and BOARD_USB_DISC_BIT board-specific values. Use these as arguments to setupUSB() and disableUSB(). This helps make the USB stack more generic, and goes towards the resolution of an important FIXME. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
* Add support for the Olimex STM32 H103 board.David Kiliani2011-09-274-0/+213
| | | | | | | | Pin layout and header files for the STM32 H103 prototype board from Olimex featuring an STM32F103RBT6 chip. This commit contains all necessary changes to compile with BOARD=olimex_stm32_h103. Signed-off-by: David Kiliani <mail@davidkiliani.de>
* maple_native.cpp: Cosmetics.Marti Bolivar2011-09-121-2/+2
| | | | | | Stick FSMC_BCR_MTYP_SRAM among the bitfields assigned to the BCR write. Technically not necessary (SRAM is the default after reset), but good for readability and future-proofing.
* Maple Native: Fix BOARD_NR_USED_PINS, boardUsedPins.Marti Bolivar2011-09-092-8/+4
|
* Update outdated stm32.h usages.Marti Bolivar2011-09-071-5/+5
| | | | | stm32.h has been updated to prefix its definitions. Update the rest of libmaple to take this into account.
* wirish/boards: Move includes into .cpp files.Marti Bolivar2011-09-017-26/+20
| | | | | The headers just #define some numbers, so there's no need for them to be including libmaple headers.
* maple_native.cpp: Add FSMC FIXME to resolve for 0.0.12.Marti Bolivar2011-09-011-0/+1
|
* maple-native.cpp: Comment tweak.Marti Bolivar2011-08-311-1/+1
| | | | | First in what is sure to be a long series of efforts in educating people that you can have GPIOs 56--100 or the SRAM chip, but not both.
* maple_native.cpp: mark initSRAMChip() static.Marti Bolivar2011-08-311-2/+2
|
* maple_native.h: Fix USART pins.Marti Bolivar2011-08-301-8/+8
| | | | | These apparently didn't get updated from an earlier prototype's values.
* HardwareSerial.h: Remove documentation TODO.Marti Bolivar2011-08-161-3/+0
| | | | | | | It's difficult to document HardwareSerial's interface fully in HardwareSerial.h, since most of the methods people care about are inherited from Print, anyway. Stick with documenting this interface by hand for the foreseeable future.