00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef ARM7_CLOCK_INCLUDE
00030 #define ARM7_CLOCK_INCLUDE
00031
00032
00033 #ifndef ARM7
00034 #error The clock is only available on the ARM7
00035 #endif
00036
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040
00041
00042 #include <nds/arm7/serial.h>
00043
00044
00045 #define WRITE_STATUS_REG1 0x60
00046 #define READ_STATUS_REG1 0x61
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #define STATUS_POC (1<<7) // read-only, cleared by reading (1 if just powered on)
00061 #define STATUS_BLD (1<<6) // read-only, cleared by reading (1 if power dropped below the safety threshold)
00062 #define STATUS_INT2 (1<<5) // read-only, INT2 has occured
00063 #define STATUS_INT1 (1<<4) // read-only, INT1 has occured
00064 #define STATUS_SC1 (1<<3) // R/W scratch bit
00065 #define STATUS_SC0 (1<<2) // R/W scratch bit
00066 #define STATUS_24HRS (1<<1) // 24 hour mode when 1, 12 hour mode when 0
00067 #define STATUS_RESET (1<<0) // write-only, reset when 1 written
00068
00069 #define WRITE_STATUS_REG2 0x62
00070 #define READ_STATUS_REG2 0x63
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 #define STATUS_TEST (1<<7) //
00088 #define STATUS_INT2AE (1<<6) //
00089 #define STATUS_SC3 (1<<5) // R/W scratch bit
00090 #define STATUS_SC2 (1<<4) // R/W scratch bit
00091
00092 #define STATUS_32kE (1<<3) // Interrupt mode bits
00093 #define STATUS_INT1AE (1<<2) //
00094 #define STATUS_INT1ME (1<<1) //
00095 #define STATUS_INT1FE (1<<0) //
00096
00097
00098 #define WRITE_TIME_AND_DATE 0x64
00099 #define READ_TIME_AND_DATE 0x65
00100
00101
00102 #define WRITE_TIME 0x66
00103 #define READ_TIME 0x67
00104
00105 #define WRITE_INT_REG1 0x68
00106 #define READ_INT_REG1 0x69
00107
00108 #define READ_INT_REG2 0x6A
00109 #define WRITE_INT_REG2 0x6B
00110
00111 #define READ_CLOCK_ADJUST_REG 0x6C
00112 #define WRITE_CLOCK_ADJUST_REG 0x6D
00113
00114
00115 #define READ_FREE_REG 0x6E
00116 #define WRITE_FREE_REG 0x6F
00117
00118
00119 void rtcReset(void);
00120 void rtcTransaction(uint8 * command, uint32 commandLength, uint8 * result, uint32 resultLength);
00121
00122 void rtcGetTime(uint8 * time);
00123 void rtcSetTime(uint8 * time);
00124
00125 void rtcGetTimeAndDate(uint8 * time);
00126 void rtcSetTimeAndDate(uint8 * time);
00127
00128 void rtcGetData(uint8 * data, uint32 size);
00129
00130 void BCDToInteger(uint8 * data, uint32 length);
00131 void integerToBCD(uint8 * data, uint32 length);
00132
00133 void initClockIRQ();
00134 void resyncClock();
00135
00136 #ifdef __cplusplus
00137 }
00138 #endif
00139
00140 #endif
00141