This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

usb libs

It important that somebody help me to finish this please,

usb asynchronous
http://www.keil.com/forum/19557/

I took the example posted on this forum and try to put it into this code

here is library

mbed.org/.../USBAudio_8cpp_source.html

#define TOTAL_DESCRIPTOR_LENGTH ((1 * CONFIGURATION_DESCRIPTOR_LENGTH) \ 
                               + (3 * INTERFACE_DESCRIPTOR_LENGTH) \ 
                               + (1 * CONTROL_INTERFACE_DESCRIPTOR_LENGTH) \ 
                               + (1 * INPUT_TERMINAL_DESCRIPTOR_LENGTH) \ 
                               + (1 * FEATURE_UNIT_DESCRIPTOR_LENGTH) \ 
                               + (1 * OUTPUT_TERMINAL_DESCRIPTOR_LENGTH) \ 
                               + (1 * STREAMING_INTERFACE_DESCRIPTOR_LENGTH) \ 
                               + (1 * FORMAT_TYPE_I_DESCRIPTOR_LENGTH) \ 
                               + (1 * (ENDPOINT_DESCRIPTOR_LENGTH + 2)) \    // <------------ changed to + (2 *
                               + (1 * STREAMING_ENDPOINT_DESCRIPTOR_LENGTH) )




// Endpoint - Standard Descriptor
        ENDPOINT_DESCRIPTOR_LENGTH + 2,         // bLength
        ENDPOINT_DESCRIPTOR,                    // bDescriptorType
        PHY_TO_DESC(EPISO_OUT),                 // bEndpointAddress
        E_ISOCHRONOUS,                          // bmAttributes
        LSB(PACKET_SIZE_ISO),                   // wMaxPacketSize
        MSB(PACKET_SIZE_ISO),                   // wMaxPacketSize
        0x01,                                   // bInterval
        0x00,                                   // bRefresh
        0x83,                                   // bSynchAddress   <----------- EP3IN

         // Endpoint - Standard Descriptor         // <-------- additional feedback EP
        ENDPOINT_DESCRIPTOR_LENGTH + 2,         // bLength
        ENDPOINT_DESCRIPTOR,                    // bDescriptorType
        PHY_TO_DESC(EPISO_IN),                 // bEndpointAddress <---------EPISO_IN
        E_ISOCHRONOUS |  E_ASYNCHRONOUS,      // bmAttributes <------ASYNC
        0x03,                   // wMaxPacketSize <----- 3 bytes
        0x03,                   // wMaxPacketSize
        0x01,                                   // bInterval  <------- 1 packet every frame
        0x01,                                   // bRefresh   <--------2ms
        0x00,                                   // bSynchAddress



Code
// Called in ISR context on each start of frame
extern uint32_t sampling_interval;
void USBAudio::SOF(int frameNumber) {
    uint16_t size = 0;
uint32_t current_timer_count;
 uint32_t feedback_value;
 uint32_t last_timer_count;
 uint16_t interface;
 uint8_t alternate;



                                                        // feedback
  current_timer_count = LPC_TIM1->TC;                   // capture current SOF timing on the Timer1
  if (interface == 1 & alternate == 1) {              // When interface 1 / alt 1 is enabled,
                                                // calculate master/SOF frequency ratio in 10.10 (10.14) format

    feedback_value = ((current_timer_count - last_timer_count) << 14) / sampling_interval;

   //feedback_value = 32 << 14;    // test value for 32k sampling



    USBDevice:: writeNB( EP3IN, (uint8_t *)&feedback_value, 3 );        // and send it to the feedback IN EP


  }
  last_timer_count = current_timer_count;       // update the last SOF timing


Code
uint32_t sampling_interval;
int main() {
    int16_t buf[LENGTH_AUDIO_PACKET/2];

    // attach a function executed each 1/FREQ s
    tic.attach_us(tic_handler, 1000000.0/(float)FREQ);

    sampling_interval =  1000000.0/FREQ;

    LPC_SC->PCONP |= (1 << 2);     // Power on Timer'

    LPC_TIM1->TCR = 1;                                       /* TC1 Enable */


    while (1) {
        // read an audio packet
        USBaudio.read((uint8_t *)buf);

        // put buffer in the circ buffer
        for(int i = 0; i < LENGTH_AUDIO_PACKET/2; i++) {
            cbuf.queue(buf[i]);
        }
    }
}

I am getting Too few arguments in function call

for USBDevice:: writeNB( EP3IN, (uint8_t *)&feedback_value, 3 );

How do I fix this please.

0