1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

56 Commits

Author SHA1 Message Date
Benjamin Valentin
3fbf473a07 cpu/sam0_common: implement periph_rtc_mem 2021-09-03 11:43:43 +02:00
benpicco
6929577c76
Merge pull request #15845 from benpicco/boards/adafruit-itsybitsy-m4
boards: add adafruit-itsybitsy-m4
2021-02-09 19:41:43 +01:00
Benjamin Valentin
73f58bfa04 cpu/samd5x: Kconfig: don't provide periph_eth on CPU level
It's up to the board to expose it.
2021-02-09 16:15:33 +01:00
Benjamin Valentin
9c1455d55f cpu: make pm_layered a DEFAULT_MODULE
Allow to disable pm_layered in the bootloader to save some ROM.
2021-01-27 13:21:20 +01:00
Benjamin Valentin
8004aa4d34 cpu/sam0_common: not every CPU has DMA 2021-01-12 15:48:37 +01:00
dylad
c934d5dde3 kconfig: add PERIPH_ETH feature to samd5x 2020-12-13 22:30:54 +01:00
Benjamin Valentin
8f72212eb0 cpu/sam0_common: SPI: add support for QSPI in SPI mode
We can use the QSPI peripheral as an additional (non-Quad) SPI peripheral.
2020-12-11 22:33:08 +01:00
Benjamin Valentin
edbb5fe9d0 cpu/samd5x: add NVM User Page Mapping 2020-11-10 12:18:47 +01:00
Bas Stottelaar
22243aec7a cpu/*: realign ENABLE_DEBUG 2020-10-23 00:46:26 +02:00
Bas Stottelaar
ab6188cea3 cpu/*: add missing include of assert.h 2020-10-22 11:13:08 +02:00
Benjamin Valentin
310eb4970c cpu/sam0_common: GPIO: use tamper detection to wake from Deep Sleep
On samd5x only the RTC can wake the CPU from Deep Sleep (pm modes 0 & 1).
The external interrupt controller is disabled, but we can use the tamper
detection of the RTC.

If an gpio interrupt is configured on one of the five tamper detect pins,
those can be used to wake the CPU from Deep Sleep / Hibernate.
2020-09-17 18:46:25 +02:00
Benjamin Valentin
cd5a847684 cpu/sam0_common: define CPU_FAM based on CPU_MODEL 2020-08-24 16:13:18 +02:00
Benjamin Valentin
7ed4979148 cpu/samd5x: define CPU_COMMON_SAMD5X symbol and use it 2020-08-24 16:13:18 +02:00
Benjamin Valentin
2cd0236a8c cpu/samd5x: add all parts to Kconfig 2020-08-24 16:11:48 +02:00
János Brodbeck
7a7f06a3e1
cpu/samd5x: add ADC resolution type 2020-08-19 17:48:37 +02:00
Benjamin Valentin
548f59d380 cpu/samd5x: remove RTC workaround
This is no longer needed.
2020-07-31 22:00:09 +02:00
Leandro Lanzieri
1c9a95e955
cpu/samd5x: Add Kconfig symbols 2020-07-16 15:33:29 +02:00
Benjamin Valentin
93b43e5753 cpu/samd5x: make SAM0_GCLK_TIMER configurable 2020-06-20 00:25:54 +02:00
Benjamin Valentin
fba3aab2f3 cpu/samd5x: rename GCLK defines
Now that the GCLK defines are not always at a fixed frequency, rename
them to better reflect this.
2020-06-20 00:25:54 +02:00
Benjamin Valentin
17304d390c cpu/samd5x: use MHZ() macro 2020-06-20 00:25:53 +02:00
Benjamin Valentin
b5f407f9a4 cpu/samd5x: enable buck voltage regulator when possible
When an external oscillator is used and the internal fast oscillators
are off, we can enable the buck converter if the board supports it.
2020-06-20 00:25:53 +02:00
Benjamin Valentin
849c76578a cpu/samd5x: allow to use XOSC as clock source
Allow to run the main clock and all peripheral clocks off XOSC.
This is necessary if we want to use the buck voltage regulator.
2020-06-20 00:10:08 +02:00
Francisco Molina
36baec4512
cpu/samd5x: add unified rtt configuration 2020-06-19 09:16:23 +02:00
Leandro Lanzieri
4d65bc8e0a
cpu: Rename CPU_ARCH to CPU_CORE 2020-06-16 12:05:40 +02:00
73c8911e62
cpu/samd5x: Add DMA peripheral to init 2020-06-12 20:04:05 +02:00
Benjamin Valentin
bfb3d52a63 cpu/sam0_common: implement periph/dac
The sam0 MCUs all have a DAC peripheral.
The DAC has a resulution of 10 or 12 bits and can have one or two
output channels.

The output pins are always hard-wired to PA2 for DAC0 and PA5 for DAC1
if it exists.

On the same54-xpro I would only get a max value of ~1V when using the
internal reference, so I configured it to use an external voltage reference.

The external reference pin is hard-wired to PA3, so you'll have to connect
that to 3.3V to get results.
2020-05-02 18:31:55 +02:00
Benjamin Valentin
49fda3e900 cpu/samd5x: don't run DFLL on-demand
The DFLL on samd5x has a hardware bug that requires a special
re-enabling sequence when it is disabled and then re-enabled again.

When running the clock on-demand, the hardware handles the disabling
and re-enabling so that sequence does not get executed.

To reproduce, run `tests/periph_uart` on `same54-xpro`.

Without this patch the test will get seemingly stuck on `sleep_test()`.
(In fact it keeps running, but the DFLL has the wrong frequency so the
UART baudrate is wrong).

In this test, on `same54-xpro` only UART0 is sourced from DFLL.
So if the UART is disabled the DFLL will be turned off as well.
2020-04-02 20:11:41 +02:00
Benjamin Valentin
5d123cbb22 cpu/sam0_common: distribute PM_NUM_MODES among siblings
Also adapt the defines to the documentation

 - CPUs define up to 4 power modes (from zero, the lowest power mode,
   to PM_NUM_MODES-1, the highest)
 - >> there is an implicit extra idle mode (which has the number PM_NUM_MODES) <<

Previously on saml21 this would always generate pm_set(3) which is an illegal state.
Now pm_layered will correctly generate pm_set(2) for IDLE modes.

Idle power consumption dropped from 750µA to 368µA and wake-up from standby is also
possible. (Before it would just enter STANDBY again as the mode register was never
written with the illegal value.)
2020-04-01 18:10:23 +02:00
Benjamin Valentin
f6139ae346 cpu/samd5x: work around errata when (re-)initializing DFLL
When a previously disabled DFLL gets enabled again, the frequency will
be incorrect. Follow the procedure outlined in the errata sheet, section 2.8.3
to work around the issue.

This fixes wake from standby.
2020-04-01 15:41:20 +02:00
Dylan Laduranty
6bba4188fc
Merge pull request #13764 from benpicco/cpu/saml11/use_buck_converter
cpu/saml1x: select buck voltage regulator when possible
2020-04-01 14:47:47 +02:00
Dylan Laduranty
6a788b3c02
Merge pull request #13761 from RIOT-OS/cpu/samd5x/rtc_workaround
cpu/samd5x: disable RTC on init to prevent undefined RTC state
2020-03-31 17:25:25 +02:00
Benjamin Valentin
895eb943d8 cpu/sam0_common: add cpu_pm_cb_enter()/leave()
This allows to implement needed work-arounds surrounding sleep on
a per-MCU basis.
2020-03-31 17:18:58 +02:00
Benjamin Valentin
d12abe6a2b cpu/samd5x: disable RTC on init to prevent undefined RTC state
When changing the clock configuration while the RTC is running, the
RTC may end up in an undefined state that leaves it unresponsive.

The RTC is not reset to stay persistent across reboots/hibernate, so
it will not be reset on init.
Instead, disable the RTC while configuring the clocks, rtc_init() will
take care of re-enabling it.

@dylad introduced this workaround for saml21, samd5x needs it too.

To reproduce, set the CLOCK_CORECLOCK of a samd5x board (e.g. same54-xpro)
to 48 MHz.
Run any RTC application. The CPU will be stuck in _wait_syncbusy() after
a reboot.
This patch will fix this. (You will need to power-cycle the board if the
RTC has entered the stuck state as it will never be reset.)
2020-03-31 15:34:55 +02:00
Leandro Lanzieri
daf38f2500
cpu/samd5x: Add Kconfig file 2020-03-31 13:39:40 +02:00
68ec8b2c2b
Merge pull request #13391 from kaspar030/mpu_feature
cpu/cortex-m: turn MPU support into a feature
2020-03-04 07:09:40 +01:00
a3c527fdbc cpu/*: add cortex_mpu to known-to-support CPU families 2020-03-03 22:59:41 +01:00
benpicco
0edfd13df0
Merge pull request #13310 from benpicco/sam0-exti-common
cpu/sam0_common: use generic exti_config
2020-02-26 08:40:49 +01:00
Juergen Fitschen
1265efc785 cpu/sam0*: Wrap cortexm_sleep call 2020-02-24 11:48:13 +01:00
Benjamin Valentin
fd9a247200 cpu/sam0_common: use generic exti_config
Creating an `exti_config` array for a new MCU manually is tedious and error prone.
Luckiely all information is already availiable in the vendor files.

Credit for this discovery & method goes to @Sizurka

The file was generated with

```C

int main(void) {
        puts("static const int8_t exti_config[PORT_GROUPS][32] = {");

        for (unsigned port = 1; port < 5; ++port) {
                printf("#if PORT_GROUPS >= %d\n{\n", port);
                for (unsigned pin = 0; pin < 32; ++pin) {
                        printf("#ifdef PIN_P%c%02uA_EIC_EXTINT_NUM\n", '@' + port, pin);
                        printf("    PIN_P%c%02uA_EIC_EXTINT_NUM,\n", '@' + port, pin);
                        printf("#else\n    -1,\n#endif\n");
                }
                printf("},\n#endif\n\n");
        }

        puts("};");

        return 0;
}
```

No changes in generated code are expected, but this makes adding new members
of the sam0 CPU families much easier.
2020-02-20 11:23:51 +01:00
Benjamin Valentin
b7b52c4c57 cpu/samd5x: use ONDEMAND bit to run clocks on demand
Set the ONDEMAND bit so clocks are only run if they have a user configured.

This saves 390 µA on same54-xpro.

 examples/default:

    before: 3.88 mA
    after : 3.49 mA

 examples/gnrc_networking: (with REB215-XPRO EXT3)

    before: 13.29 mA
    after : 12.9  mA
2020-02-19 16:56:35 +01:00
d7c0102115
cpu/cortexm: move CPU_ARCH/FAM to Makefile.features 2020-02-17 16:02:48 +01:00
Benjamin Valentin
bd1953dd80 cpu/sam0_common: use vendor files to dispatch MCU headers
Instead of manually re-creating the files from ASF, just use
the vendor provided dispatch headers and ease the maintainance
burden.
2020-02-06 19:52:05 +01:00
Benjamin Valentin
38b6ee56f3 cpu/sam0: use defines for GCLK IDs
Give the clocks explicit names to better identify their meaning.
2020-02-04 21:16:54 +01:00
Benjamin Valentin
1496149bba cpu/sam0: don't hard-code peripheral clocks
Instead of hard-coding the peripheral clocks to CLOCK_CORECLOCK
introduce helper functions to return the frequency of the individual
GCLKs and use those for baud-rate calculations.

This requires the GCLK to be part of the peripheral's config struct.
While this is already the case for most peripherals, this also adds
it for those where it wasn't used before.

As it defaults to 0 (CLOCK_CORECLOCK) no change is to be expected.
2020-02-04 21:06:21 +01:00
925445d0ff
cpu/sam0: factorize dependencies in Makefile.dep 2020-01-28 13:18:39 +01:00
Benjamin Valentin
0d977b3b3c cpu/sam0_common/periph/uart: implement buffered write
Implement interrupt based uart_write() using a tsrb for the TX buffer.

To enable it, add

    USEMODULE += periph_uart_nonblocking

to your Makefile.
2019-11-27 19:01:00 +01:00
Benjamin Valentin
9df377d699 cpu/sam*: pm: make use of DEBUG_PUTS()
`pm_set()` gets called by the idle thread whose stack is too small
for normal DEBUG()/printf().

Use DEBUG_PUTS() instead to print the static debug strings.
2019-11-22 01:30:03 +01:00
Francisco Molina
347a0fc804 cpu/ boards/: remove exports for CPU_FAM 2019-10-18 08:55:33 +02:00
Francisco Molina
5e9b92a326 cpu: remove CPU_ARCH exports 2019-10-18 08:55:33 +02:00
Benjamin Valentin
618449c7bd cpu/samd5x: hook up backup RAM 2019-10-01 18:39:40 +02:00