feetech_writer.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 
20 #ifndef FEETECH_WRITER_H
21 #define FEETECH_WRITER_H
22 
23 #include "feetech_protocol.h"
24 
25 #include <stdint.h>
26 #include <stdbool.h>
27 #include <stdlib.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
36 typedef struct {
37  uint8_t *buffer;
38  size_t size;
39  size_t buffer_max_size;
41 
49 void feetech_writer_init(feetech_writer_t *writer, uint8_t *buffer, size_t buffer_max_size);
50 
58 const uint8_t *feetech_writer_get_data(const feetech_writer_t *writer);
59 
67 size_t feetech_writer_get_size(const feetech_writer_t *writer);
68 
77 void feetech_writer_response_make(feetech_writer_t *writer, uint8_t id, const uint8_t *buffer, size_t size);
78 
85 void feetech_writer_ack_make(feetech_writer_t *writer, uint8_t id);
86 
93 void feetech_writer_ping_make(feetech_writer_t *writer, uint8_t id);
94 
104 void feetech_writer_write_make(feetech_writer_t *writer, uint8_t id, uint8_t reg, const uint8_t *buffer, size_t size);
105 
114 void feetech_writer_write8_make(feetech_writer_t *writer, uint8_t id, uint8_t reg, uint8_t value);
115 
124 void feetech_writer_write16_make(feetech_writer_t *writer, uint8_t id, uint8_t reg, uint16_t value);
125 
134 void feetech_writer_read_make(feetech_writer_t *writer, uint8_t id, uint8_t reg, size_t size);
135 
143 void feetech_writer_sync_write_begin(feetech_writer_t *writer, uint8_t reg, size_t size);
144 
151 
160 void feetech_writer_sync_write_add(feetech_writer_t *writer, uint8_t id, const uint8_t *buffer, size_t size);
161 
169 void feetech_writer_sync_write_add_8bits(feetech_writer_t *writer, uint8_t id, uint8_t value);
170 
178 void feetech_writer_sync_write_add_16bits(feetech_writer_t *writer, uint8_t id, uint16_t value);
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif /* FEETECH_WRITER_H */
185 
feetech_writer_get_size
size_t feetech_writer_get_size(const feetech_writer_t *writer)
Get the data buffer's size to send.
feetech_writer_t::buffer_max_size
size_t buffer_max_size
data buffer's size
Definition: feetech_writer.h:39
feetech_writer_sync_write_add_8bits
void feetech_writer_sync_write_add_8bits(feetech_writer_t *writer, uint8_t id, uint8_t value)
Add an item to a SYNC_WRITE packet (8 bits)
feetech_writer_t
Feetech packet writer struct.
Definition: feetech_writer.h:36
feetech_writer_write8_make
void feetech_writer_write8_make(feetech_writer_t *writer, uint8_t id, uint8_t reg, uint8_t value)
Build a WRITE packet (8 bits)
feetech_protocol.h
Feetech protocol definitions.
feetech_writer_sync_write_end
void feetech_writer_sync_write_end(feetech_writer_t *writer)
End the building of a SYNC_WRITE packet.
feetech_writer_write16_make
void feetech_writer_write16_make(feetech_writer_t *writer, uint8_t id, uint8_t reg, uint16_t value)
Build a WRITE packet (16 bits)
feetech_writer_t::size
size_t size
packet's size
Definition: feetech_writer.h:38
feetech_writer_read_make
void feetech_writer_read_make(feetech_writer_t *writer, uint8_t id, uint8_t reg, size_t size)
Build a READ packet.
feetech_writer_sync_write_begin
void feetech_writer_sync_write_begin(feetech_writer_t *writer, uint8_t reg, size_t size)
Begin to build a SYNC_WRITE packet.
feetech_writer_sync_write_add_16bits
void feetech_writer_sync_write_add_16bits(feetech_writer_t *writer, uint8_t id, uint16_t value)
Add an item to a SYNC_WRITE packet (16 bits)
feetech_writer_write_make
void feetech_writer_write_make(feetech_writer_t *writer, uint8_t id, uint8_t reg, const uint8_t *buffer, size_t size)
Build a WRITE packet.
feetech_writer_ping_make
void feetech_writer_ping_make(feetech_writer_t *writer, uint8_t id)
Build a PING packet.
feetech_writer_get_data
const uint8_t * feetech_writer_get_data(const feetech_writer_t *writer)
Get the data buffer to send.
feetech_writer_ack_make
void feetech_writer_ack_make(feetech_writer_t *writer, uint8_t id)
Build an ack packet.
feetech_writer_sync_write_add
void feetech_writer_sync_write_add(feetech_writer_t *writer, uint8_t id, const uint8_t *buffer, size_t size)
Add an item to a SYNC_WRITE packet.
feetech_writer_t::buffer
uint8_t * buffer
data buffer
Definition: feetech_writer.h:37
feetech_writer_init
void feetech_writer_init(feetech_writer_t *writer, uint8_t *buffer, size_t buffer_max_size)
Initialize the Feetech packet writer.
feetech_writer_response_make
void feetech_writer_response_make(feetech_writer_t *writer, uint8_t id, const uint8_t *buffer, size_t size)
Build a response packet.