kosmos/source/firmware/arch/stm32f4xx/__dep/print.c

48 lines
1.0 KiB
C
Raw Normal View History

2016-07-28 19:02:54 +00:00
#include <stdio.h>
#include <string.h>
#include "usbd_cdc_vcp.h"
/**
* @brief Transmit a char, if you want to use printf(),
* you need implement this function
*
* @param pStr Storage string.
* @param c Character to write.
*/
void PrintChar(char c) {
/* Send a char like:
while(Transfer not completed);
Transmit a char;
*/
USB_VCOM_Send( &c, 1);
}
/**
* @brief Implementation of fputs using the DBGU as the standard output. Required
* for printf().
*
* @param pStr String to write.
* @param pStream Output stream.
*
* @return Number of characters written if successful, or -1 if the output
* stream is not stdout or stderr.
*/
signed int fputs(const char *pStr, FILE *pStream)
{
#if 0
signed int num = 0;
while (*pStr != 0) {
if (fputc(*pStr, pStream) == -1) {
return -1;
}
num++;
pStr++;
}
return num;
#endif
USB_VCOM_Send((char*)pStr, strlen(pStr));
return strlen(pStr);
}