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

95 Commits

Author SHA1 Message Date
Kees Bakker
43670aee7b
Merge pull request #12615 from benpicco/samd21-1kHz_gclk
cpu/samd21: use dedicated 1kHz GCLK4 for RTC and WDT
2019-11-13 20:25:55 +01:00
Dylan Laduranty
0e736b8879
Merge pull request #12675 from benpicco/sam0-rtt-fix
cpu/sam0_common: rtt: enable COUNTSYNC in CTRLA
2019-11-13 10:12:07 +01:00
Benjamin Valentin
d21dc25cfe sam0/spi: Don't re-configure SPI device when not needed
Currently, spi_acquire() will always re-configure the SPI bus.
If the configuration did not change, this is entirely uneccecary
and makes SPI operations take longer than needed.

Instead, compare the current configuration with the new configuration
and skip the initialisation if it didn't change since the last call.
2019-11-12 11:31:41 +01:00
Benjamin Valentin
db2fa33660 sam0_common: rtc: use GCLK4 on SAMD21
The RTC expects to be clocked from a 1kHz source.
Previously it would re-configure GCLK2 from 32kHz to 1kHz when used.

Since GCLK2 is also used by EIC, this would break external interrupts
in strange and unexpected ways.

Dedicate a 1kHz clock to it to avoid the damage.
2019-11-12 11:30:02 +01:00
Benjamin Valentin
5fa234e435 sam0_common: wdt: use GCLK4 on SAMD21
GCLK4 will always run at 1kHz on SAMD21, so use it directly.
2019-11-12 11:29:25 +01:00
Benjamin Valentin
89b987494e cpu/sam0_common: rtt: enable COUNTSYNC in CTRLA
From the data sheet:

> The COUNT register requires synchronization when reading.
> Disabling the synchronization will prevent reading valid
> values from the COUNT register.

Without this bit enabled, rtt_get_counter() will always return 0.
2019-11-12 11:28:08 +01:00
acdb010669
sam0_common/usb: fix typo in comment 2019-10-23 10:35:47 +02:00
Kees Bakker
04c84ed158 cpu/sam0: refactor ADC_0 into plain ADC
This change is for all boards with a sam0 cpu. This cpu just has one ADC.
It is unnecessary to have defines with ADC_0_ prefix as if multiple ADCs
are possible.

Some defines were not used, such as ADC_0_EN, ADC_0_CHANNELS,
ADC_MAX_CHANNELS, ADC_0_CLK_SOURCE, ADC_0_CHANNELS

Change all ADC_0_ prefixes to ADC_
2019-10-03 20:45:44 +02:00
Gunar Schorcht
02d81b717e
Merge pull request #12063 from maribu/i2c_release
drivers/periph/i2c: Updated i2c_release() to return void
2019-10-01 19:50:38 +02:00
Benjamin Valentin
7e5aa7e775 cpu/sam0_common: uart: fix baud rate calculation
In fractional mode, 3 bits are used to store the fractional part.
Therefore we must multiply / divide by 8 instead of 10 in order to
get the correct values.
2019-09-27 10:49:43 +02:00
Benjamin Valentin
c9f8ff1cf1 sam0_common: add Watchdog implementation 2019-09-20 19:04:41 +02:00
benpicco
d5c272ed86
Merge pull request #12199 from smlng/fix_timer_returns
periph/timer: Fix return codes of timer API
2019-09-17 23:04:46 +02:00
Dylan Laduranty
88fe7afe2b
Merge pull request #12121 from benpicco/sam0-fix_exti
cpu/sam0_common/gpio: don't hard-code number of ports
2019-09-12 20:17:11 +02:00
Benjamin Valentin
b1724a7d1b periph/rtc: normalize struct tm before usage
A naive implementation may set a RTC alarm in 30s by calling

	struct tm now;
	rtc_get_time(&now);
	now.tm_sec += 30;
	rtc_set_alarm(&now, _cb, NULL);

This works for RTC implementations that use a RTT internally and call
mktime() to convert the struct tm to a unix timestamp, as mktime() will
normalize the struct in the process.

Call rtc_tm_normalize() when the RTC uses separate registers for time / date
components to ensure it is normalized.

This also modifies tests/periph_rtc to exercise this case.
2019-09-12 11:32:31 +02:00
Sebastian Meiling
49acf98841 cpu/sam0: adapt timer to return 0 on success
Adapt periph/timer implementation of sam0 based MCUs
to return 0 on success for all functions.
2019-09-11 13:52:28 +02:00
Juan Carrano
f7279c84bb cpu/sam0_common: rtt: correcly clear flags.
The INTFLAGS register is cleared by writing a 1 to the corresponding interrupt
flag bit. From the samr21's manual:

> Writing a zero to this bit has no effect.
> Writing a one to this bit clears the Compare 0 interrupt flag.

This is a common pattern in flag registers.

This RTT driver is using or-equal to clear the flags, which means it can
possibly clear other interrupts. There's a small chance that one event is
missed if it happens very close to another event.

Credits to @benpicco, @dylad for pointing out missing fixes.
2019-09-11 12:55:10 +02:00
Benjamin Valentin
ba8dfc8341 cpu/sam0_common/gpio: don't hard-code number of ports
_exti() always assumes only 2 ports, so it will always fail when using
e.g. port C or port D on same54.

Instead, determine the number of ports from the dimensions of the exti_config
array.
2019-08-29 15:27:42 +02:00
Marian Buschsieweke
dd56b3bb71
cpu/sam0_common: Updated i2c_release() 2019-08-22 12:03:08 +02:00
Benjamin Valentin
a9b0db3ba4 cpu/sam0_common: add hwrng driver 2019-08-03 14:50:58 +02:00
Kevin "Bear Puncher" Weiss
a290f2d66c
Merge pull request #11712 from bergzand/pr/sam0_common/uart_modecfg
sam0_common: add uart modecfg support
2019-06-21 13:08:07 +02:00
3241aff71c
sam0_common: add uart modecfg 2019-06-21 10:54:24 +02:00
Benjamin Valentin
7928c74e26 sam0_common: rtc/rtt: don't setup oscilators
leave that to cpu.c
2019-06-18 13:20:04 +02:00
Benjamin Valentin
f375b00ff3 cpu/samd5x: add support for samd5x/same5x MCUs
This adds supoprt for the Atmel SAMD51 & SAME54 SoC.
The SAME5x/SAMD5x is a line of Cortex-M4F MCUs that share peripherals
with the samd2x Cortex-M0+ and saml1x Cortex-M23 parts.
2019-06-06 16:47:11 +02:00
Benjamin Valentin
f36d54f239 sam0/timer: various fixes
This cleans up the sam0 timer driver:

 - remove the check for the unused freq parameter
 - the MCU provides dedicated SET/CLR registers to avoid
   read-modify-write, so don't do read-modify-write on them.
 - workaround a possible hardware bug on SAMD5x:
   loop until the CMD_READSYNC is really set
2019-06-06 15:38:55 +02:00
Benjamin Valentin
7415e0590e sam0_common: spi: use sercom_set_gen() instead of re-implementing it
Don't repeat yourself and introduce errors in doing so.
2019-05-25 19:13:53 +02:00
Benjamin Valentin
31f88a2d0e sam0_common: periph/spi: use sercom_clk_en/dis()
Use already existing functions to turn on / off SERCOM clocks instead
of replicating the functionality in the driver.
2019-05-25 19:09:32 +02:00
Benjamin Valentin
849dd4cdce sam0_common: make Timer implementation common across all sam0 MCUs
The currently supported SAM0 MCUs (samd21, saml21, saml1x) share the same
Timer peripheral, yet each of them carries it's own copy of the Timer
driver.

This introduces a new timer driver that is common for all sam0 MCUs and
uses structs for configuration instead of defines.
2019-05-21 11:47:59 +02:00
Benjamin Valentin
077056b949 sam0_common: make RTT implementation common across all sam0 MCUs
The currently supported SAM0 MCUs (samd21, saml21, saml1x) share the
same RTC peripheral, yet each of them carries it's own copy of the RTT
driver.

Unify the drivers and move them to sam0_common.
2019-05-09 20:54:00 +02:00
Benjamin Valentin
9aa8c619c1 sam0_common: make RTC implementation common across all sam0 MCUs
The currently supported SAM0 MCUs (samd21, saml21, saml1x) share the
same RTC peripheral, yet each of them carries it's own copy of the RTC
driver.

Unify the drivers and move them to sam0_common.
2019-04-15 22:25:47 +02:00
Kevin "Bear Puncher" Weiss
15c2a48fdf
Merge pull request #10839 from dylad/pr/sam0/remove_gclk_slow
cpu/sam0_common: remove unneeded GCLK_SLOW setup in i2c driver
2019-03-28 14:31:16 +01:00
Dylan Laduranty
ccf12c57a8
Merge pull request #10884 from fedepell/sam_rwee_support
sam0 flashpage RWWEE flash support
2019-03-28 11:00:25 +01:00
1286b18ca9
sam0_common: Fix syntax mistake in usbdev driver 2019-03-26 16:09:03 +01:00
d7804823db
sam0_common: Add USB peripheral driver 2019-03-26 10:26:11 +01:00
Federico Pellegrin
5faafac092 sam0 flashpage RWWEE flash support 2019-03-21 04:27:41 +01:00
Martine Lenders
39e90502af sam0_common: check ADC_NUMOF on adc_init() 2019-02-04 09:28:13 +01:00
Federico Pellegrin
318f0cf679 sam0 flashpage: make ready check inline, add wait also after PBC 2019-01-30 04:29:23 +01:00
Federico Pellegrin
409d83e087 sam0 flashpage: minor code style fixes 2019-01-29 20:58:46 +01:00
Federico Pellegrin
051be66b76 sam0 flashpage: wait for READY bit in INTFLAG after write command 2019-01-27 07:39:10 +01:00
Dylan Laduranty
5dd51f2ec5 cpu/sam0_common: remove unneeded GCLK_SLOW setup in i2c driver 2019-01-22 09:29:42 +01:00
Dylan Laduranty
9450fa7dc3 cpu/sam0_common: add support for saml10/saml11
Add SAML10/SAML11 support through SAM0 because hardware IP are the same so reuse to avoid duplication
2019-01-21 17:06:58 +01:00
Federico Pellegrin
b8b8ffd163 sam0 flashpage_write: correct assert for last byte of flash + style 2018-12-21 13:11:38 +01:00
Federico Pellegrin
a0054654ee sam0 flashpage_write: fix writes translation from RIOT to CPU pages 2018-12-19 04:54:44 +01:00
Martine Lenders
95819c660b sam0_common: mark closing #endif for MODULE_PERIPH_GPIO_IRQ 2018-10-09 15:11:00 +02:00
13654a950b cpu/samr30: add support for samr30g18a
Co-authored-by: biboc <bapclenet@gmail.com>
2018-10-01 10:15:08 +02:00
Hauke Petersen
6afd0efdd8 cpu/sam0_common/gpio: use gpio_irq feature 2018-09-21 08:19:31 +02:00
dylad
4e6d3d1f92 sam0/spi: fix SPI mode assignment
Signed-off-by: dylad <dylan.laduranty@mesotic.com>
2018-09-04 13:58:51 +02:00
smlng
90f66a1952 cpu/sam0_common/i2c: fix ambiguous reg assignment
The value assigned to the register was unclear due to usage
    of bit-comparison and ternary operator, added parentheses to
    make it explicit.
2018-07-25 12:01:40 +02:00
dylad
e6bd6bfe3b sam0/i2c: update driver to new API 2018-07-25 12:01:34 +02:00
Vincent Dupont
a1f482cbf7 cpu/sam0: use const pointer in flashpage 2018-03-14 16:28:33 +01:00
c1e20f8231
Merge pull request #7709 from smlng/cpu/sam0_common/enh_uart
cpu, sam0 common: adapt periph-uart to use read-only bit-fields
2017-12-15 12:45:10 +01:00