feetech.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Inria
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
24 #ifndef FEETECH_H
25 #define FEETECH_H
26 
27 #include <stdlib.h>
28 
29 #include "feetech_protocol.h"
30 #include "uart_half_duplex.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 typedef uint8_t feetech_id_t;
37 typedef uint8_t feetech_addr_t;
42 typedef struct {
45 } feetech_t;
46 
50 enum {
55 };
56 
69 
77 void feetech_init(feetech_t *device, uart_half_duplex_t *stream, feetech_id_t id);
78 
91 int feetech_write8(const feetech_t *device, feetech_addr_t addr, uint8_t value);
92 
105 int feetech_write16(const feetech_t *device, feetech_addr_t addr, uint16_t value);
106 
120 int feetech_write(const feetech_t *device, feetech_addr_t addr, const uint8_t *data, size_t length);
121 
134 int feetech_read8(const feetech_t *device, feetech_addr_t addr, uint8_t *value);
135 
148 int feetech_read16(const feetech_t *device, feetech_addr_t addr, uint16_t *value);
149 
163 int feetech_read(const feetech_t *device, feetech_addr_t addr, uint8_t *data, size_t length);
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif /* FEETECH_H */
170 
feetech_id_t
uint8_t feetech_id_t
device id type
Definition: feetech.h:36
feetech_addr_t
uint8_t feetech_addr_t
address type
Definition: feetech.h:37
feetech_read16
int feetech_read16(const feetech_t *device, feetech_addr_t addr, uint16_t *value)
Read from a device 16bits address.
feetech_t::stream
uart_half_duplex_t * stream
the stream used
Definition: feetech.h:43
feetech_ping
int feetech_ping(uart_half_duplex_t *stream, feetech_id_t id)
Send a PING message to a device.
feetech_read
int feetech_read(const feetech_t *device, feetech_addr_t addr, uint8_t *data, size_t length)
Read from a device address.
feetech_protocol.h
Feetech protocol definitions.
FEETECH_TIMEOUT
@ FEETECH_TIMEOUT
No response from the device.
Definition: feetech.h:52
feetech_write16
int feetech_write16(const feetech_t *device, feetech_addr_t addr, uint16_t value)
Write to a device 16bits address.
uart_half_duplex_t
Descriptor struct for half-duplex UART.
Definition: uart_half_duplex.h:62
FEETECH_BUFFER_TOO_SMALL
@ FEETECH_BUFFER_TOO_SMALL
Buffer is too small for the message.
Definition: feetech.h:53
feetech_t
Descriptor struct for a feetech device.
Definition: feetech.h:42
feetech_read8
int feetech_read8(const feetech_t *device, feetech_addr_t addr, uint8_t *value)
Read from a device 8bits address.
FEETECH_INVALID_MESSAGE
@ FEETECH_INVALID_MESSAGE
Invalid message received.
Definition: feetech.h:54
feetech_write8
int feetech_write8(const feetech_t *device, feetech_addr_t addr, uint8_t value)
Write to a device 8bits address.
feetech_write
int feetech_write(const feetech_t *device, feetech_addr_t addr, const uint8_t *data, size_t length)
Write to a device address.
FEETECH_OK
@ FEETECH_OK
Success.
Definition: feetech.h:51
feetech_init
void feetech_init(feetech_t *device, uart_half_duplex_t *stream, feetech_id_t id)
Initialize a Feetech device.
uart_half_duplex.h
Interface definition for half-duplex UART driver.
feetech_t::id
feetech_id_t id
the device address
Definition: feetech.h:44