1 /*
2  * Copyright (c) 2020-2023, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef __rcl_events_h__
34 #define __rcl_events_h__
35 
36 #include <stdint.h>
37 
38 #define RCL_EventNone                  ((RCL_Events){ .value = (0 << 0)})   /*!< No events */
39 #define RCL_EventCmdStarted            ((RCL_Events){ .value = (1 << 0)})   /*!< Command handler has accepted and started executing */
40 #define RCL_EventLastCmdDone           ((RCL_Events){ .value = (1 << 1)})   /*!< The RCL is finished with the command */
41 #define RCL_EventRxEntryAvail          ((RCL_Events){ .value = (1 << 2)})   /*!< An RX entry has been made available */
42 #define RCL_EventRxBufferFinished      ((RCL_Events){ .value = (1 << 3)})   /*!< An RX multi-buffer is finished */
43 #define RCL_EventTxBufferFinished      ((RCL_Events){ .value = (1 << 4)})   /*!< A TX buffer is finished */
44 #define RCL_EventSoftwareTriggered     ((RCL_Events){ .value = (1 << 5)})   /*!< Handler is triggered from software */
45 #define RCL_EventTimerStart            ((RCL_Events){ .value = (1 << 6)})   /*!< Timer-based start signalled */
46 #define RCL_EventDescheduleStop        ((RCL_Events){ .value = (1 << 7)})   /*!< Deschedule-type stop signalled */
47 #define RCL_EventGracefulStop          ((RCL_Events){ .value = (1 << 8)})   /*!< Timer-based graceful-stop signalled */
48 #define RCL_EventHardStop              ((RCL_Events){ .value = (1 << 9)})   /*!< Timer-based hard-stop signalled */
49 #define RCL_EventStopDelayed           ((RCL_Events){ .value = (1 << 10)})  /*!< Command was not stopped */
50 #define RCL_EventStopRejected          ((RCL_Events){ .value = (1 << 11)})  /*!< Command was not stopped */
51 #define RCL_EventStartDelayed          ((RCL_Events){ .value = (1 << 12)})  /*!< Command start is delayed, may still happen within allowDelay */
52 #define RCL_EventStartRejected         ((RCL_Events){ .value = (1 << 13)})  /*!< Command start is not possible within scheduling parameters */
53 #define RCL_EventSetup                 ((RCL_Events){ .value = (1 << 14)})  /*!< Setup has been performed */
54 #define RCL_EventPartialSetup          ((RCL_Events){ .value = (1 << 15)})  /*!< Partial setup has been performed or is required by the running command */
55 #define RCL_EventRxBufferUpdate        ((RCL_Events){ .value = (1 << 16)})  /*!< RX buffer has been updated */
56 #define RCL_EventTxBufferUpdate        ((RCL_Events){ .value = (1 << 17)})  /*!< TX buffer has been updated */
57 #define RCL_EventHandlerCmdUpdate      ((RCL_Events){ .value = (1 << 18)})  /*!< A property of a running command has been updated, to be detailed by handler */
58 #define RCL_EventCmdStepDone           ((RCL_Events){ .value = (1 << 19)})  /*!< A step of the command has been done; details are command specific */
59 #define RCL_EventStopTimesUpdated      ((RCL_Events){ .value = (1 << 20)})  /*!< A change was made to the stop times */
60 #define RCL_EventPacketTimeout         ((RCL_Events){ .value = (1 << 21)})  /*!< A manually set packet-specific timeout has expired */
61 
62 union RCL_Events_u {
63     struct {
64         uint32_t cmdStarted          : 1; /*!< Command handler has accepted and started executing */
65         uint32_t lastCmdDone         : 1; /*!< The RCL is finished with the command */
66         uint32_t rxEntryAvail        : 1; /*!< An RX entry has been made available */
67         uint32_t rxBufferFinished    : 1; /*!< An RX multi-buffer is finished */
68         uint32_t txBufferFinished    : 1; /*!< A TX buffer is finished */
69         uint32_t swTriggered         : 1; /*!< Handler is triggered from software */
70         uint32_t timerStart          : 1; /*!< Timer-based start signalled */
71         uint32_t descheduleStop      : 1; /*!< Deschedule-type stop signalled */
72         uint32_t gracefulStop        : 1; /*!< Timer/api-based graceful-stop signalled */
73         uint32_t hardStop            : 1; /*!< Timer/api-based hard-stop signalled */
74         uint32_t stopDelayed         : 1; /*!< Command was not stopped */
75         uint32_t stopRejected        : 1; /*!< Command was not stopped */
76         uint32_t startDelayed        : 1; /*!< Command start is delayed, may still happen within allowDelay */
77         uint32_t startRejected       : 1; /*!< Command start is not possible within scheduling parameters */
78         uint32_t setup               : 1; /*!< Setup has been performed */
79         uint32_t partialSetup        : 1; /*!< Partial setup has been performed or is required by the running command */
80         uint32_t rxBufferUpdate      : 1; /*!< RX buffer has been updated */
81         uint32_t txBufferUpdate      : 1; /*!< TX buffer has been updated */
82         uint32_t handlerCmdUpdate    : 1; /*!< A property of a running command has been updated, to be detailed by handler */
83         uint32_t cmdStepDone         : 1; /*!< A step of the command has been done; details are command specific */
84         uint32_t stopTimesUpdated    : 1; /*!< A change was made to the stop times */
85         uint32_t packetTimeout       : 1; /*!< A manually set packet-specific timeout has expired */
86     };
87     uint32_t value;
88 };
89 
90 #endif
91