Oki JOB60851 User Manual
Page 50
Chapter 4 Software Development
page 4-15
Receive Only Skeleton
char buf_rx[BUF_SIZE];
void bulk_rx(uchar *buf, uint size)
{
/* Called after receiving each packet, this function manages buffer overflow for the application
layer. */
if(Receive buffer threatens to overflow){
usb_rx_start(buf_rx, EP_RX);
/* Reinitialize pointer to start of buffer */
}
}
void main(void)
{
/* Initialize microcontroller and peripherals, etc. */
:
usb_init();
/* Initialize USB control vaiables */
usb_set_callback(EP_RX,rx_callback);
/* Specify receive callback function */
usb_rx_start(buf_rx, EP_RX);
/* Specify receive data buffer and start */
:
while(1){
/* Main loop */ ;
}
}
Transmit Only Skeleton
char buf_tx[BUF_SIZE];
void bulk_tx(uchar *buf, uint size)
{
/* This function is called after transmitting each packet. */
usb_tx_start(buf_tx, EP_TX);
/* Reinitialize pointer to start of buffer */
}
void main(void)
{
/* Initialize microcontroller and peripherals, etc. */
:
usb_init();
/* Initialize USB control variables */
usb_set_callback(EP_TX, bulk_tx);
/* Specify transmit callback function */
usb_tx_start(buf_tx, EP_TX);
/* Specify transmit data buffer and start */
:
while(1){
/* Main loop */ ;
}
}