aversive_10-03-12/modules/devices/servo/ax12/ax12.c File Reference

#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.


Function Documentation

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.

Returns:
Error code from AX-12 (0 means okay)

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.

Returns:
Error code from AX-12 (0 means okay)

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 
)

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 
)

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 
)

uint8_t AX12_set_position3 ( AX12 s,
uint8_t  id,
uint16_t  position,
uint16_t  speed,
uint16_t  torque 
)

uint8_t AX12_write_byte ( AX12 ,
uint8_t  id,
AX12_ADDRESS  address,
uint8_t  data 
)

Write byte in AX-12 memory.

Returns:
Error code from AX-12 (0 means okay)

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.

Returns:
Error code from AX-12 (0 means okay)
address : data low address+1 : data high

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().


Generated on Fri Mar 12 06:32:06 2010 for AVR by  doxygen 1.5.6