source: azure_iot_hub_f767zi/trunk/asp_baseplatform/pdic/stm32f7xx/device.h@ 457

Last change on this file since 457 was 457, checked in by coas-nagasima, 4 years ago

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 30.3 KB
Line 
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 * STM32F7XX用デバイスドライバの外部宣言
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_STF7
56
57/*
58 * バージョン情報
59 */
60#define TPLATFORM_PRVER 0x1041 /* プラットフォームのバージョン番号 */
61
62/*
63 * ピン設定
64 */
65
66#define PINPOSITION0 0
67#define PINPOSITION1 1
68#define PINPOSITION2 2
69#define PINPOSITION3 3
70#define PINPOSITION4 4
71#define PINPOSITION5 5
72#define PINPOSITION6 6
73#define PINPOSITION7 7
74#define PINPOSITION8 8
75#define PINPOSITION9 9
76#define PINPOSITION10 10
77#define PINPOSITION11 11
78#define PINPOSITION12 12
79#define PINPOSITION13 13
80#define PINPOSITION14 14
81#define PINPOSITION15 15
82
83#define GPIO_PIN_0 (1<<PINPOSITION0)
84#define GPIO_PIN_1 (1<<PINPOSITION1)
85#define GPIO_PIN_2 (1<<PINPOSITION2)
86#define GPIO_PIN_3 (1<<PINPOSITION3)
87#define GPIO_PIN_4 (1<<PINPOSITION4)
88#define GPIO_PIN_5 (1<<PINPOSITION5)
89#define GPIO_PIN_6 (1<<PINPOSITION6)
90#define GPIO_PIN_7 (1<<PINPOSITION7)
91#define GPIO_PIN_8 (1<<PINPOSITION8)
92#define GPIO_PIN_9 (1<<PINPOSITION9)
93#define GPIO_PIN_10 (1<<PINPOSITION10)
94#define GPIO_PIN_11 (1<<PINPOSITION11)
95#define GPIO_PIN_12 (1<<PINPOSITION12)
96#define GPIO_PIN_13 (1<<PINPOSITION13)
97#define GPIO_PIN_14 (1<<PINPOSITION14)
98#define GPIO_PIN_15 (1<<PINPOSITION15)
99
100/*
101 * GPIOモードパラメータ
102 */
103#define GPIO_MODE_INPUT 0x00000000 /* Input Floating Mode */
104#define GPIO_MODE_OUTPUT 0x00000001 /* Output Mode */
105#define GPIO_MODE_AF 0x00000002 /* Alternate Function Mode */
106#define GPIO_MODE_ANALOG 0x00000003 /* Analog Mode */
107
108/*
109 * GPIO-EXTIモードパラメータ
110 */
111#define GPIO_MODE_IT_RISING 0x10110000 /* External Interrupt Mode with Rising edge trigger detection */
112#define GPIO_MODE_IT_FALLING 0x10210000 /* External Interrupt Mode with Falling edge trigger detection */
113#define GPIO_MODE_IT_RISING_FALLING 0x10310000 /* External Interrupt Mode with Rising/Falling edge trigger detection */
114#define GPIO_MODE_EVT_RISING 0x10120000 /* External Event Mode with Rising edge trigger detection */
115#define GPIO_MODE_EVT_FALLING 0x10220000 /* External Event Mode with Falling edge trigger detection */
116#define GPIO_MODE_EVT_RISING_FALLING 0x10320000 /* External Event Mode with Rising/Falling edge trigger detection */
117
118/*
119 * GPIOアウトプット設定パラメータ
120 */
121#define GPIO_OTYPE_PP 0x0
122#define GPIO_OTYPE_OD 0x1
123
124/*
125 * GPIOアウトプット最大周波数パラメータ
126 */
127#define GPIO_SPEED_LOW 0x00000000 /* Low speed */
128#define GPIO_SPEED_MEDIUM 0x00000001 /* Medium speed */
129#define GPIO_SPEED_FAST 0x00000002 /* Fast speed */
130#define GPIO_SPEED_HIGH 0x00000003 /* High speed */
131
132/*
133 * GPIOプルアップダウンパラメータ
134 */
135#define GPIO_NOPULL 0x00000000 /* No Pull-up or Pull-down activation */
136#define GPIO_PULLUP 0x00000001 /* Pull-up activation */
137#define GPIO_PULLDOWN 0x00000002 /* Pull-down activation */
138
139/*
140 * GPIO初期化設定
141 */
142typedef struct
143{
144 uint32_t mode; /* specifies the operating mode for the selected pins. */
145 uint32_t pull; /* specifies the Pull-up or Pull-Down */
146 uint32_t otype; /* output type */
147 uint32_t speed; /* speed for the selected pins. */
148 uint32_t alternate; /* alternate for the selected pins. */
149}GPIO_Init_t;
150
151typedef struct {
152 uint32_t base;
153 uint32_t pinmap;
154} GPIO_Init_Table;
155
156
157extern void gpio_setup(uint32_t base, GPIO_Init_t *init, uint32_t pin);
158
159/*
160 * SDRAMアドレス
161 */
162#define SDRAM_ADDRESS 0xC0000000
163
164/*
165 * FMC SDRAM Bank
166 */
167#define FMC_SDRAM_BANK1 0
168#define FMC_SDRAM_BANK2 1
169
170extern void sdram_init(intptr_t exinf);
171
172
173/*
174 * キャッシュ制御関数
175 */
176#define CACHE_LINE_SIZE 32 /* cortex-m7 cacle line size */
177
178extern void invalidatedcache_by_addr(uint8_t *addr, int32_t dsize);
179extern void flushdcache_by_addr(uint8_t *addr, int32_t dsize);
180extern void flushinvalidatedcache_by_addr(uint8_t *addr, int32_t dsize);
181
182
183/*
184 * DMAステータス定義
185 */
186#define DMA_STATUS_BUSY 0x00000001 /* BUSY */
187#define DMA_STATUS_READY_HMEM0 0x00000002 /* DMA Mem0 Half process success */
188#define DMA_STATUS_READY_HMEM1 0x00000004 /* DMA Mem1 Half process success */
189#define DMA_STATUS_READY_MEM0 0x00000008 /* DMA Mem0 process success */
190#define DMA_STATUS_READY_ERROR 0x00000100 /* DMA Error end */
191
192/*
193 * DMAストリームID定義
194 */
195#define DMA1STM0_SID (0)
196#define DMA1STM1_SID (1)
197#define DMA1STM2_SID (2)
198#define DMA1STM3_SID (3)
199#define DMA1STM4_SID (4)
200#define DMA1STM5_SID (5)
201#define DMA1STM6_SID (6)
202#define DMA1STM7_SID (7)
203#define DMA2STM0_SID (8+0)
204#define DMA2STM1_SID (8+1)
205#define DMA2STM2_SID (8+2)
206#define DMA2STM3_SID (8+3)
207#define DMA2STM4_SID (8+4)
208#define DMA2STM5_SID (8+5)
209#define DMA2STM6_SID (8+6)
210#define DMA2STM7_SID (8+7)
211
212/*
213 * DMAエラー定義
214 */
215#define DMA_ERROR_NONE 0x00000000 /* No error */
216#define DMA_ERROR_TE 0x00000001 /* Transfer error */
217#define DMA_ERROR_FE 0x00000002 /* FIFO error */
218#define DMA_ERROR_DME 0x00000004 /* Direct Mode error */
219#define DMA_ERROR_TIMEOUT 0x00000020 /* Timeout error */
220
221/*
222 * DMAチャネル定義
223 */
224#define DMA_CHANNEL_0 0x00000000 /* DMA Channel 0 */
225#define DMA_CHANNEL_1 0x02000000 /* DMA Channel 1 */
226#define DMA_CHANNEL_2 0x04000000 /* DMA Channel 2 */
227#define DMA_CHANNEL_3 0x06000000 /* DMA Channel 3 */
228#define DMA_CHANNEL_4 0x08000000 /* DMA Channel 4 */
229#define DMA_CHANNEL_5 0x0A000000 /* DMA Channel 5 */
230#define DMA_CHANNEL_6 0x0C000000 /* DMA Channel 6 */
231#define DMA_CHANNEL_7 0x0E000000 /* DMA Channel 7 */
232#if defined(TOPPERS_STM32F767_NUCLEO144) || defined(TOPPERS_STM32F769_DISCOVERY)
233#define DMA_CHANNEL_8 0x10000000 /* DMA Channel 8 */
234#define DMA_CHANNEL_9 0x12000000 /* DMA Channel 9 */
235#define DMA_CHANNEL_10 0x14000000 /* DMA Channel 10*/
236#define DMA_CHANNEL_11 0x16000000 /* DMA Channel 11*/
237#define DMA_CHANNEL_12 0x18000000 /* DMA Channel 12*/
238#define DMA_CHANNEL_13 0x1A000000 /* DMA Channel 13*/
239#define DMA_CHANNEL_14 0x1C000000 /* DMA Channel 14*/
240#define DMA_CHANNEL_15 0x1E000000 /* DMA Channel 15*/
241#endif
242
243/*
244 * DMA転送方向定義
245 */
246#define DMA_PERIPH_TO_MEMORY 0x00000000 /* Peripheral to memory direction */
247#define DMA_MEMORY_TO_PERIPH DMA_SxCR_DIR_0 /* Memory to peripheral direction */
248#define DMA_MEMORY_TO_MEMORY DMA_SxCR_DIR_1 /* Memory to memory direction */
249
250/*
251 * DMAペリフェラル増加モード定義
252 */
253#define DMA_PINC_ENABLE DMA_SxCR_PINC /* Peripheral increment mode enable */
254#define DMA_PINC_DISABLE 0x00000000 /* Peripheral increment mode disable */
255
256/*
257 * DMAメモリ増加モード定義
258 */
259#define DMA_MINC_ENABLE DMA_SxCR_MINC /* Memory increment mode enable */
260#define DMA_MINC_DISABLE 0x00000000 /* Memory increment mode disable */
261
262/*
263 * DMAペリフェラル・データ・サイズ定義
264 */
265#define DMA_PDATAALIGN_BYTE 0x00000000 /* Peripheral data alignment: Byte */
266#define DMA_PDATAALIGN_HALFWORD DMA_SxCR_PSIZE_0 /* Peripheral data alignment: HalfWord */
267#define DMA_PDATAALIGN_WORD DMA_SxCR_PSIZE_1 /* Peripheral data alignment: Word */
268
269/*
270 * DMAメモリ・データ・サイズ定義
271 */
272#define DMA_MDATAALIGN_BYTE 0x00000000 /* Memory data alignment: Byte */
273#define DMA_MDATAALIGN_HALFWORD DMA_SxCR_MSIZE_0 /* Memory data alignment: HalfWord */
274#define DMA_MDATAALIGN_WORD DMA_SxCR_MSIZE_1 /* Memory data alignment: Word */
275
276/*
277 * DMAモード定義
278 */
279#define DMA_NORMAL 0x00000000 /* Normal mode */
280#define DMA_CIRCULAR DMA_SxCR_CIRC /* Circular mode */
281#define DMA_PFCTRL DMA_SxCR_PFCTRL /* Peripheral flow control mode */
282
283/*
284 * DMA優先度レベル定義
285 */
286#define DMA_PRIORITY_LOW 0x00000000 /* Priority level: Low */
287#define DMA_PRIORITY_MEDIUM DMA_SxCR_PL_0 /* Priority level: Medium */
288#define DMA_PRIORITY_HIGH DMA_SxCR_PL_1 /* Priority level: High */
289#define DMA_PRIORITY_VERY_HIGH DMA_SxCR_PL /* Priority level: Very High */
290
291/*
292 * DMA FIFOモード定義
293 */
294#define DMA_FIFOMODE_DISABLE 0x00000000 /* FIFO mode disable */
295#define DMA_FIFOMODE_ENABLE DMA_SxFCR_DMDIS /* FIFO mode enable */
296
297/*
298 * DMA FIFOスレッシュホールドレベル定義
299 */
300#define DMA_FIFO_THRESHOLD_1QUARTERFULL 0x00000000 /* FIFO threshold 1 quart full configuration */
301#define DMA_FIFO_THRESHOLD_HALFFULL DMA_SxFCR_FTH_0 /* FIFO threshold half full configuration */
302#define DMA_FIFO_THRESHOLD_3QUARTERSFULL DMA_SxFCR_FTH_1 /* FIFO threshold 3 quarts full configuration */
303#define DMA_FIFO_THRESHOLD_FULL DMA_SxFCR_FTH /* FIFO threshold full configuration */
304
305/*
306 * DMAメモリバースト定義
307 */
308#define DMA_MBURST_SINGLE 0x00000000
309#define DMA_MBURST_INC4 DMA_SxCR_MBURST_0
310#define DMA_MBURST_INC8 DMA_SxCR_MBURST_1
311#define DMA_MBURST_INC16 DMA_SxCR_MBURST
312
313/*
314 * DMAペリフェラルバースト定義
315 */
316#define DMA_PBURST_SINGLE 0x00000000
317#define DMA_PBURST_INC4 DMA_SxCR_PBURST_0
318#define DMA_PBURST_INC8 DMA_SxCR_PBURST_1
319#define DMA_PBURST_INC16 DMA_SxCR_PBURST
320
321/*
322 * DMA初期化構造体定義
323 */
324typedef struct
325{
326 uint32_t Channel; /* Specifies the channel used for the specified stream. */
327 uint32_t Direction; /* Specifies if the data will be transferred from memory to peripheral */
328 uint32_t PeriphInc; /* Specifies whether the Peripheral address register should be incremented or not. */
329 uint32_t MemInc; /* Specifies whether the memory address register should be incremented or not. */
330 uint32_t PeriphDataAlignment; /* Specifies the Peripheral data width. */
331 uint32_t MemDataAlignment; /* Specifies the Memory data width. */
332 uint32_t Mode; /* Specifies the operation mode of the DMAy Streamx. */
333 uint32_t Priority; /* Specifies the software priority for the DMAy Streamx. */
334 uint32_t FIFOMode; /* Specifies if the FIFO mode or Direct mode will be used for the specified stream. */
335 uint32_t FIFOThreshold; /* Specifies the FIFO threshold level. */
336 uint32_t MemBurst; /* Specifies the Burst transfer configuration for the memory transfers. */
337 uint32_t PeriphBurst; /* Specifies the Burst transfer configuration for the peripheral transfers. */
338}DMA_Init_t;
339
340/*
341 * DMAハンドラ構造体定義
342 */
343typedef struct __DMA_Handle_t DMA_Handle_t;
344struct __DMA_Handle_t
345{
346 uint32_t base;
347 DMA_Init_t Init; /* DMA communication parameters */
348 uint32_t sdid; /* stream dma id */
349 volatile uint32_t status; /* DMA status */
350 void (*xfercallback)(DMA_Handle_t * hdma); /* DMA transfer complete callback */
351 void (*xferhalfcallback)(DMA_Handle_t * hdma); /* DMA Half transfer complete callback */
352 void (*xferm1callback)(DMA_Handle_t * hdma); /* DMA transfer complete Memory1 callback */
353 void (*errorcallback)(DMA_Handle_t * hdma); /* DMA transfer error callback */
354 volatile uint32_t ErrorCode; /* DMA Error code */
355 void *localdata; /* DMA local data */
356};
357
358extern ER dma_init(DMA_Handle_t *hdma);
359extern ER dma_deinit(DMA_Handle_t *hdma);
360extern ER dma_start(DMA_Handle_t *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
361extern ER dma_end(DMA_Handle_t *hdma);
362extern void dma_inthandler(DMA_Handle_t *hdma);
363extern void stream_dma_isr(intptr_t exinf);
364
365
366/*
367 * DMAステータス定義
368 */
369#define DMA2D_STATUS_BUSY 0x00000001 /* BUSY */
370#define DMA2D_STATUS_TCOMP 0x00000002 /* DMA2D transfar process success */
371#define DMA2D_STATUS_CCOMP 0x00000004 /* DMA2D CLUT Transfer process success */
372#define DMA2D_STATUS_ERROR 0x00000100 /* DMA2D Error end */
373
374/*
375 * DMA2Dエラーコード定義
376 */
377#define DMA2D_ERROR_NONE 0x00000000 /* No error */
378#define DMA2D_ERROR_TE 0x00000001 /* Transfer error */
379#define DMA2D_ERROR_CE 0x00000002 /* Configuration error */
380#define DMA2D_ERROR_TIMEOUT 0x00000020 /* Timeout error */
381
382/*
383 * DMA2Dモード定義
384 */
385#define DMA2D_M2M 0x00000000 /* DMA2D memory to memory transfer mode */
386#define DMA2D_M2M_PFC 0x00010000 /* DMA2D memory to memory with pixel format conversion transfer mode */
387#define DMA2D_M2M_BLEND 0x00020000 /* DMA2D memory to memory with blending transfer mode */
388#define DMA2D_R2M 0x00030000 /* DMA2D register to memory transfer mode */
389
390/*
391 * DMA2Dカラーモード定義
392 */
393#define DMA2D_ARGB8888 0x00000000 /* ARGB8888 DMA2D color mode */
394#define DMA2D_RGB888 0x00000001 /* RGB888 DMA2D color mode */
395#define DMA2D_RGB565 0x00000002 /* RGB565 DMA2D color mode */
396#define DMA2D_ARGB1555 0x00000003 /* ARGB1555 DMA2D color mode */
397#define DMA2D_ARGB4444 0x00000004 /* ARGB4444 DMA2D color mode */
398
399/*
400 * DMA2D入力カラー定義
401 */
402#define CM_ARGB8888 0x00000000 /* ARGB8888 color mode */
403#define CM_RGB888 0x00000001 /* RGB888 color mode */
404#define CM_RGB565 0x00000002 /* RGB565 color mode */
405#define CM_ARGB1555 0x00000003 /* ARGB1555 color mode */
406#define CM_ARGB4444 0x00000004 /* ARGB4444 color mode */
407#define CM_L8 0x00000005 /* L8 color mode */
408#define CM_AL44 0x00000006 /* AL44 color mode */
409#define CM_AL88 0x00000007 /* AL88 color mode */
410#define CM_L4 0x00000008 /* L4 color mode */
411#define CM_A8 0x00000009 /* A8 color mode */
412#define CM_A4 0x0000000A /* A4 color mode */
413
414/*
415 * DMA2Dアルファモード定義
416 */
417#define DMA2D_NO_MODIF_ALPHA 0x00000000 /* No modification of the alpha channel value */
418#define DMA2D_REPLACE_ALPHA 0x00000001 /* Replace original alpha channel value by programmed alpha value */
419#define DMA2D_COMBINE_ALPHA 0x00000002 /* Replace original alpha channel value by programmed alpha value
420 with original alpha channel value */
421/*
422 * DMA2D CLUT CM定義
423 */
424#define DMA2D_CCM_ARGB8888 0x00000000 /* ARGB8888 DMA2D C-LUT color mode */
425#define DMA2D_CCM_RGB888 0x00000001 /* RGB888 DMA2D C-LUT color mode */
426
427#if defined(TOPPERS_STM32F767_NUCLEO144) || defined(TOPPERS_STM32F769_DISCOVERY)
428/*
429 * DMA2Dアルファインバート定義
430 */
431#define DMA2D_REGULAR_ALPHA 0x00000000 /* No modification of the alpha channel value */
432#define DMA2D_INVERTED_ALPHA DMA2D_OPFCCR_AI /* Invert the alpha channel value */
433
434/*
435 * DMA2D RBスワップ定義
436 */
437#define DMA2D_RB_REGULAR 0x00000000 /* Select regular mode (RGB or ARGB) */
438#define DMA2D_RB_SWAP DMA2D_OPFCCR_RBS/* Select swap mode (BGR or ABGR) */
439#endif
440
441/*
442 * DMA2Dレイヤーの数
443 */
444#define MAX_DMA2D_LAYER 2
445
446/*
447 * DMA2Dステート定義
448 */
449#define DMA2D_STATE_RESET 0 /* DMA2D not yet initialized or disabled */
450#define DMA2D_STATE_READY 1 /* Peripheral Initialized and ready for use */
451#define DMA2D_STATE_BUSY 2 /* an internal process is ongoing */
452#define DMA2D_STATE_TIMEOUT 3 /* Timeout state */
453#define DMA2D_STATE_ERROR 4 /* DMA2D state error */
454#define DMA2D_STATE_SUSPEND 5 /* DMA2D process is suspended */
455
456/*
457 * DMA2D入力構造体定義
458 */
459typedef struct
460{
461 uint32_t Mode; /* configures the DMA2D transfer mode. */
462 uint32_t ColorMode; /* configures the color format of the output image. */
463 uint32_t OutputOffset; /* Specifies the Offset value. */
464#if defined(TOPPERS_STM32F767_NUCLEO144) || defined(TOPPERS_STM32F769_DISCOVERY)
465 uint32_t AlphaInverted; /* Select regular or inverted alpha value for the output pixel format converter. */
466 uint32_t RedBlueSwap; /* Select regular mode (RGB or ARGB) or swap mode (BGR or ABGR) */
467#endif /* DMA2D_OPFCCR_RBS */
468} DMA2D_Init_t;
469
470/*
471 * DMA2Dレイヤー構造体定義
472 */
473typedef struct
474{
475 uint32_t InputOffset; /* configures the DMA2D foreground offset. */
476 uint32_t InputColorMode; /* configures the DMA2D foreground color mode . */
477 uint32_t AlphaMode; /* configures the DMA2D foreground alpha mode. */
478 uint32_t InputAlpha; /* Specifies the DMA2D foreground alpha value and color value in case of A8 or A4 color mode. */
479} DMA2D_LayerCfg_t;
480
481/*
482 * DMA2Dハンドラ構造体定義
483 */
484typedef struct __DMA2D_Handle_t DMA2D_Handle_t;
485struct __DMA2D_Handle_t
486{
487 uint32_t base;
488 DMA2D_Init_t Init; /* DMA2D communication parameters */
489 volatile uint32_t status; /* DMA2D status */
490 void (* xfercallback)(DMA2D_Handle_t * hdma2d); /* DMA2D transfer complete callback */
491 void (* errorcallback)(DMA2D_Handle_t * hdma2d); /* DMA2D transfer error callback */
492 DMA2D_LayerCfg_t LayerCfg[MAX_DMA2D_LAYER]; /* DMA2D Layers parameters */
493 uint32_t ErrorCode; /* DMA2D Error code */
494};
495
496
497#define INHNO_DMA2D IRQ_VECTOR_DMA2D
498#define INTNO_DMA2D IRQ_VECTOR_DMA2D
499
500#define INTPRI_DMA2D -7 /* 割込み優先度 */
501#define INTATR_DMA2D 0 /* 割込み属性 */
502
503extern ER dma2d_init(DMA2D_Handle_t *hdma2d);
504extern ER dma2d_start(DMA2D_Handle_t *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height);
505extern ER dma2d_waittransfar(DMA2D_Handle_t *hdma2d, uint32_t Timeout);
506extern ER dma2d_configlayer(DMA2D_Handle_t *hdma2d, uint32_t LayerIdx);
507extern void dma2d_inthandler(DMA2D_Handle_t *hdma);
508extern void dma2d_handler(void);
509
510
511/*
512 * RTCアラーム定義
513 */
514#define RTC_ALARM_A RTC_CR_ALRAE
515#define RTC_ALARM_B RTC_CR_ALRBE
516
517/*
518 * RTC日付、ウィークディ定義
519 */
520#define ALARMDAYSEL_DATE 0x00000000
521#define ALARMDAYSEL_WEEKDAY 0x40000000
522
523/*
524 * RTCマスク定義
525 */
526#define ALARMMASK_NONE 0x00000000
527#define ALARMMASK_DATESEL RTC_ALRMAR_MSK4
528#define ALARMMASK_HOURS RTC_ALRMAR_MSK3
529#define ALARMMASK_MINUTES RTC_ALRMAR_MSK2
530#define ALARMMASK_SECONDS RTC_ALRMAR_MSK1
531#define ALARMMASK_ALL (RTC_ALRMAR_MSK1 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK4)
532
533/*
534 * RTCサブセカンドアラームマッチ定義
535 */
536#define ALARMSSMASK_ALL 0x00000000 /* All Alarm SS fields are masked. */
537#define ALARMSSMASK_SS14_1 0x01000000 /* SS[0]がマッチでアラーム */
538#define ALARMSSMASK_SS14_2 0x02000000 /* SS[1:0]がマッチでアラーム */
539#define ALARMSSMASK_SS14_3 0x03000000 /* SS[2-0]がマッチでアラーム */
540#define ALARMSSMASK_SS14_4 0x04000000 /* SS[3-0]がマッチでアラーム */
541#define ALARMSSMASK_SS14_5 0x05000000 /* SS[4-0]がマッチでアラーム */
542#define ALARMSSMASK_SS14_6 0x06000000 /* SS[5-0]がマッチでアラーム */
543#define ALARMSSMASK_SS14_7 0x07000000 /* SS[6-0]がマッチでアラーム */
544#define ALARMSSMASK_SS14_8 0x08000000 /* SS[7-0]がマッチでアラーム */
545#define ALARMSSMASK_SS14_9 0x09000000 /* SS[8-0]がマッチでアラーム */
546#define ALARMSSMASK_SS14_10 0x0A000000 /* SS[9-0]がマッチでアラーム */
547#define ALARMSSMASK_SS14_11 0x0B000000 /* SS[10-0]がマッチでアラーム */
548#define ALARMSSMASK_SS14_12 0x0C000000 /* SS[11-0]がマッチでアラーム */
549#define ALARMSSMASK_SS14_13 0x0D000000 /* SS[12-0]がマッチでアラーム */
550#define ALARMSSMASK_SS14 0x0E000000 /* SS[13-0]がマッチでアラーム */
551#define ALARMSSMASK_NONE 0x0F000000 /* SS[14-0]がマッチでアラーム */
552
553#define RTC_ERROR_LSI 0x00000001
554#define RTC_ERROR_LSE 0x00000002
555#define RTC_ERROR_RTC 0x00000004
556
557#define INHNO_ALARM IRQ_VECTOR_RTC_ALARM
558#define INTNO_ALARM IRQ_VECTOR_RTC_ALARM
559
560#define INTPRI_ALARM -11 /* 割込み優先度 */
561#define INTATR_ALARM 0 /* 割込み属性 */
562
563#define INHNO_RTCWUP IRQ_VECTOR_RTC_WKUP /* 割込みハンドラ番号 */
564#define INTNO_RTCWUP IRQ_VECTOR_RTC_WKUP /* 割込み番号 */
565#define INTPRI_RTCWUP -8 /* 割込み優先度 */
566#define INTATR_RTCWUP TA_EDGE /* 割込み属性 */
567
568/*
569 * 日時設定用の構造体を定義
570 */
571struct tm2 {
572 int tm_sec; /* 秒 */
573 int tm_min; /* 分 */
574 int tm_hour; /* 時 */
575 int tm_mday; /* 月中の日 */
576 int tm_mon; /* 月 */
577 int tm_year; /* 年 */
578 int tm_wday; /* 曜日 */
579 int tm_yday; /* 年中の日 */
580 int tm_isdst;
581};
582
583/*
584 * RTCアラーム構造体
585 */
586typedef struct
587{
588 uint32_t alarm; /* アラーム選択 */
589 uint32_t alarmmask; /* アラームマスク設定 */
590 uint32_t subsecondmask; /* アラームサブセカンドマスク */
591 uint32_t dayselect; /* アラーム日付設定 */
592 uint32_t subsecond; /* アラームサブセカンド */
593 void (*callback)(void); /* アラームコールバック */
594}RTC_Alarm_t;
595
596/*
597 * RTC-WAKEUP構造体
598 */
599typedef struct
600{
601 uint8_t wakeuptimerPrescaler; /* WAKEUP TIMERプリスケーラ */
602 uint8_t asynchPrescaler; /* 非同期プリスケーラ */
603 uint16_t synchPrescaler; /* 非同期プリスケーラ */
604}RTC_Wakeup_t;
605
606
607extern uint32_t rtcerrorcode;
608
609extern void rtc_init(intptr_t exinf);
610extern ER rtc_set_time(struct tm2 *pt);
611extern ER rtc_get_time(struct tm2 *pt);
612extern ER rtc_setalarm(RTC_Alarm_t *parm, struct tm2 *ptm);
613extern ER rtc_stopalarm(uint32_t Alarm);
614extern ER rtc_getalarm(RTC_Alarm_t *parm, struct tm2 *ptm, uint32_t Alarm);
615extern ER rtc_wakeup_init(RTC_Wakeup_t *parm, void (*func)(void));
616extern ER rtc_setup_wakeuptime(uint32_t time);
617extern uint32_t rtc_get_ssr(void);
618extern void rtc_handler(void);
619extern void wakeup_handler(void);
620extern void rtc_info_init(intptr_t exinf);
621
622
623/*
624 * WINDOW-WDOGドライバ
625 */
626#define WDOG1_PORTID 1
627#define NUM_WDOGPORT 1
628
629typedef struct __WDOG_Init_t
630{
631 uint32_t Window; /* WDOG Window設定 0x40-0x7F */
632 uint32_t Counter; /* WDOG ダウンカウンタ設定 0x40-0x7F 0x7F */
633 uint32_t MCounter; /* WDOG More Counter */
634} WDOG_Init_t;
635
636extern ER wdog_init(ID portid, WDOG_Init_t *hwini);
637extern ER wdog_deinit(ID portid);
638extern ER wdog_reset(ID portod);
639extern void wdog_handler(void);
640
641
642/*
643 * USBのローカル設定
644 */
645#define ENABLE_FS_BASE1 (TADR_RCC_BASE+TOFF_RCC_AHB1ENR)
646#define ENABLE_FS_VAL1 RCC_AHB1ENR_GPIOAEN
647#define TADR_FS_G1_BASE TADR_GPIOA_BASE
648#define FS_DM_PINNO 11
649#define FS_DP_PINNO 12
650#if defined(TOPPERS_STM32F7_DISCOVERY)
651#define ENABLE_FS_BASE2 (TADR_RCC_BASE+TOFF_RCC_AHB1ENR)
652#define ENABLE_FS_VAL2 RCC_AHB1ENR_GPIODEN
653#define TADR_FS_G2_BASE TADR_GPIOD_BASE
654#define FS_ID_PINNO 10
655#define FS_POWERSW_PINO 5
656#define FS_EVBUS_PINNO FS_POWERSW_PINO
657#elif defined(TOPPERS_STM32F723_DISCOVERY)
658#define ENABLE_FS_BASE2 (TADR_RCC_BASE+TOFF_RCC_AHB1ENR)
659#define ENABLE_FS_VAL2 RCC_AHB1ENR_GPIOGEN
660#define TADR_FS_G2_BASE TADR_GPIOG_BASE
661#define FS_G2_PORT_TYPE GPIO_OTYPE_OD
662#define FS_POWERSW_PINO 8
663#else
664#define ENABLE_FS_BASE2 (TADR_RCC_BASE+TOFF_RCC_AHB1ENR)
665#define ENABLE_FS_VAL2 RCC_AHB1ENR_GPIOGEN
666#define TADR_FS_G2_BASE TADR_GPIOG_BASE
667#define FS_ID_PINNO 10
668#define FS_VBUS_PINNO 9
669#define FS_POWERSW_PINO 6
670#if !defined(TOPPERS_STM32F769_DISCOVERY)
671#define FS_EVBUS_PINNO FS_POWERSW_PINO
672#endif
673#endif
674
675#if defined(TOPPERS_STM32F769_DISCOVERY)
676#define ENABLE_HS_VAL1 RCC_AHB1ENR_GPIOIEN
677#define TADR_HS_G1_BASE TADR_GPIOI_BASE
678#define HS_DIR_PINNNO 11
679#else
680#define ENABLE_HS_VAL1 RCC_AHB1ENR_GPIOCEN
681#define TADR_HS_G1_BASE TADR_GPIOC_BASE
682#define HS_DIR_PINNNO 2
683#endif
684
685#define ENABLE_HS_BASE (TADR_RCC_BASE+TOFF_RCC_AHB1ENR)
686#define ENABLE_HS_VAL2 RCC_AHB1ENR_GPIOBEN
687#define ENABLE_HS_VAL3 RCC_AHB1ENR_GPIOHEN
688#define ENABLE_HS_VAL4 RCC_AHB1ENR_GPIOAEN
689#define ENABLE_HS_VAL5 RCC_AHB1ENR_GPIOCEN
690
691#define TOFF_RCC_USBFS TOFF_RCC_AHB2ENR
692#define RCC_USBFSEN RCC_AHB2ENR_OTGFSEN
693#define TOFF_RCC_USBHS TOFF_RCC_AHB1ENR
694#define RCC_USBHSEN RCC_AHB1ENR_OTGHSEN
695#define RCC_USBHSUPEN RCC_AHB1ENR_OTGHSULPIEN
696#define TOFF_RCC_SYSFG TOFF_RCC_APB2ENR
697#define RCC_SYSGFGEN RCC_APB2ENR_SYSCFGEN
698
699#define EXTI_IMR_BASE (TADR_EXTI_BASE+TOFF_EXTI_IMR)
700#define EXTI_PR_BASE (TADR_EXTI_BASE+TOFF_EXTI_PR)
701
702/*
703 * EMACのローカル設定
704 */
705#if defined(TOPPERS_STM32F7_DISCOVERY)
706#define RMII_MII_TXD1_PORT TADR_GPIOG_BASE
707#define RMII_MII_TXD1_PIN 14
708#else
709#define RMII_MII_TXD1_CLOCK RCC_AHB1ENR_GPIOBEN
710#endif
711
712/*
713 * ポートのLED接続ビット
714 */
715#define LED01 (1<<0)
716#define LED02 (1<<1)
717#define LED03 (1<<2)
718#define LED04 (1<<3)
719
720#define LED_MASK (LED01 | LED02 | LED03 | LED04)
721
722/*
723 * LEDとスイッチの状態マクロ
724 */
725#define ON 1 /* LEDやスイッチON状態 */
726#define OFF 0 /* LEDやスイッチOFF状態 */
727
728/*
729 * DIPSW設定
730 */
731#define DSW1 0x01
732#define DSW2 0x02
733#define DSW3 0x04
734#define DSW4 0x08
735
736/*
737 * LED接続ポート初期化
738 */
739extern void led_init(intptr_t exinf);
740
741/*
742 * LED接続ポート読み出し
743 */
744uint_t led_in(void);
745
746/*
747 * LED接続ポート書き込み
748 */
749void led_out(unsigned int led_data);
750
751/*
752 * LEDとスイッチの個別設定・読み込み関数群
753 */
754extern void set_led_state(unsigned int led, unsigned char state);
755
756#define NUM_EXTI9_FUNC 5
757#define EXTI9_BASENO 5
758#define INHNO_EXTI9 IRQ_VECTOR_EXTI9_5 /* 割込みハンドラ番号 */
759#define INTNO_EXTI9 IRQ_VECTOR_EXTI9_5 /* 割込み番号 */
760#define INTPRI_EXTI9 -4 /* 割込み優先度 */
761#define INTATR_EXTI9 0 /* 割込み属性 */
762
763#define NUM_EXTI15_FUNC 6
764#define EXTI15_BASENO 10
765#define INHNO_EXTI15 IRQ_VECTOR_EXTI15_10 /* 割込みハンドラ番号 */
766#define INTNO_EXTI15 IRQ_VECTOR_EXTI15_10 /* 割込み番号 */
767#define INTPRI_EXTI15 -4 /* 割込み優先度 */
768#define INTATR_EXTI15 0 /* 割込み属性 */
769
770#if defined(TOPPERS_STM32F769_DISCOVERY) || defined(TOPPERS_STM32F723_DISCOVERY)
771#define INHNO_SW1 IRQ_VECTOR_EXTI0 /* 割込みハンドラ番号 */
772#define INTNO_SW1 IRQ_VECTOR_EXTI0 /* 割込み番号 */
773#define INTPRI_SW1 -4 /* 割込み優先度 */
774#define INTATR_SW1 TA_EDGE /* 割込み属性 */
775#define NUM_EXTI_FUNC 1
776#define EXTI_BASENO 0
777#define exti_handler exti0_handler
778#else
779#define NUM_EXTI_FUNC 6
780#define EXTI_BASENO 10
781#endif
782
783extern void (*exti_func[16])(void);
784
785/*
786 * PSW接続ビット
787 */
788#define PSW1 0x00000001
789#define PSW_MASK (PSW1)
790#define PSW_CHK_INTERVAL 10
791
792
793/*
794 * PUSHスイッチ接続ポート初期化
795 */
796extern void switch_push_init(intptr_t exinf);
797
798/*
799 * PUSHスイッチコールバック関数設定
800 */
801extern void setup_sw_func(intptr_t exinf);
802
803/*
804 * EXTI割込みハンドラ
805 */
806extern void exti0_handler(void);
807extern void exti9_handler(void);
808extern void exti15_handler(void);
809
810/*
811 * DIPSWの取出し
812 */
813uint_t switch_dip_sense(void);
814
815
816extern void device_info_init(intptr_t exinf);
817
818extern uint_t dipsw_value;
819
820#ifdef __cplusplus
821}
822#endif
823
824#endif
825
Note: See TracBrowser for help on using the repository browser.