dynamixel.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 DYNAMIXEL_H
25 #define DYNAMIXEL_H
26 
27 #include <stdlib.h>
28 #include <stdbool.h>
29 
30 #include "dynamixel_protocol.h"
31 #include "uart_half_duplex.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 typedef uint8_t dynamixel_id_t;
38 typedef uint16_t dynamixel_addr_t;
43 typedef struct {
46 } dynamixel_t;
47 
51 enum {
56 };
57 
70 
79 
92 int dynamixel_write8(const dynamixel_t *device, dynamixel_addr_t reg, uint8_t value);
93 
106 int dynamixel_write16(const dynamixel_t *device, dynamixel_addr_t reg, uint16_t value);
107 
121 int dynamixel_write(const dynamixel_t *device, dynamixel_addr_t reg, const uint8_t *data, size_t length);
122 
135 int dynamixel_read8(const dynamixel_t *device, dynamixel_addr_t reg, uint8_t *value);
136 
149 int dynamixel_read16(const dynamixel_t *device, dynamixel_addr_t reg, uint16_t *value);
150 
164 int dynamixel_read(const dynamixel_t *device, dynamixel_addr_t reg, uint8_t *data, size_t length);
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 #endif /* DYNAMIXEL_H */
171 
dynamixel_addr_t
uint16_t dynamixel_addr_t
register address type
Definition: dynamixel.h:38
DYNAMIXEL_TIMEOUT
@ DYNAMIXEL_TIMEOUT
No response from the device.
Definition: dynamixel.h:53
dynamixel_read16
int dynamixel_read16(const dynamixel_t *device, dynamixel_addr_t reg, uint16_t *value)
Read from a device 16bits register.
dynamixel_id_t
uint8_t dynamixel_id_t
device id type
Definition: dynamixel.h:37
dynamixel_write
int dynamixel_write(const dynamixel_t *device, dynamixel_addr_t reg, const uint8_t *data, size_t length)
Write to a device address.
dynamixel_read8
int dynamixel_read8(const dynamixel_t *device, dynamixel_addr_t reg, uint8_t *value)
Read from a device 8bits register.
dynamixel_init
void dynamixel_init(dynamixel_t *device, uart_half_duplex_t *stream, dynamixel_id_t id)
Initialize a Dynamixel device.
dynamixel_protocol.h
Dynamixel protocol definitions.
DYNAMIXEL_INVALID_MESSAGE
@ DYNAMIXEL_INVALID_MESSAGE
Invalid message received.
Definition: dynamixel.h:55
dynamixel_t
Descriptor struct for a dynamixel device.
Definition: dynamixel.h:43
dynamixel_write8
int dynamixel_write8(const dynamixel_t *device, dynamixel_addr_t reg, uint8_t value)
Write to a device 8bits register.
dynamixel_t::stream
uart_half_duplex_t * stream
the stream used
Definition: dynamixel.h:44
uart_half_duplex_t
Descriptor struct for half-duplex UART.
Definition: uart_half_duplex.h:62
dynamixel_t::id
dynamixel_id_t id
the device address
Definition: dynamixel.h:45
dynamixel_read
int dynamixel_read(const dynamixel_t *device, dynamixel_addr_t reg, uint8_t *data, size_t length)
Read from a device address.
dynamixel_ping
int dynamixel_ping(uart_half_duplex_t *stream, dynamixel_id_t id)
Send a PING message to a device.
DYNAMIXEL_BUFFER_TOO_SMALL
@ DYNAMIXEL_BUFFER_TOO_SMALL
Buffer is too small for the message.
Definition: dynamixel.h:54
uart_half_duplex.h
Interface definition for half-duplex UART driver.
DYNAMIXEL_OK
@ DYNAMIXEL_OK
Success.
Definition: dynamixel.h:52
dynamixel_write16
int dynamixel_write16(const dynamixel_t *device, dynamixel_addr_t reg, uint16_t value)
Write to a device 16bits register.