Other Parts Discussed in Thread: SYSBIOS
Tool/software: TI-RTOS
Hello. I'm trying to get a USB device to communicate through to our device. Right now we're just looking for the device to send characters through the USB cable. Long term we would like to have this also be a way to update our board, but right now, the goal is to get it talk properly. Everything is up and running, it's just the communications that are not working right. I have borrowed code from the usbserialdevice_EK_TM4C129XL_TI example to get the project off the ground. So here is my initialization of the USB and ISR
void Init_USB0(void) { USBRingBufInit(&RingBuffer3, Rx3Buffer, 1024); Session3.pRingBuffer = &RingBuffer3; Session3.pfnUSBSend = &USB0_Send; USBCDCD_init(); USBIntDisableControl(USB0_BASE, USB_INTCTRL_RESET | USB_INTCTRL_DISCONNECT | USB_INTCTRL_RESUME | USB_INTCTRL_SUSPEND | USB_INTCTRL_SOF); USBIntDisableEndpoint(USB0_BASE, USB_INTEP_ALL); IntDisable(INT_USB0); IntEnable(INT_USB0); USBIntEnableEndpoint(USB0_BASE, USB_EP_1); USBIntRegister(USB0_BASE, USB0_ISR); }
USBCDCD_init() goes to the example code and nothing is changed there. I disabled the controller and endpoint interrupts because I only need the interrupt when something is coming over the line.
void USB0_ISR(void) { uint32_t ui32Status; ui32Status = USBEndpointStatus(USB0_BASE, USB_EP_1); if (ui32Status == USB_DEV_TX_TXPKTRDY) { USBRingBufWriteOne(&RingBuffer3, USBEndpointDataGet(USB0_BASE, USB_EP_1, read_data, data_size)); } USBDevEndpointDataAck(USB0_BASE,USB_EP_1,true); USBDevEndpointStatusClear(USB0_BASE, USB_EP_1, ui32Status); USB0DeviceIntHandler(); }
The ring buffer by the way is where we process all our bytes. It's how existing code already is written and will be easiest to conform to that method. Here is the declaration of read_data and data_size
uint8_t read_data[1024];
uint32_t *data_size;
Finally my send part of the code:
void USB0_Send(const uint8_t *pui8Buffer, uint32_t ui32Count) { unsigned int buffAvailSize; while(ui32Count--) { buffAvailSize = USBBufferSpaceAvailable(&txBuff); while(buffAvailSize == 0){ buffAvailSize = USBBufferSpaceAvailable(&txBuff); Task_sleep(10); } USBBufferWrite(&txBuff, (uint8_t *)*pui8Buffer++, 1); } }
Currently my code is not even getting to this point, so I haven't worked on making this part any better. Please let me know if there is something else I've forgotten to mention.