Commit graph

262 commits

Author SHA1 Message Date
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