/* ** =================================================================== ** Method : CDC1_SendString (component FSL_USB_CDC_Device) ** Description : ** Method to send a string to the USB interface. Method is ** non-blocking: if string cannot be sent, it will be lost. If ** OnError() event is enabled, the error event will be called ** in case of error. ** Parameters : ** NAME - DESCRIPTION ** * Chr - Pointer to string to send. ** Returns : ** --- - Error code. ERR_OK for success and ** ERR_FAILED otherwise. ** =================================================================== */ uint8_t CDC1_SendString(CDC1_TComData *Chr) { uint8_t res = ERR_OK; while(*Chr != '\0') { if (CDC1_SendChar(*Chr)!=ERR_OK) { res = ERR_TXFULL; } Chr++; } return res; }
/* ** =================================================================== ** Method : CDC1_SendBlock (component FSL_USB_CDC_Device) ** Description : ** Method to send a data block to the USB interface. Method is ** non-blocking: if data cannot be sent, it will be lost. If ** OnError() event is enabled, the error event will be called ** in case of error. ** Parameters : ** NAME - DESCRIPTION ** * data - Pointer to data to send. ** dataSize - Size of data in bytes ** Returns : ** --- - Error code. ERR_OK for success and ** ERR_FAILED otherwise. ** =================================================================== */ uint8_t CDC1_SendBlock(uint8_t *data, uint16_t dataSize) { uint8_t res = ERR_OK; while(dataSize > 0) { if (CDC1_SendChar(*data)!=ERR_OK) { res = ERR_TXFULL; } dataSize--; data++; } return res; }
/* ** =================================================================== ** Method : CDC1_SendBlock (component FSL_USB_CDC_Device) ** Description : ** Method to send a data block to the USB interface. Method is ** non-blocking: if data cannot be sent, it will be lost. If ** OnError() event is enabled, the error event will be called ** in case of error. ** Parameters : ** NAME - DESCRIPTION ** * data - Pointer to data to send. ** dataSize - Size of data in bytes ** Returns : ** --- - Error code. ERR_OK for success and ** ERR_FAILED otherwise. ** =================================================================== */ byte CDC1_SendBlock(byte *data, word dataSize) { byte res = ERR_OK; while(dataSize > 0) { if (CDC1_SendChar(*data)!=ERR_OK) { res = ERR_TXFULL; } dataSize--; data++; } return res; }
/* ** =================================================================== ** Method : CDC1_StdIOSendChar (component FSL_USB_CDC_Device) ** Description : ** StdIO handler to sends a character. ** Parameters : ** NAME - DESCRIPTION ** ch - Character to send. ** Returns : Nothing ** =================================================================== */ void CDC1_StdIOSendChar(uint8_t ch) { while (CDC1_SendChar((uint8_t)ch)==ERR_TXFULL){} /* Send char */ }
static void CopyCDCtoUARTStdIOSendChar(uint8_t ch) { while (CDC1_SendChar((uint8_t)ch)==ERR_TXFULL){} /* Send char */ CLS1_SendChar((uint8_t)ch); /* Send char */ }
void USB_SendByte(uint8 b){ CDC1_SendChar(b); }