• R/O
  • SSH
  • HTTPS

panda-p: 提交


Commit MetaInfo

修訂9 (tree)
時間2012-06-13 18:35:06
作者tekken_boss

Log Message

000.001.009: 2012/06/13 18:35 : Fine tuning of SCI handshake.

Modification

  • [SCI] Fine tuning of SCI handshake.

Confirmation

  • Compilable.
  • Confirmed the correct transfer between PC.

Change Summary

差異

--- trunk/src/srcver.h (revision 8)
+++ trunk/src/srcver.h (revision 9)
@@ -15,9 +15,10 @@
1515
1616 #define SRCVER_MAJOR 0
1717 #define SRCVER_MINOR 1
18-#define SRCVER_BUILD 8
18+#define SRCVER_BUILD 9
1919
2020 /* --------------------------------------------------------------------
21+000.001.009: 2012/06/13 18:35 : Fine tuning of SCI handshake.
2122 000.001.008: 2012/06/13 16:24 : Default setting for SCI was changed.
2223 000.001.007: 2012/06/13 14:45 : Fine tuning of SL811 driver class.
2324 000.001.006: 2012/06/11 17:01 : Fine tuning of SCI handshake.
--- trunk/src/serial.c (revision 8)
+++ trunk/src/serial.c (revision 9)
@@ -28,6 +28,7 @@
2828 unsigned long file_size;
2929 unsigned long sent_bytes;
3030 unsigned char* p_buf;
31+ unsigned char tx_in_progress;
3132 } TX_STATUS, *P_TX_STATUS;
3233
3334 // -------------------------------------------
@@ -89,6 +90,10 @@
8990 SCI_INITIALIZE,
9091 SCI_READY_WAIT,
9192 SCI_IDLE = 0x80, // Idle
93+ SCI_DATA_SET,
94+ SCI_WAIT_TX_OK,
95+
96+
9297 SCI_TX_IN_PROGRESS,
9398 SCI_TX_IN_PAUSE,
9499 SCI_TX_IN_END,
@@ -231,8 +236,10 @@
231236 // -------------------------------------------
232237 #pragma interrupt (int_TXI0)
233238 void int_TXI0(void) {
234- if( serial_proc == SCI_TX_IN_PROGRESS ) {
239+// if( serial_proc == SCI_TX_IN_PROGRESS ) {
240+ if( serial_proc == SCI_WAIT_TX_OK ) {
235241 if(SCI0.SSR.BIT.TDRE) {
242+/*
236243 if( sci_setting.flow_control_request == FLOW_REQ_PAUSE ) {
237244 sci_setting.flow_control_request = FLOW_REQ_NONE;
238245 serial_proc = SCI_TX_IN_PAUSE;
@@ -254,7 +261,9 @@
254261 } else {
255262 SCI0.SCR.BIT.TIE = 0; // TX empty intr. disable
256263 }
257- SCI0.SSR.BIT.TDRE = 0; // TX empty intr. clear
264+*/
265+ tx_status.tx_in_progress = 0;
266+ SCI0.SCR.BIT.TIE = 0;
258267 }
259268 } else {
260269 SCI0.SCR.BIT.TIE = 0;
@@ -293,12 +302,19 @@
293302 unsigned char TransferStartRequest( unsigned char* pBuf, unsigned long size ) {
294303 if( serial_proc != SCI_IDLE && serial_proc != SCI_TX_IN_PAUSE ) return CLASS_REQ_BUSY;
295304
296- if( serial_proc != SCI_TX_IN_PAUSE ) {
305+ if( size != 0 ) { // Start request
297306 tx_status.file_size = size;
298307 tx_status.sent_bytes = 0;
299308 tx_status.p_buf = pBuf;
300- serial_proc = SCI_TX_IN_PAUSE;
301- } else {
309+ tx_status.tx_in_progress = 0;
310+ serial_proc = SCI_DATA_SET;
311+ sci_setting.flow_control_request = FLOW_REQ_PAUSE;
312+#ifdef SCI_DEBUG_ON
313+ printf("[SCI] TX Req Set\r\n");
314+#endif
315+ }
316+/*
317+ else { // Continue request
302318 serial_proc = SCI_TX_IN_PROGRESS;
303319 // Transfer start
304320 switch( sci_setting.code_setting_index ) {
@@ -317,7 +333,7 @@
317333 if(SCI0.SSR.BIT.TDRE) SCI0.SSR.BIT.TDRE = 0; // TX empty intr. clear
318334 SCI0.SCR.BIT.TIE = 1; // TX empty intr. enable
319335 }
320-
336+*/
321337 }
322338
323339 // -------------------------------------------
@@ -354,6 +370,41 @@
354370 case SCI_IDLE:
355371 break;
356372
373+ case SCI_DATA_SET:
374+ if( sci_setting.flow_control_request != FLOW_REQ_PAUSE ) {
375+ // 1 byte Transfer start
376+ switch( sci_setting.code_setting_index ) {
377+ case COMM_CODE_ISO:
378+ SCI0.TDR = Cnv2Iso( (unsigned char) tx_status.p_buf[tx_status.sent_bytes++]);
379+ break;
380+ case COMM_CODE_EIA:
381+ SCI0.TDR = Cnv2Eia( (unsigned char) tx_status.p_buf[tx_status.sent_bytes++]);
382+ break;
383+ default:
384+ SCI0.TDR = (unsigned char) tx_status.p_buf[tx_status.sent_bytes++];
385+ break;
386+ }
387+ serial_proc = SCI_WAIT_TX_OK;
388+ serial_disable_timer = 2;
389+ SentBuf[tx_status.sent_bytes&0x0F] = SCI0.TDR;
390+ tx_status.tx_in_progress = 1;
391+
392+ if(SCI0.SSR.BIT.TDRE) SCI0.SSR.BIT.TDRE = 0; // TX empty intr. clear
393+ SCI0.SCR.BIT.TIE = 1; // TX empty intr. enable
394+ }
395+ break;
396+
397+ case SCI_WAIT_TX_OK:
398+ if( tx_status.tx_in_progress ) break;
399+ if( tx_status.sent_bytes >= tx_status.file_size ) {
400+ SCI0.SCR.BIT.TIE = 0; //TX empty Interrupt disable
401+ serial_proc = SCI_TX_IN_END;
402+ serial_disable_timer = 1000;
403+ } else {
404+ serial_proc = SCI_DATA_SET;
405+ }
406+ break;
407+
357408 case SCI_TX_IN_PROGRESS:
358409 if( tx_status.sent_bytes >= tx_status.file_size ) {
359410 SCI0.SCR.BIT.TIE = 0; //TX empty Interrupt disable
@@ -370,6 +421,9 @@
370421 break;
371422
372423 case SCI_TX_IN_END:
424+#ifdef SCI_DEBUG_ON
425+ printf("[SCI] TX Complete\r\n");
426+#endif
373427 serial_proc = SCI_IDLE;
374428 break;
375429
@@ -679,6 +733,12 @@
679733 sc1602_set_buffer( 0, "SCI is ready. " );
680734 break;
681735
736+ case SCI_DATA_SET:
737+ case SCI_WAIT_TX_OK:
738+ if( sci_setting.flow_control_request == FLOW_REQ_PAUSE ) sc1602_set_buffer( 0, "Pause.... " );
739+ else sc1602_set_buffer( 0, "Sending... " );
740+ break;
741+
682742 case SCI_TX_IN_PROGRESS:
683743 sc1602_set_buffer( 0, "Sending... " );
684744 break;
--- trunk/src/common.h (revision 8)
+++ trunk/src/common.h (revision 9)
@@ -17,6 +17,7 @@
1717 #ifdef DEBUG_ON
1818 #define SL811HS_DEBUG_ON
1919 #define MSCLASS_DEBUG_ON
20+ #define SCI_DEBUG_ON
2021 #endif
2122 #define SUB_PROC_RESULT unsigned char
2223 enum sub_proc_result_code {
Show on old repository browser