dtmfdecoder  2.0.0.0
dtmfdecoder.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 DTMFDECODER_H
29 #define DTMFDECODER_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 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
65 #define DTMFDECODER_CMD_BYTE_INPUT 0x00
66 #define DTMFDECODER_CMD_BYTE_OUTPUT 0x01
67 #define DTMFDECODER_CMD_BYTE_POL_INV 0x02
68 #define DTMFDECODER_CMD_BYTE_CONFIG 0x03
69  // dtmfdecoder_cmd
71 
87 #define DTMFDECODER_SET_DEV_ADDR 0x41
88  // dtmfdecoder_set
90 
105 #define DTMFDECODER_MAP_MIKROBUS( cfg, mikrobus ) \
106  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
107  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
108  cfg.pwd = MIKROBUS( mikrobus, MIKROBUS_CS ); \
109  cfg.inh = MIKROBUS( mikrobus, MIKROBUS_RST ); \
110  cfg.std = MIKROBUS( mikrobus, MIKROBUS_INT )
111  // dtmfdecoder_map // dtmfdecoder
114 
119 typedef struct
120 {
121  // Output pins
122 
123  digital_out_t pwd;
124  digital_out_t inh;
126  // Input pins
127 
128  digital_in_t std;
130  // Modules
131 
132  i2c_master_t i2c;
134  // I2C slave address
135 
136  uint8_t slave_address;
138 } dtmfdecoder_t;
139 
144 typedef struct
145 {
146  pin_name_t scl;
147  pin_name_t sda;
149  pin_name_t pwd;
150  pin_name_t inh;
151  pin_name_t std;
153  uint32_t i2c_speed;
154  uint8_t i2c_address;
157 
162 typedef enum
163 {
165  DTMFDECODER_ERROR = -1
166 
168 
187 
205 
219 
237 err_t dtmfdecoder_generic_write ( dtmfdecoder_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
238 
256 err_t dtmfdecoder_generic_read ( dtmfdecoder_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
257 
269 
281 
293 
305 
318 
332 
333 #ifdef __cplusplus
334 }
335 #endif
336 #endif // DTMFDECODER_H
337  // dtmfdecoder
339 
340 // ------------------------------------------------------------------------ END
dtmfdecoder_init
err_t dtmfdecoder_init(dtmfdecoder_t *ctx, dtmfdecoder_cfg_t *cfg)
DTMF Decoder initialization function.
dtmfdecoder_cfg_t::inh
pin_name_t inh
Definition: dtmfdecoder.h:150
dtmfdecoder_tone_read
uint8_t dtmfdecoder_tone_read(dtmfdecoder_t *ctx)
DTMF Decoder read tone function.
dtmfdecoder_t::std
digital_in_t std
Definition: dtmfdecoder.h:128
dtmfdecoder_cfg_setup
void dtmfdecoder_cfg_setup(dtmfdecoder_cfg_t *cfg)
DTMF Decoder configuration object setup function.
dtmfdecoder_generic_write
err_t dtmfdecoder_generic_write(dtmfdecoder_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
DTMF Decoder I2C writing function.
dtmfdecoder_delayed_steering_check
uint8_t dtmfdecoder_delayed_steering_check(dtmfdecoder_t *ctx)
DTMF Decoder check delayed steering function.
dtmfdecoder_default_cfg
void dtmfdecoder_default_cfg(dtmfdecoder_t *ctx)
DTMF Decoder default configuration function.
dtmfdecoder_inhibit_on
void dtmfdecoder_inhibit_on(dtmfdecoder_t *ctx)
DTMF Decoder inhibit on function.
dtmfdecoder_cfg_t::pwd
pin_name_t pwd
Definition: dtmfdecoder.h:149
dtmfdecoder_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: dtmfdecoder.h:153
dtmfdecoder_t::pwd
digital_out_t pwd
Definition: dtmfdecoder.h:123
dtmfdecoder_inhibit_off
void dtmfdecoder_inhibit_off(dtmfdecoder_t *ctx)
DTMF Decoder inhibit off function.
dtmfdecoder_powerdown_on
void dtmfdecoder_powerdown_on(dtmfdecoder_t *ctx)
DTMF Decoder power down on function.
dtmfdecoder_cfg_t
DTMF Decoder Click configuration object.
Definition: dtmfdecoder.h:145
dtmfdecoder_t::slave_address
uint8_t slave_address
Definition: dtmfdecoder.h:136
dtmfdecoder_cfg_t::sda
pin_name_t sda
Definition: dtmfdecoder.h:147
DTMFDECODER_ERROR
@ DTMFDECODER_ERROR
Definition: dtmfdecoder.h:165
dtmfdecoder_t::inh
digital_out_t inh
Definition: dtmfdecoder.h:124
dtmfdecoder_powerdown_off
void dtmfdecoder_powerdown_off(dtmfdecoder_t *ctx)
DTMF Decoder power down off function.
dtmfdecoder_generic_read
err_t dtmfdecoder_generic_read(dtmfdecoder_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
DTMF Decoder I2C reading function.
dtmfdecoder_t
DTMF Decoder Click context object.
Definition: dtmfdecoder.h:120
dtmfdecoder_return_value_t
dtmfdecoder_return_value_t
DTMF Decoder Click return value data.
Definition: dtmfdecoder.h:163
dtmfdecoder_t::i2c
i2c_master_t i2c
Definition: dtmfdecoder.h:132
dtmfdecoder_cfg_t::scl
pin_name_t scl
Definition: dtmfdecoder.h:146
dtmfdecoder_cfg_t::std
pin_name_t std
Definition: dtmfdecoder.h:151
DTMFDECODER_OK
@ DTMFDECODER_OK
Definition: dtmfdecoder.h:164
dtmfdecoder_cfg_t::i2c_address
uint8_t i2c_address
Definition: dtmfdecoder.h:154