Skip to content
Permalink
Browse files

drivers: counter: Add SAM0 basic counter support

This adds support for the basic timer counter (TC) found on SAM0
series parts.  This driver only supports running the counter
in 32 bit wide mode.  Since this mode explicitly slaves the odd
counters to the even ones, only instances of the even ones are
defined.

Tested with tests/drivers/counter/counter_basic_api on SAMD21.

Signed-off-by: Derek Hageman <hageman@inthat.cloud>
  • Loading branch information...
Sizurka authored and nashif committed Apr 2, 2019
1 parent 7d27903 commit a4f3e628e51a1d5cd6fe835aac4058dc3bd56a28
@@ -12,5 +12,6 @@ zephyr_library_sources_ifdef(CONFIG_COUNTER_NRF_TIMER counter_nrfx_tim
zephyr_library_sources_ifdef(CONFIG_COUNTER_NRF_RTC counter_nrfx_rtc.c)
zephyr_library_sources_ifdef(CONFIG_RTC_QMSI counter_rtc_qmsi.c)
zephyr_library_sources_ifdef(CONFIG_COUNTER_RTC_STM32 counter_ll_stm32_rtc.c)
zephyr_library_sources_ifdef(CONFIG_COUNTER_SAM0_TC32 counter_sam0_tc32.c)

zephyr_library_sources_ifdef(CONFIG_USERSPACE counter_handlers.c)
@@ -34,4 +34,6 @@ source "drivers/counter/Kconfig.imx_epit"

source "drivers/counter/Kconfig.stm32_rtc"

source "drivers/counter/Kconfig.sam0"

endif # COUNTER
@@ -0,0 +1,28 @@
# Copyright (c) 2019 Derek Hageman <hageman@inthat.cloud>
#
# SPDX-License-Identifier: Apache-2.0
#

menuconfig COUNTER_SAM0_TC32
bool "SAM0 series 32-bit basic timer driver"
default y
depends on SOC_FAMILY_SAM0
help
Enable the SAM0 series timer counter (TC) driver in 32-bit wide
mode.

if COUNTER_SAM0_TC32

index = 0
source "drivers/counter/Kconfig.template.sam0_tc32"

index = 2
source "drivers/counter/Kconfig.template.sam0_tc32"

index = 4
source "drivers/counter/Kconfig.template.sam0_tc32"

index = 6
source "drivers/counter/Kconfig.template.sam0_tc32"

endif # COUNTER_SAM0_TC32
@@ -0,0 +1,38 @@
# Copyright (c) 2019 Derek Hageman <hageman@inthat.cloud>
#
# SPDX-License-Identifier: Apache-2.0
#


choice
bool "Timer $(index) prescaler"

config COUNTER_SAM0_TC32_$(index)_PRESCALER_1
bool "clock / 1"
config COUNTER_SAM0_TC32_$(index)_PRESCALER_2
bool "clock / 2"
config COUNTER_SAM0_TC32_$(index)_PRESCALER_4
bool "clock / 4"
config COUNTER_SAM0_TC32_$(index)_PRESCALER_8
bool "clock / 8"
config COUNTER_SAM0_TC32_$(index)_PRESCALER_16
bool "clock / 16"
config COUNTER_SAM0_TC32_$(index)_PRESCALER_64
bool "clock / 64"
config COUNTER_SAM0_TC32_$(index)_PRESCALER_256
bool "clock / 256"
config COUNTER_SAM0_TC32_$(index)_PRESCALER_1024
bool "clock / 1024"

endchoice

config COUNTER_SAM0_TC32_$(index)_DIVISOR
int
default 1 if COUNTER_SAM0_TC32_$(index)_PRESCALER_1
default 2 if COUNTER_SAM0_TC32_$(index)_PRESCALER_2
default 4 if COUNTER_SAM0_TC32_$(index)_PRESCALER_4
default 8 if COUNTER_SAM0_TC32_$(index)_PRESCALER_8
default 16 if COUNTER_SAM0_TC32_$(index)_PRESCALER_16
default 64 if COUNTER_SAM0_TC32_$(index)_PRESCALER_64
default 256 if COUNTER_SAM0_TC32_$(index)_PRESCALER_256
default 1024 if COUNTER_SAM0_TC32_$(index)_PRESCALER_1024

0 comments on commit a4f3e62

Please sign in to comment.
You can’t perform that action at this time.