RA Flexible Software Package Documentation  Release v5.1.0

 
CAC Interface

Detailed Description

Interface for clock frequency accuracy measurements.

Summary

The interface for the clock frequency accuracy measurement circuit (CAC) peripheral is used to check a system clock frequency with a reference clock signal by counting the number of pulses of the clock to be measured.

Data Structures

struct  cac_ref_clock_config_t
 
struct  cac_meas_clock_config_t
 
struct  cac_callback_args_t
 
struct  cac_cfg_t
 
struct  cac_api_t
 
struct  cac_instance_t
 

Typedefs

typedef void cac_ctrl_t
 

Enumerations

enum  cac_event_t
 
enum  cac_clock_type_t
 
enum  cac_clock_source_t
 
enum  cac_ref_divider_t
 
enum  cac_ref_digfilter_t
 
enum  cac_ref_edge_t
 
enum  cac_meas_divider_t
 

Data Structure Documentation

◆ cac_ref_clock_config_t

struct cac_ref_clock_config_t

Structure defining the settings that apply to reference clock configuration.

Data Fields
cac_ref_divider_t divider Divider specification for the Reference clock.
cac_clock_source_t clock Clock source for the Reference clock.
cac_ref_digfilter_t digfilter Digital filter selection for the CACREF ext clock.
cac_ref_edge_t edge Edge detection for the Reference clock.

◆ cac_meas_clock_config_t

struct cac_meas_clock_config_t

Structure defining the settings that apply to measurement clock configuration.

Data Fields
cac_meas_divider_t divider Divider specification for the Measurement clock.
cac_clock_source_t clock Clock source for the Measurement clock.

◆ cac_callback_args_t

struct cac_callback_args_t

Callback function parameter data

Data Fields
cac_event_t event The event can be used to identify what caused the callback.
void const * p_context Value provided in configuration structure.

◆ cac_cfg_t

struct cac_cfg_t

CAC Configuration

Data Fields

cac_ref_clock_config_t cac_ref_clock
 Reference clock specific settings.
 
cac_meas_clock_config_t cac_meas_clock
 Measurement clock specific settings.
 
uint16_t cac_upper_limit
 The upper limit counter threshold.
 
uint16_t cac_lower_limit
 The lower limit counter threshold.
 
IRQn_Type mendi_irq
 Measurement End IRQ number.
 
IRQn_Type ovfi_irq
 Measurement Overflow IRQ number.
 
IRQn_Type ferri_irq
 Frequency Error IRQ number.
 
uint8_t mendi_ipl
 Measurement end interrupt priority.
 
uint8_t ovfi_ipl
 Overflow interrupt priority.
 
uint8_t ferri_ipl
 Frequency error interrupt priority.
 
void(* p_callback )(cac_callback_args_t *p_args)
 Callback provided when a CAC interrupt ISR occurs.
 
void const * p_context
 Passed to user callback in cac_callback_args_t.
 
void const * p_extend
 CAC hardware dependent configuration */.
 

◆ cac_api_t

struct cac_api_t

CAC functions implemented at the HAL layer API

Data Fields

fsp_err_t(* open )(cac_ctrl_t *const p_ctrl, cac_cfg_t const *const p_cfg)
 
fsp_err_t(* startMeasurement )(cac_ctrl_t *const p_ctrl)
 
fsp_err_t(* stopMeasurement )(cac_ctrl_t *const p_ctrl)
 
fsp_err_t(* read )(cac_ctrl_t *const p_ctrl, uint32_t *const p_counter)
 
fsp_err_t(* callbackSet )(cac_ctrl_t *const p_ctrl, void(*p_callback)(cac_callback_args_t *), void const *const p_context, cac_callback_args_t *const p_callback_memory)
 
fsp_err_t(* close )(cac_ctrl_t *const p_ctrl)
 

Field Documentation

◆ open

fsp_err_t(* cac_api_t::open) (cac_ctrl_t *const p_ctrl, cac_cfg_t const *const p_cfg)

Open function for CAC device.

Parameters
[out]p_ctrlPointer to CAC device control. Must be declared by user.
[in]cac_cfg_tPointer to CAC configuration structure.

◆ startMeasurement

fsp_err_t(* cac_api_t::startMeasurement) (cac_ctrl_t *const p_ctrl)

Begin a measurement for the CAC peripheral.

Parameters
[in]p_ctrlPointer to CAC device control.

◆ stopMeasurement

fsp_err_t(* cac_api_t::stopMeasurement) (cac_ctrl_t *const p_ctrl)

End a measurement for the CAC peripheral.

Parameters
[in]p_ctrlPointer to CAC device control.

◆ read

fsp_err_t(* cac_api_t::read) (cac_ctrl_t *const p_ctrl, uint32_t *const p_counter)

Read function for CAC peripheral.

Parameters
[in]p_ctrlControl for the CAC device context.
[in]p_counterPointer to variable in which to store the current CACNTBR register contents.

◆ callbackSet

fsp_err_t(* cac_api_t::callbackSet) (cac_ctrl_t *const p_ctrl, void(*p_callback)(cac_callback_args_t *), void const *const p_context, cac_callback_args_t *const p_callback_memory)

Specify callback function and optional context pointer and working memory pointer.

Parameters
[in]p_ctrlControl block set in cac_api_t::open call
[in]p_callbackCallback function to register
[in]p_contextPointer to send to callback function
[in]p_working_memoryPointer to volatile memory where callback structure can be allocated. Callback arguments allocated here are only valid during the callback.

◆ close

fsp_err_t(* cac_api_t::close) (cac_ctrl_t *const p_ctrl)

Close function for CAC device.

Parameters
[in]p_ctrlPointer to CAC device control.

◆ cac_instance_t

struct cac_instance_t

This structure encompasses everything that is needed to use an instance of this interface.

Data Fields
cac_ctrl_t * p_ctrl Pointer to the control structure for this instance.
cac_cfg_t const * p_cfg Pointer to the configuration structure for this instance.
cac_api_t const * p_api Pointer to the API structure for this instance.

Typedef Documentation

◆ cac_ctrl_t

typedef void cac_ctrl_t

CAC control block. Allocate an instance specific control block to pass into the CAC API calls.

Enumeration Type Documentation

◆ cac_event_t

Event types returned by the ISR callback when used in CAC interrupt mode

Enumerator
CAC_EVENT_FREQUENCY_ERROR 

Frequency error.

CAC_EVENT_MEASUREMENT_COMPLETE 

Measurement complete.

CAC_EVENT_COUNTER_OVERFLOW 

Counter overflow.

◆ cac_clock_type_t

Enumeration of the two possible clocks.

Enumerator
CAC_CLOCK_MEASURED 

Measurement clock.

CAC_CLOCK_REFERENCE 

Reference clock.

◆ cac_clock_source_t

Enumeration of the possible clock sources for both the reference and measurement clocks.

Enumerator
CAC_CLOCK_SOURCE_MAIN_OSC 

Main clock oscillator.

CAC_CLOCK_SOURCE_SUBCLOCK 

Sub-clock.

CAC_CLOCK_SOURCE_HOCO 

HOCO (High speed on chip oscillator)

CAC_CLOCK_SOURCE_MOCO 

MOCO (Middle speed on chip oscillator)

CAC_CLOCK_SOURCE_LOCO 

LOCO (Low speed on chip oscillator)

CAC_CLOCK_SOURCE_PCLKB 

PCLKB (Peripheral Clock B)

CAC_CLOCK_SOURCE_IWDT 

IWDT-dedicated on-chip oscillator.

CAC_CLOCK_SOURCE_EXTERNAL 

Externally supplied measurement clock on CACREF pin.

◆ cac_ref_divider_t

Enumeration of available dividers for the reference clock.

Enumerator
CAC_REF_DIV_32 

Reference clock divided by 32.

CAC_REF_DIV_128 

Reference clock divided by 128.

CAC_REF_DIV_1024 

Reference clock divided by 1024.

CAC_REF_DIV_8192 

Reference clock divided by 8192.

◆ cac_ref_digfilter_t

Enumeration of available digital filter settings for an external reference clock.

Enumerator
CAC_REF_DIGITAL_FILTER_OFF 

No digital filter on the CACREF pin for reference clock.

CAC_REF_DIGITAL_FILTER_1 

Sampling clock for digital filter = measuring frequency.

CAC_REF_DIGITAL_FILTER_4 

Sampling clock for digital filter = measuring frequency/4.

CAC_REF_DIGITAL_FILTER_16 

Sampling clock for digital filter = measuring frequency/16.

◆ cac_ref_edge_t

Enumeration of available edge detect settings for the reference clock.

Enumerator
CAC_REF_EDGE_RISE 

Rising edge detect for the Reference clock.

CAC_REF_EDGE_FALL 

Falling edge detect for the Reference clock.

CAC_REF_EDGE_BOTH 

Both Rising and Falling edges detect for the Reference clock.

◆ cac_meas_divider_t

Enumeration of available dividers for the measurement clock

Enumerator
CAC_MEAS_DIV_1 

Measurement clock divided by 1.

CAC_MEAS_DIV_4 

Measurement clock divided by 4.

CAC_MEAS_DIV_8 

Measurement clock divided by 8.

CAC_MEAS_DIV_32 

Measurement clock divided by 32.