I have question in relation to the line rtc_set_alarm(RTC_0, (RTC[RTC_0].rtc_ccvr + ALARM));
in main() below.
In the second argument of rtc_set_alarm() I understand RTC to be a pointer of struct type that points to the address 0xB0000400. It then access the first member of the struct by using .rtc_ccvr.
My question is, why is it necessary to use RTC_0 of the enum rtc_t.
I would of thought that it would be just RTC.rtc_ccvr?
Apologies, I'm new to struct pointers.
** Number of RTC controllers. */
typedef enum { RTC_0 = 0, RTC_NUM } rtc_t;
/** RTC register map. */
typedef struct {
RW uint32_t rtc_ccvr; /**< Current Counter Value Register */
RW uint32_t rtc_cmr; /**< Current Match Register */
RW uint32_t rtc_clr; /**< Counter Load Register */
RW uint32_t rtc_ccr; /**< Counter Control Register */
RW uint32_t rtc_stat; /**< Interrupt Status Register */
RW uint32_t rtc_rstat; /**< Interrupt Raw Status Register */
RW uint32_t rtc_eoi; /**< End of Interrupt Register */
RW uint32_t rtc_comp_version; /**< End of Interrupt Register */
} rtc_reg_t;
/* RTC register base address. */
#define RTC_BASE (0xB0000400)
/* RTC register block. */
#define RTC ((rtc_reg_t *)RTC_BASE)
//--------------------------------------------------------------------------
//function declaration
int qm_rtc_set_alarm(const rtc_t rtc, const uint32_t alarm_val)
//--------------------------------------------------------------------------
int main(void)
{
#define ALARM (RTC_ALARM_MINUTE / 6)
rtc_set_alarm(RTC_0, (RTC[RTC_0].rtc_ccvr + ALARM));
}