/***************************************************************************** * Name: * putchar_usb * In: * c: character to be sent * Out: * * Description: * Put one character into tx_buffer. * * Assumptions: * -- *****************************************************************************/ void putchar_usb(char c) { if(GetStart_transactions() == FALSE) return; while(c != (char)cdc_putch(c)) { DelayTask(5); } }
/***************************************************************************** * Name: * print * In: * s: string * Out: * n/a * * Description: * Print the specified string. * Assumptions: * *****************************************************************************/ void print(char *s) { while(*s) { while(*s != (char)cdc_putch(*s)) ; s++; } }
void CDC_Send_Buffer(unsigned char *Array_to_send,unsigned int u16Size) { unsigned int u16Counter=0; while(u16Size--) { while(*Array_to_send != (char)cdc_putch(*Array_to_send)); Array_to_send++; cdc_process(); } }
void CDC_Send_String(unsigned char *Array_to_send) { while(*Array_to_send!='\0') { // if called while no usb is hooked up, usb buffer will get full and cause // this to loop indefinitely while(*Array_to_send != (char)cdc_putch(*Array_to_send)); Array_to_send++; cdc_process(); } delay_ms(25); // KP }
/***************************************************************************** * Name: * printf_usb * In: * s: string to be sent * Out: * * Description: * Put one string into tx_buffer. * * Assumptions: * -- *****************************************************************************/ void printf_usb(char *s) { while(*s) { #if 0 while(*s != (char)cdc_putch(*s)){}; #else putchar_usb(*s); #endif s++; } }
/***************************************************************************** * Name: * USB_PktSend * In: * _toSend: * Out: * n/a * * Description: * Send Pkt * FIRST_BYTE + (LENGTH) + PAYLOAD + CHKSUM * Assumptions: * *****************************************************************************/ void USB_PktSend(byte *_toSend, byte _len) { byte cnt=0, byteToSend, cks=0; byteToSend = FIRST_BYTE_EMPTY; if (_len>0) byteToSend |= 0x01; // Primo Byte while(byteToSend != (char)cdc_putch(byteToSend)) ; cks += byteToSend; // Byte Length if (_len>0){ byteToSend = _len; while(byteToSend != (char)cdc_putch(byteToSend)) ; cks += byteToSend; } // PayLoad while (cnt<_len){ while(*_toSend != (char)cdc_putch(*_toSend)) ; cks += (*_toSend); _toSend++; cnt++; } // CheckSum while(cks != (char)cdc_putch(cks)) ; }
/*-----------------------------------------------------------------------------------*/ void slip_arch_writeb(unsigned char c) { #if (SLIP_COMM == SLIP_USB) while(GetStart_transactions() == FALSE) { DelayTask(10); } while(cdc_putch(c) != c) { //DelayTask(1); } if (c==SLIP_END) { cdc_process(); } #elif (SLIP_COMM == SLIP_UART) uart_putchar(UART_NUMBER, (char)c); #endif buffer_send[buffer_send_i++]=c; }