mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/nrf5x_common: implement periph_timer_query_freqs
This commit is contained in:
parent
5dc3d9c743
commit
b40ab8f833
@ -16,6 +16,7 @@ config CPU_FAM_NRF53
|
|||||||
select HAS_PERIPH_GPIO
|
select HAS_PERIPH_GPIO
|
||||||
select HAS_PERIPH_GPIO_IRQ
|
select HAS_PERIPH_GPIO_IRQ
|
||||||
select HAS_PERIPH_TIMER_PERIODIC
|
select HAS_PERIPH_TIMER_PERIODIC
|
||||||
|
select HAS_PERIPH_TIMER_QUERY_FREQS
|
||||||
select HAS_PERIPH_UART_MODECFG
|
select HAS_PERIPH_UART_MODECFG
|
||||||
select HAS_PERIPH_WDT
|
select HAS_PERIPH_WDT
|
||||||
select HAS_PERIPH_WDT_CB
|
select HAS_PERIPH_WDT_CB
|
||||||
|
@ -20,6 +20,7 @@ depends on !CPU_FAM_NRF53
|
|||||||
select HAS_PERIPH_HWRNG
|
select HAS_PERIPH_HWRNG
|
||||||
select HAS_PERIPH_TEMPERATURE
|
select HAS_PERIPH_TEMPERATURE
|
||||||
select HAS_PERIPH_TIMER_PERIODIC
|
select HAS_PERIPH_TIMER_PERIODIC
|
||||||
|
select HAS_PERIPH_TIMER_QUERY_FREQS
|
||||||
select HAS_PERIPH_RTT_OVERFLOW
|
select HAS_PERIPH_RTT_OVERFLOW
|
||||||
select HAS_PERIPH_UART_MODECFG
|
select HAS_PERIPH_UART_MODECFG
|
||||||
select HAS_PERIPH_WDT
|
select HAS_PERIPH_WDT
|
||||||
|
@ -5,6 +5,7 @@ FEATURES_PROVIDED += periph_flashpage_in_address_space
|
|||||||
FEATURES_PROVIDED += periph_flashpage_pagewise
|
FEATURES_PROVIDED += periph_flashpage_pagewise
|
||||||
FEATURES_PROVIDED += periph_gpio periph_gpio_irq
|
FEATURES_PROVIDED += periph_gpio periph_gpio_irq
|
||||||
FEATURES_PROVIDED += periph_timer_periodic
|
FEATURES_PROVIDED += periph_timer_periodic
|
||||||
|
FEATURES_PROVIDED += periph_timer_query_freqs
|
||||||
FEATURES_PROVIDED += periph_uart_modecfg
|
FEATURES_PROVIDED += periph_uart_modecfg
|
||||||
FEATURES_PROVIDED += periph_wdt periph_wdt_cb
|
FEATURES_PROVIDED += periph_wdt periph_wdt_cb
|
||||||
|
|
||||||
|
@ -257,6 +257,16 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
#define PERIPH_TIMER_PROVIDES_SET 1
|
#define PERIPH_TIMER_PROVIDES_SET 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Maximum number of channels
|
||||||
|
*
|
||||||
|
* @note NRF_TIMER1 and NRF_TIMER2 only have 4 hardware channels (and 3 of
|
||||||
|
* of them are available to the application, as one has to be used
|
||||||
|
* to implement timer_read()). Use @ref timer_query_channel_numof to
|
||||||
|
* check the actual number of supported channels for a given timer.
|
||||||
|
*/
|
||||||
|
#define TIMER_CHANNEL_NUMOF 5
|
||||||
|
|
||||||
#ifndef DOXYGEN
|
#ifndef DOXYGEN
|
||||||
/**
|
/**
|
||||||
* @brief Override SPI mode values
|
* @brief Override SPI mode values
|
||||||
|
@ -45,6 +45,30 @@ static inline NRF_TIMER_Type *dev(tim_t tim)
|
|||||||
return timer_config[tim].dev;
|
return timer_config[tim].dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uword_t timer_query_freqs_numof(tim_t dev)
|
||||||
|
{
|
||||||
|
assert(dev < TIMER_NUMOF);
|
||||||
|
(void)dev;
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
uword_t timer_query_channel_numof(tim_t dev)
|
||||||
|
{
|
||||||
|
assert(dev < TIMER_NUMOF);
|
||||||
|
return timer_config[dev].channels;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t timer_query_freqs(tim_t dev, uword_t index)
|
||||||
|
{
|
||||||
|
assert(dev < TIMER_NUMOF);
|
||||||
|
(void)dev;
|
||||||
|
if (index >= 10) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return F_TIMER >> index;
|
||||||
|
}
|
||||||
|
|
||||||
int timer_init(tim_t tim, uint32_t freq, timer_cb_t cb, void *arg)
|
int timer_init(tim_t tim, uint32_t freq, timer_cb_t cb, void *arg)
|
||||||
{
|
{
|
||||||
/* make sure the given timer is valid */
|
/* make sure the given timer is valid */
|
||||||
@ -75,7 +99,7 @@ int timer_init(tim_t tim, uint32_t freq, timer_cb_t cb, void *arg)
|
|||||||
dev(tim)->PRESCALER = i;
|
dev(tim)->PRESCALER = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cando /= 2;
|
cando >>= 1;
|
||||||
}
|
}
|
||||||
if (i == 10) {
|
if (i == 10) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -17,6 +17,7 @@ config CPU_FAM_NRF9160
|
|||||||
select HAS_PERIPH_GPIO_LL_IRQ
|
select HAS_PERIPH_GPIO_LL_IRQ
|
||||||
select HAS_PERIPH_GPIO_LL_IRQ_UNMASK
|
select HAS_PERIPH_GPIO_LL_IRQ_UNMASK
|
||||||
select HAS_PERIPH_TIMER_PERIODIC
|
select HAS_PERIPH_TIMER_PERIODIC
|
||||||
|
select HAS_PERIPH_TIMER_QUERY_FREQS
|
||||||
select HAS_PERIPH_UART_MODECFG
|
select HAS_PERIPH_UART_MODECFG
|
||||||
select HAS_PERIPH_SPI_GPIO_MODE
|
select HAS_PERIPH_SPI_GPIO_MODE
|
||||||
select HAS_PERIPH_WDT
|
select HAS_PERIPH_WDT
|
||||||
|
Loading…
Reference in New Issue
Block a user