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