1 /**
2   ******************************************************************************
3   * @file    ll_sys.h
4   * @author  MCD Application Team
5   * @brief   Header for Link Layer system interface module
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2022 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 #ifndef LL_SYS_H
20 #define LL_SYS_H
21 
22 #include "ll_intf.h"
23 #include "hci.h"
24 #include "cmsis_compiler.h"
25 #include <stdint.h>
26 
27 #define LL_DP_SLP_NO_WAKEUP                 ((uint32_t) ~(0) )
28 #define LL_INTERNAL_TMR_US_TO_STEPS(US)     (((US)*4)/125)
29 
30 /**
31   * @brief  Link Layer Status structure definition
32   */
33 typedef enum
34 {
35   LL_SYS_OK       = 0x00,
36   LL_SYS_ERROR    = 0x01,
37   LL_SYS_BUSY     = 0x02,
38 } ll_sys_status_t;
39 
40 /**
41   * @brief  Link Layer radio bus clock clients definition
42   */
43 typedef enum
44 {
45   LL_SYS_RADIO_HCLK_RADIO_ISR,    /* Radio interrupt event */
46   LL_SYS_RADIO_HCLK_LL_EVT,       /* Link Layer event depending on radio activity */
47   LL_SYS_RADIO_HCLK_LL_BG,        /* Link Layer background task */
48   LL_SYS_RADIO_HCLK_BLEHOST_BG,   /* BLE Host background task */
49   LL_SYS_RADIO_HCLK_PREIDLE,      /* Link Layer PRE IDLE task */
50 } ll_sys_radio_hclk_client_t;
51 
52 /**
53   * @brief  Link Layer deep sleep state
54   */
55 typedef enum
56 {
57   LL_SYS_DP_SLP_DISABLED = 0x00,
58   LL_SYS_DP_SLP_ENABLED,
59 } ll_sys_dp_slp_state_t;
60 
61 /* Link Layer system interface general module functions  ************************************************/
62 void ll_sys_init(void);
63 void ll_sys_delay_us(uint32_t delay);
64 void ll_sys_assert(uint8_t condition);
65 void ll_sys_get_rng(uint8_t *ptr_rnd, uint32_t len);
66 void ll_sys_radio_ack_ctrl(uint8_t enable);
67 void ll_sys_radio_wait_for_busclkrdy(void);
68 void ll_sys_setup_radio_intr(void (*intr_cb)());
69 void ll_sys_setup_radio_sw_low_intr(void (*intr_cb)());
70 void ll_sys_radio_sw_low_intr_trigger(uint8_t priority);
71 void ll_sys_radio_evt_not(uint8_t start);
72 void ll_sys_rco_clbr_not(uint8_t start);
73 void ll_sys_request_temperature(void);
74 void ll_sys_schldr_timing_update_not(Evnt_timing_t * p_evnt_timing);
75 
76 extern int ll_intf_is_ptr_in_ble_mem(void* inp_ptr);
77 void HostStack_Process(void);
78 
79 /* Link Layer system interface synchronisation module functions  ************************************************/
80 void ll_sys_bg_process(void);
81 void ll_sys_bg_process_init(void);
82 void ll_sys_schedule_bg_process(void);
83 void ll_sys_schedule_bg_process_isr(void);
84 void ll_sys_config_params(void);
85 
86 /* Link Layer system interface critical sections module functions  ************************************************/
87 void ll_sys_enable_irq(void);
88 void ll_sys_disable_irq(void);
89 void ll_sys_enable_specific_irq(uint8_t isr_type);
90 void ll_sys_disable_specific_irq(uint8_t isr_type);
91 void ll_sys_enable_os_context_switch(void);
92 void ll_sys_disable_os_context_switch(void);
93 
94 /* Link Layer system interface deep sleep module functions  ************************************************/
95 ll_sys_status_t ll_sys_dp_slp_init(void);
96 ll_sys_status_t ll_sys_dp_slp_enter(uint32_t dp_slp_duration);
97 ll_sys_status_t ll_sys_dp_slp_exit(void);
98 ll_sys_dp_slp_state_t ll_sys_dp_slp_get_state(void);
99 void ll_sys_dp_slp_wakeup_evt_clbk(void const *ptr_arg);
100 
101 /**
102   * @brief  Get the number of concurrent state machines for the Link Layer
103   * @param  None
104   * @retval Supported number of concurrent state machines
105   */
106 uint8_t ll_sys_get_concurrent_state_machines_num(void);
107 
108 #endif /* LL_SYS_H */
109