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 /**************************************************************************/
15 /**                                                                       */
16 /** ThreadX Component                                                     */
17 /**                                                                       */
18 /**   Event Flags                                                         */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define TX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "tx_api.h"
29 #include "tx_trace.h"
30 #include "tx_event_flags.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _tx_event_flags_set_notify                          PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    William E. Lamie, Microsoft Corporation                             */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function registers an application callback function that is    */
46 /*    called whenever an event flag is set in this group.                 */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    group_ptr                             Pointer to group control block*/
51 /*    group_put_notify                      Application callback function */
52 /*                                            (TX_NULL disables notify)   */
53 /*                                                                        */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    status                                Service return status         */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*    None                                                                */
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 /**************************************************************************/
_tx_event_flags_set_notify(TX_EVENT_FLAGS_GROUP * group_ptr,VOID (* events_set_notify)(TX_EVENT_FLAGS_GROUP * notify_group_ptr))75 UINT  _tx_event_flags_set_notify(TX_EVENT_FLAGS_GROUP *group_ptr, VOID (*events_set_notify)(TX_EVENT_FLAGS_GROUP *notify_group_ptr))
76 {
77 
78 #ifdef TX_DISABLE_NOTIFY_CALLBACKS
79 
80     TX_EVENT_FLAGS_GROUP_NOT_USED(group_ptr);
81     TX_EVENT_FLAGS_SET_NOTIFY_NOT_USED(events_set_notify);
82 
83     /* Feature is not enabled, return error.  */
84     return(TX_FEATURE_NOT_ENABLED);
85 #else
86 
87 TX_INTERRUPT_SAVE_AREA
88 
89 
90     /* Disable interrupts.  */
91     TX_DISABLE
92 
93     /* Make entry in event log.  */
94     TX_TRACE_IN_LINE_INSERT(TX_TRACE_EVENT_FLAGS_SET_NOTIFY, group_ptr, 0, 0, 0, TX_TRACE_EVENT_FLAGS_EVENTS)
95 
96     /* Make entry in event log.  */
97     TX_EL_EVENT_FLAGS_SET_NOTIFY_INSERT
98 
99     /* Setup event flag group set notification callback function.  */
100     group_ptr -> tx_event_flags_group_set_notify =  events_set_notify;
101 
102     /* Restore interrupts.  */
103     TX_RESTORE
104 
105     /* Return success to caller.  */
106     return(TX_SUCCESS);
107 #endif
108 }
109 
110