1 /*
2  * Copyright (c) 2020-2024, 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_hal_h__
34 #define __rcl_hal_h__
35 
36 #include <stdint.h>
37 
38 void hal_init_fsm(void (*setupFsmCb)(void), void (*schedFsmCb)(void),
39                   void (*commandFsmCb)(void));
40 void hal_trigger_command_fsm(void);
41 void hal_trigger_dispatch_fsm(void);
42 void hal_trigger_scheduler_fsm(void);
43 uint32_t hal_get_command_ifg_reg(void);
44 uint32_t hal_get_dispatch_ifg_reg(void);
45 uint32_t hal_get_current_time(void);
46 void hal_enable_setup_time_irq(void);
47 void hal_setup_setup_time(uint32_t setupTime);
48 void hal_setup_start_time(uint32_t startTime);
49 void hal_setup_packet_timeout(uint32_t stopTime);
50 void hal_setup_hard_stop_time(uint32_t stopTime);
51 void hal_enable_hard_stop_time_irq(void);
52 void hal_disable_hard_stop_time_irq(void);
53 void hal_setup_graceful_stop_time(uint32_t stopTime);
54 void hal_enable_graceful_stop_time_irq(void);
55 void hal_cancel_setup_time(void);
56 void hal_cancel_start_time(void);
57 void hal_cancel_packet_timeout(void);
58 void hal_cancel_hard_stop_time(void);
59 void hal_cancel_graceful_stop_time(void);
60 void hal_init_dispatch_radio_interrupts(uint32_t mask);
61 void hal_enable_command_radio_interrupt(uint32_t mask);
62 void hal_disable_command_radio_interrupt(uint32_t mask);
63 void hal_clear_command_radio_interrupt(uint32_t mask);
64 void hal_disable_all_command_radio_interrupts(void);
65 void hal_disable_all_dispatch_radio_interrupts(void);
66 void hal_temperature_init(void);
67 int16_t hal_get_temperature(void);
68 uint32_t hal_get_hfxt_ratio(void);
69 uint32_t hal_get_hfxt_ratio_default(void);
70 
71 typedef enum {
72     HAL_TIMER_EVT_NONE = 0,
73     HAL_TIMER_EVT_SETUP = 1,
74     HAL_TIMER_EVT_START = 2,
75     HAL_TIMER_EVT_GRACEFUL_STOP = 3,
76     HAL_TIMER_EVT_HARD_STOP = 4,
77     HAL_TIMER_EVT_PACKET_TIMEOUT = 5,
78 } HalTimerEvent;
79 
80 typedef enum {
81     RCL_POWER_STANDBY_AWAKE = 0,
82     RCL_POWER_XTAL_AVAILABLE = 1,
83     RCL_POWER_STANDBY_ENTER = 2,
84 } RCL_PowerEvent;
85 
86 HalTimerEvent hal_check_clear_timer_compare(void);
87 void hal_setup_cmd_start_cap(void);
88 void hal_arm_cmd_start_cap(void);
89 uint32_t hal_get_cmd_start_cap(void);
90 void hal_setup_sync_found_cap(void);
91 void hal_arm_sync_found_cap(void);
92 uint32_t hal_get_sync_found_cap(void);
93 void hal_setup_cmd_done_cap(void);
94 void hal_arm_cmd_done_cap(void);
95 uint32_t hal_get_cmd_done_cap(void);
96 void hal_set_rcl_clock_enable(uint16_t mask);
97 void hal_clear_rcl_clock_enable(uint16_t mask);
98 void hal_enable_clk_buffer(void);
99 void hal_power_set_constraint(void);
100 void hal_power_release_constraint(void);
101 void hal_power_open(void (*f)(RCL_PowerEvent));
102 void hal_power_close(void);
103 #endif
104