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 /**************************************************************************/ 14 /** */ 15 /** ThreadX Component */ 16 /** */ 17 /** Event Flags */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 #define TX_SOURCE_CODE 23 24 25 /* Include necessary system files. */ 26 27 #include "tx_api.h" 28 #include "tx_thread.h" 29 #include "tx_timer.h" 30 #include "tx_event_flags.h" 31 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _txe_event_flags_delete PORTABLE C */ 38 /* 6.1 */ 39 /* AUTHOR */ 40 /* */ 41 /* William E. Lamie, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function checks for errors in the delete event flags group */ 46 /* function call. */ 47 /* */ 48 /* INPUT */ 49 /* */ 50 /* group_ptr Pointer to group control block */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* TX_GROUP_ERROR Invalid event flag group pointer */ 55 /* TX_CALLER_ERROR Invalid caller of this function */ 56 /* status Actual completion status */ 57 /* */ 58 /* CALLS */ 59 /* */ 60 /* _tx_event_flags_delete Actual delete event flags function*/ 61 /* */ 62 /* CALLED BY */ 63 /* */ 64 /* Application Code */ 65 /* */ 66 /* RELEASE HISTORY */ 67 /* */ 68 /* DATE NAME DESCRIPTION */ 69 /* */ 70 /* 05-19-2020 William E. Lamie Initial Version 6.0 */ 71 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 72 /* resulting in version 6.1 */ 73 /* */ 74 /**************************************************************************/ _txe_event_flags_delete(TX_EVENT_FLAGS_GROUP * group_ptr)75UINT _txe_event_flags_delete(TX_EVENT_FLAGS_GROUP *group_ptr) 76 { 77 78 UINT status; 79 #ifndef TX_TIMER_PROCESS_IN_ISR 80 TX_THREAD *thread_ptr; 81 #endif 82 83 84 #ifndef TX_TIMER_PROCESS_IN_ISR 85 86 /* Default status to success. */ 87 status = TX_SUCCESS; 88 #endif 89 90 /* Check for an invalid event flag group pointer. */ 91 if (group_ptr == TX_NULL) 92 { 93 94 /* Event flags group pointer is invalid, return appropriate error code. */ 95 status = TX_GROUP_ERROR; 96 } 97 98 /* Now check for invalid event flag group ID. */ 99 else if (group_ptr -> tx_event_flags_group_id != TX_EVENT_FLAGS_ID) 100 { 101 102 /* Event flags group pointer is invalid, return appropriate error code. */ 103 status = TX_GROUP_ERROR; 104 } 105 106 /* Check for invalid caller of this function. */ 107 108 /* Is the caller an ISR or Initialization? */ 109 else if (TX_THREAD_GET_SYSTEM_STATE() != ((ULONG) 0)) 110 { 111 112 /* Invalid caller of this function, return appropriate error code. */ 113 status = TX_CALLER_ERROR; 114 } 115 else 116 { 117 118 #ifndef TX_TIMER_PROCESS_IN_ISR 119 120 /* Pickup thread pointer. */ 121 TX_THREAD_GET_CURRENT(thread_ptr) 122 123 /* Is the caller the system timer thread? */ 124 if (thread_ptr == &_tx_timer_thread) 125 { 126 127 /* Invalid caller of this function, return appropriate error code. */ 128 status = TX_CALLER_ERROR; 129 } 130 131 /* Determine if everything is okay. */ 132 if (status == TX_SUCCESS) 133 { 134 #endif 135 136 /* Call actual event flag group delete function. */ 137 status = _tx_event_flags_delete(group_ptr); 138 139 #ifndef TX_TIMER_PROCESS_IN_ISR 140 } 141 #endif 142 } 143 144 /* Return completion status. */ 145 return(status); 146 } 147 148