Microchip® Advanced Software Framework

rtc_count.c File Reference

SAM RTC Driver (Count Mode)

Copyright (c) 2012-2020 Microchip Technology Inc. and its subsidiaries.

#include "rtc_count.h"
#include <clock.h>
#include <gclk.h>
#include "conf_rtc.h"

Functions

static enum status_code _rtc_count_set_config (struct rtc_module *const module, const struct rtc_count_config *const config)
 
enum status_code rtc_count_clear_compare_match (struct rtc_module *const module, const enum rtc_count_compare comp_index)
 Clears RTC compare match flag. More...
 
void rtc_count_disable (struct rtc_module *const module)
 Disables the RTC module. More...
 
void rtc_count_enable (struct rtc_module *const module)
 Enables the RTC module. More...
 
enum status_code rtc_count_frequency_correction (struct rtc_module *const module, const int8_t value)
 Calibrate for too-slow or too-fast oscillator. More...
 
enum status_code rtc_count_get_compare (struct rtc_module *const module, uint32_t *const comp_value, const enum rtc_count_compare comp_index)
 Get the current compare value of specified compare. More...
 
uint32_t rtc_count_get_count (struct rtc_module *const module)
 Get the current count value. More...
 
enum status_code rtc_count_get_period (struct rtc_module *const module, uint16_t *const period_value)
 Retrieves the value of period. More...
 
enum status_code rtc_count_init (struct rtc_module *const module, Rtc *const hw, const struct rtc_count_config *const config)
 Initializes the RTC module with given configurations. More...
 
bool rtc_count_is_compare_match (struct rtc_module *const module, const enum rtc_count_compare comp_index)
 Check if RTC compare match has occurred. More...
 
static bool rtc_count_is_syncing (struct rtc_module *const module)
 Determines if the hardware module(s) are currently synchronizing to the bus. More...
 
void rtc_count_reset (struct rtc_module *const module)
 Resets the RTC module. More...
 
enum status_code rtc_count_set_compare (struct rtc_module *const module, const uint32_t comp_value, const enum rtc_count_compare comp_index)
 Set the compare value for the specified compare. More...
 
enum status_code rtc_count_set_count (struct rtc_module *const module, const uint32_t count_value)
 Set the current count value to desired value. More...
 
enum status_code rtc_count_set_period (struct rtc_module *const module, const uint16_t period_value)
 Set the given value to the period. More...
 

static enum status_code _rtc_count_set_config ( struct rtc_module *const  module,
const struct rtc_count_config *const  config 
)
static

Applies the given configuration.

Sets the configurations given from the configuration structure to the hardware module

Parameters
[in,out]modulePointer to the software instance struct
[in]configPointer to the configuration structure
Returns
Status of the configuration procedure.
Return values
STATUS_OKRTC configurations was set successfully
STATUS_ERR_INVALID_ARGIf invalid argument(s) were given

References Assert, rtc_count_config::clear_on_match, rtc_count_config::compare_values, rtc_count_config::enable_read_sync, if(), rtc_count_config::mode, rtc_count_config::prescaler, RTC_COUNT_MODE_16BIT, RTC_COUNT_MODE_32BIT, rtc_count_set_compare(), SAMC20, SAMC21, SAML22, STATUS_ERR_INVALID_ARG, and STATUS_OK.

Referenced by rtc_count_init().

static bool rtc_count_is_syncing ( struct rtc_module *const  module)
static

Determines if the hardware module(s) are currently synchronizing to the bus.

Checks to see if the underlying hardware peripheral module(s) are currently synchronizing across multiple clock domains to the hardware bus, This function can be used to delay further operations on a module until such time that it is ready, to prevent blocking delays for synchronization in the user application.

Parameters
[in]moduleRTC hardware module
Returns
Synchronization status of the underlying hardware module(s).
Return values
trueif the module synchronization is ongoing
falseif the module has completed synchronization

References Assert.

Referenced by rtc_count_disable(), rtc_count_enable(), rtc_count_frequency_correction(), rtc_count_get_compare(), rtc_count_get_count(), rtc_count_get_period(), rtc_count_reset(), rtc_count_set_compare(), rtc_count_set_count(), and rtc_count_set_period().