Skip to content

File x430_internal.h

FileList > src > x430_internal.h

Go to the source code of this file

  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>
  • #include "x430.h"

Classes

Type Name
struct x430_bus_ctx
State behind the opaque x430_bus .
struct x430_device_ctx
State behind the opaque x430_device .
struct x430_sim_ctx
State behind the opaque x430_sim .
struct x430_turn
One hosted device of a SYNC_READ or BULK_READ that has not answered yet.

Public Functions

Type Name
bool x430_bus_id_taken (const struct x430_bus * bus, const struct x430_device * except, uint8_t id)
True when another device on bus usesid (bus may be NULL).
uint32_t x430_bus_millis (const struct x430_bus * bus)
Milliseconds from the port of bus ; 0 without bus or clock.
void x430_copy (uint8_t * destination, const uint8_t * source, uint16_t length)
Copies length bytes (no <string.h>).
uint8_t x430_device_alert (const struct x430_device * device)
Status error alert: DXL2_ERR_ALERT_BIT when Hardware Error Status is not 0.
void x430_device_attach (struct x430_device * device, struct x430_bus * bus)
Records the bus of a device on x430_bus_attach() .
struct x430_bus * x430_device_bus (const struct x430_device * device)
Bus of the device, NULL when it is not attached.
uint8_t x430_device_byte (const struct x430_device * device, uint16_t address)
Control Table byte address , below ::X430_IMAGE_DIRECT (stored at its own index).
bool x430_device_ready (const struct x430_device * device)
True for a device that completed x430_device_init() (device may be NULL).
void x430_device_store (struct x430_device * device, uint16_t address, int32_t value)
Store value into the register that starts ataddress (none: no effect).
int32_t x430_device_value (const struct x430_device * device, uint16_t address)
Value of the register that starts at address , 0 when none starts there.
void x430_device_watchdog (struct x430_device * device, uint32_t idle_ms)
Bus Watchdog check; idle_ms is the time since the last instruction packet.
void x430_fill (uint8_t * destination, uint8_t value, uint16_t length)
Sets length bytes tovalue (no <string.h>).
size_t x430_frame_status (uint8_t * tx, size_t capacity, uint8_t id, uint16_t count)
Completes a status packet in place (no second buffer): header, id , the byte stuffing of instruction, error and data, the length field and the CRC.

Public Static Functions

Type Name
struct x430_bus_ctx * x430_bus_ctx_of (struct x430_bus * bus)
State of a bus.
const struct x430_bus_ctx * x430_bus_ctx_of_const (const struct x430_bus * bus)
Read-only variant of x430_bus_ctx_of().
struct x430_device_ctx * x430_device_ctx_of (struct x430_device * device)
State of a device.
const struct x430_device_ctx * x430_device_ctx_of_const (const struct x430_device * device)
Read-only variant of x430_device_ctx_of().
struct x430_sim_ctx * x430_sim_ctx_of (struct x430_sim * sim)
State of a simulator.

Macros

Type Name
define X430_READY 0x58343330U
Value of the ready field after a successful initialization.
define X430_TURN_NOW 0xFFU
x430_turn::after of an entry that may answer at once.

Public Functions Documentation

function x430_bus_id_taken

True when another device on bus usesid (bus may be NULL).

bool x430_bus_id_taken (
    const struct x430_bus * bus,
    const struct x430_device * except,
    uint8_t id
) 


function x430_bus_millis

Milliseconds from the port of bus ; 0 without bus or clock.

uint32_t x430_bus_millis (
    const struct x430_bus * bus
) 


function x430_copy

Copies length bytes (no <string.h>).

void x430_copy (
    uint8_t * destination,
    const uint8_t * source,
    uint16_t length
) 


function x430_device_alert

Status error alert: DXL2_ERR_ALERT_BIT when Hardware Error Status is not 0.

uint8_t x430_device_alert (
    const struct x430_device * device
) 


function x430_device_attach

Records the bus of a device on x430_bus_attach() .

void x430_device_attach (
    struct x430_device * device,
    struct x430_bus * bus
) 


function x430_device_bus

Bus of the device, NULL when it is not attached.

struct x430_bus * x430_device_bus (
    const struct x430_device * device
) 


function x430_device_byte

Control Table byte address , below ::X430_IMAGE_DIRECT (stored at its own index).

uint8_t x430_device_byte (
    const struct x430_device * device,
    uint16_t address
) 


function x430_device_ready

True for a device that completed x430_device_init() (device may be NULL).

bool x430_device_ready (
    const struct x430_device * device
) 


function x430_device_store

Store value into the register that starts ataddress (none: no effect).

void x430_device_store (
    struct x430_device * device,
    uint16_t address,
    int32_t value
) 


function x430_device_value

Value of the register that starts at address , 0 when none starts there.

int32_t x430_device_value (
    const struct x430_device * device,
    uint16_t address
) 


function x430_device_watchdog

Bus Watchdog check; idle_ms is the time since the last instruction packet.

void x430_device_watchdog (
    struct x430_device * device,
    uint32_t idle_ms
) 


function x430_fill

Sets length bytes tovalue (no <string.h>).

void x430_fill (
    uint8_t * destination,
    uint8_t value,
    uint16_t length
) 


function x430_frame_status

Completes a status packet in place (no second buffer): header, id , the byte stuffing of instruction, error and data, the length field and the CRC.

size_t x430_frame_status (
    uint8_t * tx,
    size_t capacity,
    uint8_t id,
    uint16_t count
) 

The result is byte for byte the packet of dxl2_encode(). A status whose stuffed form does not fit capacity becomes a Data Length Error without data (the alert bit is kept).

Parameters:

  • tx Packet buffer: error byte at offset 8, count data bytes from 9.
  • capacity Size of tx, at least 9 + count and at least 11 bytes.
  • id ID of the answering device.
  • count Status data bytes.

Returns:

Packet length (at least 11).


Public Static Functions Documentation

function x430_bus_ctx_of

State of a bus.

static inline struct x430_bus_ctx * x430_bus_ctx_of (
    struct x430_bus * bus
) 

Note:

MISRA C:2012 Rule 11.3, deviation DEV-01 (docs/misra.md): x430_bus is the opaque storage of x430_bus_ctx; size and alignment are checked in x430_bus.c.


function x430_bus_ctx_of_const

Read-only variant of x430_bus_ctx_of().

static inline const struct x430_bus_ctx * x430_bus_ctx_of_const (
    const struct x430_bus * bus
) 


function x430_device_ctx_of

State of a device.

static inline struct x430_device_ctx * x430_device_ctx_of (
    struct x430_device * device
) 

Note:

MISRA C:2012 Rule 11.3, deviation DEV-01 (docs/misra.md); checked in x430_device.c.


function x430_device_ctx_of_const

Read-only variant of x430_device_ctx_of().

static inline const struct x430_device_ctx * x430_device_ctx_of_const (
    const struct x430_device * device
) 


function x430_sim_ctx_of

State of a simulator.

static inline struct x430_sim_ctx * x430_sim_ctx_of (
    struct x430_sim * sim
) 

Note:

MISRA C:2012 Rule 11.3, deviation DEV-01 (docs/misra.md); checked in x430_sim.c.


Macro Definition Documentation

define X430_READY

Value of the ready field after a successful initialization.

#define X430_READY `0x58343330U`

A zeroed or never initialized instance holds another value: every function but the *_init() functions then returns X430_ERR_STATE.


define X430_TURN_NOW

x430_turn::after of an entry that may answer at once.

#define X430_TURN_NOW `0xFFU`



The documentation for this class was generated from the following file src/x430_internal.h