Wykres commitów

15 Commity (dbb0019666a3270b0ed032e2cb9479eadc599c46)

Autor SHA1 Wiadomość Data
robert-hh fc9d66fac6 samd/machine_rtc: Add the machine.RTC class.
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.
2022-10-25 23:20:09 +11:00
robert-hh be31fde012 samd/mcu: Make some settings in mpconfigmcu.h conditional.
And set the default for MICROPY_PY_MATH as 1 for both MCU types.
2022-10-25 23:13:58 +11:00
robert-hh ddd41b8bbf samd/clock_config: Document the #defines use in init_clocks().
Which may be set in the respective mpconfigboard.h files.
2022-10-25 23:10:27 +11:00
robert-hh 03075a6839 samd/modmachine: Implement machine.lightsleep().
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.
2022-10-25 23:07:27 +11:00
robert-hh 1c32cec7f1 samd/clock_config: Support changing machine.freq() for SAMD21.
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).
2022-10-25 22:40:16 +11:00
robert-hh 972212907d samd/mcu: Use lf2s for SAMD51 and lfs1 for SAMD21.
Using lfs1 gives a smaller code, but lfs2 has more features.
2022-10-06 23:14:21 +11:00
robert-hh 9f4df86016 samd/boards: Move the flash filesystem definitions to the linker files.
They used to be in mpconfigmcu.h, but have to be different for different
chip variants, like the SAMD51x20.
2022-10-06 23:14:08 +11:00
robert-hh 00dcf04643 samd/mcu: Add floating point suport for SAMD21 devices.
For consistency it should be there.
2022-10-06 23:10:49 +11:00
robert-hh d9338aabc5 samd: Change the symbol names for the peripheral clocks.
From APB_FREQ to DFLL48M_FREQ, and from apb_freq to peripheral_freq.
2022-10-06 23:10:08 +11:00
robert-hh 85fb8b8b02 samd/pin_af: Simplify the pin-af-table handling.
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.
2022-10-06 23:05:46 +11:00
robert-hh 20e7313453 samd/clock_config: Add HW_DFLL_USB_SYNC and HW_MCU_OSC32KULP extensions.
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.
2022-10-06 23:03:08 +11:00
robert-hh f00356a486 samd/clock_config: Split clock_config.c to separate SAMD21/SAMD51 files.
And put the file into the mcu directory.  The file got a little bit long
and hard to read.
2022-10-06 23:01:58 +11:00
robert-hh 929dfc66a3 samd/mpconfigport: Restructure to use ROM feature levels.
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.
2022-10-06 23:00:44 +11:00
robert-hh 9a567b04e7 samd/machine_uart: Support buffered TX for UART.
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.
2022-10-06 22:57:37 +11:00
robert-hh aa6dbbcffd samd/mcu: Factor out MCU policy for SAMD21 and SAMD51.
Which contains a mpconfigmcu.h, mpconfigmcu.mk and manifest.py file for
each MCU group.  That looks better than the previous choice.
2022-10-06 22:56:13 +11:00