Yoshiyuki Uehara / Mbed 2 deprecated Maple

Dependencies:   mbed

Committer:
uehara00
Date:
Sun Sep 25 11:37:21 2011 +0000
Revision:
0:0be38b583cf7
Child:
1:aefa1992ce0f
Preliminary. Alarm functions are not yet implimented.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
uehara00 0:0be38b583cf7 1 // MAPLE board[MARM01-BASE]
uehara00 0:0be38b583cf7 2 // sample application - clock
uehara00 0:0be38b583cf7 3 //
uehara00 0:0be38b583cf7 4 #include "Maple_alarm_clock.h"
uehara00 0:0be38b583cf7 5 #include "Maple_RTC.h"
uehara00 0:0be38b583cf7 6 #include "Maple_I2C.h"
uehara00 0:0be38b583cf7 7 #include "Maple_LCD.h"
uehara00 0:0be38b583cf7 8 #include "Maple.h"
uehara00 0:0be38b583cf7 9 #include "mbed.h"
uehara00 0:0be38b583cf7 10
uehara00 0:0be38b583cf7 11 // timer interrupt to refresh display
uehara00 0:0be38b583cf7 12 Ticker alarm_clock_refresh_tick;
uehara00 0:0be38b583cf7 13
uehara00 0:0be38b583cf7 14 // global variables
uehara00 0:0be38b583cf7 15 int BTN_count[6];
uehara00 0:0be38b583cf7 16 int BTN_status[6];
uehara00 0:0be38b583cf7 17 int display_mode ;
uehara00 0:0be38b583cf7 18 int cursor_position;
uehara00 0:0be38b583cf7 19 const int cursor_position_date_time_max = 6;
uehara00 0:0be38b583cf7 20
uehara00 0:0be38b583cf7 21 // alarm_clock_initialize
uehara00 0:0be38b583cf7 22 void alarm_clock_initialize() {
uehara00 0:0be38b583cf7 23 alarm_clock_refresh_tick.attach(&alarm_clock_refresh, ALARM_CLOCK_REFRESH_RATE);
uehara00 0:0be38b583cf7 24 }
uehara00 0:0be38b583cf7 25
uehara00 0:0be38b583cf7 26 // refresh display, called by a ticker
uehara00 0:0be38b583cf7 27 void alarm_clock_refresh() {
uehara00 0:0be38b583cf7 28 char format_date[15]; // "yyyy.mm.dd www"
uehara00 0:0be38b583cf7 29 char format_time[9]; // "hh:mm:ss"
uehara00 0:0be38b583cf7 30 const int cursor_date_time_row[7] = {0, 0, 0, 0, 1, 1, 1};
uehara00 0:0be38b583cf7 31 const int cursor_date_time_column[7] = {1, 3, 6, 9, 1, 4, 7};
uehara00 0:0be38b583cf7 32
uehara00 0:0be38b583cf7 33 if(display_mode == DISPLAY_MODE_DATE_TIME) {
uehara00 0:0be38b583cf7 34 LCD_cursor(LCD_CURSOR_OFF);
uehara00 0:0be38b583cf7 35 LCD_locate(1, 10); LCD_print_string(" ");
uehara00 0:0be38b583cf7 36
uehara00 0:0be38b583cf7 37 RTC_read_format(format_date, format_time);
uehara00 0:0be38b583cf7 38 LCD_locate(0, 0); LCD_print_string(format_date);
uehara00 0:0be38b583cf7 39 LCD_locate(1, 0); LCD_print_string(format_time);
uehara00 0:0be38b583cf7 40 }
uehara00 0:0be38b583cf7 41
uehara00 0:0be38b583cf7 42 if(display_mode == DISPLAY_MODE_DATE_TIME_ADJUST) {
uehara00 0:0be38b583cf7 43 LCD_cursor(LCD_CURSOR_OFF);
uehara00 0:0be38b583cf7 44 LCD_locate(1, 10); LCD_print_string("adjust");
uehara00 0:0be38b583cf7 45
uehara00 0:0be38b583cf7 46 RTC_read_format(format_date, format_time);
uehara00 0:0be38b583cf7 47 LCD_locate(0, 0); LCD_print_string(format_date);
uehara00 0:0be38b583cf7 48 LCD_locate(1, 0); LCD_print_string(format_time);
uehara00 0:0be38b583cf7 49
uehara00 0:0be38b583cf7 50 LCD_locate(cursor_date_time_row[cursor_position], cursor_date_time_column[cursor_position]);
uehara00 0:0be38b583cf7 51 LCD_cursor(LCD_CURSOR_ON);
uehara00 0:0be38b583cf7 52 }
uehara00 0:0be38b583cf7 53
uehara00 0:0be38b583cf7 54 BTN_check(BTN_count, BTN_status);
uehara00 0:0be38b583cf7 55 }
uehara00 0:0be38b583cf7 56
uehara00 0:0be38b583cf7 57 // read BTN and update BTN_on_count[i]
uehara00 0:0be38b583cf7 58 // called by timer tick interrupt
uehara00 0:0be38b583cf7 59 static void BTN_check(int count[], int status[]) {
uehara00 0:0be38b583cf7 60 char b;
uehara00 0:0be38b583cf7 61
uehara00 0:0be38b583cf7 62 b = i2c_BTN_read();
uehara00 0:0be38b583cf7 63 if((b & BTN_MASK_A ) == BTN_ON) { ++count[BTN_A ]; } else { count[BTN_A ] = 0; status[BTN_A ] = BTN_IDLE; }
uehara00 0:0be38b583cf7 64 if((b & BTN_MASK_B ) == BTN_ON) { ++count[BTN_B ]; } else { count[BTN_B ] = 0; status[BTN_B ] = BTN_IDLE; }
uehara00 0:0be38b583cf7 65 if((b & BTN_MASK_LEFT ) == BTN_ON) { ++count[BTN_LEFT ]; } else { count[BTN_LEFT ] = 0; status[BTN_LEFT ] = BTN_IDLE; }
uehara00 0:0be38b583cf7 66 if((b & BTN_MASK_DOWN ) == BTN_ON) { ++count[BTN_DOWN ]; } else { count[BTN_DOWN ] = 0; status[BTN_DOWN ] = BTN_IDLE; }
uehara00 0:0be38b583cf7 67 if((b & BTN_MASK_RIGHT) == BTN_ON) { ++count[BTN_RIGHT]; } else { count[BTN_RIGHT] = 0; status[BTN_RIGHT] = BTN_IDLE; }
uehara00 0:0be38b583cf7 68 if((b & BTN_MASK_UP ) == BTN_ON) { ++count[BTN_UP ]; } else { count[BTN_UP ] = 0; status[BTN_UP ] = BTN_IDLE; }
uehara00 0:0be38b583cf7 69
uehara00 0:0be38b583cf7 70 if((status[BTN_A] == BTN_IDLE) && (count[BTN_A] > BTN_THRESHOLD)) {
uehara00 0:0be38b583cf7 71 status[BTN_A] = BTN_BUSY;
uehara00 0:0be38b583cf7 72 BTN_A_action(); // one shot
uehara00 0:0be38b583cf7 73 }
uehara00 0:0be38b583cf7 74
uehara00 0:0be38b583cf7 75 if((status[BTN_B] == BTN_IDLE) && (count[BTN_B] > BTN_THRESHOLD)) {
uehara00 0:0be38b583cf7 76 status[BTN_B] = BTN_BUSY;
uehara00 0:0be38b583cf7 77 BTN_B_action(); // one shot
uehara00 0:0be38b583cf7 78 }
uehara00 0:0be38b583cf7 79
uehara00 0:0be38b583cf7 80 if((status[BTN_LEFT] == BTN_IDLE) && (count[BTN_LEFT] > BTN_THRESHOLD)) {
uehara00 0:0be38b583cf7 81 status[BTN_LEFT] = BTN_BUSY;
uehara00 0:0be38b583cf7 82 BTN_LEFT_action(); // one shot
uehara00 0:0be38b583cf7 83 }
uehara00 0:0be38b583cf7 84 else if((count[BTN_LEFT] > BTN_REPEAT) && (count[BTN_LEFT] % BTN_REPEAT_PERIOD == 0)) {
uehara00 0:0be38b583cf7 85 BTN_LEFT_action(); // auto repeat
uehara00 0:0be38b583cf7 86 }
uehara00 0:0be38b583cf7 87
uehara00 0:0be38b583cf7 88 if((status[BTN_DOWN] == BTN_IDLE) && (count[BTN_DOWN] > BTN_THRESHOLD)) {
uehara00 0:0be38b583cf7 89 status[BTN_DOWN] = BTN_BUSY;
uehara00 0:0be38b583cf7 90 BTN_DOWN_action(); // one shot
uehara00 0:0be38b583cf7 91 }
uehara00 0:0be38b583cf7 92 else if((count[BTN_DOWN] > BTN_REPEAT_FAST) && (count[BTN_DOWN] % BTN_REPEAT_PERIOD_FAST == 0)) {
uehara00 0:0be38b583cf7 93 BTN_DOWN_action(); // auto repeat fast
uehara00 0:0be38b583cf7 94 }
uehara00 0:0be38b583cf7 95 else if((count[BTN_DOWN] > BTN_REPEAT) && (count[BTN_DOWN] % BTN_REPEAT_PERIOD == 0)) {
uehara00 0:0be38b583cf7 96 BTN_DOWN_action(); // auto repeat
uehara00 0:0be38b583cf7 97 }
uehara00 0:0be38b583cf7 98
uehara00 0:0be38b583cf7 99 if((status[BTN_RIGHT] == BTN_IDLE) && (count[BTN_RIGHT] > BTN_THRESHOLD)) {
uehara00 0:0be38b583cf7 100 status[BTN_RIGHT] = BTN_BUSY;
uehara00 0:0be38b583cf7 101 BTN_RIGHT_action(); // one shot
uehara00 0:0be38b583cf7 102 }
uehara00 0:0be38b583cf7 103 else if((count[BTN_RIGHT] > BTN_REPEAT) && (count[BTN_RIGHT] % BTN_REPEAT_PERIOD == 0)) {
uehara00 0:0be38b583cf7 104 BTN_RIGHT_action(); // auto repeat
uehara00 0:0be38b583cf7 105 }
uehara00 0:0be38b583cf7 106
uehara00 0:0be38b583cf7 107 if((status[BTN_UP] == BTN_IDLE) && (count[BTN_UP] > BTN_THRESHOLD)) {
uehara00 0:0be38b583cf7 108 status[BTN_UP] = BTN_BUSY;
uehara00 0:0be38b583cf7 109 BTN_UP_action(); // one shot
uehara00 0:0be38b583cf7 110 }
uehara00 0:0be38b583cf7 111 else if((count[BTN_UP] > BTN_REPEAT_FAST) && (count[BTN_UP] % BTN_REPEAT_PERIOD_FAST == 0)) {
uehara00 0:0be38b583cf7 112 BTN_UP_action(); // auto repeat fast
uehara00 0:0be38b583cf7 113 }
uehara00 0:0be38b583cf7 114 else if((count[BTN_UP] > BTN_REPEAT) && (count[BTN_UP] % BTN_REPEAT_PERIOD == 0)) {
uehara00 0:0be38b583cf7 115 BTN_UP_action(); // auto repeat
uehara00 0:0be38b583cf7 116 }
uehara00 0:0be38b583cf7 117 }
uehara00 0:0be38b583cf7 118
uehara00 0:0be38b583cf7 119 // BTN_A: enter function mode
uehara00 0:0be38b583cf7 120 static void BTN_A_action() {
uehara00 0:0be38b583cf7 121 if(display_mode == DISPLAY_MODE_DATE_TIME) {
uehara00 0:0be38b583cf7 122 display_mode = DISPLAY_MODE_DATE_TIME_ADJUST;
uehara00 0:0be38b583cf7 123 cursor_position = CURSOR_DATE_TIME_SECOND;
uehara00 0:0be38b583cf7 124 }
uehara00 0:0be38b583cf7 125 }
uehara00 0:0be38b583cf7 126
uehara00 0:0be38b583cf7 127 // BTN_A: exit to date-time mode
uehara00 0:0be38b583cf7 128 static void BTN_B_action() {
uehara00 0:0be38b583cf7 129 display_mode = DISPLAY_MODE_DATE_TIME;
uehara00 0:0be38b583cf7 130 }
uehara00 0:0be38b583cf7 131
uehara00 0:0be38b583cf7 132 // BTN_RIGHT: move cursor backward
uehara00 0:0be38b583cf7 133 static void BTN_LEFT_action() {
uehara00 0:0be38b583cf7 134 if(display_mode == DISPLAY_MODE_DATE_TIME_ADJUST) {
uehara00 0:0be38b583cf7 135 if(cursor_position > 0) {
uehara00 0:0be38b583cf7 136 --cursor_position;
uehara00 0:0be38b583cf7 137 }
uehara00 0:0be38b583cf7 138 else {
uehara00 0:0be38b583cf7 139 cursor_position = cursor_position_date_time_max;
uehara00 0:0be38b583cf7 140 }
uehara00 0:0be38b583cf7 141 }
uehara00 0:0be38b583cf7 142 }
uehara00 0:0be38b583cf7 143
uehara00 0:0be38b583cf7 144 // decrement date/time
uehara00 0:0be38b583cf7 145 static void BTN_DOWN_action() {
uehara00 0:0be38b583cf7 146 char century, bcd_year, bcd_month, bcd_day, weekday, d, t;
uehara00 0:0be38b583cf7 147
uehara00 0:0be38b583cf7 148 if(display_mode == DISPLAY_MODE_DATE_TIME_ADJUST) {
uehara00 0:0be38b583cf7 149
uehara00 0:0be38b583cf7 150 switch(cursor_position) {
uehara00 0:0be38b583cf7 151
uehara00 0:0be38b583cf7 152 case CURSOR_DATE_TIME_CENTURY:
uehara00 0:0be38b583cf7 153 RTC_stop_and_read_date(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 154 century = decrement_bcd(century, 0x00, 0x01);
uehara00 0:0be38b583cf7 155 d = bcd_days_in_month(century, bcd_year, bcd_month);
uehara00 0:0be38b583cf7 156 if(bcd_day > d) {
uehara00 0:0be38b583cf7 157 bcd_day = d;
uehara00 0:0be38b583cf7 158 }
uehara00 0:0be38b583cf7 159 weekday = bcd_date_to_weekday(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 160 RTC_write_date_and_start(century, bcd_year, bcd_month, bcd_day, weekday);
uehara00 0:0be38b583cf7 161 break;
uehara00 0:0be38b583cf7 162
uehara00 0:0be38b583cf7 163 case CURSOR_DATE_TIME_YEAR:
uehara00 0:0be38b583cf7 164 RTC_stop_and_read_date(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 165 bcd_year = decrement_bcd(bcd_year, 0x00, 0x99);
uehara00 0:0be38b583cf7 166 d = bcd_days_in_month(century, bcd_year, bcd_month);
uehara00 0:0be38b583cf7 167 if(bcd_day > d) {
uehara00 0:0be38b583cf7 168 bcd_day = d;
uehara00 0:0be38b583cf7 169 }
uehara00 0:0be38b583cf7 170 weekday = bcd_date_to_weekday(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 171 RTC_write_date_and_start(century, bcd_year, bcd_month, bcd_day, weekday);
uehara00 0:0be38b583cf7 172 break;
uehara00 0:0be38b583cf7 173
uehara00 0:0be38b583cf7 174 case CURSOR_DATE_TIME_MONTH:
uehara00 0:0be38b583cf7 175 RTC_stop_and_read_date(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 176 bcd_month = decrement_bcd(bcd_month, 0x01, 0x12);
uehara00 0:0be38b583cf7 177 d = bcd_days_in_month(century, bcd_year, bcd_month);
uehara00 0:0be38b583cf7 178 if(bcd_day > d) {
uehara00 0:0be38b583cf7 179 bcd_day = d;
uehara00 0:0be38b583cf7 180 }
uehara00 0:0be38b583cf7 181 weekday = bcd_date_to_weekday(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 182 RTC_write_date_and_start(century, bcd_year, bcd_month, bcd_day, weekday);
uehara00 0:0be38b583cf7 183 break;
uehara00 0:0be38b583cf7 184
uehara00 0:0be38b583cf7 185 case CURSOR_DATE_TIME_DAY:
uehara00 0:0be38b583cf7 186 RTC_stop_and_read_date(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 187 bcd_day = decrement_bcd(bcd_day, 0x01, bcd_days_in_month(century, bcd_year, bcd_month));
uehara00 0:0be38b583cf7 188 weekday = bcd_date_to_weekday(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 189 RTC_write_date_and_start(century, bcd_year, bcd_month, bcd_day, weekday);
uehara00 0:0be38b583cf7 190 break;
uehara00 0:0be38b583cf7 191
uehara00 0:0be38b583cf7 192 case CURSOR_DATE_TIME_HOUR:
uehara00 0:0be38b583cf7 193 t = RTC_stop_and_read1(RTC_REG_HOUR) & 0x3F;
uehara00 0:0be38b583cf7 194 t = decrement_bcd(t, 0x00, 0x23);
uehara00 0:0be38b583cf7 195 RTC_write1_and_start(RTC_REG_HOUR, t);
uehara00 0:0be38b583cf7 196 break;
uehara00 0:0be38b583cf7 197
uehara00 0:0be38b583cf7 198 case CURSOR_DATE_TIME_MINUTE:
uehara00 0:0be38b583cf7 199 t = RTC_stop_and_read1(RTC_REG_MINUTE) & 0x7F;
uehara00 0:0be38b583cf7 200 t = decrement_bcd(t, 0x00, 0x59);
uehara00 0:0be38b583cf7 201 RTC_write1_and_start(RTC_REG_MINUTE, t);
uehara00 0:0be38b583cf7 202 break;
uehara00 0:0be38b583cf7 203
uehara00 0:0be38b583cf7 204 case CURSOR_DATE_TIME_SECOND:
uehara00 0:0be38b583cf7 205 t = RTC_stop_and_read1(RTC_REG_SECOND) & 0x7f;
uehara00 0:0be38b583cf7 206 t = 0x30;
uehara00 0:0be38b583cf7 207 RTC_write1_and_start(RTC_REG_SECOND, t);
uehara00 0:0be38b583cf7 208 break;
uehara00 0:0be38b583cf7 209 }
uehara00 0:0be38b583cf7 210 }
uehara00 0:0be38b583cf7 211 }
uehara00 0:0be38b583cf7 212
uehara00 0:0be38b583cf7 213 // BTN_RIGHT: move cursor forward
uehara00 0:0be38b583cf7 214 static void BTN_RIGHT_action() {
uehara00 0:0be38b583cf7 215 if(display_mode == DISPLAY_MODE_DATE_TIME_ADJUST) {
uehara00 0:0be38b583cf7 216 ++cursor_position;
uehara00 0:0be38b583cf7 217 if(cursor_position > cursor_position_date_time_max) {
uehara00 0:0be38b583cf7 218 cursor_position = 0;
uehara00 0:0be38b583cf7 219 }
uehara00 0:0be38b583cf7 220 }
uehara00 0:0be38b583cf7 221 }
uehara00 0:0be38b583cf7 222
uehara00 0:0be38b583cf7 223 // increment date/time
uehara00 0:0be38b583cf7 224 static void BTN_UP_action() {
uehara00 0:0be38b583cf7 225 char century, bcd_year, bcd_month, bcd_day, weekday, d, t;
uehara00 0:0be38b583cf7 226
uehara00 0:0be38b583cf7 227 if(display_mode == DISPLAY_MODE_DATE_TIME_ADJUST) {
uehara00 0:0be38b583cf7 228
uehara00 0:0be38b583cf7 229 switch(cursor_position) {
uehara00 0:0be38b583cf7 230
uehara00 0:0be38b583cf7 231 case CURSOR_DATE_TIME_CENTURY:
uehara00 0:0be38b583cf7 232 RTC_stop_and_read_date(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 233 century = increment_bcd(century, 0x00, 0x01);
uehara00 0:0be38b583cf7 234 d = bcd_days_in_month(century, bcd_year, bcd_month);
uehara00 0:0be38b583cf7 235 if(bcd_day > d) {
uehara00 0:0be38b583cf7 236 bcd_day = d;
uehara00 0:0be38b583cf7 237 }
uehara00 0:0be38b583cf7 238 weekday = bcd_date_to_weekday(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 239 RTC_write_date_and_start(century, bcd_year, bcd_month, bcd_day, weekday);
uehara00 0:0be38b583cf7 240 break;
uehara00 0:0be38b583cf7 241
uehara00 0:0be38b583cf7 242 case CURSOR_DATE_TIME_YEAR:
uehara00 0:0be38b583cf7 243 RTC_stop_and_read_date(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 244 bcd_year = increment_bcd(bcd_year, 0x00, 0x99);
uehara00 0:0be38b583cf7 245 d = bcd_days_in_month(century, bcd_year, bcd_month);
uehara00 0:0be38b583cf7 246 if(bcd_day > d) {
uehara00 0:0be38b583cf7 247 bcd_day = d;
uehara00 0:0be38b583cf7 248 }
uehara00 0:0be38b583cf7 249 weekday = bcd_date_to_weekday(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 250 RTC_write_date_and_start(century, bcd_year, bcd_month, bcd_day, weekday);
uehara00 0:0be38b583cf7 251 break;
uehara00 0:0be38b583cf7 252
uehara00 0:0be38b583cf7 253 case CURSOR_DATE_TIME_MONTH:
uehara00 0:0be38b583cf7 254 RTC_stop_and_read_date(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 255 bcd_month = increment_bcd(bcd_month, 0x01, 0x12);
uehara00 0:0be38b583cf7 256 d = bcd_days_in_month(century, bcd_year, bcd_month);
uehara00 0:0be38b583cf7 257 if(bcd_day > d) {
uehara00 0:0be38b583cf7 258 bcd_day = d;
uehara00 0:0be38b583cf7 259 }
uehara00 0:0be38b583cf7 260 weekday = bcd_date_to_weekday(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 261 RTC_write_date_and_start(century, bcd_year, bcd_month, bcd_day, weekday);
uehara00 0:0be38b583cf7 262 break;
uehara00 0:0be38b583cf7 263
uehara00 0:0be38b583cf7 264 case CURSOR_DATE_TIME_DAY:
uehara00 0:0be38b583cf7 265 RTC_stop_and_read_date(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 266 bcd_day = increment_bcd(bcd_day, 0x01, bcd_days_in_month(century, bcd_year, bcd_month));
uehara00 0:0be38b583cf7 267 weekday = bcd_date_to_weekday(century, bcd_year, bcd_month, bcd_day);
uehara00 0:0be38b583cf7 268 RTC_write_date_and_start(century, bcd_year, bcd_month, bcd_day, weekday);
uehara00 0:0be38b583cf7 269 break;
uehara00 0:0be38b583cf7 270
uehara00 0:0be38b583cf7 271 case CURSOR_DATE_TIME_HOUR:
uehara00 0:0be38b583cf7 272 t = RTC_stop_and_read1(RTC_REG_HOUR) & 0x3F;
uehara00 0:0be38b583cf7 273 t = increment_bcd(t, 0x00, 0x23);
uehara00 0:0be38b583cf7 274 RTC_write1_and_start(RTC_REG_HOUR, t);
uehara00 0:0be38b583cf7 275 break;
uehara00 0:0be38b583cf7 276
uehara00 0:0be38b583cf7 277 case CURSOR_DATE_TIME_MINUTE:
uehara00 0:0be38b583cf7 278 t = RTC_stop_and_read1(RTC_REG_MINUTE) & 0x7F;
uehara00 0:0be38b583cf7 279 t = increment_bcd(t, 0x00, 0x59);
uehara00 0:0be38b583cf7 280 RTC_write1_and_start(RTC_REG_MINUTE, t);
uehara00 0:0be38b583cf7 281 break;
uehara00 0:0be38b583cf7 282
uehara00 0:0be38b583cf7 283 case CURSOR_DATE_TIME_SECOND:
uehara00 0:0be38b583cf7 284 t = RTC_stop_and_read1(RTC_REG_SECOND) & 0x7f;
uehara00 0:0be38b583cf7 285 t = 0x00;
uehara00 0:0be38b583cf7 286 RTC_write1_and_start(RTC_REG_SECOND, t);
uehara00 0:0be38b583cf7 287 break;
uehara00 0:0be38b583cf7 288 }
uehara00 0:0be38b583cf7 289 }
uehara00 0:0be38b583cf7 290 }