How to enable and use USB Sleep interrupt on a K64 using PE and sdk1.3

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to enable and use USB Sleep interrupt on a K64 using PE and sdk1.3

1,574件の閲覧回数
inorman
Contributor III

Hi has anyone tried enabling and using the USB sleep interrupt?  This is on a usb cdc device application,

 

It looks like I should be calling   usb_hal_khci_enable_interrupts(INTR_SLEEP);

But how and where do I write the interrupt handler to deal with this event?   

 

Or can I use processor expert to generate the interrupt to go in events.c like other interrupts.

 

Thank you for you time.

Ian

ラベル(1)
0 件の賞賛
返信
2 返答(返信)

1,157件の閲覧回数
inorman
Contributor III

So far I've found Setting the parameter 

/* Advance suspend resume */
#define USBCFG_DEV_ADVANCED_SUSPEND_RESUME (1)

in usb_device_confih.h should enable the usb sleep interrupt.

Then I've put my usb interrupt handler in events.c  

void USB0_IRQHandler(void) 
{
      GPIO_DRV_TogglePinOutput(CPU_LED); //CPU_LED toggle

}

But I've not seen any sign if the interrupt being triggered.

Is there another enable I'm missing somewhere?

0 件の賞賛
返信

1,157件の閲覧回数
isaacavila
NXP Employee
NXP Employee

Hello Ian,

USB0_IRQHandler must be reserved for USB stack and should not be modified by user.

If you want to enable sleep interrupt, then, as you already saw, you need to enable suspend option on usb_device_config.h:

/* Advance suspend resume */
#define USBCFG_DEV_ADVANCED_SUSPEND_RESUME (1)

After that, all suspend events will be attend on USB_Device_callback (where other events such as bus reset, enumeration complete, among others are handled), for this basic example, I print on console that suspend event is received and increment a counter:

    case USB_DEV_EVENT_SUSPEND:
            suspend_times++;
            USB_PRINTF("SUSPEND MODE: %d\r\n", suspend_times);
        break;

    case USB_DEV_EVENT_ENUM_COMPLETE:   /* Device enumerated process complete */
      /* Write your code here ... */
      break;

This is all you need to do in order to enable sleep interrupt on USB stack from KSDK 1.3

I hope this helps!

Regards,

Isaac

0 件の賞賛
返信