Commit Graph

865 Commits

Author SHA1 Message Date
Dave Hylands f380904bd9 stmhal: Print exception information in nlr_jump_failed
Currently nlr_jump_fail prints that there was an uncaught exception
but nothing about the exception.
This patch causes nlr_jump_failed to try to print the exception.
Given that printf was called on the line above, I think that
the call to mp_obj_print_exception has about as much likelyhood
of succeeding as the printf does.
2015-12-07 17:21:51 +00:00
Dave Hylands acc208418b stmhal: Execute boot.py and main.py when formatting the file system.
When you use the USER button to perform a filesystem reset
at boot time then it wipes out the filesystem and creates
a new boot.py and main.py.  With this patch these files are
executed after formatting, ensuring that pyb and machine modules
get imported.
2015-12-07 15:11:42 +00:00
Ryan Shaw c03dd3b2f9 stmhal: Fix uart off by 1 circular buffer size. 2015-12-04 22:20:47 +00:00
Damien George 66b96822fb stmhal: Add option to free up TIM3 from USB VCP polling.
This is a hack to free up TIM3 so that it can be used by the user.
Instead we use the PVD irq to call the USB VCP polling function, and
trigger it from SysTick (so SysTick itself does not do any processing).

The feature is enabled for pyboard lite only, since it lacks timers.
2015-12-04 14:07:15 +00:00
Damien George dd7d2e0810 stmhal: Only use BASEPRI irq stuff if Cortex is M3 or higher. 2015-12-04 12:13:12 +00:00
Damien George f7697ff393 stmhal: Add rtc.init() method to force RTC to re-initialise. 2015-12-04 12:05:05 +00:00
Damien George f4c17378b3 stmhal: Protect SD card DMA transactions against USB MSC contention.
Consider the following scenario: SD card is being read by pyboard; USB
irq comes in for MSC read request; SD card needs to be read from within
USB irq while SD read is already ongoing.  Such contention needs to be
avoided.

This patch provides a simple solution, to raise the irq priority above
that of the USB irq during SD DMA transfers.  Pyboard and PC can now
read from the SD card at the same time (well, reads are interleaved).
2015-12-04 11:39:21 +00:00
Damien George 95c9cc8114 stmhal: Add raise_irq_pri and restore_irq_pri functions.
These can be used to disable only certain interrupts, ones at or above
the given priority value.
2015-12-04 11:38:23 +00:00
Dave Hylands 0077958ad0 stmhal: Put all DMA channel & stream definitions in dma.h 2015-12-02 22:55:57 +00:00
Damien George e9a684d741 stmhal: Add board config files for PYBv1.1 and PYBLITEv1.0. 2015-12-02 12:47:09 +00:00
Damien George 0d9b450701 stmhal: Make uart.write() function correctly for timeout=0.
In non-blocking mode (timeout=0), uart.write() can now transmit all of its
data without raising an exception.  uart.read() also works correctly in
this mode.

As part of this patch, timout_char now has a minimum value which is long
enough to transfer 1 character.

Addresses issue #1533.
2015-11-30 17:29:52 +00:00
Ryan Shaw f99491cbf7 stmhal: uart.any() function now returns number of bytes available. 2015-11-30 13:07:20 +00:00
Dave Hylands 3048433809 stmhal: Make stm.mem* support large integers.
With these you can now do things like:

stm.mem32[0x20000000] = 0x80000000

and read 32-bit values. You can also read all the way to the end
of memory using either stm.mem32[0xfffffffc] or stm.mem32[-4].

IRQs shouldn't use mem32 at all since they'd fail if the top 2 bits
weren't equal, so IRQs should be using 16-bit I/O.
2015-11-26 22:19:42 +00:00
Dave Hylands 061eb6fa6b stmahl: Fix usbd_conf.c for devices which don't have USB_HS at all.
The STMCube examples define both USE_USB_HS and USE_USB_HS_IN_FS when they
use the HS in FS mode.

The STM32F401 doesn't have a USB_HS at all, so the USB_OTG_HS instance
doesn't even exist.
2015-11-26 16:17:26 +00:00
Dave Hylands 364bb61df3 stmhal: Allow make DEBUG=1 to build 2015-11-26 00:04:34 +00:00
Tobias Badertscher 8844d031e4 stmhal: Add support for the STM32F429I-DISCO kit by STMicro. 2015-11-25 23:53:26 +00:00
Paul Sokolovsky f0fbab7ca7 extmod/fsusermount: Make configurable with MICROPY_FSUSERMOUNT. 2015-11-25 13:19:36 +02:00
Paul Sokolovsky 3a1bbcc2ef extmod: Move fsusermount.c from stmhal for cross-port reuse. 2015-11-25 13:19:36 +02:00
Dave Hylands c8437f97ae stmhal: Increase the priority of UART IRQ.
The UARTs have no FIFOs, so if interrupts are disabled
for more than a character time (10 usec at 1 Mbit/sec)
then characters get dropped.

The overhead for handling a UART ISR is about 0.5 usec,
so even at baud rates of 1 Mbit/sec this only corresponds
to about 5% of the CPU. Lower baud rates will have less
of an impact.
2015-11-25 08:03:44 +00:00
Damien George 65888e2006 stmhal: Process storage idle tick handler in different slot to DMA. 2015-11-24 16:57:13 +00:00
Damien George 36bd10779c stmhal: In SysTick IRQ handler, make uwTick variable non-volatile.
uwTick can only change in the SysTick IRQ so this IRQ function does not
need to take special care with this variable.  It's important to make
this IRQ function as efficient as possible.
2015-11-24 16:23:54 +00:00
Damien George e99e6c883d stmhal: Move flash storage idle tick handler from TIM3 to SysTick.
Using SysTick to do the counting and dispatch of the flash storage idle
handler is more efficient than requiring a dedicated hardware timer.
No new counter is needed, just the existing uwTick variable.  The
processing is not actually done in the SysTick IRQ, it is deferred to
the flash IRQ (which runs at lower priority).
2015-11-24 16:18:07 +00:00
Damien George 3cfb02f166 stmhal/irq: Set all IRQ subpriorities to 0, since they aren't used. 2015-11-24 15:56:33 +00:00
Damien George 18820471ae stmhal/irq: Add comment about SDIO priority being higher than DMA. 2015-11-24 15:51:07 +00:00
Damien George 22bd23114a stmhal: On SysTick IRQ, only process one DMA channel at a time.
This can be generalised if/when more processing is needed by SysTick.

Thanks to @chuckbook for the idea.
2015-11-24 15:44:16 +00:00
Damien George 9936aa3f87 stmhal: Save RAM and ROM by making SD DMA init structure const for tx/rx. 2015-11-24 15:44:16 +00:00
Damien George 522d454e34 stmhal: Small simplification of code to tickle DMA idle counter. 2015-11-24 15:44:16 +00:00
Dave Hylands 6edffd0df5 stmhal: Add dma support for sdcard.
This started out using IgorLektorovEpam work in PR #1389
and reworked it.
2015-11-24 09:37:25 +00:00
Dave Hylands b677f03407 stmhal: Turn off DMA clocks when idle for 100 msec
Turning on each DMA block increases the current consumption
by about 8 mA. This code adds an idle timer for each DMA
block and turns off the clocks when no streams are in use
for 128 msec. Having a small timeout allows for improved
performance when back-to-back transfers are being performed.

The 128 msec is basically a guess.
2015-11-24 09:37:25 +00:00
Dave Hylands 9f5486c7e2 stmhal: Put IRQs into priority order.
- added some comments to explain the priority/sub-priority.
- adds an entry for SDIO (to be used in a later patch)
- increases DMA priority above USB so that DMA can be used
  for sdcard I/O when using USB Mass Storage.
2015-11-24 09:37:25 +00:00
Damien George 056abbcf31 stmhal: Fix unused variables when HW_CLK_LAST_FREQ not defined. 2015-11-23 23:52:09 +00:00
T S 86aa16bea6 stmhal: Implement delayed RTC initialization with LSI fallback.
If RTC is already running at boot then it's left alone.  Otherwise, RTC is
started at boot but startup function returns straight away.  RTC startup
is then finished the first time it is used.  Fallback to LSI if LSE fails
to start in a certain time.

Also included:
 MICROPY_HW_CLK_LAST_FREQ
        hold pyb.freq() parameters in RTC backup reg
 MICROPY_HW_RTC_USE_US
        option to present datetime sub-seconds in microseconds
 MICROPY_HW_RTC_USE_CALOUT
        option to enable RTC calibration output

CLK_LAST_FREQ and RTC_USE_CALOUT are enabled for PYBv1.0.
2015-11-23 23:23:07 +00:00
Paul Sokolovsky 16d42368a6 stmhal/modmachine: Initial attempt to add I2C & SPI classes.
In new hardware API, these classes implement master modes of interfaces,
and "mode" parameter is not accepted. Trying to implement new HW API
in terms of older pyb module leaves variuos corner cases:

In new HW API, I2C(1) means "I2C #1 in master mode" (? depends on
interpretation), while in old API, it means "I2C #1, with no settings
changes".

For I2C class, it's easy to make mode optional, because that's last
positional param, but for SPI, there's "baudrate" after it (which
is inconsistent with I2C, which requires "baudrate" to be kwonly-arg).
2015-11-14 16:14:08 +02:00
Paul Sokolovsky 73ff0687f2 lib/utils/printf: Move from stmhal/ .
This file contains various MicroPython-specific helper functions, so isn't
good fit for lib/libc/.
2015-11-10 18:58:58 +02:00
Paul Sokolovsky 746b752b8e stmhal/moduselect: Expose POLLIN/OUT/ERR/HUP constants.
This makes select.poll() interface fully compatible with CpYthon. Also, make
their numeric values of these options compatible with Linux (and by extension,
with iBCS2 standard, which jopefully means compatibility with other Unices too).
2015-11-09 22:10:31 +02:00
Damien George 40274fec9c lib/pyexec: Move header pyexec.h from stmhal directory. 2015-11-09 13:13:09 +00:00
Alex March 748509a93c stmhal: FatFS configuration moved to the library folder.
Port specific settings defined in mpconfigport.
2015-11-08 22:21:17 +00:00
Dave Hylands 57e00ef262 stmhal: Fix RTC code to work on the F7 2015-11-07 09:42:26 -08:00
Dave Hylands 41b688e25f stmhal: Print more information at HardFault time. 2015-11-07 13:59:00 +00:00
Tony Abboud ae58035573 stmhal: Add missing regex property for parsing header comments 2015-11-06 23:32:55 +00:00
T S 8f7ff854b0 stmhal/rtc: LSx oscillator is only initialized upon initial power up.
Initial power up also includes VBAT.

If LSE is configured but fails to start, LSI is used until next full power
cycle.  Also handles STM32F7xx variant.
2015-11-06 22:00:34 +00:00
Henrik Sölver 35e7d9c0f1 stmhal/can: Fix a bug in filter handling.
Reported here: http://forum.micropython.org/viewtopic.php?f=2&t=845
2015-11-02 23:09:49 +00:00
Dave Curtis 32b3549cce stmhal: Add symbolic #defines for interrupt levels in irq.h. 2015-11-01 23:23:39 +00:00
Paul Sokolovsky 0ec51441de stmhal: pyexec.c is common module, move to lib/utils/ . 2015-10-31 19:35:10 +03:00
Damien George 731f359292 all: Add py/mphal.h and use it in all ports.
py/mphal.h contains declarations for generic mp_hal_XXX functions, such
as stdio and delay/ticks, which ports should provide definitions for.  A
port will also provide mphalport.h with further HAL declarations.
2015-10-31 19:14:30 +03:00
Damien George f705cb5f7a stmhal: Update PYBv3 and PYBv4 pin defs to include MMA pins, and others. 2015-10-31 11:14:15 +00:00
Dave Hylands 165734522e stmhal: f7: Fix recent RTC change to build on F7. 2015-10-30 23:40:00 +00:00
Peter Hinch 3819634469 stmhal: Make RTC init skip startup if LTE is already enabled and ready.
This prevents the loss of RTC time when exiting from standby mode, since
the RTC is paused while it is being re-inited and this loses about 120ms.

Thanks to @chuckbook for the patch.
2015-10-30 13:13:42 +00:00
Dave Hylands b83d0b35e9 stmhal: Add define for UNIQUE_ID address (differs per MCU) 2015-10-30 12:53:14 +00:00
Dave Hylands 823a961ecc stmhal: Enable sdcard on STM32F7DISC board. 2015-10-30 12:05:14 +00:00
Damien George 6f70283909 stmhal: Make accel AVDD pin configurable via mpconfigboard.h. 2015-10-29 22:40:42 +00:00
Paul Sokolovsky 19b671c5cd stmhal/moduselect: Use mp_hal_ticks_ms(). 2015-10-29 20:42:12 +03:00
Paul Sokolovsky 04fa999cfe stmhal/pyexec: Use mp_hal_ticks_ms().
This file is actually port-generic and should be moved out of stmhal/ .
Other ports already use it, and thus it should use mp_hal_ticks_ms()
right away.
2015-10-29 19:35:27 +03:00
Paul Sokolovsky 404dae80a9 unix, stmhal: Introduce mp_hal_delay_ms(), mp_hal_ticks_ms().
These MPHAL functions are intended to replace previously used HAL_Delay(),
HAL_GetTick() to provide better naming and MPHAL separation (they are
fully equivalent otherwise).

Also, refactor extmod/modlwip to use them.
2015-10-27 23:31:42 +03:00
Damien George 79f404a287 stmhal: Fix USB_VCP.recv so that it returns actual amount of bytes read.
Addresses issue #1529.
2015-10-25 21:43:07 +00:00
Paul Sokolovsky 4a9c60cdfb stmhal: Typo fix in comment. 2015-10-24 21:58:58 +03:00
Paul Sokolovsky 81a1e17238 stmhal/ffconf.h: Include py/mpconfig.h.
mpconfigport.h is a private, partial header not providing correct settings
unless included by py/mpconfig.h.
2015-10-24 18:33:43 +03:00
Paul Sokolovsky 0dbd928cee Makefiles: Remove duplicate object files when linking.
Scenario: module1 depends on some common file from lib/, so specifies it
in its SRC_MOD, and the same situation with module2, then common file
from lib/ eventually ends up listed twice in $(OBJ), which leads to link
errors.

Make is equipped to deal with such situation easily, quoting the manual:
"The value of $^ omits duplicate prerequisites, while $+ retains them and
preserves their order." So, just use $^ consistently in all link targets.
2015-10-24 15:46:53 +03:00
Damien George 9d0192de4a stmhal: Enable "all special methods" configuration option. 2015-10-20 23:55:27 +01:00
Damien George 60401d461a stmhal/rtc: Fix indentation to use spaces rather than tabs. 2015-10-20 12:05:27 +01:00
Peter Hinch b106532b32 stmhal/rtc: Init uses YMD rather than backup register to detect powerup. 2015-10-20 12:05:16 +01:00
Damien George 2f96b1982a stmhal: Bring Pin class close to new machine module specification.
Looks like we can use the same Pin class for legacy pyb module and new
machine module.
2015-10-19 22:50:59 +01:00
Paul Sokolovsky bedab235f9 stmhal/uart: If char is not received within timeout, return EAGAIN error.
Instead of return 0, which means EOF. There's no good way to detect EOF on
continuously active bus like UART, and treat timeout as just temporary
unvailability of data. .read() method of UART object will return None in
this case (instead of 0, which again measn EOF). This is fully compliant
with unix port.
2015-10-20 00:27:07 +03:00
Damien George 83158e0e7f stmhal: Implement os.dupterm (was pyb.repl_uart).
pyb.repl_uart still exists but points to os.dupterm.
2015-10-19 21:57:41 +01:00
Damien George d8066e999d stmhal: Add sleep_{ms,us} and ticks_{ms,us,cpu,diff} to time module.
pyb module still has pyb.delay and pyb.udelay, but these now point to
time.sleep_ms and time.sleep_us respectively.
2015-10-19 21:45:51 +01:00
Dave Hylands 504420c51d stmhal: Early version of machine module for stmhal. 2015-10-19 21:12:42 +01:00
Paul Sokolovsky e0f5df579b all: Make netutils.h available to all ports by default.
Generally, ports should inherit INC from py.mk, append to it, not
overwrite it. TODO: Likely should do the same for other vars too.
2015-10-19 18:32:42 +03:00
Dave Hylands affcbe4139 stmhal: Make USB serial number actually be unique. 2015-10-17 22:02:57 +01:00
Damien George b5c43be135 stmhal: Allow to set bits resolution for DAC; 8 is default, can have 12.
This patch allows to configure the DAC resolution in the constructor and
in the init function, eg:

dac = DAC(1, bits=12).

The default resolution is 8 bits for backwards compatibility.  The bits
sets the maximum value accepted by write and write_timed methods, being
2**bits - 1.

When using write_timed with 12-bit resolution, the input buffer is
treated as an unsigned half-word array, typecode 'H'.

See PR #1130 for discussion.
2015-10-13 14:33:04 +01:00
Damien George 0334058fa4 Rename "Micro Python" to "MicroPython" in REPL, help, readme's and misc. 2015-10-12 00:06:25 +01:00
Damien George 6206f431cf stmhal: Enable REPL auto indent; document paste mode in help(). 2015-10-11 23:33:46 +01:00
Damien George 46a1102852 repl: Add paste mode to friendly REPL, entered via CTRL-E.
Use CTRL-E to enter paste mode.  Prompt starts with "===" and accepts
all characters verbatim, echoing them back.  Only control characters are
CTRL-C which cancels the input and returns to normal REPL, and CTRL-D
which ends the input and executes it.  The input is executed as though
it were a file.  The input is not added to the prompt history.
2015-10-11 23:30:22 +01:00
Paul Sokolovsky 1b586f3a73 py: Rename MP_BOOL() to mp_obj_new_bool() for consistency in naming. 2015-10-11 15:18:15 +03:00
Dave Hylands 01d64914c5 stmhal: Fix USB CDC-only mode under Windows.
This fix adds PIDs 9801 and 9802 to the pybcdc.inf file.

When in CDC only mode, it presents itself as a Communcations
device rather than as a composite device. Presenting as a
composite device with only the CDC interface seems to confuse
windows.

To test and make sure that the correct pybcdc.inf was being used,
I used USBDeview from http://www.nirsoft.net/utils/usb_devices_view.html
to uninstall any old pyboard drivers (Use Control-F and search
for pyboard). I found running USBDeview as administrator worked best.

Installing the driver in CDC+MSC mode first is recommended (since the
pybcdc.inf file in on the internal flash drive). Then when you switch
modes everything seems to work properly.

I used https://github.com/dhylands/upy-examples/blob/master/boot_switch.py
to easily switch the pyboard between the various USB modes for testing.
2015-10-09 00:18:01 +01:00
Damien George 2a8d7ee0f8 stmhal: Fix RTC.wakeup so it correctly calculates WUT for large periods.
Thanks to Peter Hinch.  Addresses issue #1488.
2015-10-08 12:41:12 +01:00
Damien George fa391eed9d stmhal: In RTC.wakeup, fix setting of wucksel to get correct period.
Thanks to Peter Hinch.  See issue #1490.
2015-10-06 23:39:57 +01:00
Damien George 58e0f4ac50 py: Allocate parse nodes in chunks to reduce fragmentation and RAM use.
With this patch parse nodes are allocated sequentially in chunks.  This
reduces fragmentation of the heap and prevents waste at the end of
individually allocated parse nodes.

Saves roughly 20% of RAM during parse stage.
2015-10-02 00:11:11 +01:00
Tom Soulanille aeb62f9ae3 py/objslice: Make slice attributes (start/stop/step) readable.
Configurable with MICROPY_PY_BUILTINS_SLICE_ATTRS.  Disabled by default.
2015-09-15 21:59:20 +01:00
Damien George d80174d7c3 stmhal: Use polling, not DMA, for 1 byte SPI transfers.
There is an issue sending 1 byte on the SPI bus using DMA, but it only
occurs when the transmit is done for the first time after initialising
the SPI and DMA peripherals.  All other cases (sending 2 or more bytes,
doing send_recv, doing recv first) work okay.  We sidestep this issue by
using polling (not DMA) for all 1 byte transfers.  This is fine because
a 1 byte transfer can't be interrupted and doesn't need the benefits of
DMA (and using polling for this case is more efficient).

Resolves #1456.
2015-09-15 20:45:37 +01:00
Tom Soulanille 7731edf2f5 stmhal: Add "opt" arg to pyb.main, to set mp_optimise_value.
Use this to set the global optimisation value when executing the main
script (and all scripts it imports).
2015-09-12 22:53:54 +01:00
Tony Abboud 8d8fdcb4be stmhal: add option to query for the current usb mode
Fetch the current usb mode and return a string representation when
pyb.usb_mode() is called with no args. The possible string values are interned
as qstr's. None will be returned if an incorrect mode is set.
2015-09-03 23:30:43 +01:00
Bob Clough 86e6ad76cb stmhal: Add support for STM32F411 Discovery Board (STM32F411E-DISCO). 2015-08-29 22:50:58 +01:00
tobbad 1abb449dfb stmhal: Fixed some typos in stm32f411_af.csv. 2015-08-17 16:51:19 +01:00
Dave Hylands c6f1d47dcb stmhal: Enable I & D caches for M7 2015-08-15 10:58:24 -07:00
blmorris bdd78c31b6 py: Add stream_tell method, and use for unix and stmhal file tell. 2015-08-13 22:56:32 +01:00
Dave Hylands 872f9af6ae stmhal: Use CMSIS_MCU definition from mpconfigboard.mk
This needs to land afte #1407 lands, since #1407 is where
the CMSIS_MCU was defined.
2015-08-07 08:54:14 +01:00
Dave Hylands 8f59bacb92 stamhal: Add definitions for MCU_SERIES_F4 and MCU_SERIES_F7 2015-08-07 08:52:42 +01:00
Dave Hylands be66a9ecf6 stmhal: Generate modstm constants per build
This causes unnecessary constants to no longer be generated.
Some constants (like UART_BRR) are different between the F4 and F7
2015-08-07 08:46:43 +01:00
Damien George 4836bcc957 stmhal/cmsis: Replace non-ascii apostrophe with ascii apostrophe. 2015-08-07 08:46:43 +01:00
Dave Hylands 8a1a5c236d stmhal: Fix hardfault when configured as a SPI slave 2015-08-05 23:42:05 +01:00
Dave Hylands 5e11d2b349 stmhal: Enable SPI support for F7 MCUs. 2015-08-05 23:38:49 +01:00
Dave Hylands 34fe5a30c6 stmhal: Enable I2C support for F7 MCUs. 2015-08-05 23:38:24 +01:00
Damien George 4434e43fa1 stmhal: Add HALCOMMITS file with list of commits that touch the hal.
This file should be kept up to date with list of hal commits.
2015-08-03 00:55:36 +01:00
Dave Hylands 7a55c1a884 stmhal: Port of f4 hal commit 1d7fb82 to f7 hal 2015-08-03 00:49:36 +01:00
Dave Hylands 28e51c9eb1 stmhal: Port of f4 hal commit 09de030 to f7 hal 2015-08-03 00:49:36 +01:00
Dave Hylands af9d885f8c stmhal: Port of f4 hal commit c568a2b to f7 hal 2015-08-03 00:49:35 +01:00
Dave Hylands 9e8eba797e stmhal: M7 Reset clocksources changed by DFU bootloader
The DFU bootloader on the ST32F7 chip changes the clocksource
for various possible boot sources (UART1, UART3, I2C1-3).
This commit resets those clock sources back to their cold
reset values.
2015-08-03 00:46:31 +01:00
Dave Hylands 8f1eced69d stmhal: Add STM32F7 support for USB serial and storage.
USB serial is now working for F7.

Internal file storage is now working for F7.  The flash is laid out a bit
differently to the F4 - 4 x 32K, 1 x 128K with the rest 256K, so the
internal storage is 96K.

Added more pind definitions for STM32F7DISC board.  Made USART1 be the
default HWUART repl.  The STLINK usb connector also looks like a USB
serial port which is attached to USART1 on the STM32F7DISC.
2015-08-03 00:39:27 +01:00
Damien George 751485fe6b stmhal: Add support for USART1 and conditional pins in make-pins.py.
Thanks to Dave Hylands for the patch.
2015-08-03 00:23:47 +01:00
Damien George a632037866 stmhal: Add better support for UART having Tx and Rx on different ports.
Thanks to Dave Hylands for the patch.
2015-08-03 00:22:16 +01:00
Damien George c0e39864c6 stmhal: Fix make-pins.py to allow Port K.
Thanks to Dave Hylands for the patch.
2015-08-03 00:18:40 +01:00
Damien George 6e552e15fa stmhal: Add debug capability to print out info about a hard fault.
Capability is #if'd off by default.

Thanks to Dave Hylands for the patch.
2015-08-03 00:14:51 +01:00
Damien George 0851751615 stmhal: Factor GPIO clock enable logic into mp_hal_gpio_clock_enable.
Extracted GPIO clock enable logic into mp_hal_gpio_clock_enable
and called from anyplace which might need to use GPIO functions
on ports other than A-D.

Thanks to Dave Hylands for the patch.
2015-08-03 00:14:48 +01:00
Damien George 6f1c00869c stmhal: Factor out USRSW boot-up code and support boards with 1 LED.
Thanks to Dave Hylands for the patch.
2015-08-03 00:14:44 +01:00
Dave Hylands 92d4b51ad5 stmhal: Add STM32F7DISC and associated changes. 2015-07-30 00:38:32 +01:00
Dave Hylands 7e7fb0b7a3 stmhal: Renamed startup/system/_it.[ch] file to generic names. 2015-07-30 00:38:29 +01:00
Dave Hylands ea8bf81058 stmhal: Replace #include "stm32f4xx_hal.h" with #include STM32_HAL_H. 2015-07-30 00:38:25 +01:00
Damien George f243851ccd stmhal: Expose uwTick in f7 hal. 2015-07-30 00:38:25 +01:00
Dave Hylands 7c934ae501 stmhal: Add hal and cmsis files from STM32Cube_FW_F7_V1.1.0.
All files were converted to linux line endings.
All trailing whitespace was removed using:
for f in f7/inc/* f7/src/*; do sed --in-place 's/[[:space:]]\+$//' $f; done
All non-ascii chars in comments were replaced with ascii equivalents or
removed.
2015-07-30 00:38:18 +01:00
Damien George f5d04750db stmhal: Put fs_user_mount pointer in root ptr section of global state.
Should fix issue #1393.
2015-07-27 23:52:56 +01:00
Damien George 92e9a5e0a7 stmhal: Check if user block device is mounted before accessing it.
In particular this fixes a bug where pyb.sync (and os.sync) fail because
they try to sync the user mounted device even if it's not mounted.
2015-07-27 23:40:19 +01:00
Tom Soulanille 7d588b0c7c lib/mp-readline: Add emacs-style control characters for cursor movement.
Disabled by default.  Adds 108 bytes to Thumb2 arch when enabled.
2015-07-26 15:22:13 +01:00
Damien George 7693ef3bd6 stmhal: Allow ADC.read_timed to take Timer object in place of freq.
This allows a user-specified Timer for the triggering of the ADC read,
mirroring the new behaviour of DAC.write_timed.

Addresses issue #1129.
2015-07-22 19:41:13 +01:00
Damien George 99a21dc05d stmhal: Add stm32fxxx_hal_i2s_ex.c to hal/f2 (dummy) and hal/f4. 2015-07-21 23:49:19 +01:00
Damien George abc24c1876 stmhal: Allow DAC.write_timed to take Timer object in place of freq.
This allows the DAC to use a user-specified Timer for the triggering
(instead of the default Timer(6)), while still supporting original
behaviour.

Addresses issues #1129 and #1388.
2015-07-21 23:39:49 +01:00
Damien George 6f5e0fe955 stmhal: Clean up DAC code a little. 2015-07-21 22:05:56 +01:00
blmorris 2af846e711 stmhal/boards/stm32fxx_prefix.c: Fix alt function number calculation
This prevented pin_find_af* functions from being able to find some
of the alternate functions in the pin struct
2015-07-20 16:19:12 +01:00
Damien George f576057274 stmhal: Add CMSIS device header files for STM32F2xx series. 2015-07-20 12:33:05 +01:00
Wojtek Siudzinski 0621eca05e stmhal: Add STM32CubeF2 version 1.1.0, in hal/f2 directory.
Only those files which are needed by the stmhal port are added.

Also includes a dummy file (stm32f2xx_hal_pcd_ex.c) to keep the build
system the same for f4 and f2 MCU series.
2015-07-20 12:32:09 +01:00
Damien George a39df51d8a stmhal: Update Makefile and board configs to compile with relocated hal. 2015-07-20 12:30:18 +01:00
Damien George e4d43401eb stmhal: Move HAL Cube files to f4/ subdir, keeping only those we use.
This is in preparation for supporting other MCU series, such as
STM32F2xx.  Directory structure for the HAL is now hal/f4/{inc,src},
where "f4" will in the future be different for other series.

HAL source/header files that are not use are removed to reduce the size
of the code.
2015-07-20 12:30:18 +01:00
Dave Hylands 9309e609cd stmhal: Add qstr definition for ifconfig when building for WizNet 2015-07-14 23:00:29 +01:00
Dave Hylands 11115e4d23 stmhal: Add I2S support to make-pins.py 2015-07-07 10:15:37 +01:00
Damien George 0807139c1d stmhal: Add config option for storage to use second flash segment.
When enabled this allows the internal storage to be split over 2
contiguous regions of flash (two segments), and so the storage can be
increased.

This option is disabled by default, giving original behaviour.
2015-06-27 23:27:23 +01:00
blmorris c5175526dd stmhal/dma.c: Modify dma_init() to accept init struct as an argument
This removes hard-coded DMA init params from dma_init(), instead defining
these parameters in a DMA_InitTypeDef struct that gets passed as an
argument to dma_init()
This makes dma_init more generic so it can be used for I2S and SD Card,
which require different initialization parameters.
2015-06-24 17:48:52 +01:00
Damien George 6e1dfb0d1a stmhal: Reorganise code for parsing keyword args in I2C methods.
To make it the same as SPI and UART.
2015-06-22 23:46:22 +01:00
Damien George 76285469d3 stmhal: Make I2C use DMA when interrupts are enabled. 2015-06-10 14:01:44 +01:00
Damien George 3d30d605f5 stmhal: Factor out DMA initialisation code from spi.c.
This is so that the DMA can be shared by multiple peripherals.
2015-06-10 14:01:44 +01:00
Damien George 0aa5e75000 stmhal: Break immediately from USB CDC busy wait loop if IRQs disabled.
If IRQs are disabled then the USB CDC buffer will never be
drained/filled and the sys-tick timer will never increase, so we should
not busy wait in this case.
2015-06-07 23:48:07 +01:00
Damien George 53a8aeb6e7 stmhal: Fix slow SPI DMA transfers by removing wfi from DMA wait loop.
Addresses issue #1268.
2015-06-03 23:20:23 +01:00
Dave Hylands 3ac2d06bd1 stmhal: Add support for UART5
I tested this on my CERB40 board and it seems to be working fine.
2015-06-01 00:14:46 +01:00
Damien George 17d9b5006d stmhal: Fix off-by-one error when checking for valid I2C and SPI bus. 2015-05-28 11:05:44 +01:00
Damien George 70446f46c2 stmhal: Allow to name SPI busses, and give them names for pyboard. 2015-05-27 17:21:42 +01:00
Damien George 0e6f5e08e1 stmhal: Allow to name I2C busses, and give them names for pyboard. 2015-05-27 17:16:26 +01:00
Damien George 1775b65e07 stmhal: Remove PYBVxx defines and use config vars for UART/CAN names.
Now all stmhal-based boards can name their peripherals (if they want) to
any string.
2015-05-27 16:51:04 +01:00
Damien George 3c4b5d4281 stmhal: Implement sys.std{in,out,err}.buffer, for raw byte mode.
It's configurable and only enabled for stmhal port.
2015-05-24 14:31:33 +01:00
Dave Hylands 968b7dd173 stmhal: Detect disk full condition 2015-05-24 14:07:11 +01:00
Damien George 0d31bbc7fa stmhal: Make pendsv variable non-static so gcc-5 doesn't opt it away. 2015-05-23 17:42:58 +01:00
Kaspar Schleiser f5dd6f7f37 py/binary: Make return type of mp_binary_get_size size_t instead of int.
Fixes sign-compare warning.
2015-05-17 18:12:19 +01:00
Damien George 1511dd4f84 stmhal: Add readinto and readlines methods to sys.stdin, pyb.USB_VCP().
Addresses issue #1255.
2015-05-13 20:22:11 +01:00
Josef Gajdusek 1db4253886 lib: Move time utility functions to common library. 2015-05-13 00:12:54 +01:00
Steve Zatz c7df9c6c47 stmhal: Add os.rename function. 2015-05-12 23:43:11 +01:00
Damien George c50772d19f py: Add mp_obj_get_int_truncated and use it where appropriate.
mp_obj_get_int_truncated will raise a TypeError if the argument is not
an integral type.  Use mp_obj_int_get_truncated only when you know the
argument is a small or big int.
2015-05-12 23:05:53 +01:00
blmorris 5df81de7af sthmal/rtc.c: Add calibration() method to get/set RTC fine-tuning value. 2015-05-11 23:48:39 +01:00
Dave Hylands ff987ccf11 stmhal: Move debug UART repl to after uart_init0 call. 2015-05-06 22:16:49 +01:00
Damien George c98c128fe8 pyexec: Make raw REPL work with event-driven version of pyexec.
esp8266 port now has working raw and friendly REPL, as well as working
soft reset (CTRL-D at REPL, or raise SystemExit).

tools/pyboard.py now works with esp8266 port.
2015-05-06 00:02:58 +01:00
Paul Sokolovsky 3d3ef36e97 modstruct: Rename module to "ustruct", to allow full Python-level impl. 2015-05-04 16:53:52 +03:00
Josef Gajdusek 04ee5983fe lib: Move some common mod_network_* functions to lib/netutils. 2015-05-04 11:48:40 +01:00
Eero af Heurlin 2378be4e93 stmhal: Allow to configure UART pins completely via mpconfigboard.h. 2015-05-03 13:48:26 +01:00
Dave Hylands c3e37a0cde stmhal: Automatically re-enable IRQs on the USB REPL.
This allows errors to be seen and prevents hanging
the board from doing: pyb.disable_irq()
2015-04-29 08:27:38 +01:00