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_event_flags.h"
29 
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _txe_event_flags_set_notify                         PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    William E. Lamie, Microsoft Corporation                             */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function checks for errors in the event flags set notify       */
44 /*    callback function call.                                             */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    group_ptr                             Pointer to group control block*/
49 /*    group_put_notify                      Application callback function */
50 /*                                            (TX_NULL disables notify)   */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    status                                Service return status         */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    _tx_event_flags_set_notify            Actual event flags set notify */
59 /*                                            call                        */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    Application Code                                                    */
64 /*                                                                        */
65 /*  RELEASE HISTORY                                                       */
66 /*                                                                        */
67 /*    DATE              NAME                      DESCRIPTION             */
68 /*                                                                        */
69 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
70 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
71 /*                                            resulting in version 6.1    */
72 /*                                                                        */
73 /**************************************************************************/
_txe_event_flags_set_notify(TX_EVENT_FLAGS_GROUP * group_ptr,VOID (* events_set_notify)(TX_EVENT_FLAGS_GROUP * notify_group_ptr))74 UINT  _txe_event_flags_set_notify(TX_EVENT_FLAGS_GROUP *group_ptr, VOID (*events_set_notify)(TX_EVENT_FLAGS_GROUP *notify_group_ptr))
75 {
76 
77 UINT    status;
78 
79 
80     /* Check for an invalid group pointer.  */
81     if (group_ptr == TX_NULL)
82     {
83 
84         /* Event flags group pointer is invalid, return appropriate error code.  */
85         status =  TX_GROUP_ERROR;
86     }
87 
88     /* Now check for invalid event group ID.  */
89     else if (group_ptr -> tx_event_flags_group_id != TX_EVENT_FLAGS_ID)
90     {
91 
92         /* Event flags group pointer is invalid, return appropriate error code.  */
93         status =  TX_GROUP_ERROR;
94     }
95     else
96     {
97 
98         /* Call actual event flags set notify function.  */
99         status =  _tx_event_flags_set_notify(group_ptr, events_set_notify);
100     }
101 
102     /* Return completion status.  */
103     return(status);
104 }
105 
106