VSF Documented
spi.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
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#ifndef __HAL_DRIVER_${SERIES/SPI_IP}_SPI_H__
19#define __HAL_DRIVER_${SERIES/SPI_IP}_SPI_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "hal/vsf_hal_cfg.h"
24
25#if VSF_HAL_USE_SPI == ENABLED
26
27#include "../../__device.h"
28
29/*\note Refer to template/README.md for usage cases.
30 * For peripheral drivers, blackbox mode is recommended but not required, reimplementation part MUST be open.
31 * For IPCore drivers, class structure, MULTI_CLASS configuration, reimplementation and class APIs should be open to user.
32 * For emulated drivers, **** No reimplementation ****.
33 */
34
35/*\note Includes CAN ONLY be put here. */
36/*\note If current header is for a peripheral driver(hw driver), and inherit from an IPCore driver, include IPCore header here. */
37
38// IPCore
39#if defined(__VSF_HAL_${SPI_IP}_SPI_CLASS_IMPLEMENT)
40# define __VSF_CLASS_IMPLEMENT__
41#elif defined(__VSF_HAL_${SPI_IP}_SPI_CLASS_INHERIT__)
42# define __VSF_CLASS_INHERIT__
43#endif
44
45#include "utilities/ooc_class.h"
46// IPCore end
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52/*============================ MACROS ========================================*/
53
54/*\note VSF_${SPI_IP}_SPI_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
55 * while VSF_HW_SPI_CFG_MULTI_CLASS should be in spi.c.
56 */
57
58// IPCore
59#ifndef VSF_${SPI_IP}_SPI_CFG_MULTI_CLASS
60# define VSF_${SPI_IP}_SPI_CFG_MULTI_CLASS VSF_SPI_CFG_MULTI_CLASS
61#endif
62// IPCore end
63
64/*============================ MACROFIED FUNCTIONS ===========================*/
65/*============================ TYPES =========================================*/
66
67// IPCore
68vsf_class(vsf_${spi_ip}_spi_t) {
69#if VSF_${SPI_IP}_CFG_MULTI_CLASS == ENABLED
70 public_member(
72 )
73#endif
74
75/*\note You can add more member in vsf_${spi_ip}_spi_t instance.
76 * For members accessible from child, put in protected_member.
77 * Else, put in private_member.
78 */
79
80 protected_member(
81 vsf_${spi_ip}_spi_reg_t *reg;
83 )
84};
85// IPCore end
86
87/*============================ INCLUDES ======================================*/
88
89// IPCore
90/*\note Extern APIs for ip core diriver.
91 * There is no requirement about how APIs of IPCore drivers should be implemented.
92 * Just consider the simplicity for actual peripheral drivers.
93 */
94// IPCore end
95
96#ifdef __cplusplus
97}
98#endif
99
100// IPCore
101#undef __VSF_HAL_${SPI_IP}_SPI_CLASS_IMPLEMENT
102#undef __VSF_HAL_${SPI_IP}_SPI_CLASS_INHERIT__
103// IPCore end
104
105#endif // VSF_HAL_USE_SPI
106#endif // __HAL_DRIVER_${SERIES/SPI_IP}_SPI_H__
107/* EOF */
Definition adc.h:68
#define vsf_class(__name)
Definition ooc_class.h:48
spi isr for api
Definition vsf_template_spi.h:518
Definition vsf_template_spi.h:541
class vsf_$ * reg
vsf_spi_isr_t isr
Definition spi.h:83
vsf_spi_t vsf_spi[SPI_COUNT]
Definition vsf_spi.c:3