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 {
45  dynamixel_id_t id;
46 } dynamixel_t;
47 
51 enum {
56 };
57 
69 int dynamixel_ping(uart_half_duplex_t *stream, dynamixel_id_t id);
70 
78 void dynamixel_init(dynamixel_t *device, uart_half_duplex_t *stream, dynamixel_id_t id);
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 
uint8_t dynamixel_id_t
device id type
Definition: dynamixel.h:37
Invalid message received.
Definition: dynamixel.h:55
int dynamixel_read16(const dynamixel_t *device, dynamixel_addr_t reg, uint16_t *value)
Read from a device 16bits register.
Descriptor struct for a dynamixel device.
Definition: dynamixel.h:43
dynamixel_id_t id
the device address
Definition: dynamixel.h:45
int dynamixel_read(const dynamixel_t *device, dynamixel_addr_t reg, uint8_t *data, size_t length)
Read from a device address.
int dynamixel_ping(uart_half_duplex_t *stream, dynamixel_id_t id)
Send a PING message to a device.
Dynamixel protocol definitions.
Interface definition for half-duplex UART driver.
Descriptor struct for half-duplex UART.
void dynamixel_init(dynamixel_t *device, uart_half_duplex_t *stream, dynamixel_id_t id)
Initialize a Dynamixel device.
Buffer is too small for the message.
Definition: dynamixel.h:54
uint16_t dynamixel_addr_t
register address type
Definition: dynamixel.h:38
int dynamixel_write(const dynamixel_t *device, dynamixel_addr_t reg, const uint8_t *data, size_t length)
Write to a device address.
Success.
Definition: dynamixel.h:52
int dynamixel_write16(const dynamixel_t *device, dynamixel_addr_t reg, uint16_t value)
Write to a device 16bits register.
No response from the device.
Definition: dynamixel.h:53
int dynamixel_read8(const dynamixel_t *device, dynamixel_addr_t reg, uint8_t *value)
Read from a device 8bits register.
stdlib.h wrapper for MSP430
int dynamixel_write8(const dynamixel_t *device, dynamixel_addr_t reg, uint8_t value)
Write to a device 8bits register.
uart_half_duplex_t * stream
the stream used
Definition: dynamixel.h:44