Commit graph

38 commits

Author SHA1 Message Date
Marti Bolivar ef217b7434 libmaple/rcc.c: Fix typo.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar 5108a85dfd rcc.c: Fix typo.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 17:24:17 -04:00
Marti Bolivar 454aab10af RCC: Add rcc_is_clk_on().
This is a convenience function for checking if a clock line is on.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar f20a281077 RCC: Clean up and sanitize interfaces across F1, F2 series.
Additions:

- rcc_switch_sysclk():

  For changing the clock used as SYSCLK's source.

- enum rcc_clk:

  One for each system and secondary clock source (e.g. HSE,
  LSE). These are defined on a per-series basis in each of the
  <series/rcc.h>.

- rcc_turn_on_clk(),
  rcc_turn_off_clk(),
  rcc_is_clk_ready():

  For turning on system and secondary clock sources, and checking
  whether or not they're ready. Uses enum rcc_clk.

Removals:

- rcc_clk_init(): There's no way to port this to F2. Move it to the F1
  header. This also means we can remove the empty implementation and
  enum rcc_pll_multiplier from the F2 RCC header, where it doesn't
  make any sense.

Also fix up some includes, and rewrite rcc_clk_init() in terms of the
new clock source management functions.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:54 -04:00
Marti Bolivar 3dd4f375c5 RCC: Break out some portable functionality from stm32f1/.
Portions of rcc_clk_enable(), rcc_reset_dev(), and rcc_set_prescaler()
are portable; break these into static inline helpers in
rcc_private.h. These guts of these are portable, but the arrays of
registers etc. are not.

Also add an extern declaration for rcc_dev_table into
rcc_private.h. This lets us put rcc_dev_clk() into a newly resurrected
libmaple/rcc.c, since that's portable.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:51 -04:00
Marti Bolivar 32b267512f Move RCC support for STM32F1 to libmaple/stm32f1/.
This is a backwards-compatible change.

Modify libmaple/rules.mk to include the family's include
directory. This allows libmaple/include/libmaple/rcc.h to include the
STM32F1 RCC header with #include <family/rcc.h>. We'll use this
convention henceforth to distinguish between top-level and
family-specific headers.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:51 -04:00
Marti Bolivar 954f9e5065 Move public headers to include directories; related cleanups.
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>
2012-04-11 16:56:50 -04:00
Marti Bolivar 958ead333f rcc: Add RCC_USB to rcc_clk_id/rcc_dev_table.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-09-24 16:02:31 -04:00
Michael Hope b9be2450f0 Added more doxygen file level headers. Documented a few more functions.
Signed-off-by: Michael Hope <michaelh@juju.net.nz>
2011-09-13 19:35:12 +12:00
Marti Bolivar 97e4a6d8a6 rcc: Doxygen improvements. 2011-08-22 23:29:55 -04:00
Marti Bolivar 48d00170f6 rcc.c: Trivial comment tweak. 2011-06-20 15:21:39 -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
Perry Hung c9775ff15c libmaple: Fix warnings in libmaple source files
-Add -Wall, -Werror to libmaple/*
-Fix warnings
2011-05-12 05:00:47 -04:00
Marti Bolivar 7d0445ec14 Adding RCC_SPI3 for high density devices. 2011-04-29 12:02:51 -04:00
Marti Bolivar 4941335ab8 Adding rcc_dev_clk(), an accessor for a peripheral's clock line. 2011-04-25 22:08:30 -04:00
Anton Eltchaninov 1c05ac8497 Adding i2c2 and i2c fast mode
Signed-off-by: Anton Eltchaninov <anton.eltchaninov@gmail.com>
2011-04-12 13:21:15 +07:00
Marti Bolivar c8c070905c RCC refactor.
Older refactor commit e4807a5010 used
bit-banding in rcc_clk_init() to set RCC_CR_HSEON, which doesn't work
for some reason.  Not going to try to figure out why.
2011-03-21 14:42:46 -04:00
Perry Hung 3263998fca Fix merge error and compile error. 2011-03-11 00:45:33 -05:00
Perry Hung 0f6c617b44 i2c merge 2011-02-28 18:16:03 -05:00
Marti Bolivar e82e80a1a7 Refactor backup (BKP) and power (PWR) routines. 2011-02-27 06:06:12 -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
Perry Hung 443953ac94 checkpoint 2011-02-26 22:30:22 -05:00
Marti Bolivar 5ea4b56515 Basic DAC functionality (high-density devices only). 2011-02-18 04:00:00 -05:00
Marti Bolivar 620740bf19 undoing USART[45] -> UART[45] mistake 2011-02-15 20:00:10 -05:00
Michael Hope 5b85643816 Added DMA1 and DMA2 to the RCC 2010-10-20 21:05:38 +13:00
Marti Bolivar 753f89de35 whitespace cleanups 2010-09-27 00:40:44 -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 12c351d056 inital portability work 2010-08-25 22:57:46 -04:00
bnewbold ccd9833f26 Some refactoring 2010-08-05 21:43:58 -04:00
Perry Hung 6d8b91106f Switch spi to use new rcc interface 2010-08-04 09:10:46 -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 d0e353ca9f rename clock selection register
This is just a change of macro name with zero impact on the actual
binary. Looking at page 87/1003 of the STM reference manual, bits [0:1]
are the SW register which is modifiable by software, while [2:3] are SWS
and are set only by hardware.
2010-07-24 16:33:34 -04:00
Perry Hung 87c85a6449 Licensing: Relicensed libmaple under the MIT License.
Relicensed the bulk of libmaple under the more permissive MIT License,
from GPLv3. Files that were largely or entirely derived from
the Arduino, STM, or Lanchon retain their original licenses.
2010-03-31 22:43:27 -04:00
Perry Hung 25c7ba0ed7 Removed inttypes.h
Removed inttypes.h from libmaple. Will have another pass through to use
the standard libmaple types, but will come in another commit.
2010-03-31 21:29:29 -04:00
Perry Hung 869ed39e4c Removed STM32 flash code, replaced with barebones hacks for now.
At this point, there shouldn't be any STM code being compiled and linked
against. There are still a bunch of STM header includes, though.
2010-03-30 22:51:28 -04:00
Perry Hung 2c33d55bae Merge branch 'master' into rcc-dev
Conflicts:
	Makefile
2010-03-30 22:03:00 -04:00