aboutsummaryrefslogtreecommitdiff
path: root/ports/stm32/modmachine.c
AgeCommit message (Collapse)Author
2021-02-17stm32: Make pyb, uos, utime, machine and onewire modules configurable.Damien George
The default for these is to enable them, but they can now be disabled individually by a board configuration. Signed-off-by: Damien George <damien@micropython.org>
2020-12-07stm32/modmachine: Add device and revision ids to machine.info().iabdalkader
2020-10-01ports: Add SoftI2C and SoftSPI to machine module where appropriate.Damien George
Previous commits removed the ability for one I2C/SPI constructor to construct both software- or hardware-based peripheral instances. Such construction is now split to explicit soft and non-soft types. This commit makes both types available in all ports that previously could create both software and hardware peripherals: machine.I2C and machine.SPI construct hardware instances, while machine.SoftI2C and machine.SoftSPI create software instances. This is a breaking change for use of software-based I2C and SPI. Code that constructed I2C/SPI peripherals in the following way will need to be changed: machine.I2C(-1, ...) -> machine.SoftI2C(...) machine.I2C(scl=scl, sda=sda) -> machine.SoftI2C(scl=scl, sda=sda) machine.SPI(-1, ...) -> machine.SoftSPI(...) machine.SPI(sck=sck, mosi=mosi, miso=miso) -> machine.SoftSPI(sck=sck, mosi=mosi, miso=miso) Code which uses machine.I2C and machine.SPI classes to access hardware peripherals does not need to change. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01extmod/machine_i2c: Rename type to SoftI2C and add custom print method.Damien George
Also rename machine_i2c_type to mp_machine_soft_i2c_type. These changes make it clear that it's a soft-I2C implementation, and match SoftSPI. Signed-off-by: Damien George <damien@micropython.org>
2020-06-22stm32/irq: Clean up irq.h so it does not depend on core uPy defines.Damien George
The irq.h file now just provides low-level IRQ definitions and priorities. All Python binding definitions are moved to modmachine.h, with some renaming of pyb -> machine, and also the machine_idle definition (was pyb_wfi) is moved to modmachine.c. The cc3200 and teensy ports are updated to build with these changes. Signed-off-by: Damien George <damien@micropython.org>
2020-06-02stm32/modmachine: Allow changing AHB and APB bus frequencies on STM32WB.Damien George
For now SYSCLK cannot be changed and must remain at 64MHz.
2020-05-15stm32: Add support for F412 MCUs.Thomas Roberts
2020-04-05all: Use MP_ERROR_TEXT for all error messages.Jim Mussared
2020-03-28all: Remove spaces inside and around parenthesis.Damien George
Using new options enabled in the uncrustify configuration.
2020-02-28all: Reformat C and Python source code with tools/codeformat.py.Damien George
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-13py: Add mp_raise_type helper macro and use it where appropriate.Damien George
This provides a more consistent C-level API to raise exceptions, ie moving away from nlr_raise towards mp_raise_XXX. It also reduces code size by a small amount on some ports.
2020-01-31stm32/powerctrl: Improve support for changing system freq on H7 MCUs.Damien George
This commit improves pllvalues.py to generate PLL values for H7 MCUs that are valid (VCO in and out are in range) and extend for the entire range of SYSCLK values up to 400MHz (up to 480MHz is currently unsupported).
2019-10-31stm32: Add machine.Timer with soft timer implementation.Damien George
This commit adds an implementation of machine.Timer backed by the soft timer mechanism. It allows an arbitrary number of timers with 1ms resolution, with an associated Python callback. The Python-level API matches existing ports that have a soft timer, and is used as: from machine import Timer t = Timer(freq=10, callback=lambda t:print(t)) ... t = Timer(mode=Timer.ONE_SHOT, period=2000, callback=lambda t:print(t)) ... t.deinit()
2019-09-04stm32/machine_adc: Add machine.ADC class.Damien George
2019-07-17stm32: Add initial support for STM32WBxx MCUs.Damien George
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-05stm32: Add initial support for STM32L0xx MCUs.Damien George
2019-07-04stm32/modmachine: Disable IRQs before entering bootloader.Damien George
To make sure that the code that enters the bootloader is not interrupted.
2019-07-03stm32/modmachine: Make RTC class available in machine module.Damien George
This is a start to make a more consistent machine.RTC class across ports. The stm32 pyb.RTC class at least has the datetime() method which behaves the same as esp8266 and esp32, and with this patch the ntptime.py script now works with stm32.
2019-06-25stm32: Enter bootloader via a system reset.Damien George
Entering a bootloader (ST system bootloader, or custom mboot) from software by directly branching to it is not reliable, and the reliability of it working can depend on the peripherals that were enabled by the application code. It's also not possible to branch to a bootloader if the WDT is enabled (unless the bootloader has specific provisions to feed the WDT). This patch changes the way a bootloader is entered from software by first doing a complete system reset, then branching to the desired bootloader early on in the start-up process. The top two words of RAM (of the stack) are reserved to store flags indicating that the bootloader should be entered after a reset.
2019-06-14stm32: In link script, define start of stack separately from heap end.Chris Mason
Previously the end of the heap was the start (lowest address) of the stack. With the changes in this commit these addresses are now independent, allowing a board to place the heap and stack in separate locations.
2019-05-29stm32/modmachine: In bootloader() disable caches before reset of periphsAndrew Leech
Otherwise flushing and disabling the D-cache will give a hard-fault when SDRAM is used. Fixes #4818.
2019-05-17stm32/modmachine: Create dedicated asm function to branch to bootloader.Damien George
Recent gcc versions (at least 9.1) give a warning about using "sp" in the clobber list. Such code is removed by this patch. A dedicated function is instead used to set SP and branch to the bootloader so the code has full control over what happens. Fixes issue #4785.
2019-02-15stm32/modmachine: Add ability to pass through user data to mboot.Damien George
2019-02-07stm32/modmachine: Make bootloader() enter custom loader if it's enabled.Damien George
If a custom bootloader is enabled (eg mboot) then machine.bootloader() will now enter that loader. To get the original ST DFU loader pass any argument to the function, like machine.bootloader(1).
2019-01-27stm32: Implement machine.lightsleep().Damien George
2018-12-30stm32/modmachine: Fix reset_cause to correctly give DEEPSLEEP on L4 MCU.roland
Before this fix it returned SOFT_RESET after waking from a deepsleep (standby).
2018-12-05stm32/powerctrl: Add support for standby mode on L4 MCUs.Damien George
This maps to machine.deepsleep() which is now supported.
2018-11-28stm32/powerctrl: Move (deep)sleep funcs from modmachine.c to powerctrl.cDamien George
2018-09-24stm32/powerctrl: Optimise passing of default values to set_sysclk.Damien George
2018-09-24stm32/powerctrl: Move function to set SYSCLK into new powerctrl file.Damien George
Power and clock control is low-level functionality and it makes sense to have it in a dedicated file, at least so it can be reused by other parts of the code.
2018-09-24stm32/modmachine: Re-enable PLLSAI[1] after waking from stop mode.Damien George
On F7s PLLSAI is used as a 48MHz clock source if the main PLL cannot provide such a frequency, and on L4s PLLSAI1 is always used as a clock source for the peripherals. This commit makes sure these PLLs are re-enabled upon waking from stop mode so the peripherals work. See issues #4022 and #4178 (L4 specific).
2018-09-11stm32: For MCUs that have PLLSAI allow to set SYSCLK at 2MHz increments.Damien George
MCUs that have a PLLSAI can use it to generate a 48MHz clock for USB, SDIO and RNG peripherals. In such cases the SYSCLK is not restricted to values that allow the system PLL to generate 48MHz, but can be any frequency. This patch allows such configurability for F7 MCUs, allowing the SYSCLK to be set in 2MHz increments via machine.freq(). PLLSAI will only be enabled if needed, and consumes about 1mA extra. This fine grained control of frequency is useful to get accurate SPI baudrates, for example.
2018-08-01stm32/modmachine: Get machine.sleep working on L4 MCUs.Damien George
When waking from stop mode most of the system is still in the same state as before entering stop, so only minimal configuration is needed to bring the system clock back online.
2018-07-31stm32/modmachine: Get machine.sleep working on F0 MCUs.Damien George
2018-07-08stm32: Support compiling with object representation D.Damien George
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-05-28stm32: Add support for STM32F0 MCUs.Damien George
2018-05-28stm32: Allow a board to disable MICROPY_VFS_FAT.Damien George
2018-05-28stm32: Allow to have no storage support if there are no block devices.Damien George
If no block devices are defined by a board then storage support will be disabled. This means there is no filesystem provided by either the internal flash or external SPI flash. But the VFS system can still be enabled and filesystems provided on external devices like an SD card.
2018-05-04stm32: Don't use %lu or %lx for formatting, use just %u or %x.Damien George
On this 32-bit arch there's no need to use the long version of the format specifier. It's only there to appease the compiler which checks the type of the args passed to printf. Removing the "l" saves a bit of code space.
2018-04-11stm32: Allow a board to configure the HSE in bypass mode.Damien George
To use HSE bypass mode the board should define: #define MICROPY_HW_CLK_USE_BYPASS (1) If this is not defined, or is defined to 0, then HSE oscillator mode is used.
2018-03-17stm32: Use STM32xx macros instead of MCU_SERIES_xx to select MCU type.Damien George
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-09stm32/modmachine: Support basic H7 MCU features.iabdalkader
2018-02-13stm32: Introduce MICROPY_HW_ENABLE_USB and clean up USB config.Damien George
This patch allows to completely compile-out support for USB, and no-USB is now the default. If a board wants to enable USB it should define: #define MICROPY_HW_ENABLE_USB (1) And then one or more of the following to select the USB PHY: #define MICROPY_HW_USB_FS (1) #define MICROPY_HW_USB_HS (1) #define MICROPY_HW_USB_HS_IN_FS (1)
2018-02-13stm32: Update HAL macro and constant names to use newer versions.Damien George
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-05stm32/main: Reorder some init calls to put them before soft-reset loop.Damien George
The calls to rtc_init_start(), sdcard_init() and storage_init() are all guarded by a check for first_soft_reset, so it's simpler to just put them all before the soft-reset loop, without the check. The call to machine_init() can also go before the soft-reset loop because it is only needed to check the reset cause which can happen once at the first boot. To allow this to work, the reset cause must be set to SOFT upon a soft-reset, which is the role of the new function machine_deinit().
2018-02-01stm32/modmachine: In freq(), select flash latency value based on freq.Damien George
2018-01-31stm32/modmachine: Handle case of no MICROPY_PY_MACHINE_I2C.Peter D. Gray
2017-09-06ports: Make new ports/ sub-directory and move all ports there.Damien George
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.