Commit Graph

1075 Commits

Author SHA1 Message Date
Rami Ali
6901649f54 stmhal: Declare and initialise PrescTables for F7 MCUs. 2016-12-07 17:31:09 +11:00
Rami Ali
44cb2ff7ab stmhal: Port of f4 hal commit 1d7fb82 to updated f7 hal. 2016-12-07 17:31:07 +11:00
Rami Ali
821863751f stmhal: Port of f4 hal commit 09de030 to updated f7 hal. 2016-12-07 17:31:05 +11:00
Rami Ali
e1c6ed634f stmhal: Port of f4 hal commit c568a2b to updated f7 hal. 2016-12-07 17:30:44 +11:00
Rami Ali
b9741cd8f8 stmhal/hal: Update ST32CubeF7 HAL files to V1.1.2.
These files originate from the STM32Cube_FW_F7_V1.5.0 software package
from ST.  Newlines are unixified and trailing whitespace is removed.
2016-12-07 17:28:33 +11:00
Rami Ali
d9677f4098 stmhal/cmsis: Update STM32F7 CMSIS device include files to V1.1.2. 2016-12-07 17:27:40 +11:00
Damien George
4c7d799b82 stmhal/uart: Add check that UART id is valid for the given board.
Previous to this patch trying to construct, but not init, a UART that
didn't exist on the target board would actually succeed.  Only when
initialising the UART would it then raise an exception that the UART does
not exist.

This patch adds an explicit check that the constructed UART does in fact
exist for the given board.
2016-12-05 15:31:16 +11:00
Damien George
aaab6a9921 stmhal/uart: Add support for UART7 and UART8 on F7 MCUs. 2016-12-05 15:14:22 +11:00
Rami Ali
27a503f632 stmhal: Refactor UART configuration to use pin objects.
This follows the pattern of other peripherals (I2C, SPI) to specify the
pins using pin objects instead of a pair of GPIO port and pin number.  It
makes it easier to customise the UART pins for a particular board.
2016-12-05 14:26:41 +11:00
Damien George
fcd10882bd stmhal/adc: Use constants from new HAL version. 2016-12-05 10:51:00 +11:00
Damien George
2d329c4a56 extmod/moduselect: Use configurable EVENT_POLL_HOOK instead of WFI.
To make moduselect be usable by any port.
2016-12-02 16:40:39 +11:00
Damien George
304cfda8c4 py/stream: Move ad-hoc ioctl constants to stream.h and rename them.
The constants MP_IOCTL_POLL_xxx, which were stmhal-specific, are moved
from stmhal/pybioctl.h (now deleted) to py/stream.h.  And they are renamed
to MP_STREAM_POLL_xxx to be consistent with other such constants.

All uses of these constants have been updated.
2016-12-02 16:37:29 +11:00
Damien George
f7545b200e stmhal/moduos: Implement POSIX behaviour of rename, allow to overwrite. 2016-12-02 15:13:29 +11:00
Jean-François Milants
08bd7d1d31 stmhal/sdcard: Clean/invalidate cache before DMA transfers with SD card.
Add 2 macros in mphalport.h that clean and invalidate data caches only on
STM32F7 MCUs.  They are needed to ensure the cache coherency before/after
DMA transferts.

* MP_HAL_CLEANINVALIDATE_DCACHE cleans and invalidate the data cache. It
  must be called before starting a DMA transfer from the peripheral to the
  RAM memory.

* MP_HAL_CLEAN_DCACHE cleans the data cache.  It must be called before
  starting a DMA transfert from the RAM memory to the peripheral.

These macros are called in sdcard.c, before reading from and writing to
the SDCard, when DMA is used.
2016-12-02 13:51:09 +11:00
Damien George
c19a395cac stmhal/adc: Make channel "16" always map to the temperature sensor.
The temperature sensor on F4 and F7 MCUs is mostly, but not always, on
channel 16.  To retain compatibility across all these MCUs this patch
maps the user-facing channel 16 to the internal temperature sensor.
2016-11-30 12:58:54 +11:00
Damien George
390ce86a30 stmhal/adc: Add support for F767 MCU. 2016-11-30 12:58:54 +11:00
Damien George
52dfad0879 stmhal/adc: Add ADCAll.read_vref method, returning "3.3v" value. 2016-11-30 12:58:54 +11:00
Damien George
e72353cc48 stmhal/adc: Make ADCAll.read_core_temp return accurate float value.
It now uses factory calibration values to get a more accurate value, and
returns a float instead of an integer.
2016-11-30 12:58:53 +11:00
Damien George
87215a0f04 stmhal/adc: Provide more accurate measure of VBAT and VREFINT.
By using factory calibration values.
2016-11-30 12:58:53 +11:00
Damien George
029f215ead stmhal/adc: Add "mask" selection parameter to pyb.ADCAll constructor.
The "mask" parameter is used to select which pins the ADCAll constructor
will initialise to analog mode.  It defaults to all pins (0xffffffff),
which is backwards compatible with previous behaviour.
2016-11-29 14:32:05 +11:00
Nicholas Graumann
0d75b0d962 stmhal: Add address parameters to openocd config files.
Also make l4 config the default for STM32L476DISC board.
2016-11-28 15:27:36 +11:00
Nicholas Graumann
50a2966913 stmhal: Add OpenOCD configuration for STM32L4. 2016-11-28 15:27:36 +11:00
Damien George
139b891d6d stmhal: Add back GPIO_BSRRL and GPIO_BSRRH constants to stm module.
These were inadvertently removed with a recent upgrade to CMSIS, where
those registers were no longer defined in the CMSIS headers, and hence
no longer extracted.
2016-11-28 15:02:42 +11:00
Dave Hylands
21e1703d37 stmhal: Add support for flash storage on STM32F415. 2016-11-26 16:47:45 +11:00
Damien George
f8b71aabb4 stmhal/machine_i2c: Provide HW implementation of I2C peripherals for F4.
With this patch machine.I2C() uses HW I2C peripheral blocks on F4 MCUs.
Software I2C is used for other MCUs.
2016-11-25 16:31:43 +11:00
Damien George
49dcc253e3 stmhal/i2c: Expose the pyb_i2c_obj_t struct and some relevant functions.
So they can be used by other parts of the code.
2016-11-25 16:30:51 +11:00
Damien George
652ca2017d stmhal/i2c: Add support for I2C4 hardware block on F7 MCUs. 2016-11-25 11:21:18 +11:00
Damien George
3053748987 stmhal: Add beginnings of port-specific machine.I2C implementation.
This allows one to construct an I2C object using ids that are specific
to the stmhal port, eg machine.I2C('X').  Right now the implementation
of I2C uses software I2C but the idea is to just change the C-level I2C
protocol functions to hardware implementations later on.
2016-11-24 00:20:51 +11:00
Damien George
a3320e7811 stmhal/i2c: Remove use of legacy I2C_NOSTRETCH_DISABLED option.
In the new HAL this is renamed to I2C_NOSTRETCH_DISABLE.
2016-11-22 17:40:50 +11:00
Damien George
7e820792da stmhal: Updates to get F411 MCUs compiling with latest ST HAL. 2016-11-21 23:24:24 +11:00
Damien George
21d82421cd stmhal/i2c: Use the HAL's I2C IRQ handler for F7 and L4 MCUs.
The custom IRQ handler only works for F4 MCUs, which have the SR1
register.
2016-11-21 16:12:09 +11:00
Paul Sokolovsky
8f5bc3ffc0 stmhal/moduselect: Move to extmod/ for reuse by other ports. 2016-11-21 00:05:56 +03:00
Krzysztof Blazewicz
5e9057210a stmhal: Update HALCOMMITS due to change to hal. 2016-11-16 14:05:37 +01:00
Damien George
e01e214259 stmhal/make-stmconst.py: Restore Python 2 compatibility. 2016-11-16 23:53:55 +11:00
Damien George
87f18c08c9 stmhal: Update HALCOMMITS due to change to hal. 2016-11-16 23:43:02 +11:00
Damien George
c5621529c9 stmhal/make-stmconst.py: Add support for files with invalid utf8 bytes. 2016-11-16 23:29:02 +11:00
Krzysztof Blazewicz
4d9dce7759 stmhal/mphalport.h: use single GPIOx->BSRR register 2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
13400e1375 stmhal/hal: do not include <stdio.h> in HAL headers
stdio.h was included in all HAL files only to provide
definition of NULL symbol

"stdio.h" includes "types.h" which contains some conflicting definitions
with "drivers/cc3000/inc/socket.h"
2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
8fa0733647 stmhal/i2c: provide custom IRQ handlers
Use custom handlers providing minimal required functionality
because those provided by ST increase code size by almost 2 KiB.
2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
7604de3fc2 stmhal/can: clear FIFO flags in IRQ handler
HAL Driver before v1.4.2 had a bug which caused clearing all pending
flags in MSR, TSR, RF0R and RF1R instead of only the requested one.

This is why micropython got away without explicitly clearing flags
in IRQ handler.
2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
dc1ac5dc3a stmhal/dma: mark DMA sate as READY even if HAL_DMA_Init is skipped
Current version of HAL drivers checks if `hdma->State == HAL_DMA_STATE_READY`
before executing some functions.
2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
63ca7a211a stmhal/dma: precalculate register base and bitshift on handle init
Current version of HAL drivers optimize IRQ handler by using precalculated
DMA register address and stream bitshift instead of calculating it on every interrupt.

Since we skip call to `HAL_DMA_Init` on reused DMA, fields StreamBaseAddress and StreamIndex
of DMA handle are not initialized and thus leads to SegFault in `DMA_IRQHandler`.

HAL_DMA_Init is a big routine and we do not need to call it on each use of DMA
(ex.: series of I2C operations) and DMA_CalcBaseAndBitshift is really small and
releasing it increases code size by only 8 bytes.
2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
0280b2c1b1 stmhal/i2c: handle I2C IRQs
This is required by HAL Driver for error handling since v1.5.0
2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
fa833f96df stmhal/make-stmconst.py: fix regex's to work with current CMSIS
CMSIS v2.5.0 removed all uint32_t casts and uses only Misra Cast (U)
2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
7928b3e347 stmhal/boards: configure all F4 boards to work with new HAL
changes include:
* use single GPIO.BSRR instead of BSRRH and BSRRL
* change HSE_STARTUP_TIMEOUT to 100 ms
* define LSE_STARTUP_TIMEOUT to 5 s
2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
6a8f6c119c stmhal/hal/sd: reapply HAL commit 09de030 for f4 2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
e2b4822189 stmhal/hal/rcc: reapply HAL commit c568a2b for f4 2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
4f7c5fa647 stmhal/hal: reapply HAL commit 9db719b for f4 2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
c79ff9930a stmhal/hal/sd: reapply HAL commit 1d7fb82 for f4 2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
a9fb88e1dc stmhal/hal/i2c: reapply HAL commit ea040a4 for f4 2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
e8b435d1f8 stmhal: apply STM32CubeF4 v1.13.1 patch - upgrade HAL driver to v1.5.2 2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
c1fa33b493 stmhal: upgrade to STM32CubeF4 v1.13.0 - HAL v1.5.1 2016-11-16 12:43:27 +01:00
Krzysztof Blazewicz
4f5c4fdd98 stmhal: upgrade to STM32CubeF4 v1.13.0 - CMSIS/Device 2.5.1 2016-11-16 12:43:27 +01:00
Damien George
e5ef15a9d7 py/lexer: Provide generic mp_lexer_new_from_file based on mp_reader.
If a port defines MICROPY_READER_POSIX or MICROPY_READER_FATFS then
lexer.c now provides an implementation of mp_lexer_new_from_file using
the mp_reader_new_file function.
2016-11-16 18:13:51 +11:00
Damien George
6b239c271c py: Factor out persistent-code reader into separate files.
Implementations of persistent-code reader are provided for POSIX systems
and systems using FatFS.  Macros to use these are MICROPY_READER_POSIX and
MICROPY_READER_FATFS respectively.  If an alternative implementation is
needed then a port can define the function mp_reader_new_file.
2016-11-16 18:13:50 +11:00
Paul Sokolovsky
59a1201da9 all: Remove readall() method, which is equivalent to read() w/o args.
Its addition was due to an early exploration on how to add CPython-like
stream interface. It's clear that it's not needed and just takes up
bytes in all ports.
2016-11-14 00:24:22 +03:00
Damien George
1375c52772 stmhal: Rename mp_hal_pin_set_af to _config_alt, to simplify alt config.
This way the caller doesn't need to initialise a big GPIO_InitTypeDef
struct, and HAL_GPIO_Init is no longer called.
2016-11-11 17:53:45 +11:00
Damien George
74fb5d6932 stmhal/i2c: Reset the I2C peripheral if there was an error on the bus.
If an I2C send/recv fails then the peripheral is now checked to see if
it's in a "stuck" state waiting for the stop bit, and if so then it is
reset so that the next I2C transaction can proceed.

This patch also de-inits the I2C peripheral in the init() method, before
init'ing it again.
2016-11-11 17:38:52 +11:00
Damien George
c4e58eaa98 stmhal/i2c: Add option to I2C to enable/disable use of DMA transfers.
New keyword option in constructor and init() method is "dma=<bool>".
DMA is now disabled by default for I2C transfers because it currently does
not handle I2C bus errors very well (eg if slave device doesn't ACK or
NACK correctly during a transfer).
2016-11-11 17:36:19 +11:00
Damien George
e6da6a720f stmhal/dma: De-init the DMA peripheral properly before initialising.
The DMA state is always HAL_DMA_STATE_RESET because of the memset clearing
all the data, so prior to this patch HAL_DMA_DeInit was never called.  Now
it is always called to make sure the DMA is properly reset.
2016-11-11 17:24:18 +11:00
Damien George
bdf33bc136 py: Move frozen bytecode Makefile rules from ports to common mk files.
Now, to use frozen bytecode all a port needs to do is define
FROZEN_MPY_DIR to the directory containing the .py files to freeze, and
define MICROPY_MODULE_FROZEN_MPY and MICROPY_QSTR_EXTRA_POOL.
2016-11-08 14:28:30 +11:00
Ryan Shaw
8ebd53afc9 stmhal: enable SD power save (disable CLK on idle) 2016-11-07 16:49:29 +11:00
Damien George
7bb0f7b0f6 drivers: Add "from micropython import const" when const is used.
Following best-practice use of the const feature, to make it compatible
with Python.
2016-11-03 12:41:11 +11:00
Damien George
cd527bb324 lib/libm: Move Thumb-specific sqrtf function to separate file.
This allows it to be used only when the hardware supports VFP
instructions, preventing compile errors.
2016-11-03 12:26:32 +11:00
Paul Sokolovsky
369233105b stmhal/modutime: Consistently convert to MP_ROM_QSTR/MP_ROM_PTR. 2016-10-29 17:46:47 +03:00
Paul Sokolovsky
d86cac4b82 extmod/utime_mphal: Implement ticks_add(), add to all maintained ports. 2016-10-29 17:30:05 +03:00
Damien George
4ebdb1f2b2 py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros.
In order to have more fine-grained control over how builtin functions are
constructed, the MP_DECLARE_CONST_FUN_OBJ macros are made more specific,
with suffix of _0, _1, _2, _3, _VAR, _VAR_BETEEN or _KW.  These names now
match the MP_DEFINE_CONST_FUN_OBJ macros.
2016-10-21 16:26:01 +11:00
Paul Sokolovsky
3967ca7390 stmhal/Makefile: Use standard rules for frozen module generation.
As defined in py/py.mk.
2016-10-21 01:27:17 +03:00
Damien George
b4cc68e4a4 stmhal/led: Refactor LED to use mp_hal_pin_output() init function.
As part of this patch the MICROPY_HW_LED_OTYPE setting is removed because
it is now unused (all boards anyway had this as OUTPUT_PP).
2016-10-18 14:43:05 +11:00
Damien George
d49d81b167 stmhal: Refactor pin usage to use mp_hal_pin API. 2016-10-18 14:34:08 +11:00
Damien George
cd9b14bb11 stmhal/modutime: Refactor to use extmod's version of ticks_cpu. 2016-10-18 14:34:08 +11:00
Damien George
48feb8ac6e stmhal: Enable str.center(), str.[r]partition() and builtin compile().
Also adds "machine" to the list of modules that the parser can search for
constants.
2016-10-17 13:17:19 +11:00
Damien George
57226a2b7f stmhal: Implement machine.soft_reset(). 2016-10-17 13:16:47 +11:00
Paul Sokolovsky
799ccdc789 esp8266, stmhal, unix: MAKE_FROZEN is consistently defined in mkenv.mk. 2016-10-16 10:49:36 +03:00
Paul Sokolovsky
f059563507 stmhal/modutime: Refactor to use extmod/utime_mphal.c.
This includes making sure that utime_mphal's sleep_ms() and sleep_us()
don't sleep on negative arguments.
2016-10-14 20:42:42 +03:00
Damien George
8298251215 stmhal/pybstdio: Use size_t instead of mp_uint_t. 2016-10-14 00:07:32 +11:00
Damien George
a2bfcbe029 stmhal: Use mp_raise_OSError helper function. 2016-10-07 13:58:25 +11:00
Damien George
0bb3c7d3b7 stmhal: Enable machine.time_pulse_us() function. 2016-10-06 12:12:20 +11:00
Dave Hylands
c08f50bcf7 stmhal: Disable network and usocket for ESPRUINO_PICO 2016-10-06 11:47:45 +11:00
Damien George
b89ac9db78 stmhal/moduos: Implement total-number-of-blocks field in statvfs. 2016-10-05 15:52:36 +11:00
Damien George
b1537a5752 stmhal/mphalport: Change pin obj type to const pointer, to avoid casts. 2016-10-05 15:51:40 +11:00
Dave Hylands
7a9c183c20 stmhal: Fix ESPRUINO_PICO by adding ld scripts with correct flash size. 2016-10-05 11:42:50 +11:00
Pavol Rusnak
99d62c4def stmhal/usb: Use real packet size (not maximum) in HID receive. 2016-10-04 15:39:31 +11:00
Pavol Rusnak
8f3cf6e6a8 stmhal/usb: Use correct ClassData structure for HID receive. 2016-10-04 15:38:32 +11:00
Philip Potter
eb239b8398 stmhal/usb: Add support to receive USB HID messages from host. 2016-10-04 15:38:01 +11:00
Philip Potter
03de5a13cf stmhal/usbdev: Add OUT endpoint to HID interface. 2016-10-04 15:20:11 +11:00
Dave Hylands
1f433c719b stmhal: Fix linker map for STM32L476 chips.
In particular, this makes the L4 .isr_vector section 16K in size so it's
the same as the F4/F7 MCUs.  The patch also moves the L4 filesystem to
the end of flash, which allows for 512K filesystem on the 1Mb devices
like the STM32L476DISC.
2016-10-04 14:31:19 +11:00
Damien George
bd925b59c3 stmhal/spi: Enable use of fast software SPI. 2016-10-04 13:51:30 +11:00
Damien George
b932b2dd1f extmod/machine_spi: Use delay_half, not baudrate, for internal timing.
The delay_half parameter must be specified by the port to set up the
timing of the software SPI.  This allows the port to adjust the timing
value to better suit its timing characteristics, as well as provide a
more accurate printing of the baudrate.
2016-10-04 13:43:02 +11:00
Damien George
9f1e395c16 stmhal/spi: Use software SPI if no periph id given, even if pins given.
It's simpler to just default to always using software SPI if no specific
peripheral id/name is given.  To use hardware SPI users must specify a
hardware peripheral id as the first parameter to the SPI constructor.
2016-10-04 13:38:11 +11:00
Damien George
5deedd6685 stmhal/mphalport: Fix mp_hal_pin_write to use correct pin_mask. 2016-10-03 18:06:58 +11:00
Damien George
d4a5ca5056 stmhal/spi: Make machine.SPI class conform to correct API.
Includes both software and hardware SPI implementations.
2016-10-03 17:12:43 +11:00
Damien George
077dbf4a86 stmhal/mphalport: Implement mp_hal_pin_{input,output,write}. 2016-10-03 16:44:34 +11:00
Damien George
a22a67661a stmhal/spi: Simplify spi_transfer function to take only one buf len arg. 2016-10-03 12:47:56 +11:00
Damien George
5bb28c7f10 extmod/machine_spi: Simplify SPI xfer function to only take one buf len.
There is no need to take src_len and dest_len arguments.  The case of
reading-only with a single output byte (originally src_len=1, dest_len>1)
is now handled by using the output buffer as the input buffer, and using
memset to fill the output byte into this buffer.  This simplifies the
implementations of the spi_transfer protocol function.
2016-10-03 12:39:31 +11:00
Krzysztof Blazewicz
6aea34ad89 lib/cmsis: move CMSIS headers to lib/
Files in lib/cmsis are generic for all Cortex-M MCU's
files left in stmhal/cmsis are all STM32 specific.
2016-09-30 16:19:03 +10:00
Damien George
53bfcc9e84 stmhal: Remove CMSIS STM32F2xx files, they are unused/unsupported. 2016-09-28 15:09:03 +10:00
Nicholas Graumann
7165fbd8f4 stmhal: Add virtual com port support for STM32L476DISC. 2016-09-27 22:08:55 -05:00
Damien George
88ca7ff565 stmhal/modmachine: Fix clearing of reset-cause flags.
To reset the flags we should write to the single bit only, not the entire
register (otherwise all other settings in the register are cleared).

Fixes #2457.
2016-09-27 15:49:35 +10:00
Krzysztof Blazewicz
1f69b16d3f stmhal: Remove STM32CubeF2 HAL files, they are unused/unsupported. 2016-09-22 12:11:01 +10:00