crashtest-r0ket/firmware/applications/serial/serial.c

74 lines
1.1 KiB
C
Raw Normal View History

#include <sysinit.h>
#include "basic/basic.h"
#include "lcd/lcd.h"
#include "lcd/print.h"
#include "funk/nrf24l01p.h"
2011-07-27 16:22:53 +00:00
#include "usbcdc/usb.h"
#include "usbcdc/usbcore.h"
#include "usbcdc/usbhw.h"
#include "usbcdc/cdcuser.h"
#include "usbcdc/cdc_buf.h"
#include <string.h>
#if CFG_USBMSC
2011-07-27 16:22:53 +00:00
#error "MSC is defined"
#endif
#if !CFG_USBCDC
2011-07-27 16:22:53 +00:00
#error "CDC is not defined"
#endif
/**************************************************************************/
void f_ser(void) {
2011-07-27 16:22:53 +00:00
usbCDCInit();
};
void f_disconnect(void) {
2011-07-27 16:22:53 +00:00
usbCDCOff();
};
#define LEN 10
void f_sread(){
uint8_t buf[LEN+1];
int l=LEN;
lcdPrint("Bytes:");
CDC_OutBufAvailChar (&l);
lcdPrintInt(l);
lcdNl();
lcdPrint("read:");
CDC_RdOutBuf (buf, &l);
lcdPrintInt(l);
lcdNl();
buf[l]=0;
lcdPrintln(buf);
};
void f_echo(){
uint8_t buf[2] = {0,0};
int l;
while(1){
CDC_OutBufAvailChar(&l);
if( l ){
l = 1;
CDC_RdOutBuf (buf, &l);
puts(buf);
}
//puts("hello world\r\n");
//delayms(1);
}
};
void f_say(){
puts("hello world\r\n");
};