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 
9 #pragma once
10 
26 #include <stdlib.h>
27 
28 #include "feetech_protocol.h"
29 #include "uart_half_duplex.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 typedef uint8_t feetech_id_t;
36 typedef uint8_t feetech_addr_t;
41 typedef struct {
44 } feetech_t;
45 
49 enum {
54 };
55 
68 
77 
90 int feetech_write8(const feetech_t *device, feetech_addr_t addr, uint8_t value);
91 
104 int feetech_write16(const feetech_t *device, feetech_addr_t addr, uint16_t value);
105 
119 int feetech_write(const feetech_t *device, feetech_addr_t addr, const uint8_t *data, size_t length);
120 
133 int feetech_read8(const feetech_t *device, feetech_addr_t addr, uint8_t *value);
134 
147 int feetech_read16(const feetech_t *device, feetech_addr_t addr, uint16_t *value);
148 
162 int feetech_read(const feetech_t *device, feetech_addr_t addr, uint8_t *data, size_t length);
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
Feetech protocol definitions.
int feetech_write(const feetech_t *device, feetech_addr_t addr, const uint8_t *data, size_t length)
Write to a device address.
void feetech_init(feetech_t *device, uart_half_duplex_t *stream, feetech_id_t id)
Initialize a Feetech device.
uint8_t feetech_id_t
device id type
Definition: feetech.h:35
int feetech_ping(uart_half_duplex_t *stream, feetech_id_t id)
Send a PING message to a device.
uint8_t feetech_addr_t
address type
Definition: feetech.h:36
int feetech_write16(const feetech_t *device, feetech_addr_t addr, uint16_t value)
Write to a device 16bits address.
int feetech_read16(const feetech_t *device, feetech_addr_t addr, uint16_t *value)
Read from a device 16bits address.
int feetech_read8(const feetech_t *device, feetech_addr_t addr, uint8_t *value)
Read from a device 8bits address.
int feetech_read(const feetech_t *device, feetech_addr_t addr, uint8_t *data, size_t length)
Read from a device address.
int feetech_write8(const feetech_t *device, feetech_addr_t addr, uint8_t value)
Write to a device 8bits address.
@ FEETECH_INVALID_MESSAGE
Invalid message received.
Definition: feetech.h:53
@ FEETECH_TIMEOUT
No response from the device.
Definition: feetech.h:51
@ FEETECH_OK
Success.
Definition: feetech.h:50
@ FEETECH_BUFFER_TOO_SMALL
Buffer is too small for the message.
Definition: feetech.h:52
Descriptor struct for a feetech device.
Definition: feetech.h:41
uart_half_duplex_t * stream
the stream used
Definition: feetech.h:42
feetech_id_t id
the device address
Definition: feetech.h:43
Descriptor struct for half-duplex UART.
Interface definition for half-duplex UART driver.