These have by default FAT support. The SAMD21 build does not support FAT.
The nrf port also implements os.sync(), but has it's own copy of moduos.c.
Code size increases seen: 40 to 56 bytes.
Signed-off-by: robert-hh <robert@hammelrath.com>
By specifying rts=pin(x) and/or cts=Pin(x) in the constructor. The pad
numbers for the UART pins are fix in this case: TX must be at pad 0, RX at
pad 1, RTS at pad 2 and CTS at pad 3.
repr(uart) shows the pin names for rts and cts, if set. In case of a RX
overflow, the rx interrupt will be disabled instead of just discarding the
data. That allows RTS to act.
If RTS is inactive, still 2 bytes can be buffered in the FIFO.
Signed-off-by: robert-hh <robert@hammelrath.com>
With Crystal: set the crystal startup wait time to 1 second. It was 2
seconds before, and that seeemed too long.
With USB-Sync: scan for up to 1 second for the USB to be registered and
carry on with boot as soon as it it. Before, the code just waited for
500ms.
Side change: improve related comments.
Signed-off-by: robert-hh <robert@hammelrath.com>
Such that they are easier to adapt. The maximum code size is set by:
MICROPY_HW_CODESIZE=xxxK
in mpconfigmcu.mk for the MCU family as default or in mpconfigboard.mk for
a specific board. Setting the maximum code size allows the loader to error
out if the code gets larger than the space dedicated for it.
Signed-off-by: robert-hh <robert@hammelrath.com>
Even if boards do not have a clock crystal. In that case, the clock
quality will be very poor.
Always having machine.RTC means that the date/time can be set in a way that
is consistent with other ports.
This commit also removes the special code in modutime.c for devices without
the RTC class.
Signed-off-by: Damien George <damien@micropython.org>
For compatibility with other ports. Code increase up to ~1250 bytes for
SAMD21. The feature is configurable via MICROPY_PY_MACHINE_PIN_BOARD_CPU
in case flash memory is tight.
This drops the `.cpu` directive from the ARM gchelper_*.s files. Having
this directive breaks the linker when targeting older CPUs (e.g. `-mthumb
-mthumb-interwork` for `-mcpu=arm7tdmi`). The actual target CPU should be
determined by the compiler options.
The exact CPU doesn't actually matter, but rather the supported assembly
instruction set. So the files are renamed to *_thumb1.s and *thumb2.s to
indicate the instruction set support instead of the CPU support.
Signed-off-by: David Lechner <david@pybricks.com>
Including the uasyncio scripts and the drivers for DHT, DS18x20 and
onewire. The uasyncio scripts need about 8k of flash and are not included
for the SAMD21 boards by default.
This removes the difference in the time.ticks_us() range between SAMD21 and
SAMD51.
The function mp_hal_ticks_us_64() is added and used for:
- SAMD51's mp_hal_ticks_us and mp_hal_delay_us().
For SAMD21, keep the previous methods, which are faster.
- mp_hal_ticks_ms() and mp_hal_tick_ms_64(), which saves some bytes
and removes a potential race condition every 50 days.
Also set the us-counter for SAMD51 to 16 MHz for a faster reading of the
microsecond value.
Note: With SAMD51, mp_hal_ticks_us_64() has a 60 bit range only, which is
still a long time (~36000 years).
Methods implemented are:
- rtc.init(date)
- rtc.datetime([new_date])
- rtc.calibration(value)
The presence of this class can be controlled by MICROPY_PY_MACHINE_RTC. If
the RTC module is used, the time module uses the RTC as well.
For boards without a 32kHz crystal, using RTC makes no sense, since it will
then use the ULP32K oscillator, which is not precise at all. Therefore, it
will by default only be enabled for boards using a crystal, but can be
enabled in the respective mpconfigboard.h.
Which just sets the CPU clock to 200kHz and switches the peripheral clock
off. There are two modes:
machine.lightsleep(duration_ms)
and
machine.lightsleep()
In any mode any configured pin.irq() event will terminate the sleep.
Current consumption in lightsleep for some boards:
- 1.5 - 2.5 mA when supplied trough an active USB
(Seeed XIAO w/o power LED, Adafruit ItsyBitsy)
- 0.8 - 2 mA when supplied through Gnd/+5V (Vusb)
(Seeed XIAO w/o power LED, Adafruit ItsyBitsy)
- < 1 mA for SAMD51 when supplied trough a battery connector
(Sparkfun Thing SAMD51 plus)
Related change: move the calls to SysTick_Config() into set_cpu_freq(). It
is required after each CPU freq change to have ticks_ms run at the proper
rate.
Tested with a SD card connected to a SAMD51 board. The SEEED WIO terminal
has a SD-Card reader built-in.
Also a side change to remove a few obsolete lines from Makefile.
The range is 1MHz - 48 MHz. Note that below 8 MHz there is no USB support.
The frequency will be set to an integer fraction of 48 MHz. And after
changing the frequency, the peripherals like PWM, UART, I2C, SPI have to be
reconfigured.
Current consumption e.g. of the Seeed Xiao board at 1 MHz is about 1.5 mA,
mostly caused by the on-board LED (green LED with 1k resistor at 3.3V).
The value given for machine.freq(f) is extend to the range of 1_000_000 to
200_000_000. Frequencies below 48 MHz will be forced to an integer
fraction of 48 MHz. At frequencies below 8 MHz USB is switched off. The
power consumption e.g. of ADAFRUIT_ITSYBITSY_M4_EXPRESS drops to about
1.5 mA at 1 MHz.
Since the peripheral frequency is dropped as well, timing e.g. of PWM,
UART, I2C and SPI is affected and frequency/baud rate has to set again
after a frequency change below 48 MHz.
This makes it so that all a port needs to do is set the relevant variables
and "include extmod.mk" and doesn't need to worry about adding anything to
OBJ, CFLAGS, SRC_QSTR, etc.
Make all extmod variables (src, flags, etc) private to extmod.mk.
Also move common/shared, extmod-related fragments (e.g. wiznet, cyw43,
bluetooth) into extmod.mk.
Now that SRC_MOD, CFLAGS_MOD, CXXFLAGS_MOD are unused by both extmod.mk
(and user-C-modules in a previous commit), remove all uses of them from
port makefiles.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Changes are:
- The pin-af-table-SAMDxx.csv file are moved to the mcu directories with
the name as pin-af-table.csv.
- The handling in Makefile and pin_af.c is simplified.
Two new compile flags are:
MICROPY_HW_DFLL_USB_SYNC: Effective only if DFLL48 does not run from the
crystal. It will synchronize the DFLL48M clock with the USB's SOF pulse.
If no USB is connected, it will fall back to open loop mode. The DFLL48M
clock is then pretty precise, but with a higher clock jitter at SAMD51
devices.
MICROPY_HW_MCU_OSC32KULP: Effective only if the devics uses a crystal as
clock source. Run the MCU clock from the ULP 32kHz oszillator instead of
the crystal. This flag was added to cater for a interference problem of
the crystal and Neopixel/Debug pins at Adafruit FEATHER Mx boards, which
causes the board to crash. Drawback: ticks_ms() and time.time() vs. than
ticks_us() and the peripherals like PWM run at not synchronous clocks.
Changes are:
- Set the feature level for each MCU: CORE features for SAMD21, and EXTRA
features for SAMD51.
- Remove all definitions that are included in the core feature level.
- Keep the default settings for feature level and float, to make the choice
obvious.
It can be enabled/disabled by a configuration switch. The code size
increase is 308 bytes, but it requires RAM space for buffers, the larger
UART object and root pointers.