Revisión | 10 (tree) |
---|---|
Tiempo | 2012-06-18 02:19:04 |
Autor | tekken_boss |
000.001.010: 2012/06/18 02:14 : A part of end user mode is added.
* "UI" A part of end user mode is added.
* Compilable.
* End user mode is working.
@@ -26,7 +26,7 @@ | ||
26 | 26 | int sl811_initialize(void); |
27 | 27 | int sl811_process(void); |
28 | 28 | int ui_function_usb(UI_COMMAND uicmd); |
29 | -unsigned char sl811_status(unsigned char req); | |
29 | +unsigned char sl811_status(REQUEST_TO_CLASS req); | |
30 | 30 | unsigned char sl811_ctrl_receive(P_SETUP_FORMAT p_fmt); |
31 | 31 | void sl811_buffer_copy( unsigned char* p_buf, int size); |
32 | 32 | unsigned char sl811_bulk_out_request( unsigned char* p_buf, int size ); |
@@ -320,7 +320,7 @@ | ||
320 | 320 | // ------------------------------------------- |
321 | 321 | // Query for SL811 device class status |
322 | 322 | // ------------------------------------------- |
323 | -unsigned char sl811_status(unsigned char req) { | |
323 | +unsigned char sl811_status(REQUEST_TO_CLASS req) { | |
324 | 324 | |
325 | 325 | switch( req ) { |
326 | 326 | case CLASS_REQ_RESET: |
@@ -15,9 +15,10 @@ | ||
15 | 15 | |
16 | 16 | #define SRCVER_MAJOR 0 |
17 | 17 | #define SRCVER_MINOR 1 |
18 | -#define SRCVER_BUILD 9 | |
18 | +#define SRCVER_BUILD 10 | |
19 | 19 | |
20 | 20 | /* -------------------------------------------------------------------- |
21 | +000.001.010: 2012/06/18 02:14 : A part of enduser mode is added. | |
21 | 22 | 000.001.009: 2012/06/13 18:35 : Fine tuning of SCI handshake. |
22 | 23 | 000.001.008: 2012/06/13 16:24 : Default setting for SCI was changed. |
23 | 24 | 000.001.007: 2012/06/13 14:45 : Fine tuning of SL811 driver class. |
@@ -10,20 +10,21 @@ | ||
10 | 10 | #include "fat.h" |
11 | 11 | #include "serial.h" |
12 | 12 | |
13 | -// change directory | |
14 | -// read file | |
13 | +// debug options | |
14 | +// #define UI_FAT_DIR_VIEW_CHECK_SIZE | |
15 | 15 | |
16 | 16 | extern unsigned char eram_start; |
17 | 17 | extern unsigned char eram_end; |
18 | 18 | |
19 | +// for local UI control | |
20 | +enum { | |
21 | + DIR_VIEW_MODE, | |
22 | + FILE_VIEW_MODE, | |
23 | + READ_FILE_MODE, | |
24 | +}; | |
25 | + | |
26 | + | |
19 | 27 | #define MAX_RETRY 20 |
20 | -// Keep file list on current directory | |
21 | -typedef struct { | |
22 | - unsigned long FirstCluster; | |
23 | - unsigned long FileSize; | |
24 | - char Name[13]; | |
25 | - unsigned char Attributes; | |
26 | -} DIR_INFO, *P_DIR_INFO; | |
27 | 28 | |
28 | 29 | // Search status for DIR information |
29 | 30 | typedef struct { |
@@ -34,13 +35,6 @@ | ||
34 | 35 | unsigned int ByteOffset; |
35 | 36 | } DIR_ENTRY, *P_DIR_ENTRY; |
36 | 37 | |
37 | -// Read file status | |
38 | -typedef struct { | |
39 | - unsigned long ReadSize; | |
40 | - unsigned long FileSize; | |
41 | - unsigned long CurrentCluster; | |
42 | - unsigned long CurrentSector; | |
43 | -} READ_FILE_STS, *P_READ_FILE_STS; | |
44 | 38 | |
45 | 39 | // FAT position |
46 | 40 | typedef struct { |
@@ -69,6 +63,7 @@ | ||
69 | 63 | int fat_initialize(void); |
70 | 64 | int fat_process(void); |
71 | 65 | int ui_function_fat(UI_COMMAND uicmd); |
66 | +unsigned char fat_status(REQUEST_TO_CLASS req); | |
72 | 67 | unsigned char fat_change_directory( unsigned long cluster ); |
73 | 68 | unsigned char fat_read_file( unsigned long cluster, unsigned long file_size ); |
74 | 69 |
@@ -86,6 +81,10 @@ | ||
86 | 81 | // Variables |
87 | 82 | // ------------------------------------------- |
88 | 83 | // Global |
84 | +unsigned int TotalFileNum; | |
85 | +READ_FILE_STS ReadFileStatus; | |
86 | +DIR_INFO CurrentDirInfo[MAX_FILE_IN_DIR]; // Keep file list on current directory | |
87 | + | |
89 | 88 | // Locals |
90 | 89 | static int fat_disable_timer; |
91 | 90 | static int window_disable_timer; |
@@ -108,15 +107,12 @@ | ||
108 | 107 | static unsigned long CountofClusters; |
109 | 108 | |
110 | 109 | static unsigned long CurrentWindowSector; |
111 | -static unsigned int TotalFileNum; | |
112 | 110 | static unsigned char IsFAT32; |
113 | 111 | |
114 | 112 | static DIR_ENTRY dir_entry; |
115 | -static DIR_INFO dir_info[MAX_FILE_IN_DIR]; // Keep file list on current directory | |
116 | -static READ_FILE_STS ReadFileStatus; | |
117 | 113 | static unsigned char WindowBuffer[WINDOW_SIZE]; |
118 | 114 | |
119 | -static unsigned long current_byte_cnt; | |
115 | +static unsigned long current_byte_cnt; // Use this only in ui_function_fat_dir(). | |
120 | 116 | |
121 | 117 | enum fat_error_code { |
122 | 118 | FAT_ERR_NONE, |
@@ -224,6 +220,18 @@ | ||
224 | 220 | } |
225 | 221 | |
226 | 222 | // ------------------------------------------- |
223 | +// Query for FAT class status | |
224 | +// ------------------------------------------- | |
225 | +unsigned char fat_status(REQUEST_TO_CLASS req) { | |
226 | + // Status return | |
227 | + if( fat_proc < FAT_IDLE ) return CLASS_STS_RESET_IN_PROGRESS; | |
228 | + else if( fat_proc == FAT_IDLE ) return CLASS_STS_READY; | |
229 | + else if( fat_proc == FAT_ERROR_STOP ) return CLASS_STS_ERROR_STOP; | |
230 | + else return CLASS_STS_NOT_READY; | |
231 | +} | |
232 | + | |
233 | + | |
234 | +// ------------------------------------------- | |
227 | 235 | // Change Directory |
228 | 236 | // ------------------------------------------- |
229 | 237 | unsigned char fat_change_directory( unsigned long cluster ) { |
@@ -423,33 +431,33 @@ | ||
423 | 431 | fat_proc = FAT_CHANGE_DIR_04; // Long File name information ---> next entry |
424 | 432 | break; |
425 | 433 | } else { |
426 | - dir_info[TotalFileNum].FirstCluster = | |
434 | + CurrentDirInfo[TotalFileNum].FirstCluster = | |
427 | 435 | WindowBuffer[dir_entry.ByteOffset+ 20] * 0x10000 |
428 | 436 | + WindowBuffer[dir_entry.ByteOffset+ 21] * 0x1000000 |
429 | 437 | + WindowBuffer[dir_entry.ByteOffset+ 26] |
430 | 438 | + WindowBuffer[dir_entry.ByteOffset+ 27] * 0x100; |
431 | - dir_info[TotalFileNum].Attributes = WindowBuffer[dir_entry.ByteOffset+ 11]; | |
439 | + CurrentDirInfo[TotalFileNum].Attributes = WindowBuffer[dir_entry.ByteOffset+ 11]; | |
432 | 440 | |
433 | 441 | val = *( (unsigned long*) &WindowBuffer[dir_entry.ByteOffset+ 28] ); |
434 | - dir_info[TotalFileNum].FileSize = (val<<24) | ((val<<8) & 0x00FF0000) | ((val>>8) & 0x0000FF00) | ((val>>24) & 0x000000FF); | |
442 | + CurrentDirInfo[TotalFileNum].FileSize = (val<<24) | ((val<<8) & 0x00FF0000) | ((val>>8) & 0x0000FF00) | ((val>>24) & 0x000000FF); | |
435 | 443 | |
436 | - dir_info[TotalFileNum].Name[ 0] = WindowBuffer[dir_entry.ByteOffset+ 0]; dir_info[TotalFileNum].Name[ 1] = WindowBuffer[dir_entry.ByteOffset+ 1]; | |
437 | - dir_info[TotalFileNum].Name[ 2] = WindowBuffer[dir_entry.ByteOffset+ 2]; dir_info[TotalFileNum].Name[ 3] = WindowBuffer[dir_entry.ByteOffset+ 3]; | |
438 | - dir_info[TotalFileNum].Name[ 4] = WindowBuffer[dir_entry.ByteOffset+ 4]; dir_info[TotalFileNum].Name[ 5] = WindowBuffer[dir_entry.ByteOffset+ 5]; | |
439 | - dir_info[TotalFileNum].Name[ 6] = WindowBuffer[dir_entry.ByteOffset+ 6]; dir_info[TotalFileNum].Name[ 7] = WindowBuffer[dir_entry.ByteOffset+ 7]; | |
444 | + CurrentDirInfo[TotalFileNum].Name[ 0] = WindowBuffer[dir_entry.ByteOffset+ 0]; CurrentDirInfo[TotalFileNum].Name[ 1] = WindowBuffer[dir_entry.ByteOffset+ 1]; | |
445 | + CurrentDirInfo[TotalFileNum].Name[ 2] = WindowBuffer[dir_entry.ByteOffset+ 2]; CurrentDirInfo[TotalFileNum].Name[ 3] = WindowBuffer[dir_entry.ByteOffset+ 3]; | |
446 | + CurrentDirInfo[TotalFileNum].Name[ 4] = WindowBuffer[dir_entry.ByteOffset+ 4]; CurrentDirInfo[TotalFileNum].Name[ 5] = WindowBuffer[dir_entry.ByteOffset+ 5]; | |
447 | + CurrentDirInfo[TotalFileNum].Name[ 6] = WindowBuffer[dir_entry.ByteOffset+ 6]; CurrentDirInfo[TotalFileNum].Name[ 7] = WindowBuffer[dir_entry.ByteOffset+ 7]; | |
440 | 448 | |
441 | - if(dir_info[TotalFileNum].Attributes & DIR_ATTR_DIRECTORY) { | |
442 | - dir_info[TotalFileNum].Name[ 8] = WindowBuffer[dir_entry.ByteOffset+ 8]; | |
443 | - dir_info[TotalFileNum].Name[ 9] = WindowBuffer[dir_entry.ByteOffset+ 9]; | |
444 | - dir_info[TotalFileNum].Name[10] = WindowBuffer[dir_entry.ByteOffset+ 10]; | |
445 | - dir_info[TotalFileNum].Name[11] = ' '; | |
446 | - dir_info[TotalFileNum].Name[12] = 0x00; | |
449 | + if(CurrentDirInfo[TotalFileNum].Attributes & DIR_ATTR_DIRECTORY) { | |
450 | + CurrentDirInfo[TotalFileNum].Name[ 8] = WindowBuffer[dir_entry.ByteOffset+ 8]; | |
451 | + CurrentDirInfo[TotalFileNum].Name[ 9] = WindowBuffer[dir_entry.ByteOffset+ 9]; | |
452 | + CurrentDirInfo[TotalFileNum].Name[10] = WindowBuffer[dir_entry.ByteOffset+ 10]; | |
453 | + CurrentDirInfo[TotalFileNum].Name[11] = ' '; | |
454 | + CurrentDirInfo[TotalFileNum].Name[12] = 0x00; | |
447 | 455 | } else { |
448 | - dir_info[TotalFileNum].Name[ 8] = '.'; | |
449 | - dir_info[TotalFileNum].Name[ 9] = WindowBuffer[dir_entry.ByteOffset+ 8]; | |
450 | - dir_info[TotalFileNum].Name[10] = WindowBuffer[dir_entry.ByteOffset+ 9]; | |
451 | - dir_info[TotalFileNum].Name[11] = WindowBuffer[dir_entry.ByteOffset+ 10]; | |
452 | - dir_info[TotalFileNum].Name[12] = 0x00; | |
456 | + CurrentDirInfo[TotalFileNum].Name[ 8] = '.'; | |
457 | + CurrentDirInfo[TotalFileNum].Name[ 9] = WindowBuffer[dir_entry.ByteOffset+ 8]; | |
458 | + CurrentDirInfo[TotalFileNum].Name[10] = WindowBuffer[dir_entry.ByteOffset+ 9]; | |
459 | + CurrentDirInfo[TotalFileNum].Name[11] = WindowBuffer[dir_entry.ByteOffset+ 10]; | |
460 | + CurrentDirInfo[TotalFileNum].Name[12] = 0x00; | |
453 | 461 | } |
454 | 462 | |
455 | 463 | if( TotalFileNum < MAX_FILE_IN_DIR ) { |
@@ -882,12 +890,8 @@ | ||
882 | 890 | return ret_val; |
883 | 891 | } |
884 | 892 | |
885 | -enum { | |
886 | - DIR_VIEW_MODE, | |
887 | - FILE_VIEW_MODE, | |
888 | - READ_FILE_MODE, | |
889 | -}; | |
890 | 893 | |
894 | + | |
891 | 895 | // ------------------------------------------- |
892 | 896 | // UI Function - DIR debug |
893 | 897 | // ------------------------------------------- |
@@ -961,10 +965,10 @@ | ||
961 | 965 | switch ( view_mode ) { |
962 | 966 | case FILE_VIEW_MODE: |
963 | 967 | while( (p_buffer_addr[current_byte_cnt] != 0x0D) || (p_buffer_addr[current_byte_cnt+1] != 0x0A) ) { |
964 | - if( current_byte_cnt >= dir_info[current_index].FileSize ) break; | |
968 | + if( current_byte_cnt >= CurrentDirInfo[current_index].FileSize ) break; | |
965 | 969 | current_byte_cnt++; |
966 | 970 | } |
967 | - if( current_byte_cnt < dir_info[current_index].FileSize ) current_byte_cnt+=2; | |
971 | + if( current_byte_cnt < CurrentDirInfo[current_index].FileSize ) current_byte_cnt+=2; | |
968 | 972 | break; |
969 | 973 | |
970 | 974 | case DIR_VIEW_MODE: |
@@ -976,6 +980,7 @@ | ||
976 | 980 | } else { |
977 | 981 | if( current_index < TotalFileNum ) current_index++; |
978 | 982 | } |
983 | + break; | |
979 | 984 | |
980 | 985 | default: |
981 | 986 | case READ_FILE_MODE: |
@@ -987,18 +992,18 @@ | ||
987 | 992 | // change dir or file view |
988 | 993 | switch ( view_mode ) { |
989 | 994 | case FILE_VIEW_MODE: |
990 | - //TransferStartRequest(p_buffer_addr, dir_info[current_index].FileSize); | |
995 | + //TransferStartRequest(p_buffer_addr, CurrentDirInfo[current_index].FileSize); | |
991 | 996 | view_mode = READ_FILE_MODE; |
992 | 997 | break; |
993 | 998 | |
994 | 999 | case DIR_VIEW_MODE: |
995 | - if( dir_info[current_index].Attributes & DIR_ATTR_DIRECTORY ) { | |
1000 | + if( CurrentDirInfo[current_index].Attributes & DIR_ATTR_DIRECTORY ) { | |
996 | 1001 | // Change dir |
997 | - fat_change_directory(dir_info[current_index].FirstCluster); | |
1002 | + fat_change_directory(CurrentDirInfo[current_index].FirstCluster); | |
998 | 1003 | current_index = 0; |
999 | 1004 | } else { |
1000 | 1005 | // Open File |
1001 | - fat_read_file(dir_info[current_index].FirstCluster, dir_info[current_index].FileSize ); | |
1006 | + fat_read_file(CurrentDirInfo[current_index].FirstCluster, CurrentDirInfo[current_index].FileSize ); | |
1002 | 1007 | view_mode = READ_FILE_MODE; |
1003 | 1008 | current_byte_cnt = 0; |
1004 | 1009 | } |
@@ -1007,7 +1012,7 @@ | ||
1007 | 1012 | case READ_FILE_MODE: |
1008 | 1013 | #if 1 |
1009 | 1014 | if( usbms_status( CLASS_REQ_NONE ) == CLASS_STS_READY ) |
1010 | - TransferStartRequest(p_buffer_addr, dir_info[current_index].FileSize); | |
1015 | + TransferStartRequest(p_buffer_addr, CurrentDirInfo[current_index].FileSize); | |
1011 | 1016 | #endif |
1012 | 1017 | break; |
1013 | 1018 |
@@ -1026,7 +1031,7 @@ | ||
1026 | 1031 | offset = 0; |
1027 | 1032 | for(i=0; i<16; i++) tempbuf[i]=' '; |
1028 | 1033 | for(i=0; i<16; i++) { |
1029 | - if( current_byte_cnt+offset >= dir_info[current_index].FileSize ) break; | |
1034 | + if( current_byte_cnt+offset >= CurrentDirInfo[current_index].FileSize ) break; | |
1030 | 1035 | if( (p_buffer_addr[current_byte_cnt+offset] == 0x0D) && (p_buffer_addr[current_byte_cnt+offset+1] == 0x0A) ) { |
1031 | 1036 | offset += 2; |
1032 | 1037 | break; |
@@ -1041,13 +1046,13 @@ | ||
1041 | 1046 | if(offset == 16) { |
1042 | 1047 | while( (p_buffer_addr[current_byte_cnt+offset] != 0x0D) || (p_buffer_addr[current_byte_cnt+offset+1] != 0x0A) ) { |
1043 | 1048 | offset++; |
1044 | - if( current_byte_cnt+offset >= dir_info[current_index].FileSize ) break; | |
1049 | + if( current_byte_cnt+offset >= CurrentDirInfo[current_index].FileSize ) break; | |
1045 | 1050 | } |
1046 | 1051 | } |
1047 | 1052 | |
1048 | 1053 | for(i=0; i<16; i++) tempbuf[i]='.'; |
1049 | 1054 | for(i=0; i<16; i++) { |
1050 | - if( current_byte_cnt+offset >= dir_info[current_index].FileSize ) break; | |
1055 | + if( current_byte_cnt+offset >= CurrentDirInfo[current_index].FileSize ) break; | |
1051 | 1056 | if( (p_buffer_addr[current_byte_cnt+offset] == 0x0D) && (p_buffer_addr[current_byte_cnt+offset+1] == 0x0A) ) { |
1052 | 1057 | offset += 2; |
1053 | 1058 | break; |
@@ -1066,18 +1071,18 @@ | ||
1066 | 1071 | sc1602_set_buffer(1," "); |
1067 | 1072 | } else { |
1068 | 1073 | if( cursol_position == 0) { // cursol in first line |
1069 | - make_display_text_dirinfo(tempbuf, &dir_info[current_index]); | |
1074 | + make_display_text_dirinfo(tempbuf, &CurrentDirInfo[current_index]); | |
1070 | 1075 | sc1602_set_buffer_cursol( 0, tempbuf ); |
1071 | 1076 | if( current_index < TotalFileNum) { |
1072 | - make_display_text_dirinfo(tempbuf, &dir_info[current_index+1]); | |
1077 | + make_display_text_dirinfo(tempbuf, &CurrentDirInfo[current_index+1]); | |
1073 | 1078 | sc1602_set_buffer( 1, tempbuf ); |
1074 | 1079 | } else { |
1075 | 1080 | sc1602_set_buffer(1," "); |
1076 | 1081 | } |
1077 | 1082 | } else { |
1078 | - make_display_text_dirinfo(tempbuf, &dir_info[current_index-1]); | |
1083 | + make_display_text_dirinfo(tempbuf, &CurrentDirInfo[current_index-1]); | |
1079 | 1084 | sc1602_set_buffer ( 0, tempbuf ); |
1080 | - make_display_text_dirinfo(tempbuf, &dir_info[current_index]); | |
1085 | + make_display_text_dirinfo(tempbuf, &CurrentDirInfo[current_index]); | |
1081 | 1086 | sc1602_set_buffer_cursol( 1, tempbuf ); |
1082 | 1087 | } |
1083 | 1088 | } |
@@ -1084,7 +1089,7 @@ | ||
1084 | 1089 | break; |
1085 | 1090 | |
1086 | 1091 | case READ_FILE_MODE: |
1087 | - make_display_text_dirinfo(tempbuf, &dir_info[current_index]); | |
1092 | + make_display_text_dirinfo(tempbuf, &CurrentDirInfo[current_index]); | |
1088 | 1093 | sc1602_set_buffer( 0, tempbuf ); |
1089 | 1094 | sc1602_set_buffer_progress_kb(1, ReadFileStatus.ReadSize, ReadFileStatus.FileSize); |
1090 | 1095 | default: |
@@ -1105,10 +1110,7 @@ | ||
1105 | 1110 | tempbuf[ 1]='['; |
1106 | 1111 | tempbuf[14]=']'; |
1107 | 1112 | } |
1108 | -#if 0 | |
1109 | - for(i=0;i<sizeof(pDirInfo->Name)-1;i++) | |
1110 | - tempbuf[i+2]=pDirInfo->Name[i]; | |
1111 | -#else | |
1113 | +#ifdef UI_FAT_DIR_VIEW_CHECK_SIZE | |
1112 | 1114 | for(i=0;i<sizeof(pDirInfo->Name)-6;i++) |
1113 | 1115 | tempbuf[i+2]=pDirInfo->Name[i]; |
1114 | 1116 | Val = pDirInfo->FileSize / 1024; |
@@ -1120,12 +1122,14 @@ | ||
1120 | 1122 | tempbuf[14]='K'; |
1121 | 1123 | tempbuf[15]='B'; |
1122 | 1124 | } |
1125 | +#else | |
1126 | + for(i=0;i<sizeof(pDirInfo->Name)-1;i++) | |
1127 | + tempbuf[i+2]=pDirInfo->Name[i]; | |
1123 | 1128 | #endif |
1124 | 1129 | |
1125 | 1130 | } |
1126 | 1131 | |
1127 | 1132 | |
1128 | - | |
1129 | 1133 | // ------------------------------------------- |
1130 | 1134 | // UI Sub Function - USB nop |
1131 | 1135 | // ------------------------------------------- |
@@ -26,6 +26,7 @@ | ||
26 | 26 | // Locals |
27 | 27 | static int ui_function_nop(UI_COMMAND uicmd); |
28 | 28 | static int ui_function_memview(UI_COMMAND uicmd); |
29 | +static int ui_function_enduser_mode(UI_COMMAND uicmd); | |
29 | 30 | |
30 | 31 | // ------------------------------------------- |
31 | 32 | // Variables |
@@ -32,7 +33,7 @@ | ||
32 | 33 | // ------------------------------------------- |
33 | 34 | |
34 | 35 | const UI_APP_TABLE ui_app_table[] = { |
35 | - { 0, ui_function_nop, " FILE READ ", 0 }, | |
36 | + { 0, ui_function_enduser_mode, " END USER MODE ", 200 }, | |
36 | 37 | { 1, ui_function_nop, " RX START ", 0 }, |
37 | 38 | { 2, ui_function_nop, " TX START ", 1000 }, |
38 | 39 | { 3, ui_function_nop, " CONFIG ", 0 }, |
@@ -356,3 +357,155 @@ | ||
356 | 357 | } |
357 | 358 | return ret_val; |
358 | 359 | } |
360 | + | |
361 | + | |
362 | +enum enduser_mode_step { | |
363 | + STEP_WAIT_FOR_READY, | |
364 | + STEP_DIR_VIEW, | |
365 | + STEP_FILE_READ, | |
366 | + STEP_WAIT_FOR_START, | |
367 | + STEP_TANSFER, | |
368 | + STEP_COMPLETE, | |
369 | +}; | |
370 | + | |
371 | +// ------------------------------------------- | |
372 | +// UI Function - End user mode | |
373 | +// ------------------------------------------- | |
374 | +static int ui_function_enduser_mode(UI_COMMAND uicmd) { | |
375 | + int ret_val; | |
376 | + static unsigned char current_index, cursol_position, mode_step; | |
377 | + | |
378 | + ret_val = UI_RET_READY; | |
379 | + switch( uicmd.cmd ) { | |
380 | + case UI_CMD_NOP: | |
381 | + break; | |
382 | + | |
383 | + case UI_CMD_STARTED: | |
384 | + current_index = 0; | |
385 | + cursol_position = 0; | |
386 | + mode_step = STEP_WAIT_FOR_READY; | |
387 | + break; | |
388 | + break; | |
389 | + | |
390 | + case UI_CMD_KEY_PRESS_UP: | |
391 | + if( uicmd.param == OFF_EDGE ) break; // Ignore off edge | |
392 | + switch( mode_step ) { | |
393 | + case STEP_DIR_VIEW: | |
394 | + if( cursol_position == 1 ) { | |
395 | + cursol_position = 0; | |
396 | + current_index--; | |
397 | + } else { | |
398 | + if( current_index != 0 ) current_index--; | |
399 | + } | |
400 | + break; | |
401 | + | |
402 | + default: | |
403 | + break; | |
404 | + } | |
405 | + break; | |
406 | + case UI_CMD_KEY_PRESS_DOWN: | |
407 | + if( uicmd.param == OFF_EDGE ) break; // Ignore off edge | |
408 | + switch( mode_step ) { | |
409 | + case STEP_DIR_VIEW: | |
410 | + if( cursol_position == 0 ) { | |
411 | + if( TotalFileNum != 0) { | |
412 | + cursol_position = 1; | |
413 | + current_index++; | |
414 | + } | |
415 | + } else { | |
416 | + if( current_index < TotalFileNum ) current_index++; | |
417 | + } | |
418 | + break; | |
419 | + | |
420 | + default: | |
421 | + break; | |
422 | + } | |
423 | + break; | |
424 | + case UI_CMD_KEY_PRESS_BACK: | |
425 | + if( uicmd.param == OFF_EDGE ) break; // Ignore off edge | |
426 | + switch( mode_step ) { | |
427 | + case STEP_FILE_READ: | |
428 | + mode_step = STEP_DIR_VIEW; | |
429 | + break; | |
430 | + | |
431 | + case STEP_DIR_VIEW: | |
432 | + ret_val = UI_RET_QUIT; | |
433 | + break; | |
434 | + | |
435 | + default: | |
436 | + break; | |
437 | + } | |
438 | + break; | |
439 | + case UI_CMD_KEY_PRESS_OK: | |
440 | + if( uicmd.param == OFF_EDGE ) break; // Ignore off edge | |
441 | + switch( mode_step ) { | |
442 | + case STEP_DIR_VIEW: | |
443 | + if( CurrentDirInfo[current_index].Attributes & DIR_ATTR_DIRECTORY ) { | |
444 | + // Change dir | |
445 | + fat_change_directory(CurrentDirInfo[current_index].FirstCluster); | |
446 | + current_index = 0; | |
447 | + } else { | |
448 | + // Open File | |
449 | + fat_read_file(CurrentDirInfo[current_index].FirstCluster, CurrentDirInfo[current_index].FileSize ); | |
450 | + mode_step = STEP_FILE_READ; | |
451 | + } | |
452 | + break; | |
453 | + | |
454 | + default: | |
455 | + break; | |
456 | + } | |
457 | + break; | |
458 | + case UI_CMD_INTEVAL: | |
459 | + switch( mode_step ) { | |
460 | + case STEP_WAIT_FOR_READY: | |
461 | + if( fat_status(CLASS_REQ_NONE) == CLASS_STS_READY ) | |
462 | + mode_step = STEP_DIR_VIEW; | |
463 | + else { | |
464 | + sc1602_set_buffer(0,"SYSTEM STARTING "); | |
465 | + sc1602_set_buffer(1,"Wait a momnet..."); | |
466 | + } | |
467 | + break; | |
468 | + | |
469 | + case STEP_DIR_VIEW: | |
470 | + // Directory | |
471 | + if( fat_status(CLASS_REQ_NONE) != CLASS_STS_READY ) { | |
472 | + sc1602_set_buffer(0," Reading... "); | |
473 | + sc1602_set_buffer(1," "); | |
474 | + } else if(TotalFileNum == 0) { | |
475 | + sc1602_set_buffer(0,"--- NO FILE --- "); | |
476 | + sc1602_set_buffer(1," "); | |
477 | + } else { | |
478 | + if( cursol_position == 0) { // cursol in first line | |
479 | + sc1602_set_buffer_filename_cursol( 0, | |
480 | + (CurrentDirInfo[current_index].Attributes & DIR_ATTR_DIRECTORY), | |
481 | + CurrentDirInfo[current_index].Name ); | |
482 | + if( current_index < TotalFileNum) { | |
483 | + sc1602_set_buffer_filename ( 1, | |
484 | + (CurrentDirInfo[current_index+1].Attributes & DIR_ATTR_DIRECTORY), | |
485 | + CurrentDirInfo[current_index+1].Name ); | |
486 | + } else { | |
487 | + sc1602_set_buffer(1," "); | |
488 | + } | |
489 | + } else { | |
490 | + sc1602_set_buffer_filename ( 0, | |
491 | + (CurrentDirInfo[current_index-1].Attributes & DIR_ATTR_DIRECTORY), | |
492 | + CurrentDirInfo[current_index-1].Name ); | |
493 | + sc1602_set_buffer_filename_cursol( 1, | |
494 | + (CurrentDirInfo[current_index].Attributes & DIR_ATTR_DIRECTORY), | |
495 | + CurrentDirInfo[current_index].Name ); | |
496 | + } | |
497 | + } | |
498 | + break; | |
499 | + | |
500 | + case STEP_FILE_READ: | |
501 | + sc1602_set_buffer_filename ( 0, 0, CurrentDirInfo[current_index].Name ); | |
502 | + sc1602_set_buffer_progress_kb(1, ReadFileStatus.ReadSize, ReadFileStatus.FileSize); | |
503 | + break; | |
504 | + } | |
505 | + break; | |
506 | + | |
507 | + } | |
508 | + return ret_val; | |
509 | +} | |
510 | + | |
511 | + |
@@ -275,7 +275,7 @@ | ||
275 | 275 | extern int sl811_initialize(void); |
276 | 276 | extern int sl811_process(void); |
277 | 277 | extern int ui_function_usb(UI_COMMAND uicmd); |
278 | -extern unsigned char sl811_status(unsigned char cmd); | |
278 | +extern unsigned char sl811_status(REQUEST_TO_CLASS cmd); | |
279 | 279 | extern unsigned char sl811_ctrl_receive(P_SETUP_FORMAT p_fmt); |
280 | 280 | extern void sl811_buffer_copy( unsigned char* p_buf, int size); |
281 | 281 | extern unsigned char sl811_bulk_out_request( unsigned char* p_buf, int size ); |
@@ -33,6 +33,8 @@ | ||
33 | 33 | int sc1602_set_buffer_variable2 (unsigned char buf, unsigned short *data); |
34 | 34 | int sc1602_set_buffer_variable3 (unsigned char buf, unsigned long *data); |
35 | 35 | int sc1602_set_buffer_progress_kb (unsigned char buf, unsigned long val1, unsigned long val2); |
36 | +int sc1602_set_buffer_filename (unsigned char buf, unsigned char dir, char *data); | |
37 | +int sc1602_set_buffer_filename_cursol (unsigned char buf, unsigned char dir, char *data); | |
36 | 38 | |
37 | 39 | int sc1602_set_buffer_version (unsigned char buf, unsigned char major, unsigned char minor, unsigned char build); |
38 | 40 |
@@ -388,6 +390,30 @@ | ||
388 | 390 | } |
389 | 391 | |
390 | 392 | // ------------------------------------------- |
393 | +// Buffer set service function (file/dir name w/o cursol) | |
394 | +// ------------------------------------------- | |
395 | +int sc1602_set_buffer_filename (unsigned char buf, unsigned char dir, char *data) { | |
396 | + unsigned char pos, i; | |
397 | + | |
398 | + // 0123456789ABCDEF | |
399 | + if( dir == 0 ) sc1602_set_buffer(buf," "); | |
400 | + else sc1602_set_buffer(buf," [ ]"); | |
401 | + | |
402 | + pos = 2; | |
403 | + for(i=0;i<12;i++) | |
404 | + if(data[i]!=0x20) sc1602_buffer[buf][pos++]=data[i]; | |
405 | +} | |
406 | + | |
407 | + | |
408 | +// ------------------------------------------- | |
409 | +// Buffer set service function (file/dir name w/ cursol) | |
410 | +// ------------------------------------------- | |
411 | +int sc1602_set_buffer_filename_cursol (unsigned char buf, unsigned char dir, char *data) { | |
412 | + sc1602_set_buffer_filename(buf, dir, data); | |
413 | + sc1602_buffer[buf][0] = '>'; | |
414 | +} | |
415 | + | |
416 | +// ------------------------------------------- | |
391 | 417 | // Local functions |
392 | 418 | // ------------------------------------------- |
393 | 419 | void sc1602_command_output4(char cmd) { |
@@ -25,13 +25,21 @@ | ||
25 | 25 | #define DIR_ATTR_ARCHIVE 0x20 |
26 | 26 | #define DIR_ATTR_LONG_NAME (DIR_ATTR_READONLY|DIR_ATTR_HIDDEN|DIR_ATTR_SYSTEM|DIR_ATTR_VOLUME_ID) |
27 | 27 | |
28 | -extern void fat_20ms_handler(void); | |
29 | -extern int fat_initialize(void); | |
30 | -extern int fat_process(void); | |
31 | -extern int ui_function_fat(UI_COMMAND uicmd); | |
32 | -extern unsigned char fat_change_directory( unsigned long cluster ); | |
33 | -extern unsigned char fat_read_file( unsigned long cluster, unsigned long file_size ); | |
28 | +// Keep file list on current directory | |
29 | +typedef struct { | |
30 | + unsigned long FirstCluster; | |
31 | + unsigned long FileSize; | |
32 | + char Name[13]; | |
33 | + unsigned char Attributes; | |
34 | +} DIR_INFO, *P_DIR_INFO; | |
34 | 35 | |
36 | +// Read file status | |
37 | +typedef struct { | |
38 | + unsigned long ReadSize; | |
39 | + unsigned long FileSize; | |
40 | + unsigned long CurrentCluster; | |
41 | + unsigned long CurrentSector; | |
42 | +} READ_FILE_STS, *P_READ_FILE_STS; | |
35 | 43 | |
36 | 44 | typedef struct { |
37 | 45 | unsigned char fat_type; |
@@ -52,4 +60,21 @@ | ||
52 | 60 | unsigned long RootClus; // Offset 44 Size 4 |
53 | 61 | } BPB_INFORMARION, *P_BPB_INFORMATION; |
54 | 62 | |
63 | + | |
64 | +// Global variables | |
65 | +extern unsigned int TotalFileNum; | |
66 | +extern READ_FILE_STS ReadFileStatus; | |
67 | +extern DIR_INFO CurrentDirInfo[MAX_FILE_IN_DIR]; // Keep file list on current directory | |
68 | + | |
69 | +// Global functions | |
70 | +extern void fat_20ms_handler(void); | |
71 | +extern int fat_initialize(void); | |
72 | +extern int fat_process(void); | |
73 | +extern int ui_function_fat(UI_COMMAND uicmd); | |
74 | +extern unsigned char fat_status(REQUEST_TO_CLASS req); | |
75 | +extern unsigned char fat_change_directory( unsigned long cluster ); | |
76 | +extern unsigned char fat_read_file( unsigned long cluster, unsigned long file_size ); | |
77 | + | |
78 | + | |
79 | + | |
55 | 80 | #endif |
@@ -13,6 +13,7 @@ | ||
13 | 13 | #define READ_BUF_SIZE 16 |
14 | 14 | #define SENT_BUF_SIZE 16 |
15 | 15 | |
16 | +// #define RECEIVE_DATA_EVENIF_ERR | |
16 | 17 | |
17 | 18 | // ------------------------------------------- |
18 | 19 | // Macros |
@@ -183,7 +184,7 @@ | ||
183 | 184 | if(SCI0.SSR.BIT.PER) { |
184 | 185 | SCI0.SSR.BIT.PER = 0; |
185 | 186 | SCIErrorDebug+=0x100; |
186 | -#if 1 | |
187 | +#ifdef RECEIVE_DATA_EVENIF_ERR | |
187 | 188 | ReceiveBuf[ReceiveCnt] = SCI0.RDR; // データ受信 |
188 | 189 | // DC code was refered from http://www5a.biglobe.ne.jp/~NCPRO/pc_nc.htm. |
189 | 190 | if( ReceiveBuf[ReceiveCnt] == 0x11 |
@@ -28,6 +28,8 @@ | ||
28 | 28 | extern int sc1602_set_buffer_variable3 (unsigned char buf, unsigned long *data); |
29 | 29 | extern int sc1602_set_buffer_version (unsigned char buf, unsigned char major, unsigned char minor, unsigned char build); |
30 | 30 | extern int sc1602_set_buffer_progress_kb (unsigned char buf, unsigned long val1, unsigned long val2); |
31 | +extern int sc1602_set_buffer_filename (unsigned char buf, unsigned char dir, char *data); | |
32 | +extern int sc1602_set_buffer_filename_cursol (unsigned char buf, unsigned char dir, char *data); | |
31 | 33 | |
32 | 34 | extern char sc1602_buffer[MAX_LINE][MAX_COLUMN]; |
33 | 35 | extern int sc1602_buffer_updates[MAX_LINE]; |
@@ -19,7 +19,8 @@ | ||
19 | 19 | #define MSCLASS_DEBUG_ON |
20 | 20 | #define SCI_DEBUG_ON |
21 | 21 | #endif |
22 | -#define SUB_PROC_RESULT unsigned char | |
22 | +#define REQUEST_TO_CLASS unsigned char | |
23 | +#define SUB_PROC_RESULT unsigned char | |
23 | 24 | enum sub_proc_result_code { |
24 | 25 | SUB_PROC_BUSY, |
25 | 26 | SUB_PROC_DONE, |