1 /* Copyright (C) 2014-2015 by Jacob Alexander
3 * This file is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This file is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this file. If not, see <http://www.gnu.org/licenses/>.
17 // ----- Includes -----
20 #include <Lib/ScanLib.h>
30 #include "connect_scan.h"
36 // Macro for adding to each uart Tx ring buffer
37 #define uart_addTxBuffer( uartNum ) \
39 while ( uart##uartNum##_buffer_items + count > uart_buffer_size ) \
41 warn_msg("Too much data to send on UART0, waiting..."); \
44 for ( uint8_t c = 0; c < count; c++ ) \
46 if ( Connect_debug ) \
48 printHex( buffer[ c ] ); \
49 print( " +" #uartNum NL ); \
51 uart##uartNum##_buffer[ uart##uartNum##_buffer_tail++ ] = buffer[ c ]; \
52 uart##uartNum##_buffer_items++; \
53 if ( uart##uartNum##_buffer_tail >= uart_buffer_size ) \
54 uart##uartNum##_buffer_tail = 0; \
55 if ( uart##uartNum##_buffer_head == uart##uartNum##_buffer_tail ) \
56 uart##uartNum##_buffer_head++; \
57 if ( uart##uartNum##_buffer_head >= uart_buffer_size ) \
58 uart##uartNum##_buffer_head = 0; \
62 // Macro for popping from Tx ring buffer
63 #define uart_fillTxFifo( uartNum ) \
65 uint8_t fifoSize = ( ( UART##uartNum##_PFIFO & UART_PFIFO_TXFIFOSIZE ) >> 2 ); \
66 if ( fifoSize == 0 ) \
68 while ( UART##uartNum##_TCFIFO < fifoSize ) \
70 if ( uart##uartNum##_buffer_items == 0 ) \
72 UART##uartNum##_D = uart##uartNum##_buffer[ uart##uartNum##_buffer_head++ ]; \
73 uart##uartNum##_buffer_items--; \
74 if ( uart##uartNum##_buffer_head >= uart_buffer_size ) \
75 uart##uartNum##_buffer_head = 0; \
79 // Macro for processing UART Rx
80 #define uart_processRx( uartNum ) \
82 if ( !( UART##uartNum##_S1 & UART_S1_RDRF ) ) \
84 uint8_t available = UART##uartNum##_RCFIFO; \
85 if ( available == 0 ) \
87 available = UART##uartNum##_D; \
88 UART##uartNum##_CFIFO = UART_CFIFO_RXFLUSH; \
91 while ( available-- > 0 ) \
93 uint8_t byteRead = UART##uartNum##_D; \
94 if ( Connect_debug ) \
96 printHex( byteRead ); \
98 printInt8( available ); \
101 switch ( uart##uartNum##_rx_status ) \
103 case UARTStatus_Wait: \
104 if ( Connect_debug ) \
108 uart##uartNum##_rx_status = byteRead == 0x16 ? UARTStatus_SYN : UARTStatus_Wait; \
110 case UARTStatus_SYN: \
111 if ( Connect_debug ) \
115 uart##uartNum##_rx_status = byteRead == 0x01 ? UARTStatus_SOH : UARTStatus_Wait; \
117 case UARTStatus_SOH: \
119 if ( Connect_debug ) \
123 uint8_t byte = byteRead; \
124 if ( byte <= Animation ) \
126 uart##uartNum##_rx_status = UARTStatus_Command; \
127 uart##uartNum##_rx_command = byte; \
128 uart##uartNum##_rx_bytes_waiting = 0xFFFF; \
132 uart##uartNum##_rx_status = UARTStatus_Wait; \
134 switch ( uart##uartNum##_rx_command ) \
137 Connect_receive_IdRequest( 0, (uint16_t*)&uart##uartNum##_rx_bytes_waiting, uartNum ); \
138 uart##uartNum##_rx_status = UARTStatus_Wait; \
141 if ( Connect_debug ) \
149 case UARTStatus_Command: \
151 if ( Connect_debug ) \
155 uint8_t (*rcvFunc)(uint8_t, uint16_t(*), uint8_t) = (uint8_t(*)(uint8_t, uint16_t(*), uint8_t))(Connect_receiveFunctions[ uart##uartNum##_rx_command ]); \
156 if ( rcvFunc( byteRead, (uint16_t*)&uart##uartNum##_rx_bytes_waiting, uartNum ) ) \
157 uart##uartNum##_rx_status = UARTStatus_Wait; \
161 erro_msg("Invalid UARTStatus..."); \
162 uart##uartNum##_rx_status = UARTStatus_Wait; \
166 if ( Connect_debug ) \
173 // Macros for locking/unlock Tx buffers
174 #define uart_lockTx( uartNum ) \
176 while ( uart##uartNum##_tx_status == UARTStatus_Wait ); \
177 uart##uartNum##_tx_status = UARTStatus_Wait; \
180 #define uart_unlockTx( uartNum ) \
182 uart##uartNum##_tx_status = UARTStatus_Ready; \
187 // ----- Function Declarations -----
190 void cliFunc_connectCmd ( char *args );
191 void cliFunc_connectIdl ( char *args );
192 void cliFunc_connectLst ( char *args );
193 void cliFunc_connectMst ( char *args );
194 void cliFunc_connectRst ( char *args );
195 void cliFunc_connectSts ( char *args );
199 // ----- Variables -----
201 // Connect Module command dictionary
202 CLIDict_Entry( connectCmd, "Sends a command via UART Connect, first arg is which uart, next arg is the command, rest are the arguments." );
203 CLIDict_Entry( connectIdl, "Sends N number of Idle commands, 2 is the default value, and should be sufficient in most cases." );
204 CLIDict_Entry( connectLst, "Lists available UARTConnect commands and index id" );
205 CLIDict_Entry( connectMst, "Sets the device as master. Use argument of s to set as slave." );
206 CLIDict_Entry( connectRst, "Resets both Rx and Tx connect buffers and state variables." );
207 CLIDict_Entry( connectSts, "UARTConnect status." );
208 CLIDict_Def( uartConnectCLIDict, "UARTConnect Module Commands" ) = {
209 CLIDict_Item( connectCmd ),
210 CLIDict_Item( connectIdl ),
211 CLIDict_Item( connectLst ),
212 CLIDict_Item( connectMst ),
213 CLIDict_Item( connectRst ),
214 CLIDict_Item( connectSts ),
215 { 0, 0, 0 } // Null entry for dictionary end
219 // -- Connect Device Id Variables --
220 uint8_t Connect_id = 255; // Invalid, unset
221 uint8_t Connect_master = 0;
224 // -- Control Variables --
225 uint32_t Connect_lastCheck = 0; // Cable Check scheduler
226 uint8_t Connect_debug = 0; // Set 1 for debug
229 // -- Rx Status Variables --
231 volatile UARTStatus uart0_rx_status;
232 volatile UARTStatus uart1_rx_status;
233 volatile uint16_t uart0_rx_bytes_waiting;
234 volatile uint16_t uart1_rx_bytes_waiting;
235 volatile Command uart0_rx_command;
236 volatile Command uart1_rx_command;
239 // -- Tx Status Variables --
241 volatile UARTStatus uart0_tx_status;
242 volatile UARTStatus uart1_tx_status;
245 // -- Ring Buffer Variables --
247 #define uart_buffer_size UARTConnectBufSize_define
248 volatile uint8_t uart0_buffer_head;
249 volatile uint8_t uart0_buffer_tail;
250 volatile uint8_t uart0_buffer_items;
251 volatile uint8_t uart0_buffer[uart_buffer_size];
252 volatile uint8_t uart1_buffer_head;
253 volatile uint8_t uart1_buffer_tail;
254 volatile uint8_t uart1_buffer_items;
255 volatile uint8_t uart1_buffer[uart_buffer_size];
257 volatile uint8_t uarts_configured = 0;
260 // -- Ring Buffer Convenience Functions --
262 void Connect_addBytes( uint8_t *buffer, uint8_t count, uint8_t uart )
264 // Too big to fit into buffer
265 if ( count > uart_buffer_size )
267 erro_msg("Too big of a command to fit into the buffer...");
274 uart_addTxBuffer( 0 );
275 uart_addTxBuffer( 1 );
277 erro_msg("Invalid UART to send from...");
283 // -- Connect send functions --
285 // patternLen defines how many bytes should the incrementing pattern have
286 void Connect_send_CableCheck( uint8_t patternLen )
288 // Wait until the Tx buffers are ready, then lock them
293 uint8_t header[] = { 0x16, 0x01, CableCheck, patternLen };
296 Connect_addBytes( header, sizeof( header ), 1 ); // Master
297 Connect_addBytes( header, sizeof( header ), 0 ); // Slave
299 // Send 0xD2 (11010010) for each argument
300 uint8_t value = 0xD2;
301 for ( uint8_t c = 0; c < patternLen; c++ )
303 Connect_addBytes( &value, 1, 1 ); // Master
304 Connect_addBytes( &value, 1, 0 ); // Slave
307 // Release Tx buffers
312 void Connect_send_IdRequest()
314 // Lock master bound Tx
318 uint8_t header[] = { 0x16, 0x01, IdRequest };
321 Connect_addBytes( header, sizeof( header ), 1 ); // Master
327 // id is the value the next slave should enumerate as
328 void Connect_send_IdEnumeration( uint8_t id )
330 // Lock slave bound Tx
334 uint8_t header[] = { 0x16, 0x01, IdEnumeration, id };
337 Connect_addBytes( header, sizeof( header ), 0 ); // Slave
343 // id is the currently assigned id to the slave
344 void Connect_send_IdReport( uint8_t id )
346 // Lock master bound Tx
350 uint8_t header[] = { 0x16, 0x01, IdReport, id };
353 Connect_addBytes( header, sizeof( header ), 1 ); // Master
359 // id is the currently assigned id to the slave
360 // scanCodeStateList is an array of [scancode, state]'s (8 bit values)
361 // numScanCodes is the number of scan codes to parse from array
362 void Connect_send_ScanCode( uint8_t id, TriggerGuide *scanCodeStateList, uint8_t numScanCodes )
364 // Lock master bound Tx
368 uint8_t header[] = { 0x16, 0x01, ScanCode, id, numScanCodes };
371 Connect_addBytes( header, sizeof( header ), 1 ); // Master
373 // Send each of the scan codes
374 Connect_addBytes( (uint8_t*)scanCodeStateList, numScanCodes * TriggerGuideSize, 1 ); // Master
380 // id is the currently assigned id to the slave
381 // paramList is an array of [param, value]'s (8 bit values)
382 // numParams is the number of params to parse from the array
383 void Connect_send_Animation( uint8_t id, uint8_t *paramList, uint8_t numParams )
385 // Lock slave bound Tx
389 uint8_t header[] = { 0x16, 0x01, Animation, id, numParams };
392 Connect_addBytes( header, sizeof( header ), 0 ); // Slave
394 // Send each of the scan codes
395 Connect_addBytes( paramList, numParams, 0 ); // Slave
401 void Connect_send_Idle( uint8_t num )
403 // Wait until the Tx buffers are ready, then lock them
407 // Send n number of idles to reset link status (if in a bad state)
408 uint8_t value = 0x16;
409 for ( uint8_t c = 0; c < num; c++ )
411 Connect_addBytes( &value, 1, 1 ); // Master
412 Connect_addBytes( &value, 1, 0 ); // Slave
415 // Release Tx buffers
421 // -- Connect receive functions --
423 // - Cable Check variables -
424 uint32_t Connect_cableFaultsMaster = 0;
425 uint32_t Connect_cableFaultsSlave = 0;
426 uint8_t Connect_cableOkMaster = 0;
427 uint8_t Connect_cableOkSlave = 0;
429 uint8_t Connect_receive_CableCheck( uint8_t byte, uint16_t *pending_bytes, uint8_t to_master )
431 // Check if this is the first byte
432 if ( *pending_bytes == 0xFFFF )
434 *pending_bytes = byte;
438 dbug_msg("PENDING SET -> ");
441 printHex( *pending_bytes );
450 // The argument bytes are always 0xD2 (11010010)
453 warn_print("Cable Fault!");
455 // Check which side of the chain
458 Connect_cableFaultsMaster++;
459 Connect_cableOkMaster = 0;
464 Connect_cableFaultsSlave++;
465 Connect_cableOkSlave = 0;
471 // Signal that the command should wait for a SYN again
476 // If cable check was successful, set cable ok
477 if ( *pending_bytes == 0 )
481 Connect_cableOkMaster = 1;
485 Connect_cableOkSlave = 1;
491 dbug_msg("CABLECHECK RECEIVE - ");
494 printHex( *pending_bytes );
498 // Check whether the cable check has finished
499 return *pending_bytes == 0 ? 1 : 0;
502 uint8_t Connect_receive_IdRequest( uint8_t byte, uint16_t *pending_bytes, uint8_t to_master )
504 dbug_print("IdRequest");
505 // Check the directionality
508 erro_print("Invalid IdRequest direction...");
511 // Check if master, begin IdEnumeration
512 if ( Connect_master )
514 // The first device is always id 1
515 // Id 0 is reserved for the master
516 Connect_send_IdEnumeration( 1 );
518 // Propagate IdRequest
521 Connect_send_IdRequest();
527 uint8_t Connect_receive_IdEnumeration( uint8_t id, uint16_t *pending_bytes, uint8_t to_master )
529 dbug_print("IdEnumeration");
530 // Check the directionality
533 erro_print("Invalid IdEnumeration direction...");
539 // Send reponse back to master
540 Connect_send_IdReport( id );
542 // Propogate next Id if the connection is ok
543 if ( Connect_cableOkSlave )
545 Connect_send_IdEnumeration( id + 1 );
551 uint8_t Connect_receive_IdReport( uint8_t id, uint16_t *pending_bytes, uint8_t to_master )
553 dbug_print("IdReport");
554 // Check the directionality
557 erro_print("Invalid IdRequest direction...");
560 // Track Id response if master
561 if ( Connect_master )
564 info_msg("Id Reported: ");
569 // Propagate id if yet another slave
572 Connect_send_IdReport( id );
578 // - Scan Code Variables -
579 TriggerGuide Connect_receive_ScanCodeBuffer;
580 uint8_t Connect_receive_ScanCodeBufferPos;
581 uint8_t Connect_receive_ScanCodeDeviceId;
583 uint8_t Connect_receive_ScanCode( uint8_t byte, uint16_t *pending_bytes, uint8_t to_master )
585 dbug_print("ScanCode");
586 // Check the directionality
589 erro_print("Invalid ScanCode direction...");
592 // Master node, trigger scan codes
593 if ( Connect_master ) switch ( (*pending_bytes)-- )
595 case 0xFFFF: // Device Id
596 Connect_receive_ScanCodeDeviceId = byte;
599 case 0xFFFE: // Number of TriggerGuides in bytes (byte * 3)
600 *pending_bytes = byte * 3;
601 Connect_receive_ScanCodeBufferPos = 0;
605 // Set the specific TriggerGuide entry
606 ((uint8_t*)&Connect_receive_ScanCodeBuffer)[ Connect_receive_ScanCodeBufferPos++ ] = byte;
608 // Reset the BufferPos if higher than 3
609 // And send the TriggerGuide to the Macro Module
610 if ( Connect_receive_ScanCodeBufferPos > 3 )
612 Connect_receive_ScanCodeBufferPos = 0;
613 Macro_triggerState( &Connect_receive_ScanCodeBuffer, 1 );
618 // Propagate ScanCode packet
619 else switch ( (*pending_bytes)-- )
621 case 0xFFFF: // Device Id
623 Connect_receive_ScanCodeDeviceId = byte;
625 // Lock the master Tx buffer
628 // Send header + Id byte
629 uint8_t header[] = { 0x16, 0x01, ScanCode, byte };
630 Connect_addBytes( header, sizeof( header ), 1 ); // Master
633 case 0xFFFE: // Number of TriggerGuides in bytes (byte * 3)
634 *pending_bytes = byte * 3;
635 Connect_receive_ScanCodeBufferPos = 0;
638 Connect_addBytes( &byte, 1, 1 ); // Master
643 Connect_addBytes( &byte, 1, 1 ); // Master
645 // Unlock Tx Buffer after sending last byte
646 if ( *pending_bytes == 0 )
651 // Check whether the scan codes have finished sending
652 return *pending_bytes == 0 ? 1 : 0;
655 uint8_t Connect_receive_Animation( uint8_t byte, uint16_t *pending_bytes, uint8_t to_master )
657 dbug_print("Animation");
663 // NOTE: If finer baud adjustment is needed see UARTx_C4 -> BRFA in the datasheet
664 uint16_t Connect_baud = UARTConnectBaud_define; // Max setting of 8191
665 uint16_t Connect_baudFine = UARTConnectBaudFine_define;
667 // Connect receive function lookup
668 void *Connect_receiveFunctions[] = {
669 Connect_receive_CableCheck,
670 Connect_receive_IdRequest,
671 Connect_receive_IdEnumeration,
672 Connect_receive_IdReport,
673 Connect_receive_ScanCode,
674 Connect_receive_Animation,
679 // ----- Interrupt Functions -----
681 // Master / UART0 ISR
682 void uart0_status_isr()
689 void uart1_status_isr()
697 // ----- Functions -----
699 // Resets the state of the UART buffers and state variables
702 // Rx Status Variables
703 uart0_rx_status = UARTStatus_Wait;
704 uart1_rx_status = UARTStatus_Wait;
705 uart0_rx_bytes_waiting = 0;
706 uart1_rx_bytes_waiting = 0;
708 // Tx Status Variables
709 uart0_tx_status = UARTStatus_Ready;
710 uart1_tx_status = UARTStatus_Ready;
712 // Ring Buffer Variables
713 uart0_buffer_head = 0;
714 uart0_buffer_tail = 0;
715 uart0_buffer_items = 0;
716 uart1_buffer_head = 0;
717 uart1_buffer_tail = 0;
718 uart1_buffer_items = 0;
722 // Setup connection to other side
723 // - Only supports a single slave and master
724 // - If USB has been initiallized at this point, this side is the master
725 // - If both sides assert master, flash error leds
726 void Connect_setup( uint8_t master )
728 // Indication that UARTs are not ready
729 uarts_configured = 0;
731 // Register Connect CLI dictionary
732 CLI_registerDictionary( uartConnectCLIDict, uartConnectCLIDictName );
735 Connect_master = master;
736 if ( Connect_master )
737 Connect_id = 0; // 0x00 is always the master Id
739 // Master / UART0 setup
740 // Slave / UART1 setup
741 // Setup the the UART interface for keyboard data input
742 SIM_SCGC4 |= SIM_SCGC4_UART0; // Disable clock gating
743 SIM_SCGC4 |= SIM_SCGC4_UART1; // Disable clock gating
745 // Pin Setup for UART0 / UART1
746 PORTA_PCR1 = PORT_PCR_PE | PORT_PCR_PS | PORT_PCR_PFE | PORT_PCR_MUX(2); // RX Pin
747 PORTA_PCR2 = PORT_PCR_DSE | PORT_PCR_SRE | PORT_PCR_MUX(2); // TX Pin
748 PORTE_PCR0 = PORT_PCR_PE | PORT_PCR_PS | PORT_PCR_PFE | PORT_PCR_MUX(3); // RX Pin
749 PORTE_PCR1 = PORT_PCR_DSE | PORT_PCR_SRE | PORT_PCR_MUX(3); // TX Pin
752 UART0_BDH = (uint8_t)(Connect_baud >> 8);
753 UART0_BDL = (uint8_t)Connect_baud;
754 UART0_C4 = Connect_baudFine;
755 UART1_BDH = (uint8_t)(Connect_baud >> 8);
756 UART1_BDL = (uint8_t)Connect_baud;
757 UART1_C4 = Connect_baudFine;
759 // 8 bit, Even Parity, Idle Character bit after stop
760 // NOTE: For 8 bit with Parity you must enable 9 bit transmission (pg. 1065)
761 // You only need to use UART0_D for 8 bit reading/writing though
762 // UART_C1_M UART_C1_PE UART_C1_PT UART_C1_ILT
763 UART0_C1 = UART_C1_M | UART_C1_PE | UART_C1_ILT;
764 UART1_C1 = UART_C1_M | UART_C1_PE | UART_C1_ILT;
766 // Number of bytes in FIFO before TX Interrupt
771 // Number of bytes in FIFO before RX Interrupt
775 // Enable TX and RX FIFOs
776 UART0_PFIFO = UART_PFIFO_TXFE | UART_PFIFO_RXFE;
777 UART1_PFIFO = UART_PFIFO_TXFE | UART_PFIFO_RXFE;
779 // Reciever Inversion Disabled, LSBF
780 // UART_S2_RXINV UART_S2_MSBF
784 // Transmit Inversion Disabled
789 // TX Enabled, RX Enabled, RX Interrupt Enabled
790 // UART_C2_TE UART_C2_RE UART_C2_RIE
791 UART0_C2 = UART_C2_TE | UART_C2_RE | UART_C2_RIE;
792 UART1_C2 = UART_C2_TE | UART_C2_RE | UART_C2_RIE;
794 // Add interrupts to the vector table
795 NVIC_ENABLE_IRQ( IRQ_UART0_STATUS );
796 NVIC_ENABLE_IRQ( IRQ_UART1_STATUS );
798 // UARTs are now ready to go
799 uarts_configured = 1;
801 // Reset the state of the UART variables
806 // Scan for updates in the master/slave
807 // - Interrupts will deal with most input functions
808 // - Used to send queries
809 // - SyncEvent is sent immediately once the current command is sent
810 // - SyncEvent is also blocking until sent
813 // Check if initially configured as a slave and usb comes up
814 // Then reconfigure as a master
815 if ( !Connect_master && Output_Available )
817 Connect_setup( Output_Available );
820 // Limit how often we do cable checks
821 uint32_t time_compare = 0x7FF; // Must be all 1's, 0x3FF is valid, 0x4FF is not
822 uint32_t current_time = systick_millis_count;
823 if ( Connect_lastCheck != current_time
824 && ( current_time & time_compare ) == time_compare
827 // Make sure we don't double check if the clock speed is too high
828 Connect_lastCheck = current_time;
830 // Send a cable check command of 2 bytes
831 Connect_send_CableCheck( UARTConnectCableCheckLength_define );
833 // If this is a slave, and we don't have an id yeth
834 // Don't bother sending if there are cable issues
835 if ( !Connect_master && Connect_id == 0xFF && Connect_cableOkMaster )
837 Connect_send_IdRequest();
841 // Only process commands if uarts have been configured
842 if ( uarts_configured )
844 // Check if Tx Buffers are empty and the Tx Ring buffers have data to send
845 // This happens if there was previously nothing to send
846 if ( uart0_buffer_items > 0 && UART0_TCFIFO == 0 )
847 uart_fillTxFifo( 0 );
848 if ( uart1_buffer_items > 0 && UART1_TCFIFO == 0 )
849 uart_fillTxFifo( 1 );
855 // ----- CLI Command Functions -----
857 void cliFunc_connectCmd( char* args )
859 // Parse number from argument
860 // NOTE: Only first argument is used
863 CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
867 switch ( numToInt( &arg1Ptr[0] ) )
870 Connect_send_CableCheck( UARTConnectCableCheckLength_define );
874 Connect_send_IdRequest();
878 Connect_send_IdEnumeration( 5 );
882 Connect_send_IdReport( 8 );
887 TriggerGuide scanCodes[] = { { 0x00, 0x01, 0x05 }, { 0x00, 0x03, 0x16 } };
888 Connect_send_ScanCode( 10, scanCodes, 2 );
894 case RemoteCapability:
911 void cliFunc_connectIdl( char* args )
913 // Parse number from argument
914 // NOTE: Only first argument is used
917 CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
920 info_msg("Sending Sync Idles...");
922 uint8_t count = numToInt( &arg1Ptr[0] );
923 // Default to 2 idles
927 Connect_send_Idle( count );
930 void cliFunc_connectLst( char* args )
932 const char *Command_strs[] = {
945 info_msg("List of UARTConnect commands");
946 for ( uint8_t cmd = 0; cmd < Command_TOP; cmd++ )
951 dPrint( (char*)Command_strs[ cmd ] );
955 void cliFunc_connectMst( char* args )
957 // Parse number from argument
958 // NOTE: Only first argument is used
961 CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
965 switch ( arg1Ptr[0] )
969 info_msg("Setting device as slave.");
977 info_msg("Setting device as master.");
984 void cliFunc_connectRst( char* args )
987 info_msg("Resetting UARTConnect state...");
994 void cliFunc_connectSts( char* args )
997 info_msg("UARTConnect Status");
998 print( NL "Device Type:\t" );
999 print( Connect_master ? "Master" : "Slave" );
1000 print( NL "Device Id:\t" );
1001 printHex( Connect_id );
1002 print( NL "Master <=" NL "\tStatus:\t");
1003 printHex( Connect_cableOkMaster );
1004 print( NL "\tFaults:\t");
1005 printHex( Connect_cableFaultsMaster );
1006 print( NL "\tRx:\t");
1007 printHex( uart1_rx_status );
1008 print( NL "\tTx:\t");
1009 printHex( uart1_tx_status );
1010 print( NL "Slave <=" NL "\tStatus:\t");
1011 printHex( Connect_cableOkSlave );
1012 print( NL "\tFaults:\t");
1013 printHex( Connect_cableFaultsSlave );
1014 print( NL "\tRx:\t");
1015 printHex( uart0_rx_status );
1016 print( NL "\tTx:\t");
1017 printHex( uart0_tx_status );