audioamp5  2.0.0.0
audioamp5.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef AUDIOAMP5_H
36 #define AUDIOAMP5_H
37 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 
51 // -------------------------------------------------------------- PUBLIC MACROS
61 #define AUDIOAMP5_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.mds= MIKROBUS( mikrobus, MIKROBUS_RST ); \
63  cfg.en= MIKROBUS( mikrobus, MIKROBUS_CS ); \
64  cfg.gs= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
65 
71 #define AUDIOAMP5_RETVAL uint8_t
72 
73 #define AUDIOAMP5_OK 0x00
74 #define AUDIOAMP5_INIT_ERROR 0xFF
75 
81 #define AUDIOAMP5_SHDWN_MUTE_OUTPUTS 0x00
82 #define AUDIOAMP5_PWRUP_UNMUTE_OUTPUTS 0x01
83 
89 #define AUDIOAMP5_BD_MODE 0x00
90 #define AUDIOAMP5_1SPW_MODE 0x01
91 
97 #define AUDIOAMP5_GAIN_20DB 0x00
98 #define AUDIOAMP5_GAIN_26DB 0x01
99  // End group macro
101 // --------------------------------------------------------------- PUBLIC TYPES
110 typedef struct
111 {
112  // Output pins
113 
114  digital_out_t mds;
115  digital_out_t en;
116  digital_out_t gs;
117 
118 } audioamp5_t;
119 
123 typedef struct
124 {
125  // Additional gpio pins
126 
127  pin_name_t mds;
128  pin_name_t en;
129  pin_name_t gs;
130 
132  // End types group
134 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
135 
141 #ifdef __cplusplus
142 extern "C"{
143 #endif
144 
154 
163 
172 
186 void audioamp5_set_device_state ( audioamp5_t *ctx, uint8_t state );
187 
196 void audioamp5_mode_select ( audioamp5_t *ctx, uint8_t state );
197 
206 void audioamp5_gain_select ( audioamp5_t *ctx, uint8_t state );
207 
216 
217 #ifdef __cplusplus
218 }
219 #endif
220 #endif // _AUDIOAMP5_H_
221  // End public_function group
224 
225 // ------------------------------------------------------------------------- END
audioamp5_set_device_state
void audioamp5_set_device_state(audioamp5_t *ctx, uint8_t state)
Default Configuration function.
audioamp5_init
AUDIOAMP5_RETVAL audioamp5_init(audioamp5_t *ctx, audioamp5_cfg_t *cfg)
Initialization function.
audioamp5_config_update
void audioamp5_config_update(audioamp5_t *ctx)
Configuration Update function.
audioamp5_cfg_setup
void audioamp5_cfg_setup(audioamp5_cfg_t *cfg)
Config Object Initialization function.
audioamp5_cfg_t
Click configuration structure definition.
Definition: audioamp5.h:124
AUDIOAMP5_RETVAL
#define AUDIOAMP5_RETVAL
Definition: audioamp5.h:71
audioamp5_t::en
digital_out_t en
Definition: audioamp5.h:115
audioamp5_t
Click ctx object definition.
Definition: audioamp5.h:111
audioamp5_gain_select
void audioamp5_gain_select(audioamp5_t *ctx, uint8_t state)
Gain Selection function.
audioamp5_mode_select
void audioamp5_mode_select(audioamp5_t *ctx, uint8_t state)
Mode Selection function.
audioamp5_cfg_t::mds
pin_name_t mds
Definition: audioamp5.h:127
audioamp5_cfg_t::gs
pin_name_t gs
Definition: audioamp5.h:129
audioamp5_default_cfg
void audioamp5_default_cfg(audioamp5_t *ctx)
Click Default Configuration function.
audioamp5_t::gs
digital_out_t gs
Definition: audioamp5.h:116
audioamp5_cfg_t::en
pin_name_t en
Definition: audioamp5.h:128
audioamp5_t::mds
digital_out_t mds
Definition: audioamp5.h:114