px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
px_m41t00.h
1#ifndef __PX_RTC_M41T00_H__
2#define __PX_RTC_M41T00_H__
3/* =============================================================================
4 ____ ___ ____ ___ _ _ ___ __ __ ___ __ __ TM
5 | _ \ |_ _| / ___| / _ \ | \ | | / _ \ | \/ | |_ _| \ \/ /
6 | |_) | | | | | | | | | | \| | | | | | | |\/| | | | \ /
7 | __/ | | | |___ | |_| | | |\ | | |_| | | | | | | | / \
8 |_| |___| \____| \___/ |_| \_| \___/ |_| |_| |___| /_/\_\
9
10 Copyright (c) 2007 Pieter Conradie <https://piconomix.com>
11
12 License: MIT
13 https://github.com/piconomix/px-fwlib/blob/master/LICENSE.md
14
15 Title: px_m41t00.h : Driver for an ST M41T00 Real Time Clock
16 Author(s): Pieter Conradie
17 Creation Date: 2007-03-31
18
19============================================================================= */
20/**
21 * @ingroup DEVICES_RTC
22 * @defgroup PX_M41T00 px_m41t00.h : Driver for an ST M41T00 Real Time Clock
23 *
24 * This driver interface with an ST M41T00 RTC using I2C
25 *
26 * File(s):
27 * - devices/rtc/inc/px_m41t00.h
28 * - devices/rtc/src/px_m41t00.c
29 *
30 * Reference:
31 * - [ST M41T00M6E](http://us1.st.com/stonline/products/literature/ds/6100.pdf) datasheet
32 *
33 * Example:
34 *
35 * @include devices/rtc/test/px_m41t00_test.c
36 *
37 * @{
38 */
39
40/* _____PROJECT INCLUDES_____________________________________________________ */
41#include "px_defs.h"
42#include "px_i2c.h"
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47/* _____DEFINITIONS__________________________________________________________ */
48/// I2C Slave Address
49#define PX_M41T00_SLA_ADR 0x68
50
51/* _____TYPE DEFINITIONS_____________________________________________________ */
52/// Structure to store time and date
53typedef struct
54{
55 uint8_t sec; ///< Seconds: 0 to 59
56 uint8_t min; ///< Minutes: 0 to 59
57 uint8_t hour; ///< Hours: 0 to 23
58 uint8_t day_of_week; ///< Day of Week: 1 to 7
59 uint8_t day_of_month; ///< Days of Month: 1 to 31 (depending on month)
60 uint8_t month; ///< Months: 1 to 12
61 uint8_t year; ///< Years: 00 to 99
63
64/* _____TYPE DEFINITIONS_____________________________________________________ */
65
66/* _____GLOBAL VARIABLES_____________________________________________________ */
67
68/* _____GLOBAL FUNCTION DECLARATIONS_________________________________________ */
69/**
70 * Initialise driver.
71 *
72 * @param px_i2c_handle Pointer to I2C driver handle
73 */
74extern void px_m41t00_init(px_i2c_handle_t * px_i2c_handle);
75
76/**
77 * Get RTC time using I2C driver.
78 *
79 * @param[out] px_rtc_time Pointer to a structure that will contain the new time.
80 *
81 * @retval true Time succesfully retrieved and copied into structure.
82 * @retval false Unable to get the time (I2C communication error)
83 * or timer has been stopped (new battery inserted)
84 */
85bool px_m41t00_get_time(px_m41t00_time_t * px_rtc_time);
86
87/**
88 * Set RTC time using I2C driver.
89 *
90 * @param[in] px_rtc_time Pointer to a structure containing the new time.
91 *
92 * @retval true Time succesfully set
93 * @retval false Unable to set the time (I2C communication error)
94 */
95bool px_m41t00_set_time(const px_m41t00_time_t * px_rtc_time);
96
97/* _____MACROS_______________________________________________________________ */
98
99#ifdef __cplusplus
100}
101#endif
102
103/// @}
104#endif
uint8_t sec
Seconds: 0 to 59.
Definition: px_m41t00.h:55
uint8_t year
Years: 00 to 99.
Definition: px_m41t00.h:61
uint8_t hour
Hours: 0 to 23.
Definition: px_m41t00.h:57
uint8_t day_of_month
Days of Month: 1 to 31 (depending on month)
Definition: px_m41t00.h:59
uint8_t min
Minutes: 0 to 59.
Definition: px_m41t00.h:56
uint8_t month
Months: 1 to 12.
Definition: px_m41t00.h:60
uint8_t day_of_week
Day of Week: 1 to 7.
Definition: px_m41t00.h:58
bool px_m41t00_get_time(px_m41t00_time_t *px_rtc_time)
Get RTC time using I2C driver.
Definition: px_m41t00.c:141
bool px_m41t00_set_time(const px_m41t00_time_t *px_rtc_time)
Set RTC time using I2C driver.
Definition: px_m41t00.c:182
void px_m41t00_init(px_i2c_handle_t *px_i2c_handle)
Initialise driver.
Definition: px_m41t00.c:136
Structure to store time and date.
Definition: px_m41t00.h:54
Define I2C handle for a slave.
Definition: px_i2c.h:104