//! \brief Test 20 - Test upstream resume (from USB device) static void main_test20(void) { udd_attach_device(); main_usb_enum_step1(); main_usb_enum_step2(); main_usb_enum_step3(); main_usb_enum_step4(); main_usb_enum_step5(); main_usb_enum_step6(); main_usb_enum_step7(); main_usb_enum_step8(); main_usb_enum_step9(); main_usb_enum_step10(); main_usb_enum_step11(); main_usb_enum_step12(); main_usb_enum_step13(); main_usb_enum_step14(); // Setup set remotewakeup main_usb_wait_setup_packet(); main_usb_send_in(NULL,0); main_usb_wait_suspend(); delay_ms(100); udd_initiate_remote_wake_up(); main_usb_wait_wakeup(); main_usb_wait_sof(); // Setup clear remotewakeup main_usb_wait_setup_packet(); main_usb_send_in(NULL,0); }
//! \brief Test 15 - HID mouse with too large endpoint size (USBB hardware limit) static void main_test15(void) { udd_attach_device(); main_usb_enum_step1(); main_usb_enum_step2(); main_usb_enum_step3(); main_usb_enum_step4(); main_usb_enum_step5(); main_usb_enum_step6(); main_usb_enum_step7(); main_usb_enum_step8(); main_usb_enum_step9(); main_usb_enum_step10(); main_usb_enum_step11(); main_usb_enum_step12(); // Get configuration descriptor main_usb_wait_setup_packet(); main_conf_desc.conf.bDescriptorType = USB_DT_CONFIGURATION; main_conf_desc.conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER), main_conf_desc.conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR, main_conf_desc.iface.bInterfaceProtocol = HID_PROTOCOL_MOUSE; main_conf_desc.ep.wMaxPacketSize = LE16(1023); main_usb_send_in((uint8_t*)&main_conf_desc, sizeof(main_conf_desc)); main_usb_wait_out(NULL,0); main_usb_wait_suspend(); main_detach(); }
//! \brief Test 16 - Stall SET CONFIGURATION (with configuration in SELF + 300mA -> must be pass) static void main_test16(void) { uint8_t nb_fail; udd_attach_device(); nb_fail = 4; while (nb_fail--) { main_usb_enum_step1(); main_usb_enum_step2(); main_usb_enum_step3(); main_usb_enum_step4(); main_usb_enum_step5(); main_usb_enum_step6(); main_usb_enum_step7(); main_usb_enum_step8(); main_usb_enum_step9(); main_usb_enum_step10(); main_usb_enum_step11(); main_usb_enum_step12(); // Get configuration descriptor main_usb_wait_setup_packet(); main_conf_desc.conf.bDescriptorType = USB_DT_CONFIGURATION; main_conf_desc.conf.bMaxPower = USB_CONFIG_MAX_POWER(300), main_conf_desc.conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_CONFIG_ATTR_SELF_POWERED; main_conf_desc.iface.bInterfaceProtocol = HID_PROTOCOL_MOUSE; main_conf_desc.ep.wMaxPacketSize = LE16(8); main_usb_send_in((uint8_t*)&main_conf_desc, sizeof(main_conf_desc)); main_usb_wait_out(NULL,0); // Set configuration main_usb_wait_setup_packet(); main_usb_stall_after_setup_packet(); } main_usb_wait_suspend(); main_detach(); }
//! \brief Test 11 - Wrong value in first setup request get configuration 0 static void main_test11(void) { uint8_t nb_fail; main_otg_init(); udd_attach_device(); nb_fail = 4; while (nb_fail--) { main_usb_enum_step1(); main_usb_enum_step2(); main_usb_enum_step3(); main_usb_enum_step4(); main_usb_enum_step5(); main_usb_enum_step6(); main_usb_enum_step7(); main_usb_enum_step8(); main_usb_enum_step9(); main_usb_enum_step10(); main_usb_enum_step11(); // Get configuration descriptor main_usb_wait_setup_packet(); main_conf_desc.conf.bDescriptorType = 0xFF; main_conf_desc.conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER); main_conf_desc.conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR, main_usb_send_in((uint8_t*)&main_conf_desc, sizeof(usb_conf_desc_t)); main_usb_wait_out(NULL,0); } main_usb_wait_suspend(); main_detach(); }
//! \brief Test 13 - To high power consumption in setup request get configuration 0 static void main_test13(void) { udd_attach_device(); main_usb_enum_step1(); main_usb_enum_step2(); main_usb_enum_step3(); main_usb_enum_step4(); main_usb_enum_step5(); main_usb_enum_step6(); main_usb_enum_step7(); main_usb_enum_step8(); main_usb_enum_step9(); main_usb_enum_step10(); main_usb_enum_step11(); // Get configuration descriptor main_usb_wait_setup_packet(); main_conf_desc.conf.bDescriptorType = USB_DT_CONFIGURATION; main_conf_desc.conf.bMaxPower = USB_CONFIG_MAX_POWER(300); main_conf_desc.conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR, main_usb_send_in((uint8_t*)&main_conf_desc, sizeof(usb_conf_desc_t)); main_usb_wait_out(NULL,0); main_usb_wait_suspend(); main_detach(); }
//! \brief Test 18 - Test downstream resume (from USB host) static void main_test18(void) { main_usb_wait_suspend(); main_usb_wait_wakeup(); // Setup clear remotewakeup main_usb_wait_setup_packet(); main_usb_send_in(NULL,0); }
//! \brief step11 of enumeration - Reception of the full Get device descriptor static void main_usb_enum_step11(void) { // Get full device descriptor main_usb_wait_setup_packet(); main_device_desc.bDescriptorType = USB_DT_DEVICE; main_device_desc.bMaxPacketSize0 = (speed==0)?8:64; main_usb_send_in((uint8_t*)&main_device_desc, sizeof(main_device_desc)); main_usb_wait_out(NULL,0); }
//! \brief step12 of enumeration - Get first struct of USB configuration descriptor static void main_usb_enum_step12(void) { main_usb_wait_setup_packet(); main_conf_desc.conf.bDescriptorType = USB_DT_CONFIGURATION; main_conf_desc.conf.bLength = sizeof(usb_conf_desc_t); main_conf_desc.conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER); main_conf_desc.conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR, main_usb_send_in((uint8_t*)&main_conf_desc, sizeof(usb_conf_desc_t)); main_usb_wait_out(NULL,0); }
//! \brief step9 of enumeration - Reception of the Set address setup request static void main_usb_enum_step9(void) { main_usb_enable_ctrl_ep(0, (speed==0)?8:64); // Set address main_usb_wait_setup_packet(); main_usb_send_in(NULL,0); main_usb_enable_ctrl_ep(le16_to_cpu(main_setup_packet.wValue), (speed==0)?8:64); }
//! \brief step13 of enumeration - Get all USB configuration descriptor static void main_usb_enum_step13(void) { // Get configuration descriptor main_usb_wait_setup_packet(); main_conf_desc.conf.bLength = sizeof(usb_conf_desc_t); main_conf_desc.conf.bDescriptorType = USB_DT_CONFIGURATION; main_conf_desc.conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER), main_conf_desc.conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR, main_conf_desc.iface.bInterfaceProtocol = HID_PROTOCOL_MOUSE; main_conf_desc.ep.wMaxPacketSize = LE16(8); main_usb_send_in((uint8_t*)&main_conf_desc, sizeof(main_conf_desc)); main_usb_wait_out(NULL,0); }
//! \brief Test 5 - Detach after IN data phase of first setup request static void main_test5(void) { udd_attach_device(); main_usb_enum_step1(); main_usb_enum_step2(); main_usb_enum_step3(); main_usb_enum_step4(); // Get Device Descriptor main_usb_wait_setup_packet(); main_device_desc.bDescriptorType = USB_DT_DEVICE; main_device_desc.bMaxPacketSize0 = (speed==0)?8:64; main_usb_send_in((uint8_t*)&main_device_desc,8); main_detach(); }
//! \brief Test 6 - Wrong value in first setup request get descriptor static void main_test6(void) { uint8_t nb_fail; udd_attach_device(); nb_fail = 4; while (nb_fail--) { main_usb_enum_step1(); main_usb_enum_step2(); main_usb_enum_step3(); main_usb_enum_step4(); // Get Device Descriptor main_usb_wait_setup_packet(); main_device_desc.bDescriptorType = 0xFF; main_device_desc.bMaxPacketSize0 = 0xFF; main_usb_send_in((uint8_t*)&main_device_desc,8); main_usb_wait_out(NULL,0); } main_usb_wait_suspend(); main_detach(); }
//! \brief step14 of enumeration - Reception of the Set configuration setup request static void main_usb_enum_step14(void) { main_usb_wait_setup_packet(); main_usb_send_in(NULL,0); }