source: azure_iot_hub_f767zi/trunk/asp_baseplatform/pdic/stm32f7xx/dfsdm.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: 17.9 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-2017 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 *
43 * STM32F7xx DFSDMデバイスドライバの外部宣言
44 *
45 */
46
47#ifndef _DFSDM_H_
48#define _DFSDM_H_
49
50#ifdef __cplusplus
51 extern "C" {
52#endif
53
54/*
55 * DFSDM CHANNEL状態定義
56 */
57#define DFSDM_CHANNEL_STATE_RESET 0x00000000 /* DFSDM CHANNELリセット状態 */
58#define DFSDM_CHANNEL_STATE_READY 0x00000001 /* DFSDM CHANNELレディ状態 */
59#define DFSDM_CHANNEL_STATE_ERROR 0x00080000 /* DFSDM CHANNELエラー状態 */
60
61/*
62 * DFSDM CHANNEL初期化定義
63 */
64typedef struct
65{
66 uint32_t OutClockActivation; /* アウトプットクロック有効無効 */
67 uint32_t OutClockSelection; /* アウトプットクロック選択 */
68 uint32_t OutClockDivider; /* アウトプットクロックデバイダー */
69 uint32_t InputMultiplexer; /* 入力:外部シリアルまたは内部レジスタ */
70 uint32_t InputDataPacking; /* 入力:データピッキング */
71 uint32_t InputPins; /* 入力:ピン */
72 uint32_t SerialType; /* シリアル種別:SPI or Manchester modes. */
73 uint32_t SerialSpiClock; /* SPIクロック選択:(external or internal with different sampling point) */
74 uint32_t AwdFilterOrder; /* アナログウオッチドッグ シンクフィルター順序 */
75 uint32_t AwdOversampling; /* アナログウオッチドッグ oversampliオーバーサンプリング RATIO */
76 int32_t Offset; /* DFSDMチャネルオフセット */
77 uint32_t RightBitShift; /* DFSDMチャネル右ビットシフト */
78}DFSDM_Channel_Init_t;
79
80/*
81 * DFSDM CHANNELハンドラ定義
82 */
83typedef struct DFSDM_Channel_struct DFSDM_Channel_Handle_t;
84struct DFSDM_Channel_struct
85{
86 uint32_t base; /* DFSDMチャネルベースアドレス */
87 DFSDM_Channel_Init_t Init; /* DFSDM初期化データ */
88 void (*ckabcallback)(DFSDM_Channel_Handle_t * hdfsc); /* Channel Ckabコールバック関数 */
89 void (*scdcallback)(DFSDM_Channel_Handle_t * hdfsc); /* Channel Scdコールバック関数 */
90 volatile uint32_t state; /* DFSDMチャネル状態 */
91};
92
93/*
94 * DFSDMフィルター状態定義
95 */
96#define DFSDM_FILTER_STATE_RESET 0x00000000 /* DFSDMフィルターリセット状態 */
97#define DFSDM_FILTER_STATE_READY 0x00000001 /* DFSDMフィルターレディ状態 */
98#define DFSDM_FILTER_STATE_REG 0x00000002 /* DFSDMフィルターレギュラー変換状態 */
99#define DFSDM_FILTER_STATE_INJ 0x00000003 /* DFSDMフィルターインジェクト変換状態 */
100#define DFSDM_FILTER_STATE_REG_INJ 0x00000004 /* DFSDMフィルターレギュラー・インジェクト変換状態 */
101#define DFSDM_FILTER_STATE_ERROR 0x00080000 /* DFSDMフィルターエラー状態 */
102
103/*
104 * DFSDMフィルターエラー定義e
105 */
106#define DFSDM_FILTER_ERROR_NONE 0x00000000 /* エラーなし */
107#define DFSDM_FILTER_ERROR_REGULAR_OVERRUN 0x00000001 /* レギュラー変換オーバランエラー */
108#define DFSDM_FILTER_ERROR_INJECTED_OVERRUN 0x00000002 /* インジェクト変換オーバーランエラー */
109#define DFSDM_FILTER_ERROR_DMA 0x00000003 /* DMAエラー */
110
111/*
112 * DFSDMフィルター初期化定義
113 */
114typedef struct
115{
116 uint32_t RegTrigger; /* レギュラー変換:software or synchronous. */
117 uint32_t RegFastMode; /* レギュラー変換:fast mode Enable/disable fast mode */
118 uint32_t RegDmaMode; /* レギュラー変換:DMA Enable/disable */
119 uint32_t InjTrigger; /* インジェクト変換:Trigger: software, external or synchronous. */
120 uint32_t InjScanMode; /* インジェクト変換:scanning mode Enable/disable */
121 uint32_t InjDmaMode; /* インジェクト変換:DMA Enable/disable */
122 uint32_t InjExtTrigger; /* インジェクト変換:External trigger */
123 uint32_t InjExtTriggerEdge; /* インジェクト変換:External trigger edge: rising, falling or both. */
124 uint32_t FilterSincOrder; /* Sinc filter order. */
125 uint32_t FilterOversampling; /* Filter oversampling ratio. */
126 uint32_t FilterIntOversampling; /* Integrator oversampling ratio. */
127}DFSDM_Filter_Init_t;
128
129/*
130 * DFSDMフィルターハンドラ定義
131 */
132typedef struct DFSDM_Filter_struct DFSDM_Filter_Handle_t;
133struct DFSDM_Filter_struct
134{
135 uint32_t base; /* DFSDMフィルターベースアドレス */
136 DFSDM_Filter_Init_t Init; /* DFSDMフィルター初期化データ */
137 DMA_Handle_t *hdmaReg; /* レギュラー変換用DMAハンドラへのポインタ */
138 DMA_Handle_t *hdmaInj; /* インジェクト変換用DMAハンドラへのポインタ */
139 uint32_t RegularContMode; /* レギュラー変換:continuous mode */
140 uint32_t InjectedChannelsNbr; /* インジェクト変換:Number of channels */
141 uint32_t InjConvRemaining; /* インジェクト変換:remaining */
142 void (*regconvcallback)(DFSDM_Filter_Handle_t * hdfsf); /* RegConvコールバック関数 */
143 void (*regconvhalfcallback)(DFSDM_Filter_Handle_t * hdfsf); /* RegConv halfコールバック関数 */
144 void (*injconvcallback)(DFSDM_Filter_Handle_t * hdfsf); /* InjConvコールバック関数 */
145 void (*injconvhalfcallback)(DFSDM_Filter_Handle_t * hdfsf); /* InjConv halfコールバック関数 */
146 void (*awdconvcallback)(DFSDM_Filter_Handle_t * hdfsf); /* Analog Wdコールバック関数 */
147 void (*errorcallback)(DFSDM_Filter_Handle_t * hdfsf); /* エラーコールバック関数 */
148 volatile uint32_t state; /* DFSDMフィルター状態 */
149 volatile uint32_t errorcode; /* DFSDMフィルターエラー */
150};
151
152/*
153 * DFSDMフィルター analog watchdog parameters定義
154 */
155typedef struct
156{
157 uint32_t DataSource; /* データソース:digital filter or from channel watchdog filter. */
158 uint32_t Channel; /* チャネル選択. */
159 int32_t HighThreshold; /* ハイスレッド設定 */
160 int32_t LowThreshold; /* ロースレッド設定 */
161 uint32_t HighBreakSignal; /* ハイスレッド・ブレークシグナル */
162 uint32_t LowBreakSignal; /* ロースレッド・ブレークシグナル */
163} DFSDM_Filter_AwdParamTypeDef;
164
165
166/*
167 * DFSDMイネーブル・ディーブル定義
168 */
169#define DFSDM_DISABLE 0x00000000
170#define DFSDM_ENABLE 0x00000001
171#define DFSDM_MASK (~DFSDM_ENABLE)
172
173/*
174 * DFSDMチャネル OutClockSelection定義
175 */
176#define DFSDM_CHANNEL_OUTPUT_CLOCK_SYSTEM 0x00000000 /* ソース:ouput clock is system clock */
177#define DFSDM_CHANNEL_OUTPUT_CLOCK_AUDIO DFSDM_CHCFGR1_CKOUTSRC /* ソース:ouput clock is audio clock */
178
179/*
180 * DFSDMチャネル InputMultiplexer定義
181 */
182#define DFSDM_CHANNEL_EXTERNAL_INPUTS 0x00000000 /* 外部インプット */
183#define DFSDM_CHANNEL_INTERNAL_REGISTER DFSDM_CHCFGR1_DATMPX_1 /* 内部レジスタ */
184
185/*
186 * DFSDMチャネル InputDataPacking定義
187 */
188#define DFSDM_CHANNEL_STANDARD_MODE 0x00000000 /* Standard data packing mode */
189#define DFSDM_CHANNEL_INTERLEAVED_MODE DFSDM_CHCFGR1_DATPACK_0 /* Interleaved data packing mode */
190#define DFSDM_CHANNEL_DUAL_MODE DFSDM_CHCFGR1_DATPACK_1 /* Dual data packing mode */
191
192/*
193 * DFSDMチャネル InputPins定義
194 */
195#define DFSDM_CHANNEL_SAME_CHANNEL_PINS 0x00000000 /* インプットピン:pins on same channel */
196#define DFSDM_CHANNEL_FOLLOWING_CHANNEL_PINS DFSDM_CHCFGR1_CHINSEL /* インプットピン:following channel */
197
198/*
199 * DFSDMチャネル SerialType定義
200 */
201#define DFSDM_CHANNEL_SPI_RISING 0x00000000 /* SPI with rising edge */
202#define DFSDM_CHANNEL_SPI_FALLING DFSDM_CHCFGR1_SITP_0 /* SPI with falling edge */
203#define DFSDM_CHANNEL_MANCHESTER_RISING DFSDM_CHCFGR1_SITP_1 /* Manchester with rising edge */
204#define DFSDM_CHANNEL_MANCHESTER_FALLING DFSDM_CHCFGR1_SITP /* Manchester with falling edge */
205
206/*
207 * DFSDMチャネル SerialSpi clock selection定義
208 */
209#define DFSDM_CHANNEL_SPI_CLOCK_EXTERNAL 0x00000000 /* 外部SPIクロック */
210#define DFSDM_CHANNEL_SPI_CLOCK_INTERNAL DFSDM_CHCFGR1_SPICKSEL_0 /* 内部SPIクロック */
211#define DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_FALLING DFSDM_CHCFGR1_SPICKSEL_1 /* 内部SPIクロック divided by 2, falling edge */
212#define DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_RISING DFSDM_CHCFGR1_SPICKSEL /* 内部SPIクロック divided by 2, rising edge */
213
214/*
215 * DFSDMチャネル analog watchdog filter order定義
216 */
217#define DFSDM_CHANNEL_FASTSINC_ORDER 0x00000000 /* FastSinc filter type */
218#define DFSDM_CHANNEL_SINC1_ORDER DFSDM_CHAWSCDR_AWFORD_0 /* Sinc 1 filter type */
219#define DFSDM_CHANNEL_SINC2_ORDER DFSDM_CHAWSCDR_AWFORD_1 /* Sinc 2 filter type */
220#define DFSDM_CHANNEL_SINC3_ORDER DFSDM_CHAWSCDR_AWFORD /* Sinc 3 filter type */
221
222
223/*
224 * DFSDMフィルター Regular/Injected conversion trigger定義
225 */
226#define DFSDM_FILTER_SW_TRIGGER 0x00000000 /* Software trigger */
227#define DFSDM_FILTER_SYNC_TRIGGER 0x00000001 /* Synchronous with DFSDM_FLT0 */
228#define DFSDM_FILTER_EXT_TRIGGER 0x00000002 /* External trigger (only for injected conversion) */
229
230/*
231 * DFSDMフィルター external trigger定義(DFSDM filter 0, 1, 2 and 3)
232 */
233#define DFSDM_FILTER_EXT_TRIG_TIM1_TRGO 0x00000000
234#define DFSDM_FILTER_EXT_TRIG_TIM1_TRGO2 DFSDM_FLTCR1_JEXTSEL_0
235#define DFSDM_FILTER_EXT_TRIG_TIM8_TRGO DFSDM_FLTCR1_JEXTSEL_1
236#define DFSDM_FILTER_EXT_TRIG_TIM8_TRGO2 (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_1)
237#define DFSDM_FILTER_EXT_TRIG_TIM3_TRGO DFSDM_FLTCR1_JEXTSEL_2
238#define DFSDM_FILTER_EXT_TRIG_TIM4_TRGO (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_2)
239#define DFSDM_FILTER_EXT_TRIG_TIM10_OC1 (DFSDM_FLTCR1_JEXTSEL_1 | DFSDM_FLTCR1_JEXTSEL_2)
240#define DFSDM_FILTER_EXT_TRIG_TIM6_TRGO (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_1 | DFSDM_FLTCR1_JEXTSEL_2)
241#define DFSDM_FILTER_EXT_TRIG_TIM7_TRGO DFSDM_FLTCR1_JEXTSEL_3
242#define DFSDM_FILTER_EXT_TRIG_EXTI11 (DFSDM_FLTCR1_JEXTSEL_3 | DFSDM_FLTCR1_JEXTSEL_4)
243#define DFSDM_FILTER_EXT_TRIG_EXTI15 (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_3 | DFSDM_FLTCR1_JEXTSEL_4) /* For DFSDM filter 0, 1, 2 and 3 */
244#define DFSDM_FILTER_EXT_TRIG_LPTIM1_OUT (DFSDM_FLTCR1_JEXTSEL_1 | DFSDM_FLTCR1_JEXTSEL_3 | DFSDM_FLTCR1_JEXTSEL_4)
245
246/*
247 * DFSDMフィルター external trigger edge定義
248 */
249#define DFSDM_FILTER_EXT_TRIG_RISING_EDGE DFSDM_FLTCR1_JEXTEN_0 /* 外部 立上がりエッジ */
250#define DFSDM_FILTER_EXT_TRIG_FALLING_EDGE DFSDM_FLTCR1_JEXTEN_1 /* 外部 立下りエッジ */
251#define DFSDM_FILTER_EXT_TRIG_BOTH_EDGES DFSDM_FLTCR1_JEXTEN /* 外部 両エッジ */
252
253/*
254 * DFSDMフィルター sinc order定義
255 */
256#define DFSDM_FILTER_FASTSINC_ORDER 0x00000000 /* FastSinc filter type */
257#define DFSDM_FILTER_SINC1_ORDER DFSDM_FLTFCR_FORD_0 /* Sinc 1 filter type */
258#define DFSDM_FILTER_SINC2_ORDER DFSDM_FLTFCR_FORD_1 /* Sinc 2 filter type */
259#define DFSDM_FILTER_SINC3_ORDER (DFSDM_FLTFCR_FORD_0 | DFSDM_FLTFCR_FORD_1) /* Sinc 3 filter type */
260#define DFSDM_FILTER_SINC4_ORDER DFSDM_FLTFCR_FORD_2 /* Sinc 4 filter type */
261#define DFSDM_FILTER_SINC5_ORDER (DFSDM_FLTFCR_FORD_0 | DFSDM_FLTFCR_FORD_2) /* Sinc 5 filter type */
262
263/*
264 * DFSDMフィルター AwdDataSource DataSource定義
265 */
266#define DFSDM_FILTER_AWD_FILTER_DATA 0x00000000 /* デジタルフィルターから入力 */
267#define DFSDM_FILTER_AWD_CHANNEL_DATA DFSDM_FLTCR1_AWFSEL /* アナログウオッチドッグチャネルから入力 */
268
269/*
270 * DFSDMチャネル定義
271 */
272#define DFSDM_CHANNEL_0 0x00000001
273#define DFSDM_CHANNEL_1 0x00010002
274#define DFSDM_CHANNEL_2 0x00020004
275#define DFSDM_CHANNEL_3 0x00030008
276#define DFSDM_CHANNEL_4 0x00040010
277#define DFSDM_CHANNEL_5 0x00050020
278#define DFSDM_CHANNEL_6 0x00060040
279#define DFSDM_CHANNEL_7 0x00070080
280
281/*
282 * DFSDMフィルター Continuous Mode定義
283 */
284#define DFSDM_CONTINUOUS_CONV_OFF 0x00000000 /* 変換を継続しない */
285#define DFSDM_CONTINUOUS_CONV_ON 0x00000001 /* 変換を継続する */
286
287/*
288 * DFSDMフィルター AwdThreshold定義
289 */
290#define DFSDM_AWD_HIGH_THRESHOLD 0x00000000 /* アナログウオッチドッグ ハイスレシュホールド */
291#define DFSDM_AWD_LOW_THRESHOLD 0x00000001 /* アナログウオッチドッグ ロースレシュホールド */
292
293
294extern void dfsdm_clockconfig(ID port, uint32_t AudioFreq);
295extern ER dfsdm_channel_init(DFSDM_Channel_Handle_t *hdfsc);
296extern ER dfsdm_channel_deinit(DFSDM_Channel_Handle_t *hdfsc);
297
298extern ER dfsdm_channelCkabStart(DFSDM_Channel_Handle_t *hdfsc);
299extern ER dfsdm_channelCkabStop(DFSDM_Channel_Handle_t *hdfsc);
300extern ER dfsdm_channelScdStart(DFSDM_Channel_Handle_t *hdfsc, uint32_t Threshold, uint32_t BreakSignal);
301extern ER dfsdm_channelScdStop(DFSDM_Channel_Handle_t *hdfsc);
302extern int16_t dfsdm_channelGetAwdValue(DFSDM_Channel_Handle_t *hdfsc);
303extern ER dfsdm_channelModifyOffset(DFSDM_Channel_Handle_t *hdfsc, int32_t Offset);
304
305
306extern ER dfsdm_filter_init(DFSDM_Filter_Handle_t *hdfsf);
307extern ER dfsdm_filter_deinit(DFSDM_Filter_Handle_t *hdfsf);
308extern ER dfsdm_filter_config_reg(DFSDM_Filter_Handle_t *hdfsf, uint32_t Channel, uint32_t ContinuousMode);
309extern ER dfsdm_filter_config_inj(DFSDM_Filter_Handle_t *hdfsf, uint32_t Channel);
310
311extern ER dfsdm_filterRegularStart(DFSDM_Filter_Handle_t *hdfsf, int32_t *pData, uint32_t Length);
312extern ER dfsdm_filterRegularMsbStart(DFSDM_Filter_Handle_t *hdfsf, int16_t *pData, uint32_t Length);
313extern ER dfsdm_filterRegularStop(DFSDM_Filter_Handle_t *hdfsf);
314extern ER dfsdm_filterInjectedStart(DFSDM_Filter_Handle_t *hdfsf, int32_t *pData, uint32_t Length);
315extern ER dfsdm_filterInjectedMsbStart(DFSDM_Filter_Handle_t *hdfsf, int16_t *pData, uint32_t Length);
316extern ER dfsdm_filterInjectedStop(DFSDM_Filter_Handle_t *hdfsf);
317extern ER dfsdm_filterAwdStart(DFSDM_Filter_Handle_t *hdfsf, DFSDM_Filter_AwdParamTypeDef* awdParam);
318extern ER dfsdm_filterAwdStop(DFSDM_Filter_Handle_t *hdfsf);
319extern ER dfsdm_filterExdStart(DFSDM_Filter_Handle_t *hdfsf, uint32_t Channel);
320extern ER dfsdm_filterExdStop(DFSDM_Filter_Handle_t *hdfsf);
321
322extern int32_t dfsdm_filterGetRegularValue(DFSDM_Filter_Handle_t *hdfsf, uint32_t* Channel);
323extern int32_t dfsdm_filterGetInjectedValue(DFSDM_Filter_Handle_t *hdfsf, uint32_t* Channel);
324extern int32_t dfsdm_filterGetExdMaxValue(DFSDM_Filter_Handle_t *hdfsf, uint32_t* Channel);
325extern int32_t dfsdm_filterGetExdMinValue(DFSDM_Filter_Handle_t *hdfsf, uint32_t* Channel);
326extern uint32_t dfsdm_filterGetConvTimeValue(DFSDM_Filter_Handle_t *hdfsf);
327
328extern void dfsdm_irqhandler(DFSDM_Filter_Handle_t *hdfsf);
329
330
331#ifdef __cplusplus
332}
333#endif
334
335#endif /* _DFSDM_H_ */
336
Note: See TracBrowser for help on using the repository browser.