Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Frequency Meter (FREQM)

See Quickstart guide for SAM FREQM driver.

Driver for the Frequency Meter. This driver provides access to the main features of the FREQM controller.

Modules

 
 Quick Start Guide(s)
 In this section you can find a list of all Quick Start guides related to the Frequency Meter (FREQM).
 

Data Structures

struct  freqm_config
 Frequency Meter configuration structure. More...
 
struct  freqm_dev_inst
 Frequency Meter driver software instance structure. More...
 

Macros

#define FREQM_DURATION_DEFAULT   128
 The default duration value of a measurement, given in number of reference clock cycles. More...
 
#define FREQM_NUM_OF_ATTEMPTS   1000000
 Time out value (number of attempts) More...
 

Typedefs

typedef void(* freqm_callback_t )(void)
 
typedef enum freqm_interrupt_source freqm_interrupt_source_t
 FREQM interrupt source type. More...
 

Enumerations

enum  freqm_interrupt_source {
  FREQM_INTERRUPT_MEASURMENT_READY = FREQM_IER_DONE,
  FREQM_INTERRUPT_REFERENCE_CLOCK_READY = FREQM_IER_RCLKRDY,
  FREQM_INTERRUPT_SOURCE_N
}
 FREQM interrupt source type. More...
 

Functions

static void freqm_clear_interrupt_status (struct freqm_dev_inst *const dev_inst, freqm_interrupt_source_t source)
 Clear FREQM interrupt status. More...
 
enum status_code freqm_disable (struct freqm_dev_inst *const dev_inst)
 Disable FREQM. More...
 
static void freqm_disable_interrupt (struct freqm_dev_inst *const dev_inst, freqm_interrupt_source_t source)
 Disable FREQM interrupt. More...
 
static void freqm_disable_refclk (struct freqm_dev_inst *const dev_inst)
 Disable refclk. More...
 
void freqm_enable (struct freqm_dev_inst *const dev_inst)
 Enable FEQM. More...
 
static void freqm_enable_interrupt (struct freqm_dev_inst *const dev_inst, freqm_interrupt_source_t source)
 Enable FREQM interrupt. More...
 
static void freqm_enable_refclk (struct freqm_dev_inst *const dev_inst)
 Enable refclk. More...
 
void freqm_get_config_defaults (struct freqm_config *const cfg)
 Initializes Frequency Meter configuration structure to defaults. More...
 
static uint32_t freqm_get_interrupt_mask (struct freqm_dev_inst *const dev_inst)
 Get FREQM interrupt mask. More...
 
static uint32_t freqm_get_interrupt_status (struct freqm_dev_inst *const dev_inst)
 Get FREQM interrupt status. More...
 
enum status_code freqm_get_result_blocking (struct freqm_dev_inst *const dev_inst, uint32_t *p_result)
 Get measurement result. More...
 
static uint32_t freqm_get_result_value (struct freqm_dev_inst *const dev_inst)
 Get FREQM result value. More...
 
static uint32_t freqm_get_status (struct freqm_dev_inst *const dev_inst)
 Get FREQM status. More...
 
enum status_code freqm_init (struct freqm_dev_inst *const dev_inst, Freqm *const freqm, struct freqm_config *const cfg)
 Configure FREQM with specified value. More...
 
void freqm_set_callback (struct freqm_dev_inst *const dev_inst, freqm_interrupt_source_t source, freqm_callback_t callback, uint8_t irq_level)
 Set callback for FREQM interrupt handler. More...
 
static void freqm_start_measure (struct freqm_dev_inst *const dev_inst)
 Start a measurement. More...
 

#define FREQM_DURATION_DEFAULT   128

The default duration value of a measurement, given in number of reference clock cycles.

Referenced by freqm_get_config_defaults(), and main().

#define FREQM_NUM_OF_ATTEMPTS   1000000

Time out value (number of attempts)

Referenced by freqm_disable(), freqm_get_result_blocking(), and freqm_init().

typedef void(* freqm_callback_t)(void)

FREQM interrupt source type.

FREQM interrupt source type.

Enumerator
FREQM_INTERRUPT_MEASURMENT_READY 
FREQM_INTERRUPT_REFERENCE_CLOCK_READY 
FREQM_INTERRUPT_SOURCE_N 

static void freqm_clear_interrupt_status ( struct freqm_dev_inst *const  dev_inst,
freqm_interrupt_source_t  source 
)
inlinestatic

Clear FREQM interrupt status.

Parameters
dev_instDevice structure pointer.
sourceInterrupt source.

References freqm_dev_inst::hw_dev.

enum status_code freqm_disable ( struct freqm_dev_inst *const  dev_inst)

Disable FREQM.

Parameters
dev_instDevice structure pointer.
Returns
Status code

References ERR_TIMEOUT, freqm_get_status(), FREQM_NUM_OF_ATTEMPTS, freqm_dev_inst::hw_dev, SLEEPMGR_SLEEP_1, sleepmgr_unlock_mode(), STATUS_OK, and sysclk_disable_peripheral_clock().

static void freqm_disable_interrupt ( struct freqm_dev_inst *const  dev_inst,
freqm_interrupt_source_t  source 
)
inlinestatic

Disable FREQM interrupt.

Parameters
dev_instDevice structure pointer
sourceInterrupt source

References freqm_dev_inst::hw_dev.

Referenced by set_int_flag().

static void freqm_disable_refclk ( struct freqm_dev_inst *const  dev_inst)
inlinestatic

Disable refclk.

Parameters
dev_instDevice structure pointer

References freqm_dev_inst::hw_dev.

Referenced by freqm_init().

void freqm_enable ( struct freqm_dev_inst *const  dev_inst)

Enable FEQM.

Parameters
dev_instDevice structure pointer.

References freqm_dev_inst::hw_dev, sleepmgr_lock_mode(), SLEEPMGR_SLEEP_1, and sysclk_enable_peripheral_clock().

Referenced by main().

static void freqm_enable_interrupt ( struct freqm_dev_inst *const  dev_inst,
freqm_interrupt_source_t  source 
)
inlinestatic

Enable FREQM interrupt.

Parameters
dev_instDevice structure pointer
sourceInterrupt source

References freqm_dev_inst::hw_dev.

Referenced by freqm_set_callback().

static void freqm_enable_refclk ( struct freqm_dev_inst *const  dev_inst)
inlinestatic

Enable refclk.

Parameters
dev_instDevice structure pointer

References freqm_dev_inst::hw_dev.

Referenced by freqm_init().

void freqm_get_config_defaults ( struct freqm_config *const  cfg)

Initializes Frequency Meter configuration structure to defaults.

Parameters
cfgConfiguration structure to initialize to default values.

References Assert, freqm_config::duration, FREQM_DURATION_DEFAULT, freqm_config::msr_clk, and freqm_config::ref_clk.

Referenced by main(), and run_freqm_test().

static uint32_t freqm_get_interrupt_mask ( struct freqm_dev_inst *const  dev_inst)
inlinestatic

Get FREQM interrupt mask.

Parameters
dev_instDevice structure pointer.
Returns
Interrupt mask value

References freqm_dev_inst::hw_dev.

Referenced by FREQM_Handler().

static uint32_t freqm_get_interrupt_status ( struct freqm_dev_inst *const  dev_inst)
inlinestatic

Get FREQM interrupt status.

Parameters
dev_instDevice structure pointer
Returns
Interrupt status value

References freqm_dev_inst::hw_dev.

Referenced by FREQM_Handler(), and set_int_flag().

enum status_code freqm_get_result_blocking ( struct freqm_dev_inst *const  dev_inst,
uint32_t *  p_result 
)

Get measurement result.

Parameters
dev_instDevice structure pointer.
p_resultPointer to measurement result value.
Returns
Status code

References ERR_TIMEOUT, freqm_get_status(), FREQM_NUM_OF_ATTEMPTS, freqm_dev_inst::hw_dev, and STATUS_OK.

Referenced by main().

static uint32_t freqm_get_result_value ( struct freqm_dev_inst *const  dev_inst)
inlinestatic

Get FREQM result value.

Parameters
dev_instDevice structure pointer
Returns
Measurement result value

References freqm_dev_inst::hw_dev.

static uint32_t freqm_get_status ( struct freqm_dev_inst *const  dev_inst)
inlinestatic

Get FREQM status.

Parameters
dev_instDevice structure pointer
Returns
FREQM status value

References freqm_dev_inst::hw_dev.

Referenced by freqm_disable(), freqm_get_result_blocking(), and freqm_init().

enum status_code freqm_init ( struct freqm_dev_inst *const  dev_inst,
Freqm *const  freqm,
struct freqm_config *const  cfg 
)

Configure FREQM with specified value.

Parameters
dev_instDevice structure pointer.
freqmBase address of the FREQM instance.
cfgPointer to FREQM configuration
Returns
Status code

References Assert, dev_inst, freqm_config::duration, ERR_TIMEOUT, freqm_dev_inst::freqm_cfg, freqm_disable_refclk(), freqm_enable_refclk(), freqm_get_status(), FREQM_NUM_OF_ATTEMPTS, freqm_dev_inst::hw_dev, freqm_config::msr_clk, freqm_config::ref_clk, STATUS_OK, and sysclk_enable_peripheral_clock().

Referenced by main(), and run_freqm_test().

void freqm_set_callback ( struct freqm_dev_inst *const  dev_inst,
freqm_interrupt_source_t  source,
freqm_callback_t  callback,
uint8_t  irq_level 
)

Set callback for FREQM interrupt handler.

Parameters
dev_instDevice structure pointer.
sourceInterrupt source.
callbackcallback function pointer.
irq_levelinterrupt level.

References callback, freqm_enable_interrupt(), and irq_register_handler.

Referenced by run_freqm_test().

static void freqm_start_measure ( struct freqm_dev_inst *const  dev_inst)
inlinestatic

Start a measurement.

Parameters
dev_instDevice structure pointer

References freqm_dev_inst::hw_dev.

Referenced by main(), and run_freqm_test().