53#define BULK_PACKET_SIZE 64
55static int (*input_handler)(
unsigned char c) = NULL;
56static unsigned char usb_buffer[BULK_PACKET_SIZE];
57static char manufacturer[] =
"Contiki-NG";
58static char product[] =
"Contiki-NG USB";
59static char cdc_interface[] =
"Contiki-NG CDC";
61PROCESS(usb_arch_process,
"USB Arch");
77 input_handler =
input;
100 while(buffer_size > BULK_PACKET_SIZE) {
101 tud_cdc_write(buffer + i, BULK_PACKET_SIZE);
103 i += BULK_PACKET_SIZE;
104 buffer_size -= BULK_PACKET_SIZE;
108 tud_cdc_write(buffer + i, buffer_size);
114 tud_cdc_write_flush();
122 uint32_t usb_read_length;
125 if(tud_cdc_available()) {
126 usb_read_length = tud_cdc_read(usb_buffer,
sizeof(usb_buffer));
127 for(i = 0; i < usb_read_length && input_handler; i++) {
128 input_handler(usb_buffer[i]);
PROCESS_THREAD(cc2538_rf_process, ev, data)
Implementation of the cc2538 RF driver process.
void usb_set_input(int(*input)(unsigned char c))
Sets the input handler called in the event handler.
void usb_interrupt_handler(void)
Handles the interrupt.
void usb_flush(void)
Flush USB buffer.
void usb_write(uint8_t *buffer, uint32_t buffer_size)
Writes to the USB driver.
void usb_descriptor_set_manufacturer(char *manufacturer)
Set the manufactorer.
void usb_descriptor_set_cdc_interface(char *cdc_interface)
Set the cdc interface.
void usb_arch_init(void)
Initialize the architecture specific USB driver.
void usb_init(void)
Initialize the USB driver.
void usb_descriptor_set_product(char *product)
Set the product.
#define PROCESS(name, strname)
Declare a process.
#define PROCESS_BEGIN()
Define the beginning of a process.
#define PROCESS_END()
Define the end of a process.
void process_start(struct process *p, process_data_t data)
Start a process.
#define PROCESS_YIELD_UNTIL(c)
Yield the currently running process until a condition occurs.
void process_poll(struct process *p)
Request a process to be polled.
static void input(void)
Process a received 6lowpan packet.
USB header file for the nRF.
USB descriptors header file for the nRF.