RTC 4 click
RTC 4 click carries DS2417, a real time clock/calendar with a 1-Wire MicroLAN interface and a programmable interrupt for system output.
click Product page
Click library
- Author : Aleksandra Cvjeticanin
- Date : Mar 2022.
- Type : One Wire type
Software Support
We provide a library for the RTC 4 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Library Description
This library contains API for RTC 4 Click driver.
Standard key functions :
rtc4_cfg_setup
Config Object Initialization function.
void rtc4_cfg_setup(rtc4_cfg_t *cfg)
RTC 4 configuration object setup function.
RTC 4 Click configuration object.
Definition rtc4.h:215
rtc4_init
Initialization function.
err_t rtc4_init(rtc4_t *ctx, rtc4_cfg_t *cfg)
RTC 4 initialization function.
RTC 4 Click context object.
Definition rtc4.h:198
Example key functions :
rtc4_get_interrupt
This function checks the interrupt state of the DS2417 Real time clock/calendar.
uint8_t rtc4_get_interrupt(rtc4_t *ctx)
RTC 4 get interrupt function.
rtc4_set_date_time
This function sets date and time structure along with interrupt interval.
err_t rtc4_set_date_time(rtc4_t *ctx, rtc4_date_t *date, rtc4_time_t *time, uint8_t int_interval)
RTC 4 set date time function.
rtc4_date_t date
Definition main.c:31
rtc4_time_t time
Definition main.c:30
RTC 4 Click date object.
Definition rtc4.h:175
RTC 4 Click time object.
Definition rtc4.h:163
rtc4_get_date_time
This function gets RTC4 time and date structure.
err_t rtc4_get_date_time(rtc4_t *ctx, rtc4_date_t *date, rtc4_time_t *time)
RTC 4 get date time function.
Example Description
This example demonstrates the use of the RTC 4 click board.
The demo application is composed of two sections :
Application Init
Initializes the driver and logger and then sets the starting time to 23:59:50 and date to 31.12.2022.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( ONE_WIRE_ERROR ==
rtc4_init( &rtc4, &rtc4_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Check communication." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define RTC4_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition rtc4.h:149
#define RTC4_DCB_INTERVAL_1S
Definition rtc4.h:118
err_t rtc4_check_communication(rtc4_t *ctx)
RTC 4 check communication function.
void application_init(void)
Definition main.c:33
@ RTC4_ERROR
Definition rtc4.h:234
uint32_t month
Definition rtc4.h:177
uint32_t day
Definition rtc4.h:178
uint32_t year
Definition rtc4.h:176
uint32_t min
Definition rtc4.h:165
uint32_t sec
Definition rtc4.h:166
uint32_t hours
Definition rtc4.h:164
Application Task
With the usage of rtc4_get_date_time we get the time and date from the register and display them on the UART Terminal. The counter increments once per second.
{
{
log_printf( &logger, "Time: %.2u:%.2u:%.2u\r\n",
log_printf( &logger, "Date: %.2u/%.2u/%u\r\n",
log_printf( &logger, "------------------------\r\n\n");
}
}
void application_task(void)
Definition main.c:79
@ RTC4_OK
Definition rtc4.h:233
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.RTC4
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.