rtc.h
Go to the documentation of this file.
1 /*
2  * SocialLedge.com - Copyright (C) 2013
3  *
4  * This file is part of free software framework for embedded processors.
5  * You can use it and/or distribute it as long as this copyright header
6  * remains unmodified. The code is free for personal use and requires
7  * permission to use in a commercial product.
8  *
9  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
10  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
12  * I SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
13  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
14  *
15  * You can reach the author of this software at :
16  * p r e e t . w i k i @ g m a i l . c o m
17  */
18 
25 #ifndef RTC_H
26 #define RTC_H
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #include <stdint.h>
32 
33 
34 
39 typedef struct {
40  /* - Data ----- - Padding --- */
41  uint32_t sec : 6; uint32_t : 2;
42  uint32_t min : 6; uint32_t : 2;
43  uint32_t hour : 5; uint32_t : 3;
44  uint32_t dow : 3; uint32_t : 5;
45 
46  uint32_t day : 5; uint32_t : 3;
47  uint32_t month: 4; uint32_t : 4;
48  uint32_t year :12; uint32_t : 4;
49 
50  uint32_t doy :12; uint32_t : 20;
51 } __attribute__((packed)) rtc_t ;
52 
56 typedef enum {
57  dow_sun = 0,
64 } __attribute__((packed)) day_of_week_t;
65 
67 void rtc_init (void);
68 
70 rtc_t rtc_gettime (void);
71 
76 void rtc_settime (const rtc_t* rtcstruct);
77 
83 const char* rtc_get_date_time_str(void);
84 
85 
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 #endif
Definition: rtc.h:59
Definition: rtc.h:57
Definition: rtc.h:58
__attribute__
Definition: rtc.h:56
const char * rtc_get_date_time_str(void)
Definition: rtc.c:93
Definition: rtc.h:61
void rtc_settime(const rtc_t *rtcstruct)
Definition: rtc.c:71
void rtc_init(void)
Initialize the RTC.
Definition: rtc.c:29
rtc_t rtc_gettime(void)
Definition: rtc.c:55
Definition: rtc.h:60
Definition: rtc.h:63
Definition: rtc.h:62