Loading...
Searching...
No Matches
feetech.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Inria
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
22
23#include <stdlib.h>
24
25#include "feetech_protocol.h"
26#include "uart_half_duplex.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32typedef uint8_t feetech_id_t;
33typedef uint8_t feetech_addr_t;
34
42
46enum {
51};
52
65
74
87int feetech_write8(const feetech_t *device, feetech_addr_t addr, uint8_t value);
88
101int feetech_write16(const feetech_t *device, feetech_addr_t addr, uint16_t value);
102
116int feetech_write(const feetech_t *device, feetech_addr_t addr, const uint8_t *data, size_t length);
117
130int feetech_read8(const feetech_t *device, feetech_addr_t addr, uint8_t *value);
131
144int feetech_read16(const feetech_t *device, feetech_addr_t addr, uint16_t *value);
145
159int feetech_read(const feetech_t *device, feetech_addr_t addr, uint8_t *data, size_t length);
160
161#ifdef __cplusplus
162}
163#endif
164
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:32
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:33
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:50
@ FEETECH_TIMEOUT
No response from the device.
Definition feetech.h:48
@ FEETECH_OK
Success.
Definition feetech.h:47
@ FEETECH_BUFFER_TOO_SMALL
Buffer is too small for the message.
Definition feetech.h:49
Descriptor struct for a feetech device.
Definition feetech.h:38
uart_half_duplex_t * stream
the stream used
Definition feetech.h:39
feetech_id_t id
the device address
Definition feetech.h:40
Descriptor struct for half-duplex UART.
Interface definition for half-duplex UART driver.