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 
39 #ifdef PREINIT_SUPPORTED
40 #include "preinit.h"
41 #endif
42 
43 #ifdef MikroCCoreVersion
44  #if MikroCCoreVersion >= 1
45  #include "delays.h"
46  #endif
47 #endif
48 
49 #include "drv_digital_out.h"
50 
71 #define SPEAKER_MAP_MIKROBUS( cfg, mikrobus ) \
72  cfg.pwr = MIKROBUS( mikrobus, MIKROBUS_INT ); \
73  cfg.sb = MIKROBUS( mikrobus, MIKROBUS_PWM )
74  // speaker_map // speaker
77 
82 typedef struct
83 {
84  digital_out_t pwr;
85  digital_out_t sb;
87 } speaker_t;
88 
93 typedef struct
94 {
95  pin_name_t pwr;
96  pin_name_t sb;
99 
104 typedef enum
105 {
107  SPEAKER_ERROR = -1
108 
110 
127 
142 err_t speaker_init ( speaker_t *ctx, speaker_cfg_t *cfg );
143 
158 
172 
186 
200 
214 
215 #ifdef __cplusplus
216 }
217 #endif
218 #endif // SPEAKER_H
219  // speaker
221 
222 // ------------------------------------------------------------------------ END
speaker_cfg_t
Speaker Click configuration object.
Definition: speaker.h:94
speaker_cfg_t::pwr
pin_name_t pwr
Definition: speaker.h:95
speaker_return_value_t
speaker_return_value_t
Speaker Click return value data.
Definition: speaker.h:105
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_t::sb
digital_out_t sb
Definition: speaker.h:85
speaker_init
err_t speaker_init(speaker_t *ctx, speaker_cfg_t *cfg)
Speaker initialization function.
SPEAKER_ERROR
@ SPEAKER_ERROR
Definition: speaker.h:107
speaker_t::pwr
digital_out_t pwr
Definition: speaker.h:84
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:83
SPEAKER_OK
@ SPEAKER_OK
Definition: speaker.h:106
speaker_cfg_t::sb
pin_name_t sb
Definition: speaker.h:96