Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/sam3: reworked timer driver #4891

Merged
merged 4 commits into from
Feb 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 10 additions & 25 deletions boards/arduino-due/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,16 @@ extern "C" {
* @name Timer peripheral configuration
* @{
*/
#define TIMER_NUMOF (3U)
#define TIMER_0_EN 1
#define TIMER_1_EN 1
#define TIMER_2_EN 1

/* Timer 0 configuration */
#define TIMER_0_DEV TC0
#define TIMER_0_CHANNELS 6
#define TIMER_0_MAX_VALUE (0xffffffff)
#define TIMER_0_ISR1 isr_tc0
#define TIMER_0_ISR2 isr_tc1

/* Timer 1 configuration */
#define TIMER_1_DEV TC1
#define TIMER_1_CHANNELS 6
#define TIMER_1_MAX_VALUE (0xffffffff)
#define TIMER_1_ISR1 isr_tc3
#define TIMER_1_ISR2 isr_tc4

/* Timer 2 configuration */
#define TIMER_2_DEV TC2
#define TIMER_2_CHANNELS 6
#define TIMER_2_MAX_VALUE (0xffffffff)
#define TIMER_2_ISR1 isr_tc6
#define TIMER_2_ISR2 isr_tc7
static const timer_conf_t timer_config[] = {
/* dev, channel 0 ID */
{ TC0, ID_TC0 },
{ TC1, ID_TC3 },
};

#define TIMER_0_ISR isr_tc0
#define TIMER_1_ISR isr_tc3

#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0]))
/** @} */

/**
Expand Down
31 changes: 8 additions & 23 deletions boards/udoo/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,16 @@ extern "C" {
* @name Timer peripheral configuration
* @{
*/
#define TIMER_NUMOF (3U)
#define TIMER_0_EN 1
#define TIMER_1_EN 1
#define TIMER_2_EN 1

/* Timer 0 configuration */
#define TIMER_0_DEV TC0
#define TIMER_0_CHANNELS 6
#define TIMER_0_MAX_VALUE (0xffffffff)
#define TIMER_0_ISR1 isr_tc0
#define TIMER_0_ISR2 isr_tc1
static const timer_conf_t timer_config[] = {
/* dev, channel 0 ID */
{ TC0, ID_TC0 },
{ TC1, ID_TC3 },
};

/* Timer 1 configuration */
#define TIMER_1_DEV TC1
#define TIMER_1_CHANNELS 6
#define TIMER_1_MAX_VALUE (0xffffffff)
#define TIMER_1_ISR1 isr_tc3
#define TIMER_1_ISR2 isr_tc4
#define TIMER_0_ISR isr_tc0
#define TIMER_1_ISR isr_tc3

/* Timer 2 configuration */
#define TIMER_2_DEV TC2
#define TIMER_2_CHANNELS 6
#define TIMER_2_MAX_VALUE (0xffffffff)
#define TIMER_2_ISR1 isr_tc6
#define TIMER_2_ISR2 isr_tc7
#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0]))
/** @} */

/**
Expand Down
18 changes: 18 additions & 0 deletions cpu/sam3/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ typedef uint32_t gpio_t;
*/
#define CPUID_LEN (16U)

/**
* @brief All SAM3 timers are 32-bit wide
*/
#define TIMER_MAX_VAL (0xffffffff)

/**
* @brief We use 3 channels for each defined timer
*/
#define TIMER_CHANNELS (3)

/**
* @brief Override values for pull register configuration
* @{
Expand Down Expand Up @@ -102,6 +112,14 @@ typedef enum {
GPIO_MUX_B = 1, /**< alternate function B */
} gpio_mux_t;

/**
* @brief Timer configuration data
*/
typedef struct {
Tc *dev; /**< timer device */
uint8_t id_ch0; /**< ID of the timer's first channel */
} timer_conf_t;

/**
* @brief UART configuration data
*/
Expand Down
4 changes: 1 addition & 3 deletions cpu/sam3/include/sam3x8e/component/component_tc.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ typedef struct {
RwReg TC_SMMR; /**< \brief (TcChannel Offset: 0x8) Stepper Motor Mode Register */
RoReg Reserved1[1];
RwReg TC_CV; /**< \brief (TcChannel Offset: 0x10) Counter Value */
RwReg TC_RA; /**< \brief (TcChannel Offset: 0x14) Register A */
RwReg TC_RB; /**< \brief (TcChannel Offset: 0x18) Register B */
RwReg TC_RC; /**< \brief (TcChannel Offset: 0x1C) Register C */
RwReg TC_R[3]; /**< \brief (TcChannel Offset: 0x14) Register A-C */
RwReg TC_SR; /**< \brief (TcChannel Offset: 0x20) Status Register */
RwReg TC_IER; /**< \brief (TcChannel Offset: 0x24) Interrupt Enable Register */
RwReg TC_IDR; /**< \brief (TcChannel Offset: 0x28) Interrupt Disable Register */
Expand Down
Loading