1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 /**************************************************************************/ 13 /** */ 14 /** USBX Component */ 15 /** */ 16 /** Device DFU Class */ 17 /** */ 18 /**************************************************************************/ 19 /**************************************************************************/ 20 21 #define UX_SOURCE_CODE 22 23 24 /* Include necessary system files. */ 25 26 #include "ux_api.h" 27 #include "ux_device_class_dfu.h" 28 #include "ux_device_stack.h" 29 30 31 /**************************************************************************/ 32 /* */ 33 /* FUNCTION RELEASE */ 34 /* */ 35 /* _ux_device_class_dfu_state_sync PORTABLE C */ 36 /* 6.1.6 */ 37 /* AUTHOR */ 38 /* */ 39 /* Chaoqiong Xiao, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This function syncs the USB DFU device state. */ 44 /* This allows application to move DFU state out of follow: */ 45 /* - dfuDNBUSY -> dfuDNLOAD-SYNC */ 46 /* - dfuMANIFEST -> dfuMANIFEST-SYNC */ 47 /* Other states will be kept. */ 48 /* Note the dfuDNBUSY and dfuMANIFEST is involved by returning busy */ 49 /* status in application ux_slave_class_dfu_get_status callback, and */ 50 /* needs application to issue ux_device_class_dfu_state_sync to go */ 51 /* out of the state. */ 52 /* */ 53 /* INPUT */ 54 /* */ 55 /* dfu Pointer to DFU instance */ 56 /* */ 57 /* OUTPUT */ 58 /* */ 59 /* None */ 60 /* */ 61 /* CALLS */ 62 /* */ 63 /* None */ 64 /* */ 65 /* CALLED BY */ 66 /* */ 67 /* Application Code */ 68 /* USBX Source Code */ 69 /* */ 70 /* RELEASE HISTORY */ 71 /* */ 72 /* DATE NAME DESCRIPTION */ 73 /* */ 74 /* 04-02-2021 Chaoqiong Xiao Initial Version 6.1.6 */ 75 /* */ 76 /**************************************************************************/ _ux_device_class_dfu_state_sync(UX_SLAVE_CLASS_DFU * dfu)77VOID _ux_device_class_dfu_state_sync(UX_SLAVE_CLASS_DFU *dfu) 78 { 79 UX_INTERRUPT_SAVE_AREA 80 81 UX_PARAMETER_NOT_USED(dfu); 82 UX_DISABLE 83 switch(_ux_system_slave -> ux_system_slave_device_dfu_state_machine) 84 { 85 case UX_SLAVE_CLASS_DFU_STATUS_STATE_DFU_DNBUSY: 86 _ux_system_slave -> ux_system_slave_device_dfu_state_machine = 87 UX_SLAVE_CLASS_DFU_STATUS_STATE_DFU_DNLOAD_SYNC; 88 break; 89 case UX_SLAVE_CLASS_DFU_STATUS_STATE_DFU_MANIFEST: 90 _ux_system_slave -> ux_system_slave_device_dfu_state_machine = 91 UX_SLAVE_CLASS_DFU_STATUS_STATE_DFU_MANIFEST_SYNC; 92 break; 93 default: 94 break; 95 } 96 UX_RESTORE 97 } 98