@@ -646,71 +646,71 @@ TEST_CASE("suspend_resume", "[usb_msc]")
646646 msc_teardown ();
647647}
648648
649- #define MSC_TEST_PM_TIMER_INTERVAL_MS 1000
650- #define MSC_TEST_PM_TIMER_MARGIN_MS 50
649+ #define MSC_TEST_SUSPEND_TIMER_INTERVAL_MS 1000
650+ #define MSC_TEST_SUSPEND_TIMER_MARGIN_MS 50
651651/**
652- * @brief USB MSC driver with the Power Management timer
652+ * @brief USB MSC driver with the automatic suspend timer timer
653653 *
654654 * Purpose:
655- * - Test One-Shot and Periodic PM timer for global Suspend of the root port with MSC Driver
655+ * - Test One-Shot and Periodic auto suspend timer for global Suspend of the root port with MSC Driver
656656 *
657657 * Procedure:
658658 * - Install USB Host lib, Install MSC driver, open a device, register VFS
659- * - Set One-Shot PM timer to 1000ms
659+ * - Set One-Shot auto suspend timer to 1000ms
660660 * - Simulate some USB traffic by reading/writing a file multiple times and regularly check that no USB_HOST_LIB event is delivered
661661 * - Once all the traffic is idle, verify the MSC_DEVICE_SUSPENDED event is delivered
662662 * - Measure time from issuing automatic suspend until the suspend event delivery
663- - Set Periodic PM timer and periodically check for MSC_DEVICE_SUSPENDED event, manually resume the device and verify device functionality
664- * - Disable the Periodic PM timer it and make sure no other event is delivered
663+ - Set Periodic auto suspend timer and periodically check for MSC_DEVICE_SUSPENDED event, manually resume the device and verify device functionality
664+ * - Disable the Periodic auto suspend timer and make sure no other event is delivered
665665 * - Teardown
666666 */
667667TEST_CASE ("auto_suspend_timer" , "[usb_msc]" )
668668{
669669 msc_setup ();
670670
671- // Set One-Shot PM suspend timer and start measuring ticks
672- ESP_OK_ASSERT (usb_host_lib_set_auto_pm ( USB_HOST_LIB_PM_SUSPEND_ONE_SHOT , MSC_TEST_PM_TIMER_INTERVAL_MS ));
673- TickType_t auto_pm_suspend_tick_start = xTaskGetTickCount ();
671+ // Set One-Shot auto suspend timer and start measuring ticks
672+ ESP_OK_ASSERT (usb_host_lib_set_auto_suspend ( USB_HOST_LIB_AUTO_SUSPEND_ONE_SHOT , MSC_TEST_SUSPEND_TIMER_INTERVAL_MS ));
673+ TickType_t auto_suspend_tick_start = xTaskGetTickCount ();
674674 msc_host_event_t peek_event , expected_event ;
675675
676- // Simulate some traffic, so the root port would not suspend after MSC_TEST_PM_TIMER_INTERVAL_MS from now,
677- // but after MSC_TEST_PM_TIMER_INTERVAL_MS , once there is no traffic
676+ // Simulate some traffic, so the root port would not suspend after MSC_TEST_SUSPEND_TIMER_INTERVAL_MS from now,
677+ // but after MSC_TEST_SUSPEND_TIMER_INTERVAL_MS , once there is no traffic
678678 // Regularly check, that there is no item in queue (check that the timer did not expire)
679679 for (int i = 0 ; i < 5 ; i ++ ) {
680680 write_read_file (FILE_NAME );
681681 TEST_ASSERT_EQUAL (pdFALSE , xQueuePeek (app_queue , & peek_event , 0 ));
682682 }
683683
684- // Expect MSC device to be suspended, expect app queue and block for MSC_TEST_PM_TIMER_INTERVAL_MS + some margin
684+ // Expect MSC device to be suspended, expect app queue and block for MSC_TEST_SUSPEND_TIMER_INTERVAL_MS + some margin
685685 expected_event .event = MSC_DEVICE_SUSPENDED ;
686- wait_for_app_event (& expected_event , pdMS_TO_TICKS (MSC_TEST_PM_TIMER_INTERVAL_MS + MSC_TEST_PM_TIMER_MARGIN_MS ));
686+ wait_for_app_event (& expected_event , pdMS_TO_TICKS (MSC_TEST_SUSPEND_TIMER_INTERVAL_MS + MSC_TEST_SUSPEND_TIMER_MARGIN_MS ));
687687
688- TickType_t auto_pm_suspend_tick_end = xTaskGetTickCount (); // App event received, stop measuring ticks
689- const uint32_t elapsed_ms = (auto_pm_suspend_tick_end - auto_pm_suspend_tick_start ) * portTICK_PERIOD_MS ;
688+ TickType_t auto_suspend_tick_end = xTaskGetTickCount (); // App event received, stop measuring ticks
689+ const uint32_t elapsed_ms = (auto_suspend_tick_end - auto_suspend_tick_start ) * portTICK_PERIOD_MS ;
690690
691691 // Check that, the time elapsed between setting the auto suspend timer and MSC_DEVICE_SUSPENDED event
692- // is more than MSC_TEST_PM_TIMER_INTERVAL_MS + some margin
692+ // is more than MSC_TEST_SUSPEND_TIMER_INTERVAL_MS + some margin
693693 TEST_ASSERT_GREATER_THAN_UINT32_MESSAGE (
694- MSC_TEST_PM_TIMER_INTERVAL_MS + MSC_TEST_PM_TIMER_MARGIN_MS , elapsed_ms ,
694+ MSC_TEST_SUSPEND_TIMER_INTERVAL_MS + MSC_TEST_SUSPEND_TIMER_MARGIN_MS , elapsed_ms ,
695695 "Auto suspend timer did not expire on time"
696696 );
697697
698698 // Make sure that no event is delivered, since we set the timer to be One-Shot
699- wait_for_app_event (NULL , pdMS_TO_TICKS (MSC_TEST_PM_TIMER_INTERVAL_MS * 2 ));
699+ wait_for_app_event (NULL , pdMS_TO_TICKS (MSC_TEST_SUSPEND_TIMER_INTERVAL_MS * 2 ));
700700
701701 // Resume the root port manually and expect the resume event
702702 ESP_OK_ASSERT (usb_host_lib_root_port_resume ());
703703 expected_event .event = MSC_DEVICE_RESUMED ;
704704 wait_for_app_event (& expected_event , 20 );
705705
706- // Set Periodic PM suspend timer
707- ESP_OK_ASSERT (usb_host_lib_set_auto_pm ( USB_HOST_LIB_PM_SUSPEND_PERIODIC , MSC_TEST_PM_TIMER_INTERVAL_MS ));
706+ // Set Periodic auto suspend timer
707+ ESP_OK_ASSERT (usb_host_lib_set_auto_suspend ( USB_HOST_LIB_AUTO_SUSPEND_PERIODIC , MSC_TEST_SUSPEND_TIMER_INTERVAL_MS ));
708708
709709 for (int i = 0 ; i < 3 ; i ++ ) {
710710
711711 // Expect suspended event from auto suspend timer
712712 expected_event .event = MSC_DEVICE_SUSPENDED ;
713- wait_for_app_event (& expected_event , pdMS_TO_TICKS (MSC_TEST_PM_TIMER_INTERVAL_MS + MSC_TEST_PM_TIMER_MARGIN_MS ));
713+ wait_for_app_event (& expected_event , pdMS_TO_TICKS (MSC_TEST_SUSPEND_TIMER_INTERVAL_MS + MSC_TEST_SUSPEND_TIMER_MARGIN_MS ));
714714
715715 // Resume the root port manually and expect the resume event
716716 ESP_OK_ASSERT (usb_host_lib_root_port_resume ());
@@ -721,10 +721,10 @@ TEST_CASE("auto_suspend_timer", "[usb_msc]")
721721 write_read_file (FILE_NAME );
722722 }
723723
724- // Disable Periodic PM timer
725- ESP_OK_ASSERT (usb_host_lib_set_auto_pm ( USB_HOST_LIB_PM_SUSPEND_PERIODIC , 0 ));
726- // Test that the Periodic PM timer can be disabled and no other event is delivered
727- TEST_ASSERT_EQUAL (pdFALSE , xQueuePeek (app_queue , & peek_event , pdMS_TO_TICKS (MSC_TEST_PM_TIMER_INTERVAL_MS * 2 )));
724+ // Disable Periodic auto suspend timer
725+ ESP_OK_ASSERT (usb_host_lib_set_auto_suspend ( USB_HOST_LIB_AUTO_SUSPEND_PERIODIC , 0 ));
726+ // Test that the Periodic auto suspend timer can be disabled and no other event is delivered
727+ TEST_ASSERT_EQUAL (pdFALSE , xQueuePeek (app_queue , & peek_event , pdMS_TO_TICKS (MSC_TEST_SUSPEND_TIMER_INTERVAL_MS * 2 )));
728728 msc_teardown ();
729729}
730730
0 commit comments