touchkey2 2.0.0.0
touchkey2.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef TOUCHKEY2_H
36#define TOUCHKEY2_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_uart.h"
41
42
43// -------------------------------------------------------------- PUBLIC MACROS
53#define TOUCHKEY2_MAP_MIKROBUS( cfg, mikrobus ) \
54 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
55 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
56 cfg.pc5_target_reset = MIKROBUS( mikrobus, MIKROBUS_RST );
63#define TOUCHKEY2_RETVAL uint8_t
64
65#define TOUCHKEY2_OK 0x00
66#define TOUCHKEY2_INIT_ERROR 0xFF
73#define DRV_RX_BUFFER_SIZE 500 // End group macro
77// --------------------------------------------------------------- PUBLIC TYPES
87typedef struct
88{
89 // Output pins
90
91 digital_out_t pc5_target_reset;
92
93 // Modules
94
95 uart_t uart;
96
97 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
98 char uart_tx_buffer[ DRV_RX_BUFFER_SIZE ];
99
101
105typedef struct
106{
107 // Communication gpio pins
108
109 pin_name_t rx_pin;
110 pin_name_t tx_pin;
112
113 // static variable
114
115 uint32_t baud_rate; // Clock speed.
117 uart_data_bits_t data_bit; // Data bits.
118 uart_parity_t parity_bit; // Parity bit.
119 uart_stop_bits_t stop_bit; // Stop bits.
120
122 // End types group
124
125// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
126
132#ifdef __cplusplus
133extern "C"{
134#endif
135
145
154
164void touchkey2_generic_multi_write ( touchkey2_t *ctx, char *data_buf, uint8_t len );
165
175void touchkey2_generic_multi_read ( touchkey2_t *ctx, char *data_buf, uint8_t len );
176
186
195void touchkey2_generic_single_write ( touchkey2_t *ctx, char tx_data );
196
205
214
223
224#ifdef __cplusplus
225}
226#endif
227#endif // _TOUCHKEY2_H_
228 // End public_function group
231
232// ------------------------------------------------------------------------- END
#define DRV_RX_BUFFER_SIZE
Definition: touchkey2.h:73
#define TOUCHKEY2_RETVAL
Definition: touchkey2.h:63
void touchkey2_set_reset_pin(touchkey2_t *ctx)
Set reset pin function.
TOUCHKEY2_RETVAL touchkey2_init(touchkey2_t *ctx, touchkey2_cfg_t *cfg)
Initialization function.
void touchkey2_target_reset(touchkey2_t *ctx)
Reset function.
void touchkey2_cfg_setup(touchkey2_cfg_t *cfg)
Config Object Initialization function.
void touchkey2_generic_multi_write(touchkey2_t *ctx, char *data_buf, uint8_t len)
Generic multi write function.
char touchkey2_generic_single_read(touchkey2_t *ctx)
Generic single read function.
void touchkey2_clear_reset_pin(touchkey2_t *ctx)
Clear reset pin function.
void touchkey2_generic_single_write(touchkey2_t *ctx, char tx_data)
Generic single write function.
void touchkey2_generic_multi_read(touchkey2_t *ctx, char *data_buf, uint8_t len)
Generic multi read function.
Click configuration structure definition.
Definition: touchkey2.h:106
uint32_t baud_rate
Definition: touchkey2.h:115
bool uart_blocking
Definition: touchkey2.h:116
uart_data_bits_t data_bit
Definition: touchkey2.h:117
pin_name_t tx_pin
Definition: touchkey2.h:110
pin_name_t rx_pin
Definition: touchkey2.h:109
uart_stop_bits_t stop_bit
Definition: touchkey2.h:119
uart_parity_t parity_bit
Definition: touchkey2.h:118
pin_name_t pc5_target_reset
Definition: touchkey2.h:111
Click ctx object definition.
Definition: touchkey2.h:88
digital_out_t pc5_target_reset
Definition: touchkey2.h:91
uart_t uart
Definition: touchkey2.h:95