1 | /*
|
---|
2 | * TOPPERS/ASP Kernel
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
4 | * Advanced Standard Profile Kernel
|
---|
5 | *
|
---|
6 | * Copyright (C) 2008-2011 by Embedded and Real-Time Systems Laboratory
|
---|
7 | * Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
8 | * Copyright (C) 2015-2019 by TOPPERS PROJECT Educational Working Group.
|
---|
9 | *
|
---|
10 | * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
11 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
12 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
13 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
14 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
15 | * スコード中に含まれていること.
|
---|
16 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
17 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
18 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
19 | * の無保証規定を掲載すること.
|
---|
20 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
21 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
22 | * と.
|
---|
23 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
24 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
25 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
26 | * 報告すること.
|
---|
27 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
28 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
29 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
30 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
31 | * 免責すること.
|
---|
32 | *
|
---|
33 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
34 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
35 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
36 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
37 | * の責任を負わない.
|
---|
38 | *
|
---|
39 | * @(#) $Id$
|
---|
40 | */
|
---|
41 | /*
|
---|
42 | * K210用デバイスドライバの外部宣言
|
---|
43 | */
|
---|
44 |
|
---|
45 | #ifndef _DEVICE_H_
|
---|
46 | #define _DEVICE_H_
|
---|
47 |
|
---|
48 | #ifdef __cplusplus
|
---|
49 | extern "C" {
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | /*
|
---|
53 | * TOPPERS BASE PLATFORM情報
|
---|
54 | */
|
---|
55 | #define TOPPERS_BASE_PLATFORM_K210
|
---|
56 | #define SPI_DRIVER_NOSTART
|
---|
57 |
|
---|
58 | /*
|
---|
59 | * バージョン情報
|
---|
60 | */
|
---|
61 | #define TPLATFORM_PRVER 0x0012 /* プラットフォームのバージョン番号 */
|
---|
62 |
|
---|
63 | /*
|
---|
64 | * ピン設定
|
---|
65 | */
|
---|
66 |
|
---|
67 | #define PINPOSITION0 0
|
---|
68 | #define PINPOSITION1 1
|
---|
69 | #define PINPOSITION2 2
|
---|
70 | #define PINPOSITION3 3
|
---|
71 | #define PINPOSITION4 4
|
---|
72 | #define PINPOSITION5 5
|
---|
73 | #define PINPOSITION6 6
|
---|
74 | #define PINPOSITION7 7
|
---|
75 | #define PINPOSITION8 8
|
---|
76 | #define PINPOSITION9 9
|
---|
77 | #define PINPOSITION10 10
|
---|
78 | #define PINPOSITION11 11
|
---|
79 | #define PINPOSITION12 12
|
---|
80 | #define PINPOSITION13 13
|
---|
81 | #define PINPOSITION14 14
|
---|
82 | #define PINPOSITION15 15
|
---|
83 | #define PINPOSITION16 16
|
---|
84 | #define PINPOSITION17 17
|
---|
85 | #define PINPOSITION18 18
|
---|
86 | #define PINPOSITION19 19
|
---|
87 | #define PINPOSITION20 20
|
---|
88 | #define PINPOSITION21 21
|
---|
89 | #define PINPOSITION22 22
|
---|
90 | #define PINPOSITION23 23
|
---|
91 | #define PINPOSITION24 24
|
---|
92 | #define PINPOSITION25 25
|
---|
93 | #define PINPOSITION26 26
|
---|
94 | #define PINPOSITION27 27
|
---|
95 | #define PINPOSITION28 28
|
---|
96 | #define PINPOSITION29 29
|
---|
97 | #define PINPOSITION30 30
|
---|
98 | #define PINPOSITION31 31
|
---|
99 |
|
---|
100 | #define GPIO_PIN_0 (1<<PINPOSITION0)
|
---|
101 | #define GPIO_PIN_1 (1<<PINPOSITION1)
|
---|
102 | #define GPIO_PIN_2 (1<<PINPOSITION2)
|
---|
103 | #define GPIO_PIN_3 (1<<PINPOSITION3)
|
---|
104 | #define GPIO_PIN_4 (1<<PINPOSITION4)
|
---|
105 | #define GPIO_PIN_5 (1<<PINPOSITION5)
|
---|
106 | #define GPIO_PIN_6 (1<<PINPOSITION6)
|
---|
107 | #define GPIO_PIN_7 (1<<PINPOSITION7)
|
---|
108 | #define GPIO_PIN_8 (1<<PINPOSITION8)
|
---|
109 | #define GPIO_PIN_9 (1<<PINPOSITION9)
|
---|
110 | #define GPIO_PIN_10 (1<<PINPOSITION10)
|
---|
111 | #define GPIO_PIN_11 (1<<PINPOSITION11)
|
---|
112 | #define GPIO_PIN_12 (1<<PINPOSITION12)
|
---|
113 | #define GPIO_PIN_13 (1<<PINPOSITION13)
|
---|
114 | #define GPIO_PIN_14 (1<<PINPOSITION14)
|
---|
115 | #define GPIO_PIN_15 (1<<PINPOSITION15)
|
---|
116 | #define GPIO_PIN_16 (1<<PINPOSITION16)
|
---|
117 | #define GPIO_PIN_17 (1<<PINPOSITION17)
|
---|
118 | #define GPIO_PIN_18 (1<<PINPOSITION18)
|
---|
119 | #define GPIO_PIN_19 (1<<PINPOSITION19)
|
---|
120 | #define GPIO_PIN_20 (1<<PINPOSITION20)
|
---|
121 | #define GPIO_PIN_21 (1<<PINPOSITION21)
|
---|
122 | #define GPIO_PIN_22 (1<<PINPOSITION22)
|
---|
123 | #define GPIO_PIN_23 (1<<PINPOSITION23)
|
---|
124 | #define GPIO_PIN_24 (1<<PINPOSITION24)
|
---|
125 | #define GPIO_PIN_25 (1<<PINPOSITION25)
|
---|
126 | #define GPIO_PIN_26 (1<<PINPOSITION26)
|
---|
127 | #define GPIO_PIN_27 (1<<PINPOSITION27)
|
---|
128 | #define GPIO_PIN_28 (1<<PINPOSITION28)
|
---|
129 | #define GPIO_PIN_29 (1<<PINPOSITION29)
|
---|
130 | #define GPIO_PIN_30 (1<<PINPOSITION30)
|
---|
131 | #define GPIO_PIN_31 (1<<PINPOSITION31)
|
---|
132 |
|
---|
133 | #define ARDUINO_GPIO_PORT 48
|
---|
134 |
|
---|
135 | /*
|
---|
136 | * GPIOモードパラメータ
|
---|
137 | */
|
---|
138 | #define GPIO_MODE_INPUT 0x00000000 /* Input Floating Mode */
|
---|
139 | #define GPIO_MODE_OUTPUT 0x00000001 /* Output Mode */
|
---|
140 |
|
---|
141 | /*
|
---|
142 | * GPIO-割込みモードパラメータ
|
---|
143 | */
|
---|
144 | #define GPIO_MODE_IT_RISING 0x00110000 /* Interrupt Mode with Rising edge trigger detection */
|
---|
145 | #define GPIO_MODE_IT_FALLING 0x00210000 /* Interrupt Mode with Falling edge trigger detection */
|
---|
146 | #define GPIO_MODE_IT_HIGH 0x00410000 /* Interrupt Mode High Level */
|
---|
147 | #define GPIO_MODE_IT_LOW 0x00810000 /* Interrupt Mode Low Level */
|
---|
148 |
|
---|
149 | /*
|
---|
150 | * GPIOプルアップダウンパラメータ
|
---|
151 | */
|
---|
152 | #define GPIO_NOPULL 0x00000000 /* No Pull-up or Pull-down activation */
|
---|
153 | #define GPIO_PULLUP 0x00000001 /* Pull-up activation */
|
---|
154 | #define GPIO_PULLDOWN 0x00000002 /* Pull-down activation */
|
---|
155 | #define GPIO_PULLMAX (GPIO_PULLDOWN+1)
|
---|
156 |
|
---|
157 | /*
|
---|
158 | * GPIO初期化設定
|
---|
159 | */
|
---|
160 | typedef struct
|
---|
161 | {
|
---|
162 | uint32_t mode; /* specifies the operating mode for the selected pins. */
|
---|
163 | uint32_t pull; /* specifies the Pull-up or Pull-Down */
|
---|
164 | }GPIO_Init_t;
|
---|
165 |
|
---|
166 | extern void gpio_setup(unsigned long base, GPIO_Init_t *init, uint32_t pin);
|
---|
167 | extern void gpio_set_pin(unsigned long base, uint8_t pin, uint8_t value);
|
---|
168 | extern uint8_t gpio_get_pin(unsigned long base, uint8_t pin);
|
---|
169 | extern int gpio_get_gpiohno(uint8_t fpio_pin, bool_t intreq);
|
---|
170 |
|
---|
171 |
|
---|
172 | /*
|
---|
173 | * DMAチャンネル定義
|
---|
174 | */
|
---|
175 | #define DMA_CHANNEL0 0
|
---|
176 | #define DMA_CHANNEL1 1
|
---|
177 | #define DMA_CHANNEL2 2
|
---|
178 | #define DMA_CHANNEL3 3
|
---|
179 | #define DMA_CHANNEL4 4
|
---|
180 | #define DMA_CHANNEL5 5
|
---|
181 | #define NUM_DMA_CHANNEL (NUM_DMAC_CHANNEL)
|
---|
182 |
|
---|
183 | /*
|
---|
184 | * DMA選択定義
|
---|
185 | */
|
---|
186 | #define DMA_SELECT_SSI0_RX_REQ 0
|
---|
187 | #define DMA_SELECT_SSI0_TX_REQ 1
|
---|
188 | #define DMA_SELECT_SSI1_RX_REQ 2
|
---|
189 | #define DMA_SELECT_SSI1_TX_REQ 3
|
---|
190 | #define DMA_SELECT_SSI2_RX_REQ 4
|
---|
191 | #define DMA_SELECT_SSI2_TX_REQ 5
|
---|
192 | #define DMA_SELECT_SSI3_RX_REQ 6
|
---|
193 | #define DMA_SELECT_SSI3_TX_REQ 7
|
---|
194 | #define DMA_SELECT_I2C0_RX_REQ 8
|
---|
195 | #define DMA_SELECT_I2C0_TX_REQ 9
|
---|
196 | #define DMA_SELECT_I2C1_RX_REQ 10
|
---|
197 | #define DMA_SELECT_I2C1_TX_REQ 11
|
---|
198 | #define DMA_SELECT_I2C2_RX_REQ 12
|
---|
199 | #define DMA_SELECT_I2C2_TX_REQ 13
|
---|
200 | #define DMA_SELECT_UART1_RX_REQ 14
|
---|
201 | #define DMA_SELECT_UART1_TX_REQ 15
|
---|
202 | #define DMA_SELECT_UART2_RX_REQ 16
|
---|
203 | #define DMA_SELECT_UART2_TX_REQ 17
|
---|
204 | #define DMA_SELECT_UART3_RX_REQ 18
|
---|
205 | #define DMA_SELECT_UART3_TX_REQ 19
|
---|
206 | #define DMA_SELECT_AES_REQ 20
|
---|
207 | #define DMA_SELECT_SHA_RX_REQ 21
|
---|
208 | #define DMA_SELECT_AI_RX_REQ 22
|
---|
209 | #define DMA_SELECT_FFT_RX_REQ 23
|
---|
210 | #define DMA_SELECT_FFT_TX_REQ 24
|
---|
211 | #define DMA_SELECT_I2S0_TX_REQ 25
|
---|
212 | #define DMA_SELECT_I2S0_RX_REQ 26
|
---|
213 | #define DMA_SELECT_I2S1_TX_REQ 27
|
---|
214 | #define DMA_SELECT_I2S1_RX_REQ 28
|
---|
215 | #define DMA_SELECT_I2S2_TX_REQ 29
|
---|
216 | #define DMA_SELECT_I2S2_RX_REQ 30
|
---|
217 | #define DMA_SELECT_I2S0_BF_DIR_REQ 31
|
---|
218 | #define DMA_SELECT_I2S0_BF_VOICE_REQ 32
|
---|
219 | #define NUM_DMA_SELECT 33
|
---|
220 |
|
---|
221 | /*
|
---|
222 | * DMAステータス定義
|
---|
223 | */
|
---|
224 | #define DMA_STATUS_BUSY 0x0001 /* BUSY */
|
---|
225 | #define DMA_STATUS_READY_HMEM0 0x0002 /* DMA Mem0 Half process success */
|
---|
226 | #define DMA_STATUS_READY_HMEM1 0x0004 /* DMA Mem1 Half process success */
|
---|
227 | #define DMA_STATUS_READY_MEM0 0x0008 /* DMA Mem0 process success */
|
---|
228 | #define DMA_STATUS_READY_ERROR 0x0100 /* DMA Error end */
|
---|
229 |
|
---|
230 | /*
|
---|
231 | * DMA転送方向定義
|
---|
232 | */
|
---|
233 | #define DMA_MEMORY_TO_MEMORY 0x0000 /* Memory to memory direction(DMAC) */
|
---|
234 | #define DMA_MEMORY_TO_PERIPH 0x0001 /* Memory to peripheral direction(DMAC) */
|
---|
235 | #define DMA_PERIPH_TO_MEMORY 0x0002 /* Peripheral to memory direction(DMAC) */
|
---|
236 | #define DMA_PERIPH_TO_PERIPH 0x0003 /* Peripheral to peripheral direction(DMAC) */
|
---|
237 | #define PRF_PERIPH_TO_MEMORY1 0x0004 /* Peripheral to memory direction(PRF-SRC) */
|
---|
238 | #define PRF_PERIPH_TO_PERIPH 0x0005 /* Peripheral to peripheral direction(PRF) */
|
---|
239 | #define PRF_MEMORY_TO_PERIPH 0x0006 /* Memory to peripheral direction(PRF) */
|
---|
240 | #define PRF_PERIPH_TO_MEMORY2 0x0007 /* Peripheral to memory direction(PRF-DST) */
|
---|
241 |
|
---|
242 | /*
|
---|
243 | * DMAマルチブロックタイプ
|
---|
244 | */
|
---|
245 | #define DMAC_MULTBLOCK_CONT 0x0000 /* Continuous multiblock type */
|
---|
246 | #define DMAC_MULTBLOCK_RELOAD 0x0001 /* Reload multiblock type */
|
---|
247 | #define DMAC_MULTBLOCK_SHADOW 0x0002 /* Shadow register based multiblock type */
|
---|
248 | #define DMAC_MULTBLOCK_LINKED 0x0003 /* Linked lisr bases multiblock type */
|
---|
249 |
|
---|
250 | /*
|
---|
251 | * DMAソフトウェア-ハードウェアハンドシェイク
|
---|
252 | */
|
---|
253 | #define DMAC_HS_HARDWARE 0x0000 /* Hardware handshaking */
|
---|
254 | #define DMAC_HS_SOFTWARE 0x0001 /* Software handshaking */
|
---|
255 |
|
---|
256 | /*
|
---|
257 | * DMAハードウェアハンドシェイク極性
|
---|
258 | */
|
---|
259 | #define DMAC_HWHS_POLARITY_LOW 0x0000 /* polarity low */
|
---|
260 | #define DMAC_HWHS_POLARITY_HIGH 0x00001 /* polarity high */
|
---|
261 |
|
---|
262 | /*
|
---|
263 | * DMA優先度定義
|
---|
264 | */
|
---|
265 | #define DMAC_PRIORITY_0 0x0000
|
---|
266 | #define DMAC_PRIORITY_1 0x0001
|
---|
267 | #define DMAC_PRIORITY_2 0x0002
|
---|
268 | #define DMAC_PRIORITY_3 0x0003
|
---|
269 | #define DMAC_PRIORITY_4 0x0004
|
---|
270 | #define DMAC_PRIORITY_5 0x0005
|
---|
271 | #define DMAC_PRIORITY_6 0x0006
|
---|
272 | #define DMAC_PRIORITY_7 0x0007
|
---|
273 |
|
---|
274 |
|
---|
275 | /*
|
---|
276 | * DMAマスター定義
|
---|
277 | */
|
---|
278 | #define DMAC_MASTER1 0x0000 /* Master #1 */
|
---|
279 | #define DMAC_MASTER2 0x0001 /* Master #2 */
|
---|
280 |
|
---|
281 | /*
|
---|
282 | * DMAインクリメントモード
|
---|
283 | */
|
---|
284 | #define DMAC_ADDR_INCREMENT 0x0000 /* インクリメント */
|
---|
285 | #define DMAC_ADDR_NOCHANGE 0x0001 /* 未変更 */
|
---|
286 |
|
---|
287 | /*
|
---|
288 | * DMA転送幅定義
|
---|
289 | */
|
---|
290 | #define DMAC_TRANS_WIDTH_8 0x0000 /* 8ビット */
|
---|
291 | #define DMAC_TRANS_WIDTH_16 0x0001 /* 16ビット */
|
---|
292 | #define DMAC_TRANS_WIDTH_32 0x0002 /* 32ビット */
|
---|
293 | #define DMAC_TRANS_WIDTH_64 0x0003 /* 64ビット */
|
---|
294 | #define DMAC_TRANS_WIDTH_128 0x0004 /* 128ビット */
|
---|
295 | #define DMAC_TRANS_WIDTH_256 0x0005 /* 256ビット */
|
---|
296 |
|
---|
297 | /*
|
---|
298 | * DMAブースト転送サイズ定義
|
---|
299 | */
|
---|
300 | #define DMAC_MSIZE_1 0x0000 /* 1バイト */
|
---|
301 | #define DMAC_MSIZE_4 0x0001 /* 4バイト */
|
---|
302 | #define DMAC_MSIZE_8 0x0002 /* 8バイト */
|
---|
303 | #define DMAC_MSIZE_16 0x0003 /* 16バイト */
|
---|
304 | #define DMAC_MSIZE_32 0x0004 /* 32バイト */
|
---|
305 | #define DMAC_MSIZE_64 0x0005 /* 64バイト */
|
---|
306 | #define DMAC_MSIZE_128 0x0006 /* 128バイト */
|
---|
307 | #define DMAC_MSIZE_256 0x0007 /* 256バイト */
|
---|
308 |
|
---|
309 | #define DMA_TRS_TIMEOUT 2000 /* 2秒 */
|
---|
310 |
|
---|
311 | /*
|
---|
312 | * DMA初期化構造体定義
|
---|
313 | */
|
---|
314 | typedef struct
|
---|
315 | {
|
---|
316 | uint16_t Request; /* DMA選択 */
|
---|
317 | uint16_t Direction; /* DMA転送方向 */
|
---|
318 | uint16_t SrcMultBlock; /* ソースマルチブロックタイプ */
|
---|
319 | uint16_t DrcMultBlock; /* デスティネーションマルチブロックタイプ */
|
---|
320 | uint16_t SrcHandShake; /* ソースハンドシェイク */
|
---|
321 | uint16_t DrcHandShake; /* デスティネーションハンドシェイク */
|
---|
322 | uint16_t SrcHwhsPol; /* ソースハードウェアハンドシェイク極性 */
|
---|
323 | uint16_t DrcHwhsPol; /* デスティネーションハードウェアハンドシェイク極性 */
|
---|
324 | uint16_t Priority; /* 優先度 */
|
---|
325 | uint16_t SrcMaster; /* ソースマスター設定 */
|
---|
326 | uint16_t DstMaster; /* デスティネーションマスター設定 */
|
---|
327 | uint16_t SrcInc; /* ソースインクリメント設定 */
|
---|
328 | uint16_t DstInc; /* デスティネーションインクリメント設定 */
|
---|
329 | uint16_t SrcTransWidth;/* ソース転送幅 */
|
---|
330 | uint16_t DstTransWidth;/* デスティネーション転送幅 */
|
---|
331 | uint16_t SrcBurstSize; /* ソースバーストサイズ */
|
---|
332 | uint16_t DstBurstSize; /* デスティネーションバーストサイズ */
|
---|
333 | uint16_t IocBlkTrans; /* IOCブロック転送 */
|
---|
334 | }DMA_Init_t;
|
---|
335 |
|
---|
336 | /*
|
---|
337 | * DMAハンドラ構造体定義
|
---|
338 | */
|
---|
339 | typedef struct __DMA_Handle_t DMA_Handle_t;
|
---|
340 | struct __DMA_Handle_t
|
---|
341 | {
|
---|
342 | unsigned long base; /* DMA Port base address */
|
---|
343 | unsigned long cbase; /* DMA Channel Port address */
|
---|
344 | DMA_Init_t Init; /* DMA communication parameters */
|
---|
345 | uint16_t chnum; /* channel number */
|
---|
346 | volatile uint16_t status; /* DMA status */
|
---|
347 | volatile uint16_t ErrorCode; /* DMA Error code */
|
---|
348 | uint16_t dummy;
|
---|
349 | void (*xfercallback)(DMA_Handle_t * hdma); /* DMA transfer complete callback */
|
---|
350 | void (*errorcallback)(DMA_Handle_t * hdma); /* DMA transfer error callback */
|
---|
351 | void *localdata; /* DMA local data */
|
---|
352 | };
|
---|
353 |
|
---|
354 | /*
|
---|
355 | * DMAステータス定義
|
---|
356 | */
|
---|
357 | #define DMA_STATUS_READY 0x0000 /* READY */
|
---|
358 | #define DMA_STATUS_BUSY 0x0001 /* BUSY */
|
---|
359 | #define DMA_STATUS_READY_TRN1 0x0008 /* DMA Mem process success */
|
---|
360 | #define DMA_STATUS_READY_TRN2 0x0010 /* DMA SRC process success */
|
---|
361 | #define DMA_STATUS_READY_TRN3 0x0020 /* DMA DST process success */
|
---|
362 | #define DMA_STATUS_READY_ERROR 0x0100 /* DMA Error end */
|
---|
363 |
|
---|
364 | /*
|
---|
365 | * DMAエラー定義
|
---|
366 | */
|
---|
367 | #define DMA_ERROR_NONE 0x0000 /* No error */
|
---|
368 | #define DMA_ERROR_SRC_DODE 0x0020 /* Source Decode error */
|
---|
369 | #define DMA_ERROR_DST_DECODE 0x0040 /* Destination Decode error */
|
---|
370 | #define DMA_ERROR_SRC_SLV 0x0080 /* Source Slave Error Status Enable */
|
---|
371 | #define DMA_ERROR_DST_SLV 0x0100 /* Destination Slave Error Status Enable */
|
---|
372 | #define DMA_ERROR_LLI_RD_DEC 0x0200 /* LLI Read Decode Error Status */
|
---|
373 | #define DMA_ERROR_LLI_WR_DEC 0x0400 /* LLI Write Decode Error Status */
|
---|
374 | #define DMA_ERROR_LLI_RD_SLV 0x0800 /* LLI Read Slave Error Status Enable */
|
---|
375 | #define DMA_ERROR_LLI_WR_SLV 0x1000 /* LLI Write Slave Error Status Enable */
|
---|
376 | #define DMA_ERROR_TIMEOUT 0x0001 /* Timeout error */
|
---|
377 |
|
---|
378 | extern ER dma_init(DMA_Handle_t *hdma);
|
---|
379 | extern ER dma_deinit(DMA_Handle_t *hdma);
|
---|
380 | extern ER dma_reset(DMA_Handle_t *hdma);
|
---|
381 | extern ER dma_start(DMA_Handle_t *hdma, uintptr_t SrcAddress, uintptr_t DstAddress, uint32_t DataLength);
|
---|
382 | extern ER dma_end(DMA_Handle_t *hdma);
|
---|
383 | extern void channel_dmac_isr(intptr_t exinf);
|
---|
384 | extern ER select_dma_channel(uint8_t channel, uint8_t select);
|
---|
385 |
|
---|
386 |
|
---|
387 | /*
|
---|
388 | * WDOGドライバ
|
---|
389 | */
|
---|
390 | #define WDOG1_PORTID 1
|
---|
391 | #define WDOG2_PORTID 2
|
---|
392 | #define NUM_WDOGPORT 2
|
---|
393 |
|
---|
394 | /*
|
---|
395 | * WDOGモード定義
|
---|
396 | */
|
---|
397 | #define WDT_MODE_REST WDT_CR_RMOD_RESET
|
---|
398 | #define WDT_MODE_INTERRUPT WDT_CR_RMOD_INTERRUPT
|
---|
399 |
|
---|
400 | /*
|
---|
401 | * WDOGハンドラ定義
|
---|
402 | */
|
---|
403 | typedef struct __WDT_Handle_t WDT_Handle_t;
|
---|
404 | struct __WDT_Handle_t
|
---|
405 | {
|
---|
406 | unsigned long base;
|
---|
407 | uint32_t wdtno;
|
---|
408 | uint32_t pclk;
|
---|
409 | void (*callback)(WDT_Handle_t *hwdt);
|
---|
410 | };
|
---|
411 |
|
---|
412 | #define INHNO_WDOG1 IRQ_VECTOR_WDT0 /* 割込みハンドラ番号 */
|
---|
413 | #define INTNO_WDOG1 IRQ_VECTOR_WDT0 /* 割込み番号 */
|
---|
414 | #define INHNO_WDOG2 IRQ_VECTOR_WDT1 /* 割込みハンドラ番号 */
|
---|
415 | #define INTNO_WDOG2 IRQ_VECTOR_WDT1 /* 割込み番号 */
|
---|
416 | #define INTPRI_WDOG -1 /* 割込み優先度 */
|
---|
417 | #define INTATR_WDOG 0 /* 割込み属性 */
|
---|
418 |
|
---|
419 | extern WDT_Handle_t *wdt_init(ID port);
|
---|
420 | extern ER wdt_deinit(WDT_Handle_t *hwdt);
|
---|
421 | extern ER_UINT wdt_start(WDT_Handle_t *hwdt, uint32_t mode, uint32_t timeout_ms);
|
---|
422 | extern ER wdt_stop(WDT_Handle_t *hwdt);
|
---|
423 | extern void wdog_isr(intptr_t exinf);
|
---|
424 |
|
---|
425 |
|
---|
426 | /*
|
---|
427 | * RTCドライバ
|
---|
428 | */
|
---|
429 |
|
---|
430 | /*
|
---|
431 | * RTCモード定義
|
---|
432 | */
|
---|
433 | #define RTC_TIMER_PAUSE 0 /* Timer pause */
|
---|
434 | #define RTC_TIMER_RUNNING 1 /* Timer time running */
|
---|
435 | #define RTC_TIMER_SETTING 2 /* Timer time setting */
|
---|
436 | #define RTC_TIMER_MAX 3 /* Max count of this enum*/
|
---|
437 |
|
---|
438 | /*
|
---|
439 | * RTC TICK割込みモード
|
---|
440 | */
|
---|
441 | #define RTC_INT_SECOND 0 /* 秒単位 */
|
---|
442 | #define RTC_INT_MINUTE 1 /* 分単位 */
|
---|
443 | #define RTC_INT_HOUR 2 /* 時間単位 */
|
---|
444 | #define RTC_INT_DAY 3 /* 日単位 */
|
---|
445 |
|
---|
446 | /*
|
---|
447 | * RTC ALARMマスク
|
---|
448 | */
|
---|
449 | #define RTC_ALARM_SECOND 0x02000000 /* 秒マスク */
|
---|
450 | #define RTC_ALARM_MINUTE 0x04000000 /* 分マスク */
|
---|
451 | #define RTC_ALARM_HOUR 0x08000000 /* 時マスク */
|
---|
452 | #define RTC_ALARM_WEEK 0x10000000 /* 週マスク */
|
---|
453 | #define RTC_ALARM_DAY 0x20000000 /* 日マスク */
|
---|
454 | #define RTC_ALARM_MONTH 0x40000000 /* 月マスク */
|
---|
455 | #define RTC_ALARM_YEAR 0x80000000 /* 年マスク */
|
---|
456 |
|
---|
457 | /*
|
---|
458 | * RTC割込み設定
|
---|
459 | */
|
---|
460 | #define INHNO_RTC IRQ_VECTOR_RTC /* 割込みハンドラ番号 */
|
---|
461 | #define INTNO_RTC IRQ_VECTOR_RTC /* 割込み番号 */
|
---|
462 | #define INTPRI_RTC -7 /* 割込み優先度 */
|
---|
463 | #define INTATR_RTC 0 /* 割込み属性 */
|
---|
464 |
|
---|
465 | /*
|
---|
466 | * 日時設定用の構造体を定義
|
---|
467 | */
|
---|
468 | struct tm2 {
|
---|
469 | int tm_sec; /* 秒 */
|
---|
470 | int tm_min; /* 分 */
|
---|
471 | int tm_hour; /* 時 */
|
---|
472 | int tm_mday; /* 月中の日 */
|
---|
473 | int tm_mon; /* 月 */
|
---|
474 | int tm_year; /* 年 */
|
---|
475 | int tm_wday; /* 曜日 */
|
---|
476 | int tm_yday; /* 年中の日 */
|
---|
477 | int tm_isdst;
|
---|
478 | };
|
---|
479 |
|
---|
480 | /*
|
---|
481 | * RTCアラーム構造体
|
---|
482 | */
|
---|
483 | typedef struct
|
---|
484 | {
|
---|
485 | uint32_t alarmmask; /* アラームマスク設定 */
|
---|
486 | void (*callback)(int); /* アラームコールバック */
|
---|
487 | }RTC_Alarm_t;
|
---|
488 |
|
---|
489 | extern void rtc_init(intptr_t exinf);
|
---|
490 | extern void rtc_info_init(intptr_t exinf);
|
---|
491 | extern ER rtc_timer_set_mode(uint8_t timer_mode);
|
---|
492 | extern ER rtc_set_time(struct tm2 *pt);
|
---|
493 | extern ER rtc_get_time(struct tm2 *pt);
|
---|
494 | extern ER_UINT rtc_intmode(int8_t mode, void *func);
|
---|
495 | extern ER rtc_setalarm(RTC_Alarm_t *parm, struct tm2 *ptm);
|
---|
496 | extern void rtc_int_handler(void);
|
---|
497 |
|
---|
498 | extern uint8_t rtc_timer_mode;
|
---|
499 |
|
---|
500 | /*
|
---|
501 | * デバイス初期化
|
---|
502 | */
|
---|
503 | extern void device_init(intptr_t exinf);
|
---|
504 |
|
---|
505 | /*
|
---|
506 | * SPI0/DVPのモード設定
|
---|
507 | */
|
---|
508 | extern ER select_spi0_dvp_mode(uint8_t en);
|
---|
509 |
|
---|
510 |
|
---|
511 | /*
|
---|
512 | * FPIOAにファンクションを設定する
|
---|
513 | * param1 number The IO number
|
---|
514 | * param2 function The function enum number
|
---|
515 | * return 0-OK
|
---|
516 | */
|
---|
517 | extern ER fpioa_set_function(int number, uint8_t function);
|
---|
518 |
|
---|
519 |
|
---|
520 | /*
|
---|
521 | * PLLクロック取得
|
---|
522 | */
|
---|
523 | extern uint32_t get_pll_clock(uint8_t no);
|
---|
524 |
|
---|
525 |
|
---|
526 |
|
---|
527 | #ifdef __cplusplus
|
---|
528 | }
|
---|
529 | #endif
|
---|
530 |
|
---|
531 | #endif
|
---|
532 |
|
---|