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
32extern "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#include "drv_uart.h"
52
73#define SPEAKUP3_START_BYTE 0x5A
74#define SPEAKUP3_INS_ENTER_WAKE_UP 0x00 // Voice CMD: hey pudding / hello pudding
75#define SPEAKUP3_INS_EXIT_WAKE_UP 0x01 // Voice CMD: goodbye / see you
76#define SPEAKUP3_INS_LEARN_MATCH_AC 0x02 // Voice CMD: match the air conditioner
77#define SPEAKUP3_INS_AC_TURN_ON 0x03 // Voice CMD: turn on the air conditioner
78#define SPEAKUP3_INS_AC_TURN_OFF 0x04 // Voice CMD: turn off the air conditioner
79#define SPEAKUP3_INS_AC_MODE_AUTO 0x05 // Voice CMD: automatic mode
80#define SPEAKUP3_INS_AC_MODE_COLD 0x06 // Voice CMD: cold mode
81#define SPEAKUP3_INS_AC_MODE_HEAT 0x07 // Voice CMD: heat mode
82#define SPEAKUP3_INS_AC_MODE_DRY 0x08 // Voice CMD: dry mode
83#define SPEAKUP3_INS_AC_MODE_FAN 0x09 // Voice CMD: fan mode
84#define SPEAKUP3_INS_AC_MODE_SLEEP 0x0A // Voice CMD: sleeping mode
85#define SPEAKUP3_INS_AC_WIND_AUTO 0x0B // Voice CMD: automatic fan
86#define SPEAKUP3_INS_AC_WIND_LOW 0x0C // Voice CMD: low fan
87#define SPEAKUP3_INS_AC_WIND_MID 0x0D // Voice CMD: medium fan
88#define SPEAKUP3_INS_AC_WIND_HIGH 0x0E // Voice CMD: high fan
89#define SPEAKUP3_INS_AC_WIND_INC 0x0F // Voice CMD: higher the fan
90#define SPEAKUP3_INS_AC_WIND_DEC 0x10 // Voice CMD: lower the fan
91#define SPEAKUP3_INS_AC_TMP_16 0x11 // Voice CMD: sixteen centigrade
92#define SPEAKUP3_INS_AC_TMP_17 0x12 // Voice CMD: seventeen centigrade
93#define SPEAKUP3_INS_AC_TMP_18 0x13 // Voice CMD: eighteen centigrade
94#define SPEAKUP3_INS_AC_TMP_19 0x14 // Voice CMD: nineteen centigrade
95#define SPEAKUP3_INS_AC_TMP_20 0x15 // Voice CMD: twenty centigrade
96#define SPEAKUP3_INS_AC_TMP_21 0x16 // Voice CMD: twenty one centigrade
97#define SPEAKUP3_INS_AC_TMP_22 0x17 // Voice CMD: twenty two centigrade
98#define SPEAKUP3_INS_AC_TMP_23 0x18 // Voice CMD: twenty three centigrade
99#define SPEAKUP3_INS_AC_TMP_24 0x19 // Voice CMD: twenty four centigrade
100#define SPEAKUP3_INS_AC_TMP_25 0x1A // Voice CMD: twenty five centigrade
101#define SPEAKUP3_INS_AC_TMP_26 0x1B // Voice CMD: twenty six centigrade
102#define SPEAKUP3_INS_AC_TMP_27 0x1C // Voice CMD: twenty seven centigrade
103#define SPEAKUP3_INS_AC_TMP_28 0x1D // Voice CMD: twenty eight centigrade
104#define SPEAKUP3_INS_AC_TMP_29 0x1E // Voice CMD: twenty nine centigrade
105#define SPEAKUP3_INS_AC_TMP_30 0x1F // Voice CMD: thirty centigrade
106#define SPEAKUP3_INS_AC_TMP_INC 0x20 // Voice CMD: warmer
107#define SPEAKUP3_INS_AC_TMP_DEC 0x21 // Voice CMD: cooler
108#define SPEAKUP3_INS_AC_SWEPT_ON 0x22 // Voice CMD: start to fan
109#define SPEAKUP3_INS_AC_SWEPT_OFF 0x23 // Voice CMD: stop to fan
110#define SPEAKUP3_INS_AC_SWEPT_VERT 0x24 // Voice CMD: air swing up and down
111#define SPEAKUP3_INS_AC_SWEPT_CROSS 0x25 // Voice CMD: air swing left and right
112#define SPEAKUP3_INS_SET_RESTORE 0x26 // Voice CMD: air conditioner reset
113#define SPEAKUP3_RESERVED_BYTE_1 0x00
114#define SPEAKUP3_RESERVED_BYTE_2 0x00
115
121#define TX_DRV_BUFFER_SIZE 100
122#define RX_DRV_BUFFER_SIZE 200
123
124 // speakup3_cmd
125
140#define SPEAKUP3_MAP_MIKROBUS( cfg, mikrobus ) \
141 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
142 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX );
143
144 // speakup3_map
145 // speakup3
146
151typedef struct
152{
153 // Modules
154 uart_t uart;
156 // Buffers
157 char uart_rx_buffer[ RX_DRV_BUFFER_SIZE ];
158 char uart_tx_buffer[ TX_DRV_BUFFER_SIZE ];
160} speakup3_t;
161
166typedef struct
167{
168 // Communication gpio pins
169 pin_name_t rx_pin;
170 pin_name_t tx_pin;
172 // Static variable
173 uint32_t baud_rate;
175 uart_data_bits_t data_bit;
176 uart_parity_t parity_bit;
177 uart_stop_bits_t stop_bit;
180
185typedef enum
186{
188 SPEAKUP3_ERROR = -1
189
191
208
223
236err_t speakup3_generic_write ( speakup3_t *ctx, char *data_in, uint16_t len );
237
250err_t speakup3_generic_read ( speakup3_t *ctx, char *data_out, uint16_t len );
251
264err_t speakup3_wait_for_reply ( speakup3_t *ctx, uint8_t *reply_ins, uint32_t wait_ms );
265
266#ifdef __cplusplus
267}
268#endif
269#endif // SPEAKUP3_H
270
271 // speakup3
272
273// ------------------------------------------------------------------------ END
#define RX_DRV_BUFFER_SIZE
Definition speakup3.h:122
#define TX_DRV_BUFFER_SIZE
SpeakUp 3 driver buffer size.
Definition speakup3.h:121
void speakup3_cfg_setup(speakup3_cfg_t *cfg)
SpeakUp 3 configuration object setup function.
err_t speakup3_generic_write(speakup3_t *ctx, char *data_in, uint16_t len)
SpeakUp 3 data writing function.
err_t speakup3_generic_read(speakup3_t *ctx, char *data_out, uint16_t len)
SpeakUp 3 data reading function.
err_t speakup3_wait_for_reply(speakup3_t *ctx, uint8_t *reply_ins, uint32_t wait_ms)
SpeakUp 3 wait for reply function.
err_t speakup3_init(speakup3_t *ctx, speakup3_cfg_t *cfg)
SpeakUp 3 initialization function.
speakup3_return_value_t
SpeakUp 3 Click return value data.
Definition speakup3.h:186
@ SPEAKUP3_ERROR
Definition speakup3.h:188
@ SPEAKUP3_OK
Definition speakup3.h:187
SpeakUp 3 Click configuration object.
Definition speakup3.h:167
uint32_t baud_rate
Definition speakup3.h:173
bool uart_blocking
Definition speakup3.h:174
uart_data_bits_t data_bit
Definition speakup3.h:175
pin_name_t tx_pin
Definition speakup3.h:170
pin_name_t rx_pin
Definition speakup3.h:169
uart_stop_bits_t stop_bit
Definition speakup3.h:177
uart_parity_t parity_bit
Definition speakup3.h:176
SpeakUp 3 Click context object.
Definition speakup3.h:152
uart_t uart
Definition speakup3.h:154