mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 03:45:50 +08:00
SAMA5 T/C: Can now handle non-constant BOARD_MCK_FREQUENCY. Also now supports methods to attach user interrupt handlers
This commit is contained in:
@@ -423,6 +423,7 @@
|
|||||||
# define SAMA5_HAVE_PMC_PCR_DIV 1 /* Supports conditional compilation */
|
# define SAMA5_HAVE_PMC_PCR_DIV 1 /* Supports conditional compilation */
|
||||||
# define PMC_PCR_DIV_SHIFT (16) /* Bits 16-17: Divisor Value */
|
# define PMC_PCR_DIV_SHIFT (16) /* Bits 16-17: Divisor Value */
|
||||||
# define PMC_PCR_DIV_MASK (3 << PMC_PCR_DIV_SHIFT)
|
# define PMC_PCR_DIV_MASK (3 << PMC_PCR_DIV_SHIFT)
|
||||||
|
# define PMC_PCR_DIV(n) ((uint32_t)(n) << PMC_PCR_DIV_SHIFT)
|
||||||
# define PMC_PCR_DIV1 (0 << PMC_PCR_DIV_SHIFT) /* Peripheral clock is MCK */
|
# define PMC_PCR_DIV1 (0 << PMC_PCR_DIV_SHIFT) /* Peripheral clock is MCK */
|
||||||
# define PMC_PCR_DIV2 (1 << PMC_PCR_DIV_SHIFT) /* Peripheral clock is MCK/2 */
|
# define PMC_PCR_DIV2 (1 << PMC_PCR_DIV_SHIFT) /* Peripheral clock is MCK/2 */
|
||||||
# define PMC_PCR_DIV4 (2 << PMC_PCR_DIV_SHIFT) /* Peripheral clock is MCK/4 */
|
# define PMC_PCR_DIV4 (2 << PMC_PCR_DIV_SHIFT) /* Peripheral clock is MCK/4 */
|
||||||
|
|||||||
+354
-61
File diff suppressed because it is too large
Load Diff
@@ -55,12 +55,15 @@
|
|||||||
|
|
||||||
/* The timer/counter and channel arguments to sam_tc_allocate() */
|
/* The timer/counter and channel arguments to sam_tc_allocate() */
|
||||||
|
|
||||||
#define TC_CHAN0 0
|
#define TC_CHAN0 0 /* TC0 */
|
||||||
#define TC_CHAN1 1
|
#define TC_CHAN1 1
|
||||||
#define TC_CHAN2 2
|
#define TC_CHAN2 2
|
||||||
#define TC_CHAN3 3
|
#define TC_CHAN3 3 /* TC1 */
|
||||||
#define TC_CHAN4 4
|
#define TC_CHAN4 4
|
||||||
#define TC_CHAN5 5
|
#define TC_CHAN5 5
|
||||||
|
#define TC_CHAN6 6 /* TC2 */
|
||||||
|
#define TC_CHAN7 7
|
||||||
|
#define TC_CHAN8 8
|
||||||
|
|
||||||
/* Register identifier used with sam_tc_setregister */
|
/* Register identifier used with sam_tc_setregister */
|
||||||
|
|
||||||
@@ -71,9 +74,21 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
/* An opaque handle used to represent a timer channel */
|
||||||
|
|
||||||
typedef void *TC_HANDLE;
|
typedef void *TC_HANDLE;
|
||||||
|
|
||||||
|
/* Timer interrupt callback. When a timer interrup expires, the client will
|
||||||
|
* receive:
|
||||||
|
*
|
||||||
|
* handle - The handle that represents the timer state
|
||||||
|
* arg - An opaque argument provided when the interrupt was registered
|
||||||
|
* sr - The value of the timer interrupt status register at the time
|
||||||
|
* that the interrupt occurred.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef void (*tc_handler_t)(TC_HANDLE handle, void *arg, uint32_t sr);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -144,6 +159,33 @@ void sam_tc_free(TC_HANDLE handle);
|
|||||||
|
|
||||||
void sam_tc_start(TC_HANDLE handle);
|
void sam_tc_start(TC_HANDLE handle);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: sam_tc_attach/sam_tc_detach
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Attach or detach an interrupt handler to the timer interrupt. The
|
||||||
|
* interrupt is detached if the handler argument is NULL.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* handle The handle that represents the timer state
|
||||||
|
* handler The interrupt handler that will be invoked when the interrupt
|
||||||
|
* condition occurs
|
||||||
|
* arg An opaque argument that will be provided when the interrupt
|
||||||
|
* handler callback is executed. Ignored if handler is NULL.
|
||||||
|
* mask The value of the timer interrupt mask register that defines
|
||||||
|
* which interrupts should be disabled. Ignored if handler is
|
||||||
|
* NULL.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* The address of the previous handler, if any.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
tc_handler_t sam_tc_attach(TC_HANDLE handle, tc_handler_t handler,
|
||||||
|
void *arg, uint32_t mask);
|
||||||
|
|
||||||
|
#define sam_tc_detach(h) sam_tc_attach(h, NULL, NULL, 0)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: sam_tc_stop
|
* Name: sam_tc_stop
|
||||||
*
|
*
|
||||||
@@ -166,7 +208,7 @@ void sam_tc_stop(TC_HANDLE handle);
|
|||||||
* Set TC_RA, TC_RB, or TC_RB using the provided divisor. The actual
|
* Set TC_RA, TC_RB, or TC_RB using the provided divisor. The actual
|
||||||
* setting in the register will be the TC input frequency divided by
|
* setting in the register will be the TC input frequency divided by
|
||||||
* the provided divider (which should derive from the divider returned
|
* the provided divider (which should derive from the divider returned
|
||||||
* by sam_tc_divider).
|
* by sam_tc_divisor).
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
@@ -206,7 +248,7 @@ uint32_t sam_tc_frequency(void);
|
|||||||
* (Ftc / (div * 65536)) <= freq <= (Ftc / dev)
|
* (Ftc / (div * 65536)) <= freq <= (Ftc / dev)
|
||||||
*
|
*
|
||||||
* where:
|
* where:
|
||||||
* freq - the desitred frequency
|
* freq - the desired frequency
|
||||||
* Ftc - The timer/counter input frequency
|
* Ftc - The timer/counter input frequency
|
||||||
* div - With DIV being the highest possible value.
|
* div - With DIV being the highest possible value.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -197,7 +197,8 @@ struct watchdog_lowerhalf_s
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#define EXTERN extern "C"
|
#define EXTERN extern "C"
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
#else
|
#else
|
||||||
#define EXTERN extern
|
#define EXTERN extern
|
||||||
#endif
|
#endif
|
||||||
@@ -235,8 +236,8 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN FAR void *watchdog_register(FAR const char *path,
|
FAR void *watchdog_register(FAR const char *path,
|
||||||
FAR struct watchdog_lowerhalf_s *lower);
|
FAR struct watchdog_lowerhalf_s *lower);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: watchdog_unregister
|
* Name: watchdog_unregister
|
||||||
@@ -253,7 +254,7 @@ EXTERN FAR void *watchdog_register(FAR const char *path,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN void watchdog_unregister(FAR void *handle);
|
void watchdog_unregister(FAR void *handle);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Platform-Independent "Lower-Half" Watchdog Driver Interfaces
|
* Platform-Independent "Lower-Half" Watchdog Driver Interfaces
|
||||||
@@ -282,7 +283,7 @@ EXTERN void watchdog_unregister(FAR void *handle);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN int up_wdginitialize(void);
|
int up_wdginitialize(void);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user