ASF4 (Atmel Start) CDC Example, Where's the Documentation?

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm trying to get a simple project up and running that requires a USB CDC Serial Port, a few interrupts, I2C, etc... 

 

I am a self taught AVR guy. Did a professional project using an STM8. This is my first real CortexM project.

I've created an Atmel Start project that includes the USB CDC Echo example. The example works on my board, but modifying the code to eliminate the echo and build a proper terminal interface has turned out more difficult and hackish then I thought it would be.

 

The echo appears to be occuring in the bulk_out and bulk_in callbacks. The following code will display typed keys on the LCD. I have confirmed that cdcdf_acm_write() will send text strings to my PC as expected.

 

However, unusually I found that in the bulk_out function, if I didn't perform a write of length 0, that these callbacks would stop firing when I would type random letters into my terminal program.

 

In short, I do not how the USB CDC ACM driver works. I also cannot find documentation for it. Does documentation for it exist? I have the ASF4 API Reference manual. A google search for cdcdf_acm_write isn't bearing much fruit.

 

/**

 * \brief Callback invoked when bulk OUT data received

 */

static bool usb_device_cb_bulk_out(const uint8_t ep, const enum usb_xfer_code rc, const uint32_t count)

{

//cdcdf_acm_write((uint8_t *)usbd_cdc_buffer, count);

cdcdf_acm_write(usbd_cdc_buffer,0);

 

/* No error. */

return false;

}

 

/**

 * \brief Callback invoked when bulk IN data received

 */

static bool usb_device_cb_bulk_in(const uint8_t ep, const enum usb_xfer_code rc, const uint32_t count)

{

/* Echo data. */

int x = cdcdf_acm_read((uint8_t *)usbd_cdc_buffer, sizeof(usbd_cdc_buffer));

char temp[16];

strncpy(temp,usbd_cdc_buffer,1);

temp[1]=0;

lcd_writeCommand(0x08);

lcd_writeCommand(0x01);

lcd_writeCommand(0x02);

lcd_writeText(temp);

lcd_writeCommand(0x0C);

 

/* No error. */

return false;

}

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is only a guess: do everything in usb_device_cb_bulk_out. This is the read callback (you are not writing so you should not depend on reaching the write callback).

/Lars

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Somewhat of a necro bump..

 

brad did you every get this working, or find more documentation? Working on this now and it's not clear at all how it actually operates..

murph

Debugging - Being a detective in a crime movie where you are also the murderer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Any updates ?