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