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