Skip to content

Group x430_types

Modules > x430_types

Callbacks, configuration structures and the opaque instances.

Classes

Type Name
struct x430_bus
One serial line with up to X430_MAX_DEVICES emulated devices.
struct x430_bus_config
Bus configuration, copied by x430_bus_init() .
struct x430_device
One emulated actuator (one DYNAMIXEL ID): Control Table image and rules.
struct x430_device_config
Device configuration, copied by x430_device_init() .
struct x430_hooks
Application hooks of a device.
struct x430_port
Platform services.
struct x430_sim
Kinematic model of an X430 behind a device.
struct x430_sim_config
Simulator configuration, copied by x430_sim_init() .

Public Types

Type Name
typedef void(* x430_delay_fn
Busy or sleeping delay ( x430_port::delay_us ).
typedef uint8_t(* x430_event_hook
Device event ( x430_hooks::event ).
typedef void(* x430_lock_fn
Take or release the bus lock ( x430_port::lock ,x430_port::unlock ).
typedef uint32_t(* x430_millis_fn
Free-running millisecond counter ( x430_port::millis ).
typedef int(* x430_nvm_read_hook
Read part of a persistent block ( x430_hooks::nvm_read ).
typedef int(* x430_nvm_write_hook
Write part of a persistent block ( x430_hooks::nvm_write ), after the change; may be slow.
typedef void(* x430_read_hook
Data is about to be read ( x430_hooks::read ).
typedef uint8_t(* x430_write_hook
A validated register write, before the value is stored ( x430_hooks::write ).

Macros

Type Name
define X430_ALIGN_UP (n, a) (((((n) + (a)) - 1U) / (a)) \* (a))
n rounded up to a multiple ofa .
define X430_BUS_BYTES /* multi line expression */
Private state of a bus in bytes; x430_bus.c checks it at compile time.
define X430_BUS_WORDS (([**X430\_BUS\_BYTES**](group__x430__types.md#define-x430_bus_bytes) + 7U) / 8U)
Size of x430_bus in 64-bit words.
define X430_DEVICE_BYTES ((3U \* [**X430\_POINTER\_BYTES**](group__x430__types.md#define-x430_pointer_bytes)) + 17U + X430\_IMAGE\_SIZE + X430\_REG\_WRITE\_SIZE\_U)
Private state of a device in bytes; x430_device.c checks it at compile time.
define X430_DEVICE_WORDS (([**X430\_DEVICE\_BYTES**](group__x430__types.md#define-x430_device_bytes) + 7U) / 8U)
Size of x430_device in 64-bit words.
define X430_DXL2_LINK_BYTES /* multi line expression */
Bytes of struct dxl2_link of DXL2-C 2.0.0, from DXL2_MAX_PACKET_SIZE: configuration (4 pointers), parser (buffer and size_t), decoded packet (ID, instruction, parameter count and a pointer to the parameters in the parser buffer), two 32-bit counters.
define X430_NVM_BACKUP_SIZE ([**X430\_NVM\_HEADER\_SIZE**](group__x430__defs.md#define-x430_nvm_header_size) + X430\_IMAGE\_SIZE + 2U)
Size of the persistent Control Table backup block (the compact image).
define X430_NVM_EEPROM_SIZE ([**X430\_NVM\_HEADER\_SIZE**](group__x430__defs.md#define-x430_nvm_header_size) + [**X430\_RAM\_START**](group__x430__defs.md#define-x430_ram_start) + 2U)
Size of the persistent EEPROM block (nvm_read / nvm_write).
define X430_POINTER_BYTES 4U
Size of a pointer and of size_t: 8 on 64-bit hosts, 4 on Cortex-M.
define X430_SIM_BYTES (24U + [**X430\_POINTER\_BYTES**](group__x430__types.md#define-x430_pointer_bytes))
Private state of a simulator in bytes; x430_sim.c checks it at compile time.
define X430_SIM_WORDS (([**X430\_SIM\_BYTES**](group__x430__types.md#define-x430_sim_bytes) + 7U) / 8U)
Size of x430_sim in 64-bit words.

Public Types Documentation

typedef x430_delay_fn

Busy or sleeping delay ( x430_port::delay_us ).

typedef void(* x430_delay_fn) (void *context, uint32_t us);

Parameters:


typedef x430_event_hook

Device event ( x430_hooks::event ).

typedef uint8_t(* x430_event_hook) (struct x430_device *device, enum x430_event event, void *user_data);

Parameters:

Returns:

DXL2_ERR_NONE, or a DXL2_ERR_* code where the event can be refused (X430_EVENT_CLEAR_MULTI_TURN); ignored otherwise.


typedef x430_lock_fn

Take or release the bus lock ( x430_port::lock ,x430_port::unlock ).

typedef void(* x430_lock_fn) (void *context);

Parameters:


typedef x430_millis_fn

Free-running millisecond counter ( x430_port::millis ).

typedef uint32_t(* x430_millis_fn) (void *context);

Parameters:

Returns:

Milliseconds; wraps at 2^32.


typedef x430_nvm_read_hook

Read part of a persistent block ( x430_hooks::nvm_read ).

typedef int(* x430_nvm_read_hook) (struct x430_device *device, enum x430_nvm_slot slot, uint16_t offset, uint8_t *data, uint16_t length, void *user_data);

The device reads a block in parts, so that it needs no buffer of its own: first the whole block in chunks (header, payload and CRC are checked), then the registers it takes from it. Return the stored bytes; where they live is up to the application.

Parameters:

Return value:

  • 0 length bytes were read.
  • <0 No data: the device treats the block as missing (factory values stay).

typedef x430_nvm_write_hook

Write part of a persistent block ( x430_hooks::nvm_write ), after the change; may be slow.

typedef int(* x430_nvm_write_hook) (struct x430_device *device, enum x430_nvm_slot slot, uint16_t offset, const uint8_t *data, uint16_t length, void *user_data);

A block is written in parts with increasing offsets, from 0 to its end (X430_NVM_EEPROM_SIZE or X430_NVM_BACKUP_SIZE): header, payload (straight from the Control Table image of the device) and CRC. Start a new block at offset 0 (for example erase the flash page) and commit it when offset + length reaches the size. A block that is not written to its end fails the CRC check when it is read.

Parameters:

  • device Device.
  • slot Block to write.
  • offset First byte, from the start of the block.
  • data length bytes, opaque to the application.
  • length Bytes.
  • user_data x430_device_config::user_data.

Return value:

  • 0 Written.
  • <0 Failure: the remaining parts are not written, the host gets Result Fail.

typedef x430_read_hook

Data is about to be read ( x430_hooks::read ).

typedef void(* x430_read_hook) (struct x430_device *device, uint16_t address, uint16_t length, void *user_data);

Called once per contiguous run of real addresses (Indirect Data is resolved to the addresses it points at). The hook may refresh live registers with x430_device_set().

Parameters:


typedef x430_write_hook

A validated register write, before the value is stored ( x430_hooks::write ).

typedef uint8_t(* x430_write_hook) (struct x430_device *device, uint16_t address, uint8_t size, int32_t value, void *user_data);

Parameters:

  • device Device written.
  • address First address of the register.
  • size Register size in bytes (1, 2 or 4).
  • value New value (sign-extended for signed registers).
  • user_data x430_device_config::user_data.

Returns:

DXL2_ERR_NONE to accept, another DXL2_ERR_* code to refuse (the instruction stops at this register and the host gets that error).


Macro Definition Documentation

define X430_ALIGN_UP

n rounded up to a multiple ofa .

#define X430_ALIGN_UP (
    n,
    a
) `(((((n) + (a)) - 1U) / (a)) * (a))`


define X430_BUS_BYTES

Private state of a bus in bytes; x430_bus.c checks it at compile time.

#define X430_BUS_BYTES `/* multi line expression */`


define X430_BUS_WORDS

Size of x430_bus in 64-bit words.

#define X430_BUS_WORDS `(( X430_BUS_BYTES + 7U) / 8U)`


define X430_DEVICE_BYTES

Private state of a device in bytes; x430_device.c checks it at compile time.

#define X430_DEVICE_BYTES `((3U * X430_POINTER_BYTES ) + 17U + X430_IMAGE_SIZE + X430_REG_WRITE_SIZE_U)`


define X430_DEVICE_WORDS

Size of x430_device in 64-bit words.

#define X430_DEVICE_WORDS `(( X430_DEVICE_BYTES + 7U) / 8U)`


Bytes of struct dxl2_link of DXL2-C 2.0.0, from DXL2_MAX_PACKET_SIZE: configuration (4 pointers), parser (buffer and size_t), decoded packet (ID, instruction, parameter count and a pointer to the parameters in the parser buffer), two 32-bit counters.

#define X430_DXL2_LINK_BYTES `/* multi line expression */`

Plain arithmetic so that the instance size needs no sizeof (static analysis); x430_bus.c checks it at compile time.


define X430_NVM_BACKUP_SIZE

Size of the persistent Control Table backup block (the compact image).

#define X430_NVM_BACKUP_SIZE `( X430_NVM_HEADER_SIZE + X430_IMAGE_SIZE + 2U)`


define X430_NVM_EEPROM_SIZE

Size of the persistent EEPROM block (nvm_read / nvm_write).

#define X430_NVM_EEPROM_SIZE `( X430_NVM_HEADER_SIZE + X430_RAM_START + 2U)`


define X430_POINTER_BYTES

Size of a pointer and of size_t: 8 on 64-bit hosts, 4 on Cortex-M.

#define X430_POINTER_BYTES `4U`


define X430_SIM_BYTES

Private state of a simulator in bytes; x430_sim.c checks it at compile time.

#define X430_SIM_BYTES `(24U + X430_POINTER_BYTES )`


define X430_SIM_WORDS

Size of x430_sim in 64-bit words.

#define X430_SIM_WORDS `(( X430_SIM_BYTES + 7U) / 8U)`