49 #include "adi_processor.h" 52 #include <adi_callback.h> 53 #include <adi_rtc_config.h> 68 #define ADI_RTC_MEMORY_SIZE (24u) 71 #define ADI_RTC_GATEWAY_FLUSH 0xa2c5 77 #define ADI_RTC_IRQ_SOURCE_OFFSET_SR0 (0u) 80 #define ADI_RTC_IRQ_SOURCE_MASK_SR0 (0x7Eu) 83 #define ADI_RTC_IRQ_SOURCE_OFFSET_SR2 (8u) 86 #define ADI_RTC0_IRQ_SOURCE_MASK_SR2 (0x0Fu) 88 #define ADI_RTC1_IRQ_SOURCE_MASK_SR2 (0x1Fu) 91 #define ADI_RTC_IRQ_SOURCE_OFFSET_SR3 (16u) 94 #if defined(__ADUCM302x__) 95 #define ADI_RTC_IRQ_SOURCE_MASK_SR3 (0x031Du) 96 #elif defined(__ADUCM4x50__) 97 #define ADI_RTC_IRQ_SOURCE_MASK_SR3 (0x1FFDu) 136 #define ADI_RTC_ALARM_INT 0x00000001u 137 #define ADI_RTC_MOD60ALM_INT 0x00000002u 138 #define ADI_RTC_ISO_DONE_INT 0x00000004u 139 #define ADI_RTC_WRITE_PENDERR_INT 0x00000008u 140 #define ADI_RTC_WRITE_SYNC_INT 0x00000010u 141 #define ADI_RTC_WRITE_PEND_INT 0x00000020u 142 #define ADI_RTC_COUNT_INT 0x00000040u 143 #define ADI_RTC_PSI_INT 0x00000080u 144 #define ADI_RTC_TRIM_INT 0x00000100u 145 #define ADI_RTC_COUNT_ROLLOVER_INT 0x00000200u 146 #define ADI_RTC_MOD60_ROLLOVER_INT 0x00000400u 147 #define ADI_RTC_SENSOR_STROBE_CH1_INT 0x00000800u 148 #define ADI_RTC_INPUT_CAPTURE_CH0_INT 0x00008000u 149 #define ADI_RTC_INPUT_CAPTURE_CH2_INT 0x00010000u 150 #define ADI_RTC_INPUT_CAPTURE_CH3_INT 0x00020000u 151 #define ADI_RTC_INPUT_CAPTURE_CH4_INT 0x00040000u 152 #define ADI_RTC_LFXTL_FAILURE_INT 0x00080000u 153 #define ADI_RTC_RTCSS1MSKEN 0x08000000u 155 #if defined(__ADUCM4x50__) 156 #define ADI_RTC_RTCSS4_FE_INT 0x00100000u 157 #define ADI_RTC_RTCSS3_FE_INT 0x00200000u 158 #define ADI_RTC_RTCSS2_FE_INT 0x00400000u 159 #define ADI_RTC_RTCSS1_FE_INT 0x00800000u 160 #define ADI_RTC_RTCSS4MSKEN 0x01000000u 161 #define ADI_RTC_RTCSS3MSKEN 0x02000000u 162 #define ADI_RTC_RTCSS2MSKEN 0x04000000u 163 #define ADI_RTC_CR5OCS_SS3SMPMTCHIRQEN 0x10000000u 164 #define ADI_RTC_CR5OCS_SS2SMPMTCHIRQEN 0x20000000u 165 #define ADI_RTC_CR5OCS_SS1SMPMTCHIRQEN 0x40000000u 166 #define ADI_RTC_SENSOR_STROBE_CH2_INT 0x00001000u 167 #define ADI_RTC_SENSOR_STROBE_CH3_INT 0x00002000u 168 #define ADI_RTC_SENSOR_STROBE_CH4_INT 0x00004000u 171 #if defined(__ADUCM4x50__) 172 #define ADI_RTC_NUM_INTERRUPTS 31 174 #define ADI_RTC_NUM_INTERRUPTS 18 263 #if defined(__ADUCM4x50__) 265 ADI_RTC_SS_CHANNEL_2 = 1 << BITP_RTC_CR3SS_SS2EN,
267 ADI_RTC_SS_CHANNEL_3 = 1 << BITP_RTC_CR3SS_SS3EN,
269 ADI_RTC_SS_CHANNEL_4 = 1 << BITP_RTC_CR3SS_SS4EN,
327 uint32_t DeviceNumber,
330 ADI_RTC_HANDLE *phDevice
334 ADI_RTC_HANDLE
const hDevice
342 ADI_RTC_HANDLE
const hDevice,
347 ADI_RTC_HANDLE
const hDevice,
352 ADI_RTC_HANDLE
const hDevice,
357 ADI_RTC_HANDLE
const hDevice,
358 ADI_RTC_INT_TYPE Interrupts,
363 ADI_RTC_HANDLE
const hDevice,
368 ADI_RTC_HANDLE
const hDevice,
369 ADI_RTC_SS_CHANNEL eSSChannel,
373 ADI_RTC_HANDLE
const hDevice,
374 ADI_RTC_SS_CHANNEL eSSChannel,
378 ADI_RTC_HANDLE
const hDevice,
379 ADI_RTC_INPUT_CHANNEL eInpChannel,
383 ADI_RTC_HANDLE
const hDevice,
384 ADI_RTC_SS_CHANNEL eSSChannel,
388 ADI_RTC_HANDLE
const hDevice,
397 ADI_RTC_HANDLE
const hDevice,
402 ADI_RTC_HANDLE
const hDevice,
407 (ADI_RTC_HANDLE
const hDevice,
413 ADI_RTC_HANDLE
const hDevice,
418 (ADI_RTC_HANDLE
const hDevice,
424 ADI_RTC_HANDLE
const hDevice
428 ADI_RTC_HANDLE
const hDevice,
434 ADI_RTC_HANDLE
const hDevice,
435 ADI_RTC_CONTROL_REGISTER eRegister,
440 ADI_RTC_HANDLE
const hDevice,
445 ADI_RTC_HANDLE
const hDevice,
451 ADI_RTC_HANDLE
const hDevice,
456 ADI_RTC_HANDLE
const hDevice,
463 ADI_RTC_HANDLE
const hDevice,
464 ADI_RTC_SS_CHANNEL eSSChannel,
467 #if defined(__ADUCM302x__) 469 ADI_RTC_HANDLE
const hDevice,
470 ADI_RTC_SS_CHANNEL eSSChannel,
472 #elif defined (__ADUCM4x50__) 474 ADI_RTC_HANDLE
const hDevice,
475 ADI_RTC_SS_CHANNEL eSSChannel,
477 uint16_t nHighValue);
479 #error "RTC driver not ported to this proccessor" 484 ADI_RTC_HANDLE
const hDevice,
485 ADI_RTC_INPUT_CHANNEL eInpChannel,
489 ADI_RTC_HANDLE
const hDevice,
490 ADI_RTC_SS_CHANNEL eSSChannel,
498 ADI_RTC_HANDLE hDevice,
503 ADI_RTC_HANDLE hDevice,
507 ADI_RTC_HANDLE hDevice,
514 ADI_RTC_HANDLE hDevice,
515 ADI_RTC_CONTROL_REGISTER eRegister ,
519 ADI_RTC_HANDLE hDevice,
524 ADI_RTC_HANDLE
const hDevice,
529 ADI_RTC_HANDLE
const hDevice,
534 ADI_RTC_HANDLE
const hDevice,
535 ADI_RTC_INPUT_CHANNEL eChannel,
537 uint16_t *pFraction);
540 ADI_RTC_HANDLE
const hDevice,
541 ADI_RTC_INPUT_CHANNEL eChannel,
542 uint16_t *pSnap0, uint16_t * pSnap1,
546 ADI_RTC_HANDLE
const hDevice,
547 ADI_RTC_INPUT_CHANNEL eChannel,
551 ADI_RTC_HANDLE
const hDevice,
552 ADI_RTC_WRITE_STATUS *pPendBits
556 ADI_RTC_HANDLE
const hDevice,
557 ADI_RTC_WRITE_STATUS *pSyncBits
561 ADI_RTC_HANDLE
const hDevice,
562 ADI_RTC_SS_CHANNEL eSSChannel,
566 ADI_RTC_HANDLE
const hDevice,
575 ADI_RTC_HANDLE
const hDevice,
576 ADI_RTC_INT_TYPE *pStatus);
579 ADI_RTC_HANDLE
const hDevice,
580 ADI_RTC_INT_TYPE Status);
583 ADI_RTC_HANDLE
const hDevice
587 ADI_RTC_HANDLE
const hDevice,
588 ADI_CALLBACK
const pfCallback,
ADI_RTC_RESULT adi_rtc_ClearInterruptStatus(ADI_RTC_HANDLE const hDevice, ADI_RTC_INT_TYPE Status)
Clear an RTC interrupt status bit(s).
ADI_RTC_RESULT adi_rtc_GetInputCaptureValueEx(ADI_RTC_HANDLE const hDevice, ADI_RTC_INPUT_CHANNEL eChannel, uint16_t *pSnap0, uint16_t *pSnap1, uint16_t *pSnap2)
Get input capture value for specified input channel.
ADI_RTC_RESULT adi_rtc_SetAutoReloadValue(ADI_RTC_HANDLE const hDevice, ADI_RTC_SS_CHANNEL eSSChannel, uint16_t nValue)
Set auto reload value for the given Sensor Strobe channel.
ADI_RTC_RESULT adi_rtc_GetCount(ADI_RTC_HANDLE const hDevice, uint32_t *pCount)
Get current RTC count value.
ADI_RTC_RESULT adi_rtc_SetSensorStrobeValue(ADI_RTC_HANDLE const hDevice, ADI_RTC_SS_CHANNEL eSSChannel, uint16_t nValue)
Set Sensor Strobe value for the given Sensor Strobe channel.
ADI_RTC_RESULT adi_rtc_SetGateway(ADI_RTC_HANDLE const hDevice, uint16_t Command)
Set an RTC gateway command.
ADI_RTC_RESULT adi_rtc_Close(ADI_RTC_HANDLE const hDevice)
Uninitialize and deallocate an RTC device.
ADI_RTC_RESULT adi_rtc_SetAlarm(ADI_RTC_HANDLE const hDevice, uint32_t nAlarm)
Set a new RTC alarm value.
ADI_RTC_RESULT adi_rtc_GetTrim(ADI_RTC_HANDLE hDevice, ADI_RTC_TRIM_VALUE *peTrim)
Get current RTC clock trim value.
uint32_t ADI_RTC_INT_TYPE
ADI_RTC_RESULT adi_rtc_GetInterruptStatus(ADI_RTC_HANDLE const hDevice, ADI_RTC_INT_TYPE *pStatus)
Get current RTC interrupt source status.
ADI_RTC_RESULT adi_rtc_SetAlarmRegsAsync(ADI_RTC_HANDLE const hDevice, uint16_t nAlarm0, uint16_t nAlarm1, uint16_t nAlarm2)
Set a new RTC alarm value for RTC ALM0, ALM1 and ALM2 Registers without waiting for synchronization...
ADI_RTC_RESULT adi_rtc_SynchronizeAllWrites(ADI_RTC_HANDLE const hDevice)
Force synchronization of all pending writes.
ADI_RTC_RESULT adi_rtc_GetInputCaptureValue(ADI_RTC_HANDLE const hDevice, ADI_RTC_INPUT_CHANNEL eChannel, uint16_t *pValue)
Get input capture value for specified input channel.
ADI_RTC_RESULT adi_rtc_GetSensorStrobeValue(ADI_RTC_HANDLE const hDevice, ADI_RTC_SS_CHANNEL eSSChannel, uint16_t *pValue)
Get Sensor Strobe value for the given Sensor Strobe channel.
ADI_RTC_RESULT adi_rtc_GetCountRegs(ADI_RTC_HANDLE const hDevice, uint32_t *pnCount, uint32_t *pfCount)
Get current RTC count value of all registers.
ADI_RTC_RESULT adi_rtc_GetWriteSyncStatus(ADI_RTC_HANDLE const hDevice, ADI_RTC_WRITE_STATUS *pSyncBits)
Get current RTC posted write synchronization status.
ADI_RTC_RESULT adi_rtc_SyncAlarm(ADI_RTC_HANDLE const hDevice)
Sync after writing RTC alarm registers.
ADI_RTC_RESULT adi_rtc_SetTrim(ADI_RTC_HANDLE const hDevice, ADI_RTC_TRIM_INTERVAL eInterval, ADI_RTC_TRIM_VALUE eTrimValue, ADI_RTC_TRIM_POLARITY eOperation)
Set a new RTC trim value.
ADI_RTC_RESULT adi_rtc_GetCountEx(ADI_RTC_HANDLE const hDevice, float *pfCount)
Get current RTC count value with fraction.
ADI_RTC_RESULT adi_rtc_Open(uint32_t DeviceNumber, void *pDeviceMemory, uint32_t MemorySize, ADI_RTC_HANDLE *phDevice)
RTC Initialization.
ADI_RTC_RESULT adi_rtc_SetPreScale(ADI_RTC_HANDLE const hDevice, uint8_t nPreScale)
Set Prescale. This is power of 2 division factor for the RTC base clock.
ADI_RTC_RESULT adi_rtc_EnableMod60Alarm(ADI_RTC_HANDLE const hDevice, bool bEnable)
Enable MOD60 RTC alarm.
ADI_RTC_RESULT adi_rtc_GetAlarmEx(ADI_RTC_HANDLE hDevice, float *pAlarm)
Get current RTC alarm value with fractional part also.
ADI_RTC_RESULT adi_rtc_EnableTrim(ADI_RTC_HANDLE const hDevice, bool bEnable)
Enable RTC automatic clock trimming.
ADI_RTC_RESULT adi_rtc_GetAlarmRegs(ADI_RTC_HANDLE hDevice, uint16_t *pAlarm0, uint16_t *pAlarm1, uint16_t *pAlarm2)
Get current RTC alarm value from RTC Alarm register.
ADI_RTC_RESULT adi_rtc_RegisterCallback(ADI_RTC_HANDLE const hDevice, ADI_CALLBACK const pfCallback, void *const pCBparam)
Registers a Callback function with the RTC device driver. The registered call back function will be c...
ADI_RTC_RESULT adi_rtc_SetInputCapturePolarity(ADI_RTC_HANDLE const hDevice, ADI_RTC_INPUT_CHANNEL eInpChannel, bool bEnable)
Set input capture polarity for the specified channel.
ADI_RTC_RESULT adi_rtc_SetAlarmAsync(ADI_RTC_HANDLE const hDevice, uint32_t nAlarm)
Set a new RTC alarm value without waiting for synchronization.
ADI_RTC_RESULT adi_rtc_GetControl(ADI_RTC_HANDLE hDevice, ADI_RTC_CONTROL_REGISTER eRegister, uint32_t *pControl)
Get current RTC control register value.
ADI_RTC_RESULT adi_rtc_EnableInputCapture(ADI_RTC_HANDLE const hDevice, ADI_RTC_INPUT_CHANNEL eInpChannel, bool bEnable)
Enable input capture for the specified channel.
ADI_RTC_RESULT adi_rtc_SetAlarmEx(ADI_RTC_HANDLE const hDevice, float fAlarm)
Set a new RTC alarm value with fractional value.
ADI_RTC_RESULT adi_rtc_Enable(ADI_RTC_HANDLE const hDevice, bool bEnable)
Enable RTC device.
ADI_RTC_RESULT adi_rtc_EnableAlarm(ADI_RTC_HANDLE const hDevice, bool bEnable)
Enable RTC alarm.
ADI_RTC_RESULT adi_rtc_SetSensorStrobeChannelMask(ADI_RTC_HANDLE const hDevice, ADI_RTC_SS_CHANNEL eSSChannel, uint8_t nMask)
To set channel mask for the given Sensor Strobe channel.
ADI_RTC_RESULT adi_rtc_SetControlRegister(ADI_RTC_HANDLE const hDevice, ADI_RTC_CONTROL_REGISTER eRegister, uint32_t Control)
Set a new RTC control register value.
ADI_RTC_RESULT adi_rtc_GetSnapShot(ADI_RTC_HANDLE const hDevice, ADI_RTC_INPUT_CHANNEL eChannel, uint32_t *pValue, uint16_t *pFraction)
Read RTC snapshot registers values.
ADI_RTC_RESULT adi_rtc_EnableSensorStrobeOutput(ADI_RTC_HANDLE const hDevice, ADI_RTC_SS_CHANNEL eSSChannel, bool bEnable)
Enable output for the specified Sensor Strobe Channel.
ADI_RTC_RESULT adi_rtc_EnableAutoReload(ADI_RTC_HANDLE const hDevice, ADI_RTC_SS_CHANNEL eSSChannel, bool bEnable)
Enable auto reload for given Sensor Strobe Channel.
ADI_RTC_RESULT adi_rtc_GetAlarm(ADI_RTC_HANDLE hDevice, uint32_t *pAlarm)
Get current RTC alarm value.
ADI_RTC_RESULT adi_rtc_EnableSensorStrobeChannelMask(ADI_RTC_HANDLE const hDevice, ADI_RTC_SS_CHANNEL eSSChannel, bool bEnable)
Enable or disable thermometer-code masking for the given Sensor Strobe Channel.
ADI_RTC_RESULT adi_rtc_GetWritePendStatus(ADI_RTC_HANDLE const hDevice, ADI_RTC_WRITE_STATUS *pPendBits)
Get current RTC posted write pending status.
ADI_RTC_RESULT adi_rtc_SetCount(ADI_RTC_HANDLE const hDevice, uint32_t nCount)
Set a new RTC count value.
ADI_RTC_RESULT adi_rtc_SetMod60AlarmPeriod(ADI_RTC_HANDLE const hDevice, uint8_t nPeriod)
Set the pre-scale. This is power of 2 division factor for the RTC base clock.
ADI_RTC_RESULT adi_rtc_SetAlarmRegs(ADI_RTC_HANDLE const hDevice, uint16_t nAlarm0, uint16_t nAlarm1, uint16_t nAlarm2)
Set a new RTC alarm value for RTC ALM0,ALM1 and ALM2 Register.
ADI_RTC_RESULT adi_rtc_EnableInterrupts(ADI_RTC_HANDLE const hDevice, ADI_RTC_INT_TYPE Interrupts, bool bEnable)
Manage interrupt enable/disable in the RTC and NVIC controller.
ADI_RTC_RESULT adi_rtc_EnableOverwriteSnapshot(ADI_RTC_HANDLE const hDevice, bool bEnable)
Enable Overwrite of Unread Snapshots for all RTC Input Capture Channels.