Frame interrupt for isosynchronus audio endpoint

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Frame interrupt for isosynchronus audio endpoint

540 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by terminus on Thu Apr 23 07:36:23 MST 2015
Hi!

I am currently working on an I2S-USB-Converter where an external ADC samples an audio signal (48kHz, 32 bit) and the connected lpc1759 sends the audio data to the pc.

I got the usb device descriptors set up and the pc recognizes the lpc as an usb sound card. I am also able to open the audio stream from the sound card but i haven't implemented the frame handler yet because i didn't get the frame request interrupt.

Here is the code i got so far:

// EP 3 IN
#define USB_AUDIO_ENDPOINT_ADDRESS 0x83 
#define USB_AUDIO_ENDPOINT 3
#define USB_AUDIO_ENDPOINT_INDEX 7

// Handle frame request interrupt
ErrorCode_t USB_AUDIO_FRAME_HANDLER(USBD_HANDLE_T hUsb, void* data, uint32_t event)
{
TOGGLE_LED();

return LPC_OK;
}

void USB_Init(void)
{
// enable USB PLL and clocks
Chip_USB_Init();

// Dev, AHB clock enable
LPC_USB->USBClkCtrl = 0x12;
while ((LPC_USB->USBClkSt & 0x12) != 0x12)
;

// call back structures
USBD_API_INIT_PARAM_T usb_param;
memset((void *) &usb_param, 0, sizeof(USBD_API_INIT_PARAM_T));
usb_param.usb_reg_base = LPC_USB_BASE + 0x200;
usb_param.max_num_ep = 4;
usb_param.mem_base = USB_STACK_MEM_BASE;
usb_param.mem_size = USB_STACK_MEM_SIZE;

// Set the USB descriptors
USB_CORE_DESCS_T desc;
desc.device_desc = (uint8_t *) &USB_DeviceDescriptor[0];
desc.string_desc = (uint8_t *) &USB_StringDescriptor[0];
desc.high_speed_desc = (uint8_t *) &USB_FsConfigDescriptor[0];
desc.full_speed_desc = (uint8_t *) &USB_FsConfigDescriptor[0];
desc.device_qualifier = 0;

// USB Initialization
ErrorCode_t ret = USBD_API->hw->Init(&g_hUsb, &desc, &usb_param);

// Check if initialisation was successfull
if (ret == LPC_OK)
{
// Install usb class handler
ret = USBD_API->core->RegisterClassHandler(g_hUsb, USB_Class_Handler, &g_hUsb);

// Check if handler installation was successful
if (ret == LPC_OK)
{
// Register endpoint handler for streaming interface
ret = USBD_API->core->RegisterEpHandler(g_hUsb, USB_AUDIO_ENDPOINT_INDEX, USB_AUDIO_FRAME_HANDLER, &g_hUsb);

// Enable streaming endpoint
USBD_API->hw->EnableEP(g_hUsb, USB_AUDIO_ENDPOINT_ADDRESS);

// Check if handler installation was successful
if (ret == LPC_OK)
{
//  Enable USB interrupts
NVIC_EnableIRQ(USB_IRQn);

// Connect USB
USBD_API->hw->Connect(g_hUsb, 1);

// Realise EP3
LPC_USB->ReEp |= (1 << USB_AUDIO_ENDPOINT);

// Set endpoint package size
LPC_USB->EpInd = USB_AUDIO_ENDPOINT;
LPC_USB->MaxPSize = 828;

// Disable dma for EP3
LPC_USB->EpDMADis = (1 << USB_AUDIO_ENDPOINT);

// Enable TX interrupt for EP3
LPC_USB->EpIntEn |= (1 << USB_AUDIO_ENDPOINT);

// Enable frame request interrupt
LPC_USB->DevIntEn |= 1;
}
}

}
}


Can anybody help me with my problem?

Kind regards
Christian

P.S.: I am using the latest LPCOpen device drivers (2.10) with the included USDB rom stack.
Labels (1)
0 Kudos
0 Replies