dtmfgenerator  2.0.0.0
dtmfgenerator.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 DTMFGENERATOR_H
29 #define DTMFGENERATOR_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 #include "drv_digital_in.h"
51 
71 #define DTMFGENERATOR_OUT_TONE_0 0x00
72 #define DTMFGENERATOR_OUT_TONE_1 0x01
73 #define DTMFGENERATOR_OUT_TONE_2 0x02
74 #define DTMFGENERATOR_OUT_TONE_3 0x03
75 #define DTMFGENERATOR_OUT_TONE_4 0x04
76 #define DTMFGENERATOR_OUT_TONE_5 0x05
77 #define DTMFGENERATOR_OUT_TONE_6 0x06
78 #define DTMFGENERATOR_OUT_TONE_7 0x07
79 #define DTMFGENERATOR_OUT_TONE_8 0x08
80 #define DTMFGENERATOR_OUT_TONE_9 0x09
81 #define DTMFGENERATOR_OUT_TONE_A 0x0A
82 #define DTMFGENERATOR_OUT_TONE_B 0x0B
83 #define DTMFGENERATOR_OUT_TONE_C 0x0C
84 #define DTMFGENERATOR_OUT_TONE_D 0x0D
85 #define DTMFGENERATOR_OUT_TONE_ASTERISK 0x0E
86 #define DTMFGENERATOR_OUT_TONE_HASH 0x0F
87 #define DTMFGENERATOR_OUT_TONE_STOP 0x10
88 
89 #define DTMFGENERATOR_GPIO_PIN_STATE_LOW 0x00
90 #define DTMFGENERATOR_GPIO_PIN_STATE_HIGH 0x01
91  // dtmfgenerator_set
92 
107 #define DTMFGENERATOR_MAP_MIKROBUS( cfg, mikrobus ) \
108  cfg.dat = MIKROBUS( mikrobus, MIKROBUS_RST ); \
109  cfg.ce = MIKROBUS( mikrobus, MIKROBUS_CS ); \
110  cfg.clk = MIKROBUS( mikrobus, MIKROBUS_PWM )
111  // dtmfgenerator_map // dtmfgenerator
114 
119 typedef struct
120 {
121  digital_out_t dat;
122  digital_out_t ce;
123  digital_out_t clk;
126 
131 typedef struct
132 {
133  pin_name_t dat;
134  pin_name_t ce;
135  pin_name_t clk;
138 
143 typedef enum
144 {
147 
149 
166 
182 
191 void dtmfgenerator_set_dat ( dtmfgenerator_t *ctx, uint8_t pin_state );
192 
201 void dtmfgenerator_set_ce ( dtmfgenerator_t *ctx, uint8_t pin_state );
202 
211 void dtmfgenerator_set_clk ( dtmfgenerator_t *ctx, uint8_t pin_state );
212 
221 
232 void dtmfgenerator_transmit_out_tone ( dtmfgenerator_t *ctx, uint8_t out_tone, uint16_t delay_m_s );
233 
234 #ifdef __cplusplus
235 }
236 #endif
237 #endif // DTMFGENERATOR_H
238  // dtmfgenerator
240 
241 // ------------------------------------------------------------------------ END
dtmfgenerator_cfg_t
DTMF Generator Click configuration object.
Definition: dtmfgenerator.h:132
dtmfgenerator_cfg_t::clk
pin_name_t clk
Definition: dtmfgenerator.h:135
dtmfgenerator_set_dat
void dtmfgenerator_set_dat(dtmfgenerator_t *ctx, uint8_t pin_state)
Set DATA ( RST ) pin state function.
dtmfgenerator_t
DTMF Generator Click context object.
Definition: dtmfgenerator.h:120
DTMFGENERATOR_ERROR
@ DTMFGENERATOR_ERROR
Definition: dtmfgenerator.h:146
dtmfgenerator_t::ce
digital_out_t ce
Definition: dtmfgenerator.h:122
dtmfgenerator_set_clk
void dtmfgenerator_set_clk(dtmfgenerator_t *ctx, uint8_t pin_state)
Set CLK ( PWM ) pin state function.
dtmfgenerator_transmit_out_tone
void dtmfgenerator_transmit_out_tone(dtmfgenerator_t *ctx, uint8_t out_tone, uint16_t delay_m_s)
Transmit output tone function.
dtmfgenerator_cfg_t::dat
pin_name_t dat
Definition: dtmfgenerator.h:133
dtmfgenerator_set_ce
void dtmfgenerator_set_ce(dtmfgenerator_t *ctx, uint8_t pin_state)
Set CE ( CS ) pin state function.
dtmfgenerator_init
err_t dtmfgenerator_init(dtmfgenerator_t *ctx, dtmfgenerator_cfg_t *cfg)
DTMF Generator initialization function.
dtmfgenerator_power_on
void dtmfgenerator_power_on(dtmfgenerator_t *ctx)
Power ON function.
dtmfgenerator_t::dat
digital_out_t dat
Definition: dtmfgenerator.h:121
dtmfgenerator_cfg_setup
void dtmfgenerator_cfg_setup(dtmfgenerator_cfg_t *cfg)
DTMF Generator configuration object setup function.
dtmfgenerator_cfg_t::ce
pin_name_t ce
Definition: dtmfgenerator.h:134
dtmfgenerator_return_value_t
dtmfgenerator_return_value_t
DTMF Generator Click return value data.
Definition: dtmfgenerator.h:144
dtmfgenerator_t::clk
digital_out_t clk
Definition: dtmfgenerator.h:123
DTMFGENERATOR_OK
@ DTMFGENERATOR_OK
Definition: dtmfgenerator.h:145