Radio Control Layer (RCL)
RCL_Command.h
Go to the documentation of this file.
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 ti_drivers_RCL_Command_h__include
34 #define ti_drivers_RCL_Command_h__include
35 
36 #include <stdint.h>
37 #include <stdbool.h>
38 
41 #include <ti/drivers/rcl/LRF.h>
42 
46 typedef RCL_Events (*RCL_CommandHandler)(RCL_Command *cmd, LRF_Events lrfEvents, RCL_Events rclEvents);
47 
51 typedef void (*RCL_Callback)(RCL_Command *cmd, LRF_Events lrfEvents, RCL_Events rclEvents);
52 
60  RCL_Client *client;
61  LRF_Events lrfCallbackMask;
62  RCL_Events rclCallbackMask;
64 };
65 
72  uint32_t absStartTime;
73  uint32_t relMinTime;
75  uint32_t relHardStopTime;
76 };
77 
83 typedef enum RCL_CommandStatus_e {
122 
126 #define RCL_CommandStatus_isAnyStop(x) (((x) >= RCL_CommandStatus_DescheduledApi) && ((x) <= RCL_CommandStatus_HardStopScheduling))
127 #define RCL_CommandStatus_isAnyDescheduled(x) (((x) >= RCL_CommandStatus_DescheduledApi) && ((x) <= RCL_CommandStatus_DescheduledScheduling))
128 #define RCL_CommandStatus_isAnyGracefulStop(x) (((x) >= RCL_CommandStatus_GracefulStopTimeout) && ((x) <= RCL_CommandStatus_GracefulStopScheduling))
129 #define RCL_CommandStatus_isAnyHardStop(x) (((x) >= RCL_CommandStatus_HardStopTimeout) && ((x) <= RCL_CommandStatus_HardStopScheduling))
130 #define RCL_CommandStatus_isAnyTimeoutStop(x) (((x) == RCL_CommandStatus_GracefulStopTimeout) || ((x) == RCL_CommandStatus_HardStopTimeout))
131 #define RCL_CommandStatus_isAnyApiStop(x) (((x) == RCL_CommandStatus_DescheduledApi) || ((x) == RCL_CommandStatus_GracefulStopApi) || ((x) == RCL_CommandStatus_HardStopApi))
132 #define RCL_CommandStatus_isAnySchedulingStop(x) (((x) == RCL_CommandStatus_DescheduledScheduling) || ((x) == RCL_CommandStatus_GracefulStopScheduling) || ((x) == RCL_CommandStatus_HardStopScheduling))
133 
139 typedef enum {
144 } RCL_StopType;
145 
151 typedef enum {
155 
161 typedef enum {
166 
173  uint16_t cmdId;
174  uint16_t phyFeatures;
175  RCL_ScheduleType scheduling : 8;
176  RCL_CommandStatus status : 8;
177  RCL_ConflictPolicy conflictPolicy : 8;
178  bool allowDelay;
179  RCL_CommandRuntime runtime;
180  RCL_CommandTiming timing;
181 };
182 
183 #define RCL_Command_Default(_id, _handler) \
184 { \
185  .cmdId = _id, \
186  .phyFeatures = 0, \
187  .scheduling = RCL_Schedule_Now, \
188  .status = RCL_CommandStatus_Idle, \
189  .conflictPolicy = RCL_ConflictPolicy_AlwaysInterrupt, \
190  .allowDelay = false, \
191  .runtime = { \
192  .handler = _handler, \
193  }, \
194  .timing = { \
195  .absStartTime = 0, \
196  .relGracefulStopTime = 0, \
197  .relHardStopTime = 0, \
198  }, \
199 }
200 #define RCL_Command_DefaultRuntime(_id, _handler) (RCL_Command) RCL_Command_Default(_id, _handler)
201 
215 
222 static inline void RCL_Command_setRawTxPower(uint32_t registerSetting, uint32_t temperatureCoefficient)
223 {
224  LRF_setRawTxPower(registerSetting, temperatureCoefficient);
225 }
226 
227 #endif /* ti_drivers_RCL_Command_h__include */
Definition: RCL_Command.h:95
static void RCL_Command_setRawTxPower(uint32_t registerSetting, uint32_t temperatureCoefficient)
Set raw TX power.
Definition: RCL_Command.h:222
LRF_TxPowerTable_Index RCL_Command_TxPower
Type for TX power.
Definition: RCL_Command.h:214
Definition: RCL_Command.h:99
void(* RCL_Callback)(RCL_Command *cmd, LRF_Events lrfEvents, RCL_Events rclEvents)
Callback function type.
Definition: RCL_Command.h:51
Definition: RCL_Command.h:98
RCL_Client * client
Definition: RCL_Command.h:60
Definition: RCL_Command.h:112
Definition: RCL_Command.h:92
Definition: RCL_Command.h:88
Definition: RCL_Command.h:102
Definition: RCL_Command.h:105
RCL_Events(* RCL_CommandHandler)(RCL_Command *cmd, LRF_Events lrfEvents, RCL_Events rclEvents)
Command handler function type.
Definition: RCL_Command.h:46
Definition: RCL_Command.h:113
uint16_t cmdId
Definition: RCL_Command.h:173
RCL_CommandHandler handler
Definition: RCL_Command.h:59
Definition: RCL_Command.h:90
RCL_StopType
Stop types.
Definition: RCL_Command.h:139
RCL_ConflictPolicy
Conflict resolution policy.
Definition: RCL_Command.h:161
Definition: RCL_Command.h:108
Definition: RCL_Command.h:96
uint32_t relHardStopTime
Definition: RCL_Command.h:75
RCL_ScheduleType
Schedule type.
Definition: RCL_Command.h:151
Definition: RCL_Command.h:152
Index of the tx power table.
Definition: LRFCC23X0.h:173
RCL_Events rclCallbackMask
Definition: RCL_Command.h:62
Command timing structure.
Definition: RCL_Command.h:71
RCL_Callback callback
Definition: RCL_Command.h:63
Definition: RCL_Command.h:91
Definition: RCL_Command.h:85
Definition: RCL_Command.h:162
Definition: RCL_Command.h:164
Definition: RCL_Command.h:120
Definition: RCL_Command.h:89
Definition: RCL_Command.h:142
Definition: RCL_Command.h:100
Definition: RCL_Command.h:140
uint32_t absStartTime
Definition: RCL_Command.h:72
Definition: RCL_Command.h:93
Definition: RCL_Command.h:114
Definition: RCL_Command.h:141
Definition: RCL_Command.h:84
Definition: RCL_Command.h:107
Definition: RCL_Command.h:109
LRF_Events lrfCallbackMask
Definition: RCL_Command.h:61
RCL_CommandTiming timing
Definition: RCL_Command.h:180
int32_t relGracefulStopTime
Definition: RCL_Command.h:74
Definition: RCL_Command.h:115
Definition: RCL_Command.h:153
Definition: RCL_Command.h:116
Definition: RCL_Command.h:87
Definition: RCL_Command.h:163
Definition: RCL_Command.h:111
void LRF_setRawTxPower(uint32_t value, uint32_t temperatureCoefficient)
Definition: LRFCC23X0.c:1418
Definition: RCL_Command.h:101
bool allowDelay
Definition: RCL_Command.h:178
Command runtime structure.
Definition: RCL_Command.h:58
uint16_t phyFeatures
Definition: RCL_Command.h:174
RCL_CommandRuntime runtime
Definition: RCL_Command.h:179
General command.
Definition: RCL_Command.h:172
Definition: RCL_Command.h:97
Definition: RCL_Command.h:119
uint32_t relMinTime
Definition: RCL_Command.h:73
Definition: RCL_Command.h:103
Definition: RCL_Command.h:110
Definition: RCL_Command.h:94
RCL_CommandStatus
Command status.
Definition: RCL_Command.h:83
Definition: RCL_Command.h:118
Definition: RCL_Command.h:104
Definition: RCL_Command.h:143
Definition: RCL_Command.h:106
Definition: RCL_Command.h:86
Definition: RCL_Command.h:117