Tiva Timer: Add conditional compilation to enable/disable each timer feature. Not only does this reduce the footprint by suppressing unused features, it also protects from partially implemented features that are now conditioned on EXPERIMENTAL
This commit is contained in:
parent
dcb9f4cf31
commit
b1697c7ff4
@ -746,6 +746,54 @@ if TIVA_TIMER
|
||||
|
||||
menu "Tiva Timer Configuration"
|
||||
|
||||
config TIVA_TIMER_DRIVER
|
||||
bool
|
||||
default n
|
||||
|
||||
config TIVA_TIMER_32BIT
|
||||
bool "32-bit timer support"
|
||||
default n
|
||||
|
||||
if TIVA_TIMER_32BIT
|
||||
|
||||
config TIVA_TIMER32_PERIODIC
|
||||
bool "32-bit one-shot/periodic timer support"
|
||||
default n
|
||||
select TIVA_TIMER_DRIVER if TIMER
|
||||
|
||||
config TIVA_TIMER32_RTC
|
||||
bool "32-bit RTC (needs 32.768-KHz input)"
|
||||
default n
|
||||
|
||||
endif # TIVA_TIMER_32BIT
|
||||
|
||||
config TIVA_TIMER_16BIT
|
||||
bool "16-bit Timers"
|
||||
default n
|
||||
|
||||
if TIVA_TIMER_16BIT
|
||||
|
||||
config TIVA_TIMER16_PERIODIC
|
||||
bool "16-bit one-shot/periodic timer support"
|
||||
default n
|
||||
|
||||
config TIVA_TIMER32_EDGECOUNT
|
||||
bool "16-bit input edge-count capture support"
|
||||
default n
|
||||
depends on EXPERIMENTAL
|
||||
|
||||
config TIVA_TIMER32_TIMECAP
|
||||
bool "16-bit input time capture support"
|
||||
default n
|
||||
depends on EXPERIMENTAL
|
||||
|
||||
config TIVA_TIMER32_PWM
|
||||
bool "16-bit PWM output support"
|
||||
default n
|
||||
depends on EXPERIMENTAL
|
||||
|
||||
endif # TIVA_TIMER_16BIT
|
||||
|
||||
config TIVA_TIMER_REGDEBUG
|
||||
bool "Register level debug"
|
||||
default n
|
||||
|
@ -178,6 +178,7 @@ enum tiva_timer16mode_e
|
||||
|
||||
typedef FAR void *TIMER_HANDLE;
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
/* This type describes the 32-bit timer interrupt handler.
|
||||
*
|
||||
* Input Parameters:
|
||||
@ -204,22 +205,28 @@ struct tiva_timer32config_s
|
||||
|
||||
union
|
||||
{
|
||||
#ifdef CONFIG_TIVA_TIMER32_PERIODIC
|
||||
/* 32-bit programmable one-shot or periodic timer */
|
||||
|
||||
struct
|
||||
{
|
||||
uint32_t interval; /* Value for interval load register */
|
||||
} periodic;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_RTC
|
||||
/* 32-bit RTC with external 32.768-KHz input */
|
||||
|
||||
struct
|
||||
{
|
||||
/* No special configuration settings */
|
||||
} rtc;
|
||||
#endif
|
||||
} u;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
/* This type describes the 16-bit timer interrupt handler
|
||||
*
|
||||
* Input Parameters:
|
||||
@ -249,6 +256,7 @@ struct tiva_timer16config_s
|
||||
|
||||
union
|
||||
{
|
||||
#ifdef CONFIG_TIVA_TIMER16_PERIODIC
|
||||
/* 16-bit programmable one-shot or periodic timer */
|
||||
|
||||
struct
|
||||
@ -256,29 +264,37 @@ struct tiva_timer16config_s
|
||||
uint8_t prescaler; /* Prescaler-1: 0-255 corresponding to 1-256 */
|
||||
uint16_t interval; /* Value for interval load register */
|
||||
} periodic;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_EDGECOUNT
|
||||
/* 16-bit input edge-count capture mode w/8-bit prescaler */
|
||||
|
||||
struct
|
||||
{
|
||||
/* TODO: To be provided */
|
||||
} count;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_TIMECAP
|
||||
/* 16-bit input time capture mode w/8-bit prescaler */
|
||||
|
||||
struct
|
||||
{
|
||||
/* TODO: To be provided */
|
||||
} time;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_PWM
|
||||
/* 16-bit PWM output mode w/8-bit prescaler */
|
||||
|
||||
struct
|
||||
{
|
||||
/* TODO: To be provided */
|
||||
} pwm;
|
||||
#endif
|
||||
} u;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* This structure describes usage of both timers on a GPTIM module */
|
||||
|
||||
@ -289,6 +305,7 @@ struct tiva_gptmconfig_s
|
||||
bool alternate; /* False: Use SysClk; True: Use alternate clock source */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
/* This structure is cast compatible with struct tiva_gptmconfig_s and
|
||||
* describes usage of the single 32-bit timers on a GPTM module.
|
||||
*/
|
||||
@ -298,16 +315,19 @@ struct tiva_gptm32config_s
|
||||
struct tiva_gptmconfig_s cmn;
|
||||
struct tiva_timer32config_s config;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* This structure is cast compatible with struct tiva_gptmconfig_s and
|
||||
* describes usage of both bit-bit timers A/B on a GPTM module.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
struct tiva_gptm16config_s
|
||||
{
|
||||
struct tiva_gptmconfig_s cmn;
|
||||
struct tiva_timer16config_s config[2];
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
@ -430,7 +450,9 @@ void tiva_gptm_modifyreg(TIMER_HANDLE handle, unsigned int offset,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
void tiva_timer32_start(TIMER_HANDLE handle);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer16_start
|
||||
@ -448,10 +470,12 @@ void tiva_timer32_start(TIMER_HANDLE handle);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
void tiva_timer16_start(TIMER_HANDLE handle, int tmndx);
|
||||
|
||||
#define tiva_timer16a_start(h) tiva_timer16_start(h, TIMER16A)
|
||||
#define tiva_timer16b_start(h) tiva_timer16_start(h, TIMER16B)
|
||||
# define tiva_timer16a_start(h) tiva_timer16_start(h, TIMER16A)
|
||||
# define tiva_timer16b_start(h) tiva_timer16_start(h, TIMER16B)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer32_stop
|
||||
@ -468,7 +492,9 @@ void tiva_timer16_start(TIMER_HANDLE handle, int tmndx);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
void tiva_timer32_stop(TIMER_HANDLE handle);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer16_stop
|
||||
@ -486,10 +512,12 @@ void tiva_timer32_stop(TIMER_HANDLE handle);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
void tiva_timer16_stop(TIMER_HANDLE handle, int tmndx);
|
||||
|
||||
#define tiva_timer16a_stop(h) tiva_timer16_stop(h, TIMER16A)
|
||||
#define tiva_timer16b_stop(h) tiva_timer16_stop(h, TIMER16B)
|
||||
# define tiva_timer16a_stop(h) tiva_timer16_stop(h, TIMER16A)
|
||||
# define tiva_timer16b_stop(h) tiva_timer16_stop(h, TIMER16B)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer32_counter
|
||||
@ -505,10 +533,12 @@ void tiva_timer16_stop(TIMER_HANDLE handle, int tmndx);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
static inline uint32_t tiva_timer32_counter(TIMER_HANDLE handle)
|
||||
{
|
||||
return tiva_gptm_getreg(handle, TIVA_TIMER_TAR_OFFSET);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer16_counter
|
||||
@ -534,8 +564,13 @@ static inline uint32_t tiva_timer32_counter(TIMER_HANDLE handle)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
uint32_t tiva_timer16_counter(TIMER_HANDLE handle, int tmndx);
|
||||
|
||||
# define tiva_timer16a_counter(h) tiva_timer16_counter(h, TIMER16A)
|
||||
# define tiva_timer16b_counter(h) tiva_timer16_counter(h, TIMER16B)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer32_setinterval
|
||||
*
|
||||
@ -552,7 +587,9 @@ uint32_t tiva_timer16_counter(TIMER_HANDLE handle, int tmndx);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
void tiva_timer32_setinterval(TIMER_HANDLE handle, uint32_t interval);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer16_setinterval
|
||||
@ -571,10 +608,12 @@ void tiva_timer32_setinterval(TIMER_HANDLE handle, uint32_t interval);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
void tiva_timer16_setinterval(TIMER_HANDLE handle, uint16_t interval, int tmndx);
|
||||
|
||||
#define tiva_timer16a_setinterval(h,l) tiva_timer16_setinterval(h,l,TIMER16A)
|
||||
#define tiva_timer16b_setinterval(h,l) tiva_timer16_setinterval(h,l,TIMER16B)
|
||||
# define tiva_timer16a_setinterval(h,l) tiva_timer16_setinterval(h,l,TIMER16A)
|
||||
# define tiva_timer16b_setinterval(h,l) tiva_timer16_setinterval(h,l,TIMER16B)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer32_absmatch
|
||||
@ -593,11 +632,13 @@ void tiva_timer16_setinterval(TIMER_HANDLE handle, uint16_t interval, int tmndx)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
static inline void tiva_timer32_absmatch(TIMER_HANDLE handle,
|
||||
uint32_t absmatch)
|
||||
{
|
||||
tiva_gptm_putreg(handle, TIVA_TIMER_TAMATCHR_OFFSET, absmatch);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer16_absmatch
|
||||
@ -617,6 +658,7 @@ static inline void tiva_timer32_absmatch(TIMER_HANDLE handle,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
static inline void tiva_timer16_absmatch(TIMER_HANDLE handle,
|
||||
uint16_t absmatch, int tmndx)
|
||||
{
|
||||
@ -635,6 +677,7 @@ static inline void tiva_timer16b_absmatch(TIMER_HANDLE handle, uint16_t absmatch
|
||||
{
|
||||
tiva_gptm_putreg(handle, TIVA_TIMER_TBMATCHR_OFFSET, absmatch);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_rtc_settime
|
||||
@ -656,10 +699,12 @@ static inline void tiva_timer16b_absmatch(TIMER_HANDLE handle, uint16_t absmatch
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_RTC
|
||||
static inline void tiva_rtc_settime(TIMER_HANDLE handle, uint32_t newtime)
|
||||
{
|
||||
tiva_gptm_putreg(handle, TIVA_TIMER_TAILR_OFFSET, newtime);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_rtc_setalarm
|
||||
@ -686,7 +731,9 @@ static inline void tiva_rtc_settime(TIMER_HANDLE handle, uint32_t newtime)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_RTC
|
||||
void tiva_rtc_setalarm(TIMER_HANDLE handle, uint32_t delay);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer32_relmatch
|
||||
@ -717,7 +764,9 @@ void tiva_rtc_setalarm(TIMER_HANDLE handle, uint32_t delay);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_PERIODIC
|
||||
void tiva_timer32_relmatch(TIMER_HANDLE handle, uint32_t relmatch);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer16_relmatch
|
||||
@ -759,10 +808,12 @@ void tiva_timer32_relmatch(TIMER_HANDLE handle, uint32_t relmatch);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER16_PERIODIC
|
||||
void tiva_timer16_relmatch(TIMER_HANDLE handle, uint32_t relmatch, int tmndx);
|
||||
|
||||
#define tiva_timer16a_relmatch(h,r) tiva_timer16_relmatch(h,r,TIMER16A)
|
||||
#define tiva_timer16b_relmatch(h,r) tiva_timer16_relmatch(h,r,TIMER16B)
|
||||
# define tiva_timer16a_relmatch(h,r) tiva_timer16_relmatch(h,r,TIMER16A)
|
||||
# define tiva_timer16b_relmatch(h,r) tiva_timer16_relmatch(h,r,TIMER16B)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_gptm0_synchronize
|
||||
@ -779,10 +830,12 @@ void tiva_timer16_relmatch(TIMER_HANDLE handle, uint32_t relmatch, int tmndx);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVER_TIMER0
|
||||
static inline void tiva_gptm0_synchronize(uint32_t sync)
|
||||
{
|
||||
putreg32(sync, TIVA_TIMER0_SYNC);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer_register
|
||||
|
@ -72,9 +72,13 @@
|
||||
struct tiva_gptmattr_s
|
||||
{
|
||||
uintptr_t base; /* Register base address */
|
||||
int irq[2]; /* Timer A/B interrupt numbers */
|
||||
uint16_t irq[2]; /* Timer A/B interrupt numbers */
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
xcpt_t handler32; /* Handler for 32-bit timer interrupts */
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
xcpt_t handler16[2]; /* Handlers for 16-bit timer A/B interrupts */
|
||||
#endif
|
||||
};
|
||||
|
||||
/* This structure represents the state of a GPTM module */
|
||||
@ -116,6 +120,7 @@ static void tiva_putreg(struct tiva_gptmstate_s *priv, unsigned int offset,
|
||||
|
||||
/* Interrupt handling */
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
static int tiva_timer32_interrupt(struct tiva_gptmstate_s *priv);
|
||||
#ifdef CONFIG_TIVA_TIMER0
|
||||
static int tiva_gptm0_interrupt(int irq, FAR void *context);
|
||||
@ -141,7 +146,9 @@ static int tiva_gptm6_interrupt(int irq, FAR void *context);
|
||||
#ifdef CONFIG_TIVA_TIMER7
|
||||
static int tiva_gptm7_interrupt(int irq, FAR void *context);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
static int tiva_timer16_interrupt(struct tiva_gptmstate_s *priv,
|
||||
int tmndx);
|
||||
#ifdef CONFIG_TIVA_TIMER0
|
||||
@ -176,26 +183,43 @@ static int tiva_timer6b_interrupt(int irq, FAR void *context);
|
||||
static int tiva_timer7a_interrupt(int irq, FAR void *context);
|
||||
static int tiva_timer7b_interrupt(int irq, FAR void *context);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Timer initialization and configuration */
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_PERIODIC
|
||||
static int tiva_oneshot_periodic_mode32(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer32config_s *timer);
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER16_PERIODIC
|
||||
static int tiva_oneshot_periodic_mode16(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer16config_s *timer, int tmndx);
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER32_RTC
|
||||
static int tiva_rtc_mode32(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer32config_s *timer);
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER32_EDGECOUNT
|
||||
static int tiva_input_edgecount_mode16(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer16config_s *timer, int tmndx);
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER32_TIMECAP
|
||||
static int tiva_input_time_mode16(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer16config_s *timer, int tmndx);
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER32_PWM
|
||||
static int tiva_pwm_mode16(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer16config_s *timer, int tmndx);
|
||||
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
static int tiva_timer32_configure(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer32config_s *timer);
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
static int tiva_timer16_configure(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer16config_s *timer, int tmndx);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@ -206,8 +230,12 @@ static const struct tiva_gptmattr_s g_gptm0_attr =
|
||||
{
|
||||
.base = TIVA_TIMER0_BASE,
|
||||
.irq = { TIVA_IRQ_TIMER0A, TIVA_IRQ_TIMER0B },
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
.handler32 = tiva_gptm0_interrupt,
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
.handler16 = { tiva_timer0a_interrupt, tiva_timer0b_interrupt },
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct tiva_gptmstate_s g_gptm0_state;
|
||||
@ -218,8 +246,12 @@ static const struct tiva_gptmattr_s g_gptm1_attr =
|
||||
{
|
||||
.base = TIVA_TIMER1_BASE,
|
||||
.irq = { TIVA_IRQ_TIMER1A, TIVA_IRQ_TIMER1B },
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
.handler32 = tiva_gptm1_interrupt,
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
.handler16 = { tiva_timer1a_interrupt, tiva_timer1b_interrupt },
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct tiva_gptmstate_s g_gptm1_state;
|
||||
@ -230,8 +262,12 @@ static const struct tiva_gptmattr_s g_gptm2_attr =
|
||||
{
|
||||
.base = TIVA_TIMER2_BASE,
|
||||
.irq = { TIVA_IRQ_TIMER2A, TIVA_IRQ_TIMER2B },
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
.handler32 = tiva_gptm2_interrupt,
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
.handler16 = { tiva_timer2a_interrupt, tiva_timer2b_interrupt },
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct tiva_gptmstate_s g_gptm2_state;
|
||||
@ -242,8 +278,12 @@ static const struct tiva_gptmattr_s g_gptm3_attr =
|
||||
{
|
||||
.base = TIVA_TIMER3_BASE,
|
||||
.irq = { TIVA_IRQ_TIMER3A, TIVA_IRQ_TIMER3B },
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
.handler32 = tiva_gptm3_interrupt,
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
.handler16 = { tiva_timer3a_interrupt, tiva_timer3b_interrupt },
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct tiva_gptmstate_s g_gptm3_state;
|
||||
@ -254,8 +294,12 @@ static const struct tiva_gptmattr_s g_gptm4_attr =
|
||||
{
|
||||
.base = TIVA_TIMER4_BASE,
|
||||
.irq = { TIVA_IRQ_TIMER4A, TIVA_IRQ_TIMER4B },
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
.handler32 = tiva_gptm4_interrupt,
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
.handler16 = { tiva_timer4a_interrupt, tiva_timer4b_interrupt },
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct tiva_gptmstate_s g_gptm4_state;
|
||||
@ -266,8 +310,12 @@ static const struct tiva_gptmattr_s g_gptm5_attr =
|
||||
{
|
||||
.base = TIVA_TIMER5_BASE,
|
||||
.irq = { TIVA_IRQ_TIMER5A, TIVA_IRQ_TIMER5B },
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
.handler32 = tiva_gptm5_interrupt,
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
.handler16 = { tiva_timer5a_interrupt, tiva_timer5b_interrupt },
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct tiva_gptmstate_s g_gptm5_state;
|
||||
@ -278,8 +326,12 @@ static const struct tiva_gptmattr_s g_gptm6_attr =
|
||||
{
|
||||
.base = TIVA_TIMER6_BASE,
|
||||
.irq = { TIVA_IRQ_TIMER6A, TIVA_IRQ_TIMER6B },
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
.handler32 = tiva_gptm6_interrupt,
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
.handler16 = { tiva_timer6a_interrupt, tiva_timer6b_interrupt },
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct tiva_gptmstate_s g_gptm6_state;
|
||||
@ -290,8 +342,12 @@ static const struct tiva_gptmattr_s g_gptm7_attr =
|
||||
{
|
||||
.base = TIVA_TIMER7_BASE,
|
||||
.irq = { TIVA_IRQ_TIMER7A, TIVA_IRQ_TIMER7B },
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
.handler32 = tiva_gptm7_interrupt,
|
||||
#endif
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
.handler16 = { tiva_timer7a_interrupt, tiva_timer7b_interrupt },
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct tiva_gptmstate_s g_gptm7_state;
|
||||
@ -438,6 +494,7 @@ static void tiva_modifyreg(struct tiva_gptmstate_s *priv, unsigned int offset,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
static int tiva_timer32_interrupt(struct tiva_gptmstate_s *priv)
|
||||
{
|
||||
const struct tiva_gptm32config_s *config32;
|
||||
@ -485,6 +542,7 @@ static int tiva_timer32_interrupt(struct tiva_gptmstate_s *priv)
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_gptmN_interrupt, N=0..7
|
||||
@ -494,6 +552,7 @@ static int tiva_timer32_interrupt(struct tiva_gptmstate_s *priv)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
#ifdef CONFIG_TIVA_TIMER0
|
||||
static int tiva_gptm0_interrupt(int irq, FAR void *context)
|
||||
{
|
||||
@ -549,6 +608,7 @@ static int tiva_gptm7_interrupt(int irq, FAR void *context)
|
||||
return tiva_timer32_interrupt(&g_gptm7_state);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer16_interrupt
|
||||
@ -558,6 +618,7 @@ static int tiva_gptm7_interrupt(int irq, FAR void *context)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
static int tiva_timer16_interrupt(struct tiva_gptmstate_s *priv, int tmndx)
|
||||
{
|
||||
const struct tiva_gptm16config_s *config16;
|
||||
@ -607,6 +668,7 @@ static int tiva_timer16_interrupt(struct tiva_gptmstate_s *priv, int tmndx)
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timerNa_interrupt, tiva_timerNb_interrupt, N=0..7
|
||||
@ -616,6 +678,7 @@ static int tiva_timer16_interrupt(struct tiva_gptmstate_s *priv, int tmndx)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
#ifdef CONFIG_TIVA_TIMER0
|
||||
static int tiva_timer0a_interrupt(int irq, FAR void *context)
|
||||
{
|
||||
@ -711,6 +774,7 @@ static int tiva_timer7b_interrupt(int irq, FAR void *context)
|
||||
return tiva_timer16_interrupt(&g_gptm7_state, TIMER16B);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_oneshot_periodic_mode32
|
||||
@ -720,6 +784,7 @@ static int tiva_timer7b_interrupt(int irq, FAR void *context)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_PERIODIC
|
||||
static int tiva_oneshot_periodic_mode32(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer32config_s *timer)
|
||||
{
|
||||
@ -929,6 +994,7 @@ static int tiva_oneshot_periodic_mode32(struct tiva_gptmstate_s *priv,
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_oneshot_periodic_mode16
|
||||
@ -938,6 +1004,7 @@ static int tiva_oneshot_periodic_mode32(struct tiva_gptmstate_s *priv,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER16_PERIODIC
|
||||
static int tiva_oneshot_periodic_mode16(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer16config_s *timer,
|
||||
int tmndx)
|
||||
@ -1149,6 +1216,7 @@ static int tiva_oneshot_periodic_mode16(struct tiva_gptmstate_s *priv,
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_rtc_mode32
|
||||
@ -1162,6 +1230,7 @@ static int tiva_oneshot_periodic_mode16(struct tiva_gptmstate_s *priv,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_RTC
|
||||
static int tiva_rtc_mode32(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer32config_s *timer)
|
||||
{
|
||||
@ -1235,6 +1304,7 @@ static int tiva_rtc_mode32(struct tiva_gptmstate_s *priv,
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_input_edgecount_mode16
|
||||
@ -1244,6 +1314,7 @@ static int tiva_rtc_mode32(struct tiva_gptmstate_s *priv,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_EDGECOUNT
|
||||
static int tiva_input_edgecount_mode16(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer16config_s *timer,
|
||||
int tmndx)
|
||||
@ -1302,6 +1373,7 @@ static int tiva_input_edgecount_mode16(struct tiva_gptmstate_s *priv,
|
||||
|
||||
return -ENOSYS;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_input_time_mode16
|
||||
@ -1311,6 +1383,7 @@ static int tiva_input_edgecount_mode16(struct tiva_gptmstate_s *priv,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_TIMECAP
|
||||
static int tiva_input_time_mode16(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer16config_s *timer,
|
||||
int tmndx)
|
||||
@ -1370,6 +1443,7 @@ static int tiva_input_time_mode16(struct tiva_gptmstate_s *priv,
|
||||
|
||||
return -ENOSYS;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_pwm_mode16
|
||||
@ -1379,6 +1453,7 @@ static int tiva_input_time_mode16(struct tiva_gptmstate_s *priv,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_PWM
|
||||
static int tiva_pwm_mode16(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer16config_s *timer,
|
||||
int tmndx)
|
||||
@ -1438,6 +1513,7 @@ static int tiva_pwm_mode16(struct tiva_gptmstate_s *priv,
|
||||
|
||||
return -ENOSYS;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer16_configure
|
||||
@ -1447,23 +1523,29 @@ static int tiva_pwm_mode16(struct tiva_gptmstate_s *priv,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
static int tiva_timer32_configure(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer32config_s *timer)
|
||||
{
|
||||
switch (priv->config->mode)
|
||||
{
|
||||
#ifdef CONFIG_TIVA_TIMER32_PERIODIC
|
||||
case TIMER32_MODE_ONESHOT: /* 32-bit programmable one-shot timer */
|
||||
case TIMER32_MODE_PERIODIC: /* 32-bit programmable periodic timer */
|
||||
return tiva_oneshot_periodic_mode32(priv, timer);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_RTC
|
||||
case TIMER32_MODE_RTC: /* 32-bit RTC with external 32.768-KHz
|
||||
* input */
|
||||
return tiva_rtc_mode32(priv, timer);
|
||||
#endif
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer16_configure
|
||||
@ -1473,6 +1555,7 @@ static int tiva_timer32_configure(struct tiva_gptmstate_s *priv,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
static int tiva_timer16_configure(struct tiva_gptmstate_s *priv,
|
||||
const struct tiva_timer16config_s *timer,
|
||||
int tmndx)
|
||||
@ -1484,26 +1567,35 @@ static int tiva_timer16_configure(struct tiva_gptmstate_s *priv,
|
||||
case TIMER16_MODE_NONE:
|
||||
return OK;
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER16_PERIODIC
|
||||
case TIMER16_MODE_ONESHOT: /* 16-bit programmable one-shot timer */
|
||||
case TIMER16_MODE_PERIODIC: /* 16-bit programmable periodic timer */
|
||||
return tiva_oneshot_periodic_mode16(priv, timer, tmndx);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_EDGECOUNT
|
||||
case TIMER16_MODE_COUNT_CAPTURE: /* 16-bit input-edge count-capture
|
||||
* mode w/8-bit prescaler */
|
||||
return tiva_input_edgecount_mode16(priv, timer, tmndx);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_TIMECAP
|
||||
case TIMER16_MODE_TIME_CAPTURE: /* 16-bit input-edge time-capture
|
||||
* mode w/8-bit prescaler */
|
||||
return tiva_input_time_mode16(priv, timer, tmndx);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_PWM
|
||||
case TIMER16_MODE_PWM: /* 16-bit PWM output mode w/8-bit
|
||||
* prescaler */
|
||||
return tiva_pwm_mode16(priv, timer, tmndx);
|
||||
#endif
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -1687,6 +1779,7 @@ TIMER_HANDLE tiva_gptm_configure(const struct tiva_gptmconfig_s *config)
|
||||
|
||||
if (config->mode != TIMER16_MODE)
|
||||
{
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
const struct tiva_gptm32config_s *config32 =
|
||||
(const struct tiva_gptm32config_s *)config;
|
||||
|
||||
@ -1701,9 +1794,13 @@ TIMER_HANDLE tiva_gptm_configure(const struct tiva_gptmconfig_s *config)
|
||||
|
||||
ret = tiva_timer32_configure(priv, &config32->config);
|
||||
}
|
||||
#else
|
||||
return (TIMER_HANDLE)NULL;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
const struct tiva_gptm16config_s *config16 =
|
||||
(const struct tiva_gptm16config_s *)config;
|
||||
|
||||
@ -1738,6 +1835,9 @@ TIMER_HANDLE tiva_gptm_configure(const struct tiva_gptmconfig_s *config)
|
||||
ret = tiva_timer16_configure(priv, &config16->config[TIMER16B],
|
||||
TIMER16B);
|
||||
}
|
||||
#else
|
||||
return (TIMER_HANDLE)NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return the timer handler if successfully configured */
|
||||
@ -1894,6 +1994,7 @@ void tiva_gptm_modifyreg(TIMER_HANDLE handle, unsigned int offset,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
void tiva_timer32_start(TIMER_HANDLE handle)
|
||||
{
|
||||
struct tiva_gptmstate_s *priv = (struct tiva_gptmstate_s *)handle;
|
||||
@ -1913,6 +2014,7 @@ void tiva_timer32_start(TIMER_HANDLE handle)
|
||||
up_enable_irq(priv->attr->irq[TIMER32]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer16_start
|
||||
@ -1930,6 +2032,7 @@ void tiva_timer32_start(TIMER_HANDLE handle)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
void tiva_timer16_start(TIMER_HANDLE handle, int tmndx)
|
||||
{
|
||||
struct tiva_gptmstate_s *priv = (struct tiva_gptmstate_s *)handle;
|
||||
@ -1953,6 +2056,7 @@ void tiva_timer16_start(TIMER_HANDLE handle, int tmndx)
|
||||
up_enable_irq(priv->attr->irq[tmndx]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer32_stop
|
||||
@ -1969,6 +2073,7 @@ void tiva_timer16_start(TIMER_HANDLE handle, int tmndx)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
void tiva_timer32_stop(TIMER_HANDLE handle)
|
||||
{
|
||||
struct tiva_gptmstate_s *priv = (struct tiva_gptmstate_s *)handle;
|
||||
@ -1983,6 +2088,7 @@ void tiva_timer32_stop(TIMER_HANDLE handle)
|
||||
|
||||
tiva_modifyreg(priv, TIVA_TIMER_CTL_OFFSET, TIMER_CTL_TAEN, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer16_stop
|
||||
@ -2000,6 +2106,7 @@ void tiva_timer32_stop(TIMER_HANDLE handle)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
void tiva_timer16_stop(TIMER_HANDLE handle, int tmndx)
|
||||
{
|
||||
struct tiva_gptmstate_s *priv = (struct tiva_gptmstate_s *)handle;
|
||||
@ -2016,6 +2123,7 @@ void tiva_timer16_stop(TIMER_HANDLE handle, int tmndx)
|
||||
clrbits = tmndx ? TIMER_CTL_TBEN : TIMER_CTL_TAEN;
|
||||
tiva_gptm_modifyreg(handle, TIVA_TIMER_CTL_OFFSET, clrbits, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer16_counter
|
||||
@ -2041,6 +2149,7 @@ void tiva_timer16_stop(TIMER_HANDLE handle, int tmndx)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
uint32_t tiva_timer16_counter(TIMER_HANDLE handle, int tmndx)
|
||||
{
|
||||
struct tiva_gptmstate_s *priv = (struct tiva_gptmstate_s *)handle;
|
||||
@ -2141,6 +2250,7 @@ uint32_t tiva_timer16_counter(TIMER_HANDLE handle, int tmndx)
|
||||
|
||||
return counter;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer32_setinterval
|
||||
@ -2158,6 +2268,7 @@ uint32_t tiva_timer16_counter(TIMER_HANDLE handle, int tmndx)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_32BIT
|
||||
void tiva_timer32_setinterval(TIMER_HANDLE handle, uint32_t interval)
|
||||
{
|
||||
struct tiva_gptmstate_s *priv = (struct tiva_gptmstate_s *)handle;
|
||||
@ -2251,6 +2362,7 @@ void tiva_timer32_setinterval(TIMER_HANDLE handle, uint32_t interval)
|
||||
lldbg("%08x<-%08x\n", imrr, priv->imr);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer16_setinterval
|
||||
@ -2269,6 +2381,7 @@ void tiva_timer32_setinterval(TIMER_HANDLE handle, uint32_t interval)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER_16BIT
|
||||
void tiva_timer16_setinterval(TIMER_HANDLE handle, uint16_t interval, int tmndx)
|
||||
{
|
||||
struct tiva_gptmstate_s *priv = (struct tiva_gptmstate_s *)handle;
|
||||
@ -2376,6 +2489,7 @@ void tiva_timer16_setinterval(TIMER_HANDLE handle, uint16_t interval, int tmndx)
|
||||
lldbg("%08x<-%08x\n", imrr, priv->imr);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_rtc_setalarm
|
||||
@ -2397,6 +2511,7 @@ void tiva_timer16_setinterval(TIMER_HANDLE handle, uint16_t interval, int tmndx)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_RTC
|
||||
void tiva_rtc_setalarm(TIMER_HANDLE handle, uint32_t delay)
|
||||
{
|
||||
struct tiva_gptmstate_s *priv = (struct tiva_gptmstate_s *)handle;
|
||||
@ -2464,6 +2579,7 @@ void tiva_rtc_setalarm(TIMER_HANDLE handle, uint32_t delay)
|
||||
lldbg("%08x<-%08x\n", base + TIVA_TIMER_IMR_OFFSET, priv->imr);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer32_relmatch
|
||||
@ -2494,6 +2610,7 @@ void tiva_rtc_setalarm(TIMER_HANDLE handle, uint32_t delay)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER32_PERIODIC
|
||||
void tiva_timer32_relmatch(TIMER_HANDLE handle, uint32_t relmatch)
|
||||
{
|
||||
struct tiva_gptmstate_s *priv = (struct tiva_gptmstate_s *)handle;
|
||||
@ -2561,6 +2678,7 @@ void tiva_timer32_relmatch(TIMER_HANDLE handle, uint32_t relmatch)
|
||||
lldbg("%08x<-%08x\n", base + TIVA_TIMER_IMR_OFFSET, priv->imr);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timer16_relmatch
|
||||
@ -2602,6 +2720,7 @@ void tiva_timer32_relmatch(TIMER_HANDLE handle, uint32_t relmatch)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_TIMER16_PERIODIC
|
||||
void tiva_timer16_relmatch(TIMER_HANDLE handle, uint32_t relmatch, int tmndx)
|
||||
{
|
||||
struct tiva_gptmstate_s *priv = (struct tiva_gptmstate_s *)handle;
|
||||
@ -2749,3 +2868,5 @@ void tiva_timer16_relmatch(TIMER_HANDLE handle, uint32_t relmatch, int tmndx)
|
||||
lldbg("%08x<-%08x\n", imr, priv->imr);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user