audioamp6  2.0.0.0
audioamp6.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 AUDIOAMP6_H
36 #define AUDIOAMP6_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 
50 // -------------------------------------------------------------- PUBLIC MACROS
60 #define AUDIOAMP6_MAP_MIKROBUS( cfg, mikrobus ) \
61  cfg.mds= MIKROBUS( mikrobus, MIKROBUS_RST ); \
62  cfg.en= MIKROBUS( mikrobus, MIKROBUS_CS ); \
63  cfg.gs= MIKROBUS( mikrobus, MIKROBUS_PWM );
64 
70 #define AUDIOAMP6_RETVAL uint8_t
71 
72 #define AUDIOAMP6_OK 0x00
73 #define AUDIOAMP6_INIT_ERROR 0xFF
74 
80 #define AUDIOAMP6_GAIN_20dB 0x00
81 #define AUDIOAMP6_GAIN_26dB 0x01
82 
88 #define AUDIOAMP6_OUTPUT_ENABLE 0x01
89 #define AUDIOAMP6_OUTPUT_DISABLE 0x00
90 
96 #define AUDIOAMP6_MODE_BD 0x00
97 #define AUDIOAMP6_MODE_1SPW 0x01
98  // 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 } audioamp6_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 
135 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
136 
142 #ifdef __cplusplus
143 extern "C"{
144 #endif
145 
155 
164 
175 void audioamp6_set_mode( audioamp6_t *ctx, uint8_t mode );
176 
183 void audioamp6_set_output( audioamp6_t *ctx, uint8_t out );
184 
191 void audioamp6_set_gain( audioamp6_t *ctx, uint8_t gain );
192 
193 #ifdef __cplusplus
194 }
195 #endif
196 #endif // _AUDIOAMP6_H_
197  // End public_function group
200 
201 // ------------------------------------------------------------------------- END
audioamp6_cfg_setup
void audioamp6_cfg_setup(audioamp6_cfg_t *cfg)
Config Object Initialization function.
audioamp6_cfg_t::en
pin_name_t en
Definition: audioamp6.h:128
audioamp6_cfg_t::mds
pin_name_t mds
Definition: audioamp6.h:127
audioamp6_set_mode
void audioamp6_set_mode(audioamp6_t *ctx, uint8_t mode)
Sets mode.
audioamp6_t::en
digital_out_t en
Definition: audioamp6.h:115
audioamp6_set_output
void audioamp6_set_output(audioamp6_t *ctx, uint8_t out)
Enable or Disable output.
audioamp6_t::gs
digital_out_t gs
Definition: audioamp6.h:116
audioamp6_t::mds
digital_out_t mds
Definition: audioamp6.h:114
audioamp6_cfg_t
Click configuration structure definition.
Definition: audioamp6.h:124
audioamp6_cfg_t::gs
pin_name_t gs
Definition: audioamp6.h:129
audioamp6_t
Click ctx object definition.
Definition: audioamp6.h:111
audioamp6_set_gain
void audioamp6_set_gain(audioamp6_t *ctx, uint8_t gain)
Sets Gain.
AUDIOAMP6_RETVAL
#define AUDIOAMP6_RETVAL
Definition: audioamp6.h:70
audioamp6_init
AUDIOAMP6_RETVAL audioamp6_init(audioamp6_t *ctx, audioamp6_cfg_t *cfg)
Initialization function.