Go to the documentation of this file.
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
38 #include "drv_i2c_master.h"
39 #include "drv_spi_master.h"
62 #define SMARTMIC_NO_RESPONSE_BIT 0x1000
63 #define SMARTMIC_CMD_SYNC 0x8000
64 #define SMARTMIC_CMD_SET_AUDIO_DATA_PORT 0x8004
65 #define SMARTMIC_CMD_GET_DEVICE_PARAM 0x800B
66 #define SMARTMIC_CMD_SET_DEVICE_PARAM_ID 0x800C
67 #define SMARTMIC_CMD_SET_DEVICE_PARAM 0x800D
68 #define SMARTMIC_CMD_GET_CHIP_ID 0x800E
69 #define SMARTMIC_CMD_SET_POWER_STATE ( 0x8010 | SMARTMIC_NO_RESPONSE_BIT )
70 #define SMARTMIC_CMD_SET_CLOCK_SOURCE 0x8011
71 #define SMARTMIC_CMD_SET_UART_STOP_BITS 0x8012
72 #define SMARTMIC_CMD_GET_SIG_RMS 0x8013
73 #define SMARTMIC_CMD_GET_SIG_PEAK 0x8014
74 #define SMARTMIC_CMD_SET_DIG_GAIN 0x8015
75 #define SMARTMIC_CMD_GET_ALGO_PARAM 0x8016
76 #define SMARTMIC_CMD_SET_ALGO_PARAM_ID 0x8017
77 #define SMARTMIC_CMD_SET_ALGO_PARAM 0x8018
78 #define SMARTMIC_CMD_UART_RATE_REQUEST 0x8019
79 #define SMARTMIC_CMD_SET_EVENT_RESP 0x801A
80 #define SMARTMIC_CMD_SET_DIAG_CONFIG 0x801C
81 #define SMARTMIC_CMD_GET_DIG_GAIN 0x801D
82 #define SMARTMIC_CMD_OUTPUT_KNOWN_SIG 0x801E
83 #define SMARTMIC_CMD_GET_FIRST_BUILD_STR 0x8020
84 #define SMARTMIC_CMD_GET_NEXT_BUILD_STR 0x8021
85 #define SMARTMIC_CMD_GET_INFO 0x8022
86 #define SMARTMIC_CMD_SET_SPI_SAMPLE_CFG 0x8023
87 #define SMARTMIC_CMD_SET_STREAMING 0x8025
88 #define SMARTMIC_CMD_GET_BAF_INFO 0x8027
89 #define SMARTMIC_CMD_SELECT_STREAMING 0x8028
90 #define SMARTMIC_CMD_CONFIG_DATA_PORT 0x802C
91 #define SMARTMIC_CMD_READ_DATA_BLOCK 0x802E
92 #define SMARTMIC_CMD_WRITE_DATA_BLOCK 0x802F
93 #define SMARTMIC_CMD_SET_SAMPLE_RATE 0x8030
94 #define SMARTMIC_CMD_SET_PRESET 0x8031
95 #define SMARTMIC_CMD_SELECT_ROUTE 0x8032
96 #define SMARTMIC_CMD_STOP_ROUTE 0x8033
97 #define SMARTMIC_CMD_SET_BUFF_DATA_FORMAT 0x8034
98 #define SMARTMIC_CMD_SET_FRAME_SIZE 0x8035
99 #define SMARTMIC_CMD_PDM_BYPASS_MODE 0x8040
100 #define SMARTMIC_CMD_SET_AUDIO_PORT_CLK_F 0x8042
101 #define SMARTMIC_CMD_POWER_DOWN_INT_OSC 0x8043
102 #define SMARTMIC_CMD_SET_DIG_HW_PT 0x8052
103 #define SMARTMIC_CMD_ENABLE_DISABLE_JTAG 0x8061
104 #define SMARTMIC_CMD_SET_PAD_CONTROL 0x8062
105 #define SMARTMIC_CMD_GET_EVENT 0x806D
123 #define SMARTMIC_VQ_CMD_VS_PROCESSING_MODE 0x5003
124 #define SMARTMIC_VQ_CMD_OEM_SENSITIVITY 0x5008
125 #define SMARTMIC_VQ_CMD_UTK_SENSITIVITY 0x5009
126 #define SMARTMIC_VQ_CMD_VID_SENSITIVITY 0x500D
127 #define SMARTMIC_VQ_CMD_RESET 0x500E
133 #define SMARTMIC_VS_PROCESSING_MODE_KW 0x0000 // Keyword Detection mode
134 #define SMARTMIC_OEM_SENSITIVITY_5 0x0005 // Set the OEM Detection Sensitivity to 5
135 #define SMARTMIC_UTK_SENSITIVITY_0 0x0000 // Set the UTK Detection Sensitivity to 0
136 #define SMARTMIC_VID_SENSITIVITY_2 0x0002 // Set the Voice ID Detection Sensitivity to 0
137 #define SMARTMIC_RESET 0x0001 // Perform reset
143 #define SMARTMIC_SYNC_BYTE 0xB7
144 #define SMARTMIC_BOOT_BYTE 0x01
145 #define SMARTMIC_SAMPLE_RATE_16K 0x0001 // 16k Sample Rate
146 #define SMARTMIC_FRAME_SIZE_16MS 0x0010 // For Voice Q 16 mS Frame Size
147 #define SMARTMIC_BUFF_DATA_FORMAT_16BIT 0x0002 // 16 bit Buffer Data Format
148 #define SMARTMIC_ROUTE_6 0x0006 // Select Route 6
149 #define SMARTMIC_DIGITAL_GAIN_20 0x0C14 // 20 db Gain and End point ID = 12
150 #define SMARTMIC_END_POINT_ID 0x0C00 // Endpoint ID for Route-6 Stream manager-0
151 #define SMARTMIC_LOW_POWER_MODE_RT6 0x0002 // Low Power mode for Route 6
152 #define SMARTMIC_IA611_INT_RISING_EDGE 0x04
153 #define SMARTMIC_IA611_INT_FALLING_EDGE 0x03
154 #define SMARTMIC_IA611_INT_LOW_LEVEL 0x01
155 #define SMARTMIC_WDB_SIZE_NO_HEADER 508 // Data block size without 4 byte Header
156 #define SMARTMIC_WDB_SIZE 512 // Data block size with 4 byte Header
157 #define SMARTMIC_UART_EVENT_HEADER 0xFE
158 #define SMARTMIC_NO_KWD_DETECTED 0
159 #define SMARTMIC_OEM1_KWD_DETECTED 1
160 #define SMARTMIC_OEM2_KWD_DETECTED 2
161 #define SMARTMIC_OEM3_KWD_DETECTED 3
162 #define SMARTMIC_OEM4_KWD_DETECTED 4
168 #define SMARTMIC_DRIVER_UART 0
169 #define SMARTMIC_DRIVER_SPI 1
170 #define SMARTMIC_DRIVER_I2C 2
171 #define SMARTMIC_DRIVER_SELECTOR SMARTMIC_DRIVER_I2C
177 #define SMARTMIC_SYS_CFG_6SEC_TO 0
178 #define SMARTMIC_SYS_CFG_6SEC_TO_UTK 1
179 #define SMARTMIC_SYS_CFG_6SEC_TO_VID 2
180 #define SMARTMIC_SYS_CFG_SELECTOR SMARTMIC_SYS_CFG_6SEC_TO
187 #define SMARTMIC_DEVICE_ADDRESS_0 0x3E
188 #define SMARTMIC_DEVICE_ADDRESS_1 0x3F
189 #define SMARTMIC_DEVICE_ADDRESS_2 0x38
190 #define SMARTMIC_DEVICE_ADDRESS_3 0x39
200 #define SMARTMIC_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
201 #define SMARTMIC_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
208 #define DRV_BUFFER_SIZE 256
226 #define SMARTMIC_MAP_MIKROBUS( cfg, mikrobus ) \
227 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
228 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
229 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
230 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
231 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
232 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
233 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
234 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
235 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
236 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
251 #if ( SMARTMIC_DRIVER_SELECTOR == SMARTMIC_DRIVER_UART )
255 #elif ( SMARTMIC_DRIVER_SELECTOR == SMARTMIC_DRIVER_I2C )
260 pin_name_t chip_select;
282 #if ( SMARTMIC_DRIVER_SELECTOR == SMARTMIC_DRIVER_UART )
285 uart_data_bits_t data_bit;
286 uart_parity_t parity_bit;
287 uart_stop_bits_t stop_bit;
288 #elif ( SMARTMIC_DRIVER_SELECTOR == SMARTMIC_DRIVER_I2C )
293 spi_master_mode_t spi_mode;
294 spi_master_chip_select_polarity_t cs_polarity;
@ SMARTMIC_OK
Definition: smartmic.h:305
void smartmic_cfg_setup(smartmic_cfg_t *cfg)
Smart Mic configuration object setup function.
Smart Mic Click configuration object.
Definition: smartmic.h:270
err_t smartmic_download_config(smartmic_t *ctx)
Smart Mic download config function.
err_t smartmic_write_data(smartmic_t *ctx, uint8_t *data_in, uint16_t len)
Smart Mic write data function.
digital_in_t irq
Definition: smartmic.h:249
uint8_t slave_address
Definition: smartmic.h:257
This file contains SPI specific macros, functions, etc.
pin_name_t miso
Definition: smartmic.h:275
pin_name_t en
Definition: smartmic.h:279
err_t smartmic_send_command(smartmic_t *ctx, uint16_t cmd, uint16_t data_in, uint16_t *response)
Smart Mic send command function.
pin_name_t sck
Definition: smartmic.h:277
err_t smartmic_download_firmware(smartmic_t *ctx)
Smart Mic download firmware function.
err_t smartmic_download_keyword(smartmic_t *ctx, uint16_t *data_in, uint16_t len)
Smart Mic download keyword function.
pin_name_t tx_pin
Definition: smartmic.h:272
Smart Mic Click context object.
Definition: smartmic.h:246
pin_name_t int_pin
Definition: smartmic.h:280
pin_name_t cs
Definition: smartmic.h:278
pin_name_t mosi
Definition: smartmic.h:276
@ SMARTMIC_FIRMWARE_OK
Definition: smartmic.h:307
struct smartmic_s smartmic_t
Smart Mic Click context object.
err_t smartmic_init(smartmic_t *ctx, smartmic_cfg_t *cfg)
Smart Mic initialization function.
pin_name_t sda
Definition: smartmic.h:274
err_t smartmic_download_bin(smartmic_t *ctx, uint8_t *data_in, uint32_t len)
Smart Mic download bin function.
err_t smartmic_wait_keyword(smartmic_t *ctx)
Smart Mic wait keyword function.
@ SMARTMIC_ERROR
Definition: smartmic.h:306
void smartmic_enable_device(smartmic_t *ctx)
Smart Mic enable device function.
pin_name_t scl
Definition: smartmic.h:273
uint32_t i2c_speed
Definition: smartmic.h:289
pin_name_t rx_pin
Definition: smartmic.h:271
void smartmic_disable_device(smartmic_t *ctx)
Smart Mic disable device function.
i2c_master_t i2c
Definition: smartmic.h:256
err_t smartmic_default_cfg(smartmic_t *ctx)
Smart Mic default configuration function.
digital_out_t en
Definition: smartmic.h:247
smartmic_return_value_t
Smart Mic Click return value data.
Definition: smartmic.h:304
err_t smartmic_voice_make(smartmic_t *ctx)
Smart Mic voice make function.
uint8_t i2c_address
Definition: smartmic.h:290
err_t smartmic_read_data(smartmic_t *ctx, uint8_t *data_out, uint16_t len)
Smart Mic read data function.
#define DRV_BUFFER_SIZE
Smart Mic driver buffer size.
Definition: smartmic.h:208
uint8_t smartmic_get_irq_pin(smartmic_t *ctx)
Smart Mic get irq pin function.