speakup3  2.1.0.0
speakup3.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 SPEAKUP3_H
29 #define SPEAKUP3_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_uart.h"
38 
59 #define SPEAKUP3_START_BYTE 0x5A
60 #define SPEAKUP3_INS_ENTER_WAKE_UP 0x00 // Voice CMD: hey pudding / hello pudding
61 #define SPEAKUP3_INS_EXIT_WAKE_UP 0x01 // Voice CMD: goodbye / see you
62 #define SPEAKUP3_INS_LEARN_MATCH_AC 0x02 // Voice CMD: match the air conditioner
63 #define SPEAKUP3_INS_AC_TURN_ON 0x03 // Voice CMD: turn on the air conditioner
64 #define SPEAKUP3_INS_AC_TURN_OFF 0x04 // Voice CMD: turn off the air conditioner
65 #define SPEAKUP3_INS_AC_MODE_AUTO 0x05 // Voice CMD: automatic mode
66 #define SPEAKUP3_INS_AC_MODE_COLD 0x06 // Voice CMD: cold mode
67 #define SPEAKUP3_INS_AC_MODE_HEAT 0x07 // Voice CMD: heat mode
68 #define SPEAKUP3_INS_AC_MODE_DRY 0x08 // Voice CMD: dry mode
69 #define SPEAKUP3_INS_AC_MODE_FAN 0x09 // Voice CMD: fan mode
70 #define SPEAKUP3_INS_AC_MODE_SLEEP 0x0A // Voice CMD: sleeping mode
71 #define SPEAKUP3_INS_AC_WIND_AUTO 0x0B // Voice CMD: automatic fan
72 #define SPEAKUP3_INS_AC_WIND_LOW 0x0C // Voice CMD: low fan
73 #define SPEAKUP3_INS_AC_WIND_MID 0x0D // Voice CMD: medium fan
74 #define SPEAKUP3_INS_AC_WIND_HIGH 0x0E // Voice CMD: high fan
75 #define SPEAKUP3_INS_AC_WIND_INC 0x0F // Voice CMD: higher the fan
76 #define SPEAKUP3_INS_AC_WIND_DEC 0x10 // Voice CMD: lower the fan
77 #define SPEAKUP3_INS_AC_TMP_16 0x11 // Voice CMD: sixteen centigrade
78 #define SPEAKUP3_INS_AC_TMP_17 0x12 // Voice CMD: seventeen centigrade
79 #define SPEAKUP3_INS_AC_TMP_18 0x13 // Voice CMD: eighteen centigrade
80 #define SPEAKUP3_INS_AC_TMP_19 0x14 // Voice CMD: nineteen centigrade
81 #define SPEAKUP3_INS_AC_TMP_20 0x15 // Voice CMD: twenty centigrade
82 #define SPEAKUP3_INS_AC_TMP_21 0x16 // Voice CMD: twenty one centigrade
83 #define SPEAKUP3_INS_AC_TMP_22 0x17 // Voice CMD: twenty two centigrade
84 #define SPEAKUP3_INS_AC_TMP_23 0x18 // Voice CMD: twenty three centigrade
85 #define SPEAKUP3_INS_AC_TMP_24 0x19 // Voice CMD: twenty four centigrade
86 #define SPEAKUP3_INS_AC_TMP_25 0x1A // Voice CMD: twenty five centigrade
87 #define SPEAKUP3_INS_AC_TMP_26 0x1B // Voice CMD: twenty six centigrade
88 #define SPEAKUP3_INS_AC_TMP_27 0x1C // Voice CMD: twenty seven centigrade
89 #define SPEAKUP3_INS_AC_TMP_28 0x1D // Voice CMD: twenty eight centigrade
90 #define SPEAKUP3_INS_AC_TMP_29 0x1E // Voice CMD: twenty nine centigrade
91 #define SPEAKUP3_INS_AC_TMP_30 0x1F // Voice CMD: thirty centigrade
92 #define SPEAKUP3_INS_AC_TMP_INC 0x20 // Voice CMD: warmer
93 #define SPEAKUP3_INS_AC_TMP_DEC 0x21 // Voice CMD: cooler
94 #define SPEAKUP3_INS_AC_SWEPT_ON 0x22 // Voice CMD: start to fan
95 #define SPEAKUP3_INS_AC_SWEPT_OFF 0x23 // Voice CMD: stop to fan
96 #define SPEAKUP3_INS_AC_SWEPT_VERT 0x24 // Voice CMD: air swing up and down
97 #define SPEAKUP3_INS_AC_SWEPT_CROSS 0x25 // Voice CMD: air swing left and right
98 #define SPEAKUP3_INS_SET_RESTORE 0x26 // Voice CMD: air conditioner reset
99 #define SPEAKUP3_RESERVED_BYTE_1 0x00
100 #define SPEAKUP3_RESERVED_BYTE_2 0x00
101 
107 #define TX_DRV_BUFFER_SIZE 100
108 #define RX_DRV_BUFFER_SIZE 200
109  // speakup3_cmd
111 
126 #define SPEAKUP3_MAP_MIKROBUS( cfg, mikrobus ) \
127  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
128  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX );
129  // speakup3_map // speakup3
132 
137 typedef struct
138 {
139  // Modules
140  uart_t uart;
142  // Buffers
143  char uart_rx_buffer[ RX_DRV_BUFFER_SIZE ];
144  char uart_tx_buffer[ TX_DRV_BUFFER_SIZE ];
146 } speakup3_t;
147 
152 typedef struct
153 {
154  // Communication gpio pins
155  pin_name_t rx_pin;
156  pin_name_t tx_pin;
158  // Static variable
159  uint32_t baud_rate;
161  uart_data_bits_t data_bit;
162  uart_parity_t parity_bit;
163  uart_stop_bits_t stop_bit;
166 
171 typedef enum
172 {
174  SPEAKUP3_ERROR = -1
175 
177 
194 
209 
222 err_t speakup3_generic_write ( speakup3_t *ctx, char *data_in, uint16_t len );
223 
236 err_t speakup3_generic_read ( speakup3_t *ctx, char *data_out, uint16_t len );
237 
250 err_t speakup3_wait_for_reply ( speakup3_t *ctx, uint8_t *reply_ins, uint32_t wait_ms );
251 
252 #ifdef __cplusplus
253 }
254 #endif
255 #endif // SPEAKUP3_H
256  // speakup3
258 
259 // ------------------------------------------------------------------------ END
SPEAKUP3_OK
@ SPEAKUP3_OK
Definition: speakup3.h:173
speakup3_t
SpeakUp 3 Click context object.
Definition: speakup3.h:138
SPEAKUP3_ERROR
@ SPEAKUP3_ERROR
Definition: speakup3.h:174
speakup3_wait_for_reply
err_t speakup3_wait_for_reply(speakup3_t *ctx, uint8_t *reply_ins, uint32_t wait_ms)
SpeakUp 3 wait for reply function.
speakup3_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: speakup3.h:162
speakup3_cfg_t::rx_pin
pin_name_t rx_pin
Definition: speakup3.h:155
speakup3_cfg_setup
void speakup3_cfg_setup(speakup3_cfg_t *cfg)
SpeakUp 3 configuration object setup function.
speakup3_cfg_t::uart_blocking
bool uart_blocking
Definition: speakup3.h:160
speakup3_generic_read
err_t speakup3_generic_read(speakup3_t *ctx, char *data_out, uint16_t len)
SpeakUp 3 data reading function.
speakup3_return_value_t
speakup3_return_value_t
SpeakUp 3 Click return value data.
Definition: speakup3.h:172
speakup3_cfg_t::baud_rate
uint32_t baud_rate
Definition: speakup3.h:159
speakup3_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: speakup3.h:163
RX_DRV_BUFFER_SIZE
#define RX_DRV_BUFFER_SIZE
Definition: speakup3.h:108
speakup3_cfg_t::tx_pin
pin_name_t tx_pin
Definition: speakup3.h:156
speakup3_init
err_t speakup3_init(speakup3_t *ctx, speakup3_cfg_t *cfg)
SpeakUp 3 initialization function.
speakup3_t::uart
uart_t uart
Definition: speakup3.h:140
speakup3_generic_write
err_t speakup3_generic_write(speakup3_t *ctx, char *data_in, uint16_t len)
SpeakUp 3 data writing function.
speakup3_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: speakup3.h:161
TX_DRV_BUFFER_SIZE
#define TX_DRV_BUFFER_SIZE
SpeakUp 3 driver buffer size.
Definition: speakup3.h:107
speakup3_cfg_t
SpeakUp 3 Click configuration object.
Definition: speakup3.h:153