Developing the RTC driver
In this section, we will develop the RTC calendar driver so that we can configure and keep track of the time and date.
As always, we will create a copy of our previous project while following the steps outlined in earlier chapters. We rename this copied project to RTC_Calendar
. Next, create a new file named rtc.c
in the Src
folder and another file named rtc.h
in the Inc
folder. The RTC configuration can be quite elaborate, so we will create several helper functions to modularize the initialization process.
The RTC implementation file
Let’s begin by populating the rtc.c
file, starting with the helper functions necessary for the initialization function. Here are the macro definitions that we will use in the RTC configuration:
#include "rtc.h" #define PWREN (1U << 28) #define CR_DBP (1U << 8) #define CSR_LSION ...