VSF Documented
device.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/*============================ INCLUDES ======================================*/
19
20#include "hal/vsf_hal_cfg.h"
21
22/*============================ MACROS ========================================*/
23
24#if defined(__VSF_HEADER_ONLY_SHOW_ARCH_INFO__)
25
26/*\note __VSF_HEADER_ONLY_SHOW_ARCH_INFO__ is defined to include arch information only.
27 * Some arch provide chip-vendor with some vendor-specified options, define these options here.
28 */
29
31// for ARM, number of interrupt priority is vendor-specified, so define here
32
33# define VSF_ARCH_PRI_NUM 64
34# define VSF_ARCH_PRI_BIT 6
35
36#elif defined(__VSF_HAL_SHOW_VENDOR_INFO__)
37
38/*\note __VSF_HAL_SHOW_VENDOR_INFO__ is defined to include vendor information only.
39 * Vendor information means the registers/structures/macros from vendor SDK.
40 * Usually these information are not visible from user side to avoid name-space pollution.
41 */
42
43# define __VSF_HEADER_ONLY_SHOW_VENDOR_INFO__
44# include "vendor_header.h"
45
46#else
47
48/*\note __VSF_HEADER_ONLY_SHOW_ARCH_INFO__ and __VSF_HAL_SHOW_VENDOR_INFO__ are not defined.
49 * Define device information here.
50 */
51
52#ifndef __VSF_HAL_DEVICE_${VENDOR}_${DEVICE}_H__
53#define __VSF_HAL_DEVICE_${VENDOR}_${DEVICE}_H__
54
55/*============================ INCLUDES ======================================*/
56
57/*\note Centralized vendor-peripheral header block.
58 *
59 * Every peripheral struct / reg header pulled from the vendor SDK
60 * (e.g. `hardware/structs/uart.h`, `hardware/regs/dma.h`) belongs
61 * here, NOT inside each peripheral driver .c file. The driver .c
62 * only includes:
63 * #include "hal/vsf_hal.h"
64 * #include "hal/driver/vendor_driver.h" // optional, for
65 * // chip-level symbols
66 * and any non-vendor headers it owns (IPCore register layouts,
67 * driver-private .h). All vendor peripheral memory-map structs
68 * and register-bit constants reach the driver transitively from
69 * this block.
70 *
71 * Two options for organizing this:
72 * (1) Inline the includes directly here, grouped by struct/reg.
73 * (2) Aggregate them into a sibling `__common.h` and include that
74 * file once. The path is up to the porter.
75 *
76 * Whichever you choose, this is the *only* place vendor peripheral
77 * headers should be named. A driver .c that reaches into
78 * `hardware/structs/<periph>.h` directly is a porting bug.
79 */
80//#include "../common/__common.h"
81// — or inline the vendor peripheral headers:
82//#include "hardware/structs/uart.h"
83//#include "hardware/regs/uart.h"
84//#include "hardware/structs/i2c.h"
85//#include "hardware/regs/i2c.h"
86// ... etc., one line per peripheral that has a driver.
87
88/*============================ MACROS ========================================*/
89
90// peripheral defines
91
92// software interrupt provided by a dedicated device
93#define VSF_DEV_SWI_NUM 0
94
95/*\note For specified peripheral, VSF_HW_PERIPHERAL_COUNT MUST be defined as number of peripheral instance.
96 * If peripheral instances start from 0, and are in sequence order(eg, 3 I2Cs: I2C0, I2C1, I2C2), VSF_HW_PERIPHERAL_MASK is not needed.
97 * Otherwise, define VSF_HW_PERIPHERAL_MASK to indicate which peripheral instances to implmenent.
98 * eg: 3 I2Cs: I2C0, I2C2, I2C4, define VSF_HW_I2C_MASK to 0x15(BIT(0) | BIT(2)) | BIT(4)).
99 *
100 * Other configurations are vendor specified, drivers will use these information to generate peripheral instances.
101 * Usually need irqn, irqhandler, peripheral clock enable bits, peripheral reset bites, etc.
102 */
103
104// GPIO
105
106#define VSF_HW_GPIO_PORT_COUNT 1
107#define VSF_HW_GPIO_PIN_COUNT 32
108
109// I2C0, I2C2
110
111#define VSF_HW_I2C_COUNT 2
112#define VSF_HW_I2C_MASK 0x05
113#define VSF_HW_I2C0_IRQN I2C0_IRQn
114#define VSF_HW_I2C0_IRQHandler I2C0_IRQHandler
115#define VSF_HW_I2C0_REG I2C0_BASE
116#define VSF_HW_I2C2_IRQN I2C2_IRQn
117#define VSF_HW_I2C2_IRQHandler I2C2_IRQHandler
118#define VSF_HW_I2C2_REG I2C2_BASE
119
120// SPI0, SPI1
121
122#define VSF_HW_SPI_COUNT 2
123#define VSF_HW_SPI0_IRQN SPI0_IRQn
124#define VSF_HW_SPI0_IRQHandler SPI0_IRQHandler
125#define VSF_HW_SPI0_REG SPI0_BASE
126#define VSF_HW_SPI1_IRQN SPI1_IRQn
127#define VSF_HW_SPI1_IRQHandler SPI1_IRQHandler
128#define VSF_HW_SPI1_REG SPI1_BASE
129
130// QSPI0
131#define VSF_HW_QSPI_COUNT 1
132#define VSF_HW_QSPI0_IRQN QSPI0_IRQn
133#define VSF_HW_QSPI0_IRQHandler QSPI0_IRQHandler
134#define VSF_HW_QSPI0_REG QSPI0_BASE
135#define VSF_HW_QSPI1_IRQN QSPI1_IRQn
136#define VSF_HW_QSPI1_IRQHandler QSPI1_IRQHandler
137#define VSF_HW_QSPI1_REG QSPI1_BASE
138
139// peripheral defines end
140
141/*============================ MACROFIED FUNCTIONS ===========================*/
142/*============================ TYPES =========================================*/
143/*============================ GLOBAL VARIABLES ==============================*/
144/*============================ LOCAL VARIABLES ===============================*/
145/*============================ PROTOTYPES ====================================*/
146
147#endif // __VSF_HAL_DEVICE_${VENDOR}_${DEVICE}_H__
148#endif
149/* EOF */
Generated from commit: vsfteam/vsf@3b461d0