Instances of this class handle an interface to the frequency-adjustable HW clock core, based upon Appendix G of RFC-1305 (NTP). More...
#include <core/DspClk1305G.h>
Classes | |
struct | alarm_queue |
Structure for alarm queue. More... | |
Public Types | |
typedef void(* | tfAlarmCallback )(unsigned int, void *) |
prototype for the alarm callbacks. | |
Public Member Functions | |
tcDspClk1305G (void *apAddress) | |
This constructor is used to open a tcDspClk1305G interface. | |
virtual | ~tcDspClk1305G () |
This destructor is used to close up and free the resources tied to the associated RTC-1305G clock interface. | |
bool | getTime (unsigned int &arSecs, unsigned int &arNanoSecs) |
Returns the seconds and nanoseconds fields from the RTC-1305 clock. | |
bool | setTime (unsigned int anSecs, unsigned int anNanoSecs) |
Sets the current seconds and nanoseconds fields of the RTC-1305 clock. | |
int | adjFreq (int anPPB) |
Adjusts the clock frequency by the given parts-per-billion. | |
int | getFreq (void) |
Returns the total clock frequency adjustment in parts-per-billion. | |
int | setFreq (int anPPB) |
Sets the total clock frequency adjustment in parts-per-billion. | |
unsigned int | setAlarm (unsigned int anSecs, unsigned int anNanoSecs, tfAlarmCallback afCallback, void *apUserData) |
Schedules an alarm at the provided time. | |
bool | cancelAlarm (unsigned int ahAlarmId) |
Removes a pending alarm from the queue. | |
Public Attributes | |
unsigned int | mnInterruptCount |
ISR counter (debug). | |
Static Public Attributes | |
static const int | gnMaxAdjPPB = 10000000 |
maximum frequency adjustment, in parts-per-billion | |
Protected Types | |
typedef struct MityDSP::tcDspClk1305G::alarm_queue | tsAlarmQueue |
Structure for alarm queue. | |
Protected Member Functions | |
void | alarmInterrupt (void) |
Interrupt service routine for alarm interrupts. | |
void | scheduleAlarm (void) |
Internal method used to schedule the next alarm in the queue. | |
Static Protected Member Functions | |
static int | interrupt_dispatch (Arg arMyObject) |
Static interrupt dispatch routine. | |
Protected Attributes | |
volatile unsigned int * | mpBaseAddr |
LCK_Handle | mhMutex |
mutex to serialize access | |
unsigned int | mnNominalSwallow |
the "nominal swallow count" | |
int | mnPPB |
accumulated parts-per-billion adjustment | |
volatile tsAlarmQueue * | mpAlarmQueue |
queue of pending alarms | |
unsigned short | mnMyIntMask |
core interrupt mask | |
int | mnMyIntLevel |
core interrupt level | |
int | mnMyIntVector |
core interrupt vector | |
Static Protected Attributes | |
static const int | gnMaxPD = 1048575 |
max prescaler divider | |
static const int | gnMinPPB = 954 |
minimum possible PPB adjustment | |
static const unsigned int | gnCLK_LSB = 200 |
LSB of nanoseconds field. |
Instances of this class handle an interface to the frequency-adjustable HW clock core, based upon Appendix G of RFC-1305 (NTP).
typedef void(* MityDSP::tcDspClk1305G::tfAlarmCallback)(unsigned int, void *) |
prototype for the alarm callbacks.
typedef struct MityDSP::tcDspClk1305G::alarm_queue MityDSP::tcDspClk1305G::tsAlarmQueue [protected] |
Structure for alarm queue.
tcDspClk1305G::tcDspClk1305G | ( | void * | apAddress | ) |
This constructor is used to open a tcDspClk1305G interface.
The clock is initialized to time zero, and is immediately available for use.
[in] | apAddress | Base Address of ADC core. |
tcDspClk1305G::~tcDspClk1305G | ( | ) | [virtual] |
This destructor is used to close up and free the resources tied to the associated RTC-1305G clock interface.
bool tcDspClk1305G::getTime | ( | unsigned int & | arSecs, | |
unsigned int & | arNanoSecs | |||
) |
Returns the seconds and nanoseconds fields from the RTC-1305 clock.
The fields are latched so there's no rollover concerns to be addressed.
[out] | arSecs | Reference to the seconds field to fill. |
[out] | arNanoSecs | Reference to the nsec field to fill. |
bool tcDspClk1305G::setTime | ( | unsigned int | anSecs, | |
unsigned int | anNanoSecs | |||
) |
Sets the current seconds and nanoseconds fields of the RTC-1305 clock.
[in] | anSecs | Seconds value to set. |
[in] | anNanoSecs | Nanoseconds value to set. |
int tcDspClk1305G::adjFreq | ( | int | anPPB | ) |
Adjusts the clock frequency by the given parts-per-billion.
[in] | anPPB | Adjustment to the current parts-per-billion setting. |
int tcDspClk1305G::getFreq | ( | void | ) |
Returns the total clock frequency adjustment in parts-per-billion.
int tcDspClk1305G::setFreq | ( | int | anPPB | ) |
Sets the total clock frequency adjustment in parts-per-billion.
[in] | anPPB | Absolute parts-per-billion setting. |
unsigned int tcDspClk1305G::setAlarm | ( | unsigned int | anSecs, | |
unsigned int | anNanoSecs, | |||
tfAlarmCallback | afCallback, | |||
void * | apUserData | |||
) |
Schedules an alarm at the provided time.
Alarm will trigger immediately if time is past. If other alarms are pending, the new alarm will be added to a queue of alarms at the appropriate point.
[in] | anSecs | Seconds alarm value to set. |
[in] | anNanoSecs | Nanoseconds alarm value to set. |
[in] | afCallback | The function to call when the alarm occurs. |
[in] | apUserData | An argument to be supplied with the callback. |
bool tcDspClk1305G::cancelAlarm | ( | unsigned int | ahAlarmId | ) |
Removes a pending alarm from the queue.
[in] | ahAlarmId | Handle of alarm to remove (returned by setAlarm) |
int tcDspClk1305G::interrupt_dispatch | ( | Arg | ahMyObject | ) | [static, protected] |
Static interrupt dispatch routine.
Required because of the hidden this pointer associated with a member function, which cannot be passed directly to the interrupt dispatcher.
[in] | ahMyObject | The "this->" pointer for the instance of tcDspClk1305G associated with this ISR. |
void tcDspClk1305G::alarmInterrupt | ( | void | ) | [protected] |
Interrupt service routine for alarm interrupts.
The ISR reads and disables any pending interrupts. The callback associated with the alarm is activated. The next alarm in the queue (if any) is then scheduled.
"Interrupt-ness" is taken care of by the 'dispatcher' in DSP/BIOS. Installed by the constructor.
void tcDspClk1305G::scheduleAlarm | ( | void | ) | [protected] |
Internal method used to schedule the next alarm in the queue.
If there is no alarm pending, alarms are left disabled.
const int MityDSP::tcDspClk1305G::gnMaxAdjPPB = 10000000 [static] |
maximum frequency adjustment, in parts-per-billion
unsigned int MityDSP::tcDspClk1305G::mnInterruptCount |
ISR counter (debug).
const int MityDSP::tcDspClk1305G::gnMaxPD = 1048575 [static, protected] |
max prescaler divider
const int MityDSP::tcDspClk1305G::gnMinPPB = 954 [static, protected] |
minimum possible PPB adjustment
const unsigned int MityDSP::tcDspClk1305G::gnCLK_LSB = 200 [static, protected] |
LSB of nanoseconds field.
volatile unsigned int* MityDSP::tcDspClk1305G::mpBaseAddr [protected] |
LCK_Handle MityDSP::tcDspClk1305G::mhMutex [protected] |
mutex to serialize access
unsigned int MityDSP::tcDspClk1305G::mnNominalSwallow [protected] |
the "nominal swallow count"
int MityDSP::tcDspClk1305G::mnPPB [protected] |
accumulated parts-per-billion adjustment
volatile tsAlarmQueue* MityDSP::tcDspClk1305G::mpAlarmQueue [protected] |
queue of pending alarms
unsigned short MityDSP::tcDspClk1305G::mnMyIntMask [protected] |
core interrupt mask
int MityDSP::tcDspClk1305G::mnMyIntLevel [protected] |
core interrupt level
int MityDSP::tcDspClk1305G::mnMyIntVector [protected] |
core interrupt vector