The real-time clock is a configurable, linear, 16-bit real time clock with capture and compare capabilities. The input clock frequency is 32 KHz. This module contains functions for initializing, configuring and controlling the real-time clock.
Enumerations | |
enum | hal_rtc_compare_mode_t { HAL_RTC_COMPARE_MODE_DISABLE = 0x00, HAL_RTC_COMPARE_MODE_1 = 0x02, HAL_RTC_COMPARE_MODE_0 = 0x03 } |
Functions | |
void | hal_rtc_capture (void) |
void | hal_rtc_radio_capture_enable (_Bool en) |
void | hal_rtc_set_compare_mode (hal_rtc_compare_mode_t mode) |
void | hal_rtc_start (_Bool en) |
void | hal_rtc_set_compare_value (uint16_t value) |
uint16_t | hal_rtc_get_compare_value (void) |
uint16_t | hal_rtc_get_capture_value (void) |
uint8_t | hal_rtc_get_capture_clock_cycles (void) |
An enum describing the clock frequency.
HAL_RTC_COMPARE_MODE_DISABLE |
Compare disabled |
HAL_RTC_COMPARE_MODE_1 |
Interrupt will not reset the timer |
HAL_RTC_COMPARE_MODE_0 |
The interrupt resets the timer |
Definition at line 34 of file hal_rtc.h.
{ HAL_RTC_COMPARE_MODE_DISABLE = 0x00, HAL_RTC_COMPARE_MODE_1 = 0x02, HAL_RTC_COMPARE_MODE_0 = 0x03 } hal_rtc_compare_mode_t;
void hal_rtc_capture | ( | void | ) |
void hal_rtc_radio_capture_enable | ( | _Bool | en ) |
Function that enables the timer value to be captured by an IRQ from the Radio
en | True to enable, false to disable capture by radio |
< The value of bit 3
< The value of bit 3
void hal_rtc_set_compare_mode | ( | hal_rtc_compare_mode_t | mode ) |
void hal_rtc_start | ( | _Bool | en ) |
Function that enables RTC2.
en | True to enable, false to disable rtc |
< The value of bit 0
< The value of bit 0
void hal_rtc_set_compare_value | ( | uint16_t | value ) |
Function that sets the value to be compared to the timer value to generate interrupt.
value | Comparing value |
< The value of bit 1
< The value of bit 2
< The value of bit 1
< The value of bit 2
uint16_t hal_rtc_get_compare_value | ( | void | ) |
Function that returns the compare value
< The value of bit 1
< The value of bit 2
< The value of bit 1
< The value of bit 2
Definition at line 66 of file hal_rtc.c.
{ uint8_t compare_status; uint16_t value; // Create temporary output variable compare_status = (RTC2CON & (BIT_1 | BIT_2)); // Save "compareMode" bits RTC2CON &= ~(BIT_1 | BIT_2); // Disable compare value = RTC2CMP1; // Read MSB value <<= 8; // Shift to correct position value |= RTC2CMP0; // Add LSB RTC2CON |= compare_status; // Update compare status return value; // Return compare value }
uint16_t hal_rtc_get_capture_value | ( | void | ) |
Function that returns the timer value.
< The value of bit 3
< The value of bit 3
Definition at line 79 of file hal_rtc.c.
{ uint8_t capture_status; uint16_t value; // Create temporary output variable capture_status = (RTC2CON & BIT_3); // Save "compareMode" bits RTC2CON &= ~BIT_3; // Disable compare value = RTC2CPT01; // Read MSB value <<= 8; // Shift to correct position value |= RTC2CPT00; // Add LSB RTC2CON |= capture_status; // Update external capture status return value; // Return timer value }
uint8_t hal_rtc_get_capture_clock_cycles | ( | void | ) |
Function that returns the value of the counter that counts the number of CPU clock cycles from the previous positive edge of the 32 KHz clock until the capture event.
Definition at line 92 of file hal_rtc.c.
{ return RTC2CPT10; // Return register }