Hi,
I was trying to create a virtual COM port to communicate a tm4c123 uC with my pc (via UART), to make a simple echo program, so i took a look to TI´s usb_dev_serial example. I spent a day trying to understand how this code works, but it´s to complicated. Searching for internet i found i readable and understandable code, but it doesn´t work. I would like to modificate the usb_dev_serial example to get something like this (which is the understundable code):
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "inc/hw_uart.h"
#include "inc/hw_sysctl.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/timer.h"
#include "driverlib/uart.h"
#include "driverlib/rom.h"
#include "usblib/usblib.h"
#include "usblib/usbcdc.h"
#include "usblib/device/usbdevice.h"
#include "usblib/device/usbdcdc.h"
#include "utils/ustdlib.h"
#include "utils/uartstdio.h"
#include "usb_structs.h"
#include "usbconfig.h"
// UART configuration for uartstdio library
void ConfigureUART(void)
{
// Enable the GPIO Peripheral used by the UART.
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
// Enable UART0
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
// Configure GPIO Pins for UART mode.
ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
// Use the internal 16MHz oscillator as the UART clock source.
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
// Initialize the UART for console I/O.
UARTStdioConfig(0, 115200, 16000000);
}
// This is the main application entry function.
int main(void)
{
// Set the clocking to run from the PLL at 50MHz
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
// Enable the GPIO port that is used for the on-board LED.
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
// Enable the GPIO pins for the LED (PF2 & PF3).
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3|GPIO_PIN_2);
// Initialise UART for debug
ConfigureUART();
// Initialise USBCDC for VCP.
USBInit();
while(1)
{
SysCtlSleep();
}
}
// Data handler for RX channel
void RxDataHandler()
{
uint32_t numbytes;
uint8_t data[32];
numbytes = USBBufferDataAvailable(&RxBuffer);
USBBufferRead(&RxBuffer, data, numbytes);
USBBufferFlush(&RxBuffer);
USBBufferWrite(&TxBuffer, data, numbytes);
}
Is there a way to make something like this?
I already have the usbconfig and usb_structs libraries, but i don´t know why they don´t work. I´m working with ccs 6.1.
Hope someone could help me!
Thanks!