• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  *
15  * Description: Provides V100 HAL spi \n
16  *
17  * History: \n
18  * 2022-08-08, Create file. \n
19  */
20 #ifndef HAL_SPI_V151_H
21 #define HAL_SPI_V151_H
22 
23 #include "hal_spi.h"
24 
25 #ifdef __cplusplus
26 #if __cplusplus
27 extern "C" {
28 #endif /* __cplusplus */
29 #endif /* __cplusplus */
30 
31 /**
32  * @defgroup drivers_hal_spi_v151 SPI V100
33  * @ingroup  drivers_hal_spi
34  * @{
35  */
36 
37 /**
38  * @if Eng
39  * @brief  Init device for hal SPI.
40  * @param  [in]  bus The SPI bus. For details, see @ref spi_bus_t
41  * @param  [in]  attr SPI basic attributes.
42  * @param  [in]  extra_attr SPI extra attributes.
43  * @param  [in]  callback SPI callback function.
44  * @retval ERRCODE_SUCC Success.
45  * @retval Other        Failure. For details, see @ref errcode_t
46  * @else
47  * @brief  HAL层SPI的初始化接口。
48  * @param  [in]  bus SPI端口号。参考 @ref spi_bus_t
49  * @param  [in]  attr SPI的基本配置参数。
50  * @param  [in]  extra_attr SPI高级配置参数。
51  * @param  [in]  callback SPI回调函数。
52  * @retval ERRCODE_SUCC 成功。
53  * @retval Other        失败。参考 @ref errcode_t
54  * @endif
55  */
56 errcode_t hal_spi_v151_init(spi_bus_t bus, const hal_spi_attr_t *attr,
57                             const hal_spi_extra_attr_t *extra_attr, hal_spi_callback_t callback);
58 
59 /**
60  * @if Eng
61  * @brief  Deinit device for hal SPI.
62  * @param  [in]  bus The SPI bus. For details, see @ref spi_bus_t
63  * @retval ERRCODE_SUCC Success.
64  * @retval Other        Failure. For details, see @ref errcode_t
65  * @else
66  * @brief  HAL层SPI的去初始化接口。
67  * @param  [in]  bus SPI端口号。参考 @ref spi_bus_t
68  * @retval ERRCODE_SUCC 成功。
69  * @retval Other        失败。参考 @ref errcode_t
70  * @endif
71  */
72 errcode_t hal_spi_v151_deinit(spi_bus_t bus);
73 
74 /**
75  * @if Eng
76  * @brief  Write interface for hal SPI.
77  * @param  [in]  bus The SPI bus. For details, see @ref spi_bus_t
78  * @param  [in]  data Transfer data. For details, see @ref hal_spi_xfer_data_t
79  * @param  [in]  timeout Timeout duration.
80  * @retval ERRCODE_SUCC Success.
81  * @retval Other        Failure. For details, see @ref errcode_t
82  * @else
83  * @brief  HAL层SPI发送数据接口。
84  * @param  [in]  bus 串口号。参考 @ref spi_bus_t
85  * @param  [in]  data 传输数据。参考 @ref hal_spi_xfer_data_t
86  * @param  [in]  timeout 超时时间。
87  * @retval ERRCODE_SUCC 成功。
88  * @retval Other        失败。参考 @ref errcode_t
89  * @endif
90  */
91 errcode_t hal_spi_v151_write(spi_bus_t bus, hal_spi_xfer_data_t *data, uint32_t timeout);
92 
93 /**
94  * @if Eng
95  * @brief  Read interface for hal SPI(When timeout is zero, will be exited If the data is full or no data is fifo).
96  * @param  [in]  bus The SPI bus. For details, see @ref spi_bus_t
97  * @param  [out] data Transfer data. For details, see @ref hal_spi_xfer_data_t
98  * @param  [in]  timeout Timeout duration.
99  * @retval ERRCODE_SUCC Success.
100  * @retval Other        Failure. For details, see @ref errcode_t
101  * @else
102  * @brief  HAL层SPI读取数据接口(当timeout为0时会在数据读满或者fifo中没有数据的时候结束)。
103  * @param  [in]  bus 串口号。参考 @ref spi_bus_t
104  * @param  [out] data 传输数据。参考 @ref hal_spi_xfer_data_t
105  * @param  [in]  timeout 超时时间。
106  * @retval ERRCODE_SUCC 成功。
107  * @retval Other        失败。参考 @ref errcode_t
108  * @endif
109  */
110 errcode_t hal_spi_v151_read(spi_bus_t bus, hal_spi_xfer_data_t *data, uint32_t timeout);
111 
112 /**
113  * @if Eng
114  * @brief  Control interface for hal SPI.
115  * @param  [in]  bus The SPI bus. For details, see @ref spi_bus_t
116  * @param  [in]  id ID of the SPI control.
117  * @param  [in]  param Parameter for callback.
118  * @retval ERRCODE_SUCC Success.
119  * @retval Other        Failure. For details, see @ref errcode_t
120  * @else
121  * @brief  HAL层SPI控制接口。
122  * @param  [in]  bus 串口号。参考 @ref spi_bus_t
123  * @param  [in]  id SPI控制请求ID。
124  * @param  [in]  param 传递给控制回调的参数。
125  * @retval ERRCODE_SUCC 成功。
126  * @retval Other        失败。参考 @ref errcode_t
127  * @endif
128  */
129 errcode_t hal_spi_v151_ctrl(spi_bus_t bus, hal_spi_ctrl_id_t id, uintptr_t param);
130 
131 #if defined(CONFIG_SPI_SUPPORT_INTERRUPT) && (CONFIG_SPI_SUPPORT_INTERRUPT == 1)
132 /**
133  * @if Eng
134  * @brief  Handler of the SPI interrupt request.
135  * @param  [in]  bus The spi bus. see @ref spi_bus_t
136  * @else
137  * @brief  SPI中断处理函数
138  * @param  [in]  bus 串口号, 参考 @ref spi_bus_t
139  * @endif
140  */
141 void hal_spi_v151_irq_handler(spi_bus_t bus);
142 #endif  /* CONFIG_SPI_SUPPORT_SLAVE */
143 
144 /**
145  * @}
146  */
147 
148 #ifdef __cplusplus
149 #if __cplusplus
150 }
151 #endif /* __cplusplus */
152 #endif /* __cplusplus */
153 
154 #endif