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 "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 
67 #define SPEAKER_MAP_MIKROBUS( cfg, mikrobus ) \
68  cfg.pwr = MIKROBUS( mikrobus, MIKROBUS_INT ); \
69  cfg.sb = MIKROBUS( mikrobus, MIKROBUS_PWM )
70  // speaker_map // speaker
73 
78 typedef struct
79 {
80  digital_out_t pwr;
81  digital_out_t sb;
83 } speaker_t;
84 
89 typedef struct
90 {
91  pin_name_t pwr;
92  pin_name_t sb;
95 
100 typedef enum
101 {
103  SPEAKER_ERROR = -1
104 
106 
123 
138 err_t speaker_init ( speaker_t *ctx, speaker_cfg_t *cfg );
139 
154 
168 
182 
196 
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 #endif // SPEAKER_H
215  // speaker
217 
218 // ------------------------------------------------------------------------ END
speaker_cfg_t
Speaker Click configuration object.
Definition: speaker.h:90
speaker_cfg_t::pwr
pin_name_t pwr
Definition: speaker.h:91
speaker_return_value_t
speaker_return_value_t
Speaker Click return value data.
Definition: speaker.h:101
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:81
speaker_init
err_t speaker_init(speaker_t *ctx, speaker_cfg_t *cfg)
Speaker initialization function.
SPEAKER_ERROR
@ SPEAKER_ERROR
Definition: speaker.h:103
speaker_t::pwr
digital_out_t pwr
Definition: speaker.h:80
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:79
SPEAKER_OK
@ SPEAKER_OK
Definition: speaker.h:102
speaker_cfg_t::sb
pin_name_t sb
Definition: speaker.h:92