39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
74#define DTMF_CMD_GENERAL_RESET 0x01
75#define DTMF_CMD_GENERAL_CONTROL 0xE0
76#define DTMF_CMD_TRANSMIT_MODE 0xE1
77#define DTMF_CMD_RECEIVE_MODE 0xE2
78#define DTMF_CMD_TRANSMIT_DATA 0xE3
79#define DTMF_CMD_RECEIVE_DATA 0xE5
80#define DTMF_CMD_STATUS 0xE6
81#define DTMF_CMD_PROGRAMMING 0xE8
99#define DTMF_CONTROL_TXAN_OFF 0x8000u
100#define DTMF_CONTROL_TXA_OFF 0x4000u
101#define DTMF_CONTROL_LB 0x0800u
102#define DTMF_CONTROL_EQU 0x0400u
103#define DTMF_CONTROL_PWR 0x0100u
104#define DTMF_CONTROL_RST 0x0080u
105#define DTMF_CONTROL_IRQN_EN 0x0040u
106#define DTMF_CONTROL_IRQ_PROG_FLAG 0x0010u
107#define DTMF_CONTROL_IRQ_TX_RDY_UNF 0x0008u
108#define DTMF_CONTROL_IRQ_ENERGY_RX_CP 0x0004u
109#define DTMF_CONTROL_IRQ_CONT_10 0x0002u
110#define DTMF_CONTROL_IRQ_RX_RDY_OVF 0x0001u
111#define DTMF_CONTROL_IRQ_MASK 0x001Fu
117#define DTMF_TX_MODE_V21_FSK_HIGH 0x9000u
118#define DTMF_TX_MODE_V21_FSK_LOW 0x8000u
119#define DTMF_TX_MODE_BELL_103_FSK_HIGH 0x7000u
120#define DTMF_TX_MODE_BELL_103_FSK_LOW 0x6000u
121#define DTMF_TX_MODE_V23_FSK_1200 0x5000u
122#define DTMF_TX_MODE_V23_FSK_75 0x4000u
123#define DTMF_TX_MODE_BELL_202_FSK_1200 0x3000u
124#define DTMF_TX_MODE_BELL_202_FSK_150 0x2000u
125#define DTMF_TX_MODE_DTMF_TONES 0x1000u
126#define DTMF_TX_MODE_DISABLED 0x0000u
127#define DTMF_TX_MODE_MASK 0xF000u
128#define DTMF_TX_LEVEL_0_DB 0x0E00u
129#define DTMF_TX_LEVEL_MIN_1_5_DB 0x0C00u
130#define DTMF_TX_LEVEL_MIN_3_DB 0x0A00u
131#define DTMF_TX_LEVEL_MIN_4_5_DB 0x0800u
132#define DTMF_TX_LEVEL_MIN_6_DB 0x0600u
133#define DTMF_TX_LEVEL_MIN_7_5_DB 0x0400u
134#define DTMF_TX_LEVEL_MIN_9_DB 0x0200u
135#define DTMF_TX_LEVEL_MIN_10_5_DB 0x0000u
136#define DTMF_TX_LEVEL_MASK 0x0E00u
137#define DTMF_TX_DTMF_TWIST_2_DB 0x00E0u
138#define DTMF_TX_DTMF_TWIST_1_DB 0x00C0u
139#define DTMF_TX_DTMF_TWIST_1_5_DB 0x00A0u
140#define DTMF_TX_DTMF_TWIST_2_5_DB 0x0080u
141#define DTMF_TX_DTMF_TWIST_3_DB 0x0060u
142#define DTMF_TX_DTMF_TWIST_3_5_DB 0x0040u
143#define DTMF_TX_DTMF_TWIST_4_DB 0x0020u
144#define DTMF_TX_DTMF_TWIST_4_5_DB 0x0000u
145#define DTMF_TX_DTMF_TWIST_MASK 0x00E0u
146#define DTMF_TX_DATA_FORMAT_SYNC 0x0018u
147#define DTMF_TX_DATA_FORMAT_SS_NO_PAR 0x0010u
148#define DTMF_TX_DATA_FORMAT_SS_EVEN_PAR 0x0008u
149#define DTMF_TX_DATA_FORMAT_SS_ODD_PAR 0x0000u
150#define DTMF_TX_DATA_FORMAT_MASK 0x0018u
151#define DTMF_TX_DATA_STOP_8_2 0x0007u
152#define DTMF_TX_DATA_STOP_8_1 0x0006u
153#define DTMF_TX_DATA_STOP_7_2 0x0005u
154#define DTMF_TX_DATA_STOP_7_1 0x0004u
155#define DTMF_TX_DATA_STOP_6_2 0x0003u
156#define DTMF_TX_DATA_STOP_6_1 0x0002u
157#define DTMF_TX_DATA_STOP_5_2 0x0001u
158#define DTMF_TX_DATA_STOP_5_1 0x0000u
159#define DTMF_TX_DATA_STOP_MASK 0x0007u
160#define DTMF_TX_DATA_SOURCE_TX_BUF 0x0004u
161#define DTMF_TX_DATA_SOURCE_CONT_1S 0x0003u
162#define DTMF_TX_DATA_SOURCE_CONT_0S 0x0002u
163#define DTMF_TX_DATA_SOURCE_CONT_ALT 0x0000u
164#define DTMF_TX_DATA_SOURCE_MASK 0x0007u
165#define DTMF_TX_TONE_FIXED_NO_TONE 0x0000u
166#define DTMF_TX_TONE_FIXED_PAIR_697 0x0001u
167#define DTMF_TX_TONE_FIXED_PAIR_770 0x0002u
168#define DTMF_TX_TONE_FIXED_PAIR_852 0x0003u
169#define DTMF_TX_TONE_FIXED_PAIR_941 0x0004u
170#define DTMF_TX_TONE_FIXED_PAIR_1209 0x0005u
171#define DTMF_TX_TONE_FIXED_PAIR_1336 0x0006u
172#define DTMF_TX_TONE_FIXED_PAIR_1477 0x0007u
173#define DTMF_TX_TONE_FIXED_PAIR_1633 0x0008u
174#define DTMF_TX_TONE_FIXED_PAIR_1300 0x0009u
175#define DTMF_TX_TONE_FIXED_PAIR_2100 0x000Au
176#define DTMF_TX_TONE_FIXED_PAIR_2225 0x000Bu
177#define DTMF_TX_TONE_FIXED_PAIR_TA 0x000Cu
178#define DTMF_TX_TONE_FIXED_PAIR_TB 0x000Du
179#define DTMF_TX_TONE_FIXED_PAIR_TC 0x000Eu
180#define DTMF_TX_TONE_FIXED_PAIR_TD 0x000Fu
181#define DTMF_TX_TONE_D 0x0010u
182#define DTMF_TX_TONE_1 0x0011u
183#define DTMF_TX_TONE_2 0x0012u
184#define DTMF_TX_TONE_3 0x0013u
185#define DTMF_TX_TONE_4 0x0014u
186#define DTMF_TX_TONE_5 0x0015u
187#define DTMF_TX_TONE_6 0x0016u
188#define DTMF_TX_TONE_7 0x0017u
189#define DTMF_TX_TONE_8 0x0018u
190#define DTMF_TX_TONE_9 0x0019u
191#define DTMF_TX_TONE_0 0x001Au
192#define DTMF_TX_TONE_STAR 0x001Bu
193#define DTMF_TX_TONE_HASH 0x001Cu
194#define DTMF_TX_TONE_A 0x001Du
195#define DTMF_TX_TONE_B 0x001Eu
196#define DTMF_TX_TONE_C 0x001Fu
197#define DTMF_TX_TONE_MASK 0x001Fu
203#define DTMF_RX_MODE_V21_FSK_HIGH 0x9000u
204#define DTMF_RX_MODE_V21_FSK_LOW 0x8000u
205#define DTMF_RX_MODE_BELL_103_FSK_HIGH 0x7000u
206#define DTMF_RX_MODE_BELL_103_FSK_LOW 0x6000u
207#define DTMF_RX_MODE_V23_FSK_1200 0x5000u
208#define DTMF_RX_MODE_V23_FSK_75 0x4000u
209#define DTMF_RX_MODE_BELL_202_FSK_1200 0x3000u
210#define DTMF_RX_MODE_BELL_202_FSK_150 0x2000u
211#define DTMF_RX_MODE_DTMF_TONES 0x1000u
212#define DTMF_RX_MODE_DISABLED 0x0000u
213#define DTMF_RX_MODE_MASK 0xF000u
214#define DTMF_RX_LEVEL_0_DB 0x0E00u
215#define DTMF_RX_LEVEL_MIN_1_5_DB 0x0C00u
216#define DTMF_RX_LEVEL_MIN_3_DB 0x0A00u
217#define DTMF_RX_LEVEL_MIN_4_5_DB 0x0800u
218#define DTMF_RX_LEVEL_MIN_6_DB 0x0600u
219#define DTMF_RX_LEVEL_MIN_7_5_DB 0x0400u
220#define DTMF_RX_LEVEL_MIN_9_DB 0x0200u
221#define DTMF_RX_LEVEL_MIN_10_5_DB 0x0000u
222#define DTMF_RX_LEVEL_MASK 0x0E00u
223#define DTMF_RX_USART_SYNC 0x0038u
224#define DTMF_RX_USART_START_STOP 0x0030u
225#define DTMF_RX_USART_DISABLED 0x0000u
226#define DTMF_RX_USART_MASK 0x0038u
227#define DTMF_RX_DATA_PARITY_8_PAR 0x0007u
228#define DTMF_RX_DATA_PARITY_8_NO_PAR 0x0006u
229#define DTMF_RX_DATA_PARITY_7_PAR 0x0005u
230#define DTMF_RX_DATA_PARITY_7_NO_PAR 0x0004u
231#define DTMF_RX_DATA_PARITY_6_PAR 0x0003u
232#define DTMF_RX_DATA_PARITY_6_NO_PAR 0x0002u
233#define DTMF_RX_DATA_PARITY_5_PAR 0x0001u
234#define DTMF_RX_DATA_PARITY_5_NO_PAR 0x0000u
235#define DTMF_RX_DATA_PARITY_MASK 0x0007u
236#define DTMF_RX_TONE_DETECT_PROG_PAIR 0x0004u
237#define DTMF_RX_TONE_DETECT_CALL_PROG 0x0003u
238#define DTMF_RX_TONE_DETECT_ANSWER 0x0002u
239#define DTMF_RX_TONE_DETECT_DTMF 0x0001u
240#define DTMF_RX_TONE_DETECT_DISABLE 0x0007u
241#define DTMF_RX_TONE_DETECT_MASK 0x0007u
247#define DTMF_STATUS_IRQ 0x8000u
248#define DTMF_STATUS_PROG_FLAG 0x2000u
249#define DTMF_STATUS_TX_READY 0x1000u
250#define DTMF_STATUS_TX_UNDERFLOW 0x0800u
251#define DTMF_STATUS_ENERGY_RX_CP 0x0400u
252#define DTMF_STATUS_1010_PATTERN 0x0200u
253#define DTMF_STATUS_CONT_0S 0x0100u
254#define DTMF_STATUS_CONT_1S 0x0080u
255#define DTMF_STATUS_RX_READY 0x0040u
256#define DTMF_STATUS_RX_OVERFLOW 0x0020u
257#define DTMF_STATUS_RX_FRAMING_ERROR 0x0010u
258#define DTMF_STATUS_RX_EVEN_PARITY 0x0008u
259#define DTMF_STATUS_FSK_OUT 0x0001u
260#define DTMF_STATUS_TONE_D 0x0000u
261#define DTMF_STATUS_TONE_1 0x0001u
262#define DTMF_STATUS_TONE_2 0x0002u
263#define DTMF_STATUS_TONE_3 0x0003u
264#define DTMF_STATUS_TONE_4 0x0004u
265#define DTMF_STATUS_TONE_5 0x0005u
266#define DTMF_STATUS_TONE_6 0x0006u
267#define DTMF_STATUS_TONE_7 0x0007u
268#define DTMF_STATUS_TONE_8 0x0008u
269#define DTMF_STATUS_TONE_9 0x0009u
270#define DTMF_STATUS_TONE_0 0x000Au
271#define DTMF_STATUS_TONE_STAR 0x000Bu
272#define DTMF_STATUS_TONE_HASH 0x000Cu
273#define DTMF_STATUS_TONE_A 0x000Du
274#define DTMF_STATUS_TONE_B 0x000Eu
275#define DTMF_STATUS_TONE_C 0x000Fu
276#define DTMF_STATUS_TONE_MASK 0x000Fu
282#define DTMF_TIMEOUT_CLEAR_IRQ 2000u
283#define DTMF_TIMEOUT_TX_READY 2000u
284#define DTMF_TIMEOUT_CALL_PROGRESS 60000u
285#define DTMF_TIMING_BUSY 50u
286#define DTMF_TIMING_DISCONNECTED 250u
287#define DTMF_TIMING_RINGING 2000u
288#define DTMF_TIMING_CALL_PROGRESS 6000u
289#define DTMF_TIMING_SEND_MESSAGE 2000u
290#define DTMF_TIMING_RX_READY 10u
291#define DTMF_TIMING_WAIT_FOR_MESSAGE 10000u
297#define DTMF_STATE_IDLE 0
298#define DTMF_STATE_IRQ_SET 1
299#define DTMF_STATE_RINGING 2
300#define DTMF_STATE_CALL_IN_PROGRESS 3
306#define DTMF_DIAL_NUMBER_MAX_LEN 16
316#define DTMF_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
317#define DTMF_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
335#define DTMF_MAP_MIKROBUS( cfg, mikrobus ) \
336 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
337 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
338 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
339 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
340 cfg.rdn = MIKROBUS( mikrobus, MIKROBUS_AN ); \
341 cfg.hsw = MIKROBUS( mikrobus, MIKROBUS_RST ); \
342 cfg.irq = MIKROBUS( mikrobus, MIKROBUS_INT )
dtmf_return_value_t
DTMF Click return value data.
Definition dtmf.h:401
@ DTMF_TIMEOUT
Definition dtmf.h:404
@ DTMF_ERROR
Definition dtmf.h:403
@ DTMF_OK
Definition dtmf.h:402
err_t dtmf_send_message(dtmf_t *ctx, uint8_t *data_in, uint8_t len)
DTMF send message function.
err_t dtmf_init(dtmf_t *ctx, dtmf_cfg_t *cfg)
DTMF initialization function.
uint8_t dtmf_get_irq_pin(dtmf_t *ctx)
DTMF get irq pin function.
uint8_t dtmf_unscram_1s_det(dtmf_t *ctx)
DTMF unscram 1s det function.
uint8_t dtmf_rx_ready(dtmf_t *ctx)
DTMF rx ready function.
void dtmf_hook_off(dtmf_t *ctx)
DTMF hook off function.
err_t dtmf_set_control(dtmf_t *ctx, uint16_t data_in)
DTMF set control function.
err_t dtmf_dial(dtmf_t *ctx, uint8_t *dial_num)
DTMF dial function.
err_t dtmf_receive_data(dtmf_t *ctx, uint8_t *data_out)
DTMF receive data function.
void dtmf_cfg_setup(dtmf_cfg_t *cfg)
DTMF configuration object setup function.
uint8_t dtmf_tx_ready(dtmf_t *ctx)
DTMF tx ready function.
uint8_t dtmf_call_progress(dtmf_t *ctx)
DTMF call progress function.
err_t dtmf_clear_interrupts(dtmf_t *ctx)
DTMF clear interrupts function.
void dtmf_hook_on(dtmf_t *ctx)
DTMF hook on function.
err_t dtmf_set_receive_mode(dtmf_t *ctx, uint16_t data_in)
DTMF set receive mode function.
err_t dtmf_set_transmit_mode(dtmf_t *ctx, uint16_t data_in)
DTMF set transmit mode function.
err_t dtmf_transmit_data(dtmf_t *ctx, uint8_t data_in)
DTMF transmit data function.
err_t dtmf_set_programming(dtmf_t *ctx, uint16_t data_in)
DTMF set programming function.
void dtmf_set_hsw_pin(dtmf_t *ctx, uint8_t state)
DTMF set hsw pin function.
err_t dtmf_general_reset(dtmf_t *ctx)
DTMF general reset function.
uint8_t dtmf_get_rdn_pin(dtmf_t *ctx)
DTMF get rdn pin function.
err_t dtmf_get_status(dtmf_t *ctx, uint16_t *data_out)
DTMF get status function.
err_t dtmf_handshake_init(dtmf_t *ctx)
DTMF handshake init function.
This file contains SPI specific macros, functions, etc.
DTMF Click configuration object.
Definition dtmf.h:377
pin_name_t hsw
Definition dtmf.h:386
pin_name_t irq
Definition dtmf.h:387
spi_master_chip_select_polarity_t cs_polarity
Definition dtmf.h:392
pin_name_t sck
Definition dtmf.h:381
spi_master_mode_t spi_mode
Definition dtmf.h:391
pin_name_t rdn
Definition dtmf.h:385
pin_name_t mosi
Definition dtmf.h:380
uint32_t spi_speed
Definition dtmf.h:390
pin_name_t miso
Definition dtmf.h:379
pin_name_t cs
Definition dtmf.h:382
DTMF Click context object.
Definition dtmf.h:352
uint16_t control
Definition dtmf.h:365
spi_master_t spi
Definition dtmf.h:361
digital_in_t rdn
Definition dtmf.h:357
uint16_t status
Definition dtmf.h:368
digital_in_t irq
Definition dtmf.h:358
uint16_t tx_mode
Definition dtmf.h:366
uint16_t rx_mode
Definition dtmf.h:367
digital_out_t hsw
Definition dtmf.h:354
pin_name_t chip_select
Definition dtmf.h:363