RTC5 click
RTC5 click carries MCP79510, a real-time clock/calendar with an SPI interface (mikroBUS MISO, MOSI, SCK and CS pins); along with a programmable interrupt for system output.
click Product page
Click library
- Author : MikroE Team
- Date : Jan 2020.
- Type : SPI type
Software Support
We provide a library for the Rtc5 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 form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.
Library Description
This library contains API for Rtc5 Click driver.
Standard key functions :
- Config Object Initialization function.
void rtc5_cfg_setup ( rtc5_cfg_t *cfg );
- Initialization function.
RTC5_RETVAL rtc5_init ( rtc5_t *ctx, rtc5_cfg_t *cfg );
- Click Default Configuration function.
void rtc5_default_cfg ( rtc5_t *ctx );
Example key functions :
- Set time hours, minutes and seconds function.
void rtc5_set_time ( rtc5_t *ctx, uint8_t time_hours, uint8_t time_min, uint8_t time_sec );
- Set date hours, minutes and seconds function.
void rtc5_set_date ( rtc5_t *ctx, uint8_t date_day, uint8_t date_month, uint16_t date_year );
- Get time and date function.
void rtc5_get_time_and_date ( rtc5_t *ctx, rtc5_timedate_t *timedate_data );
Examples Description
This is a example which demonstrates the use of RTC 5 Click board.
The demo application is composed of two sections :
Application Init
Initializes GPIO, SPI and LOG structures, sets CS pin as output and INT pin as input. Initialization driver enable's - SPI, clear RTCC and SRAM memory, sets starting time and date, enable counting and start write log.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_printf( &logger, "- Application Init -\r\n" );
Delay_ms( 100 );
Delay_ms( 100 );
time_sec_new = 255;
Delay_ms( 100 );
log_printf( &logger, "--------------------\r\n" );
log_printf( &logger, " RTC 5 Click \r\n" );
log_printf( &logger, "--------------------\r\n" );
}
#define RTC5_MAP_MIKROBUS(cfg, mikrobus)
Definition: rtc5.h:54
void rtc5_set_day_of_the_week(rtc5_t *ctx, uint8_t w_day)
Set day of the week function.
void rtc5_set_counting(rtc5_t *ctx, uint8_t en_osc)
Enable counting function.
void rtc5_default_cfg(rtc5_t *ctx)
Click Default Configuration function.
RTC5_RETVAL rtc5_init(rtc5_t *ctx, rtc5_cfg_t *cfg)
Initialization function.
void rtc5_cfg_setup(rtc5_cfg_t *cfg)
Config Object Initialization function.
void rtc5_clear(rtc5_t *ctx)
Clear RTCC and SRAM memory function.
void rtc5_set_date(rtc5_t *ctx, uint8_t date_day, uint8_t date_month, uint16_t date_year)
Set date hours, minutes and seconds function.
void rtc5_set_time(rtc5_t *ctx, uint8_t time_hours, uint8_t time_min, uint8_t time_sec)
Set time hours, minutes and seconds function.
#define RTC5_DAY_OF_THE_WEEK_TUESDAY
Definition: rtc5.h:144
void application_init(void)
Definition: main.c:90
Click configuration structure definition.
Definition: rtc5.h:181
Application Task
RTC 5 Click communicates with register via SPI by write to register and read from register, display RTC time and date.
{
{
log_printf( &logger, "--------------------\r\n" );
}
}
void rtc5_get_time_and_date(rtc5_t *ctx, rtc5_timedate_t *timedate_data)
Get time and date function.
void application_task(void)
Definition: main.c:141
void display_log_day_of_the_week(uint8_t w_day)
Definition: main.c:42
rtc5_timedate_t time_date_data
Definition: main.c:38
uint8_t hours
Definition: rtc5.h:211
uint8_t month
Definition: rtc5.h:216
uint8_t day
Definition: rtc5.h:215
uint8_t year
Definition: rtc5.h:217
uint8_t w_day
Definition: rtc5.h:218
uint8_t min
Definition: rtc5.h:210
uint8_t sec
Definition: rtc5.h:209
Note
Additional Functions: void display_log_day_of_the_week( uint8_t w_day ) - Write day of the week log.
The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.
Other mikroE Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.Rtc5
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. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.