speaker  2.0.0.0
speaker.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 SPEAKER_H
29 #define SPEAKER_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 
57 #define SPEAKER_MAP_MIKROBUS( cfg, mikrobus ) \
58  cfg.pwr = MIKROBUS( mikrobus, MIKROBUS_INT ); \
59  cfg.sb = MIKROBUS( mikrobus, MIKROBUS_PWM )
60  // speaker_map // speaker
63 
68 typedef struct
69 {
70  digital_out_t pwr;
71  digital_out_t sb;
73 } speaker_t;
74 
79 typedef struct
80 {
81  pin_name_t pwr;
82  pin_name_t sb;
85 
90 typedef enum
91 {
93  SPEAKER_ERROR = -1
94 
96 
112 void speaker_cfg_setup ( speaker_cfg_t *cfg );
113 
128 err_t speaker_init ( speaker_t *ctx, speaker_cfg_t *cfg );
129 
143 err_t speaker_default_cfg ( speaker_t *ctx );
144 
157 err_t speaker_enable_slave_amp ( speaker_t *ctx );
158 
171 err_t speaker_disable_slave_amp ( speaker_t *ctx );
172 
185 err_t speaker_shutdown ( speaker_t *ctx );
186 
199 err_t speaker_normal_operation ( speaker_t *ctx );
200 
201 #ifdef __cplusplus
202 }
203 #endif
204 #endif // SPEAKER_H
205  // speaker
207 
208 // ------------------------------------------------------------------------ END
speaker_cfg_t
Speaker Click configuration object.
Definition: speaker.h:78
speaker_return_value_t
speaker_return_value_t
Speaker Click return value data.
Definition: speaker.h:89
speaker_enable_slave_amp
err_t speaker_enable_slave_amp(speaker_t *ctx)
Speaker enables the slave amplifier function.
speaker_default_cfg
err_t speaker_default_cfg(speaker_t *ctx)
Speaker default configuration function.
speaker_normal_operation
err_t speaker_normal_operation(speaker_t *ctx)
Speaker normal operation mode function.
speaker_init
err_t speaker_init(speaker_t *ctx, speaker_cfg_t *cfg)
Speaker initialization function.
SPEAKER_ERROR
Definition: speaker.h:92
speaker_cfg_setup
void speaker_cfg_setup(speaker_cfg_t *cfg)
Speaker configuration object setup function.
speaker_shutdown
err_t speaker_shutdown(speaker_t *ctx)
Speaker shutdown mode function.
speaker_disable_slave_amp
err_t speaker_disable_slave_amp(speaker_t *ctx)
Speaker disables the slave amplifier function.
speaker_t
Speaker Click context object.
Definition: speaker.h:67
SPEAKER_OK
Definition: speaker.h:91