Revisión | 12 (tree) |
---|---|
Tiempo | 2012-08-22 17:03:12 |
Autor | tekken_boss |
000.001.012: 2012/08/22 16:59 : Single chip mode is implemented.
@@ -15,9 +15,10 @@ | ||
15 | 15 | |
16 | 16 | #define SRCVER_MAJOR 0 |
17 | 17 | #define SRCVER_MINOR 1 |
18 | -#define SRCVER_BUILD 11 | |
18 | +#define SRCVER_BUILD 12 | |
19 | 19 | |
20 | 20 | /* -------------------------------------------------------------------- |
21 | +000.001.012: 2012/08/22 16:59 : Single chip mode is implemented. | |
21 | 22 | 000.001.011: 2012/06/18 09:21 : enduser mode is ready. (still not default) |
22 | 23 | 000.001.010: 2012/06/18 02:14 : A part of enduser mode is added. |
23 | 24 | 000.001.009: 2012/06/13 18:35 : Fine tuning of SCI handshake. |
@@ -131,10 +131,20 @@ | ||
131 | 131 | break; |
132 | 132 | |
133 | 133 | case UI_01_STARTUP: |
134 | +#ifdef START_WITH_ENDUSERMODE | |
135 | + { | |
136 | + UI_COMMAND ui_cmd; | |
137 | + ui_cmd.cmd = UI_CMD_STARTED; | |
138 | + ui_cmdset( ui_cmd ); // TODO: error handling | |
139 | + ui_event_timer = ui_app_table[current_index].interval_time; // timer reset | |
140 | + ui_proc = UI_03_EXECUTING; | |
141 | + } | |
142 | +#else | |
134 | 143 | if( ui_queue_rp || ui_queue_wp ) { |
135 | 144 | ui_queue_rp = ui_queue_wp = 0; |
136 | 145 | ui_proc++; |
137 | 146 | } |
147 | +#endif | |
138 | 148 | break; |
139 | 149 | |
140 | 150 | case UI_02_TOP_LEVEL: |
@@ -56,7 +56,7 @@ | ||
56 | 56 | volatile int lcd_wait_timer; |
57 | 57 | volatile int lcd_proc; |
58 | 58 | volatile int lcd_disable_timer; |
59 | -const char hex2ascii[] = "0123456789ABCDEF"; | |
59 | +static const char hex2ascii[] = "0123456789ABCDEF"; | |
60 | 60 | |
61 | 61 | enum lcd_process_mode { |
62 | 62 | LCD_00_INIT, |
@@ -58,6 +58,7 @@ | ||
58 | 58 | static int ui_function_serial_debug(UI_COMMAND uicmd, int param); |
59 | 59 | static int ui_function_serial_config(UI_COMMAND uicmd, int param); |
60 | 60 | static int ui_function_serial_trans(UI_COMMAND uicmd, int param); |
61 | +static int ui_function_serial_trans_debug(UI_COMMAND uicmd, int param); | |
61 | 62 | |
62 | 63 | // ------------------------------------------- |
63 | 64 | // Variables |
@@ -142,6 +143,7 @@ | ||
142 | 143 | { 0, 0, ui_function_serial_debug, " Debug ", }, |
143 | 144 | { 1, 0, ui_function_serial_config, " Config ", }, |
144 | 145 | { 2, 0, ui_function_serial_trans, " Transfer ", }, |
146 | + { 3, 0, ui_function_serial_trans_debug, " Transfer(Dbg) ", }, | |
145 | 147 | { -1, 0, ui_function_serial_nop, "0123456789ABCDEF", }, |
146 | 148 | }; |
147 | 149 |
@@ -803,7 +805,141 @@ | ||
803 | 805 | return ret_val; |
804 | 806 | } |
805 | 807 | |
808 | +static const char hex2ascii[] = "0123456789ABCDEF"; | |
806 | 809 | // ------------------------------------------- |
810 | +// UI Function - SERIAL trans (debug) | |
811 | +// ------------------------------------------- | |
812 | +static int ui_function_serial_trans_debug(UI_COMMAND uicmd, int param) { | |
813 | + static unsigned char current_index; | |
814 | + static unsigned char ok_press; | |
815 | + unsigned char *data; | |
816 | + int ret_val; | |
817 | + unsigned int uint_val; | |
818 | + char tempbuf[2][16]; | |
819 | + // 0123456789ABCDEF | |
820 | + // ---------------- | |
821 | + // R[?]:........|** | |
822 | + // S..C..P.. ...% | |
823 | + tempbuf[0][0x0]='R'; tempbuf[0][0x1]='['; tempbuf[0][0x2]=' '; tempbuf[0][0x3]=']'; | |
824 | + tempbuf[0][0x4]=' '; tempbuf[0][0x5]=' '; tempbuf[0][0x6]=' '; tempbuf[0][0x7]=' '; | |
825 | + tempbuf[0][0x8]=' '; tempbuf[0][0x9]=' '; tempbuf[0][0xA]=' '; tempbuf[0][0xB]=' '; | |
826 | + tempbuf[0][0xC]=' '; tempbuf[0][0xD]='|'; tempbuf[0][0xE]=' '; tempbuf[0][0xF]=' '; | |
827 | + | |
828 | + tempbuf[1][0x0]='S'; tempbuf[1][0x1]=' '; tempbuf[1][0x2]=' '; tempbuf[1][0x3]='C'; | |
829 | + tempbuf[1][0x4]=' '; tempbuf[1][0x5]=' '; tempbuf[1][0x6]='P'; tempbuf[1][0x7]=' '; | |
830 | + tempbuf[1][0x8]=' '; tempbuf[1][0x9]=' '; tempbuf[1][0xA]=' '; tempbuf[1][0xB]=' '; | |
831 | + tempbuf[1][0xC]=' '; tempbuf[1][0xD]=' '; tempbuf[1][0xE]=' '; tempbuf[1][0xF]='%'; | |
832 | + | |
833 | + | |
834 | + ret_val = UI_RET_READY; | |
835 | + | |
836 | + switch( uicmd.cmd ) { | |
837 | + case UI_CMD_NOP: | |
838 | + break; | |
839 | + | |
840 | + case UI_CMD_KEY_PRESS_OK: | |
841 | + if( uicmd.param == OFF_EDGE ) ok_press = 0; | |
842 | + else ok_press = 1; | |
843 | + if( uicmd.param == OFF_EDGE ) break; // Ignore off edge | |
844 | + break; | |
845 | + | |
846 | + case UI_CMD_INTEVAL: | |
847 | + // Title | |
848 | + switch( serial_proc ) { | |
849 | + case SCI_INITIALIZE: | |
850 | + case SCI_ERROR_STOP: | |
851 | + case SCI_READY_WAIT: | |
852 | + //sc1602_set_buffer( 0, "SCI is not ready" ); | |
853 | + tempbuf[0][0xE]='N'; tempbuf[0][0xF]='R'; // NR / Not ready | |
854 | + break; | |
855 | + | |
856 | + case SCI_IDLE: | |
857 | + //sc1602_set_buffer( 0, "SCI is ready. " ); | |
858 | + tempbuf[0][0xE]='R'; tempbuf[0][0xF]='D'; // RD / Ready | |
859 | + break; | |
860 | + | |
861 | + case SCI_DATA_SET: | |
862 | + case SCI_WAIT_TX_OK: | |
863 | + if( sci_setting.flow_control_request == FLOW_REQ_PAUSE ) | |
864 | + /*sc1602_set_buffer( 0, "Pause.... " );*/ {tempbuf[0][0xE]='P'; tempbuf[0][0xF]='S';} // PS / Pause | |
865 | + else | |
866 | + /*sc1602_set_buffer( 0, "Sending... " );*/ {tempbuf[0][0xE]='S'; tempbuf[0][0xF]='D';} // SD / Sending | |
867 | + break; | |
868 | + | |
869 | + case SCI_TX_IN_PROGRESS: | |
870 | + //sc1602_set_buffer( 0, "Sending... " ); | |
871 | + tempbuf[0][0xE]='S'; tempbuf[0][0xF]='D'; // SD / Sending | |
872 | + break; | |
873 | + | |
874 | + case SCI_TX_IN_PAUSE: | |
875 | + //sc1602_set_buffer( 0, "Pause.... " ); | |
876 | + tempbuf[0][0xE]='P'; tempbuf[0][0xF]='S'; // PS / Pause | |
877 | + break; | |
878 | + | |
879 | + case SCI_TX_IN_END: | |
880 | + //sc1602_set_buffer( 0, "Complete! " ); | |
881 | + tempbuf[0][0xE]='P'; tempbuf[0][0xF]='S'; // DN / Complete | |
882 | + break; | |
883 | + } | |
884 | + | |
885 | + // Read buf dump | |
886 | + data = &ReceiveBuf[(ReceiveCnt&0x03)]; | |
887 | + tempbuf[0][0x2] = hex2ascii[ReceiveCnt & 0x0F ]; | |
888 | + tempbuf[0][0x5] = hex2ascii[(*(data + 0) >> 4) & 0x0F ]; | |
889 | + tempbuf[0][0x6] = hex2ascii[(*(data + 0) ) & 0x0F ]; | |
890 | + tempbuf[0][0x7] = hex2ascii[(*(data + 1) >> 4) & 0x0F ]; | |
891 | + tempbuf[0][0x8] = hex2ascii[(*(data + 1) ) & 0x0F ]; | |
892 | + tempbuf[0][0x9] = hex2ascii[(*(data + 2) >> 4) & 0x0F ]; | |
893 | + tempbuf[0][0xA] = hex2ascii[(*(data + 2) ) & 0x0F ]; | |
894 | + tempbuf[0][0xB] = hex2ascii[(*(data + 3) >> 4) & 0x0F ]; | |
895 | + tempbuf[0][0xC] = hex2ascii[(*(data + 3) ) & 0x0F ]; | |
896 | + | |
897 | + // Registers | |
898 | + tempbuf[1][0x1] = hex2ascii[(SCI0.SSR.BYTE >> 4) & 0x0F ]; | |
899 | + tempbuf[1][0x2] = hex2ascii[(SCI0.SSR.BYTE ) & 0x0F ]; | |
900 | + tempbuf[1][0x4] = hex2ascii[(SCI0.SCR.BYTE >> 4) & 0x0F ]; | |
901 | + tempbuf[1][0x5] = hex2ascii[(SCI0.SCR.BYTE ) & 0x0F ]; | |
902 | + tempbuf[1][0x7] = hex2ascii[(serial_proc >> 4) & 0x0F ]; | |
903 | + tempbuf[1][0x8] = hex2ascii[(serial_proc ) & 0x0F ]; | |
904 | + | |
905 | + // Percentage | |
906 | + uint_val = (unsigned int) (tx_status.sent_bytes/tx_status.file_size)*100; | |
907 | + tempbuf[1][0xC] = hex2ascii[(uint_val/100) % 10 ]; | |
908 | + tempbuf[1][0xD] = hex2ascii[(uint_val/10) % 10 ]; | |
909 | + tempbuf[1][0xE] = hex2ascii[(uint_val) % 10 ]; | |
910 | + | |
911 | + sc1602_set_buffer(0,tempbuf[0]); | |
912 | + sc1602_set_buffer(1,tempbuf[1]); | |
913 | + break; | |
914 | + | |
915 | + case UI_CMD_STARTED: | |
916 | + current_index = 0; | |
917 | + ok_press = 0; | |
918 | + break; | |
919 | + | |
920 | + case UI_CMD_KEY_PRESS_UP: | |
921 | + if( uicmd.param == OFF_EDGE ) break; // Ignore off edge | |
922 | + if( current_index != 0 ) current_index--; | |
923 | + break; | |
924 | + | |
925 | + case UI_CMD_KEY_PRESS_DOWN: | |
926 | + if( uicmd.param == OFF_EDGE ) break; // Ignore off edge | |
927 | + if( ok_press == 0 ) { | |
928 | + if( debug_var_table[current_index+1].num != -1 ) current_index++; | |
929 | + } else { | |
930 | + // TODO | |
931 | + } | |
932 | + break; | |
933 | + | |
934 | + case UI_CMD_KEY_PRESS_BACK: | |
935 | + if( uicmd.param == OFF_EDGE ) break; // Ignore off edge | |
936 | + ret_val = UI_RET_QUIT; | |
937 | + break; | |
938 | + } | |
939 | + return ret_val; | |
940 | +} | |
941 | + | |
942 | +// ------------------------------------------- | |
807 | 943 | // UI Sub Function - SERIAL nop |
808 | 944 | // ------------------------------------------- |
809 | 945 | static int ui_function_serial_nop(UI_COMMAND uicmd, int param) { |
@@ -54,6 +54,19 @@ | ||
54 | 54 | // Main routine |
55 | 55 | // ------------------------------------------- |
56 | 56 | int main(void) { |
57 | +/* | |
58 | + BSC.ABWCR.BYTE = 0xff; // CS0-CS7:8bitバス | |
59 | + BSC.ASTCR.BYTE = 0xff; // CS0-CS7:3ステートアクセス | |
60 | + BSC.BCR.BYTE = 0xc6; // | |
61 | + | |
62 | + P1DDR=0xFF; // Port1 use for BUS | |
63 | + P2DDR=0x07; // Port2 use for BUS | |
64 | + P8DDR=0xEC; // Port8(4-2) use for CS | |
65 | + RTCOR=0x03; | |
66 | + RTMCSR=0x27; | |
67 | + DRCRB=0x98; | |
68 | + DRCRA=0x78; | |
69 | +*/ | |
57 | 70 | // uCom initialize |
58 | 71 | port_initialize(); |
59 | 72 | register_initialize(); |
@@ -16,6 +16,7 @@ | ||
16 | 16 | AS = $(TOOL_PREFIX)as |
17 | 17 | |
18 | 18 | LDSCRIPT = H8_3069_h8mon.x |
19 | +#LDSCRIPT = H8_3069_single.x | |
19 | 20 | CRT0 = start.s |
20 | 21 | SRCS = main.c sc1602.c key.c ui.c sl811.c usb_ms.c led.c fat.c serial.c |
21 | 22 |
@@ -13,7 +13,16 @@ | ||
13 | 13 | |
14 | 14 | #include "3069s.h" |
15 | 15 | |
16 | -#define DEBUG_ON | |
16 | +//#define ROM_VERSION | |
17 | +#ifdef ROM_VERSION | |
18 | + //#define DEBUG_ON | |
19 | + #define START_WITH_ENDUSERMODE | |
20 | +#else | |
21 | + #define DEBUG_ON | |
22 | + #define START_WITH_ENDUSERMODE | |
23 | +#endif | |
24 | + | |
25 | + | |
17 | 26 | #ifdef DEBUG_ON |
18 | 27 | #define SL811HS_DEBUG_ON |
19 | 28 | #define MSCLASS_DEBUG_ON |
@@ -49,8 +58,10 @@ | ||
49 | 58 | #define CLASS_STS_UNKNOWN 0xFF |
50 | 59 | |
51 | 60 | |
61 | +#ifdef DEBUG_ON | |
52 | 62 | #define printf ((int (*)(const char *,...))0x00002b84) |
53 | 63 | #define scanf ((int (*)(const char *,...))0x00002bd6) |
64 | +#endif // DEBUG_ON | |
54 | 65 | |
55 | 66 | extern const char hex2char[256][3]; |
56 | 67 |