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 "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 
62 #define DSP_SET_EFFECT_MEDIUM 0x00
63 #define DSP_SET_EFFECT_CHAMBR7B 0x01
64 #define DSP_SET_EFFECT_ROOM3B 0x02
65 #define DSP_SET_EFFECT_CHAMBER2 0x03
66 #define DSP_SET_EFFECT_REVERS3B 0x04
67 #define DSP_SET_EFFECT_GATED4B 0x05
68 #define DSP_SET_EFFECT_ROOM2A 0x06
69 #define DSP_SET_EFFECT_SPRING3B 0x07
70 #define DSP_SET_EFFECT_PHASER1 0x08
71 #define DSP_SET_EFFECT_FLANGER2 0x09
72 #define DSP_SET_EFFECT_DELAY7 0x0A
73 #define DSP_SET_EFFECT_CHORUS4 0x0B
74 #define DSP_SET_EFFECT_EARLREF4 0x0C
75 #define DSP_SET_EFFECT_AMB4 0x0D
76 #define DSP_SET_EFFECT_DELAY3 0x0E
77 #define DSP_SET_EFFECT_DELAY1 0x0F
78  // effects
80 
90 #define DSP_SET_PIN_STATE_LOW 0x00
91 #define DSP_SET_PIN_STATE_HIGH 0x01
92  // pin_state
94 
104 #define dsp_retval_t uint8_t
105 
106 #define DSP_OK 0x00
107 #define DSP_ERROR 0xFF
108  // dsp_retval_t
110 
111 
126 #define DSP_MAP_MIKROBUS( cfg, mikrobus ) \
127  cfg.p0 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
128  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
129  cfg.p1 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
130  cfg.p3 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
131  cfg.p2 = MIKROBUS( mikrobus, MIKROBUS_INT )
132  // dsp_map // dsp
135 
140 typedef struct
141 {
142  digital_out_t p0;
143  digital_out_t rst;
144  digital_out_t p1;
145  digital_out_t p3;
146  digital_out_t p2;
148 } dsp_t;
149 
154 typedef struct
155 {
156  pin_name_t p0;
157  pin_name_t rst;
158  pin_name_t p1;
159  pin_name_t p3;
160  pin_name_t p2;
162 } dsp_cfg_t;
163 
179 void dsp_cfg_setup ( dsp_cfg_t *cfg );
180 
195 err_t dsp_init ( dsp_t *ctx, dsp_cfg_t *cfg );
196 
207 void dsp_default_cfg ( dsp_t *ctx );
208 
221 void dsp_pin_set_p0 ( dsp_t *ctx, uint8_t pin_state );
222 
235 void dsp_pin_set_p1 ( dsp_t *ctx, uint8_t pin_state );
236 
249 void dsp_pin_set_p2 ( dsp_t *ctx, uint8_t pin_state );
250 
263 void dsp_pin_set_p3 ( dsp_t *ctx, uint8_t pin_state );
264 
274 void dsp_power_on ( dsp_t *ctx );
275 
285 void dsp_reset ( dsp_t *ctx );
286 
314 dsp_retval_t dsp_set_effect ( dsp_t *ctx, uint8_t effects );
315 
316 #ifdef __cplusplus
317 }
318 #endif
319 #endif // DSP_H
320  // dsp
322 
323 // ------------------------------------------------------------------------ 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_t::p0
digital_out_t p0
Definition: dsp.h:142
dsp_set_effect
dsp_retval_t dsp_set_effect(dsp_t *ctx, uint8_t effects)
DSP reverb and multi-effects setting function.
dsp_cfg_t::rst
pin_name_t rst
Definition: dsp.h:157
dsp_t::p3
digital_out_t p3
Definition: dsp.h:145
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_t::p1
pin_name_t p1
Definition: dsp.h:158
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::p2
pin_name_t p2
Definition: dsp.h:160
dsp_cfg_t::p0
pin_name_t p0
Definition: dsp.h:156
dsp_t::rst
digital_out_t rst
Definition: dsp.h:143
dsp_cfg_t::p3
pin_name_t p3
Definition: dsp.h:159
dsp_t::p1
digital_out_t p1
Definition: dsp.h:144
dsp_cfg_t
DSP Click configuration object.
Definition: dsp.h:155
dsp_t::p2
digital_out_t p2
Definition: dsp.h:146
dsp_retval_t
#define dsp_retval_t
DSP error code settings.
Definition: dsp.h:104
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:141