dsp  2.0.0.0
dsp.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef DSP_H
29 #define DSP_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 
52 #define DSP_SET_EFFECT_MEDIUM 0x00
53 #define DSP_SET_EFFECT_CHAMBR7B 0x01
54 #define DSP_SET_EFFECT_ROOM3B 0x02
55 #define DSP_SET_EFFECT_CHAMBER2 0x03
56 #define DSP_SET_EFFECT_REVERS3B 0x04
57 #define DSP_SET_EFFECT_GATED4B 0x05
58 #define DSP_SET_EFFECT_ROOM2A 0x06
59 #define DSP_SET_EFFECT_SPRING3B 0x07
60 #define DSP_SET_EFFECT_PHASER1 0x08
61 #define DSP_SET_EFFECT_FLANGER2 0x09
62 #define DSP_SET_EFFECT_DELAY7 0x0A
63 #define DSP_SET_EFFECT_CHORUS4 0x0B
64 #define DSP_SET_EFFECT_EARLREF4 0x0C
65 #define DSP_SET_EFFECT_AMB4 0x0D
66 #define DSP_SET_EFFECT_DELAY3 0x0E
67 #define DSP_SET_EFFECT_DELAY1 0x0F
68  // effects
70 
80 #define DSP_SET_PIN_STATE_LOW 0x00
81 #define DSP_SET_PIN_STATE_HIGH 0x01
82  // pin_state
84 
94 #define dsp_retval_t uint8_t
95 
96 #define DSP_OK 0x00
97 #define DSP_ERROR 0xFF
98  // dsp_retval_t
100 
101 
116 #define DSP_MAP_MIKROBUS( cfg, mikrobus ) \
117  cfg.p0 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
118  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
119  cfg.p1 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
120  cfg.p3 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
121  cfg.p2 = MIKROBUS( mikrobus, MIKROBUS_INT )
122  // dsp_map // dsp
125 
130 typedef struct
131 {
132  digital_out_t p0;
133  digital_out_t rst;
134  digital_out_t p1;
135  digital_out_t p3;
136  digital_out_t p2;
138 } dsp_t;
139 
144 typedef struct
145 {
146  pin_name_t p0;
147  pin_name_t rst;
148  pin_name_t p1;
149  pin_name_t p3;
150  pin_name_t p2;
152 } dsp_cfg_t;
153 
169 void dsp_cfg_setup ( dsp_cfg_t *cfg );
170 
185 err_t dsp_init ( dsp_t *ctx, dsp_cfg_t *cfg );
186 
197 void dsp_default_cfg ( dsp_t *ctx );
198 
211 void dsp_pin_set_p0 ( dsp_t *ctx, uint8_t pin_state );
212 
225 void dsp_pin_set_p1 ( dsp_t *ctx, uint8_t pin_state );
226 
239 void dsp_pin_set_p2 ( dsp_t *ctx, uint8_t pin_state );
240 
253 void dsp_pin_set_p3 ( dsp_t *ctx, uint8_t pin_state );
254 
264 void dsp_power_on ( dsp_t *ctx );
265 
275 void dsp_reset ( dsp_t *ctx );
276 
304 dsp_retval_t dsp_set_effect ( dsp_t *ctx, uint8_t effects );
305 
306 #ifdef __cplusplus
307 }
308 #endif
309 #endif // DSP_H
310  // dsp
312 
313 // ------------------------------------------------------------------------ END
dsp_pin_set_p0
void dsp_pin_set_p0(dsp_t *ctx, uint8_t pin_state)
DSP P0 pin setting function.
dsp_init
err_t dsp_init(dsp_t *ctx, dsp_cfg_t *cfg)
DSP initialization function.
dsp_set_effect
dsp_retval_t dsp_set_effect(dsp_t *ctx, uint8_t effects)
DSP reverb and multi-effects setting function.
dsp_pin_set_p1
void dsp_pin_set_p1(dsp_t *ctx, uint8_t pin_state)
DSP P1 pin setting function.
dsp_reset
void dsp_reset(dsp_t *ctx)
DSP reset the device function.
dsp_cfg_setup
void dsp_cfg_setup(dsp_cfg_t *cfg)
DSP configuration object setup function.
dsp_default_cfg
void dsp_default_cfg(dsp_t *ctx)
DSP default configuration function.
dsp_pin_set_p3
void dsp_pin_set_p3(dsp_t *ctx, uint8_t pin_state)
DSP P3 pin setting function.
dsp_power_on
void dsp_power_on(dsp_t *ctx)
DSP power on the device function.
dsp_cfg_t
DSP Click configuration object.
Definition: dsp.h:143
dsp_retval_t
#define dsp_retval_t
DSP error code settings.
Definition: dsp.h:93
dsp_pin_set_p2
void dsp_pin_set_p2(dsp_t *ctx, uint8_t pin_state)
DSP P2 pin setting function.
dsp_t
DSP Click context object.
Definition: dsp.h:129