#include <stdio.h>
#include <string.h>
#include "ax12.h"
Go to the source code of this file.
Functions | |
void | AX12_init (AX12 *s) |
void | AX12_set_hardware_send (AX12 *s, int8_t(*pf)(uint8_t)) |
Set the function called when writing a character. | |
void | AX12_set_hardware_recv (AX12 *s, int16_t(*pf)(void)) |
Set the function called when reading a character. | |
void | AX12_set_hardware_switch (AX12 *s, void(*pf)(uint8_t)) |
Set the function called when switching line direction. | |
uint8_t | AX12_checksum (AX12_Packet *packet) |
Compute AX12 packet checksum. | |
uint8_t | AX12_send (AX12 *s, AX12_Packet *packet) |
Send a formated AX12 instruction packet. Return 0 on on success. | |
uint8_t | AX12_recv (AX12 *s, AX12_Packet *packet) |
uint8_t | AX12_write_byte (AX12 *s, uint8_t id, AX12_ADDRESS address, uint8_t data) |
Write byte in AX-12 memory. | |
uint8_t | AX12_write_int (AX12 *s, uint8_t id, AX12_ADDRESS address, uint16_t data) |
Write integer (2 bytes) in AX-12 memory. | |
uint8_t | AX12_read_byte (AX12 *s, uint8_t id, AX12_ADDRESS address, uint8_t *val) |
Read byte from AX-12 memory. | |
uint8_t | AX12_read_int (AX12 *s, uint8_t id, AX12_ADDRESS address, uint16_t *val) |
Write integer (2 bytes) from AX-12 memory. | |
uint8_t | AX12_set_position (AX12 *s, uint8_t id, uint16_t position) |
Set AX12 position. | |
uint8_t | AX12_set_position2 (AX12 *s, uint8_t id, uint16_t position, uint16_t speed) |
Set AX12 position and moving speed. | |
uint8_t | AX12_set_position3 (AX12 *s, uint8_t id, uint16_t position, uint16_t speed, uint16_t torque) |
Set AX12 position, moving speed and torque. | |
uint8_t | AX12_get_position (AX12 *s, uint8_t id, uint16_t *pos) |
Read AX12 position. | |
uint8_t | AX12_get_speed (AX12 *s, uint8_t id, uint16_t *speed) |
Read AX12 speed. | |
uint8_t | AX12_get_load (AX12 *s, uint8_t id, uint16_t *load) |
Read AX12 load. | |
uint8_t | AX12_ping (AX12 *s, uint8_t id) |
Ping an AX12 and return error register. | |
uint8_t | AX12_reset (AX12 *s, uint8_t id) |
Reset AX12 back to factory settings. |
uint8_t AX12_checksum | ( | AX12_Packet * | packet | ) |
Compute AX12 packet checksum.
Definition at line 62 of file ax12.c.
References i, AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, and AX12_Packet::params.
Referenced by AX12_recv(), and AX12_send().
uint8_t AX12_get_load | ( | AX12 * | s, | |
uint8_t | id, | |||
uint16_t * | load | |||
) |
Read AX12 load.
Definition at line 447 of file ax12.c.
References AA_PRESENT_LOAD_L, and AX12_read_int().
uint8_t AX12_get_position | ( | AX12 * | s, | |
uint8_t | id, | |||
uint16_t * | pos | |||
) |
Read AX12 position.
Definition at line 437 of file ax12.c.
References AA_PRESENT_POSITION_L, and AX12_read_int().
uint8_t AX12_get_speed | ( | AX12 * | s, | |
uint8_t | id, | |||
uint16_t * | speed | |||
) |
Read AX12 speed.
Definition at line 442 of file ax12.c.
References AA_PRESENT_SPEED_L, and AX12_read_int().
void AX12_init | ( | AX12 * | s | ) |
Definition at line 33 of file ax12.c.
References AX12::hardware_recv, AX12::hardware_send, and AX12::hardware_switch.
uint8_t AX12_ping | ( | AX12 * | s, | |
uint8_t | id | |||
) |
Ping an AX12 and return error register.
Definition at line 452 of file ax12.c.
References AX12_BROADCAST_ID, AX12_PING, AX12_recv(), AX12_send(), AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, and gen_regs::p.
uint8_t AX12_read_byte | ( | AX12 * | , | |
uint8_t | id, | |||
AX12_ADDRESS | address, | |||
uint8_t * | val | |||
) |
Read byte from AX-12 memory.
Definition at line 298 of file ax12.c.
References AX12_READ, AX12_recv(), AX12_send(), AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, gen_regs::p, and AX12_Packet::params.
uint8_t AX12_read_int | ( | AX12 * | , | |
uint8_t | id, | |||
AX12_ADDRESS | address, | |||
uint16_t * | val | |||
) |
Write integer (2 bytes) from AX-12 memory.
Definition at line 330 of file ax12.c.
References AX12_READ, AX12_recv(), AX12_send(), AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, gen_regs::p, and AX12_Packet::params.
Referenced by AX12_get_load(), AX12_get_position(), and AX12_get_speed().
uint8_t AX12_recv | ( | AX12 * | s, | |
AX12_Packet * | packet | |||
) |
Definition at line 167 of file ax12.c.
References AX12_checksum(), AX12_ERROR_TYPE_BAD_CKSUM, AX12_ERROR_TYPE_INVALID_PACKET, AX12_ERROR_TYPE_NO_ANSWER, AX12_ERROR_TYPE_TIMEOUT, AX12_STATE_READ, AX12_Packet::error, AX12::hardware_recv, AX12::hardware_switch, i, AX12_Packet::id, AX12_Packet::nparams, and AX12_Packet::params.
Referenced by AX12_ping(), AX12_read_byte(), AX12_read_int(), AX12_reset(), AX12_set_position2(), AX12_set_position3(), AX12_write_byte(), and AX12_write_int().
uint8_t AX12_reset | ( | AX12 * | s, | |
uint8_t | id | |||
) |
Reset AX12 back to factory settings.
Definition at line 474 of file ax12.c.
References AX12_BROADCAST_ID, AX12_recv(), AX12_RESET, AX12_send(), AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, and gen_regs::p.
uint8_t AX12_send | ( | AX12 * | s, | |
AX12_Packet * | packet | |||
) |
Send a formated AX12 instruction packet. Return 0 on on success.
Definition at line 80 of file ax12.c.
References AX12_checksum(), AX12_ERROR_TYPE_INVALID_PACKET, AX12_ERROR_TYPE_XMIT_FAILED, AX12_STATE_READ, AX12_STATE_WRITE, AX12::hardware_send, AX12::hardware_switch, i, AX12_Packet::id, AX12_Packet::instruction, IRQ_LOCK, IRQ_UNLOCK, AX12_Packet::nparams, AX12_Packet::params, scheduler_disable_save(), and scheduler_enable_restore().
Referenced by AX12_ping(), AX12_read_byte(), AX12_read_int(), AX12_reset(), AX12_set_position2(), AX12_set_position3(), AX12_write_byte(), and AX12_write_int().
void AX12_set_hardware_recv | ( | AX12 * | s, | |
int16_t(*)(void) | pf | |||
) |
Set the function called when reading a character.
Definition at line 48 of file ax12.c.
References AX12::hardware_recv.
void AX12_set_hardware_send | ( | AX12 * | s, | |
int8_t(*)(uint8_t) | pf | |||
) |
Set the function called when writing a character.
Definition at line 43 of file ax12.c.
References AX12::hardware_send.
void AX12_set_hardware_switch | ( | AX12 * | s, | |
void(*)(uint8_t) | pf | |||
) |
Set the function called when switching line direction.
Definition at line 53 of file ax12.c.
References AX12::hardware_switch.
uint8_t AX12_set_position | ( | AX12 * | s, | |
uint8_t | id, | |||
uint16_t | position | |||
) |
Set AX12 position.
Definition at line 365 of file ax12.c.
References AA_GOAL_POSITION_L, and AX12_write_int().
uint8_t AX12_set_position2 | ( | AX12 * | s, | |
uint8_t | id, | |||
uint16_t | position, | |||
uint16_t | speed | |||
) |
Set AX12 position and moving speed.
Definition at line 370 of file ax12.c.
References AA_GOAL_POSITION_L, AX12_BROADCAST_ID, AX12_recv(), AX12_send(), AX12_WRITE, AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, gen_regs::p, and AX12_Packet::params.
uint8_t AX12_set_position3 | ( | AX12 * | s, | |
uint8_t | id, | |||
uint16_t | position, | |||
uint16_t | speed, | |||
uint16_t | torque | |||
) |
Set AX12 position, moving speed and torque.
Definition at line 402 of file ax12.c.
References AA_GOAL_POSITION_L, AX12_BROADCAST_ID, AX12_recv(), AX12_send(), AX12_WRITE, AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, gen_regs::p, and AX12_Packet::params.
uint8_t AX12_write_byte | ( | AX12 * | , | |
uint8_t | id, | |||
AX12_ADDRESS | address, | |||
uint8_t | data | |||
) |
Write byte in AX-12 memory.
Definition at line 228 of file ax12.c.
References AX12_BROADCAST_ID, AX12_recv(), AX12_send(), AX12_WRITE, AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, gen_regs::p, and AX12_Packet::params.
uint8_t AX12_write_int | ( | AX12 * | , | |
uint8_t | id, | |||
AX12_ADDRESS | address, | |||
uint16_t | data | |||
) |
Write integer (2 bytes) in AX-12 memory.
Definition at line 261 of file ax12.c.
References AX12_BROADCAST_ID, AX12_recv(), AX12_send(), AX12_WRITE, AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, gen_regs::p, and AX12_Packet::params.
Referenced by AX12_set_position().