Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ static void event_timer()

tmrConfig.nLoad = cnt;
tmrConfig.nAsyncLoad = cnt;
adi_tmr_ConfigTimer(ADI_TMR_DEVICE_GP2, tmrConfig);
adi_tmr_ConfigTimer(ADI_TMR_DEVICE_GP2, &tmrConfig);
adi_tmr_Enable(ADI_TMR_DEVICE_GP2, true);
} else {
tmrConfig.nLoad = 65535u;
tmrConfig.nAsyncLoad = 65535u;
adi_tmr_ConfigTimer(ADI_TMR_DEVICE_GP2, tmrConfig);
adi_tmr_ConfigTimer(ADI_TMR_DEVICE_GP2, &tmrConfig);
adi_tmr_Enable(ADI_TMR_DEVICE_GP2, true);
}
}
Expand Down Expand Up @@ -274,13 +274,13 @@ void us_ticker_init(void)
tmrConfig.nAsyncLoad = 0;
tmrConfig.bReloading = false;
tmrConfig.bSyncBypass = true; // Allow x1 prescale: requires PCLK as a clk
adi_tmr_ConfigTimer(ADI_TMR_DEVICE_GP0, tmrConfig);
adi_tmr_ConfigTimer(ADI_TMR_DEVICE_GP0, &tmrConfig);

/* Configure GP1 to have a period 256 times longer than GP0 */
tmrConfig.nLoad = 0;
tmrConfig.nAsyncLoad = 0;
tmrConfig.ePrescaler = ADI_TMR_PRESCALER_256; // TMR1 = 26MHz/256
adi_tmr_ConfigTimer(ADI_TMR_DEVICE_GP1, tmrConfig);
adi_tmr_ConfigTimer(ADI_TMR_DEVICE_GP1, &tmrConfig);

/* Configure GP2 for doing event counts */
tmrConfig.bCountingUp = true;
Expand All @@ -291,7 +291,7 @@ void us_ticker_init(void)
tmrConfig.nAsyncLoad = 0;
tmrConfig.bReloading = false;
tmrConfig.bSyncBypass = true; // Allow x1 prescale
adi_tmr_ConfigTimer(ADI_TMR_DEVICE_GP2, tmrConfig);
adi_tmr_ConfigTimer(ADI_TMR_DEVICE_GP2, &tmrConfig);


/*------------------------- GP TIMER ENABLE ------------------------------*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file adi_tmr_config.h
* @brief GP and RGB timer device driver configuration
-----------------------------------------------------------------------------
Copyright (c) 2016 Analog Devices, Inc.
Copyright (c) 2016-2018 Analog Devices, Inc.

All rights reserved.

Expand Down Expand Up @@ -169,7 +169,13 @@ POSSIBILITY OF SUCH DAMAGE.
a value of 0 - 39. Please refer hardware reference manual to know
which events can be captured by a particular GP timer.
*/
#if defined(__ADUCM3029__)
#define TMR0_CFG_EVENT_CAPTURE (9u)
#elif defined(__ADUCM4050__)
#define TMR0_CFG_EVENT_CAPTURE (27u)
#else
#error TMR is not ported for this processor
#endif

/*************************************************************
GP Timer 0 PWM0 Configuration
Expand Down Expand Up @@ -295,8 +301,13 @@ POSSIBILITY OF SUCH DAMAGE.
a value of 0 - 39. Please refer hardware reference manual to know
which events can be captured by a particular GP timer.
*/
#if defined(__ADUCM3029__)
#define TMR1_CFG_EVENT_CAPTURE (15u)
#elif defined(__ADUCM4050__)
#define TMR1_CFG_EVENT_CAPTURE (28u)

#else
#error TMR is not ported for this processor
#endif
/*************************************************************
GP Timer 1 PWM0 Configuration
*************************************************************/
Expand Down Expand Up @@ -419,8 +430,13 @@ POSSIBILITY OF SUCH DAMAGE.
a value of 0 - 39. Please refer hardware reference manual to know
which events can be captured by a particular GP timer.
*/
#if defined(__ADUCM3029__)
#define TMR2_CFG_EVENT_CAPTURE (6u)
#elif defined(__ADUCM4050__)
#define TMR2_CFG_EVENT_CAPTURE (27u)

#else
#error TMR is not ported for this processor
#endif
/*************************************************************
GP Timer 2 PWM0 Configuration
*************************************************************/
Expand Down Expand Up @@ -451,7 +467,7 @@ POSSIBILITY OF SUCH DAMAGE.

/*! @} */


#if defined(__ADUCM4050__)
/*************************************************************
RGB Timer Configuration
*************************************************************/
Expand Down Expand Up @@ -629,7 +645,7 @@ POSSIBILITY OF SUCH DAMAGE.
the PWM output remains idle. It can be any value from 0 to 65535.
*/
#define TMR3_CFG_PWM2_MATCH_VALUE (0u)

#endif
/*! @} */

/*************************************************************
Expand Down Expand Up @@ -676,9 +692,17 @@ POSSIBILITY OF SUCH DAMAGE.
#error "Invalid configuration"
#endif

#if defined(__ADUCM3029__)
#if TMR0_CFG_EVENT_CAPTURE > 15u
#error "Invalid configuration"
#endif
#elif defined(__ADUCM4050__)
#if TMR0_CFG_EVENT_CAPTURE > 39u
#error "Invalid configuration"
#endif
#else
#error TMR is not ported for this processor
#endif

#if TMR0_CFG_ENABLE_PWM0_MATCH_MODE > 1u
#error "Invalid configuration"
Expand Down Expand Up @@ -736,9 +760,17 @@ POSSIBILITY OF SUCH DAMAGE.
#error "Invalid configuration"
#endif

#if defined(__ADUCM3029__)
#if TMR1_CFG_EVENT_CAPTURE > 15u
#error "Invalid configuration"
#endif
#elif defined(__ADUCM4050__)
#if TMR1_CFG_EVENT_CAPTURE > 39u
#error "Invalid configuration"
#endif
#else
#error TMR is not ported for this processor
#endif

#if TMR1_CFG_ENABLE_PWM0_MATCH_MODE > 1u
#error "Invalid configuration"
Expand Down Expand Up @@ -796,9 +828,17 @@ POSSIBILITY OF SUCH DAMAGE.
#error "Invalid configuration"
#endif

#if defined(__ADUCM3029__)
#if TMR2_CFG_EVENT_CAPTURE > 15u
#error "Invalid configuration"
#endif
#elif defined(__ADUCM4050__)
#if TMR2_CFG_EVENT_CAPTURE > 39u
#error "Invalid configuration"
#endif
#else
#error TMR is not ported for this processor
#endif

#if TMR2_CFG_ENABLE_PWM0_MATCH_MODE > 1u
#error "Invalid configuration"
Expand All @@ -812,6 +852,7 @@ POSSIBILITY OF SUCH DAMAGE.
#error "Invalid configuration"
#endif

#if defined(__ADUCM4050__)
/*************************************************************
RGB Timer Macro Validation
**************************************************************/
Expand Down Expand Up @@ -896,6 +937,7 @@ POSSIBILITY OF SUCH DAMAGE.
#error "Invalid configuration"
#endif

#endif
/*! @} */


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file adi_tmr.h
* @brief GP and RGB timer device driver public header file
-----------------------------------------------------------------------------
Copyright (c) 2016 Analog Devices, Inc.
Copyright (c) 2016-2018 Analog Devices, Inc.

All rights reserved.

Expand Down Expand Up @@ -56,12 +56,16 @@ POSSIBILITY OF SUCH DAMAGE.
* @{
*/

/* C++ linkage */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/*!
*****************************************************************************
* \enum ADI_TMR_RESULT
* Enumeration for result code returned from the timer device driver functions.
* The return value of all timer APIs returning #ADI_TMR_RESULT should always
* The return value of all timer APIs returning #ADI_TMR_RESULT should always
* be tested at the application level for success or failure.
*****************************************************************************/
typedef enum {
Expand Down Expand Up @@ -97,10 +101,17 @@ typedef enum {
ADI_TMR_DEVICE_GP1 = 1u,
/*! General purpose timer 2 */
ADI_TMR_DEVICE_GP2 = 2u,
#if defined(__ADUCM3029__)
/*! Total number of devices (private) */
ADI_TMR_DEVICE_NUM = 3u,
#elif defined(__ADUCM4050__)
/*! RGB timer */
ADI_TMR_DEVICE_RGB = 3u,
/*! Total number of devices (private) */
ADI_TMR_DEVICE_NUM = 4u,
#else
#error TMR is not ported for this processor
#endif
} ADI_TMR_DEVICE;

/*!
Expand All @@ -110,7 +121,7 @@ typedef enum {
*****************************************************************************/
typedef enum {
/*! Timeout event occurred */
ADI_TMR_EVENT_TIMEOUT = 0x01,
ADI_TMR_EVENT_TIMEOUT = 0x01,
/*! Event capture event occurred */
ADI_TMR_EVENT_CAPTURE = 0x02,
} ADI_TMR_EVENT;
Expand All @@ -124,7 +135,7 @@ typedef enum {
/*! Count every 1 source clock periods */
ADI_TMR_PRESCALER_1 = 0u,
/*! Count every 16 source clock periods */
ADI_TMR_PRESCALER_16 = 1u,
ADI_TMR_PRESCALER_16 = 1u,
/*! Count every 64 source clock periods */
ADI_TMR_PRESCALER_64 = 2u,
/*! Count every 256 source clock periods */
Expand All @@ -138,11 +149,11 @@ typedef enum {
*****************************************************************************/
typedef enum {
/*! Use periphreal clock (PCLK) */
ADI_TMR_CLOCK_PCLK = 0u,
ADI_TMR_CLOCK_PCLK = 0u,
/*! Use internal high frequency clock (HFOSC) */
ADI_TMR_CLOCK_HFOSC = 1u,
ADI_TMR_CLOCK_HFOSC = 1u,
/*! Use internal low frequency clock (LFOSC) */
ADI_TMR_CLOCK_LFOSC = 2u,
ADI_TMR_CLOCK_LFOSC = 2u,
/*! Use external low frequency clock (LFXTAL) */
ADI_TMR_CLOCK_LFXTAL = 3u,
} ADI_TMR_CLOCK_SOURCE;
Expand All @@ -151,7 +162,7 @@ typedef enum {
*****************************************************************************
* \enum ADI_TMR_PWM_OUTPUT
* RGB PWM outputs, used to specify which PWM output to configure. For the GP
* timers only #ADI_TMR_PWM_OUTPUT_0 is allowed. The RGB timer has all three
* timers only #ADI_TMR_PWM_OUTPUT_0 is allowed. The RGB timer has all three
* outputs.
*****************************************************************************/
typedef enum {
Expand All @@ -168,7 +179,7 @@ typedef enum {
/*!
*****************************************************************************
* \struct ADI_TMR_CONFIG
* Configuration structure to fill and pass to #adi_tmr_ConfigTimer when
* Configuration structure to fill and pass to #adi_tmr_ConfigTimer when
* configuring the GP or RGB timer
*****************************************************************************/
typedef struct {
Expand All @@ -180,7 +191,7 @@ typedef struct {
ADI_TMR_PRESCALER ePrescaler;
/*! Clock source */
ADI_TMR_CLOCK_SOURCE eClockSource;
/*! Load value (only relent in periodic mode) */
/*! Load value (only relevant in periodic mode) */
uint16_t nLoad;
/*! Asynchronous load value (only relevant in periodic mode, and when PCLK is used) */
uint16_t nAsyncLoad;
Expand All @@ -193,7 +204,7 @@ typedef struct {
/*!
*****************************************************************************
* \struct ADI_TMR_EVENT_CONFIG
* Configuration structure to fill and pass to #adi_tmr_ConfigEvent when
* Configuration structure to fill and pass to #adi_tmr_ConfigEvent when
* configuring event capture
*****************************************************************************/
typedef struct {
Expand All @@ -208,7 +219,7 @@ typedef struct {
/*!
*****************************************************************************
* \struct ADI_TMR_PWM_CONFIG
* Configuration structure to fill and pass to #adi_tmr_ConfigPwm when
* Configuration structure to fill and pass to #adi_tmr_ConfigPwm when
* configuring pulse width modulation output
*****************************************************************************/
typedef struct {
Expand All @@ -232,9 +243,9 @@ typedef struct {
ADI_TMR_RESULT adi_tmr_Init (ADI_TMR_DEVICE const eDevice, ADI_CALLBACK const pfCallback, void * const pCBParam, bool bEnableInt);

/* Configuration interface functions */
ADI_TMR_RESULT adi_tmr_ConfigTimer (ADI_TMR_DEVICE const eDevice, ADI_TMR_CONFIG timerConfig);
ADI_TMR_RESULT adi_tmr_ConfigEvent (ADI_TMR_DEVICE const eDevice, ADI_TMR_EVENT_CONFIG eventConfig);
ADI_TMR_RESULT adi_tmr_ConfigPwm (ADI_TMR_DEVICE const eDevice, ADI_TMR_PWM_CONFIG pwmConfig );
ADI_TMR_RESULT adi_tmr_ConfigTimer (ADI_TMR_DEVICE const eDevice, ADI_TMR_CONFIG* timerConfig);
ADI_TMR_RESULT adi_tmr_ConfigEvent (ADI_TMR_DEVICE const eDevice, ADI_TMR_EVENT_CONFIG* eventConfig);
ADI_TMR_RESULT adi_tmr_ConfigPwm (ADI_TMR_DEVICE const eDevice, ADI_TMR_PWM_CONFIG* pwmConfig );

/* Timer start and stop */
ADI_TMR_RESULT adi_tmr_Enable (ADI_TMR_DEVICE const eDevice, bool bEnable);
Expand All @@ -246,7 +257,9 @@ ADI_TMR_RESULT adi_tmr_GetCaptureCount (ADI_TMR_DEVICE const eDevice, uint16_t *
/* Reload function */
ADI_TMR_RESULT adi_tmr_Reload (ADI_TMR_DEVICE const eDevice);


#ifdef __cplusplus
}
#endif
/*! @} */


Expand Down
Loading