Commit Graph

39 Commits

Author SHA1 Message Date
Damien George
61339aa506 stm32: Add initial support for H5 MCUs.
This commit adds initial support for STM32H5xx MCUs.  The following
features have been confirmed to be working on an STM32H573:
- UART over REPL and USB CDC
- USB CDC and MSC
- internal flash filesystem
- machine.Pin
- machine.SPI transfers with DMA
- machine.ADC
- machine.RTC
- pyb.LED
- pyb.Switch
- pyb.rng
- mboot

Signed-off-by: Damien George <damien@micropython.org>
2023-06-15 11:09:20 +10:00
Damien George
b9dad0add2 stm32: Remove commented-out printf's and debugging code.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-09 12:47:45 +11:00
yn386
427d72667f stm32: Add support for STM32L1 MCUs.
This change adds STM32L1 support to the STM32 port.
2022-09-25 23:56:41 +10:00
Jim Mussared
94beeabd2e py/obj: Convert make_new into a mp_obj_type_t slot.
Instead of being an explicit field, it's now a slot like all the other
methods.

This is a marginal code size improvement because most types have a make_new
(100/138 on PYBV11), however it improves consistency in how types are
declared, removing the special case for make_new.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:15 +10:00
Jim Mussared
9dce82776d all: Remove unnecessary locals_dict cast.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:01 +10:00
Jim Mussared
662b9761b3 all: Make all mp_obj_type_t defs use MP_DEFINE_CONST_OBJ_TYPE.
In preparation for upcoming rework of mp_obj_type_t layout.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:01 +10:00
Asensio Lorenzo Sempere
010012c7c3 stm32: Add support for G0 MCUs.
This commit adds support for the STM32G0 series of MCUs.

Signed-off-by: Asensio Lorenzo Sempere <asensio.aerospace@gmail.com>
2022-04-28 11:56:15 +10:00
Damien George
e0a0719416 stm32: Add initial support for STM32WL MCUs.
Signed-off-by: Damien George <damien@micropython.org>
2022-02-04 09:43:43 +11:00
Damien George
e4f59a0020 stm32/rtc: Use LL_RTC functions to simplify some MCU-specific code.
This also fixes a possible race condition when exiting initialisation mode:
reading then writing to ISR (via ISR &= ~RTC_ISR_INIT) will clear any flags
that were set by the hardware between the read and the write.  The correct
way to clear just the INIT bit is to just do a single write via ISR =
~RTC_ISR_INIT, which will not clear any other flags (they must be written
to 0 to clear), and that is exactly what LL_RTC_DisableInitMode does.

Signed-off-by: Damien George <damien@micropython.org>
2022-02-04 08:35:14 +11:00
Herwin Grobben
8f68e26f79 stm32: Add support for G4 MCUs, and add NUCLEO_G474RE board defn.
This commit adds support for the STM32G4 series of MCUs, and a board
definition for NUCLEO_G474RE.  This board has the REPL on LPUART1 which is
connected to the on-board ST-link USB-UART.
2022-02-01 16:21:01 +11:00
Jan Staal
9e2423e730 stm32: Add support for H7A3(Q)/H7B3(Q), and STM32H73B3I_DK board defn.
This commit is based upon prior work of @dpgeorge and @koendv.

MCU support for the STM32H7A3 and B3 families MCUs:
- STM32H7A3xx
- STM32H7A3xxQ (SMPS)
- STM32H7B3xx
- STM32H7B3xxQ (SMPS)

Support has been added for the STM32H7B3I_DK board.

Signed-off-by: Jan Staal <info@janstaal.com>
2021-09-16 12:29:28 +10:00
Damien George
136369d72f all: Update to point to files in new shared/ directory.
Signed-off-by: Damien George <damien@micropython.org>
2021-07-12 17:08:10 +10:00
Andrew Scheller
499e199add docs,stm32: Fix minor typos in RTC docs, and->an. 2021-01-30 14:13:30 +11:00
Damien George
cc2a35b7b2 stm32/rtc: Validate the RTC prescaler on boot and change if incorrect.
Devices with RTC backup-batteries have been shown (very rarely) to have
incorrect RTC prescaler values.  Such incorrect values mean the RTC counts
fast or slow, and will be wrong forever if the power/backup-battery is
always present.

This commit detects such a state at start up (hard reset) and corrects it
by reconfiguring the RTC prescaler values.

Signed-off-by: Damien George <damien@micropython.org>
2020-11-13 11:23:52 +11:00
Damien George
8f20cdc353 all: Rename absolute time-based functions to include "epoch".
For time-based functions that work with absolute time there is the need for
an Epoch, to set the zero-point at which the absolute time starts counting.
Such functions include time.time() and filesystem stat return values.  And
different ports may use a different Epoch.

To make it clearer what functions use the Epoch (whatever it may be), and
make the ports more consistent with their use of the Epoch, this commit
renames all Epoch related functions to include the word "epoch" in their
name (and remove references to "2000").

Along with this rename, the following things have changed:

- mp_hal_time_ns() is now specified to return the number of nanoseconds
  since the Epoch, rather than since 1970 (but since this is an internal
  function it doesn't change anything for the user).

- littlefs timestamps on the esp8266 have been fixed (they were previously
  off by 30 years in nanoseconds).

Otherwise, there is no functional change made by this commit.

Signed-off-by: Damien George <damien@micropython.org>
2020-09-18 17:20:34 +10:00
Damien George
ee50a6effe py/mphal.h: Introduce mp_hal_time_ns and implement on various ports.
This should return a 64-bit value being the number of nanoseconds since
1970/1/1.

Signed-off-by: Damien George <damien@micropython.org>
2020-08-22 16:13:44 +10:00
stijn
84fa3312cf all: Format code to add space after C++-style comment start.
Note: the uncrustify configuration is explicitly set to 'add' instead of
'force' in order not to alter the comments which use extra spaces after //
as a means of indenting text for clarity.
2020-04-23 11:24:25 +10:00
Jim Mussared
def76fe4d9 all: Use MP_ERROR_TEXT for all error messages. 2020-04-05 15:02:06 +10:00
Damien George
1a3e386c67 all: Remove spaces inside and around parenthesis.
Using new options enabled in the uncrustify configuration.
2020-03-28 23:36:44 +11:00
Damien George
69661f3343 all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28 10:33:03 +11:00
Damien George
59b7166d87 stm32: Add initial support for STM32WBxx MCUs.
This new series of MCUs is similar to the L4 series with an additional
Cortex-M0 coprocessor.  The firmware for the wireless stack must be managed
separately and MicroPython does not currently interface to it.  Supported
features so far include: RTC, UART, USB, internal flash filesystem.
2019-07-17 16:33:31 +10:00
Damien George
23d9c6a0fd stm32: Add initial support for STM32L0xx MCUs. 2019-07-05 17:24:59 +10:00
Andrew Leech
29865e3e58 stm32/rtc: Allow overriding startup timeouts from mpconfigboard. 2019-05-09 12:08:43 +10:00
Damien George
fd112239d6 stm32/rtc: Remove non-ASCII mu-character from source code comment.
And fix a typo in the comment on this line.
2019-04-12 11:32:24 +10:00
Damien George
fc9f2ff0cd stm32/rtc: Remove unused LSE detection code. 2019-04-11 12:14:21 +10:00
Damien George
46e5d6b889 stm32/rtc: Add auto-LSE-bypass detection with fallback to LSE then LSI.
If MICROPY_HW_RTC_USE_BYPASS is enabled the RTC startup goes as follows:
- RTC is started with LSE in bypass mode to begin with
- if that fails to start (after a given timeout) then LSE is reconfigured
  in non-bypass
- if that fails to start then RTC is switched to LSI
2019-04-11 12:09:21 +10:00
Damien George
c2886868b9 stm32/rtc: Check RTCEN=1 when testing if RTC is already running on boot.
It can be that LSEON and LSERDY are set yet the RTC is not enabled (this
can happen for example when coming out of the ST DFU mode on an F405 with
the RTC not previously initialised).  In such a case the RTC is never
started because the code thinks it's already running.  This patch fixes
this case by always checking if RTCEN is set when booting up (and also
testing for a valid RTCSEL value in the case of using an LSE).
2019-01-27 13:21:31 +11:00
Damien George
9dfbb6cc16 stm32/rtc: Get rtc.wakeup working on F0 MCUs.
The problem was that the EXTI line for the RTC wakeup event is line 20 on
the F0, so the interrupt was not firing.
2018-07-31 17:24:10 +10:00
Damien George
e1ae9939ac stm32: Support compiling with object representation D.
With this and previous patches the stm32 port can now be compiled using
object representation D (nan boxing).  Note that native code and frozen mpy
files with float constants are currently not supported with this object
representation.
2018-07-08 23:25:11 +10:00
Damien George
ea7e747979 stm32: Add support for STM32F0 MCUs. 2018-05-28 21:49:49 +10:00
Damien George
6c955932f3 stm32/rtc: Don't try to set SubSeconds value on RTC.
The hardware doesn't allow it, instead the value is reset to 255 upon
setting the other calendar/time values.
2018-05-21 14:08:37 +10:00
Damien George
a03e6c1e05 stm32/irq: Define IRQ priorities directly as encoded hardware values.
For a given IRQn (eg UART) there's no need to carry around both a PRI and
SUBPRI value (eg IRQ_PRI_UART, IRQ_SUBPRI_UART).  Instead, the IRQ_PRI_UART
value has been changed in this patch to be the encoded hardware value,
using NVIC_EncodePriority.  This way the NVIC_SetPriority function can be
used directly, instead of going through HAL_NVIC_SetPriority which must do
extra processing to encode the PRI+SUBPRI.

For a priority grouping of 4 (4 bits for preempt priority, 0 bits for the
sub-priority), which is used in the stm32 port, the IRQ_PRI_xxx constants
remain unchanged in their value.

This patch also "fixes" the use of raise_irq_pri() which should be passed
the encoded value (but as mentioned above the unencoded value is the same
as the encoded value for priority grouping 4, so there was no bug from this
error).
2018-05-02 14:41:02 +10:00
Damien George
e37b8ba5a5 stm32: Use STM32xx macros instead of MCU_SERIES_xx to select MCU type.
The CMSIS files for the STM32 range provide macros to distinguish between
the different MCU series: STM32F4, STM32F7, STM32H7, STM32L4, etc.  Prefer
to use these instead of custom ones.
2018-03-17 10:42:50 +11:00
iabdalkader
711f817c2a stm32/rtc: Add RTC support for H7 MCUs. 2018-03-09 15:12:29 +11:00
Damien George
3eb0694b97 stm32: Update HAL macro and constant names to use newer versions.
Newer versions of the HAL use names which are cleaner and more
self-consistent amongst the HAL itself.  This patch switches to use those
names in most places so it is easier to update the HAL in the future.
2018-02-13 15:37:35 +11:00
Damien George
12464f1bd2 stm32/rtc: Add compile-time option to set RTC source as LSE bypass.
To use the LSE bypass feature (where an external source provides the RTC
clock) a board must set the config variable MICROPY_HW_RTC_USE_BYPASS.
2018-02-05 15:22:15 +11:00
Damien George
011d1555cb stm32/rtc: Fix RTC init to use LSI if LSI is already selected on boot.
Upon boot the RTC early-init function should detect if LSE or LSI is
already selected/running and, if so, use it.  When the LSI has previously
(in the previous reset cycle) been selected as the clock source the only
way to reliably tell is if the RTCSEL bits of the RCC_BDCR are set to the
correct LSI value.  In particular the RCC_CSR bits for LSI control do not
indicate if the LSI is ready even if it is selected.

This patch removes the check on the RCC_CSR bits for the LSI being on and
ready and only uses the check on the RCC_BDCR to see if the LSI should be
used straightaway.  This was tested on a PYBLITEv1.0 and with the patch the
LSI persists correctly as the RTC source as long as the backup domain
remains powered.
2018-02-05 15:12:22 +11:00
Damien George
5a62f0faa6 stm32/rtc: Fix rtc_info flags when LSE fails and falls back to LSI.
Previously, if LSE is selected but fails and the RTC falls back to LSI,
then the rtc_info flags would incorrectly state that LSE is used.  This
patch fixes that by setting the bit in rtc_info only after the clock is
ready.
2018-02-05 14:40:06 +11:00
Damien George
01dd7804b8 ports: Make new ports/ sub-directory and move all ports there.
This is to keep the top-level directory clean, to make it clear what is
core and what is a port, and to allow the repository to grow with new ports
in a sustainable way.
2017-09-06 13:40:51 +10:00