Mercurial > ~darius > hgwebdir.cgi > avr-lib
annotate ds1307.c @ 15:a50a054d060c
- Make OWREADBUS work properly.
- Fix debug commands.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Wed, 08 Feb 2012 10:36:26 +1030 |
parents | 119688bb743f |
children | b5e4591b6570 |
rev | line source |
---|---|
0 | 1 /* |
2 * Interface to a DS1307 | |
3 * | |
4 * Copyright (c) 2008 | |
5 * Daniel O'Connor <darius@dons.net.au>. All rights reserved. | |
6 * | |
7 * Redistribution and use in source and binary forms, with or without | |
8 * modification, are permitted provided that the following conditions | |
9 * are met: | |
10 * 1. Redistributions of source code must retain the above copyright | |
11 * notice, this list of conditions and the following disclaimer. | |
12 * 2. Redistributions in binary form must reproduce the above copyright | |
13 * notice, this list of conditions and the following disclaimer in the | |
14 * documentation and/or other materials provided with the distribution. | |
15 * | |
16 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE | |
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 * SUCH DAMAGE. | |
27 */ | |
28 | |
29 #include <stdio.h> | |
30 #include <stdlib.h> | |
31 #include <inttypes.h> | |
32 #include <avr/io.h> | |
33 #include <avr/pgmspace.h> | |
34 #include <util/twi.h> | |
35 #include <util/delay.h> | |
36 | |
37 #include "ds1307.h" | |
38 | |
39 // #define TWDEBUG | |
40 | |
8
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
41 /* Helper code to wait for the TWCR to do something */ |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
42 #define WAITFORTWINT() do { \ |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
43 uint8_t i; \ |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
44 for (i = 0; i < 255 && (TWCR & _BV(TWINT)) == 0; i++) \ |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
45 _delay_ms(1); \ |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
46 if (i == 255) \ |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
47 return(IIC_NORESP); \ |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
48 } while (0) |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
49 |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
50 |
0 | 51 /* |
52 * ds1307_init | |
53 * | |
54 * Setup TWI interface | |
55 * | |
56 */ | |
57 int | |
58 ds1307_init(void) { | |
3
15d89caaf516
Add support for single UART devices, although untested apart from a compile.
darius@Inchoate
parents:
0
diff
changeset
|
59 #ifdef PRR |
6
3da232f97e81
Invert the bit mask, we only want to turn off this bit, not everything.
darius@inchoate.localdomain
parents:
3
diff
changeset
|
60 PRR &= ~_BV(PRTWI); /* Power TWI on - note that the |
0 | 61 * datasheet says this is already 0 at |
62 * power on.. */ | |
3
15d89caaf516
Add support for single UART devices, although untested apart from a compile.
darius@Inchoate
parents:
0
diff
changeset
|
63 #endif |
0 | 64 TWSR = 0; /* TWI Prescaler = 1 */ |
65 #if F_CPU < 3600000UL | |
66 TWBR = 10; /* Smallest valid TWBR */ | |
67 #else | |
68 TWBR = (F_CPU / 100000UL - 16) / 2; | |
69 #endif | |
70 | |
71 TWCR = _BV(TWEN); | |
72 | |
73 return(0); | |
74 } | |
75 | |
76 /* | |
77 * iic_read | |
78 * | |
79 * Read len bytes of data from address adr in slave sla into | |
80 * data. Presume that the slave auto-increments the address on | |
81 * successive reads. | |
82 * | |
83 * Returns the number of bytes read, or the following on failure. | |
84 * IIC_STFAIL Could generate START condition (broken bus or busy). | |
85 * IIC_FAILARB Failed bus arbitration. | |
86 * IIC_SLNAK Slave NAK'd. | |
87 * IIC_NOREPLY No reply (no such slave?) | |
88 * IIC_UNKNOWN Unexpected return from TWI reg. | |
89 * | |
90 * Heaviy cribbed from twitest.c by Joerg Wunsch | |
91 */ | |
92 int8_t | |
93 iic_read(uint8_t *data, uint8_t len, uint8_t adr, uint8_t sla) { | |
94 uint8_t twst, twcr, cnt; | |
95 | |
96 /* Generate START */ | |
97 TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN); | |
98 | |
99 /* Spin waiting for START to be generated */ | |
8
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
100 WAITFORTWINT(); |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
101 |
0 | 102 switch (twst = TW_STATUS) { |
103 case TW_REP_START: /* OK but shouldn't happen */ | |
104 case TW_START: | |
105 break; | |
106 | |
107 case TW_MT_ARB_LOST: | |
108 return IIC_FAILARB; | |
109 break; | |
110 | |
111 default: | |
112 /* Not in start condition, bail */ | |
113 return IIC_UNKNOWN; | |
114 } | |
115 #ifdef TWDEBUG | |
116 printf_P(PSTR("Sent START\r\n")); | |
117 #endif | |
118 /* Send SLA+W */ | |
119 TWDR = sla | TW_WRITE; | |
120 TWCR = _BV(TWINT) | _BV(TWEN); | |
121 | |
122 /* Spin waiting for a response to be generated */ | |
8
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
123 WAITFORTWINT(); |
0 | 124 |
125 #ifdef TWDEBUG | |
126 printf_P(PSTR("Sent SLA+W\r\n")); | |
127 #endif | |
128 switch (twst = TW_STATUS) { | |
129 case TW_MT_SLA_ACK: | |
130 break; | |
131 | |
132 case TW_MT_SLA_NACK: | |
133 /* Send STOP */ | |
134 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
135 return IIC_SLNAK; | |
136 | |
137 case TW_MT_ARB_LOST: | |
138 return IIC_FAILARB; | |
139 break; | |
140 | |
141 default: | |
142 /* Send STOP */ | |
143 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
144 return IIC_UNKNOWN; | |
145 } | |
146 /* Send address */ | |
147 TWDR = adr; | |
148 TWCR = _BV(TWINT) | _BV(TWEN); | |
149 | |
150 /* Spin waiting for a response to be generated */ | |
8
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
151 WAITFORTWINT(); |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
152 |
0 | 153 #ifdef TWDEBUG |
154 printf_P(PSTR("Sent address\r\n")); | |
155 #endif | |
156 switch ((twst = TW_STATUS)) { | |
157 case TW_MT_DATA_ACK: | |
158 break; | |
159 | |
160 case TW_MT_DATA_NACK: | |
161 /* Send STOP */ | |
162 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
163 return IIC_SLNAK; | |
164 | |
165 case TW_MT_ARB_LOST: | |
166 return IIC_FAILARB; | |
167 | |
168 default: | |
169 /* Send STOP */ | |
170 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
171 return IIC_UNKNOWN; | |
172 } | |
173 | |
174 /* Master receive cycle */ | |
175 TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN); | |
8
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
176 |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
177 /* wait for transmission */ |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
178 WAITFORTWINT(); |
0 | 179 |
180 #ifdef TWDEBUG | |
181 printf_P(PSTR("Sent START\r\n")); | |
182 #endif | |
183 switch ((twst = TW_STATUS)) { | |
184 case TW_REP_START: /* OK but shouldn't happen */ | |
185 case TW_START: | |
186 break; | |
187 | |
188 case TW_MT_ARB_LOST: | |
189 return IIC_FAILARB; | |
190 | |
191 default: | |
192 /* Send STOP */ | |
193 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
194 return IIC_UNKNOWN; | |
195 } | |
196 | |
197 /* send SLA+R */ | |
198 TWDR = sla | TW_READ; | |
199 TWCR = _BV(TWINT) | _BV(TWEN); /* clear interrupt to start transmission */ | |
200 | |
201 /* Spin waiting for a response to be generated */ | |
8
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
202 WAITFORTWINT(); |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
203 |
0 | 204 #ifdef TWDEBUG |
205 printf_P(PSTR("Sent SLA+R\r\n")); | |
206 #endif | |
207 switch ((twst = TW_STATUS)) { | |
208 case TW_MR_SLA_ACK: | |
209 break; | |
210 | |
211 case TW_MR_SLA_NACK: | |
212 /* Send STOP */ | |
213 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
214 return IIC_SLNAK; | |
215 | |
216 case TW_MR_ARB_LOST: | |
217 return IIC_FAILARB; | |
218 | |
219 default: | |
220 /* Send STOP */ | |
221 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
222 return IIC_UNKNOWN; | |
223 } | |
224 | |
225 cnt = 0; | |
226 for (twcr = _BV(TWINT) | _BV(TWEN) | _BV(TWEA); | |
227 len > 0; len--) { | |
228 /* Send NAK on last byte */ | |
229 if (len == 1) | |
230 twcr = _BV(TWINT) | _BV(TWEN); | |
231 TWCR = twcr; /* clear int to start transmission */ | |
232 /* Spin waiting for a response to be generated */ | |
8
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
233 WAITFORTWINT(); |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
234 |
0 | 235 #ifdef TWDEBUG |
236 printf_P(PSTR("Data request done\r\n")); | |
237 #endif | |
238 switch ((twst = TW_STATUS)) { | |
239 case TW_MR_DATA_NACK: | |
240 /* Send STOP */ | |
241 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
242 //printf_P(PSTR("NACK on byte %d\r\n"), cnt); | |
243 return cnt; | |
244 | |
245 case TW_MR_DATA_ACK: | |
246 *data++ = TWDR; | |
247 //printf_P(PSTR("ACK on byte %d for 0x%02x\r\n"), cnt, *(data - 1)); | |
248 cnt++; | |
249 break; | |
250 | |
251 default: | |
252 return IIC_UNKNOWN; | |
253 } | |
254 } | |
255 | |
256 /* Send STOP */ | |
257 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
258 return cnt; | |
259 } | |
260 | |
261 /* | |
262 * iic_write | |
263 * | |
264 * Write len bytes of data from address adr in slave sla into | |
265 * data. Presume that the slave auto-increments the address on | |
266 * successive writes. | |
267 * | |
268 * Returns the number of bytes read, or the following on failure. | |
269 * IIC_STFAIL Could generate START condition (broken bus or busy). | |
270 * IIC_FAILARB Failed bus arbitration. | |
271 * IIC_SLNAK Slave NAK'd. | |
272 * IIC_NOREPLY No reply (no such slave?) | |
273 * IIC_UNKNOWN Unexpected return from TWI reg. | |
274 * | |
275 * Heaviy cribbed from twitest.c by Joerg Wunsch | |
276 */ | |
277 int8_t | |
278 iic_write(uint8_t *data, uint8_t len, uint8_t adr, uint8_t sla) { | |
279 uint8_t twst, cnt; | |
280 | |
281 /* Generate START */ | |
282 TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN); | |
283 | |
284 /* Spin waiting for START to be generated */ | |
8
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
285 WAITFORTWINT(); |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
286 |
0 | 287 switch (twst = TW_STATUS) { |
288 case TW_REP_START: /* OK but shouldn't happen */ | |
289 case TW_START: | |
290 break; | |
291 | |
292 case TW_MT_ARB_LOST: | |
293 return IIC_FAILARB; | |
294 break; | |
295 | |
296 default: | |
297 /* Not in start condition, bail */ | |
298 return IIC_UNKNOWN; | |
299 } | |
300 #ifdef TWDEBUG | |
301 printf_P(PSTR("Sent START\r\n")); | |
302 #endif | |
303 | |
304 /* Send SLA+W */ | |
305 TWDR = sla | TW_WRITE; | |
306 TWCR = _BV(TWINT) | _BV(TWEN); | |
307 | |
308 /* Spin waiting for a response to be generated */ | |
8
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
309 WAITFORTWINT(); |
0 | 310 |
311 #ifdef TWDEBUG | |
312 printf_P(PSTR("Sent SLA+W\r\n")); | |
313 #endif | |
314 switch (twst = TW_STATUS) { | |
315 case TW_MT_SLA_ACK: | |
316 break; | |
317 | |
318 case TW_MT_SLA_NACK: | |
319 /* Send STOP */ | |
320 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
321 return IIC_SLNAK; | |
322 | |
323 case TW_MT_ARB_LOST: | |
324 return IIC_FAILARB; | |
325 break; | |
326 | |
327 default: | |
328 /* Send STOP */ | |
329 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
330 return IIC_UNKNOWN; | |
331 } | |
332 /* Send address */ | |
333 TWDR = adr; | |
334 TWCR = _BV(TWINT) | _BV(TWEN); | |
335 | |
336 /* Spin waiting for a response to be generated */ | |
8
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
337 WAITFORTWINT(); |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
338 |
0 | 339 #ifdef TWDEBUG |
340 printf_P(PSTR("Sent address\r\n")); | |
341 #endif | |
342 switch ((twst = TW_STATUS)) { | |
343 case TW_MT_DATA_ACK: | |
344 break; | |
345 | |
346 case TW_MT_DATA_NACK: | |
347 /* Send STOP */ | |
348 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
349 return IIC_SLNAK; | |
350 | |
351 case TW_MT_ARB_LOST: | |
352 return IIC_FAILARB; | |
353 | |
354 default: | |
355 /* Send STOP */ | |
356 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
357 return IIC_UNKNOWN; | |
358 } | |
359 | |
360 cnt = 0; | |
361 for (; len > 0; len--) { | |
362 TWDR = *data++; | |
363 TWCR = _BV(TWINT) | _BV(TWEN); | |
364 | |
365 /* Spin waiting for a response to be generated */ | |
8
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
366 WAITFORTWINT(); |
119688bb743f
Don't spin forever waiting for the TWI hardware to do something.
darius@dons.net.au
parents:
6
diff
changeset
|
367 |
0 | 368 #ifdef TWDEBUG |
369 printf_P(PSTR("Data sent\r\n")); | |
370 #endif | |
371 switch ((twst = TW_STATUS)) { | |
372 case TW_MT_DATA_NACK: | |
373 /* Send STOP */ | |
374 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
375 return cnt; | |
376 | |
377 case TW_MT_DATA_ACK: | |
378 cnt++; | |
379 break; | |
380 | |
381 default: | |
382 return IIC_UNKNOWN; | |
383 } | |
384 } | |
385 | |
386 /* Send STOP */ | |
387 TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); | |
388 return cnt; | |
389 } | |
390 | |
391 /* | |
392 * ds1307_gettod | |
393 * | |
394 * Read time of day from DS1307 into time | |
395 * | |
396 * Note that we canonify to 24hr mode. | |
397 * | |
398 */ | |
399 int8_t | |
400 ds1307_gettod(ds1307raw_t *time) { | |
401 int8_t len; | |
402 | |
403 len = iic_read((uint8_t *)time, sizeof(ds1307raw_t) + 1, 0, DS1307_ADR); | |
404 if (len < 0) { | |
405 printf_P(PSTR("iic_read failed - %d\r\n"), len); | |
406 return(0); | |
407 } | |
408 | |
409 #if 1 | |
410 if (len != sizeof(ds1307raw_t)) { | |
411 printf_P(PSTR("Only got %d bytes (vs %d)\r\n"), len, sizeof(ds1307raw_t)); | |
412 return(0); | |
413 } | |
414 #endif | |
415 | |
416 #ifdef TWDEBUG | |
417 int i; | |
418 | |
419 for (i = 0; i < len; i++) | |
420 printf_P(PSTR("0x%02x: 0x%02x\r\n"), i, *(((uint8_t *)time) + i)); | |
421 #endif | |
422 | |
423 return(1); | |
424 } | |
425 | |
426 /* | |
427 * ds1307_settod | |
428 * | |
429 * Set the DS1307 with the supplied time, format like so | |
430 * sc 2008/10/29 23:45:30 | |
431 * | |
432 */ | |
433 int8_t | |
434 ds1307_settod(char *date) { | |
435 ds1307raw_t rtime; | |
436 uint16_t year; | |
437 uint8_t i, month, day, hour, min, sec; | |
438 | |
439 if ((i = sscanf_P(date, PSTR("%hu/%hhd/%hhd %hhd:%hhd:%hhd"), &year, &month, &day, &hour, &min, &sec)) != 6) { | |
440 printf_P(PSTR("Can't parse date\r\n")); | |
441 return(0); | |
442 } | |
443 | |
444 if (year > 1900) | |
445 year -= 1900; | |
446 | |
447 rtime.split.year10 = year / 10; | |
448 rtime.split.year = year % 10; | |
449 rtime.split.month10 = month / 10; | |
450 rtime.split.month = month % 10; | |
451 rtime.split.day10 = day / 10; | |
452 rtime.split.day = day % 10; | |
453 rtime.split.pmam = ((hour / 10) & 0x02) >> 1; | |
454 rtime.split.hour10 = (hour / 10) & 0x01; | |
455 rtime.split.hour = hour % 10; | |
456 rtime.split.min10 = min / 10; | |
457 rtime.split.min = min % 10; | |
458 rtime.split.sec10 = sec / 10; | |
459 rtime.split.sec = sec % 10; | |
460 | |
461 rtime.split.ch = 0; // Enable clock | |
462 rtime.split.s1224 = 0; // 24 hour mode | |
463 rtime.split.dow = 0; // XXX: unused | |
464 rtime.split.out = 0; // No clock out | |
465 | |
466 #ifdef TWDEBUG | |
467 for (i = 0; i < sizeof(ds1307raw_t); i++) | |
468 printf_P(PSTR("0x%02x: 0x%02x\r\n"), i, *(((uint8_t *)&rtime) + i)); | |
469 #endif | |
470 if ((i = iic_write((uint8_t *)&rtime, sizeof(ds1307raw_t), 0, DS1307_ADR)) != sizeof(ds1307raw_t)) | |
471 printf_P(PSTR("Can't write to RTC, sent %d (vs %d)\r\n"), i, sizeof(ds1307raw_t)); | |
472 | |
473 return(1); | |
474 } | |
475 | |
476 /* | |
477 * ds1307_printtime | |
478 * | |
479 * Print the time in rtime with trailer | |
480 * | |
481 */ | |
482 void | |
483 ds1307_printtime(char *leader, char *trailer) { | |
484 ds1307raw_t rtime; | |
485 uint8_t hour; | |
486 | |
487 if (ds1307_gettod(&rtime) != 1) | |
488 return; | |
489 | |
490 // Handle 12/24 hour time | |
491 hour = rtime.split.hour10 * 10 + rtime.split.hour; | |
492 if (rtime.split.s1224) { | |
493 if (rtime.split.pmam) | |
494 hour += 12; | |
495 } else | |
496 hour += (rtime.split.pmam << 1) * 10; | |
497 | |
498 printf_P(PSTR("%S%04d/%02d/%02d %02d:%02d:%02d%S"), leader, | |
499 1900 + rtime.split.year10 * 10 + rtime.split.year, | |
500 rtime.split.month10 * 10 + rtime.split.month, | |
501 rtime.split.day10 * 10 + rtime.split.day, | |
502 hour, | |
503 rtime.split.min10 * 10 + rtime.split.min, | |
504 rtime.split.sec10 * 10 + rtime.split.sec, | |
505 trailer); | |
506 } |