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 {
115 
119 #define RCL_CommandStatus_isAnyStop(x) (((x) == RCL_CommandStatus_Descheduled) || ((x) == RCL_CommandStatus_GracefulStop) || ((x) == RCL_CommandStatus_HardStop))
120 #define RCL_CommandStatus_isAnyDescheduled(x) ((x) == RCL_CommandStatus_Descheduled)
121 #define RCL_CommandStatus_isAnyGracefulStop(x) ((x) == RCL_CommandStatus_GracefulStop)
122 #define RCL_CommandStatus_isAnyHardStop(x) ((x) == RCL_CommandStatus_HardStop)
123 
129 typedef enum {
134 } RCL_StopType;
135 
136 
142 typedef enum {
146 
152 typedef enum {
157 
164  uint16_t cmdId;
165  uint16_t phyFeatures;
169  bool allowDelay;
170  RCL_CommandRuntime runtime;
171  RCL_CommandTiming timing;
172 };
173 
174 #define RCL_Command_Default(_id, _handler) \
175 { \
176  .cmdId = _id, \
177  .phyFeatures = 0, \
178  .scheduling = RCL_Schedule_Now, \
179  .status = RCL_CommandStatus_Idle, \
180  .conflictPolicy = RCL_ConflictPolicy_AlwaysInterrupt, \
181  .allowDelay = false, \
182  .runtime = { \
183  .handler = _handler, \
184  }, \
185  .timing = { \
186  .absStartTime = 0, \
187  .relGracefulStopTime = 0, \
188  .relHardStopTime = 0, \
189  }, \
190 }
191 #define RCL_Command_DefaultRuntime(_id, _handler) (RCL_Command) RCL_Command_Default(_id, _handler)
192 
206 
213 static inline void RCL_Command_setRawTxPower(uint32_t registerSetting, uint32_t temperatureCoefficient)
214 {
215  LRF_setRawTxPower(registerSetting, temperatureCoefficient);
216 }
217 
218 #endif /* ti_drivers_RCL_Command_h__include */
RCL_CommandStatus_Error_RxFifo
@ RCL_CommandStatus_Error_RxFifo
Definition: RCL_Command.h:110
RCL_CommandStatus_Connect
@ RCL_CommandStatus_Connect
Definition: RCL_Command.h:100
RCL_CommandStatus_RxErr
@ RCL_CommandStatus_RxErr
Definition: RCL_Command.h:95
RCL_ConflictPolicy
RCL_ConflictPolicy
Conflict resolution policy.
Definition: RCL_Command.h:152
RCL_CommandStatus_Suspended
@ RCL_CommandStatus_Suspended
Definition: RCL_Command.h:88
RCL_CommandRuntime_s::callback
RCL_Callback callback
Definition: RCL_Command.h:63
RCL_CommandStatus_Error_MissingTxBuffer
@ RCL_CommandStatus_Error_MissingTxBuffer
Definition: RCL_Command.h:105
RCL_CommandStatus_ChannelBusy
@ RCL_CommandStatus_ChannelBusy
Definition: RCL_Command.h:92
RCL_Command_s::status
RCL_CommandStatus status
Definition: RCL_Command.h:167
LRF_TxPowerTable_Index
Index of the tx power table.
Definition: LRFCC23X0.h:153
RCL_CommandRuntime_s::rclCallbackMask
RCL_Events rclCallbackMask
Definition: RCL_Command.h:62
RCL_Event.h
RCL_CommandStatus_Error_TxBufferCorruption
@ RCL_CommandStatus_Error_TxBufferCorruption
Definition: RCL_Command.h:106
RCL_CommandStatus_RejectedStart
@ RCL_CommandStatus_RejectedStart
Definition: RCL_Command.h:99
RCL_StopType
RCL_StopType
Stop types.
Definition: RCL_Command.h:129
LRF.h
RCL_CommandTiming_s::relGracefulStopTime
int32_t relGracefulStopTime
Definition: RCL_Command.h:74
RCL_CommandTiming_s::relMinTime
uint32_t relMinTime
Definition: RCL_Command.h:73
RCL_Command_s::timing
RCL_CommandTiming timing
Definition: RCL_Command.h:171
RCL_CommandStatus_Finished
@ RCL_CommandStatus_Finished
Definition: RCL_Command.h:90
RCL_Command_s::conflictPolicy
RCL_ConflictPolicy conflictPolicy
Definition: RCL_Command.h:168
RCL_CommandStatus_ChannelIdle
@ RCL_CommandStatus_ChannelIdle
Definition: RCL_Command.h:91
RCL_CommandStatus_Queued
@ RCL_CommandStatus_Queued
Definition: RCL_Command.h:85
RCL_Command_setRawTxPower
static void RCL_Command_setRawTxPower(uint32_t registerSetting, uint32_t temperatureCoefficient)
Set raw TX power.
Definition: RCL_Command.h:213
RCL_ConflictPolicy_AlwaysInterrupt
@ RCL_ConflictPolicy_AlwaysInterrupt
Definition: RCL_Command.h:153
RCL_CommandTiming_s::absStartTime
uint32_t absStartTime
Definition: RCL_Command.h:72
RCL_CommandStatus
RCL_CommandStatus
Command status.
Definition: RCL_Command.h:83
RCL_CommandTiming_s
Command timing structure.
Definition: RCL_Command.h:71
RCL_Schedule_Now
@ RCL_Schedule_Now
Definition: RCL_Command.h:143
RCL_Command_s::phyFeatures
uint16_t phyFeatures
Definition: RCL_Command.h:165
RCL_CommandStatus_Deferred
@ RCL_CommandStatus_Deferred
Definition: RCL_Command.h:89
RCL_StopType_Graceful
@ RCL_StopType_Graceful
Definition: RCL_Command.h:132
RCL_CommandStatus_Descheduled
@ RCL_CommandStatus_Descheduled
Definition: RCL_Command.h:98
RCL_Command_s::allowDelay
bool allowDelay
Definition: RCL_Command.h:169
RCL_StopType_None
@ RCL_StopType_None
Definition: RCL_Command.h:130
RCL_ConflictPolicy_NeverInterrupt
@ RCL_ConflictPolicy_NeverInterrupt
Definition: RCL_Command.h:155
RCL_Types.h
RCL_CommandStatus_Error_AlreadySubmitted
@ RCL_CommandStatus_Error_AlreadySubmitted
Definition: RCL_Command.h:113
RCL_CommandRuntime_s::handler
RCL_CommandHandler handler
Definition: RCL_Command.h:59
RCL_CommandStatus_Error_RxBufferCorruption
@ RCL_CommandStatus_Error_RxBufferCorruption
Definition: RCL_Command.h:107
RCL_StopType_DescheduleOnly
@ RCL_StopType_DescheduleOnly
Definition: RCL_Command.h:131
RCL_CommandStatus_MaxNak
@ RCL_CommandStatus_MaxNak
Definition: RCL_Command.h:101
RCL_CommandStatus_Idle
@ RCL_CommandStatus_Idle
Definition: RCL_Command.h:84
RCL_CommandStatus_Error_StartTooLate
@ RCL_CommandStatus_Error_StartTooLate
Definition: RCL_Command.h:108
RCL_CommandRuntime_s::client
RCL_Client * client
Definition: RCL_Command.h:60
LRF_setRawTxPower
void LRF_setRawTxPower(uint32_t value, uint32_t temperatureCoefficient)
Definition: LRFCC23X0.c:1266
RCL_CommandStatus_RxTimeout
@ RCL_CommandStatus_RxTimeout
Definition: RCL_Command.h:93
RCL_Schedule_AbsTime
@ RCL_Schedule_AbsTime
Definition: RCL_Command.h:144
RCL_Callback
void(* RCL_Callback)(RCL_Command *cmd, LRF_Events lrfEvents, RCL_Events rclEvents)
Callback function type.
Definition: RCL_Command.h:51
RCL_CommandStatus_Active
@ RCL_CommandStatus_Active
Definition: RCL_Command.h:87
RCL_Command_TxPower
LRF_TxPowerTable_Index RCL_Command_TxPower
Type for TX power.
Definition: RCL_Command.h:205
RCL_CommandStatus_Error
@ RCL_CommandStatus_Error
Definition: RCL_Command.h:102
RCL_CommandHandler
RCL_Events(* RCL_CommandHandler)(RCL_Command *cmd, LRF_Events lrfEvents, RCL_Events rclEvents)
Command handler function type.
Definition: RCL_Command.h:46
RCL_CommandStatus_GracefulStop
@ RCL_CommandStatus_GracefulStop
Definition: RCL_Command.h:96
RCL_Command_s::cmdId
uint16_t cmdId
Definition: RCL_Command.h:164
RCL_CommandStatus_Error_TxFifo
@ RCL_CommandStatus_Error_TxFifo
Definition: RCL_Command.h:109
RCL_CommandTiming_s::relHardStopTime
uint32_t relHardStopTime
Definition: RCL_Command.h:75
RCL_ConflictPolicy_Polite
@ RCL_ConflictPolicy_Polite
Definition: RCL_Command.h:154
RCL_CommandStatus_Error_Param
@ RCL_CommandStatus_Error_Param
Definition: RCL_Command.h:104
RCL_Command_s::runtime
RCL_CommandRuntime runtime
Definition: RCL_Command.h:170
RCL_CommandStatus_HardStop
@ RCL_CommandStatus_HardStop
Definition: RCL_Command.h:97
RCL_CommandStatus_Error_UnknownOp
@ RCL_CommandStatus_Error_UnknownOp
Definition: RCL_Command.h:112
RCL_CommandRuntime_s
Command runtime structure.
Definition: RCL_Command.h:58
RCL_Command_s::scheduling
RCL_ScheduleType scheduling
Definition: RCL_Command.h:166
RCL_CommandStatus_NoSync
@ RCL_CommandStatus_NoSync
Definition: RCL_Command.h:94
RCL_Command_s
General command.
Definition: RCL_Command.h:163
RCL_CommandStatus_Error_Setup
@ RCL_CommandStatus_Error_Setup
Definition: RCL_Command.h:103
RCL_ScheduleType
RCL_ScheduleType
Schedule type.
Definition: RCL_Command.h:142
RCL_CommandStatus_Scheduled
@ RCL_CommandStatus_Scheduled
Definition: RCL_Command.h:86
RCL_StopType_Hard
@ RCL_StopType_Hard
Definition: RCL_Command.h:133
RCL_CommandStatus_Error_Synth
@ RCL_CommandStatus_Error_Synth
Definition: RCL_Command.h:111
RCL_CommandRuntime_s::lrfCallbackMask
LRF_Events lrfCallbackMask
Definition: RCL_Command.h:61