Mistake on this page?
Report an issue in GitHub or email us
csl_mbed.h
1 /* Copyright (c) 2019 Unisoc Communications Inc.
2  * SPDX-License-Identifier: Apache-2.0
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*****************************************************************************/
18 /* */
19 /* File Name : csl_mbed.h */
20 /* */
21 /* Description : This file contains all declarations and functions */
22 /* related to the chip support library. */
23 /* */
24 /* MbedOS Usage : Call maclib_get_funcs_struct() to get MACLib funcs; */
25 /* Define mbed_reg_func_t var, Register it by ml_init; */
26 /* */
27 /*****************************************************************************/
28 
29 #ifndef CSL_MBED_H
30 #define CSL_MBED_H
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*****************************************************************************/
37 /* Constants */
38 /*****************************************************************************/
39 #define RDA_EXT_INT_MAC_HW_INDEX 8
40 #define RDA_EXT_INT_MAC_HW_PRI 0x80
41 
42 /*****************************************************************************/
43 /* Enums */
44 /*****************************************************************************/
45 typedef enum {
46  MACLIB_EVENT_PEND = 0,
47  MACLIB_EVENT_PROCESS = 1,
48  MACLIB_EVENT_CLEANUP = 2
49 } MACLIB_EVENT_HANDLE_T;
50 
51 /*****************************************************************************/
52 /* Data Types */
53 /*****************************************************************************/
54 typedef struct
55 {
56  unsigned int ml_id; /* Buffer identification */
57  unsigned char* ml_data; /* Pkt start address */
58  unsigned short ml_len; /* Pkt length */
59 } maclib_buf_t;
60 
61 /* Structure that contains functions provided by MACLib */
62 typedef struct {
63  /* Initialize MAC Library, input param: mbed_reg_func_t *reg_funcs */
64  int (*ml_init)(void *reg_funcs);
65 
66  /* As a peroid task to process MAC Library background event */
67  void (*ml_tasklet)(void);
68 
69  /* Get a new packet buffer, output param: maclib_buf_t *buf */
70  void (*ml_get_pkt_buf)(void *buf);
71 
72  /* Mbed stack send packet to MAC Library, input param: maclib_buf_t *buf*/
73  int (*ml_xmit_pkt)(void *buf);
74 
75  /* Mbed receive and processing packet done, input param: unsigned int buf_id */
76  void (*ml_recv_pkt_comp)(unsigned int buf_id);
78 
79 /* Structure that contains functions provided by MbedOS */
80 typedef struct {
81  /* MAC Library send packet to mbed stack, input param: maclib_buf_t *buf */
82  void (*mbed_recv_pkt)(void *buf);
83 
84  /* Critical section start realized in mbed */
85  void (*mbed_critical_sec_start)(void);
86 
87  /* Critical section end realized in mbed */
88  void (*mbed_critical_sec_end)(void);
89 
90  /* Create interrupt in mbed, input param: vector/priority/isr(function), */
91  unsigned int (*mbed_critical_sec_counter_get)(void);
92  /* return: interrupt handle, non-zero is valid */
93  void * (*mbed_create_interrupt)(unsigned int vec, unsigned int pri, void *isr);
94 
95  /* Delete interrupt in mbed, input param: vector */
96  void (*mbed_delete_interrupt)(unsigned int vec);
97 
98  /* Enable interrupt in mbed, input param: vector */
99  void (*mbed_enable_interrupt)(unsigned int vec);
100 
101  /* Disable interrupt in mbed, input param: vector */
102  void (*mbed_disable_interrupt)(unsigned int vec);
103 
104  /* Get current time realized in mbed, return time in units of micro second */
105  unsigned long (*mbed_get_cur_time_ms)(void);
106 
107  /* Create alarm in mbed, input param: func(callback)/data(pass to func), */
108  /* return: alarm handle, non-zero is valid */
109  void * (*mbed_create_alarm)(void *func, unsigned int data);
110 
111  /* Delete alarm in mbed, input param: alarm handle */
112  void (*mbed_delete_alarm)(void **handle);
113 
114  /* Start alarm in mbed, input param: alarm handle/timeout(micro second) */
115  void (*mbed_start_alarm)(void *handle, unsigned int timeout_ms);
116 
117  /* Stop alarm in mbed, input param: alarm handle */
118  void (*mbed_stop_alarm)(void *handle);
119 
120 #if defined(MBED_MUTEX_INTERFACE)
121  /* Create mutex */
122  void (*mbed_mutex_create)(void);
123 
124  /* Delete mutex */
125  unsigned int (*mbed_mutex_delete)(void *rdamutex);
126 
127  /* Wait mutex, timer unit : millisec */
128  unsigned int (*mbed_mutex_wait)(void *rdamutex, unsigned int millisec);
129 
130  /* Release mutex */
131  unsigned int (*mbed_mutex_release)(void *rdamutex);
132 #endif /* MBED_MUTEX_INTERFACE */
133 
134  /* Event post/get callback function, input param: event_type */
135  void (*mbed_event_hdl_cb)(unsigned int event);
136 
137  /* maclib task sleep callback function */
138  void (*mbed_task_sleep_cb)(void);
139 
140  /* maclib task wakeup callback function */
141  void (*mbed_task_wakeup_cb)(void);
143 
144 /*****************************************************************************/
145 /* Extern Function Declarations */
146 /*****************************************************************************/
147 extern void maclib_get_funcs_struct(maclib_func_t *func_str);
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #endif /* CSL_MBED_H */
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.