Commit graph

262 commits

Author SHA1 Message Date
Marti Bolivar ad33982885 wirish: Clean up includes; other fixups.
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>
2011-10-18 15:12:21 -04:00
Marti Bolivar 494f05b236 usb: Disentangle CDC ACM functionality.
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>
2011-10-18 13:30:18 -04:00
Marti Bolivar 17e67dff76 usb: Cleanups and renames.
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>
2011-10-18 13:30:17 -04:00
Marti Bolivar 545aae4459 usb: Move some board-specific configuration to Wirish.
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>
2011-10-18 13:30:17 -04:00
David Kiliani 1873871aea Add support for the Olimex STM32 H103 board.
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>
2011-09-27 16:44:53 -04:00
Marti Bolivar 0697f5d0d6 maple_native.cpp: Cosmetics.
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.
2011-09-12 21:29:50 -04:00
Marti Bolivar 626e4e06f0 Maple Native: Fix BOARD_NR_USED_PINS, boardUsedPins. 2011-09-09 15:33:11 -04:00
Marti Bolivar aad2377ae3 Update outdated stm32.h usages.
stm32.h has been updated to prefix its definitions.  Update the rest
of libmaple to take this into account.
2011-09-07 23:34:23 -04:00
Marti Bolivar 4a98ddaccb wirish/boards: Move includes into .cpp files.
The headers just #define some numbers, so there's no need for them to
be including libmaple headers.
2011-09-01 09:38:39 -04:00
Marti Bolivar d349f7cd6b maple_native.cpp: Add FSMC FIXME to resolve for 0.0.12. 2011-09-01 09:35:11 -04:00
Marti Bolivar 1769ba3a05 maple-native.cpp: Comment tweak.
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.
2011-08-31 15:32:29 -04:00
Marti Bolivar 15b9adcf66 maple_native.cpp: mark initSRAMChip() static. 2011-08-31 15:00:54 -04:00
Marti Bolivar d055e99a9f maple_native.h: Fix USART pins.
These apparently didn't get updated from an earlier prototype's
values.
2011-08-30 18:16:00 -04:00
Marti Bolivar b1b71c5e09 HardwareSerial.h: Remove documentation TODO.
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.
2011-08-16 06:13:48 -04:00
Marti Bolivar 8a3aa2a29b HardwareSerial.cpp: Respect PCLK1 and PCLK2. 2011-08-16 06:13:48 -04:00
Marti Bolivar fcb4afcd50 HardwareSerial: Add pin accessors. 2011-08-16 06:13:48 -04:00
Marti Bolivar 96c474d94b HardwareSerial: trivial code reordering 2011-08-16 06:13:48 -04:00
Marti Bolivar 5710942d83 HardwareSPI.cpp: minor HardwareSPI::send() cleanup. 2011-08-16 06:13:48 -04:00
Marti Bolivar e1c0b0cfee HardwareSPI: Add pin accessors. 2011-08-16 06:13:41 -04:00
Marti Bolivar ab8d721c05 HardwareTimer.cpp: fix HardwareTimer::setPeriod() 2011-06-14 16:35:10 -04:00
Marti Bolivar f36a1d9849 Remove reST documentation, attendant updates.
The documentation covers topics not specifically relevant to libmaple,
so it doesn't make sense for it to be part of the libmaple source
distribution.

Delete the docs/ tree, and prepare libmaple for use with the new
leaflabs-docs repo, which will contain the docs from now on.

* README: update to reflect this change

* support/doxygen/Doxyfile: This is the old docs/Doxyfile

* Makefile: Add a doxygen target

* wirish/comm/HardwareSerial.h: fix reference to docs/.  The comment
  informing maintainers that the HardwareSerial interface is
  documented by hand refers to the docs/ tree, which no longer exists.
  Update it to refer to the separate leaflabs-docs repository.

* support/scripts/copy-to-ide: No longer build the documentation
2011-06-11 20:05:33 -04:00
Marti Bolivar 5c847fda31 Update Print to match Arduino master.
Add base argument to integral Print methods, defaulting to DEC so as
not to break backwards compatibility.  Add precision argument to
floating-point Print methods.

These changes increase compatibility with the Arduino Print
implementation.
2011-06-08 16:39:04 -04:00
Marti Bolivar 5ceb99bc29 Revert "Add wiring_limits.h"
This reverts commit f960c41b1a.

Wait until the Wiring spec is complete to merge this into master.
2011-06-07 16:51:40 -04:00
Marti Bolivar f960c41b1a Add wiring_limits.h
This file is analogous to the standard C header <limits.h>.  It
defines various constants within the Wiring language that we consider
to be implementation-defined.  The current version is a work in
progress; more constants may be added as time goes on.

The member constants defined in wiring_limits.h are currently limited
to the core Wiring language.  They do not include
implementation-defined values which pertain to the standard Wiring
libraries.
2011-06-07 15:37:27 -04:00
Marti Bolivar 450e1c6e17 Keep it 80-column clean.
Go through overlong source code lines and convert as many of them as
appropriate to be 80-column clean.  This mostly affects license
headers.  Overlong lines are determined by running following from the
libmaple base directory:

$ ack-grep --nocolor --nogroup --cpp --cc --ignore-dir=usb -- '.{80}'

Note that this excludes libmaple's usb subdirectory, which is still
full of ST code that doesn't follow the libmaple source code
guidelines.

Contents of ~/.ackrc (these won't matter, but are included for
completeness):

--ignore-dir=docs
--ignore-dir=build
--type-set
ld=.ld
--type-set
rst=.rst
--type-set
txt=.txt
--type-set
mk=.mk
2011-06-07 14:44:39 -04:00
Marti Bolivar 9d9275e7a0 Docs: Fix several board-specific values.
Ugh.

Fix BOARD_NR_ADC_PINS and boardADCPins on Maple, Maple Mini, and Maple
RET6 Edition:

Maple and Maple RET6 Ed. don't have ADC on pin 3.  Seems likely that
the error was due to AIN being missing on the silkscreen.  They also
have ADC on pin 13.  This is not really true due to the voltage drop
across the built-in LED.

Maple Mini really should not include BOARD_LED_PIN among its ADC pins,
since it's not broken out to a header.

Fix BOARD_NR_PWM_PINS and boardPWMPins on Maple and RET6 Ed:

Both boards falsely include pin 25 as a PWM pin.  Maple RET6 Edition
also lacks some PWM pins.

Fix BOARD_NR_SPI on Maple RET6 Edition:

SPI3 uses PB4, which is unusable since it's tied to NRST.  This means
that SPI3 is not available on the RET6 edition.  Decreasing
BOARD_NR_SPI to 2 to accomodate this.  Leave the BOARD_SPI3_*_PIN
defines intact so as not to further clutter the rest of the library
with RET6-specific wrinkles.
2011-05-26 02:42:07 -04:00
Marti Bolivar e3dfbf4b5b Getting rid of the last 0.0.10 TODO.
We should be good to go.
2011-05-23 10:18:39 -04:00
Marti Bolivar 3b9cc70fb2 HardwareSerial.h: adding documentation TODO for 0.1.0 2011-05-20 15:21:59 -04:00
Marti Bolivar cd723c2f0e adc.c: adc_init() doesn't set the RCC's ADC prescaler.
You have to call rcc_set_prescaler() yourself now.  adc_init() never
should have been doing that anyway.
2011-05-19 18:45:45 -04:00
Marti Bolivar 7444fc5a7a Punting the fix of Maple Native's boardUsedPins to 0.0.12. 2011-05-19 15:03:21 -04:00
Marti Bolivar f92d5f4865 Fixing HardwareSPI.h mistake for non-LeafLabs boards.
"#warn" -> "#warning"; oops.
2011-05-12 04:37:30 -04:00
Perry Hung 914db021c3 i2c: Various fixes, extensions, documentation.
-Fix clock calculations for fast-mode support
-Add I2C_REMAP option to remap i2c1 (untested)
-Add I2C_BUS_RESET option to reset bus on initialization
-Add optional timeout parameter
-Doxygen comments
-Various cleanup

10-bit slave addressing is untested until I have a device that speaks
such.
2011-05-12 04:07:33 -04:00
Marti Bolivar f3d44dfa4e Adding SPI3 definitions for Maple RET6 Edition. 2011-05-11 13:23:30 -04:00
Marti Bolivar ff5ae825d6 Converting all files to UNIX newlines.
Committing the results of running the following on the libmaple root
directory:

$ fromdos `grep --exclude-dir='[.]git' -Ilsr $'\r$' .`
2011-05-10 16:41:37 -04:00
Marti Bolivar a20c3966b5 Putting updated HardwareTimer back into the build.
HardwareTimer was removed from the build when the timer refactor was
done; this redoes it in terms of the new timer.h interface.  A variety
of conflicting or badly designed bits were deprecated or removed.

I'm still not satisfied with this interface, as it's going to make
life difficult moving forward to high-density chips, where the
addition of basic timers means that the capture/compare methods won't
apply in some cases.  However, we need to get 0.0.10 out the door, so
it'll have to do for now.

The docs are up to date, and contain a warning that the Wirish API
isn't stable and a recommendation to use libmaple proper.
2011-05-06 19:30:49 -04:00
Marti Bolivar 194084baed Renaming "enum ExtIntTriggerMode_" -> "enum ExtIntTriggerMode".
Done for consistency the rest of the source.  Doesn't affect any
documented features.
2011-05-05 15:38:58 -04:00
Marti Bolivar 6c427d285f SPI fixups.
Initial post-review changes based on thread here:

77f707d7b8 (comments)
2011-05-04 17:23:54 -04:00
Marti Bolivar 5cf58d39d4 Maple Mini pin map fix.
Thanks, Xavier!
2011-05-04 13:36:52 -04:00
Marti Bolivar bc745cd913 Making micros() counter underrun safe.
Thanks, ala42!
2011-05-04 13:31:53 -04:00
Marti Bolivar e7d5f4c167 SerialUSB fixups. 2011-05-04 13:31:53 -04:00
Marti Bolivar 837e649dba Fixing USBSerial::read(void*, uint32). 2011-05-04 13:31:53 -04:00
Marti Bolivar c436ffa1bb Native and FSMC cleanups.
Got rid of native_sram.h (and native_sram.cpp), and pushed their
functionality into maple_native.cpp.  Fixed includes in maple_native.h.

Fixed includes in fsmc.h.
2011-05-04 13:29:55 -04:00
Marti Bolivar 77f707d7b8 SPI refactor.
Still a polling driver, but the libmaple proper interface exposes
enough that users enable the various interrupts and define their own
IRQ handlers if they feel like it.

Wirish HardwareSPI interface was largely redone; it's more like the
Arduino implementation now, although there are some differences when I
didn't like their API.  The old methods are still there, but are
deprecated and slated for deletion in 0.1.0.

New board-specific values: BOARD_NR_SPI, BOARD_SPIx_NSS_PIN,
BOARD_SPIx_MOSI_PIN, BOARD_SPIx_MISO_PIN, and BOARD_SPIx_SCK_PIN, for
x from 1 to BOARD_NR_SPI.

Documentation was updated appropriately.
2011-04-28 14:23:30 -04:00
Marti Bolivar d4552d602c maple_native.cpp updates/fixes. 2011-04-27 17:38:55 -04:00
Marti Bolivar d5097adadf RET6 fixes 2011-04-27 15:33:06 -04:00
Marti Bolivar 95d1f62997 Removing Maple-specific values from WirinPinMode doxygen comment.
Comment changes only.
2011-04-26 03:27:33 -04:00
Marti Bolivar 2f07cb6f6c Better debug port support.
- gpio.h: afio_mapr_swj_config() renamed afio_cfg_debug_ports()

- [new] wirish_debug.h: disableDebugPorts(), enableDebugPorts()

- Maple, Maple Native, and Maple RET6 PIN_MAPs are now larger by 5,
  have mappings for the extra JTAG/SW pins.

  Documentation was updated appropriately.
2011-04-25 22:03:25 -04:00
Marti Bolivar 842096ba35 Minor Print cleanups. 2011-04-25 18:02:10 -04:00
Marti Bolivar 61ac368578 Updating Maple Native pins for prototype C. 2011-04-13 15:49:05 -04:00
Marti Bolivar f72d2948a8 Compromise Print implementation.
The users really hated the code size requirements for an snprintf()-based
Print implementation, but I really hated how bad the old implementation was.

Revised version fixes bugs related to printing 64-bit values and has some
improved behavior when it comes to printing doubles.  Now, instead of
happily printing garbage values when large doubles are printed, we try
printing "<large double>" or "-<large double>" (depending on sign) when
the argument is too big for the old strategy to accommodate.
2011-04-12 17:44:27 -04:00
Marti Bolivar b99df81845 Reverting "Rewrote Print class."
This reverts commit 8bd3cebbee.
2011-04-12 17:25:51 -04:00
Marti Bolivar 7ed7de1f12 Fixing brain-damaged abs() implementation. 2011-04-12 17:25:51 -04:00
Marti Bolivar 83f14f36d0 Doxygen bugfixes.
Fixed various Doxygen comment errors.
2011-04-12 00:08:54 -04:00
Marti Bolivar f604bb7b27 USART bugfix.
USART refactor commit f6f9a11227 only
worked for USART1.
2011-04-11 15:56:38 -04:00
Marti Bolivar c3fe9417e1 Adding CLOCK_SPEED_MHZ and CLOCK_SPEED_HZ as derived board-specific values. 2011-04-08 18:58:58 -04:00
Marti Bolivar f6f9a11227 USART refactor. 2011-04-07 13:18:36 -04:00
Marti Bolivar 6661d006e6 NVIC and SCB refactor 2011-04-05 13:59:33 -04:00
Marti Bolivar 32b7f0b240 Broke the build with previous commit; sorry. 2011-04-01 00:52:58 -04:00
Marti Bolivar b20009eddd Hacks to get things to compile in the IDE. 2011-03-30 13:57:33 -04:00
Marti Bolivar 6cf3178996 Board-specific values; corresponding QA test generalizations.
Various board-specific #defines and arrays of pins added.

For the changelog (some of this information predates this commit):

* wirish/boards.h now declares the following arrays of pin numbers:

      * boardPWMPins - PWM-capable pins
      * boardADCPins - ADC-capable pins
      * boardUsedPins - pins already in use, e.g. BOARD_BUTTON_PIN

  It also declares a bool boardUsesPin(uint8 pin) function for
  convenient testing of whether a pin is in use.

* wirish/boards/*.h now define:

      * BOARD_USART1_TX_PIN
      * BOARD_USART1_RX_PIN
      * BOARD_USART2_TX_PIN
      * BOARD_USART2_RX_PIN
      * BOARD_USART3_TX_PIN
      * BOARD_USART3_RX_PIN
      * BOARD_NR_GPIO_PINS (renamed from NR_GPIO_PINS)
      * BOARD_NR_USARTS (renamed from NR_USARTS)
      * BOARD_NR_PWM_PINS
      * BOARD_NR_ADC_PINS
      * BOARD_NR_USED_PINS

* wirish/boards/maple_native.h now defines:

      * BOARD_UART4_TX_PIN
      * BOARD_UART4_RX_PIN
      * BOARD_UART5_TX_PIN
      * BOARD_UART5_RX_PIN

  (Unfortunately, wirish/boards/maple_RET6.h cannot, since at least
  one of the UART4/UART5 pins are used already; this will require layout
  changes for a wide-release Maple form factor RET6 board).

* wirish/boards/*.cpp all include the corresponding array definitions.
  They all live in flash by default, thanks to the new __FLASH__ macro
  in wirish/wirish_types.h, which is a synonym for the existing __attr_flash
  #define in libmaple/libmaple_types.h.

The documentation was updated to include this information.  It also
gained various FIXME/TODO comments related to its generalization
across boards.

The quality assurance-related examples (examples/qa-slave-shield.cpp
and examples/test-session.cpp) now make heavy use of board-specific
values to ensure portability.
2011-03-30 07:19:13 -04:00
Marti Bolivar 949ae1d750 Removed Maple-specific information from digitalWrite() doxygen comment. 2011-03-30 05:59:33 -04:00
Marti Bolivar 19736152f3 Nitpicks 2011-03-30 03:45:08 -04:00
Marti Bolivar c5e16e9625 Final stm32_pin_info design candidate; ADC3 support on Native.
Added an adc_dev to struct stm32_pin_info.  This was necessary to add
support for the channels on the Native which are only connected to
ADC3, but it does add a bunch of NULLs to the PIN_MAPs.

I don't think any other peripherals need representation on a per-pin
basis.  Each peripheral library will be responsible for keeping track
of related GPIO ports and bits, and we can throw #defines in to
boards/*.h for other things (e.g. BOARD_SPI1_MISO_PIN).

Fleshed out the ADC refactor and brought it more in keeping with the
new design as it evolves.

A couple of other tweaks.  Notably: waitForButtonPress() now takes a
default argument meaning "wait forever".

Removed Maple-specific documentation from core functions in io.h; this
information will need to go into the individual board docs files.
2011-03-25 20:09:30 -04:00
Marti Bolivar 9d2b4e574c Adding /wirish/boards/ for easier porting; shrank PIN_MAPs.
/wirish/boards/ contains xxx.h and xxx.cpp (for xxx=maple,
maple_native, maple_mini, maple_RET6).  The headers contain the
board-specific #defines that used to live in boards.h (except
BOARD_INIT, which was removed).  The CPP files contain the PIN_MAP
definitions that used to live in boards.cpp, and a proper boardInit()
function to replace the old BOARD_INIT macro.  This will make it
easier to add new boards in the future.

struct PinMapping was renamed struct stm32_pin_info, and was moved
into a new wirish_types.h.  Its external interrupt field was moved
into struct gpio_dev, which saves memory by storing an afio_exti_port
per port, rather than one per pin.  Also rearranged the stm32_pin_info
fields to improve packing.  Maple's PIN_MAP is now down to below 500
bytes.
2011-03-24 17:31:47 -04:00
Marti Bolivar 296b1188bf Initial timer refactor.
Basic PWM works.  Had some problems in testing that might be due to
USART bugs.

HardwareTimer has been removed from the build for now; I will
re-implement it in terms of the new libmaple API, but consider it
deprecated.  Let's come up with something better.

Servo is implemented in terms of HardwareTimer, so it also has been
temporarily removed from the build.

pwmWrite() likely got a little bit less inefficient due to
indirection, but the PIN_MAPs shrank by a pointer per PinMapping.
2011-03-24 07:25:14 -04:00
Marti Bolivar 1ee7192493 Native PIN_MAP typo 2011-03-21 14:35:18 -04:00
Perry Hung 59f4a8a0df Merge branch 'i2c-wip' into refactor
Conflicts:
	examples/test-fsmc.cpp
	libmaple/rules.mk
	wirish/boards.h
2011-03-21 02:47:53 -04:00
Perry Hung eae720021d Revert "RCC refactor, bugfixes"
This reverts commit e4807a5010.
2011-03-21 02:25:23 -04:00
Marti Bolivar 009b229d54 FSMC refactor; SRAM test code 2011-03-17 01:49:40 -04:00
Marti Bolivar 580f0b6965 Maple RET6 edition support 2011-03-16 17:56:54 -04:00
Perry Hung 5a727766a7 Reenable other peripherals. 2011-03-15 19:46:47 -04:00
Perry Hung 4d92849452 Add rudimentary error handling for nack condition 2011-03-14 22:52:06 -04:00
Marti Bolivar e4807a5010 RCC refactor, bugfixes 2011-03-12 23:28:53 -05:00
Marti Bolivar 1ab2bdfb73 shiftOut(), docs fixes 2011-03-11 20:43:59 -05:00
Marti Bolivar 164148fa25 Oops. 2011-03-11 16:37:05 -05:00
Marti Bolivar 7c5c5bb118 [WIP] GPIO refactor: seems ok, ready for review 2011-03-11 16:24:44 -05:00
Perry Hung 3263998fca Fix merge error and compile error. 2011-03-11 00:45:33 -05:00
Perry Hung 6d302c059f Merge refactor into i2c-wip:
Squashed commit of the following:

commit 4d6662dadf
Merge: 174d9ab 7ddc844
Author: Marti Bolivar <mbolivar@leaflabs.com>
Date:   Fri Mar 4 23:18:29 2011 -0500

    Merge remote branch 'origin/refactor' into refactor

commit 174d9ab73c
Author: Marti Bolivar <mbolivar@leaflabs.com>
Date:   Fri Mar 4 23:16:53 2011 -0500

    USBSerial docs fix.

commit f217acb73d
Author: Marti Bolivar <mbolivar@leaflabs.com>
Date:   Fri Mar 4 20:25:26 2011 -0500

    Brought examples/ up to date; PIN_MAP bugfix for D24.

commit c4ba3ba05f
Author: Marti Bolivar <mbolivar@leaflabs.com>
Date:   Fri Mar 4 19:16:42 2011 -0500

    Cosmetic/documentation changes to adc.c

commit e7747b4eb8
Author: Marti Bolivar <mbolivar@leaflabs.com>
Date:   Fri Mar 4 19:16:07 2011 -0500

    Cosmetic changes to wirish/main.cxx

commit e2f9d4116e
Author: Marti Bolivar <mbolivar@leaflabs.com>
Date:   Fri Mar 4 19:15:24 2011 -0500

    Untabifying docs/source/conf.py

commit 7ddc84481b
Author: Perry Hung <iperry@gmail.com>
Date:   Wed Mar 2 00:30:19 2011 -0500

    cscope: Find .S instead of .s files

commit 62cb09ed63
Author: Marti Bolivar <mbolivar@leaflabs.com>
Date:   Wed Mar 2 00:07:10 2011 -0500

    Fixing typo in main.cpp.example.
2011-03-09 23:25:03 -05:00
Marti Bolivar f217acb73d Brought examples/ up to date; PIN_MAP bugfix for D24. 2011-03-04 23:16:32 -05:00
Marti Bolivar e7747b4eb8 Cosmetic changes to wirish/main.cxx 2011-03-04 19:16:07 -05:00
Marti Bolivar d6ef63b471 Cleaned out libmaple.h; this had wide-ranging implications.
Many of the #defines in libmaple.h were board-specific, not
MCU-specific.  Most of these were only used by code under
libmaple/usb/.  These were moved into usb_config.h, and are clearly
marked as being terrible hacks.  I'm going to treat the USB stack as a
black box that we'll deal with later.

Further, instead of having a variety of #defines like "How many USARTS
do I have?", we decide that based on the density of the chip.  This is
determined by testing for STM32_MEDIUM_DENSITY or STM32_HIGH_DENSITY
defines.  libmaple currently doesn't support low-density chips, so
that suffices.  The Makefile will set these automatically based on the
MCU.

Other offending #defines are ERROR_LED_PORT and ERROR_LED_PIN; these
were made optional, but they're set in the Makefile as a hack to keep
things working.
2011-02-27 11:42:56 -05:00
Perry Hung 4527ee7b9c Refactor ADC: Pass device pointer instead of register map 2011-02-27 07:37:19 -05:00
Perry Hung 0138947c8a Refactor DAC
DAC header and source slightly cleaned up. Test on Maple Native prototype. Add
flags parameter to allow selective enabling of channels.
2011-02-27 06:38:53 -05:00
Perry Hung 4a57d4ddac libmaple: Refactor ADC routines
ADC routines rewritten, support for ADC2, 3, added.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-02-27 04:58:43 -05:00
Marti Bolivar 5c48fdc187 Trivial wirish_digital.c sanity check + bugfix. 2011-02-25 13:15:07 -05:00
Marti Bolivar 8bd3cebbee Rewrote Print class.
The old Print class couldn't print uint64 values, and featured
hand-hacked functionality better handled by snprintf().  Redid it
using snprintf(), using "[u]int[8,16,32,64]" types for more clarity,
and eliminated some private methods in favor of auxiliary functions in
Print.cpp.

Breaking compatibility with original implementation in three ways:

  - Print::print(double) is now accurate to 6 digits, rather
    than 2; this is consistent with the default behavior of the %f
    format specifier, and if you're using floating point, it's slow
    enough that you probably want the increased accuracy.

  - The only bases you can print a number to are 2, 8, 10, and
    16.  8, 10, and 16 already have format specifiers, and 2 is an
    important special case; others complicate matters unnecessarily.

  - Printing numbers in bases other than 10 treats them as
    unsigned quantities (i.e., won't print '-' characters).  This is
    more consistent with C++'s behavior for hexadecimal and octal
    literals (e.g., 0xFFFFFFFF has type uint32).

Updated HardwareSerial and USBSerial class documentation to reflect
the new behavior.
2011-02-24 15:45:41 -05:00
Marti Bolivar f9fe35b46e Generalizing adc_init() to allow user to select sample time 2011-02-17 23:47:31 -05:00
Marti Bolivar 12914284f5 Merge branch 'nzmichaelh-master' into master.
This provides DMA, IWDG, PWR, and BKP support, and fixes several bugs.

Conflicts:
	libmaple/adc.h
	libmaple/libmaple.h
	libmaple/ring_buffer.h
2011-02-16 01:17:21 -05:00
Marti Bolivar cae9d414ca Merge branch 'debug-serialusb'
Conflicts:
	libmaple/usb/usb.c
	notes/coding_standard.txt
2011-02-12 03:09:40 -05:00
Marti Bolivar a93626ced8 Made Native prototype B definitions in libmaple.h and boards.h; added
notes/native-pin-definitions.txt (copied from ST datasheet).
2011-02-10 16:31:58 -05:00
Marti Bolivar 2e7fa60e43 nvic bugfix; removed unnecessary volatile usage 2011-01-31 00:19:36 -05:00
Marti Bolivar 635dfb6f59 Ported libmaple to the new mini prototype 2011-01-27 23:41:03 -05:00
Marti Bolivar 4dc4a0a28e Merge branch 'master' into debug-serialusb.
Chose debug-serialusb version in cases of conflict.

Conflicts:
	libmaple/usb/usb_callbacks.c
2010-12-21 10:27:37 -05:00
Marti Bolivar 88cb23747e Finalized 0.0.9 documentation. 2010-12-15 16:16:31 -05:00
Marti Bolivar e2a04cb048 Merge branch 'master' into newdoc 2010-12-14 15:41:17 -05:00
AJM ffc963692e fixed broken build from usb_serial.cpp
oops
2010-12-13 22:33:22 -05:00
AJM 13be968982 made SerialUSB.read blocking
it should have been blocking before but wasnt. see bug #49
2010-12-13 22:09:12 -05:00
Marti Bolivar 691f0cf6d0 Servo library tested and debugged.
Some additional HardwareTimer methods introduced to make this
convenient; ancillary libmaple/timers.h changes resulted.
2010-12-08 23:39:37 -05:00
Marti Bolivar 563770c353 added interrupts()/noInterrupts() 2010-12-02 17:15:43 -05:00
Marti Bolivar e1290a38cb maple mini prototype seems to be working 2010-11-30 21:31:17 -05:00
Marti Bolivar edc97211f6 Finished converting the Arduino docs 2010-11-29 01:49:26 -05:00
Marti Bolivar 88a16d144f arduino language reference nearing completion, properly CC-BY-SA 3.0 attributed 2010-11-17 12:44:28 -05:00
Marti Bolivar 2a73980456 fixed highByte() implementation for when sizeof(argument) > 2 2010-11-16 07:41:03 -05:00
Marti Bolivar abe45fd38e removed arduino/gpl dependency in bits.h; added binary notation for bytes (e.g. B10110011) 2010-11-10 03:22:18 -05:00
Marti Bolivar 8658f090c2 maple mini runs blinky now.
still need usb descriptors to improve, and also nothing else is tested.
2010-10-22 21:13:02 -04:00
Marti Bolivar 850db43290 Merge branch 'master' of github.com:leaflabs/libmaple 2010-10-14 23:31:33 -04:00
Perry Hung ab55cf348e Add selective enabling of channels for pwm channels
pinMode(PWM) turns the channel on, other modes should turn it off

Fixes bug with conflicting timer for spi1 and timer. This is not
well-tested.

Conflicts:
	libmaple/timers.c
2010-10-12 20:59:46 -04:00
Marti Bolivar 1d3f7c7831 more sphinx docs 2010-10-11 23:39:50 -04:00
Michael Hope 76e8745d80 Make systick.h C++ safe. Expose the sys tick count via systick.h and remove other externs. 2010-10-10 19:58:58 +13:00
Michael Hope 6fcd4cd306 Merge remote branch 'upstream/master' 2010-09-29 20:45:57 +13:00
Michael Hope 368e4fc166 Fixed up the build due to a missing header file. 2010-09-29 20:42:18 +13:00
Perry Hung adde11b099 Fix HardwareSPI to pass SPI modes for CPOL and CPHA 2010-09-28 19:21:16 -04:00
Marti Bolivar 994f1f1e36 cleanups 2010-09-27 00:51:11 -04:00
Marti Bolivar 849bc0f8f6 wirish reformatted and code-styled 2010-09-26 21:47:55 -04:00
Perry Hung c13e850abe Enable external interrupts on all Maple GPIOs.
Extend the wirish attachInterrupt() and detachInterrupt() interface to
work with all GPIOs.

Note: The STM32 external interrupt lines are multiplexed between GPIO
ports. While any GPIO can be used as an external interrupt, not all of
them can be used at the same time. Each EXTI[n] line selects between
PA[n], PB[n], PC[n], etc. For example, line EXTI5 can be used with STM32
pins PA5, PB5, or PC5, but not all at the same time. See table:

EXTI Line       Maple Pin       STM32 Pin
  0             D2              PA0
  0             D27             PB0
  0             D15             PC0
  1             D3              PA1
  1             D28             PB1
  1             D16             PC1
  2             D1              PA2
  2             D17             PC2
  2             D25             PD2
  3             D0              PA3
  3             D18             PC3
  4             D10             PA4
  4             D19             PC4
  5             D13             PA5
  5             D4              PB5
  5             D20             PC5
  6             D12             PA6
  6             D5              PB6
  6             D35             PC6
  7             D11             PA7
  7             D9              PB7
  7             D36             PC7
  8             D6              PA8
  8             D14             PB8
  8             D37             PC8
  9             D7              PA9
  9             D24             PB9
  9             D38             PC9 (BUT)
 10             D8              PA10
 10             D29             PB10
 10             D26             PC10
 11             D30             PB11
 12             D31             PB12
 13             D32             PB13
 13             D21             PC13
 14             D33             PB14
 14             D22             PC14
 15             D34             PB15
 15             D23             PC15
2010-09-22 03:17:45 -04:00
Perry Hung 943006daef Add PWM_OPEN_DRAIN option to pinMode()
Allow for alternate function open drain output mode to be accessed
through the wirish interface. This allows for open drain to be used on
PWM pins.
2010-09-21 20:24:04 -04:00
Marti Bolivar ee5667f54d bugfix MAPLE_RELOAD_VAL, whitespace fixes 2010-09-13 13:32:01 -04:00
bnewbold 5bfeb40e47 systick testing and simplification
ripped out marti's SystemTick for the sake of simplicity and added a
systick_resume function to libmaple. new example program demonstrates
the functionality, also demonstrates micros()/USB bug
2010-09-05 23:48:31 -04:00
bnewbold b6e3624a70 timer refactor (c, not c++)
also removed an old ASSERT()
2010-09-05 22:58:36 -04:00
bnewbold 1c6f9a9b5e Off-by-one in timer setPeriod() function
Thanks CarlO!
2010-09-02 22:29:36 -04:00
bnewbold 6783e66eb1 added 'unused' attribs and reset default target 2010-09-02 19:23:22 -04:00
bnewbold d6a3299168 Various fixes, working with Maple 2010-09-01 00:02:36 -04:00
bnewbold 0ccec95446 Portability fixes
Still not working but fixed a lot of merge errors
2010-08-31 22:05:39 -04:00
Marti Bolivar 9c9d6c1531 added support to enable/disable systick in wirish 2010-08-31 18:28:07 -04:00
bnewbold 02d7b08f04 Merge maple-native changes into portable
This compiles for both maple and maple_native but is untested.
2010-08-31 17:39:46 -04:00
bnewbold e03d58f4da Further wirish portability progress
Sort of ugly changes. Compiles but untested.
2010-08-31 17:17:57 -04:00
bnewbold 01c38f5567 Partial progress on wirish portability
This version throws "defined but unused" warnings which could probably
be squashed with #pragma
2010-08-31 16:28:23 -04:00
Marti Bolivar b10ef4875f fix reset.py to work on OS X,; .gitignore leaves out ~ files; cleanup
support/make/build-rules.mk
2010-08-29 02:07:32 -04:00
bnewbold 12c351d056 inital portability work 2010-08-25 22:57:46 -04:00
Perry Hung f5a28b3084 Removed typedef enum for external interrupts, should function. Note
that there's no LOW option.
2010-08-19 22:50:32 -04:00
bnewbold ccd9833f26 Some refactoring 2010-08-05 21:43:58 -04:00
Perry Hung d249461115 Cleaned up wirish/time, some interrupt handling refactoring:
Fixed millis(), it was just wrong, before.
Added micros(), not extensively tested.
New implementation of delayMicroseconds(). Should be more consistent
now.
Added a handful of nvic routines to enable/disable interrupts.
Cleaned up systick
2010-08-04 08:52:30 -04:00
Perry Hung c58c7dbe18 New usart implementation:
Fixed a bug where the maximum baud rate was incorrectly set to 225000
General cleanup
Use new rcc and nvic APIs
2010-08-04 04:38:58 -04:00
Perry Hung 57df5396fe New reset and clock control api 2010-08-04 04:29:02 -04:00
Perry Hung 2bb8c3fbe3 Basic flash peripheral management api for board bringup 2010-08-04 04:17:16 -04:00
bnewbold 31f9eb2364 last usbserial change... please? 2010-07-22 20:33:53 -04:00
bnewbold 99c251b846 added isConnected() to serialusb 2010-07-22 18:24:51 -04:00
bnewbold f728985846 went with 50ms SerialUSB timeout 2010-07-20 22:03:52 -04:00
bnewbold 895d2a48fa wirish implementation of timers plus test 2010-07-20 15:37:44 -04:00
bnewbold dd52d66d03 timers progress
examples code cleanup, more descriptive comments, more notes
2010-07-20 15:37:09 -04:00
bnewbold f06fcac502 good quality vga leaf logo; usb+systick disabled
refactored timers and added interrupt behavior. see notes and
comments...  also includes a crude vga hack that doesn't use timers.
2010-07-20 15:36:44 -04:00
bnewbold 52cbd2f1a1 working serialUSB with timeout
as a temporary workaround for the fact that SerialUSB is often blocking,
this crude implementation makes the low-level C usbSendBytes function
non-blocking (with a return code of bytes sent) and implements a 2ms
timeout in the wirish write() function.

also adds begin(), end(), getDTR(), getRTS(), pending(). device is still
initialized the old fashioned way during init() so that, eg, autoreset
will work. includes a simple multi-test program.
2010-07-19 00:38:36 -04:00
bnewbold 432cf91f7d added Serial.flush() 2010-07-19 00:38:00 -04:00
bnewbold a852f8d6a6 added SerialN.end() 2010-07-18 23:25:03 -04:00
Perry Hung 2c043efb66 make: Modularize makefiles, add dependency tracking, build-type tracking
Major build system rewrite. New and exciting:

1. Proper dependency tracking. All source files including header files
should be properly tracked and recompiled as necessary when they are
changed.

2. Build-type tracking. If the target changes from 'ram' to 'flash,'
for example, the build system will force a rebuild rather than
incorrectly link modules to a different address.

3. New targets:
   The old 'ram,' 'flash,' and 'jtag' targets have been replaced with
the environment variable MAPLE_TARGET, which controls the link address.
Users can either export it to their environment, or pass MAPLE_TARGET on
the command-line. Once this is set, sketches can be compiled with 'make
sketch,' or simply 'make.'

Note: the default is MAPLE_TARGET='flash.'

The target 'install' now automagically uploads the sketch to the board
using the appropriate method.

The 'run' target has been renamed to 'debug.' It starts an openocd gdb
server.

4. Odds and ends:
  -Verbose and 'quiet' modes. Set V=1 for verbose compilation, the default
   is quiet.
  -Object file sizes and disassembly information is generated and placed
   in build/$(BOARD).sizes and build/$(BOARD).disas, respectively.
  -Parallel make with -j should speed things up if you have multiple
   cores.
2010-06-25 21:23:04 -04:00
xttocs 70a18f96b6 Support for Arduino's LiquidCrystal lib, which may help for a few other libs too.
Signed-off-by: Perry Hung <iperry@alum.mit.edu>
2010-06-23 19:23:45 -04:00
AJM cb1a6fbc21 added getDTR and getRTS to usb.h, subtly modded how sendBytes checks for connection
flip flopped back and forth on how much work should be done here. For now its like 5 lines of changes
2010-06-11 13:03:09 -04:00
Perry Hung 717060ef8c USB Serial read() fix:
stupid, stupid mistake.
2010-06-05 22:35:43 -04:00
Perry Hung 88d4b095e4 Preliminary wirish USBSerial implementation.
-updated examples
-removed HardwareUSB
-cleaned up a handful of includes
2010-06-04 00:43:21 -04:00
bnewbold cf068bc0ac [for AJ] added new HardwareUsb implementation. hack. 2010-05-27 23:37:48 -04:00