\section{aversive\_\-10-03-12/modules/devices/servo/ax12/ax12.h File Reference}
\label{ax12_8h}\index{aversive\_\-10-03-12/modules/devices/servo/ax12/ax12.h@{aversive\_\-10-03-12/modules/devices/servo/ax12/ax12.h}}
This module provides functions for using a Robotis Dynamixel AX-12 numeric actuator. 

{\tt \#include $<$aversive.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include \char`\"{}ax12\_\-address.h\char`\"{}}\par
{\tt \#include \char`\"{}ax12\_\-config.h\char`\"{}}\par
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct {\bf AX12}
\item 
struct {\bf AX12\_\-Packet}
\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf AX12\_\-STATE\_\-READ}~0
\item 
\#define {\bf AX12\_\-STATE\_\-WRITE}~1
\item 
\#define {\bf AX12\_\-ERROR\_\-BIT\_\-VOLTAGE}~0
\item 
\#define {\bf AX12\_\-ERROR\_\-BIT\_\-ANGLE\_\-LIMIT}~1
\item 
\#define {\bf AX12\_\-ERROR\_\-BIT\_\-OVERHEAT}~2
\item 
\#define {\bf AX12\_\-ERROR\_\-BIT\_\-RANGE}~3
\item 
\#define {\bf AX12\_\-ERROR\_\-BIT\_\-CHECKSUM}~4
\item 
\#define {\bf AX12\_\-ERROR\_\-BIT\_\-OVERLOAD}~5
\item 
\#define {\bf AX12\_\-ERROR\_\-BIT\_\-INSTRUCTION}~6
\item 
\#define {\bf AX12\_\-ERROR\_\-TYPE\_\-NO\_\-ANSWER}~0xff
\item 
\#define {\bf AX12\_\-ERROR\_\-TYPE\_\-TIMEOUT}~0xfe
\item 
\#define {\bf AX12\_\-ERROR\_\-TYPE\_\-INVALID\_\-PACKET}~0xfd
\item 
\#define {\bf AX12\_\-ERROR\_\-TYPE\_\-XMIT\_\-FAILED}~0xfc
\item 
\#define {\bf AX12\_\-ERROR\_\-TYPE\_\-BAD\_\-CKSUM}~0xfb
\item 
\#define {\bf AX12\_\-BROADCAST\_\-ID}~0xFE
\item 
\#define {\bf AX12\_\-PING}~0x01
\item 
\#define {\bf AX12\_\-READ}~0x02
\item 
\#define {\bf AX12\_\-WRITE}~0x03
\item 
\#define {\bf AX12\_\-REG\_\-WRITE}~0x04
\item 
\#define {\bf AX12\_\-ACTION}~0x05
\item 
\#define {\bf AX12\_\-RESET}~0x06
\item 
\#define {\bf AX12\_\-SYNC\_\-WRITE}~0x83
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf AX12\_\-init} ({\bf AX12} $\ast$)
\item 
void {\bf AX12\_\-set\_\-hardware\_\-send} ({\bf AX12} $\ast$, int8\_\-t($\ast$)(uint8\_\-t))
\begin{CompactList}\small\item\em Set the function called when writing a character. \item\end{CompactList}\item 
void {\bf AX12\_\-set\_\-hardware\_\-recv} ({\bf AX12} $\ast$, int16\_\-t($\ast$)(void))
\begin{CompactList}\small\item\em Set the function called when reading a character. \item\end{CompactList}\item 
void {\bf AX12\_\-set\_\-hardware\_\-switch} ({\bf AX12} $\ast$, void($\ast$)(uint8\_\-t))
\begin{CompactList}\small\item\em Set the function called when switching line direction. \item\end{CompactList}\item 
uint8\_\-t {\bf AX12\_\-checksum} ({\bf AX12\_\-Packet} $\ast$packet)
\begin{CompactList}\small\item\em Compute \doxyref{AX12}{p.}{structAX12} packet checksum. \item\end{CompactList}\item 
uint8\_\-t {\bf AX12\_\-send} ({\bf AX12} $\ast$, {\bf AX12\_\-Packet} $\ast$packet)
\begin{CompactList}\small\item\em Send a formated \doxyref{AX12}{p.}{structAX12} instruction packet. Return 0 on on success. \item\end{CompactList}\item 
uint8\_\-t {\bf AX12\_\-recv} ({\bf AX12} $\ast$, {\bf AX12\_\-Packet} $\ast$packet)
\item 
uint8\_\-t {\bf AX12\_\-write\_\-byte} ({\bf AX12} $\ast$, uint8\_\-t id, {\bf AX12\_\-ADDRESS} address, uint8\_\-t data)
\begin{CompactList}\small\item\em Write byte in AX-12 memory. \item\end{CompactList}\item 
uint8\_\-t {\bf AX12\_\-write\_\-int} ({\bf AX12} $\ast$, uint8\_\-t id, {\bf AX12\_\-ADDRESS} address, uint16\_\-t data)
\begin{CompactList}\small\item\em Write integer (2 bytes) in AX-12 memory. \item\end{CompactList}\item 
uint8\_\-t {\bf AX12\_\-read\_\-byte} ({\bf AX12} $\ast$, uint8\_\-t id, {\bf AX12\_\-ADDRESS} address, uint8\_\-t $\ast$val)
\begin{CompactList}\small\item\em Read byte from AX-12 memory. \item\end{CompactList}\item 
uint8\_\-t {\bf AX12\_\-read\_\-int} ({\bf AX12} $\ast$, uint8\_\-t id, {\bf AX12\_\-ADDRESS} address, uint16\_\-t $\ast$val)
\begin{CompactList}\small\item\em Write integer (2 bytes) from AX-12 memory. \item\end{CompactList}\item 
uint8\_\-t {\bf AX12\_\-set\_\-position} ({\bf AX12} $\ast$, uint8\_\-t id, uint16\_\-t position)
\begin{CompactList}\small\item\em Set \doxyref{AX12}{p.}{structAX12} position. \item\end{CompactList}\item 
uint8\_\-t {\bf AX12\_\-set\_\-position2} ({\bf AX12} $\ast$, uint8\_\-t id, uint16\_\-t position, uint16\_\-t speed)
\begin{CompactList}\small\item\em Set \doxyref{AX12}{p.}{structAX12} position and moving speed. \item\end{CompactList}\item 
uint8\_\-t {\bf AX12\_\-set\_\-position3} ({\bf AX12} $\ast$, uint8\_\-t id, uint16\_\-t position, uint16\_\-t speed, uint16\_\-t torque)
\begin{CompactList}\small\item\em Set \doxyref{AX12}{p.}{structAX12} position, moving speed and torque. \item\end{CompactList}\item 
uint8\_\-t {\bf AX12\_\-get\_\-position} ({\bf AX12} $\ast${\bf s}, uint8\_\-t id, uint16\_\-t $\ast$pos)
\begin{CompactList}\small\item\em Read \doxyref{AX12}{p.}{structAX12} position. \item\end{CompactList}\item 
uint8\_\-t {\bf AX12\_\-get\_\-speed} ({\bf AX12} $\ast${\bf s}, uint8\_\-t id, uint16\_\-t $\ast$speed)
\begin{CompactList}\small\item\em Read \doxyref{AX12}{p.}{structAX12} speed. \item\end{CompactList}\item 
uint8\_\-t {\bf AX12\_\-get\_\-load} ({\bf AX12} $\ast${\bf s}, uint8\_\-t id, uint16\_\-t $\ast$load)
\begin{CompactList}\small\item\em Read \doxyref{AX12}{p.}{structAX12} load. \item\end{CompactList}\item 
uint8\_\-t {\bf AX12\_\-ping} ({\bf AX12} $\ast$, uint8\_\-t id)
\begin{CompactList}\small\item\em Ping an \doxyref{AX12}{p.}{structAX12} and return \doxyref{error}{p.}{structerror} register. \item\end{CompactList}\item 
uint8\_\-t {\bf AX12\_\-reset} ({\bf AX12} $\ast$, uint8\_\-t id)
\begin{CompactList}\small\item\em Reset \doxyref{AX12}{p.}{structAX12} back to factory settings. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
This module provides functions for using a Robotis Dynamixel AX-12 numeric actuator. 

\begin{Desc}
\item[{\bf Todo}]\begin{itemize}
\item Manage the \char`\"{}Status Return Level\char`\"{}\end{itemize}
\end{Desc}
\doxyref{AX12}{p.}{structAX12} servos uses a half duplex uart. This means that there is only one line that is used for both transmitting and receiving. Refer to the \doxyref{AX12}{p.}{structAX12} documentation for more informations.

This module doesn't need ATmega's uart, user have to provide 3 functions to control the half duplex uart:\begin{itemize}
\item send char.\item write char.\item switch direction\end{itemize}


These functions may use (or not) the AVR uart. Have a look to the test program in test/ directory for an example. 

Definition in file {\bf ax12.h}.

\subsection{Define Documentation}
\index{ax12.h@{ax12.h}!AX12\_\-ACTION@{AX12\_\-ACTION}}
\index{AX12\_\-ACTION@{AX12\_\-ACTION}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-ACTION]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-ACTION~0x05}\label{ax12_8h_2b351b8f3a2ad75dab7391e3646b3f52}




Definition at line 86 of file ax12.h.\index{ax12.h@{ax12.h}!AX12\_\-BROADCAST\_\-ID@{AX12\_\-BROADCAST\_\-ID}}
\index{AX12\_\-BROADCAST\_\-ID@{AX12\_\-BROADCAST\_\-ID}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-BROADCAST\_\-ID]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-BROADCAST\_\-ID~0xFE}\label{ax12_8h_3c092fb5342a87b9ea454917066437ea}




Definition at line 79 of file ax12.h.

Referenced by AX12\_\-ping(), AX12\_\-reset(), AX12\_\-set\_\-position2(), AX12\_\-set\_\-position3(), AX12\_\-write\_\-byte(), and AX12\_\-write\_\-int().\index{ax12.h@{ax12.h}!AX12\_\-ERROR\_\-BIT\_\-ANGLE\_\-LIMIT@{AX12\_\-ERROR\_\-BIT\_\-ANGLE\_\-LIMIT}}
\index{AX12\_\-ERROR\_\-BIT\_\-ANGLE\_\-LIMIT@{AX12\_\-ERROR\_\-BIT\_\-ANGLE\_\-LIMIT}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-ERROR\_\-BIT\_\-ANGLE\_\-LIMIT]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-ERROR\_\-BIT\_\-ANGLE\_\-LIMIT~1}\label{ax12_8h_11eec67bf37fa7b84e4c6fd4f5ecd7d5}




Definition at line 64 of file ax12.h.\index{ax12.h@{ax12.h}!AX12\_\-ERROR\_\-BIT\_\-CHECKSUM@{AX12\_\-ERROR\_\-BIT\_\-CHECKSUM}}
\index{AX12\_\-ERROR\_\-BIT\_\-CHECKSUM@{AX12\_\-ERROR\_\-BIT\_\-CHECKSUM}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-ERROR\_\-BIT\_\-CHECKSUM]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-ERROR\_\-BIT\_\-CHECKSUM~4}\label{ax12_8h_1223fefa569a72b9346e372ff56f41ec}




Definition at line 67 of file ax12.h.\index{ax12.h@{ax12.h}!AX12\_\-ERROR\_\-BIT\_\-INSTRUCTION@{AX12\_\-ERROR\_\-BIT\_\-INSTRUCTION}}
\index{AX12\_\-ERROR\_\-BIT\_\-INSTRUCTION@{AX12\_\-ERROR\_\-BIT\_\-INSTRUCTION}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-ERROR\_\-BIT\_\-INSTRUCTION]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-ERROR\_\-BIT\_\-INSTRUCTION~6}\label{ax12_8h_f39ce3b1d740fe37ee764e4abdf8a462}




Definition at line 69 of file ax12.h.\index{ax12.h@{ax12.h}!AX12\_\-ERROR\_\-BIT\_\-OVERHEAT@{AX12\_\-ERROR\_\-BIT\_\-OVERHEAT}}
\index{AX12\_\-ERROR\_\-BIT\_\-OVERHEAT@{AX12\_\-ERROR\_\-BIT\_\-OVERHEAT}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-ERROR\_\-BIT\_\-OVERHEAT]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-ERROR\_\-BIT\_\-OVERHEAT~2}\label{ax12_8h_4304eb3de51e608124f891cdc03847a2}




Definition at line 65 of file ax12.h.\index{ax12.h@{ax12.h}!AX12\_\-ERROR\_\-BIT\_\-OVERLOAD@{AX12\_\-ERROR\_\-BIT\_\-OVERLOAD}}
\index{AX12\_\-ERROR\_\-BIT\_\-OVERLOAD@{AX12\_\-ERROR\_\-BIT\_\-OVERLOAD}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-ERROR\_\-BIT\_\-OVERLOAD]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-ERROR\_\-BIT\_\-OVERLOAD~5}\label{ax12_8h_1d002a4d76e60ded0f93a9aad66ad4a5}




Definition at line 68 of file ax12.h.\index{ax12.h@{ax12.h}!AX12\_\-ERROR\_\-BIT\_\-RANGE@{AX12\_\-ERROR\_\-BIT\_\-RANGE}}
\index{AX12\_\-ERROR\_\-BIT\_\-RANGE@{AX12\_\-ERROR\_\-BIT\_\-RANGE}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-ERROR\_\-BIT\_\-RANGE]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-ERROR\_\-BIT\_\-RANGE~3}\label{ax12_8h_3dfbb4f064e9e0728e8cd84481e269ab}




Definition at line 66 of file ax12.h.\index{ax12.h@{ax12.h}!AX12\_\-ERROR\_\-BIT\_\-VOLTAGE@{AX12\_\-ERROR\_\-BIT\_\-VOLTAGE}}
\index{AX12\_\-ERROR\_\-BIT\_\-VOLTAGE@{AX12\_\-ERROR\_\-BIT\_\-VOLTAGE}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-ERROR\_\-BIT\_\-VOLTAGE]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-ERROR\_\-BIT\_\-VOLTAGE~0}\label{ax12_8h_72153284e27b46d55e5d9cb416abf55f}




Definition at line 63 of file ax12.h.\index{ax12.h@{ax12.h}!AX12\_\-ERROR\_\-TYPE\_\-BAD\_\-CKSUM@{AX12\_\-ERROR\_\-TYPE\_\-BAD\_\-CKSUM}}
\index{AX12\_\-ERROR\_\-TYPE\_\-BAD\_\-CKSUM@{AX12\_\-ERROR\_\-TYPE\_\-BAD\_\-CKSUM}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-ERROR\_\-TYPE\_\-BAD\_\-CKSUM]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-ERROR\_\-TYPE\_\-BAD\_\-CKSUM~0xfb}\label{ax12_8h_53b7e0ef1470f477e3b116b9b6d1fb20}




Definition at line 76 of file ax12.h.

Referenced by AX12\_\-recv().\index{ax12.h@{ax12.h}!AX12\_\-ERROR\_\-TYPE\_\-INVALID\_\-PACKET@{AX12\_\-ERROR\_\-TYPE\_\-INVALID\_\-PACKET}}
\index{AX12\_\-ERROR\_\-TYPE\_\-INVALID\_\-PACKET@{AX12\_\-ERROR\_\-TYPE\_\-INVALID\_\-PACKET}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-ERROR\_\-TYPE\_\-INVALID\_\-PACKET]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-ERROR\_\-TYPE\_\-INVALID\_\-PACKET~0xfd}\label{ax12_8h_6b2a408269be62896ae325c5e17ae8bc}




Definition at line 74 of file ax12.h.

Referenced by AX12\_\-recv(), and AX12\_\-send().\index{ax12.h@{ax12.h}!AX12\_\-ERROR\_\-TYPE\_\-NO\_\-ANSWER@{AX12\_\-ERROR\_\-TYPE\_\-NO\_\-ANSWER}}
\index{AX12\_\-ERROR\_\-TYPE\_\-NO\_\-ANSWER@{AX12\_\-ERROR\_\-TYPE\_\-NO\_\-ANSWER}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-ERROR\_\-TYPE\_\-NO\_\-ANSWER]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-ERROR\_\-TYPE\_\-NO\_\-ANSWER~0xff}\label{ax12_8h_a49cf82f5ea1cb3dd3bcccd78688ce07}




Definition at line 72 of file ax12.h.

Referenced by AX12\_\-recv().\index{ax12.h@{ax12.h}!AX12\_\-ERROR\_\-TYPE\_\-TIMEOUT@{AX12\_\-ERROR\_\-TYPE\_\-TIMEOUT}}
\index{AX12\_\-ERROR\_\-TYPE\_\-TIMEOUT@{AX12\_\-ERROR\_\-TYPE\_\-TIMEOUT}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-ERROR\_\-TYPE\_\-TIMEOUT]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-ERROR\_\-TYPE\_\-TIMEOUT~0xfe}\label{ax12_8h_c3d7983e0889b9dc927db9db742aa33a}




Definition at line 73 of file ax12.h.

Referenced by AX12\_\-recv().\index{ax12.h@{ax12.h}!AX12\_\-ERROR\_\-TYPE\_\-XMIT\_\-FAILED@{AX12\_\-ERROR\_\-TYPE\_\-XMIT\_\-FAILED}}
\index{AX12\_\-ERROR\_\-TYPE\_\-XMIT\_\-FAILED@{AX12\_\-ERROR\_\-TYPE\_\-XMIT\_\-FAILED}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-ERROR\_\-TYPE\_\-XMIT\_\-FAILED]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-ERROR\_\-TYPE\_\-XMIT\_\-FAILED~0xfc}\label{ax12_8h_45887a570bc76f125379e885490d859d}




Definition at line 75 of file ax12.h.

Referenced by AX12\_\-send().\index{ax12.h@{ax12.h}!AX12\_\-PING@{AX12\_\-PING}}
\index{AX12\_\-PING@{AX12\_\-PING}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-PING]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-PING~0x01}\label{ax12_8h_bfbc9405553f4c5272fddc8a7328df42}




Definition at line 82 of file ax12.h.

Referenced by AX12\_\-ping().\index{ax12.h@{ax12.h}!AX12\_\-READ@{AX12\_\-READ}}
\index{AX12\_\-READ@{AX12\_\-READ}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-READ]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-READ~0x02}\label{ax12_8h_d533c25627926e69c8897ccdf4a4826c}




Definition at line 83 of file ax12.h.

Referenced by AX12\_\-read\_\-byte(), and AX12\_\-read\_\-int().\index{ax12.h@{ax12.h}!AX12\_\-REG\_\-WRITE@{AX12\_\-REG\_\-WRITE}}
\index{AX12\_\-REG\_\-WRITE@{AX12\_\-REG\_\-WRITE}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-REG\_\-WRITE]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-REG\_\-WRITE~0x04}\label{ax12_8h_cb34eb4c2a1ebbef791ef46d862b72a2}




Definition at line 85 of file ax12.h.\index{ax12.h@{ax12.h}!AX12\_\-RESET@{AX12\_\-RESET}}
\index{AX12\_\-RESET@{AX12\_\-RESET}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-RESET]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-RESET~0x06}\label{ax12_8h_95207335493c570c69734e5e24692421}




Definition at line 87 of file ax12.h.

Referenced by AX12\_\-reset().\index{ax12.h@{ax12.h}!AX12\_\-STATE\_\-READ@{AX12\_\-STATE\_\-READ}}
\index{AX12\_\-STATE\_\-READ@{AX12\_\-STATE\_\-READ}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-STATE\_\-READ]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-STATE\_\-READ~0}\label{ax12_8h_05c8064551bd64fce3d6f3119612fecc}




Definition at line 59 of file ax12.h.

Referenced by AX12\_\-recv(), and AX12\_\-send().\index{ax12.h@{ax12.h}!AX12\_\-STATE\_\-WRITE@{AX12\_\-STATE\_\-WRITE}}
\index{AX12\_\-STATE\_\-WRITE@{AX12\_\-STATE\_\-WRITE}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-STATE\_\-WRITE]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-STATE\_\-WRITE~1}\label{ax12_8h_94da3fecc675d4e8175f019cdd33147b}




Definition at line 60 of file ax12.h.

Referenced by AX12\_\-send().\index{ax12.h@{ax12.h}!AX12\_\-SYNC\_\-WRITE@{AX12\_\-SYNC\_\-WRITE}}
\index{AX12\_\-SYNC\_\-WRITE@{AX12\_\-SYNC\_\-WRITE}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-SYNC\_\-WRITE]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-SYNC\_\-WRITE~0x83}\label{ax12_8h_0949364230a2dbff18f6fd5991a98b0c}




Definition at line 88 of file ax12.h.\index{ax12.h@{ax12.h}!AX12\_\-WRITE@{AX12\_\-WRITE}}
\index{AX12\_\-WRITE@{AX12\_\-WRITE}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-WRITE]{\setlength{\rightskip}{0pt plus 5cm}\#define AX12\_\-WRITE~0x03}\label{ax12_8h_ae84d2bbddaeb225573c91c8172a816a}




Definition at line 84 of file ax12.h.

Referenced by AX12\_\-set\_\-position2(), AX12\_\-set\_\-position3(), AX12\_\-write\_\-byte(), and AX12\_\-write\_\-int().

\subsection{Function Documentation}
\index{ax12.h@{ax12.h}!AX12\_\-checksum@{AX12\_\-checksum}}
\index{AX12\_\-checksum@{AX12\_\-checksum}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-checksum]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-checksum ({\bf AX12\_\-Packet} $\ast$ {\em packet})}\label{ax12_8h_cd8899fe4f225f2a67160c485c6ccbc2}


Compute \doxyref{AX12}{p.}{structAX12} 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().\index{ax12.h@{ax12.h}!AX12\_\-get\_\-load@{AX12\_\-get\_\-load}}
\index{AX12\_\-get\_\-load@{AX12\_\-get\_\-load}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-get\_\-load]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-get\_\-load ({\bf AX12} $\ast$ {\em s}, \/  uint8\_\-t {\em id}, \/  uint16\_\-t $\ast$ {\em load})}\label{ax12_8h_96c45d14658dcf2ed809c0f1bd5513f2}


Read \doxyref{AX12}{p.}{structAX12} load. 



Definition at line 447 of file ax12.c.

References AA\_\-PRESENT\_\-LOAD\_\-L, and AX12\_\-read\_\-int().\index{ax12.h@{ax12.h}!AX12\_\-get\_\-position@{AX12\_\-get\_\-position}}
\index{AX12\_\-get\_\-position@{AX12\_\-get\_\-position}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-get\_\-position]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-get\_\-position ({\bf AX12} $\ast$ {\em s}, \/  uint8\_\-t {\em id}, \/  uint16\_\-t $\ast$ {\em pos})}\label{ax12_8h_43aec6447c98ec2a94ac3507e74832bd}


Read \doxyref{AX12}{p.}{structAX12} position. 



Definition at line 437 of file ax12.c.

References AA\_\-PRESENT\_\-POSITION\_\-L, and AX12\_\-read\_\-int().\index{ax12.h@{ax12.h}!AX12\_\-get\_\-speed@{AX12\_\-get\_\-speed}}
\index{AX12\_\-get\_\-speed@{AX12\_\-get\_\-speed}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-get\_\-speed]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-get\_\-speed ({\bf AX12} $\ast$ {\em s}, \/  uint8\_\-t {\em id}, \/  uint16\_\-t $\ast$ {\em speed})}\label{ax12_8h_6c3ef4d4ed9a1686e18f66a3ddfeb87d}


Read \doxyref{AX12}{p.}{structAX12} speed. 



Definition at line 442 of file ax12.c.

References AA\_\-PRESENT\_\-SPEED\_\-L, and AX12\_\-read\_\-int().\index{ax12.h@{ax12.h}!AX12\_\-init@{AX12\_\-init}}
\index{AX12\_\-init@{AX12\_\-init}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-init]{\setlength{\rightskip}{0pt plus 5cm}void AX12\_\-init ({\bf AX12} $\ast$)}\label{ax12_8h_038ce10a443768e73cd60016c4c11530}




Definition at line 33 of file ax12.c.

References AX12::hardware\_\-recv, AX12::hardware\_\-send, and AX12::hardware\_\-switch.\index{ax12.h@{ax12.h}!AX12\_\-ping@{AX12\_\-ping}}
\index{AX12\_\-ping@{AX12\_\-ping}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-ping]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-ping ({\bf AX12} $\ast$, \/  uint8\_\-t {\em id})}\label{ax12_8h_ff8ff0802b83853b85256065607358f3}


Ping an \doxyref{AX12}{p.}{structAX12} and return \doxyref{error}{p.}{structerror} 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.\index{ax12.h@{ax12.h}!AX12\_\-read\_\-byte@{AX12\_\-read\_\-byte}}
\index{AX12\_\-read\_\-byte@{AX12\_\-read\_\-byte}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-read\_\-byte]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-read\_\-byte ({\bf AX12} $\ast$, \/  uint8\_\-t {\em id}, \/  {\bf AX12\_\-ADDRESS} {\em address}, \/  uint8\_\-t $\ast$ {\em val})}\label{ax12_8h_54a36a5caf04034c4a12b1db119b9ed6}


Read byte from AX-12 memory. 

\begin{Desc}
\item[Returns:]Error code from AX-12 (0 means okay) \end{Desc}


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.\index{ax12.h@{ax12.h}!AX12\_\-read\_\-int@{AX12\_\-read\_\-int}}
\index{AX12\_\-read\_\-int@{AX12\_\-read\_\-int}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-read\_\-int]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-read\_\-int ({\bf AX12} $\ast$, \/  uint8\_\-t {\em id}, \/  {\bf AX12\_\-ADDRESS} {\em address}, \/  uint16\_\-t $\ast$ {\em val})}\label{ax12_8h_6726b531b9fb32fa6272641c0a628c6a}


Write integer (2 bytes) from AX-12 memory. 

\begin{Desc}
\item[Returns:]Error code from AX-12 (0 means okay) \end{Desc}


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().\index{ax12.h@{ax12.h}!AX12\_\-recv@{AX12\_\-recv}}
\index{AX12\_\-recv@{AX12\_\-recv}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-recv]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-recv ({\bf AX12} $\ast$, \/  {\bf AX12\_\-Packet} $\ast$ {\em packet})}\label{ax12_8h_9e925bb14af21c882bf245f3fbf047cf}




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().\index{ax12.h@{ax12.h}!AX12\_\-reset@{AX12\_\-reset}}
\index{AX12\_\-reset@{AX12\_\-reset}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-reset]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-reset ({\bf AX12} $\ast$, \/  uint8\_\-t {\em id})}\label{ax12_8h_86888c9c9f3bdeb558a653644d5c3aa5}


Reset \doxyref{AX12}{p.}{structAX12} 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.\index{ax12.h@{ax12.h}!AX12\_\-send@{AX12\_\-send}}
\index{AX12\_\-send@{AX12\_\-send}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-send]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-send ({\bf AX12} $\ast$, \/  {\bf AX12\_\-Packet} $\ast$ {\em packet})}\label{ax12_8h_d124c24c2267fb106593fb9977e1d854}


Send a formated \doxyref{AX12}{p.}{structAX12} 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().\index{ax12.h@{ax12.h}!AX12\_\-set\_\-hardware\_\-recv@{AX12\_\-set\_\-hardware\_\-recv}}
\index{AX12\_\-set\_\-hardware\_\-recv@{AX12\_\-set\_\-hardware\_\-recv}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-set\_\-hardware\_\-recv]{\setlength{\rightskip}{0pt plus 5cm}void AX12\_\-set\_\-hardware\_\-recv ({\bf AX12} $\ast$, \/  int16\_\-t($\ast$)(void))}\label{ax12_8h_29066fa4a1743e765c01257799479b56}


Set the function called when reading a character. 



Definition at line 48 of file ax12.c.

References AX12::hardware\_\-recv.\index{ax12.h@{ax12.h}!AX12\_\-set\_\-hardware\_\-send@{AX12\_\-set\_\-hardware\_\-send}}
\index{AX12\_\-set\_\-hardware\_\-send@{AX12\_\-set\_\-hardware\_\-send}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-set\_\-hardware\_\-send]{\setlength{\rightskip}{0pt plus 5cm}void AX12\_\-set\_\-hardware\_\-send ({\bf AX12} $\ast$, \/  int8\_\-t($\ast$)(uint8\_\-t))}\label{ax12_8h_5e1256840e3f84d6cb3fc0aecc1c3001}


Set the function called when writing a character. 



Definition at line 43 of file ax12.c.

References AX12::hardware\_\-send.\index{ax12.h@{ax12.h}!AX12\_\-set\_\-hardware\_\-switch@{AX12\_\-set\_\-hardware\_\-switch}}
\index{AX12\_\-set\_\-hardware\_\-switch@{AX12\_\-set\_\-hardware\_\-switch}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-set\_\-hardware\_\-switch]{\setlength{\rightskip}{0pt plus 5cm}void AX12\_\-set\_\-hardware\_\-switch ({\bf AX12} $\ast$, \/  void($\ast$)(uint8\_\-t))}\label{ax12_8h_0543b7d5a248a3a7f7761974e3ee876a}


Set the function called when switching line direction. 



Definition at line 53 of file ax12.c.

References AX12::hardware\_\-switch.\index{ax12.h@{ax12.h}!AX12\_\-set\_\-position@{AX12\_\-set\_\-position}}
\index{AX12\_\-set\_\-position@{AX12\_\-set\_\-position}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-set\_\-position]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-set\_\-position ({\bf AX12} $\ast$, \/  uint8\_\-t {\em id}, \/  uint16\_\-t {\em position})}\label{ax12_8h_adaff2efd64cf4211f2e030a980cbd54}


Set \doxyref{AX12}{p.}{structAX12} position. 



Definition at line 365 of file ax12.c.

References AA\_\-GOAL\_\-POSITION\_\-L, and AX12\_\-write\_\-int().\index{ax12.h@{ax12.h}!AX12\_\-set\_\-position2@{AX12\_\-set\_\-position2}}
\index{AX12\_\-set\_\-position2@{AX12\_\-set\_\-position2}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-set\_\-position2]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-set\_\-position2 ({\bf AX12} $\ast$, \/  uint8\_\-t {\em id}, \/  uint16\_\-t {\em position}, \/  uint16\_\-t {\em speed})}\label{ax12_8h_c58046120ebfd64006d706463ee5c7c0}


Set \doxyref{AX12}{p.}{structAX12} 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.\index{ax12.h@{ax12.h}!AX12\_\-set\_\-position3@{AX12\_\-set\_\-position3}}
\index{AX12\_\-set\_\-position3@{AX12\_\-set\_\-position3}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-set\_\-position3]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-set\_\-position3 ({\bf AX12} $\ast$, \/  uint8\_\-t {\em id}, \/  uint16\_\-t {\em position}, \/  uint16\_\-t {\em speed}, \/  uint16\_\-t {\em torque})}\label{ax12_8h_425db97da2cf66957c3968ab71a2033e}


Set \doxyref{AX12}{p.}{structAX12} 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.\index{ax12.h@{ax12.h}!AX12\_\-write\_\-byte@{AX12\_\-write\_\-byte}}
\index{AX12\_\-write\_\-byte@{AX12\_\-write\_\-byte}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-write\_\-byte]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-write\_\-byte ({\bf AX12} $\ast$, \/  uint8\_\-t {\em id}, \/  {\bf AX12\_\-ADDRESS} {\em address}, \/  uint8\_\-t {\em data})}\label{ax12_8h_bf0ecf5423c427e169115c2aacfd3630}


Write byte in AX-12 memory. 

\begin{Desc}
\item[Returns:]Error code from AX-12 (0 means okay) \end{Desc}


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.\index{ax12.h@{ax12.h}!AX12\_\-write\_\-int@{AX12\_\-write\_\-int}}
\index{AX12\_\-write\_\-int@{AX12\_\-write\_\-int}!ax12.h@{ax12.h}}
\subsubsection[AX12\_\-write\_\-int]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t AX12\_\-write\_\-int ({\bf AX12} $\ast$, \/  uint8\_\-t {\em id}, \/  {\bf AX12\_\-ADDRESS} {\em address}, \/  uint16\_\-t {\em data})}\label{ax12_8h_dc77b9cfff63ce1505cc41f955ed9775}


Write integer (2 bytes) in AX-12 memory. 

\begin{Desc}
\item[Returns:]Error code from AX-12 (0 means okay)\end{Desc}
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().