crashtest-r0ket/firmware/usbcdc/util.c

43 lines
889 B
C
Raw Normal View History

2011-07-27 16:22:53 +00:00
#include <sysinit.h>
#include <string.h>
2011-07-27 16:22:53 +00:00
#include "usbcdc/usb.h"
#include "usbcdc/usbcore.h"
#include "usbcdc/cdc_buf.h"
#include "usbcdc/usbhw.h"
#include "usbcdc/cdcuser.h"
int puts(const char * str){
if(!USB_Configuration)
return -1;
2011-12-10 20:39:32 +00:00
int len = strlen(str);
CDC_WrInBuf(str, &len);
2011-07-27 16:22:53 +00:00
return 0;
}
2011-07-30 01:26:59 +00:00
int puts_plus(const char * str){
return puts(str);
2011-07-30 01:26:59 +00:00
}
2011-07-27 16:22:53 +00:00
void usbCDCInit(){
CDC_Init(); // Initialise VCOM
USB_Init(); // USB Initialization
USB_Connect(TRUE); // USB Connect
/* You could wait until serial is connected. */
#if 0 // We don't
uint32_t usbTimeout = 0;
while ( usbTimeout < CFG_USBCDC_INITTIMEOUT / 10 ) {
if (USB_Configuration) break;
delayms(10); // Wait 10ms
usbTimeout++;
}
#endif
}
2011-07-29 17:01:41 +00:00
void usbCDCOff(void){
2011-07-27 16:22:53 +00:00
USB_Connect(FALSE);
}