diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2017-07-07 11:55:23 -0400 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2017-07-07 11:55:23 -0400 |
| commit | 8655d4f4948b2deef7844503c8d690f23ac1a062 (patch) | |
| tree | b2c6effc9d6cd5b5b43933a1e53b8bf17e9e82cf /lib/lufa/Projects/TempDataLogger/Lib/RTC.h | |
| parent | 1896c76a2928c96f9ab7947bec2ef8dd37623cff (diff) | |
| parent | 60b30c036397cb5627fa374bb930794b225daa29 (diff) | |
| download | qmk_firmware-8655d4f4948b2deef7844503c8d690f23ac1a062.tar.gz qmk_firmware-8655d4f4948b2deef7844503c8d690f23ac1a062.zip | |
Merge commit '60b30c036397cb5627fa374bb930794b225daa29' as 'lib/lufa'
Diffstat (limited to 'lib/lufa/Projects/TempDataLogger/Lib/RTC.h')
| -rw-r--r-- | lib/lufa/Projects/TempDataLogger/Lib/RTC.h | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/lib/lufa/Projects/TempDataLogger/Lib/RTC.h b/lib/lufa/Projects/TempDataLogger/Lib/RTC.h new file mode 100644 index 000000000..f35b8ff1e --- /dev/null +++ b/lib/lufa/Projects/TempDataLogger/Lib/RTC.h | |||
| @@ -0,0 +1,126 @@ | |||
| 1 | /* | ||
| 2 | Copyright (C) Dean Camera, 2017. | ||
| 3 | |||
| 4 | dean [at] fourwalledcubicle [dot] com | ||
| 5 | www.lufa-lib.org | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef _RTC_H_ | ||
| 9 | #define _RTC_H_ | ||
| 10 | |||
| 11 | /* Includes: */ | ||
| 12 | #include <avr/io.h> | ||
| 13 | |||
| 14 | #include <LUFA/Drivers/Peripheral/TWI.h> | ||
| 15 | |||
| 16 | #include "Config/AppConfig.h" | ||
| 17 | |||
| 18 | /* Type Defines: */ | ||
| 19 | typedef struct | ||
| 20 | { | ||
| 21 | uint8_t Hour; | ||
| 22 | uint8_t Minute; | ||
| 23 | uint8_t Second; | ||
| 24 | uint8_t Day; | ||
| 25 | uint8_t Month; | ||
| 26 | uint8_t Year; | ||
| 27 | } TimeDate_t; | ||
| 28 | |||
| 29 | typedef struct | ||
| 30 | { | ||
| 31 | union | ||
| 32 | { | ||
| 33 | struct | ||
| 34 | { | ||
| 35 | unsigned Sec : 4; | ||
| 36 | unsigned TenSec : 3; | ||
| 37 | unsigned CH : 1; | ||
| 38 | } Fields; | ||
| 39 | |||
| 40 | uint8_t IntVal; | ||
| 41 | } Byte1; | ||
| 42 | |||
| 43 | union | ||
| 44 | { | ||
| 45 | struct | ||
| 46 | { | ||
| 47 | unsigned Min : 4; | ||
| 48 | unsigned TenMin : 3; | ||
| 49 | unsigned Reserved : 1; | ||
| 50 | } Fields; | ||
| 51 | |||
| 52 | uint8_t IntVal; | ||
| 53 | } Byte2; | ||
| 54 | |||
| 55 | union | ||
| 56 | { | ||
| 57 | struct | ||
| 58 | { | ||
| 59 | unsigned Hour : 4; | ||
| 60 | unsigned TenHour : 2; | ||
| 61 | unsigned TwelveHourMode : 1; | ||
| 62 | unsigned Reserved : 1; | ||
| 63 | } Fields; | ||
| 64 | |||
| 65 | uint8_t IntVal; | ||
| 66 | } Byte3; | ||
| 67 | |||
| 68 | union | ||
| 69 | { | ||
| 70 | struct | ||
| 71 | { | ||
| 72 | unsigned DayOfWeek : 3; | ||
| 73 | unsigned Reserved : 5; | ||
| 74 | } Fields; | ||
| 75 | |||
| 76 | uint8_t IntVal; | ||
| 77 | } Byte4; | ||
| 78 | |||
| 79 | union | ||
| 80 | { | ||
| 81 | struct | ||
| 82 | { | ||
| 83 | unsigned Day : 4; | ||
| 84 | unsigned TenDay : 2; | ||
| 85 | unsigned Reserved : 2; | ||
| 86 | } Fields; | ||
| 87 | |||
| 88 | uint8_t IntVal; | ||
| 89 | } Byte5; | ||
| 90 | |||
| 91 | union | ||
| 92 | { | ||
| 93 | struct | ||
| 94 | { | ||
| 95 | unsigned Month : 4; | ||
| 96 | unsigned TenMonth : 1; | ||
| 97 | unsigned Reserved : 3; | ||
| 98 | } Fields; | ||
| 99 | |||
| 100 | uint8_t IntVal; | ||
| 101 | } Byte6; | ||
| 102 | |||
| 103 | union | ||
| 104 | { | ||
| 105 | struct | ||
| 106 | { | ||
| 107 | unsigned Year : 4; | ||
| 108 | unsigned TenYear : 4; | ||
| 109 | } Fields; | ||
| 110 | |||
| 111 | uint8_t IntVal; | ||
| 112 | } Byte7; | ||
| 113 | } DS1307_DateTimeRegs_t; | ||
| 114 | |||
| 115 | /* Macros: */ | ||
| 116 | /** TWI address of the DS1307 device on the bus. */ | ||
| 117 | #define DS1307_ADDRESS 0xD0 | ||
| 118 | |||
| 119 | /* Function Prototypes: */ | ||
| 120 | void RTC_Init(void); | ||
| 121 | void RTC_Tick500ms(void); | ||
| 122 | bool RTC_SetTimeDate(const TimeDate_t* NewTimeDate); | ||
| 123 | bool RTC_GetTimeDate(TimeDate_t* const TimeDate); | ||
| 124 | |||
| 125 | #endif | ||
| 126 | |||
