Revisión | 5 (tree) |
---|---|
Tiempo | 2012-06-11 13:07:50 |
Autor | tekken_boss |
000.001.005: 2012/06/11 13:06 : UI for DC flow control is added.
[Modification]
+ [SCI] UI for DC flow control is added.
+ [SCI] Transfer condition for SCI is changed from FLOW_REQ_NONE to FLOW_REQ_PAUSE.
[Confirmation]
+ Compilable.
@@ -15,9 +15,10 @@ | ||
15 | 15 | |
16 | 16 | #define SRCVER_MAJOR 0 |
17 | 17 | #define SRCVER_MINOR 1 |
18 | -#define SRCVER_BUILD 4 | |
18 | +#define SRCVER_BUILD 5 | |
19 | 19 | |
20 | 20 | /* -------------------------------------------------------------------- |
21 | +000.001.005: 2012/06/11 13:06 : UI for DC flow control is added. | |
21 | 22 | 000.001.004: 2012/06/11 11:23 : DC flow control is added. |
22 | 23 | 000.001.003: 2012/06/11 09:39 : SCI config UI function is added. |
23 | 24 | 000.001.002: 2012/06/11 02:15 : Character code(ISO/EIA) conversion are added. |
@@ -991,8 +991,10 @@ | ||
991 | 991 | break; |
992 | 992 | |
993 | 993 | case READ_FILE_MODE: |
994 | +#if 1 | |
994 | 995 | if( usbms_status( CLASS_REQ_NONE ) == CLASS_STS_READY ) |
995 | 996 | TransferStartRequest(p_buffer_addr, dir_info[current_index].FileSize); |
997 | +#endif | |
996 | 998 | break; |
997 | 999 | |
998 | 1000 | default: |
@@ -51,6 +51,7 @@ | ||
51 | 51 | static int ui_function_serial_nop(UI_COMMAND uicmd, int param); |
52 | 52 | static int ui_function_serial_debug(UI_COMMAND uicmd, int param); |
53 | 53 | static int ui_function_serial_config(UI_COMMAND uicmd, int param); |
54 | +static int ui_function_serial_trans(UI_COMMAND uicmd, int param); | |
54 | 55 | |
55 | 56 | // ------------------------------------------- |
56 | 57 | // Variables |
@@ -127,7 +128,8 @@ | ||
127 | 128 | |
128 | 129 | static const MODULE_MENU_TABLE serial_app_table[] = { // interval time will be ignored. |
129 | 130 | { 0, 0, ui_function_serial_debug, " Debug ", }, |
130 | - { 2, 0, ui_function_serial_config, " Config ", }, | |
131 | + { 1, 0, ui_function_serial_config, " Config ", }, | |
132 | + { 2, 0, ui_function_serial_trans, " Transfer ", }, | |
131 | 133 | { -1, 0, ui_function_serial_nop, "0123456789ABCDEF", }, |
132 | 134 | }; |
133 | 135 |
@@ -204,6 +206,7 @@ | ||
204 | 206 | if( serial_proc == SCI_TX_IN_PROGRESS ) { |
205 | 207 | if(SCI0.SSR.BIT.TDRE) { |
206 | 208 | if( sci_setting.flow_control_request == FLOW_REQ_PAUSE ) { |
209 | + sci_setting.flow_control_request = FLOW_REQ_NONE; | |
207 | 210 | serial_proc = SCI_TX_IN_PAUSE; |
208 | 211 | tx_status.sent_bytes++; |
209 | 212 | SCI0.SCR.BIT.TIE = 0; // TX empty intr. disable |
@@ -264,24 +267,26 @@ | ||
264 | 267 | tx_status.file_size = size; |
265 | 268 | tx_status.sent_bytes = 0; |
266 | 269 | tx_status.p_buf = pBuf; |
270 | + serial_proc = SCI_TX_IN_PAUSE; | |
271 | + } else { | |
272 | + serial_proc = SCI_TX_IN_PROGRESS; | |
273 | + // Transfer start | |
274 | + switch( sci_setting.code_setting_index ) { | |
275 | + case COMM_CODE_ISO: | |
276 | + SCI0.TDR = Cnv2Iso( (unsigned char) tx_status.p_buf[tx_status.sent_bytes++]); | |
277 | + break; | |
278 | + case COMM_CODE_EIA: | |
279 | + SCI0.TDR = Cnv2Eia( (unsigned char) tx_status.p_buf[tx_status.sent_bytes++]); | |
280 | + break; | |
281 | + default: | |
282 | + SCI0.TDR = (unsigned char) tx_status.p_buf[tx_status.sent_bytes++]; | |
283 | + break; | |
284 | + } | |
285 | + | |
286 | + if(SCI0.SSR.BIT.TDRE) SCI0.SSR.BIT.TDRE = 0; // TX empty intr. clear | |
287 | + SCI0.SCR.BIT.TIE = 1; // TX empty intr. enable | |
267 | 288 | } |
268 | 289 | |
269 | - // Transfer start | |
270 | - serial_proc = SCI_TX_IN_PROGRESS; | |
271 | - switch( sci_setting.code_setting_index ) { | |
272 | - case COMM_CODE_ISO: | |
273 | - SCI0.TDR = Cnv2Iso( (unsigned char) tx_status.p_buf[tx_status.sent_bytes++]); | |
274 | - break; | |
275 | - case COMM_CODE_EIA: | |
276 | - SCI0.TDR = Cnv2Eia( (unsigned char) tx_status.p_buf[tx_status.sent_bytes++]); | |
277 | - break; | |
278 | - default: | |
279 | - SCI0.TDR = (unsigned char) tx_status.p_buf[tx_status.sent_bytes++]; | |
280 | - break; | |
281 | - } | |
282 | - | |
283 | - if(SCI0.SSR.BIT.TDRE) SCI0.SSR.BIT.TDRE = 0; // TX empty intr. clear | |
284 | - SCI0.SCR.BIT.TIE = 1; // TX empty intr. enable | |
285 | 290 | } |
286 | 291 | |
287 | 292 | // ------------------------------------------- |
@@ -317,17 +322,21 @@ | ||
317 | 322 | break; |
318 | 323 | |
319 | 324 | case SCI_TX_IN_PROGRESS: |
320 | - if( tx_status.sent_bytes >= tx_status.file_size ) serial_proc = SCI_TX_IN_END; | |
325 | + if( tx_status.sent_bytes >= tx_status.file_size ) { | |
326 | + SCI0.SCR.BIT.TIE = 0; //TX empty Interrupt disable | |
327 | + serial_proc = SCI_TX_IN_END; | |
328 | + serial_disable_timer = 1000; | |
329 | + } | |
321 | 330 | break; |
322 | 331 | |
323 | 332 | case SCI_TX_IN_PAUSE: |
324 | 333 | if( sci_setting.flow_control_request == FLOW_REQ_RESUME ) { |
334 | + sci_setting.flow_control_request = FLOW_REQ_NONE; | |
325 | 335 | TransferStartRequest(0, 0); |
326 | 336 | } |
327 | 337 | break; |
328 | 338 | |
329 | 339 | case SCI_TX_IN_END: |
330 | - SCI0.SCR.BIT.TIE = 0; //TX empty Interrupt disable | |
331 | 340 | serial_proc = SCI_IDLE; |
332 | 341 | break; |
333 | 342 |
@@ -593,6 +602,80 @@ | ||
593 | 602 | } |
594 | 603 | |
595 | 604 | // ------------------------------------------- |
605 | +// UI Function - SERIAL trans | |
606 | +// ------------------------------------------- | |
607 | +static int ui_function_serial_trans(UI_COMMAND uicmd, int param) { | |
608 | + static unsigned char current_index; | |
609 | + static unsigned char ok_press; | |
610 | + int ret_val; | |
611 | + | |
612 | + ret_val = UI_RET_READY; | |
613 | + | |
614 | + switch( uicmd.cmd ) { | |
615 | + case UI_CMD_NOP: | |
616 | + break; | |
617 | + | |
618 | + case UI_CMD_KEY_PRESS_OK: | |
619 | + if( uicmd.param == OFF_EDGE ) ok_press = 0; | |
620 | + else ok_press = 1; | |
621 | + if( uicmd.param == OFF_EDGE ) break; // Ignore off edge | |
622 | + | |
623 | + break; | |
624 | + | |
625 | + case UI_CMD_INTEVAL: | |
626 | + // Title | |
627 | + switch( serial_proc ) { | |
628 | + case SCI_INITIALIZE: | |
629 | + case SCI_ERROR_STOP: | |
630 | + case SCI_READY_WAIT: | |
631 | + sc1602_set_buffer( 0, "SCI is not ready" ); | |
632 | + break; | |
633 | + | |
634 | + case SCI_IDLE: | |
635 | + sc1602_set_buffer( 0, "SCI is ready. " ); | |
636 | + break; | |
637 | + | |
638 | + case SCI_TX_IN_PROGRESS: | |
639 | + sc1602_set_buffer( 0, "Sending... " ); | |
640 | + break; | |
641 | + | |
642 | + case SCI_TX_IN_PAUSE: | |
643 | + sc1602_set_buffer( 0, "Pause.... " ); | |
644 | + break; | |
645 | + | |
646 | + case SCI_TX_IN_END: | |
647 | + sc1602_set_buffer( 0, "Complete! " ); | |
648 | + break; | |
649 | + } | |
650 | + sc1602_set_buffer_progress_kb(1, tx_status.sent_bytes, tx_status.file_size); | |
651 | + break; | |
652 | + | |
653 | + case UI_CMD_STARTED: | |
654 | + current_index = 0; | |
655 | + ok_press = 0; | |
656 | + break; | |
657 | + | |
658 | + case UI_CMD_KEY_PRESS_UP: | |
659 | + if( uicmd.param == OFF_EDGE ) break; // Ignore off edge | |
660 | + if( current_index != 0 ) current_index--; | |
661 | + break; | |
662 | + case UI_CMD_KEY_PRESS_DOWN: | |
663 | + if( uicmd.param == OFF_EDGE ) break; // Ignore off edge | |
664 | + if( ok_press == 0 ) { | |
665 | + if( debug_var_table[current_index+1].num != -1 ) current_index++; | |
666 | + } else { | |
667 | + // TODO | |
668 | + } | |
669 | + break; | |
670 | + case UI_CMD_KEY_PRESS_BACK: | |
671 | + if( uicmd.param == OFF_EDGE ) break; // Ignore off edge | |
672 | + ret_val = UI_RET_QUIT; | |
673 | + break; | |
674 | + } | |
675 | + return ret_val; | |
676 | +} | |
677 | + | |
678 | +// ------------------------------------------- | |
596 | 679 | // UI Sub Function - SERIAL nop |
597 | 680 | // ------------------------------------------- |
598 | 681 | static int ui_function_serial_nop(UI_COMMAND uicmd, int param) { |