12.07.2015 Views

Programming Manual Elektor Proton Robot - ELEKTOR.se

Programming Manual Elektor Proton Robot - ELEKTOR.se

Programming Manual Elektor Proton Robot - ELEKTOR.se

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}//This function waits for the transmitter to become idle, and then starts transmission of the character. It//does not wait for the transmission to complete.void UART_CHAR_SEND( char c ){while( !TXIF ) continue;TXREG = c;}//This function u<strong>se</strong>s uart_char_<strong>se</strong>nd to <strong>se</strong>nd a 0-terminated string of characters.void UART_STRING_SEND( const char *p ){while( *p != 0 ){UART_CHAR_SEND( *p );p++;}}//This function receives a string of characters. The pointer received must point to a caller-allocated string.//Characters that are in the string ignore will be skipped. Receiving will terminate as soon as one of the//following conditions holds:// ? received_size - 1 characters have been received (not counting skipped characters, - 1 to have room// for the terminating \0), or// ? milli<strong>se</strong>conds milli<strong>se</strong>conds have elap<strong>se</strong>d, or// ? A character that is in the string terminate has been received.void UART_STRING_RECEIVE(char *received,unsigned char received_size,unsigned int milli<strong>se</strong>conds,const char * terminate,const char * ignore){unsigned char i, t;char c;t = 0;i = 0;for(;;){received[ i ] = '\0';if( i + 1 == received_size ){return;}if( UART_CHAR_AVAILABLE() ){c = UART_CHAR_RECEIVE();if( ! CHAR_IN( c, ignore )){received[ i ] = c;i++;}if( CHAR_IN( c, terminate )){return;}} el<strong>se</strong> {__delay_us( 100 );t++;if( t == 10 ){t = 0;milli<strong>se</strong>conds--;if( milli<strong>se</strong>conds == 0 ){Bart Huyskens <strong>Manual</strong> <strong>Elektor</strong> <strong>Proton</strong> V1.0 3 April 2011 158

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!