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

521 Commits

Author SHA1 Message Date
benpicco
228ba83dc6
Merge pull request #17184 from benpicco/drivers/dose-standby_fix
drivers/dose: fix standby mode
2021-12-07 11:09:43 +01:00
benpicco
05b9c84369
Merge pull request #17255 from MrKevinWeiss/pr/kconfig/sam54
.murdock: Add same54-xpro to kconfig tests
2021-11-29 23:22:23 +01:00
MrKevinWeiss
fba9cad987
periph/gpio: Model TAMPER_WAKE for kconfig 2021-11-29 09:12:28 +01:00
Gunar Schorcht
007e29ebb5 cpu/periph/i2c: update implementations to new I2C API
Make all `spi_acquire` implementations return `void` and add assertions to check for valid device identifier where missing.
2021-11-29 06:35:25 +01:00
Benjamin Valentin
669104d841 cpu/sam0_common: SPI: don't perform DMA transfer for small buffers
Setting up a DMA transfer can take longer than sending out a buffer
byte by byte if the buffer is small.

DMA only shows advantages for large buffers, using it for every transfer
will cause a net slowdown.

Since we did not come up with a good way to determine the treshold based
on the SPI frequency, just use a fixed buffer for now so that DMA can be
used without slowing things down overall.
2021-11-19 17:22:51 +01:00
a6b6f43ce2
sam0_common/usbdev: Adapt to xmit API 2021-11-16 20:17:04 +01:00
Benjamin Valentin
18cdd100a9 cpu/sam0_common: uart: set oversampling based on baud rate
In Asynchronous Fractional baud rate mode, the baud rate can not be
greater than the source frequency divided by the oversampling (8, 16).

Currently we are always using 16x oversampling.
This makes it impossible to e.g. set a 2 MHz UART baud rate on the 16 MHz
`saml10-xpro`.

With this change, the oversampling is automatically reduced to 8x which
allows us to set 16 MHz / 8 -> 2 MHz baud rate.
2021-11-11 17:03:05 +01:00
Benjamin Valentin
1ef458a701 cpu/sam0_common: uart: wait for synchronisation done after powerup
Otherwise we lose settings if we write to it right after uart_poweron()
2021-11-11 14:32:42 +01:00
dylad
8842377e93 cpu/sam0: prevent disabled irq from being called
Reported-by: biboc <bapclenet@gmail.com>
Signed-off-by: dylad <dylan.laduranty@mesotic.com>
2021-11-05 18:21:21 +01:00
d9dd0cc3b1
cpu/sam0_common: Uncrustified and fixed static-check issues 2021-11-04 13:49:34 +01:00
MrKevinWeiss
9b6a63a951
drivers/kconfig: simplify shared rtt/rtc hardware in kconfig 2021-10-14 11:28:46 +02:00
Benjamin Valentin
3fbf473a07 cpu/sam0_common: implement periph_rtc_mem 2021-09-03 11:43:43 +02:00
Francisco
a1cbcc9ede
Merge pull request #15902 from maribu/spi-api-change-1
drivers/periph_spi: let spi_acquire return void
2021-09-02 08:50:56 +02:00
Marian Buschsieweke
f04b522601
cpu/periph_spi: update implementations to new API
Make all spi_acquire() implementations return `void` and add assertions to
check for valid parameters, where missing.
2021-09-01 21:38:40 +02:00
Jan Romann
4384795cb9
treewide: Remove excessive newlines 2021-08-13 19:50:38 +02:00
Benjamin Valentin
ddf96f7000 cpu/saml21: uart: disable fractional baud rate
SERCOM5 on SAM L21 does not support fractional baud rate mode.
Instead of special-casing it, just use arithmetic baud rate mode
in general on this CPU, as I'm not sure what the advantages of fractional
baud rate mode are.

fixes #16692
2021-07-30 11:28:02 +02:00
benpicco
feac187d54
Merge pull request #16506 from benpicco/drivers/dose-rx_start
drivers/dose: make use of start condition received interrupt
2021-07-28 17:21:29 +02:00
Benjamin Valentin
02269ef869 cpu/sam0_common: implement periph_uart_rx_start feature 2021-07-28 16:19:04 +02:00
dylad
950c71cc10 cpu/sam0: improve ethernet driver resilience
In case of network heavy traffic on the Ethernet, interrupts
fire faster than the netdev thread can process them and we
run out of buffers. With this commit, we now check if we
don't have buffers available, so we can flush everything and
restart reception properly even if we did drop a few in the
operation
2021-07-27 12:52:07 +02:00
MrKevinWeiss
cead7a5877 cpu/sam0/i2c: Handle read with I2C_NOSTOP flag
When using the I2C_NOSTOP flag the bus should remain in control.
The current check assumes it must go to idle when reading.
This adds a condition checks if the nostop flag is active
and expects the bus status to be the owner of the bus.
2021-07-01 14:50:54 +02:00
Benjamin Valentin
5f002ced1f Revert "cpu/sam0_common: UART: implement inverted RX & TX"
This reverts commit 585dc15f99.

I did misunderstand this feature: This only inverts the data
bits (instead of `c` uart will transmit `~c`), not the whole
line level.

This is not very useful on it's own, so revert it.
2021-05-21 12:47:03 +02:00
Dylan Laduranty
efbd867484
Merge pull request #16421 from benpicco/cpu/sam0_common-rtc_reorder
cpu/sam0_common: only include RTC/RTT symbols if module is used
2021-05-03 22:07:09 +02:00
Benjamin Valentin
d47a880915 cpu: add periph_rtt_overflow feature
The RTT overflow callback is not available on all RTT implementations.
This means it is either a no-op or `rtt_set_overflow_cb()` is a no-op
or it will overwrite the alarm set with `rtt_set_alarm()`.

This adds a feature to indicate that proper overflow reporting is available.
2021-04-30 11:58:00 +02:00
Benjamin Valentin
69b16dc8a2 cpu/sam0_common: only include RTC/RTT symbols if module is used
This allows to use the sam0 RTT together with the rtt_rtc module.
The idea is to use RTT as a monotonic counter, but still keep track
of the time with the virtual RTC module.
2021-04-30 10:39:51 +02:00
Benjamin Valentin
3f0459288c cpu/sam0_common: ethernet: fix RX detection
Detect RX of frame also when other bits of RSR are set.

fixes #16298
2021-04-23 17:46:36 +02:00
benpicco
bd6114ae9d
Merge pull request #16187 from benpicco/cpu/sam0_common/get_tamper
cpu/sam0_common: add rtc_get_tamper_event()
2021-04-13 14:11:46 +02:00
Benjamin Valentin
13fbb7c1a0 cpu/sam0_common: add rtc_tamper_pin_mask() 2021-04-13 10:45:16 +02:00
Benjamin Valentin
9d482c4448 cpu/sam0_common: RTC: only write TAMPCTRL when tamper is enabled
If we configure TAMPCTRL early, GPIO events will set bits in the
TAMPCTRL register.
That means that after a wake-up, we can't tell if the bit was set
because it was the wake-up source or if it was already set by a
run-time GPIO event.
2021-04-13 10:45:16 +02:00
Benjamin Valentin
73dbda99ac cpu/sam0_common: add rtc_get_tamper()
Add a function to query which tamper event woke the CPU from hibernation.
2021-04-13 10:45:16 +02:00
dylad
99764b82ab cpu/sam0: correct periph_cpu_common.h documentation 2021-03-31 22:17:01 +02:00
Marian Buschsieweke
ab89234040
drivers/periph/rtt: add periph_rtt_set_counter feature
Some periph_rtt implementations do not provide `rtt_set_counter()`. This
adds `periph_rtt_set_counter` as feature to allow testing for its
availability. The feature is provided at CPU level if periph_rtt is
provided by the board for all CPUs implementing `rtt_set_counter()`.
2021-03-08 14:16:46 +01:00
Marian Buschsieweke
b9cb75fedf
drivers/periph/rtt: add periph_rtt_set_counter feature
Some periph_rtt implementations do not provide `rtt_set_counter()`. This
adds `periph_rtt_set_counter` as feature to allow testing for its
availability. The feature is provided at CPU level if periph_rtt is
provided by the board for all CPUs implementing `rtt_set_counter()`.
2021-03-04 18:05:06 +01:00
Dylan Laduranty
cf40e0bfed
Merge pull request #16069 from benpicco/cpu/sam0_common/periph/spi-revert
Revert "cpu/sam0_common: SPI: only mux MISO on spi_acquire()"
2021-02-25 19:15:09 +01:00
Benjamin Valentin
a17686b551 Revert "cpu/sam0_common: SPI: only mux MISO on spi_acquire()"
This reverts commit 31bf0c5257.
2021-02-22 19:46:10 +01:00
Benjamin Valentin
56654478d4 sam0/adc: work around ADC errata on SAM D5x/E5x
The ADC SYNCBUSY.SWTRIG gets stuck to '1' after wake-up from Standby Sleep mode.
Ignore the ADC `SYNCBUSY.SWTRIG` status bit, this functionality is not used by
the driver anyway.
2021-02-22 12:39:32 +01:00
Francisco
3b2a55a923
Merge pull request #15865 from benpicco/pm_layered-default
cpu: make pm_layered a DEFAULT_MODULE
2021-02-03 08:17:29 +01:00
Dylan Laduranty
1d0dbb4626
Merge pull request #15846 from benpicco/cpu/sam0_common-spi_fixes
cpu/sam0_common: SPI: MOSI only operation & fix for adafruit-itsybitsy-m4
2021-01-28 09:26:28 +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
31bf0c5257 cpu/sam0_common: SPI: only mux MISO on spi_acquire() 2021-01-26 21:42:06 +01:00
benpicco
98726ded6d
Merge pull request #14662 from benpicco/cpu/samd20
cpu/samd21: add support for SAMD20 & SAM D20 Xplained Pro board
2021-01-26 19:14:36 +01:00
Benjamin Valentin
00a467e86d cpu/sam0_common: SPI: allow to only configure MOSI/CLK
Some slave devices (e.g. LED strips) don't have a back-channel and
will only need MOSI and CLK.
2021-01-24 17:51:44 +01:00
Benjamin Valentin
f11fc64af6 cpu/sam0_common: PWM: fix build on samd20
There is no SYNCBUSY register, so the dummy fallback does not work.
This code path is not used anyway, so just ifdef it out.
2021-01-21 20:29:15 +01:00
Daniel Lockau
ef7cbdb312 cpu/sam0_common/periph/flashpage: fix unaligned writes 2021-01-20 09:55:47 +01:00
Benjamin Valentin
3a7aa5d09a cpu/sam0_common: RTC: add timeout to spurious tamper event
Errate 2.17.4 says:

> Upon enabling the RTC tamper detection feature, a false tamper
> detection *can* be reported by the RTC.

It turns out that this spurious event is not always generated.
If RTC alarm is used and the CPU was previously woken from hibernate
by RTC, it *can* happen that the false tamper event is *not* generated.

In this case, we will block indefinitely on the mutex.

To solve this, add a timeout to the event.
Also poll the event instead of using a mutex, as we have already set
`PM->SLEEPCFG.bit.SLEEPMODE` at this point.
2021-01-12 17:36:40 +01:00
Benjamin Valentin
5b11da01c1 cpu/sam0_common: UART: add support for SAMD20 2021-01-12 15:48:39 +01:00
Benjamin Valentin
93d27bb9a0 cpu/sam0_common: I2C: add support for SAMD20 2021-01-12 15:48:39 +01:00
Benjamin Valentin
31b8dad147 cpu/samd21: add support for SAMD20 2021-01-12 15:48:39 +01:00
Benjamin Valentin
7b65398ae1 cpu/sam0_common: add samd20 vendor files
Files from Atmel.SAMD20_DFP.1.3.165.atpack
2021-01-12 15:48:39 +01:00
Benjamin Valentin
8004aa4d34 cpu/sam0_common: not every CPU has DMA 2021-01-12 15:48:37 +01:00
ba85c2d9ca
cpu/sam0_common: fix ENABLE_DEBUG definition 2021-01-08 14:37:33 +01:00
dylad
e98459f414 cpu/saml11: fix GPIO/IOBUS management 2020-12-15 17:00:54 +01:00
Dylan Laduranty
aec905d697
Merge pull request #15620 from benpicco/cpu/sam0_common/dac_startup
cpu/sam0_common: DAC: wait for DAC to be ready
2020-12-15 12:25:32 +01:00
dylad
a1f5b6182d cpu/sam0: add initial Ethernet support 2020-12-13 22:01:50 +01:00
Benjamin Valentin
c5c46ba35b cpu/sam0_common: DAC: wait for DAC to be ready
The DAC can have some start-up delay.
If we try to write to it before it's ready, it will get stuck.

This happens now that `tests/driver_dac_dds` immediately sets a DAC
value after init.

The samd2x class of MCUs doesn't have this bit, but a quick test on
samd10 shows that it might not be nececary there - the DAC does not
get stuck when writing to it immediately after init.
2020-12-13 02:11:36 +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
94c7f40b9c cpu/sam0_common: SPI: add support for SAMD20 2020-12-11 22:33:07 +01:00
Benjamin Valentin
fb2a6b7024 cpu/sam0_common: SPI: cleanup
Insert whitespace and factor out functions to make it easier to
add functionality.
2020-12-11 22:33:07 +01:00
Benjamin Valentin
531fca952b cpu/sam0_common: add samd10 vendor files
Files from Atmel.SAMD10_DFP.1.1.77.atpack
2020-12-11 18:25:36 +01:00
Benjamin Valentin
2845554b4e cpu/sam0_common: flashpage: rename to sam0_flashpage_aux_write()
`flashpage_write_raw()` got renamed to `flashpage_write()`.
Now `sam0_flashpage_aux_write_raw()` is the only remaining 'raw'
function, even though it behaves just like `flashpage_write()`.

So let's also rename that for consistency.
2020-11-17 00:34:31 +01:00
72d7a903a2
sam0: Adapt to flashpage/flashpage_pagewise API 2020-11-11 23:16:41 +01:00
Benjamin Valentin
4e8c461f46 cpu/sam0_common: flashpage: invalidate cache on _lock() 2020-11-10 14:21:47 +01:00
Benjamin Valentin
e6192a13bd cpu/sam0_common: flashpage: support unaligned writes
We can pad the unaligned bytes with 0xFF to make up a whole word that
can be written.
2020-11-10 12:18:47 +01:00
Benjamin Valentin
20f093ede6 cpu/sam0_common: flashpage: introduce functions to write to user page 2020-11-10 12:18:47 +01:00
Leandro Lanzieri
7185edb070
cpu/sam0_common/periph: add periph_rtc_rtt module to Kconfig 2020-11-06 15:57:56 +01:00
Marian Buschsieweke
60802f864a
Merge pull request #15149 from benpicco/cpu/samd21-gclk7
cpu/samd21: improve GCLK7 magic
2020-11-03 18:14:09 +01:00
Marian Buschsieweke
d046772e7f
Merge pull request #15348 from maribu/periph_timer_type
drivers/periph_timer: Use uint32_t over unsigned long for frequency
2020-10-30 23:22:51 +01:00
Marian Buschsieweke
125c892c03
drivers/periph/timer: Use uint32_t for frequency
For all currently supported platforms `unsigned long` is 32 bit in width. But
better use `uint32_t` to be safe.
2020-10-30 22:02:12 +01:00
Benjamin Valentin
8e4af4d778 cpu/sam0_common: remove unused linker script
`samd21j18a_arduino_bootloader.ld` is not referenced anywhere else
in the codebase and it's job is performed by the generic `ROM_OFFSET`
variable.
2020-10-28 23:17:48 +01:00
Bas Stottelaar
22243aec7a cpu/*: realign ENABLE_DEBUG 2020-10-23 00:46:26 +02:00
Bas Stottelaar
fb61443bbd cpu/*: remove unused assert.h include 2020-10-22 11:13:09 +02:00
Bas Stottelaar
ab6188cea3 cpu/*: add missing include of assert.h 2020-10-22 11:13:08 +02:00
Cenk Gündoğan
f05ac07f19
Merge pull request #15217 from leandrolanzieri/pr/kconfig/allow_merge_configs
makefiles/kconfig: always allow to use KCONFIG_ADD_CONFIG
2020-10-13 15:11:09 +02:00
Leandro Lanzieri
4d7ea1b50a
makefiles/kconfig: always allow to use KCONFIG_ADD_CONFIG 2020-10-13 09:53:00 +02:00
Leandro Lanzieri
fe6d66d92a
kconfig: add ERROR symbol for conflicting modules 2020-10-09 18:04:17 +02:00
Benjamin Valentin
35d6736d9d cpu/sam0_common: PWM: use named GCLK for disabling peripheral 2020-10-02 23:17:53 +02:00
35f357a9ad
cpu/sam0_common: fix typos
- 'acces' -> 'access'
- 'withing' -> 'within'
2020-10-02 07:58:35 +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
0499d016ad cpu/sam0_common: implement RTC tamper detection 2020-09-17 18:45:50 +02:00
benpicco
5715f5776b
Merge pull request #14804 from bergzand/pr/sam0/gpio_iobus
sam0_common: Use Single-cycle I/O Port for GPIO when available
2020-09-10 23:45:43 +02:00
Dylan Laduranty
4db8a1f602
Merge pull request #14478 from benpicco/cpu/sam0/tc_pwm
cpu/sam0_common: add support to run PWM off TC timers
2020-09-10 23:04:58 +02:00
ddb22a3c56
sam0_common: Use Single-cycle I/O Port for GPIO when available
The Cortex-m0 based ATSAM devices can use the Single-cycle I/O Port for
GPIO. This commit modifies the gpio_t type to use this port when
available. It is mapped back to the peripheral memory space for
configuration access.  When it is not available, the _port_iobus() and
_port() functions behave identical, which is the case for the samd51.
2020-09-10 22:13:24 +02:00
Benjamin Valentin
0437461812 cpu/sam0_common: PWM: add support to run PWM off TC timers 2020-09-10 21:47:03 +02:00
Leandro Lanzieri
2e79e00ca7
treewide: change Kconfig prefix for module symbols
This changes the prefix used for the symbols that reprensent modules
(not the ones generated from USEMODULE).

MOD_ => MODULE_
2020-08-31 09:57:28 +02:00
Leandro Lanzieri
d25fc243c4
treewide: change prefix for generated Kconfig symbols.
This changes the prefixes of the symbols generated from USEMODULE and
USEPKG variables. The changes are as follow:

   KCONFIG_MODULE_ => KCONFIG_USEMODULE_
   KCONFIG_PKG_ => KCONFIG_USEPKG_
   MODULE_ => USEMODULE_
   PKG_ => USEPKG_
2020-08-31 09:37:09 +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
52a95642d5 sam0/adc: make driver MCU family agnostic
Replace checks for `CPU_SAMD21` with checks for actual defines.
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
cc7f897cbc cpu/saml1x: define CPU_COMMON_SAML1X symbol and use it 2020-08-24 16:13:18 +02:00
Benjamin Valentin
5d96151775 cpu/saml21: define CPU_COMMON_SAML21 symbol and use it 2020-08-24 16:13:18 +02:00
Benjamin Valentin
e32b0783c4 cpu/samd21: define CPU_COMMON_SAMD21 symbol and use it 2020-08-24 16:13:18 +02:00
Benjamin Valentin
582da9b233 cpu/sam0_common: add script to generate Kconfig files for all parts
e.g. Usage:

	./sam0_common/dist/kconfig_gen.sh samd51
2020-08-24 16:13:18 +02:00
János Brodbeck
083b3c167f
sam0/adc: add support for samd5x/same5x
Add samd5x/same5x support  through introducing ADC_DEV as alias for ADC0/ADC1/ADC. ADC (respectively ADC0) is the default if no device is set.
2020-08-19 18:00:29 +02:00
Leandro Lanzieri
7dc6639f59
cpu/cortexm_common: add default Kconfig configuration 2020-08-12 12:22:43 +02:00
Leandro Lanzieri
f4e651e26d
cpu/sam0_common: Add default Kconfig configuration
The configuration file is included by samd21 so it is merged when using
Kconfig.
2020-08-12 12:22:42 +02:00
Leandro Lanzieri
0ddd2886b7
cpu/sam0_common: add sam0_common_periph module to Kconfig 2020-08-12 12:22:39 +02:00
benpicco
419ee52ddc
Merge pull request #14711 from benpicco/cpu/sam0_common/gpio-intermediate_irq
cpu/sam0_common: GPIO: ignore stale interrupts
2020-08-11 16:32:57 +02:00
benpicco
3ef906c841
Merge pull request #14563 from benpicco/cpu/sam0_common-bitarithm_test_and_clear
cpu/sam0_common: GPIO: use bitarithm_test_and_clear()
2020-08-11 14:05:06 +02:00
Francisco
16f47fc893
Merge pull request #14502 from benpicco/cpu/sam0_common/flashpage_cleanup
cpu/sam0_common: flashpage: clean up implementation
2020-08-10 08:21:49 +02:00
Benjamin Valentin
d02aa4a6b5 cpu/sam0_common: RTC: use RIOT_EPOCH 2020-08-07 13:24:10 +02:00
Benjamin Valentin
39d71ac671 cpu/sam0_common: GPIO: ignore interrupts when interrupts are disabled
If we disable an external interrupt, GPIO events that would generate an interrupt will still set the interrupt flag.
That means once we enable the interrupt again, a stale interrupt will be triggered.

This is surprising and probably not what the user wants, unfortunately the API documentation is not very clear about what to expect.
There is however no way to drop those intermediate interrupts with the current API.

Ignoring the events that occurred while the GPIO interrupt were disabled is probably the right (and expected) thing to.
2020-08-05 16:57:05 +02:00
Leandro Lanzieri
d7dbbb71ac
Merge pull request #14226 from benpicco/cpu/sam0_common/i2c_arbitrary_freqs
cpu/sam0_common: i2c: fix BAUD handling & cleanup
2020-08-04 14:49:10 +02:00
Benjamin Valentin
1472d2095c cpu/sam0_common: i2c: document frequency constraints 2020-08-04 12:13:28 +02:00
Benjamin Valentin
e560042488 cpu/sam0_common: flashpage: split RWWEE and normal functions
Move common code into helper functions and extract the commands
that differ between normal and RWWEE page reading / writing.
This cuts down on `#ifdef` use.
2020-08-04 12:00:49 +02:00
Benjamin Valentin
83a56ae666 cpu/sam0_common: merge RTC & RTT implementation
The RTC and RTT share the same peripheral, so they can also
share the same code.

This is needed to integrate the Tamper Detection into common
RTC/RTT code.
2020-07-31 22:00:09 +02:00
Benjamin Valentin
cc2a3c9fd3 cpu/sam0_common: GPIO: use bitarithm_test_and_clear() 2020-07-28 12:43:39 +02:00
Benjamin Valentin
003c25b2e8 cpu/sam0_common: uart: document frequency constraints 2020-07-28 11:22:22 +02:00
Benjamin Valentin
e1f84de6c5 cpu/sam0_common: UART: simplify init sequence
We don't need to read-modify-write the CTRLA register to disable
the UART.
The entire CTRLA register is re-written just a few lines below, so
we can just set it to 0 to disable the UART.

There is also no need to reset the UART since we re-write all config
registers in init.
2020-07-28 11:22:22 +02:00
Benjamin Valentin
28c1c502bc cpu/sam0_common: UART: implement arithmetic BAUD mode
SAMD20 does not implement a Fractional Baud mode, so we have to
implement Asynchronous Arithmetic mode.
2020-07-28 11:22:22 +02:00
Benjamin Valentin
e6f33fc436 cpu/sam0_common: uart: implement the periph_uart_reconfigure feature 2020-07-28 10:10:15 +02:00
Benjamin Valentin
62dbb21f19 cpu/sam0_common: UART move pin configuration to function
Makes the init code easier to read.
2020-07-28 10:10:15 +02:00
Benjamin Valentin
4df36cbfda cpu/sam0_common: i2c: improve readability of baud rate calculation
Use variables to represent fSCL an fGCLK to make the baud rate calculation
more readable.
2020-07-25 15:14:55 +02:00
Benjamin Valentin
2fb0d9061f cpu/sam0_common: i2c: fix High Speed 2020-07-25 15:14:55 +02:00
Benjamin Valentin
7269dc4e3a cpu/sam0_common: i2c: allow arbitrary I2C frequencies
The Atmel I2C peripheral supports arbitrary I2C frequencies.
Since the `i2c_speed_t` enum just encodes the raw frequency values,
we can just use them in the peripheral definition.

We just have to remove the switch-case block that will generate an error
for values outside of `i2c_speed_t`.
2020-07-25 15:14:55 +02:00
Benjamin Valentin
c5f6a5c6f5 cpu/sam0_common: PWM: prepare for TC timers as PWM source 2020-07-19 01:38:15 +02:00
Benjamin Valentin
a96e5666b4 cpu/sam0_common: PWM: fix doxygen group 2020-07-19 01:38:15 +02:00
Benjamin Valentin
48340f971f cpu/sam0_common: flashpage: clean up helper function 2020-07-14 20:50:50 +02:00
benpicco
30ebabb84e
Merge pull request #14007 from benpicco/cpu/sam0_common-pwm
cpu/sam0_common: move PWM to common code, add support for saml21, samd5x
2020-07-09 10:01:08 +02:00
Benjamin Valentin
bce7d25f10 cpu/sam0_common: add PWM support for saml2x, samd5x 2020-07-08 21:51:12 +02:00
Francisco
325b7a8d8e
Merge pull request #13631 from benpicco/cpu/sam0_common/spi-deinit
drivers/periph/spi: add periph_spi_reconfigure feature & implementation for sam0
2020-06-30 15:34:53 +02:00
Francisco
48bdd7018a
Merge pull request #14302 from fjmolinas/pr_sam0_rtt_opt
cpu/sam0_common/rt%: use READREQUEST when accessing CLOCK/COUNT regs
2020-06-24 08:42:03 +02:00
Bas Stottelaar
6774f7e412
Merge pull request #14337 from benpicco/TIMER_CHANNEL_NUMOF
use TIMER_CHANNEL_NUMOF instead of TIMER_CHANNELS
2020-06-24 01:19:17 +02:00
Benjamin Valentin
c8ff026640 cpu/sam0_common: use TIMER_CHANNEL_NUMOF 2020-06-24 00:45:35 +02:00
Francisco
a73b61e30b
Merge pull request #14320 from benpicco/cpu/sam0_common-gpio_gclk
cpu/sam0_common: GPIO always default to MAIN clock for EXTI, make configurable
2020-06-23 22:48:45 +02:00
Benjamin Valentin
3e91914831 cpu/sam0_common: spi: implement the periph_spi_reconfigure feature 2020-06-21 21:19:17 +02:00
Francisco Molina
bdda25c534
cpu/sam0_common/rt%: issue READREQUEST to access CLOCK/COUNT regs
read-synchronized register will stall immediatly when read, instead
issue READREQUEST and wait for sync to be unset.
2020-06-19 14:10:31 +02:00
Benjamin Valentin
c0203ad35c cpu/sam0_common: GPIO default to MAIN clock for EXTI, make configurable
Currently only samd21 used the 32 kHz clock for EXTI which makes it miss fast events.
All newer members of the family use the MAIN clock.

While touching this, also make the clock source configurable to this can be overwritten,
e.g. in the board config if desired.
2020-06-19 13:27:48 +02:00
Francisco
a970163812
Merge pull request #14312 from benpicco/cpu/sam0_common/periph/uart-rxonly
cpu/sam0_common: UART: allow RX only configuration
2020-06-19 11:44:10 +02:00
benpicco
c3314e1a0c
Merge pull request #14303 from fjmolinas/pr_sam0_unified_rtt
cpu/sam0: unified rtt configuration
2020-06-19 11:30:06 +02:00
Francisco Molina
ff24aa61f3
cpu/sam0_common/periph/rtt: uncrustify 2020-06-19 09:16:24 +02:00
Francisco Molina
15bbd95b6a
cpu/sam0_common/rtt: add configurable RTT_FREQUENCY 2020-06-19 09:16:24 +02:00
Benjamin Valentin
5c3ae77df9 cpu/sam0_common: UART: allow RX only configuration 2020-06-19 00:33:50 +02:00
Dylan Laduranty
6bf0a41399
Merge pull request #13600 from benpicco/sam0-gpio
cpu/sam0_common: GPIO IRQ optimizations
2020-06-17 21:23:19 +02:00
07c78efc83
Merge pull request #14285 from fjmolinas/pr_uart_nb_race
sam0/stm32: fix possible uart_nonblocking deadlock
2020-06-17 12:14:25 +02:00
Francisco Molina
80d682becd
cpu/sam0: avoid deadlock on nonblocking write
If a write to a full tsrb is attempted with disabled interrupts
or in a interrupt then a deadlock will occure. To avoid this make
space in the ringbuffer by synchronously writing to uart.
2020-06-17 10:01:21 +02:00
Francisco Molina
0b8adb2d27
cpu/sam0-stm32/uart: rename tx buf size to UART_TXBUF_SIZE 2020-06-17 10:01:20 +02:00
Benjamin Valentin
585dc15f99 cpu/sam0_common: UART: implement inverted RX & TX
The UART TX and TX lines on SAMD5x and SAML1x can be inverted.
However, the flags don't do exactly what one would expect.

See errata 2.18.5: SERCOM-UART: TXINV and RXINV Bits Reference:

> The TXINV and RXINV bits in the CTRLA register have inverted functionality.
>
> Workaround:
> In software interpret the TXINV bit as a functionality of RXINV, and conversely,
> interpret the RXINV bit as a functionality of TXINV.
2020-06-16 22:55:37 +02:00
benpicco
1992f57765
Merge pull request #14261 from bergzand/pr/sam0_common/spi_dma
sam0_common: Make SPI peripheral DMA compatible
2020-06-14 18:25:37 +02:00
60f4502e6c
cpu/sam0_common: Make SPI peripheral DMA compatible 2020-06-14 14:56:20 +02:00
22c8788b58
sam0_common/dma: Rename len to num 2020-06-14 11:51:36 +02:00
02b2b58358
sam0_common: Add additional documentation on DMA usage 2020-06-14 11:48:43 +02:00
7a8566c391
sam0_common/dma: Mark src parameter as const 2020-06-13 21:02:04 +02:00
benpicco
74299a2b03
Merge pull request #14260 from bergzand/pr/sam0_common/dma_periph
sam0_common: Add DMA peripheral driver
2020-06-12 21:18:31 +02:00
73c8911e62
cpu/samd5x: Add DMA peripheral to init 2020-06-12 20:04:05 +02:00
6be1b27bbb
sam0_common: Add DMA peripheral driver 2020-06-12 20:04:05 +02:00
Benjamin Valentin
54b57bd97f cpu/sam0_common: drop prescaler from timer config
since c05984b341 the prescaler in the timer
config struct is no longer used.

Let's remove it.
2020-06-11 19:29:43 +02:00
Benjamin Valentin
824f7aa82b cpu/sam0_common: move PWM to common code 2020-06-07 16:50:17 +02:00
Leandro Lanzieri
67a43e0ada
drivers/wdt/kconfig: Rename HAS_WDT_WARNING_PERIOD
The symbol now is HAS_PERIPH_WDT_WARNING_PERIOD.
2020-06-02 17:43:19 +02:00
Leandro Lanzieri
079a7ee1e5
cpu/sam0_common: Add family specific Kconfig symbols 2020-06-02 17:42:10 +02:00
Leandro Lanzieri
48759eccdc
drivers/wdt: Add feature to indicate a configurable warning period
This adds the feature `periph_wdt_warning_period` that indicates that a
platform WDT driver implementation supports a configurable
CONFIG_WDT_WARNING_PERIOD.
2020-06-02 12:54:25 +02:00
Leandro Lanzieri
12470f0ed2
cpu/sam0_common: Move periph_timer_periodic feature to Makefile.features 2020-05-29 11:13:59 +02:00
Benjamin Valentin
8486e8c6d1 cpu/sam0_common: implement timer_set_periodic() 2020-05-28 17:37:42 +02:00
Benjamin Valentin
ec7ae668e2 cpu/sam0_common: define TIMER_CHANNELS 2020-05-28 13:24:06 +02:00
Juergen Fitschen
df90176b1f cpu/sam0_common/spi: move clk pin muxing into spi_acquire / spi_release
When the SPI peripheral is disabled, the output lines will become HIGH-Z.
If the clk pin is not pulled HIGH or LOW, connected SPI slaves will start drawing current expectedly.
2020-05-23 13:54:39 +02:00
Benjamin Valentin
5481d8c73a cpu/sam0_common: clean up formatting
Make the code nicer to read.
2020-05-06 14:11:47 +02:00
Benjamin Valentin
e93c9a82f1 cpu/sam0_common: RTC INTFLAG are clear on write
Writing a 1 bit clears the interrupt flag, writing with |= is thus
uneccecary (and actually an error as this would clear *all* flags).

This cleanup was already done for rtt.c, but rtc.c missed out.
2020-05-06 14:05:12 +02:00
Francisco
cea0d1c532
Merge pull request #13421 from benpicco/cpu/sam0_common/i2c-deinit
drivers/periph/i2c: add periph_i2c_reconfigure feature & implementation for sam0
2020-05-05 19:09:47 +02:00
Benjamin Valentin
8c502322f4 cpu/sam0_common: i2c: implement the periph_i2c_reconfigure feature
This adds sam0 implementations for

 - i2c_init_pins()
 - i2c_deinit_pins()
 - i2c_pin_sda()
 - i2c_pin_scl()
2020-05-05 16:12:19 +02:00
benpicco
fbae0a1117
Merge pull request #13901 from benpicco/cpu/sam0_common/timer_flex_freq
cpu/sam0_common: timer: don't ignore frequency in timer_init()
2020-05-04 02:56:01 +02:00
Dylan Laduranty
76870721fe
Merge pull request #13965 from benpicco/cpu/sam0_common/periph/dac
cpu/sam0_common: implement periph/dac
2020-05-02 20:34:40 +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
c05984b341 cpu/sam0_common: timer: don't ignore frequency in timer_init()
Now that we can query the GCLK frequency at run-time, there is no need
to implicitely hard-code the timer frequency in the config struct anymore.
2020-05-01 16:44:06 +02:00
fe299138aa
sam0_common: clarify memcpy in cpuid_get 2020-04-28 14:56:19 +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
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
Leandro Lanzieri
64552a3b9a
cpu/cortexm_common: Move common modules to Makefile.dep
This moves the following modules to a architecture-specific Makefile.dep
file:
- cortexm_common
- cortexm_common_periph
- newlib
- newlib_nano
- periph
2020-04-01 09:46:21 +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
9b90fd478a cpu/sam0_common: provide function to switch voltage regulator
Add a fucntion to switch between LDO and Buck concerter to provide the
internal CPU voltage.
The Buck Converter is not compatible with internal fast oscillators (DFLL, DPLL)
and requires an inductivity to be present on the board.
2020-03-31 17:18:20 +02:00
Francisco
1a8b35f54b
Merge pull request #13377 from leandrolanzieri/pr/kconfig_migrate/drivers/periph_wdt
drivers/periph/wdt: Expose configurations to Kconfig
2020-03-31 16:36:36 +02:00
Dylan Laduranty
783ffdc28a
Merge pull request #13607 from benpicco/cpu/sam0_common/generic_RAM_ROM
cpu/sam0_common: derive ROM_LEN & RAM_LEN from part number
2020-03-31 15:55:04 +02:00
Leandro Lanzieri
cf53a86308
cpu/sam0_common: Add CPU-specific WDT peripheral configuration 2020-03-31 13:39:39 +02:00
Leandro Lanzieri
00b71a2708
drivers/wdt: Move WDT_WARNING_PERIOD to 'CONFIG_' namespace 2020-03-31 13:39:37 +02:00
Benjamin Valentin
77961106f9 cpu/sam0_common: derive ROM_LEN, RAM_LEN from part number & vendor file
The ROM size is encoded in the part number of the Atmel SAM chips.
RAM size is not encoded directly, so get it by parsing the chip's vendor file.

The file remains in the page cache for the compiler to use, so the overhead
should be minimal:

on master:

  Benchmark #1: make BOARD=samr21-xpro -j
    Time (mean ± σ):     527.9 ms ±   4.9 ms    [User: 503.1 ms, System: 69.6 ms]
    Range (min … max):   519.7 ms … 537.2 ms    10 runs

with this patch:

  Benchmark #1: make BOARD=samr21-xpro -j
    Time (mean ± σ):     535.6 ms ±   4.0 ms    [User: 507.6 ms, System: 75.1 ms]
    Range (min … max):   530.6 ms … 542.0 ms    10 runs
2020-03-25 15:07:50 +01:00
79431878ac
Merge pull request #13051 from dylad/pr/uart_hw_fc
cpu/uart: create common uart hw fc module
2020-03-10 16:41:36 +01:00
Dylan Laduranty
7a095a80d7 cpu/sam0: use generic hw fc module 2020-03-10 14:22:34 +01:00
benpicco
741b9d3b2d
Merge pull request #13603 from ML-PA-Consulting-GmbH/samd21j17d_add
cpu/sam0_common: add samd21j17d
2020-03-10 12:00:25 +01:00
Benjamin Valentin
eb3f515f55 cpu/sam0_common: gpio: Make use of dedicated GPIO interrupts
saml1x and samd5x have dedicated interrupts per GPIO line.
Use those instead of iterating over the GPIO status bits
to serve IRQs even faster.
2020-03-10 10:33:31 +01:00
Alexandre Moguilevski
648a5b9c58 cpu/sam0_common: add samd21j17d 2020-03-10 10:26:45 +01:00
Benjamin Valentin
5c4c45fd3f cpu/sam0_common: gpio: add gpio_disable_mux() function
Inverse to gpio_init_mux()
2020-03-09 19:23:33 +01:00
Benjamin Valentin
6540609c35 cpu/sam0_common: gpio: save a few cycles in isr_eic()
Don't iterate over all bits in the GPIO status register, instead
just loop as many times as there are set bits.
2020-03-09 18:34:06 +01:00
Juergen Fitschen
0032d35fe8 cpu/sam0_common: mitigate rounding errors of baud rate calculation
Instead of always rounding up, the driver now rounds to the nearest integer. This reduces the absolut rounding error when setting SPI baud rates.
2020-03-03 12:32:42 +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
Benjamin Valentin
a0ac2384ac cpu/sam0_common: samr30: add integer literal macros
All the more recent vendor files have them, so include them for samr30 too.
It is expected for this to become obsolete with the next vendor file update.
2020-02-25 21:52:24 +01:00
Gunar Schorcht
f688f84a15
Merge pull request #12928 from benpicco/newlib-multiheap
sys/newlib: enable multiple heaps in _sbrk_r()
2020-02-25 19:16:42 +01:00
Benjamin Valentin
442ddc1346 cpu/samd21: Switch EIC clock to slow speed on STANDBY mode 2020-02-24 12:02:27 +01:00
Juergen Fitschen
43ff72ad56 cpu/sam0*: Switch EIC clock to slow speed on STANDBY mode 2020-02-24 12:02:25 +01:00
Juergen Fitschen
1265efc785 cpu/sam0*: Wrap cortexm_sleep call 2020-02-24 11:48:13 +01:00
Benjamin Valentin
b77afadb49 cpu/sam0_common/gpio: use explicit GCLK names
For consistency, use named GCLKs.

 - `SAM0_GCLK_32KHZ` will always be 2 for samd21
 - `SAM0_GCLK_MAIN` will always be 0

So no change in functionality, just makes the code easier to understand.
2020-02-21 14:25:43 +01:00
Benjamin Valentin
cfd0ef415e cpu/sam0_common: hook up low power RAM as extra heap
This enables unused low-lower RAM on saml21/samd5x to be used for
heap memory.
2020-02-20 17:11:25 +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
93d536f761 cpu/sam0_common: samr30 add PIN_(.*)_EIC_EXTINT_NUM to vendor header
samr30 is the only MCU of this family where the vendor files do not
define the PIN_($pin)_EIC_EXTINT_NUM macro yet.

This macro is needed to create a generic EXTI configuration for all
sam0 MCUs.

The defines were generated with

    sed -Ei '/define PIN_(.*)_EIC_EXTINT([0-9]*)/
            {h; x;
             s/define PIN_(.*)A_EIC_EXTINT([0-9]*)(.*)/
               define PIN_\1A_EIC_EXTINT_NUM       _L_\(\2\)
               \/**< \brief EIC signal: PIN_\1 External Interrupt Line *\/
              /g; G}' samr30g18a.h samr30e18a.h
2020-02-18 18:28:10 +01:00
Dylan Laduranty
cc17d3c2ba
Merge pull request #13350 from benpicco/saml21-asf
cpu/sam0_common: update saml21 vendor files to version 1.2.125
2020-02-12 14:27:39 +01:00
Benjamin Valentin
1333a5698c cpu/sam0_common: update saml21 vendor files to version 1.2.125
This release adds EXTINT defines compatible with later versions of
the sam0 series of MCUs.
2020-02-12 11:46:36 +01:00
Benjamin Valentin
e03780c8ca cpu/sam0_common: update samd21 vendor files to version 1.3.395
This release adds EXTINT defines compatible with later versions of
the sam0 series of MCUs.
2020-02-08 03:28:14 +01:00
Dylan Laduranty
b5bb846d3a
Merge pull request #13312 from benpicco/cpu/sam0-vendor_cleanup
cpu/sam0_common: use vendor provided MCU header dispatch
2020-02-07 20:33:45 +01:00
Benjamin Valentin
b0078b1a98 cpu/sam0_common: update samr21 vendor files to version 1.1.72
This release adds EXTINT defines compatible with later versions of
the sam0 series of MCUs.
2020-02-07 12:14:45 +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
fd793b8917 cpu/samd51: add common header file from ASF
Somehow I forgot to commit this.
2020-02-06 19:49:50 +01:00
benpicco
9b33e1ca92
Merge pull request #13271 from kfessel/patch-shed
core/sched: sched.h: remove not needed bitarithm include to avoid conflict
2020-02-05 14:44:08 +01:00
Karl Fessel
4445faaa3a core/shed: remove not needed bitarithm include add missing
bitarithm.h is not needed for the interface of shed but may cause conflicts
due to different definitions of SETBIT and CLRBIT

common implementations are: (value, offset) xor (value, mask) bitarithm
implements the later

frac.c and nrf52/usbdev.c use bitarithm.h but where missing the include

sam0/rtt.c defined a bit using mask from bitarithm,
changed that to the soulution used in sam0/rtc.c
2020-02-05 12:45:29 +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