1 /*********************************************************************************************************//**
2 * @file ht32f5xxxx_midi.c
3 * @version $Rev:: 6684 $
4 * @date $Date:: 2023-01-18 #$
5 * @brief This file provides all the MIDI firmware functions.
6 *************************************************************************************************************
7 * @attention
8 *
9 * Firmware Disclaimer Information
10 *
11 * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the
12 * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the
13 * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and
14 * other intellectual property laws.
15 *
16 * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the
17 * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties
18 * other than HOLTEK and the customer.
19 *
20 * 3. The program technical documentation, including the code, is provided "as is" and for customer reference
21 * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including
22 * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including
23 * the warranties of merchantability, satisfactory quality and fitness for a particular purpose.
24 *
25 * <h2><center>Copyright (C) Holtek Semiconductor Inc. All rights reserved</center></h2>
26 ************************************************************************************************************/
27
28 /* Includes ------------------------------------------------------------------------------------------------*/
29 #include "ht32f5xxxx_midi.h"
30
31 /** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver
32 * @{
33 */
34
35 /** @defgroup MIDI MIDI
36 * @brief MIDI driver modules
37 * @{
38 */
39
40
41 /* Private constants ---------------------------------------------------------------------------------------*/
42 /** @defgroup MIDI_Private_Define MIDI private definitions
43 * @{
44 */
45 /* MIDI TRIG ST Mask */
46 #define TRIG_ST_ENABLE (u32)0x00000400
47 #define TRIG_ST_DISABLE (u32)0xFFFFFBFF
48
49 /* MIDI TRIG VM Mask */
50 #define TRIG_VM_ENABLE (u32)0x00000200
51 #define TRIG_VM_DISABLE (u32)0xFFFFFDFF
52
53 /* MIDI TRIG FR Mask */
54 #define TRIG_FR_ENABLE (u32)0x00000100
55 #define TRIG_FR_DISABLE (u32)0xFFFFFEFF
56
57 /* MIDI CHAN CHx Mask */
58 #define MIDI_CHAN_CHx_MASK (u32)0x0000001F
59
60 /* MIDI FREQ BL Mask */
61 #define MIDI_FREQ_BL_MASK (u32)0x0000F000
62
63 /* MIDI FREQ FR Mask */
64 #define MIDI_FREQ_FR_MASK (u32)0x00000FFF
65
66 /* MIDI VOL AR Mask */
67 #define MIDI_VOL_AR_MASK (u32)0x80000000
68
69 /* MIDI VOL ENV Mask */
70 #define MIDI_VOL_ENV_MASK (u32)0x60000000
71
72 /* MIDI VOL VL Mask */
73 #define MIDI_VOL_VL_MASK (u32)0x03FF0000
74
75 /* MIDI VOL VR Mask */
76 #define MIDI_VOL_VR_MASK (u32)0x000003FF
77
78 /* MIDI RENUM WBS Mask */
79 #define MIDI_RENUM_WBS_MASK (u32)0x00030000
80
81 /* MIDI RENUM RE Mask */
82 #define MIDI_RENUM_RE_MASK (u32)0x00007FFF
83
84 /* MIDI MCUCH0 CH0B Mask */
85 #define MIDI_MCUCH0_CH0B_MASK (u32)0xFFFF0000
86
87 /* MIDI MCUCH0 CH0A Mask */
88 #define MIDI_MCUCH0_CH0A_MASK (u32)0x0000FFFF
89
90 /* MIDI MCUCH1 CH1B Mask */
91 #define MIDI_MCUCH1_CH1B_MASK (u32)0xFFFF0000
92
93 /* MIDI MCUCH1 CH1A Mask */
94 #define MIDI_MCUCH1_CH1A_MASK (u32)0x0000FFFF
95
96 /* MIDI MCUCH2 CH2B Mask */
97 #define MIDI_MCUCH2_CH2B_MASK (u32)0xFFFF0000
98
99 /* MIDI MCUCH2 CH2A Mask */
100 #define MIDI_MCUCH2_CH2A_MASK (u32)0x0000FFFF
101
102 /* MIDI MCUCH3 CH3B Mask */
103 #define MIDI_MCUCH3_CH3B_MASK (u32)0xFFFF0000
104
105 /* MIDI MCUCH3 CH3A Mask */
106 #define MIDI_MCUCH3_CH3A_MASK (u32)0x0000FFFF
107
108 /* MIDI CTRL MCUCHEN3 Mask */
109 #define MCUCHEN3_ENABLE (u32)0x00008000
110 #define MCUCHEN3_DISABLE (u32)0xFFFF7FFF
111
112 /* MIDI CTRL MCUCHEN2 Mask */
113 #define MCUCHEN2_ENABLE (u32)0x00004000
114 #define MCUCHEN2_DISABLE (u32)0xFFFFBFFF
115
116 /* MIDI CTRL MCUCHEN1 Mask */
117 #define MCUCHEN1_ENABLE (u32)0x00002000
118 #define MCUCHEN1_DISABLE (u32)0xFFFFDFFF
119
120 /* MIDI CTRL MCUCHEN0 Mask */
121 #define MCUCHEN0_ENABLE (u32)0x00001000
122 #define MCUCHEN0_DISABLE (u32)0xFFFFEFFF
123
124 /* MIDI CTRL DACDS Mask */
125 #define MIDI_CTRL_DACDS_MASK (u32)0x00000700
126
127 /* MIDI CTRL MUSICEN Mask */
128 #define MUSICEN_ENABLE (u32)0x00000080
129 #define MUSICEN_DISABLE (u32)0xFFFFFF7F
130
131 /* MIDI CTRL SPIRDEN Mask */
132 #define SPIRDEN_ENABLE (u32)0x00000040
133 #define SPIRDEN_DISABLE (u32)0xFFFFFFBF
134
135 /* MIDI CTRL SPIDISLOOP Mask */
136 #define SPIDISLOOP_ENABLE (u32)0x00000020
137 #define SPIDISLOOP_DISABLE (u32)0xFFFFFFDF
138
139 /* MIDI CTRL CHS Mask */
140 #define MIDI_CTRL_CHS_MASK (u32)0x00000007
141 /**
142 * @}
143 */
144
145 /* Global functions ----------------------------------------------------------------------------------------*/
146 /** @defgroup MIDI_Exported_Functions MIDI exported functions
147 * @{
148 */
149 /*********************************************************************************************************//**
150 * @brief Deinitialize the MIDI peripheral registers to their default reset values.
151 * @retval None
152 ************************************************************************************************************/
MIDI_DeInit(void)153 void MIDI_DeInit(void)
154 {
155 RSTCU_PeripReset_TypeDef RSTCUReset = {{0}};
156
157 RSTCUReset.Bit.MIDI = 1;
158 RSTCU_PeripReset(RSTCUReset, ENABLE);
159 }
160
161 /*********************************************************************************************************//**
162 * @brief Initialize the MIDIx peripheral according to the specified parameters in the MIDI_InitStruct.
163 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
164 * @param MIDI_InitStruct: pointer to a MIDI_InitTypeDef structure that contains the configuration
165 * information for the specified MIDI peripheral.
166 * @retval None
167 ***********************************************************************************************************/
MIDI_Init(HT_MIDI_TypeDef * MIDIx,MIDI_InitTypeDef * MIDI_InitStruct)168 void MIDI_Init(HT_MIDI_TypeDef* MIDIx, MIDI_InitTypeDef* MIDI_InitStruct)
169 {
170 /* Check the parameters */
171 Assert_Param(IS_MIDI(MIDIx));
172 Assert_Param(IS_MIDI_CTRL_DACDS(MIDI_InitStruct->MIDI_CTRL_DACDS));
173 Assert_Param(IS_MIDI_CTRL_MUSICEN(MIDI_InitStruct->MIDI_CTRL_MUSICEN));
174 Assert_Param(IS_MIDI_CTRL_SPIDISLOOP(MIDI_InitStruct->MIDI_CTRL_SPIDISLOOP));
175 Assert_Param(IS_MIDI_CTRL_CHS(MIDI_InitStruct->MIDI_CTRL_CHS));
176 Assert_Param(IS_MIDI_FREQ_BL(MIDI_InitStruct->MIDI_FREQ_BL));
177 Assert_Param(IS_MIDI_FREQ_FR(MIDI_InitStruct->MIDI_FREQ_FR));
178 Assert_Param(IS_MIDI_VOL_AR(MIDI_InitStruct->MIDI_VOL_AR));
179 Assert_Param(IS_MIDI_VOL_ENV(MIDI_InitStruct->MIDI_VOL_ENV));
180 Assert_Param(IS_MIDI_VOL_VL(MIDI_InitStruct->MIDI_VOL_VL));
181 Assert_Param(IS_MIDI_VOL_VR(MIDI_InitStruct->MIDI_VOL_VR));
182 Assert_Param(IS_MIDI_STADDR(MIDI_InitStruct->MIDI_STADDR));
183 Assert_Param(IS_MIDI_RENUM_WBS(MIDI_InitStruct->MIDI_RENUM_WBS));
184 Assert_Param(IS_MIDI_RENUM_RE(MIDI_InitStruct->MIDI_RENUM_RE));
185 Assert_Param(IS_MIDI_ENDADDR(MIDI_InitStruct->MIDI_ENDADDR));
186 Assert_Param(IS_MIDI_CHAN_ST(MIDI_InitStruct->MIDI_CHAN_ST));
187 Assert_Param(IS_MIDI_CHAN_VM(MIDI_InitStruct->MIDI_CHAN_VM));
188 Assert_Param(IS_MIDI_CHAN_FR(MIDI_InitStruct->MIDI_CHAN_FR));
189 Assert_Param(IS_MIDI_CHAN_CHx(MIDI_InitStruct->MIDI_CHAN_CHx));
190
191 MIDIx->CTRL = ((MIDI_InitStruct->MIDI_CTRL_DACDS) << 8) |
192 ((MIDI_InitStruct->MIDI_CTRL_MUSICEN) << 7) |
193 ((MIDI_InitStruct->MIDI_CTRL_SPIDISLOOP) << 6) |
194 (MIDI_InitStruct->MIDI_CTRL_CHS);
195
196 MIDIx->FREQ = ((MIDI_InitStruct->MIDI_FREQ_BL) << 12) |
197 (MIDI_InitStruct->MIDI_FREQ_FR);
198
199 MIDIx->VOL = ((MIDI_InitStruct->MIDI_VOL_AR) << 31) |
200 ((MIDI_InitStruct->MIDI_VOL_ENV) << 29) |
201 ((MIDI_InitStruct->MIDI_VOL_VL) << 16) |
202 (MIDI_InitStruct->MIDI_VOL_VR);
203
204 MIDIx->ST_ADDR = MIDI_InitStruct->MIDI_STADDR;
205
206 MIDIx->RE_NUM = ((MIDI_InitStruct->MIDI_RENUM_WBS) << 16) |
207 (MIDI_InitStruct->MIDI_RENUM_RE);
208
209 MIDIx->END_ADDR = MIDI_InitStruct->MIDI_ENDADDR;
210
211 MIDIx->CHAN = ((MIDI_InitStruct->MIDI_CHAN_ST) << 10) |
212 ((MIDI_InitStruct->MIDI_CHAN_VM) << 9) |
213 ((MIDI_InitStruct->MIDI_CHAN_FR) << 8) |
214 (MIDI_InitStruct->MIDI_CHAN_CHx);
215 }
216
217 /*********************************************************************************************************//**
218 * @brief Fill each MIDI_InitStruct member with its default value.
219 * @param MIDI_InitStruct: pointer to an MIDI_InitTypeDef structure which will be initialized.
220 * @retval None
221 ***********************************************************************************************************/
MIDI_StructInit(MIDI_InitTypeDef * MIDI_InitStruct)222 void MIDI_StructInit(MIDI_InitTypeDef* MIDI_InitStruct)
223 {
224 /* Initialize the MIDI_CTRL_DACDS member */
225 MIDI_InitStruct->MIDI_CTRL_DACDS = 0x0;
226
227 /* Initialize the MIDI_CTRL_MUSICEN member */
228 MIDI_InitStruct->MIDI_CTRL_MUSICEN = DISABLE;
229
230 /* Initialize the MIDI_CTRL_SPIDISLOOP member */
231 MIDI_InitStruct->MIDI_CTRL_SPIDISLOOP = DISABLE;
232
233 /* Initialize the MIDI_CTRL_CHS member */
234 MIDI_InitStruct->MIDI_CTRL_CHS = CHS16;
235
236 /* Initialize the MIDI_FREQ_BL member */
237 MIDI_InitStruct->MIDI_FREQ_BL = BL0;
238
239 /* Initialize the MIDI_FREQ_FR member */
240 MIDI_InitStruct->MIDI_FREQ_FR = 0x0;
241
242 /* Initialize the MIDI_VOL_AR member */
243 MIDI_InitStruct->MIDI_VOL_AR = ENV_RELEASE;
244
245 /* Initialize the MIDI_VOL_ENV member */
246 MIDI_InitStruct->MIDI_VOL_ENV = ENV_NO;
247
248 /* Initialize the MIDI_VOL_VL member */
249 MIDI_InitStruct->MIDI_VOL_VL = 0x3FF;
250
251 /* Initialize the MIDI_VOL_VR member */
252 MIDI_InitStruct->MIDI_VOL_VR = 0x3FF;
253
254 /* Initialize the MIDI_STADDR member */
255 MIDI_InitStruct->MIDI_STADDR = 0x0;
256
257 /* Initialize the MIDI_RENUM_WBS member */
258 MIDI_InitStruct->MIDI_RENUM_WBS = WBS8;
259
260 /* Initialize the MIDI_RENUM_RE member */
261 MIDI_InitStruct->MIDI_RENUM_RE = 0x0;
262
263 /* Initialize the MIDI_ENDADDR member */
264 MIDI_InitStruct->MIDI_ENDADDR = 0x0;
265
266 /* Initialize the MIDI_CHAN_ST member */
267 MIDI_InitStruct->MIDI_CHAN_ST = DISABLE;
268
269 /* Initialize the MIDI_CHAN_VM member */
270 MIDI_InitStruct->MIDI_CHAN_VM = DISABLE;
271
272 /* Initialize the MIDI_CHAN_FR member */
273 MIDI_InitStruct->MIDI_CHAN_FR = DISABLE;
274
275 /* Initialize the MIDI_CHAN_CHx member */
276 MIDI_InitStruct->MIDI_CHAN_CHx = MIDI_CHx0;
277 }
278
279 /*********************************************************************************************************//**
280 * @brief Enable or Disable the specified MIDI interrupt.
281 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
282 * @param MIDI_Int: specify if the MIDI interrupt source to be enabled or disabled.
283 * This parameter can be any combination of the following values:
284 * @arg MIDIO_DMAEN : MIDIO DMAEN
285 * @arg MIDII_DMAEN : MIDII DMAEN
286 * @arg MIDI_INTEN : MIDI INTEN
287 * @param NewState: new state of the MIDI interrupts.
288 * This parameter can be: ENABLE or DISABLE.
289 * @retval None
290 ***********************************************************************************************************/
MIDI_IntConfig(HT_MIDI_TypeDef * MIDIx,u32 MIDI_Int,ControlStatus NewState)291 void MIDI_IntConfig(HT_MIDI_TypeDef* MIDIx, u32 MIDI_Int, ControlStatus NewState)
292 {
293 /* Check the parameters */
294 Assert_Param(IS_MIDI(MIDIx));
295 Assert_Param(IS_MIDI_INT(MIDI_Int));
296 Assert_Param(IS_CONTROL_STATUS(NewState));
297
298 if (NewState != DISABLE)
299 {
300 MIDIx->IER |= MIDI_Int;
301 }
302 else
303 {
304 MIDIx->IER &= (u32)~MIDI_Int;
305 }
306 }
307
308 /*********************************************************************************************************//**
309 * @brief Check whether the specified MIDI flag has been set or not.
310 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
311 * @param MIDI_Flag: specify the flag that is to be check.
312 * This parameter can be one of the following values:
313 * @arg MIDI_INTF : MIDI int flag
314 * @retval The new state of MIDI_Flag (SET or RESET).
315 ***********************************************************************************************************/
MIDI_GetFlagStatus(HT_MIDI_TypeDef * MIDIx,u32 MIDI_Flag)316 FlagStatus MIDI_GetFlagStatus(HT_MIDI_TypeDef* MIDIx, u32 MIDI_Flag)
317 {
318 FlagStatus bitstatus = RESET;
319 u32 statusreg = 0;
320
321 /* Check the parameters */
322 Assert_Param(IS_MIDI(MIDIx));
323 Assert_Param(IS_MIDI_FLAG(MIDI_Flag));
324
325 statusreg = MIDIx->SR;
326
327 if ((statusreg & MIDI_Flag) != (u32)RESET)
328 {
329 bitstatus = SET;
330 }
331 else
332 {
333 bitstatus = RESET;
334 }
335
336 return bitstatus;
337 }
338
339 /*********************************************************************************************************//**
340 * @brief Clear the specified MIDI flag.
341 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
342 * @param MIDI_Flag: specify the flag that is to be cleared.
343 * This parameter can be one of the following values:
344 * @arg MIDI_INTF : MIDI INTF
345 * @retval None
346 ***********************************************************************************************************/
MIDI_ClearFlag(HT_MIDI_TypeDef * MIDIx,u32 MIDI_Flag)347 void MIDI_ClearFlag(HT_MIDI_TypeDef* MIDIx, u32 MIDI_Flag)
348 {
349 /* Check the parameters */
350 Assert_Param(IS_MIDI(MIDIx));
351 Assert_Param(IS_MIDI_FLAG_CLEAR(MIDI_Flag));
352
353 MIDIx->SR = MIDI_Flag;
354 }
355
356 /*********************************************************************************************************//**
357 * @brief Configure the Channel for the selected MIDI.
358 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
359 * @param MCUCHEN3: this parameter can be ENABLE or DISABLE.
360 * @param MCUCHEN2: this parameter can be ENABLE or DISABLE.
361 * @param MCUCHEN1: this parameter can be ENABLE or DISABLE.
362 * @param MCUCHEN0: this parameter can be ENABLE or DISABLE.
363 * @param DACDS: specify the clipping and distorting volume of the MIDI.
364 * @param MUSICEN: this parameter can be ENABLE or DISABLE.
365 * @param SPIRDEN: this parameter can be ENABLE or DISABLE.
366 * @param SPIDISLOOP: this parameter can be ENABLE or DISABLE.
367 * @param CHS: specify channel selection of the MIDI.
368 * @retval None
369 ***********************************************************************************************************/
MIDI_CTRL(HT_MIDI_TypeDef * MIDIx,MIDI_CTRL_MCUCHEN3_Enum MCUCHEN3,MIDI_CTRL_MCUCHEN2_Enum MCUCHEN2,MIDI_CTRL_MCUCHEN1_Enum MCUCHEN1,MIDI_CTRL_MCUCHEN0_Enum MCUCHEN0,u8 DACDS,MIDI_CTRL_MUSICEN_Enum MUSICEN,MIDI_CTRL_SPIRDEN_Enum SPIRDEN,MIDI_CTRL_SPIDISLOOP_Enum SPIDISLOOP,MIDI_CTRL_CHS_Enum CHS)370 void MIDI_CTRL(HT_MIDI_TypeDef* MIDIx,
371 MIDI_CTRL_MCUCHEN3_Enum MCUCHEN3, MIDI_CTRL_MCUCHEN2_Enum MCUCHEN2,
372 MIDI_CTRL_MCUCHEN1_Enum MCUCHEN1, MIDI_CTRL_MCUCHEN0_Enum MCUCHEN0,
373 u8 DACDS,
374 MIDI_CTRL_MUSICEN_Enum MUSICEN,
375 MIDI_CTRL_SPIRDEN_Enum SPIRDEN, MIDI_CTRL_SPIDISLOOP_Enum SPIDISLOOP,
376 MIDI_CTRL_CHS_Enum CHS)
377 {
378 /* Check the parameters */
379 Assert_Param(IS_MIDI(MIDIx));
380 Assert_Param(IS_MIDI_CTRL_MCUCHEN3(MCUCHEN3));
381 Assert_Param(IS_MIDI_CTRL_MCUCHEN2(MCUCHEN2));
382 Assert_Param(IS_MIDI_CTRL_MCUCHEN1(MCUCHEN1));
383 Assert_Param(IS_MIDI_CTRL_MCUCHEN0(MCUCHEN0));
384 Assert_Param(IS_MIDI_CTRL_DACDS(DACDS));
385 Assert_Param(IS_MIDI_CTRL_MUSICEN(MUSICEN));
386 Assert_Param(IS_MIDI_CTRL_SPIRDEN(SPIRDEN));
387 Assert_Param(IS_MIDI_CTRL_SPIDISLOOP(SPIDISLOOP));
388 Assert_Param(IS_MIDI_CTRL_CHS(CHS));
389
390 MIDIx->CTRL = (MCUCHEN3 << 15) | (MCUCHEN2 << 14) | (MCUCHEN1 << 13) | (MCUCHEN0 << 12) |
391 (DACDS << 8) |
392 (MUSICEN << 7) |
393 (SPIRDEN << 6) | (SPIDISLOOP << 5) |
394 CHS;
395 }
396
397 /*********************************************************************************************************//**
398 * @brief Configure the FREQ for the selected MIDI.
399 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
400 * @param BL: specify octave of the MIDI.
401 * @param FR: specify pitch of the MIDI.
402 * @retval None
403 ***********************************************************************************************************/
MIDI_FREQ(HT_MIDI_TypeDef * MIDIx,MIDI_FREQ_BL_Enum BL,u16 FR)404 void MIDI_FREQ(HT_MIDI_TypeDef* MIDIx, MIDI_FREQ_BL_Enum BL, u16 FR)
405 {
406 /* Check the parameters */
407 Assert_Param(IS_MIDI(MIDIx));
408 Assert_Param(IS_MIDI_FREQ_BL(BL));
409 Assert_Param(IS_MIDI_FREQ_FR(FR));
410
411 MIDIx->FREQ = (BL << 12) | FR;
412 }
413
414 /*********************************************************************************************************//**
415 * @brief Configure the VOL for the selected MIDI.
416 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
417 * @param A_R: specify attack or release of the MIDI.
418 * @param ENV: specify envelope of the MIDI.
419 * @param VL: specify left channel of the MIDI.
420 * @param VR: specify right channel of the MIDI.
421 * @retval None
422 ***********************************************************************************************************/
MIDI_VOL(HT_MIDI_TypeDef * MIDIx,MIDI_VOL_AR_Enum A_R,MIDI_VOL_ENV_Enum ENV,u16 VL,u16 VR)423 void MIDI_VOL(HT_MIDI_TypeDef* MIDIx, MIDI_VOL_AR_Enum A_R, MIDI_VOL_ENV_Enum ENV, u16 VL, u16 VR)
424 {
425 /* Check the parameters */
426 Assert_Param(IS_MIDI(MIDIx));
427 Assert_Param(IS_MIDI_VOL_AR(A_R));
428 Assert_Param(IS_MIDI_VOL_ENV(ENV));
429 Assert_Param(IS_MIDI_VOL_VL(VL));
430 Assert_Param(IS_MIDI_VOL_VR(VR));
431
432 MIDIx->VOL = (A_R << 31) | (ENV << 29) | (VL << 16) | VR;
433 }
434
435 /*********************************************************************************************************//**
436 * @brief Configure the Start Address for the selected MIDI.
437 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
438 * @param ST_ADDR: specify start address of the MIDI.
439 * @retval None
440 ***********************************************************************************************************/
MIDI_STADDR(HT_MIDI_TypeDef * MIDIx,u32 ST_ADDR)441 void MIDI_STADDR(HT_MIDI_TypeDef* MIDIx, u32 ST_ADDR)
442 {
443 /* Check the parameters */
444 Assert_Param(IS_MIDI(MIDIx));
445 Assert_Param(IS_MIDI_STADDR(ST_ADDR));
446
447 MIDIx->ST_ADDR = ST_ADDR;
448 }
449
450 /*********************************************************************************************************//**
451 * @brief Configure the RENUM for the selected MIDI.
452 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
453 * @param WBS: specify waveform of the MIDI.
454 * @param RE: specify repeated code of the MIDI.
455 * @retval None
456 ***********************************************************************************************************/
MIDI_RENUM(HT_MIDI_TypeDef * MIDIx,MIDI_RENUM_WBS_Enum WBS,u16 RE)457 void MIDI_RENUM(HT_MIDI_TypeDef* MIDIx, MIDI_RENUM_WBS_Enum WBS, u16 RE)
458 {
459 /* Check the parameters */
460 Assert_Param(IS_MIDI(MIDIx));
461 Assert_Param(IS_MIDI_RENUM_WBS(WBS));
462 Assert_Param(IS_MIDI_RENUM_RE(RE));
463
464 MIDIx->RE_NUM = (WBS << 16) | RE;
465 }
466
467 /*********************************************************************************************************//**
468 * @brief Configure the End Address for the selected MIDI.
469 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
470 * @param END_ADDR: specify end address of the MIDI.
471 * @retval None
472 ***********************************************************************************************************/
MIDI_ENDADDR(HT_MIDI_TypeDef * MIDIx,u32 END_ADDR)473 void MIDI_ENDADDR(HT_MIDI_TypeDef* MIDIx, u32 END_ADDR)
474 {
475 /* Check the parameters */
476 Assert_Param(IS_MIDI(MIDIx));
477 Assert_Param(IS_MIDI_ENDADDR(END_ADDR));
478
479 MIDIx->END_ADDR = END_ADDR;
480 }
481
482 /*********************************************************************************************************//**
483 * @brief Configure the Channel for the selected MIDI.
484 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
485 * @param TRIG_ST: this parameter can be ENABLE or DISABLE.
486 * @param TRIG_VM: this parameter can be ENABLE or DISABLE.
487 * @param TRIG_FR: this parameter can be ENABLE or DISABLE.
488 * @param CHx: specify selected channel of the MIDI.
489 * @retval None
490 ***********************************************************************************************************/
MIDI_CHAN(HT_MIDI_TypeDef * MIDIx,MIDI_CHAN_ST_Enum TRIG_ST,MIDI_CHAN_VM_Enum TRIG_VM,MIDI_CHAN_FR_Enum TRIG_FR,u8 CHx)491 void MIDI_CHAN(HT_MIDI_TypeDef* MIDIx,
492 MIDI_CHAN_ST_Enum TRIG_ST, MIDI_CHAN_VM_Enum TRIG_VM, MIDI_CHAN_FR_Enum TRIG_FR,
493 u8 CHx)
494 {
495 /* Check the parameters */
496 Assert_Param(IS_MIDI(MIDIx));
497 Assert_Param(IS_MIDI_CHAN_ST(TRIG_ST));
498 Assert_Param(IS_MIDI_CHAN_VM(TRIG_VM));
499 Assert_Param(IS_MIDI_CHAN_FR(TRIG_FR));
500 Assert_Param(IS_MIDI_CHAN_CHx(CHx));
501
502 MIDIx->CHAN = (TRIG_ST << 10) | (TRIG_VM << 9) | (TRIG_FR << 8) | CHx;
503 }
504
505 /*********************************************************************************************************//**
506 * @brief Configure the MCU CH0 DATA for the selected MIDI.
507 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
508 * @param CH0B: specify DATA[31:16] of MCU CH0 of the MIDI.
509 * @param CH0A: specify DATA[15:0] of MCU CH0 of the MIDI.
510 * @retval None
511 ***********************************************************************************************************/
MIDI_MCUCH0(HT_MIDI_TypeDef * MIDIx,u16 CH0B,u16 CH0A)512 void MIDI_MCUCH0(HT_MIDI_TypeDef* MIDIx, u16 CH0B, u16 CH0A)
513 {
514 /* Check the parameters */
515 Assert_Param(IS_MIDI(MIDIx));
516 Assert_Param(IS_MIDI_MCUCHx11_BH(CH0B));
517 Assert_Param(IS_MIDI_MCUCHx11_BL(CH0A));
518
519 MIDIx->MCU_CH0 = (CH0B << 16) | CH0A;
520 }
521
522 /*********************************************************************************************************//**
523 * @brief Configure the MCU CH1 DATA for the selected MIDI.
524 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
525 * @param CH1B: specify DATA[31:16] of MCU CH1 of the MIDI.
526 * @param CH1A: specify DATA[15:0] of MCU CH1 of the MIDI.
527 * @retval None
528 ***********************************************************************************************************/
MIDI_MCUCH1(HT_MIDI_TypeDef * MIDIx,u16 CH1B,u16 CH1A)529 void MIDI_MCUCH1(HT_MIDI_TypeDef* MIDIx, u16 CH1B, u16 CH1A)
530 {
531 /* Check the parameters */
532 Assert_Param(IS_MIDI(MIDIx));
533 Assert_Param(IS_MIDI_MCUCHx12_CH(CH1B));
534 Assert_Param(IS_MIDI_MCUCHx12_CL(CH1A));
535
536 MIDIx->MCU_CH1 = (CH1B << 16) | CH1A;
537 }
538
539 /*********************************************************************************************************//**
540 * @brief Configure the MCU CH2 DATA for the selected MIDI.
541 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
542 * @param CH2B: specify DATA[31:16] of MCU CH2 of the MIDI.
543 * @param CH2A: specify DATA[15:0] of MCU CH2 of the MIDI.
544 * @retval None
545 ***********************************************************************************************************/
MIDI_MCUCH2(HT_MIDI_TypeDef * MIDIx,u16 CH2B,u16 CH2A)546 void MIDI_MCUCH2(HT_MIDI_TypeDef* MIDIx, u16 CH2B, u16 CH2A)
547 {
548 /* Check the parameters */
549 Assert_Param(IS_MIDI(MIDIx));
550 Assert_Param(IS_MIDI_MCUCHx13_DH(CH2B));
551 Assert_Param(IS_MIDI_MCUCHx13_DL(CH2A));
552
553 MIDIx->MCU_CH2 = (CH2B << 16) | CH2A;
554 }
555
556 /*********************************************************************************************************//**
557 * @brief Configure the MCU CH3 DATA for the selected MIDI.
558 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
559 * @param CH3B: specify DATA[31:16] of MCU CH3 of the MIDI.
560 * @param CH3A: specify DATA[15:0] of MCU CH3 of the MIDI.
561 * @retval None
562 ***********************************************************************************************************/
MIDI_MCUCH3(HT_MIDI_TypeDef * MIDIx,u16 CH3B,u16 CH3A)563 void MIDI_MCUCH3(HT_MIDI_TypeDef* MIDIx, u16 CH3B, u16 CH3A)
564 {
565 /* Check the parameters */
566 Assert_Param(IS_MIDI(MIDIx));
567 Assert_Param(IS_MIDI_MCUCHx14_EH(CH3B));
568 Assert_Param(IS_MIDI_MCUCHx14_EL(CH3A));
569
570 MIDIx->MCU_CH3 = (CH3B << 16) | CH3A;
571 }
572
573 /*********************************************************************************************************//**
574 * @brief Configure the FREQ BL for the selected MIDI.
575 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
576 * @param BL: specify octave of the MIDI.
577 * @retval None
578 ***********************************************************************************************************/
MIDI_FREQ_BL(HT_MIDI_TypeDef * MIDIx,MIDI_FREQ_BL_Enum BL)579 void MIDI_FREQ_BL(HT_MIDI_TypeDef* MIDIx, MIDI_FREQ_BL_Enum BL)
580 {
581 /* Check the parameters */
582 Assert_Param(IS_MIDI(MIDIx));
583 Assert_Param(IS_MIDI_FREQ_BL(BL));
584
585 /* Clear BL[3:0] in FREQ */
586 MIDIx->FREQ &= (u32)~MIDI_FREQ_BL_MASK;
587
588 /* Set new BL[3:0] in FREQ */
589 MIDIx->FREQ |= (BL << 12);
590 }
591
592 /*********************************************************************************************************//**
593 * @brief Configure the FREQ FR for the selected MIDI.
594 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
595 * @param FR: specify pitch of the MIDI.
596 * @retval None
597 ***********************************************************************************************************/
MIDI_FREQ_FR(HT_MIDI_TypeDef * MIDIx,u16 FR)598 void MIDI_FREQ_FR(HT_MIDI_TypeDef* MIDIx, u16 FR)
599 {
600 /* Check the parameters */
601 Assert_Param(IS_MIDI(MIDIx));
602 Assert_Param(IS_MIDI_FREQ_FR(FR));
603
604 /* Clear FR[11:0] in FREQ */
605 MIDIx->FREQ &= (u32)~MIDI_FREQ_FR_MASK;
606
607 /* Set new FR[11:0] in FREQ */
608 MIDIx->FREQ |= FR;
609 }
610
611 /*********************************************************************************************************//**
612 * @brief Configure the VOL AR for the selected MIDI.
613 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
614 * @param A_R: specify attack or release of the MIDI.
615 * @retval None
616 ***********************************************************************************************************/
MIDI_VOL_AR(HT_MIDI_TypeDef * MIDIx,MIDI_VOL_AR_Enum A_R)617 void MIDI_VOL_AR(HT_MIDI_TypeDef* MIDIx, MIDI_VOL_AR_Enum A_R)
618 {
619 /* Check the parameters */
620 Assert_Param(IS_MIDI(MIDIx));
621 Assert_Param(IS_MIDI_VOL_AR(A_R));
622
623 /* Clear A_R in VOL */
624 MIDIx->VOL &= (u32)~MIDI_VOL_AR_MASK;
625
626 /* Set new A_R in VOL */
627 MIDIx->VOL |= (A_R << 31);
628 }
629
630 /*********************************************************************************************************//**
631 * @brief Configure the VOL ENV for the selected MIDI.
632 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
633 * @param ENV: specify envelope of the MIDI.
634 * @retval None
635 ***********************************************************************************************************/
MIDI_VOL_ENV(HT_MIDI_TypeDef * MIDIx,MIDI_VOL_ENV_Enum ENV)636 void MIDI_VOL_ENV(HT_MIDI_TypeDef* MIDIx, MIDI_VOL_ENV_Enum ENV)
637 {
638 /* Check the parameters */
639 Assert_Param(IS_MIDI(MIDIx));
640 Assert_Param(IS_MIDI_VOL_ENV(ENV));
641
642 /* Clear ENV[1:0] in VOL */
643 MIDIx->VOL &= (u32)~MIDI_VOL_ENV_MASK;
644
645 /* Set new ENV[1:0] in VOL */
646 MIDIx->VOL |= (ENV << 29);
647 }
648
649 /*********************************************************************************************************//**
650 * @brief Configure the VOL VL for the selected MIDI.
651 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
652 * @param VL: specify left channel of the MIDI.
653 * @retval None
654 ***********************************************************************************************************/
MIDI_VOL_VL(HT_MIDI_TypeDef * MIDIx,u16 VL)655 void MIDI_VOL_VL(HT_MIDI_TypeDef* MIDIx, u16 VL)
656 {
657 /* Check the parameters */
658 Assert_Param(IS_MIDI(MIDIx));
659 Assert_Param(IS_MIDI_VOL_VL(VL));
660
661 /* Clear VL[9:0] in VOL */
662 MIDIx->VOL &= (u32)~MIDI_VOL_VL_MASK;
663
664 /* Set new VL[9:0] in VOL */
665 MIDIx->VOL |= (VL << 16);
666 }
667
668 /*********************************************************************************************************//**
669 * @brief Configure the VOL VR for the selected MIDI.
670 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
671 * @param VR: specify right channel of the MIDI.
672 * @retval None
673 ***********************************************************************************************************/
MIDI_VOL_VR(HT_MIDI_TypeDef * MIDIx,u16 VR)674 void MIDI_VOL_VR(HT_MIDI_TypeDef* MIDIx, u16 VR)
675 {
676 /* Check the parameters */
677 Assert_Param(IS_MIDI(MIDIx));
678 Assert_Param(IS_MIDI_VOL_VR(VR));
679
680 /* Clear VR[9:0] in VOL */
681 MIDIx->VOL &= (u32)~MIDI_VOL_VR_MASK;
682
683 /* Set new VR[9:0] in VOL */
684 MIDIx->VOL |= VR;
685 }
686
687 /*********************************************************************************************************//**
688 * @brief Configure the RENUM WBS for the selected MIDI.
689 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
690 * @param WBS: specify waveform of the MIDI.
691 * @retval None
692 ***********************************************************************************************************/
MIDI_RENUM_WBS(HT_MIDI_TypeDef * MIDIx,MIDI_RENUM_WBS_Enum WBS)693 void MIDI_RENUM_WBS(HT_MIDI_TypeDef* MIDIx, MIDI_RENUM_WBS_Enum WBS)
694 {
695 /* Check the parameters */
696 Assert_Param(IS_MIDI(MIDIx));
697 Assert_Param(IS_MIDI_RENUM_WBS(WBS));
698
699 /* Clear WBS[1:0] in RENUM */
700 MIDIx->RE_NUM &= (u32)~MIDI_RENUM_WBS_MASK;
701
702 /* Set new WBS[1:0] in RENUM */
703 MIDIx->RE_NUM |= (WBS << 16);
704 }
705
706 /*********************************************************************************************************//**
707 * @brief Configure the RENUM RE for the selected MIDI.
708 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
709 * @param RE: specify repeated code of the MIDI.
710 * @retval None
711 ***********************************************************************************************************/
MIDI_RENUM_RE(HT_MIDI_TypeDef * MIDIx,u16 RE)712 void MIDI_RENUM_RE(HT_MIDI_TypeDef* MIDIx, u16 RE)
713 {
714 /* Check the parameters */
715 Assert_Param(IS_MIDI(MIDIx));
716 Assert_Param(IS_MIDI_RENUM_RE(RE));
717
718 /* Clear RE[14:0] in RENUM */
719 MIDIx->RE_NUM &= (u32)~MIDI_RENUM_RE_MASK;
720
721 /* Set new RE[14:0] in RENUM */
722 MIDIx->RE_NUM |= RE;
723 }
724
725 /*********************************************************************************************************//**
726 * @brief Enable or Disable ST ADDR for the specified MIDI peripheral.
727 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
728 * @param NewState: new state of the MIDIx peripheral.
729 * This parameter can be: ENABLE or DISABLE.
730 * @retval None
731 ***********************************************************************************************************/
MIDI_CHAN_STCmd(HT_MIDI_TypeDef * MIDIx,ControlStatus NewState)732 void MIDI_CHAN_STCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState)
733 {
734 /* Check the parameters */
735 Assert_Param(IS_MIDI(MIDIx));
736 Assert_Param(IS_CONTROL_STATUS(NewState));
737
738 if (NewState != DISABLE)
739 {
740 MIDIx->CHAN |= TRIG_ST_ENABLE;
741 }
742 else
743 {
744 MIDIx->CHAN &= (TRIG_ST_DISABLE);
745 }
746 }
747
748 /*********************************************************************************************************//**
749 * @brief Enable or Disable VM for the specified MIDI peripheral.
750 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
751 * @param NewState: new state of the MIDIx peripheral.
752 * This parameter can be: ENABLE or DISABLE.
753 * @retval None
754 ***********************************************************************************************************/
MIDI_CHAN_VMCmd(HT_MIDI_TypeDef * MIDIx,ControlStatus NewState)755 void MIDI_CHAN_VMCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState)
756 {
757 /* Check the parameters */
758 Assert_Param(IS_MIDI(MIDIx));
759 Assert_Param(IS_CONTROL_STATUS(NewState));
760
761 if (NewState != DISABLE)
762 {
763 MIDIx->CHAN |= TRIG_VM_ENABLE;
764 }
765 else
766 {
767 MIDIx->CHAN &= (TRIG_VM_DISABLE);
768 }
769 }
770
771 /*********************************************************************************************************//**
772 * @brief Enable or Disable FR for the specified MIDI peripheral.
773 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
774 * @param NewState: new state of the MIDIx peripheral.
775 * This parameter can be: ENABLE or DISABLE.
776 * @retval None
777 ***********************************************************************************************************/
MIDI_CHAN_FRCmd(HT_MIDI_TypeDef * MIDIx,ControlStatus NewState)778 void MIDI_CHAN_FRCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState)
779 {
780 /* Check the parameters */
781 Assert_Param(IS_MIDI(MIDIx));
782 Assert_Param(IS_CONTROL_STATUS(NewState));
783
784 if (NewState != DISABLE)
785 {
786 MIDIx->CHAN |= TRIG_FR_ENABLE;
787 }
788 else
789 {
790 MIDIx->CHAN &= (TRIG_FR_DISABLE);
791 }
792 }
793
794 /*********************************************************************************************************//**
795 * @brief Configure the Selected Channel for the selected MIDI.
796 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
797 * @param CHx: specify selected channel of the MIDI.
798 * @retval None
799 ***********************************************************************************************************/
MIDI_CHAN_CHx(HT_MIDI_TypeDef * MIDIx,u8 CHx)800 void MIDI_CHAN_CHx(HT_MIDI_TypeDef* MIDIx, u8 CHx)
801 {
802 /* Check the parameters */
803 Assert_Param(IS_MIDI(MIDIx));
804 Assert_Param(IS_MIDI_CHAN_CHx(CHx));
805
806 /* Clear CHx[4:0] in CHAN */
807 MIDIx->CHAN &= (u32)~MIDI_CHAN_CHx_MASK;
808
809 /* Set new CHx[4:0] in CHAN */
810 MIDIx->CHAN |= CHx;
811 }
812
813 /*********************************************************************************************************//**
814 * @brief Configure the CH0B of MCU CH0 DATA for the selected MIDI.
815 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
816 * @param CH0B: specify DATA[31:16] of MCU CH0 of the MIDI.
817 * @retval None
818 ***********************************************************************************************************/
MIDI_MCUCH0_CH0B(HT_MIDI_TypeDef * MIDIx,u16 CH0B)819 void MIDI_MCUCH0_CH0B(HT_MIDI_TypeDef* MIDIx, u16 CH0B)
820 {
821 /* Check the parameters */
822 Assert_Param(IS_MIDI(MIDIx));
823 Assert_Param(IS_MIDI_MCUCHx11_BH(CH0B));
824
825 /* Clear CH0B[16:0] in MCUCH0 */
826 MIDIx->MCU_CH0 &= (u32)~MIDI_MCUCH0_CH0B_MASK;
827
828 /* Set new CH0B[16:0] in MCUCH0 */
829 MIDIx->MCU_CH0 |= (CH0B << 16);
830 }
831
832 /*********************************************************************************************************//**
833 * @brief Configure the CH0A of MCU CH0 DATA for the selected MIDI.
834 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
835 * @param CH0A: specify DATA[15:0] of MCU CH0 of the MIDI.
836 * @retval None
837 ***********************************************************************************************************/
MIDI_MCUCH0_CH0A(HT_MIDI_TypeDef * MIDIx,u16 CH0A)838 void MIDI_MCUCH0_CH0A(HT_MIDI_TypeDef* MIDIx, u16 CH0A)
839 {
840 /* Check the parameters */
841 Assert_Param(IS_MIDI(MIDIx));
842 Assert_Param(IS_MIDI_MCUCHx11_BL(CH0A));
843
844 /* Clear CH0B[16:0] in MCUCH0 */
845 MIDIx->MCU_CH0 &= (u32)~MIDI_MCUCH0_CH0A_MASK;
846
847 /* Set new CH0B[16:0] in MCUCH0 */
848 MIDIx->MCU_CH0 |= CH0A;
849 }
850
851 /*********************************************************************************************************//**
852 * @brief Configure the CH1B of MCU CH1 DATA for the selected MIDI.
853 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
854 * @param CH1B: specify DATA[31:16] of MCU CH1 of the MIDI.
855 * @retval None
856 ***********************************************************************************************************/
MIDI_MCUCH1_CH1B(HT_MIDI_TypeDef * MIDIx,u16 CH1B)857 void MIDI_MCUCH1_CH1B(HT_MIDI_TypeDef* MIDIx, u16 CH1B)
858 {
859 /* Check the parameters */
860 Assert_Param(IS_MIDI(MIDIx));
861 Assert_Param(IS_MIDI_MCUCHx12_CH(CH1B));
862
863 /* Clear CH0B[16:0] in MCUCH0 */
864 MIDIx->MCU_CH1 &= (u32)~MIDI_MCUCH1_CH1B_MASK;
865
866 /* Set new CH1B[16:0] in MCUCH1 */
867 MIDIx->MCU_CH1 |= (CH1B << 16);
868 }
869
870 /*********************************************************************************************************//**
871 * @brief Configure the CH1A of MCU CH1 DATA for the selected MIDI.
872 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
873 * @param CH1A: specify DATA[15:0] of MCU CH1 of the MIDI.
874 * @retval None
875 ***********************************************************************************************************/
MIDI_MCUCH1_CH1A(HT_MIDI_TypeDef * MIDIx,u16 CH1A)876 void MIDI_MCUCH1_CH1A(HT_MIDI_TypeDef* MIDIx, u16 CH1A)
877 {
878 /* Check the parameters */
879 Assert_Param(IS_MIDI(MIDIx));
880 Assert_Param(IS_MIDI_MCUCHx12_CL(CH1A));
881
882 /* Clear CH1A[16:0] in MCUCH1 */
883 MIDIx->MCU_CH1 &= (u32)~MIDI_MCUCH1_CH1A_MASK;
884
885 /* Set new CH1A[16:0] in MCUCH1 */
886 MIDIx->MCU_CH1 |= CH1A;
887 }
888
889 /*********************************************************************************************************//**
890 * @brief Configure the CH2B of MCU CH2 DATA for the selected MIDI.
891 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
892 * @param CH2B: specify DATA[31:16] of MCU CH2 of the MIDI.
893 * @retval None
894 ***********************************************************************************************************/
MIDI_MCUCH2_CH2B(HT_MIDI_TypeDef * MIDIx,u16 CH2B)895 void MIDI_MCUCH2_CH2B(HT_MIDI_TypeDef* MIDIx, u16 CH2B)
896 {
897 /* Check the parameters */
898 Assert_Param(IS_MIDI(MIDIx));
899 Assert_Param(IS_MIDI_MCUCHx13_DH(CH2B));
900
901 /* Clear CH2B[16:0] in MCUCH2 */
902 MIDIx->MCU_CH2 &= (u32)~MIDI_MCUCH2_CH2B_MASK;
903
904 /* Set new CH2B[16:0] in MCUCH2 */
905 MIDIx->MCU_CH2 |= (CH2B << 16);
906 }
907
908 /*********************************************************************************************************//**
909 * @brief Configure the CH2A of MCU CH2 DATA for the selected MIDI.
910 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
911 * @param CH2A: specify DATA[15:0] of MCU CH2 of the MIDI.
912 * @retval None
913 ***********************************************************************************************************/
MIDI_MCUCH2_CH2A(HT_MIDI_TypeDef * MIDIx,u16 CH2A)914 void MIDI_MCUCH2_CH2A(HT_MIDI_TypeDef* MIDIx, u16 CH2A)
915 {
916 /* Check the parameters */
917 Assert_Param(IS_MIDI(MIDIx));
918 Assert_Param(IS_MIDI_MCUCHx13_DL(CH2A));
919
920 /* Clear CH2A[16:0] in MCUCH2 */
921 MIDIx->MCU_CH2 &= (u32)~MIDI_MCUCH2_CH2A_MASK;
922
923 /* Set new CH2A[16:0] in MCUCH2 */
924 MIDIx->MCU_CH2 |= CH2A;
925 }
926
927 /*********************************************************************************************************//**
928 * @brief Configure the CH3B of MCU CH3 DATA for the selected MIDI.
929 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
930 * @param CH3B: specify DATA[31:16] of MCU CH3 of the MIDI.
931 * @retval None
932 ***********************************************************************************************************/
MIDI_MCUCH3_CH3B(HT_MIDI_TypeDef * MIDIx,u16 CH3B)933 void MIDI_MCUCH3_CH3B(HT_MIDI_TypeDef* MIDIx, u16 CH3B)
934 {
935 /* Check the parameters */
936 Assert_Param(IS_MIDI(MIDIx));
937 Assert_Param(IS_MIDI_MCUCHx14_EH(CH3B));
938
939 /* Clear CH3B[16:0] in MCUCH3 */
940 MIDIx->MCU_CH3 &= (u32)~MIDI_MCUCH3_CH3B_MASK;
941
942 /* Set new CH3B[16:0] in MCUCH3 */
943 MIDIx->MCU_CH3 |= (CH3B << 16);
944 }
945
946 /*********************************************************************************************************//**
947 * @brief Configure the CH3A of MCU CH3 DATA for the selected MIDI.
948 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
949 * @param CH3A: specify DATA[15:0] of MCU CH3 of the MIDI.
950 * @retval None
951 ***********************************************************************************************************/
MIDI_MCUCH3_CH3A(HT_MIDI_TypeDef * MIDIx,u16 CH3A)952 void MIDI_MCUCH3_CH3A(HT_MIDI_TypeDef* MIDIx, u16 CH3A)
953 {
954 /* Check the parameters */
955 Assert_Param(IS_MIDI(MIDIx));
956 Assert_Param(IS_MIDI_MCUCHx14_EL(CH3A));
957
958 /* Clear CH3A[16:0] in MCUCH3 */
959 MIDIx->MCU_CH3 &= (u32)~MIDI_MCUCH3_CH3A_MASK;
960
961 /* Set new CH3A[16:0] in MCUCH3 */
962 MIDIx->MCU_CH3 |= CH3A;
963 }
964
965 /*********************************************************************************************************//**
966 * @brief Enable or Disable MCU CHEN3 for the specified MIDI peripheral.
967 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
968 * @param NewState: new state of the MIDIx peripheral.
969 * This parameter can be: ENABLE or DISABLE.
970 * @retval None
971 ***********************************************************************************************************/
MIDI_CTRL_MCUCHEN3(HT_MIDI_TypeDef * MIDIx,ControlStatus NewState)972 void MIDI_CTRL_MCUCHEN3(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState)
973 {
974 /* Check the parameters */
975 Assert_Param(IS_MIDI(MIDIx));
976 Assert_Param(IS_CONTROL_STATUS(NewState));
977
978 if (NewState != DISABLE)
979 {
980 MIDIx->CTRL |= MCUCHEN3_ENABLE;
981 }
982 else
983 {
984 MIDIx->CTRL &= MCUCHEN3_DISABLE;
985 }
986 }
987
988 /*********************************************************************************************************//**
989 * @brief Enable or Disable MCU CHEN2 for the specified MIDI peripheral.
990 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
991 * @param NewState: new state of the MIDIx peripheral.
992 * This parameter can be: ENABLE or DISABLE.
993 * @retval None
994 ***********************************************************************************************************/
MIDI_CTRL_MCUCHEN2(HT_MIDI_TypeDef * MIDIx,ControlStatus NewState)995 void MIDI_CTRL_MCUCHEN2(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState)
996 {
997 /* Check the parameters */
998 Assert_Param(IS_MIDI(MIDIx));
999 Assert_Param(IS_CONTROL_STATUS(NewState));
1000
1001 if (NewState != DISABLE)
1002 {
1003 MIDIx->CTRL |= MCUCHEN2_ENABLE;
1004 }
1005 else
1006 {
1007 MIDIx->CTRL &= MCUCHEN2_DISABLE;
1008 }
1009 }
1010
1011 /*********************************************************************************************************//**
1012 * @brief Enable or Disable MCU CHEN1 for the specified MIDI peripheral.
1013 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
1014 * @param NewState: new state of the MIDIx peripheral.
1015 * This parameter can be: ENABLE or DISABLE.
1016 * @retval None
1017 ***********************************************************************************************************/
MIDI_CTRL_MCUCHEN1(HT_MIDI_TypeDef * MIDIx,ControlStatus NewState)1018 void MIDI_CTRL_MCUCHEN1(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState)
1019 {
1020 /* Check the parameters */
1021 Assert_Param(IS_MIDI(MIDIx));
1022 Assert_Param(IS_CONTROL_STATUS(NewState));
1023
1024 if (NewState != DISABLE)
1025 {
1026 MIDIx->CTRL |= MCUCHEN1_ENABLE;
1027 }
1028 else
1029 {
1030 MIDIx->CTRL &= MCUCHEN1_DISABLE;
1031 }
1032 }
1033
1034 /*********************************************************************************************************//**
1035 * @brief Enable or Disable MCU CHEN0 for the specified MIDI peripheral.
1036 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
1037 * @param NewState: new state of the MIDIx peripheral.
1038 * This parameter can be: ENABLE or DISABLE.
1039 * @retval None
1040 ***********************************************************************************************************/
MIDI_CTRL_MCUCHEN0(HT_MIDI_TypeDef * MIDIx,ControlStatus NewState)1041 void MIDI_CTRL_MCUCHEN0(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState)
1042 {
1043 /* Check the parameters */
1044 Assert_Param(IS_MIDI(MIDIx));
1045 Assert_Param(IS_CONTROL_STATUS(NewState));
1046
1047 if (NewState != DISABLE)
1048 {
1049 MIDIx->CTRL |= MCUCHEN0_ENABLE;
1050 }
1051 else
1052 {
1053 MIDIx->CTRL &= MCUCHEN0_DISABLE;
1054 }
1055 }
1056
1057
1058 /*********************************************************************************************************//**
1059 * @brief Configure the DACDS for the selected MIDI.
1060 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
1061 * @param DACDS: specify the clipping and distorting volume of the MIDI.
1062 * @retval None
1063 ***********************************************************************************************************/
MIDI_CTRL_DACDS(HT_MIDI_TypeDef * MIDIx,u8 DACDS)1064 void MIDI_CTRL_DACDS(HT_MIDI_TypeDef* MIDIx, u8 DACDS)
1065 {
1066 /* Check the parameters */
1067 Assert_Param(IS_MIDI(MIDIx));
1068 Assert_Param(IS_MIDI_CTRL_DACDS(DACDS));
1069
1070 /* Clear DACDS[2:0] in CTRL */
1071 MIDIx->CTRL &= (u32)~MIDI_CTRL_DACDS_MASK;
1072
1073 /* Set new DACDS[2:0] in CTRL */
1074 MIDIx->CTRL |= (DACDS << 8);
1075 }
1076
1077 /*********************************************************************************************************//**
1078 * @brief Enable or Disable MUSIC Engine for the specified MIDI peripheral.
1079 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
1080 * @param NewState: new state of the MIDIx peripheral.
1081 * This parameter can be: ENABLE or DISABLE.
1082 * @retval None
1083 ***********************************************************************************************************/
MIDI_CTRL_MUSICENCmd(HT_MIDI_TypeDef * MIDIx,ControlStatus NewState)1084 void MIDI_CTRL_MUSICENCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState)
1085 {
1086 /* Check the parameters */
1087 Assert_Param(IS_MIDI(MIDIx));
1088 Assert_Param(IS_CONTROL_STATUS(NewState));
1089
1090 if (NewState != DISABLE)
1091 {
1092 MIDIx->CTRL |= MUSICEN_ENABLE;
1093 }
1094 else
1095 {
1096 MIDIx->CTRL &= MUSICEN_DISABLE;
1097 }
1098 }
1099
1100 /*********************************************************************************************************//**
1101 * @brief Enable or Disable SPI RDEN for the specified MIDI peripheral.
1102 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
1103 * @param NewState: new state of the MIDIx peripheral.
1104 * This parameter can be: ENABLE or DISABLE.
1105 * @retval None
1106 ***********************************************************************************************************/
MIDI_CTRL_SPIRDENCmd(HT_MIDI_TypeDef * MIDIx,ControlStatus NewState)1107 void MIDI_CTRL_SPIRDENCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState)
1108 {
1109 /* Check the parameters */
1110 Assert_Param(IS_MIDI(MIDIx));
1111 Assert_Param(IS_CONTROL_STATUS(NewState));
1112
1113 if (NewState != DISABLE)
1114 {
1115 MIDIx->CTRL |= SPIRDEN_ENABLE;
1116 }
1117 else
1118 {
1119 MIDIx->CTRL &= SPIRDEN_DISABLE;
1120 }
1121 }
1122
1123 /*********************************************************************************************************//**
1124 * @brief Enable or Disable SPI DISLOOP for the specified MIDI peripheral.
1125 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
1126 * @param NewState: new state of the MIDIx peripheral.
1127 * This parameter can be: ENABLE or DISABLE.
1128 * @retval None
1129 ***********************************************************************************************************/
MIDI_CTRL_SPIDISLOOPCmd(HT_MIDI_TypeDef * MIDIx,ControlStatus NewState)1130 void MIDI_CTRL_SPIDISLOOPCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState)
1131 {
1132 /* Check the parameters */
1133 Assert_Param(IS_MIDI(MIDIx));
1134 Assert_Param(IS_CONTROL_STATUS(NewState));
1135
1136 if (NewState != DISABLE)
1137 {
1138 MIDIx->CTRL |= SPIDISLOOP_ENABLE;
1139 }
1140 else
1141 {
1142 MIDIx->CTRL &= SPIDISLOOP_DISABLE;
1143 }
1144 }
1145
1146 /*********************************************************************************************************//**
1147 * @brief Configure the Channel Selection for the selected MIDI.
1148 * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals.
1149 * @param CHS: specify channel selection of the MIDI.
1150 * @retval None
1151 ***********************************************************************************************************/
MIDI_CTRL_CHS(HT_MIDI_TypeDef * MIDIx,u8 CHS)1152 void MIDI_CTRL_CHS(HT_MIDI_TypeDef* MIDIx, u8 CHS)
1153 {
1154 /* Check the parameters */
1155 Assert_Param(IS_MIDI(MIDIx));
1156 Assert_Param(IS_MIDI_CTRL_CHS(CHS));
1157
1158 /* Clear CHS[2:0] in CTRL */
1159 MIDIx->CTRL &= (u32)~MIDI_CTRL_CHS_MASK;
1160
1161 /* Set new CHS[2:0] in CTRL */
1162 MIDIx->CTRL |= CHS;
1163 }
1164
1165 /**
1166 * @}
1167 */
1168
1169
1170 /**
1171 * @}
1172 */
1173
1174 /**
1175 * @}
1176 */
1177