Radio Control Layer (RCL)
RCL.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_h__include
34 #define ti_drivers_RCL_h__include
35 
36 #include <stdint.h>
37 #include <stddef.h>
38 
39 #include <ti/drivers/rcl/LRF.h>
46 
47 #include <ti/drivers/rcl/hal/hal.h>
48 
49 #include <ti/drivers/dpl/SemaphoreP.h>
50 
56 typedef enum {
60 
64 typedef struct RCL_s {
65  uint16_t numClients;
69  RCL_Command *nextCmd;
70  RCL_Command *doneCmd;
71 } RCL;
72 
82 int RCL_init();
83 
92 RCL_Handle RCL_open(RCL_Client *c, const LRF_Config *lrfConfig);
93 
99 void RCL_close(RCL_Handle h);
100 
113 
124 
138 
148 int8_t RCL_readRssi(void);
149 
150 #endif
RCL::nextCmd
RCL_Command * nextCmd
Definition: RCL.h:69
hal_enable_clk_buffer
void hal_enable_clk_buffer(void)
Definition: hal_octopus.c:278
RCL_close
void RCL_close(RCL_Handle h)
Closes client instance and deallocates open resources.
Definition: RCL.c:592
RadioState_Down
@ RadioState_Down
Definition: LRF.h:87
hal_power_open
void hal_power_open(void(*f)(RCL_PowerEvent))
Definition: hal_octopus.c:290
RCL_Scheduler.h
RCL_Command_pend
RCL_CommandStatus RCL_Command_pend(RCL_Command_Handle c)
Wait for a submitted command to complete.
Definition: RCL.c:672
RCL_readRssi
int8_t RCL_readRssi(void)
Get the last valid RSSI value.
Definition: RCL.c:760
RCL_open
RCL_Handle RCL_open(RCL_Client *c, const LRF_Config *lrfConfig)
Initializes an RCL client instance.
Definition: RCL.c:559
RCL_Command_stop
RCL_CommandStatus RCL_Command_stop(RCL_Command_Handle c, RCL_StopType stopType)
Stop a command.
Definition: RCL.c:699
RCL_POWER_STANDBY_AWAKE
@ RCL_POWER_STANDBY_AWAKE
Definition: hal.h:70
RCL_SCHEDULER_WAKEUP_MARGIN
#define RCL_SCHEDULER_WAKEUP_MARGIN
Definition: RCL_Scheduler.h:63
RCL_Scheduler_setSchedStopTime
RCL_StopType RCL_Scheduler_setSchedStopTime(RCL_SchedulerStopInfo *stopInfo, uint32_t schedStopTime)
Set scheduler stop time.
Definition: RCL_Scheduler.c:391
RCL_SchedulerStopInfo::apiStopEnabled
uint32_t apiStopEnabled
Definition: RCL_Scheduler.h:81
RCL_Command_stop
RCL_CommandStatus RCL_Command_stop(RCL_Command_Handle c, RCL_StopType stopType)
Stop a command.
Definition: RCL.c:699
hal.h
RCL_SchedulerState::currCmd
RCL_Command * currCmd
Definition: RCL_Scheduler.h:88
RCL::doneCmd
RCL_Command * doneCmd
Definition: RCL.h:70
HalTimerEvent
HalTimerEvent
Definition: hal.h:61
LRF_imagesNeedUpdate
bool LRF_imagesNeedUpdate(const LRF_Config *lrfConfig)
Definition: LRFCC23X0.c:184
phyHook
void phyHook(RCL *rclState, RCL_Handle client, RCL_Command *cmd)
Hook function to allow dynamic PHY change.
hal_init_fsm
void hal_init_fsm(void(*dispatchFsmCb)(void), void(*schedFsmCb)(void), void(*commandFsmCb)(void))
Definition: hal_octopus.c:96
hal_cancel_start_time
void hal_cancel_start_time(void)
Definition: hal_octopus.c:204
hal_trigger_dispatch_fsm
void hal_trigger_dispatch_fsm(void)
Definition: hal_octopus.c:121
RCL_readRssi
int8_t RCL_readRssi(void)
Get the last valid RSSI value.
Definition: RCL.c:760
RCL_init
int RCL_init()
Initializes the RCL driver state.
Definition: RCL.c:542
rclCommandHwi
static void rclCommandHwi(void)
Definition: RCL.c:94
RCL_Event.h
RCL_CommandStatus_RejectedStart
@ RCL_CommandStatus_RejectedStart
Definition: RCL_Command.h:99
RCL_StopType
RCL_StopType
Stop types.
Definition: RCL_Command.h:129
hal_cancel_hard_stop_time
void hal_cancel_hard_stop_time(void)
Definition: hal_octopus.c:210
LRF.h
hal_set_systim_imask
void hal_set_systim_imask(void)
Definition: hal_octopus.c:299
RCL_Command_submit
RCL_CommandStatus RCL_Command_submit(RCL_Handle h, RCL_Command_Handle c)
Submit RCL command object to be scheduled for execution.
Definition: RCL.c:638
hal_power_release_constraint
void hal_power_release_constraint(void)
Definition: hal_octopus.c:286
RCL_standbyAllow
@ RCL_standbyAllow
Definition: RCL.h:57
LRF_SetupResult
LRF_SetupResult
Setup operation result.
Definition: LRF.h:95
RCL_Scheduler_getCurrentTime
static uint32_t RCL_Scheduler_getCurrentTime(void)
Get current time.
Definition: RCL_Scheduler.h:233
RCL_Command.h
LRF_sendGracefulStop
void LRF_sendGracefulStop(void)
RCL_Command_submit
RCL_CommandStatus RCL_Command_submit(RCL_Handle h, RCL_Command_Handle c)
Submit RCL command object to be scheduled for execution.
Definition: RCL.c:638
RCL_CommandStatus_Finished
@ RCL_CommandStatus_Finished
Definition: RCL_Command.h:90
RCL_ProfilingEvent_PreprocStart
@ RCL_ProfilingEvent_PreprocStart
Definition: RCL_Profiling.h:37
RCL_POWER_XTAL_AVAILABLE
@ RCL_POWER_XTAL_AVAILABLE
Definition: hal.h:71
LRF_EventNone
#define LRF_EventNone
Definition: LRFCC23X0.h:70
SetupResult_Ok
@ SetupResult_Ok
Definition: LRF.h:96
RCL_Buffer.h
RCL_SchedulerState::gracefulStopInfo
RCL_SchedulerStopInfo gracefulStopInfo
Definition: RCL_Scheduler.h:94
RCL_SCHEDULER_MARGIN_CONFIGURE
#define RCL_SCHEDULER_MARGIN_CONFIGURE
Definition: RCL_Scheduler.h:56
RCL_CommandStatus_Queued
@ RCL_CommandStatus_Queued
Definition: RCL_Command.h:85
RCL_Scheduler_isLater
bool RCL_Scheduler_isLater(uint32_t refTime, uint32_t chkTime)
Find if a time instant occurs after another, allowing wrap-around.
Definition: RCL_Scheduler.c:345
RCL_Debug_assert
#define RCL_Debug_assert(expr)
Definition: RCL_Debug.h:39
RCL
Global shared driver state.
Definition: RCL.h:64
RCL_ConflictPolicy_AlwaysInterrupt
@ RCL_ConflictPolicy_AlwaysInterrupt
Definition: RCL_Command.h:153
RCL_PowerEvent
RCL_PowerEvent
Definition: hal.h:69
RCL_CommandStatus
RCL_CommandStatus
Command status.
Definition: RCL_Command.h:83
RCL_Schedule_Now
@ RCL_Schedule_Now
Definition: RCL_Command.h:143
rclDispatchHwi
static void rclDispatchHwi(void)
Definition: RCL.c:250
RCL::lrfState
LRF_RadioState lrfState
Definition: RCL.h:66
RCL_PowerState
RCL_PowerState
RCL power state.
Definition: RCL.h:56
hal_power_close
void hal_power_close(void)
Definition: hal_octopus.c:295
RCL_StopType_Graceful
@ RCL_StopType_Graceful
Definition: RCL_Command.h:132
RCL_SchedulerState::postedRclEvents
RCL_Events postedRclEvents
Definition: RCL_Scheduler.h:91
HAL_TIMER_EVT_GRACEFUL_STOP
@ HAL_TIMER_EVT_GRACEFUL_STOP
Definition: hal.h:65
RCL_close
void RCL_close(RCL_Handle h)
Closes client instance and deallocates open resources.
Definition: RCL.c:592
RCL_CommandStatus_Descheduled
@ RCL_CommandStatus_Descheduled
Definition: RCL_Command.h:98
RCL_Tracer.h
hal_check_clear_timer_compare
HalTimerEvent hal_check_clear_timer_compare(void)
Definition: hal_octopus.c:233
RCL_Scheduler_delta
int32_t RCL_Scheduler_delta(uint32_t refTime, uint32_t chkTime)
Find the time difference between two times, allowing wrap-around.
Definition: RCL_Scheduler.c:363
RCL_StopType_None
@ RCL_StopType_None
Definition: RCL_Command.h:130
RCL::lrfConfig
const LRF_Config * lrfConfig
Definition: RCL.h:68
RCL_SchedulerState
Definition: RCL_Scheduler.h:87
RCL_ConflictPolicy_NeverInterrupt
@ RCL_ConflictPolicy_NeverInterrupt
Definition: RCL_Command.h:155
RCL_open
RCL_Handle RCL_open(RCL_Client *c, const LRF_Config *lrfConfig)
Initializes an RCL client instance.
Definition: RCL.c:559
RCL_Types.h
RCL_SCHEDULER_SLEEP_CUTOFF
#define RCL_SCHEDULER_SLEEP_CUTOFF
Definition: RCL_Scheduler.h:58
RCL::numClients
uint16_t numClients
Definition: RCL.h:65
RCL_CommandStatus_Error_AlreadySubmitted
@ RCL_CommandStatus_Error_AlreadySubmitted
Definition: RCL_Command.h:113
RCL_SchedulerState::nextWantsStop
uint32_t nextWantsStop
Definition: RCL_Scheduler.h:89
RCL_StopType_DescheduleOnly
@ RCL_StopType_DescheduleOnly
Definition: RCL_Command.h:131
RCL_SchedulerStopInfo
Definition: RCL_Scheduler.h:78
LRF_RSSI_INVALID
#define LRF_RSSI_INVALID
Definition: LRF.h:83
RCL_CommandStatus_Idle
@ RCL_CommandStatus_Idle
Definition: RCL_Command.h:84
RCL_Client.h
RadioState_ImagesLoaded
@ RadioState_ImagesLoaded
Definition: LRF.h:88
rclPowerNotify
static void rclPowerNotify(RCL_PowerEvent eventType)
Definition: RCL.c:500
LRF_RadioState
LRF_RadioState
Definition: LRF.h:86
LRF_hardStop
void LRF_hardStop(void)
RCL_CommandStatus_Error_StartTooLate
@ RCL_CommandStatus_Error_StartTooLate
Definition: RCL_Command.h:108
hal_get_ifg_reg
uint32_t hal_get_ifg_reg(void)
Definition: hal_octopus.c:80
LRF_setupRadio
LRF_SetupResult LRF_setupRadio(const LRF_Config *lrfConfig, uint16_t phyFeatures, LRF_RadioState lrfState)
Definition: LRFCC23X0.c:88
RCL_Debug.h
RCL_init
int RCL_init(void)
Initializes the RCL driver state.
Definition: RCL.c:542
RCL_Callback
void(* RCL_Callback)(RCL_Command *cmd, LRF_Events lrfEvents, RCL_Events rclEvents)
Callback function type.
Definition: RCL_Command.h:51
LRF_readRssi
int8_t LRF_readRssi(void)
Definition: LRFCC23X0.c:1261
HAL_TIMER_EVT_START
@ HAL_TIMER_EVT_START
Definition: hal.h:64
RCL_CommandStatus_Active
@ RCL_CommandStatus_Active
Definition: RCL_Command.h:87
rclSchedulerHwi
static void rclSchedulerHwi(void)
Definition: RCL.c:417
RCL_CommandStatus_Error
@ RCL_CommandStatus_Error
Definition: RCL_Command.h:102
LRF_rclDisableRadioClocks
void LRF_rclDisableRadioClocks(void)
Definition: LRFCC23X0.c:1248
RCL_SCHEDULER_MARGIN_LOAD
#define RCL_SCHEDULER_MARGIN_LOAD
Definition: RCL_Scheduler.h:57
LRF_rclEnableRadioClocks
void LRF_rclEnableRadioClocks(void)
Definition: LRFCC23X0.c:1235
HAL_TIMER_EVT_HARD_STOP
@ HAL_TIMER_EVT_HARD_STOP
Definition: hal.h:66
RCL_SCHEDULER_TRIG_NOW_DELAY
#define RCL_SCHEDULER_TRIG_NOW_DELAY
Definition: RCL_Scheduler.h:59
RCL_ConflictPolicy_Polite
@ RCL_ConflictPolicy_Polite
Definition: RCL_Command.h:154
hal_setup_setup_time
void hal_setup_setup_time(uint32_t startTime)
Definition: hal_octopus.c:149
RCL_Profiling.h
RCL.h
RCL_SCHEDULER_MARGIN_ARM
#define RCL_SCHEDULER_MARGIN_ARM
Definition: RCL_Scheduler.h:55
HAL_TIMER_EVT_SETUP
@ HAL_TIMER_EVT_SETUP
Definition: hal.h:63
rclState
RCL rclState
Definition: RCL.c:54
scheduleHook
void scheduleHook(RCL_SchedulerState *rclSchedulerState, RCL_Handle client, RCL_Command *cmd)
Hook function to schedule new command.
RCL_CommandStatus_Error_Setup
@ RCL_CommandStatus_Error_Setup
Definition: RCL_Command.h:103
hal_enable_setup_time_irq
void hal_enable_setup_time_irq(void)
Definition: hal_octopus.c:144
RadioState_Configured
@ RadioState_Configured
Definition: LRF.h:89
RCL_EventNone
#define RCL_EventNone
Definition: RCL_Event.h:38
hal_trigger_scheduler_fsm
void hal_trigger_scheduler_fsm(void)
Definition: hal_octopus.c:127
RCL_SchedulerState::hardStopInfo
RCL_SchedulerStopInfo hardStopInfo
Definition: RCL_Scheduler.h:93
RCL_ProfilingEvent_PostprocStop
@ RCL_ProfilingEvent_PostprocStop
Definition: RCL_Profiling.h:40
RCL_Command_Handle
void * RCL_Command_Handle
Definition: RCL_Types.h:36
policyHook
RCL_StopType policyHook(RCL_Command *currentCmd, RCL_Command *newCmd)
Hook function to determine what stop type the ongoing command should get.
RCL_EventSetup
#define RCL_EventSetup
Definition: RCL_Event.h:53
LRF_sendHardStop
void LRF_sendHardStop(void)
hal_cancel_graceful_stop_time
void hal_cancel_graceful_stop_time(void)
Definition: hal_octopus.c:216
RCL_CommandStatus_Scheduled
@ RCL_CommandStatus_Scheduled
Definition: RCL_Command.h:86
RCL_Scheduler_postEvent
bool RCL_Scheduler_postEvent(RCL_Command_Handle c, RCL_Events e)
Post event to command handler.
Definition: RCL_Scheduler.c:498
RCL_Command_pend
RCL_CommandStatus RCL_Command_pend(RCL_Command_Handle c)
Wait for a submitted command to complete.
Definition: RCL.c:672
RCL_standbyDisallow
@ RCL_standbyDisallow
Definition: RCL.h:58
rclSchedulerState
RCL_SchedulerState rclSchedulerState
Definition: RCL_Scheduler.c:51
LRF_Config
Radio configuration structure.
Definition: LRFCC23X0.h:456
RCL::powerState
RCL_PowerState powerState
Definition: RCL.h:67
hal_disable_radio_interrupts
void hal_disable_radio_interrupts(void)
Definition: hal_octopus.c:266
RCL_StopType_Hard
@ RCL_StopType_Hard
Definition: RCL_Command.h:133
__attribute__
__attribute__((weak))
Definition: RCL.c:337
hal_power_set_constraint
void hal_power_set_constraint(void)
Definition: hal_octopus.c:282
RCL_Scheduler_setStopTimes
RCL_StopType RCL_Scheduler_setStopTimes(void)
Function to apply relevant stop times.
Definition: RCL_Scheduler.c:294