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/*\note first define basic info for arch. */
25#if defined(__VSF_HEADER_ONLY_SHOW_ARCH_INFO__)
26
28# define VSF_ARCH_PRI_NUM 4
29# define VSF_ARCH_PRI_BIT 2
30
31
32// software interrupt provided by a dedicated device
33# define VSF_DEV_SWI_NUM 8
34
35#else
36
37#ifndef __HAL_DEVICE_ARM_CMSDK_CM0_H__
38#define __HAL_DEVICE_ARM_CMSDK_CM0_H__
39
40// software interrupt provided by a dedicated device
41#define VSF_DEV_SWI_LIST 24,25,26,27,28,29,30,31
42
43/*============================ INCLUDES ======================================*/
44
45/*\note this is should be the only place where __common.h is included.*/
46#include "../common/__common.h"
47//#include "CMSDK_CM0.h"
48
49/*============================ MACROS ========================================*/
50
51#define __def_idx(__name, __no) VSF_MCONNECT2(__name, _idx) = (__no)
52#define __def_msk(__name) VSF_MCONNECT2(__name, _msk) = BIT(VSF_MCONNECT2(__name, _idx) & 0x1F)
53
54#define GPIO_COUNT 1
55
56#define PIO_PORTA
57#define PIO_PORTA_PIN_NUM 7
58/*
59#define PIO_PORTB
60#define PIO_PORTB_PIN_NUM 16
61
62#define PIO_PORTC
63#define PIO_PORTC_PIN_NUM 16
64
65#define PIO_PORTD
66#define PIO_PORTD_PIN_NUM 16
67
68
69#define PIO_PORTE
70#define PIO_PORTF
71#define PIO_PORTG
72#define PIO_PORTH
73*/
74
75/*============================ MACROFIED FUNCTIONS ===========================*/
76
77// bit0 - bit13: clksrc bitfield
78// bit14- bit27: clkdiv bitfield
79// bit28- bit31: clkdiv_remap
80#define __def_periph_clk(__name, __bf_clksel, __bf_clkdiv, __clksel_map_idx) \
81 VSF_MCONNECT2(__name, _idx) = ((__bf_clksel) << 0) \
82 | ((__bf_clkdiv) << 14) \
83 | ((__clksel_map_idx) << 28)
84
85#define __def_sync_clk_idx(__name, __bus_idx, __bit_idx) \
86 VSF_MCONNECT2(__name, _idx) = ((__bit_idx) << 0) | ((__bus_idx) << 5)
87
88#define __def_clk_src(__name, __value) __name = (__value)
89
90/*============================ TYPES =========================================*/
91
92#if 0
96 __def_idx(POWER_DUMMY, 0),
97};
99
103 __def_msk(POWER_DUMMY),
104} ;
106
110 VSF_PM_WAIT = 0,
114} ;
116
118 ...,
119};
121
123 ...
124};
126
129enum pm_periph_async_clk_no_t{
130 ...
131};
133
136enum pm_sync_clk_no_t {
137 // NAME BUS_IDX,BIT_IDX
138 // AHB
139 __def_sync_clk_idx( SCLK_UART0, 1, 16 ),
140 __def_sync_clk_idx( SCLK_UART1, 1, 17 ),
141 __def_sync_clk_idx( SCLK_UART2, 1, 18 ),
142 __def_sync_clk_idx( SCLK_UART3, 1, 19 ),
143};
144
145enum pm_sync_clk_msk_t {
146 __def_msk(SCLK_UART0),
147 __def_msk(SCLK_UART1),
148 __def_msk(SCLK_UART2),
149 __def_msk(SCLK_UART3),
150};
152
155 ...
156};
158
159enum vsf_pm_pll_sel_t {
160 PLL0_idx,
161};
162
163struct io_wakeup_cfg_t {
165};
166typedef struct io_wakeup_cfg_t io_wakeup_cfg_t;
167
170
171declare_interface( i_pm_wakeup_t )
172def_interface( i_pm_wakeup_t )
173 struct {
176 }UseIO;
177end_def_interface( i_pm_wakeup_t )
178
179struct pm_periph_asyn_clk_cfg_t {
180 vsf_pm_clk_src_sel_t clk_src;
182};
183
186struct pm_main_clk_cfg_t {
187 vsf_pm_clk_src_sel_t clk_src;
188 uint32_t freq;
189 uint16_t core_div[1];
190 uint16_t ahb_div[1];
191 uint16_t apb_div[2];
192};
194#endif
195
196/*============================ GLOBAL VARIABLES ==============================*/
197/*============================ LOCAL VARIABLES ===============================*/
198/*============================ PROTOTYPES ====================================*/
199
200#endif // __HAL_DEVICE_ARM_CMSDK_CM0_H__
201#endif // __VSF_HEADER_ONLY_SHOW_ARCH_INFO__
202/* EOF */
vsf_err_t
Definition __type.h:42
def_interface(i_adc_t) i_peripheral_t
pm_periph_clksrc_t
Definition pm.h:93
pm_periph_clksel_t
Definition pm.h:114
vsf_io_port_no_t
Definition io.h:90
#define __def_idx(__name, __no)
Definition device.h:51
#define __def_sync_clk_idx(__name, __bus_idx, __bit_idx)
Definition device.h:85
#define __def_msk(__name)
Definition device.h:52
end_def_interface(i_pm_wakeup_t) struct vsf_pm_pclk_cfg_t
Definition device.h:249
UseIO
Definition device.h:248
unsigned short uint16_t
Definition stdint.h:7
unsigned char uint_fast8_t
Definition stdint.h:23
unsigned uint32_t
Definition stdint.h:9
unsigned int uint_fast32_t
Definition stdint.h:27
div_t div(int numer, int denom)
Definition pm.h:549
uint32_t dummy
Definition pm.h:550
void(* Enable)(void)
enable
Definition systick.h:86
bool(* Disable)(void)
disable
Definition systick.h:87
uint32_t size
Definition vsf_memfs.h:50
declare_interface(i_msg_tree_node_t) def_interface(i_msg_tree_node_t) vsf_msgt_handler_t msg_handler
vsf_pm_pll_sel_t
Definition vsf_template_pm.h:374
vsf_pm_power_cfg_msk_t
Definition vsf_template_pm.h:210
vsf_pm_power_cfg_no_t
Definition vsf_template_pm.h:204
vsf_pm_sleep_mode_t
Definition vsf_template_pm.h:222
@ VSF_PM_POWER_OFF
Definition vsf_template_pm.h:226
@ VSF_PM_DEEP_SLEEP
Definition vsf_template_pm.h:225
@ VSF_PM_WAIT
Definition vsf_template_pm.h:223
@ VSF_PM_SLEEP
Definition vsf_template_pm.h:224
vsf_pm_clk_src_sel_t
Definition vsf_template_pm.h:266