diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/common/timefuncs.c | 2 | ||||
-rw-r--r-- | firmware/include/timefuncs.h | 2 | ||||
-rw-r--r-- | firmware/usbstack/usb_storage.c | 17 |
3 files changed, 20 insertions, 1 deletions
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c index af4b596dd0..cffdb3951a 100644 --- a/firmware/common/timefuncs.c +++ b/firmware/common/timefuncs.c | |||
@@ -105,6 +105,7 @@ int set_time(const struct tm *tm) | |||
105 | #endif /* RTC */ | 105 | #endif /* RTC */ |
106 | } | 106 | } |
107 | 107 | ||
108 | #if CONFIG_RTC | ||
108 | void set_day_of_week(struct tm *tm) | 109 | void set_day_of_week(struct tm *tm) |
109 | { | 110 | { |
110 | int y=tm->tm_year+1900; | 111 | int y=tm->tm_year+1900; |
@@ -115,4 +116,5 @@ void set_day_of_week(struct tm *tm) | |||
115 | if(m == 0 || m == 1) y--; | 116 | if(m == 0 || m == 1) y--; |
116 | tm->tm_wday = (d + mo[m] + y + y/4 - y/100 + y/400) % 7; | 117 | tm->tm_wday = (d + mo[m] + y + y/4 - y/100 + y/400) % 7; |
117 | } | 118 | } |
119 | #endif /* CONFIG_RTC */ | ||
118 | 120 | ||
diff --git a/firmware/include/timefuncs.h b/firmware/include/timefuncs.h index b7e9be53c6..4c5f0fbb42 100644 --- a/firmware/include/timefuncs.h +++ b/firmware/include/timefuncs.h | |||
@@ -30,8 +30,8 @@ struct tm *get_time(void); | |||
30 | int set_time(const struct tm *tm); | 30 | int set_time(const struct tm *tm); |
31 | #if CONFIG_RTC | 31 | #if CONFIG_RTC |
32 | bool valid_time(const struct tm *tm); | 32 | bool valid_time(const struct tm *tm); |
33 | #endif | ||
34 | void set_day_of_week(struct tm *tm); | 33 | void set_day_of_week(struct tm *tm); |
34 | #endif | ||
35 | 35 | ||
36 | #endif /* _TIMEFUNCS_H_ */ | 36 | #endif /* _TIMEFUNCS_H_ */ |
37 | 37 | ||
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index 4954c9272e..0b9e6a95db 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c | |||
@@ -31,7 +31,9 @@ | |||
31 | /* Needed to get at the audio buffer */ | 31 | /* Needed to get at the audio buffer */ |
32 | #include "audio.h" | 32 | #include "audio.h" |
33 | #include "usb_storage.h" | 33 | #include "usb_storage.h" |
34 | #if CONFIG_RTC | ||
34 | #include "timefuncs.h" | 35 | #include "timefuncs.h" |
36 | #endif | ||
35 | 37 | ||
36 | /* For sector filter macro definitions */ | 38 | /* For sector filter macro definitions */ |
37 | #include "usb-target.h" | 39 | #include "usb-target.h" |
@@ -299,7 +301,9 @@ static void send_command_result(void *data,int size); | |||
299 | static void send_command_failed_result(void); | 301 | static void send_command_failed_result(void); |
300 | static void send_block_data(void *data,int size); | 302 | static void send_block_data(void *data,int size); |
301 | static void receive_block_data(void *data,int size); | 303 | static void receive_block_data(void *data,int size); |
304 | #if CONFIG_RTC | ||
302 | static void receive_time(void); | 305 | static void receive_time(void); |
306 | #endif | ||
303 | static void fill_inquiry(IF_MD_NONVOID(int lun)); | 307 | static void fill_inquiry(IF_MD_NONVOID(int lun)); |
304 | static void send_and_read_next(void); | 308 | static void send_and_read_next(void); |
305 | static bool ejected[NUM_DRIVES]; | 309 | static bool ejected[NUM_DRIVES]; |
@@ -322,11 +326,14 @@ static enum { | |||
322 | SENDING_RESULT, | 326 | SENDING_RESULT, |
323 | SENDING_FAILED_RESULT, | 327 | SENDING_FAILED_RESULT, |
324 | RECEIVING_BLOCKS, | 328 | RECEIVING_BLOCKS, |
329 | #if CONFIG_RTC | ||
325 | RECEIVING_TIME, | 330 | RECEIVING_TIME, |
331 | #endif | ||
326 | WAITING_FOR_CSW_COMPLETION_OR_COMMAND, | 332 | WAITING_FOR_CSW_COMPLETION_OR_COMMAND, |
327 | WAITING_FOR_CSW_COMPLETION | 333 | WAITING_FOR_CSW_COMPLETION |
328 | } state = WAITING_FOR_COMMAND; | 334 | } state = WAITING_FOR_COMMAND; |
329 | 335 | ||
336 | #if CONFIG_RTC | ||
330 | static void yearday_to_daymonth(int yd, int y, int *d, int *m) | 337 | static void yearday_to_daymonth(int yd, int y, int *d, int *m) |
331 | { | 338 | { |
332 | static const char tnl[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | 339 | static const char tnl[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; |
@@ -351,6 +358,7 @@ static void yearday_to_daymonth(int yd, int y, int *d, int *m) | |||
351 | *d = yd+1; | 358 | *d = yd+1; |
352 | *m = i; | 359 | *m = i; |
353 | } | 360 | } |
361 | #endif /* CONFIG_RTC */ | ||
354 | 362 | ||
355 | static bool check_disk_present(IF_MD_NONVOID(int volume)) | 363 | static bool check_disk_present(IF_MD_NONVOID(int volume)) |
356 | { | 364 | { |
@@ -491,7 +499,9 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length) | |||
491 | { | 499 | { |
492 | (void)ep; | 500 | (void)ep; |
493 | struct command_block_wrapper* cbw = (void*)cbw_buffer; | 501 | struct command_block_wrapper* cbw = (void*)cbw_buffer; |
502 | #if CONFIG_RTC | ||
494 | struct tm tm; | 503 | struct tm tm; |
504 | #endif | ||
495 | 505 | ||
496 | logf("transfer result for ep %d/%d %X %d", ep,dir,status, length); | 506 | logf("transfer result for ep %d/%d %X %d", ep,dir,status, length); |
497 | switch(state) { | 507 | switch(state) { |
@@ -654,6 +664,7 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length) | |||
654 | cur_sense_data.ascq=0; | 664 | cur_sense_data.ascq=0; |
655 | } | 665 | } |
656 | break; | 666 | break; |
667 | #if CONFIG_RTC | ||
657 | case RECEIVING_TIME: | 668 | case RECEIVING_TIME: |
658 | tm.tm_year=(tb.transfer_buffer[0]<<8)+tb.transfer_buffer[1] - 1900; | 669 | tm.tm_year=(tb.transfer_buffer[0]<<8)+tb.transfer_buffer[1] - 1900; |
659 | tm.tm_yday=(tb.transfer_buffer[2]<<8)+tb.transfer_buffer[3]; | 670 | tm.tm_yday=(tb.transfer_buffer[2]<<8)+tb.transfer_buffer[3]; |
@@ -665,6 +676,7 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length) | |||
665 | set_time(&tm); | 676 | set_time(&tm); |
666 | send_csw(UMS_STATUS_GOOD); | 677 | send_csw(UMS_STATUS_GOOD); |
667 | break; | 678 | break; |
679 | #endif /* CONFIG_RTC */ | ||
668 | } | 680 | } |
669 | } | 681 | } |
670 | 682 | ||
@@ -1131,6 +1143,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) | |||
1131 | } | 1143 | } |
1132 | break; | 1144 | break; |
1133 | 1145 | ||
1146 | #if CONFIG_RTC | ||
1134 | case SCSI_WRITE_BUFFER: | 1147 | case SCSI_WRITE_BUFFER: |
1135 | if(cbw->command_block[1]==1 /* mode = vendor specific */ | 1148 | if(cbw->command_block[1]==1 /* mode = vendor specific */ |
1136 | && cbw->command_block[2]==0 /* buffer id = 0 */ | 1149 | && cbw->command_block[2]==0 /* buffer id = 0 */ |
@@ -1148,6 +1161,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) | |||
1148 | && cbw->command_block[9]==0) | 1161 | && cbw->command_block[9]==0) |
1149 | receive_time(); | 1162 | receive_time(); |
1150 | break; | 1163 | break; |
1164 | #endif /* CONFIG_RTC */ | ||
1151 | 1165 | ||
1152 | default: | 1166 | default: |
1153 | logf("scsi unknown cmd %x",cbw->command_block[0x0]); | 1167 | logf("scsi unknown cmd %x",cbw->command_block[0x0]); |
@@ -1177,11 +1191,14 @@ static void send_command_failed_result(void) | |||
1177 | state = SENDING_FAILED_RESULT; | 1191 | state = SENDING_FAILED_RESULT; |
1178 | } | 1192 | } |
1179 | 1193 | ||
1194 | #if CONFIG_RTC | ||
1180 | static void receive_time(void) | 1195 | static void receive_time(void) |
1181 | { | 1196 | { |
1182 | usb_drv_recv(ep_out, tb.transfer_buffer, 12); | 1197 | usb_drv_recv(ep_out, tb.transfer_buffer, 12); |
1183 | state = RECEIVING_TIME; | 1198 | state = RECEIVING_TIME; |
1184 | } | 1199 | } |
1200 | #endif /* CONFIG_RTC */ | ||
1201 | |||
1185 | static void receive_block_data(void *data,int size) | 1202 | static void receive_block_data(void *data,int size) |
1186 | { | 1203 | { |
1187 | usb_drv_recv(ep_out, data, size); | 1204 | usb_drv_recv(ep_out, data, size); |