Commit Graph

51 Commits

Author SHA1 Message Date
Matthew McGowan
295cc18190 style(swan_r5): pre-commit whitespace style changes 2021-09-28 18:52:03 -07:00
Brandon Satrom
48f67d007e feat: add Blues Swan R5 support
complete pin mapping for Feather pins

stubbed out files needed for complilation. still to be modified

0 out all CPY modules in mpconfigboard.mk until we get the build running

add csv for pin generation for STM32L4R5

add F4R5 references in peripherals files

refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX

took a guess at the number of USB endpoint pairs to get the build done

guess was close, but wrong. It is 8

clean up peripheral DEFs

Fixes build error:
```
In file included from ../../py/mpstate.h:33,
                 from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
 static inline char *vstr_str(vstr_t *vstr) {
 ^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)

A grep through the sources revealed where this flag was being set for the stm ports.

With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!

working build with minimal set of modules for the Blues Swan r5

chore:change header copyright name to Blues Wireless Contributors

USB operational.  Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)

USART working

adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins.  I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output.  The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.

short circuit implementation of backup memory for the STM32L4

all the ports

remove company name from board name to be consistent with the Arduino board definition.

add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected.  Confirmed I2C timing.

fix board name

fix incorrect pin definition. add test to allow manual check of each output pin

analog IO

code changes for WebUSB. Doesn't appear to work, will revisit later.

ensure that `sys.platform` is available

checkin missing file

feat: make room for a larger filesystem so the sensor tutorial will fit on the device.

fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.

fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger

chore(Swan R5): update peripherals pins from `parse_af_csv.py` output

optimize flash sector access
2021-09-28 18:52:02 -07:00
Scott Shawcroft
d2860b58b0
Check background pending before sleep
There is a race between when we run background tasks and when we
sleep. If an interrupt happens between the two, then we may delay
executing the background task. On some ports we checked this for
TinyUSB already. On iMX RT, we didn't which caused USB issues.
This PR makes it more generic for all background tasks including
USB.

Fixes #5086 and maybe others.
2021-08-19 12:18:13 -07:00
Lucian Copeland
525b34b042 Fix formatting and broken links
Implmements missed pre-commit changes for all files, and fixes links broken by
cleanup in #4698
2021-05-10 18:04:43 -04:00
Lucian Copeland
bab5a22f0c Fix build issues
H7 compatibility problems in port.c and peripherals/exti
NRF build failures due to new use of const for PinAlarm pin objects
Isolated board flash overage on blackpill_with_flash, remove audio modules
2021-04-29 14:48:16 -04:00
Lucian Copeland
8ce89860e6 Pass pre-commit formatting 2021-04-21 17:34:13 -04:00
Lucian Copeland
e0024c70de Merge remote-tracking branch 'upstream/main' into stm-alarm 2021-04-15 16:32:30 -04:00
Lucian Copeland
8a2143f161 Clean up comments and debugging pins 2021-04-02 17:40:40 -04:00
Lucian Copeland
66a1583183 Implement fake and true deep sleep alarm differentiation 2021-04-02 15:13:10 -04:00
Lucian Copeland
4f52554eb3 Fix to RTC reset 2021-04-01 20:53:25 -04:00
Lucian Copeland
d35a307ffa Merge branch 'sleep-api-update' into stm-alarm 2021-03-29 12:27:25 -04:00
Lucian Copeland
529fb52309 Style changes and wakeup detection 2021-03-27 13:16:12 -04:00
Artyom Skrobov
b40d072648 [stm] implementation of audiopwmio
Based on nrf PWMAudioOut by @jepler and stm PulseOut by @hierophect

Tested on a Meowbit
2021-03-26 13:18:01 -04:00
Lucian Copeland
d8a2d69e10 Working deep sleep via RTC reset, with debug pins 2021-03-21 13:15:44 -04:00
microDev
a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Lucian Copeland
6b2c9985ff Extract RTC, implement fake RTC deepsleep 2021-03-11 17:50:05 -05:00
Lucian Copeland
f1792c8474 Extract EXTI, create base sleep framework 2021-03-02 11:41:53 -05:00
Scott Shawcroft
40118bcf57
Add board_deinit for use with sleep
This changes lots of files to unify `board.h` across ports. It adds
`board_deinit` when CIRCUITPY_ALARM is set. `main.c` uses it to
deinit the board before deep sleeping (even when pretending.)

Deep sleep is now a two step process for the port. First, the
port should prepare to deep sleep based on the given alarms. It
should set alarms for both deep and pretend sleep. In particular,
the pretend versions should be set immediately so that we don't
miss an alarm as we shutdown. These alarms should also wake from
`port_idle_until_interrupt` which is used when pretending to deep
sleep.

Second, when real deep sleeping, `alarm_enter_deep_sleep` is called.
The port should set any alarms it didn't during prepare based on
data it saved internally during prepare.

ESP32-S2 sleep is a bit reorganized to locate more logic with
TimeAlarm. This will help it scale to more alarm types.

Fixes #3786
2020-12-08 10:52:25 -08:00
Christian Walther
c7404a3ff8 Add movable allocation system.
This allows calls to `allocate_memory()` while the VM is running, it will then allocate from the GC heap (unless there is a suitable hole among the supervisor allocations), and when the VM exits and the GC heap is freed, the allocation will be moved to the bottom of the former GC heap and transformed into a proper supervisor allocation. Existing movable allocations will also be moved to defragment the supervisor heap and ensure that the next VM run gets as much memory as possible for the GC heap.

By itself this breaks terminalio because it violates the assumption that supervisor_display_move_memory() still has access to an undisturbed heap to copy the tilegrid from. It will work in many cases, but if you're unlucky you will get garbled terminal contents after exiting from the vm run that created the display. This will be fixed in the following commit, which is separate to simplify review.
2020-11-28 17:50:23 +01:00
Scott Shawcroft
56427d9abe
Fix stm sleep too long 2020-10-13 14:02:29 -07:00
Scott Shawcroft
a0e5e961c5
Fix STM RTC read so it's atomic.
Fixes #3376
2020-10-12 17:43:25 -07:00
Jeff Epler
726dcdb60a Add some NORETURN attributes
I have a function where it should be impossible to reach the end, so I put in a safe-mode reset at the bottom:
```
int find_unused_slot(void) {
    // precondition: you already verified that a slot was available
    for (int i=0; i<NUM_SLOTS; i++) {
        if( slot_free(i)) {
            return i;
        }
    }
    safe_mode_reset(MICROPY_FATAL_ERROR);
}
```
However, the compiler still gave a diagnostic, because safe_mode_reset was not declared NORETURN.

So I started by teaching the compiler that reset_into_safe_mode never returned.  This leads at least one level deeper due to reset_cpu needing to be a NORETURN function.  Each port is a little different in this area.  I also marked reset_to_bootloader as NORETURN.
Additional notes:

 * stm32's reset_to_bootloader was not implemented, but now does a bare reset.  Most stm32s are not fitted with uf2 bootloaders anyway.
 * ditto cxd56
 * esp32s2 did not implement reset_cpu at all.  I used esp_restart().  (not tested)
 * litex did not implement reset_cpu at all.  I used reboot_ctrl_write.  But notably this is what reset_to_bootloader already did, so one or the other must be incorrect (not tested).  reboot_ctrl_write cannot be declared NORETURN, as it returns unless the special value 0xac is written), so a new unreachable forever-loop is added.
 * cxd56's reset is via a boardctl() call which can't generically be declared NORETURN, so a new unreacahble "for(;;)" forever-loop is added.
 * In several places, NVIC_SystemReset is redeclared with NORETURN applied.  This is accepted just fine by gcc.  I chose this as preferable to editing the multiple copies of CMSIS headers where it is normally declared.
 * the stub safe_mode reset simply aborts.  This is used in mpy-cross.
2020-09-28 18:55:56 -05:00
Scott Shawcroft
6857f98426
Split pulseio.PWMOut into pwmio
This gives us better granularity when implementing new ports because
PWMOut is commonly implemented before PulseIn and PulseOut.

Fixes #3211
2020-08-18 13:08:33 -07:00
Jeff Epler
d73505a027 stm: fix if-guard of conditional code 2020-07-30 07:18:12 -05:00
Jeff Epler
4adbd23b75 stm: Add sdioio support for feather_stm32f405_express
Currently, only the bus specs of the stm32f405xx have been coded.
Other stm-family chips need (at a minimum) the specs added in their
periph.[ch] files.
2020-07-30 07:18:02 -05:00
Lucian Copeland
ab9a64eafa Add timer allocator, adjust pulsio to use general purpose timers 2020-07-01 10:35:49 -04:00
Lucian Copeland
c88a8e66c6 Minor comment fix 2020-06-10 13:22:21 -04:00
Lucian Copeland
b414f82669 Add DTCM and ITCM support to F7 series 2020-06-09 18:01:52 -04:00
Lucian Copeland
ad0971fb25 Override HAL_Delay and HAL_GetTick 2020-06-05 13:56:32 -04:00
Lucian Copeland
a0977cac7b Merge remote-tracking branch 'upstream/master' into stm32-LSE-startup-fix 2020-06-04 16:15:38 -04:00
Lucian Copeland
d14e34449b Rework LSE clock init, allow clock overrides 2020-06-04 13:21:29 -04:00
Diego Elio Pettenò
dd5d7c86d2 Fix up end of file and trailing whitespace.
This can be enforced by pre-commit, but correct it separately to make it easier to review.
2020-06-03 10:56:35 +01:00
Scott Shawcroft
3c1469b0a5
Add port_fixed_stack for more builds 2020-05-15 16:22:33 -07:00
Lucian Copeland
94949fb46f Add recovery domain write access, adjust stack 2020-05-11 18:02:40 -04:00
Lucian Copeland
5249a7b02c Add timeout and adjustment to LSI 2020-05-08 12:36:39 -04:00
Scott Shawcroft
b277944cf0
Fix STM so it matches the correct RTC fields. 2020-04-22 11:10:51 -07:00
Scott Shawcroft
17d038830d
Use our own flag for board crystal config. 2020-04-21 14:14:30 -07:00
Scott Shawcroft
bebf27e733
Merge remote-tracking branch 'adafruit/master' into lower_power
This isn't perfect and needs a bit more testing.
2020-04-20 18:25:13 -07:00
Lucian Copeland
9e49fc13f4 startup file crash fix, H7 bin fix 2020-04-16 17:33:48 -04:00
Lucian Copeland
6427994b14 Implement requested changes 2020-04-15 10:22:51 -04:00
Lucian Copeland
5ac38c95cc Various requested fixes 2020-04-13 12:03:05 -04:00
Lucian Copeland
92a0621e59 Add busio support, cleanup 2020-04-09 13:43:19 -04:00
Scott Shawcroft
01941c027b
Fix up STM
Enable the Alarm IRQ earlier and correct bit clearing.
2020-04-08 14:41:57 -07:00
Scott Shawcroft
d0a25ca9ac
Tweaks based on dhalberts feedback 2020-04-08 10:49:46 -07:00
Lucian Copeland
9761672d42 Linker file restructure, TCM and MPU additions 2020-04-03 16:33:18 -04:00
Lucian Copeland
c4db8b87e2 Add F7 and H7 Support to the STM32 port
Restructures the STM port of Circuitpython to be more generic about the STM32 chip lines to support
the F7 and H7 series of chips. Adds the new Packages directory to organize different chip layouts
between lines. Makes general changes to the Makefile to condense board-level flags to the minimum
and support the new chip series. Adds the new chip line to the Peripherals directory, along with
new python tools used to generate peripheral text automatically in the tools/ directory.
2020-03-26 18:01:17 -04:00
Scott Shawcroft
ea0ce39962
Simplify STM a bit. 2020-03-24 15:49:24 -07:00
Scott Shawcroft
c0c4c4403a
Factor out stm32f4xx_hal_conf.h 2020-03-23 14:46:25 -07:00
Scott Shawcroft
2623022c84
Initial work for STM32. Need to fix us delay and PulseIn still. 2020-03-20 12:58:34 -07:00
Lucian Copeland
18442c5b00 Merge remote-tracking branch 'upstream/master' into stm32-port-namechange 2020-03-12 15:40:44 -04:00