diff --git a/comm/include/comm.h b/comm/include/comm.h index c8cc9e439c9931f6208d360ffb9bb96a23918f58..6509ae74248c72b8c108e7efa6b06f407de43989 100644 --- a/comm/include/comm.h +++ b/comm/include/comm.h @@ -1,4 +1,4 @@ -/** @file */ +/** @file */ #ifndef _COMM_H #define _COMM_H @@ -35,7 +35,7 @@ typedef enum {COMM_SUCCESS=0x00,/*!< The communication module has ended successf * * Configure the DMA transactions (in case they are enabled). * * Implement the functions required by this structure to initiate and cancel * RX and TX transactions using both IRQ and DMA. - * * Implement the basic IRQ and DMa handler functions. + * * Implement the basic IRQ and DMA handler functions. * * On the user application side, another set of functions must be also implemented * and assigned to this structure at initialization time. The user application @@ -43,9 +43,9 @@ typedef enum {COMM_SUCCESS=0x00,/*!< The communication module has ended successf * required. * * In blocking mode, the IRQ driven transactions are used except when the use of - * DMA is enbaled, in which case the DMA driven transactions are used. + * DMA is enabled, in which case the DMA driven transactions are used. * - * The following diagram descrives the transmission operation when using + * The following diagram describes the transmission operation when using * interrupts, and how the user application, the communication module and the * actual communication device work together: * @@ -61,9 +61,9 @@ typedef enum {COMM_SUCCESS=0x00,/*!< The communication module has ended successf * While the data transfer is in progress the user can call the comm_is_send_done() * function to check the status of the transmission and the comm_get_error() * function to check for errors (if any). This functions can be used with any kind - * of non-blobking transactions (IRQ and DMA). + * of non-blocking transactions (IRQ and DMA). * - * The following diagram descrives the reception operation when using + * The following diagram describes the reception operation when using * interrupts, and how the user application, the communication module and the * actual communication device work together: * @@ -100,7 +100,7 @@ typedef enum {COMM_SUCCESS=0x00,/*!< The communication module has ended successf * * Finally, when the TX interrupt handler is called, the comm_do_irq_send() * function is called, in the same way it is called in a regular IRQ driven - * transmission. In this case however, its behaviour is different, because + * transmission. In this case however, its behavior is different, because * the user application callback function pointed by dma_send_cb is called, * so that the user can perform any required action. * @@ -110,7 +110,7 @@ typedef enum {COMM_SUCCESS=0x00,/*!< The communication module has ended successf * *  * - * The user application starts a DMA driven reception by calling the comm_recive_dma() + * The user application starts a DMA driven reception by calling the comm_receive_dma() * function, which in turn calls the low level communication function pointed by * the parameter receive_dma. This function should configure the DMA transfer and start * it. @@ -118,10 +118,10 @@ typedef enum {COMM_SUCCESS=0x00,/*!< The communication module has ended successf * When the desired number of bytes have been received, the reception DMA interrupt * handler is called, which calls the comm_do_dma_receive() function, calls the * user application function pointed by the dma_receive_cb parameter, so that the - * user canm perform any required action. + * user can perform any required action. * * In the case of DMA driven reception, the received data can be accessed by the - * data pointer provided to the comm_recive_dma() function, once the reception + * data pointer provided to the comm_receive_dma() function, once the reception * has ended. */ typedef struct @@ -136,7 +136,7 @@ typedef struct /** * \brief Active transmission using IRQ flag * - * This parameter is used to indicate if there is an acive transmission of data + * This parameter is used to indicate if there is an active transmission of data * using interrupts to handle it. This flag is set when a transmission starts and * it is cleared when it ends. */ @@ -144,7 +144,7 @@ typedef struct /** * \brief Active transmission using DMA flag * - * This parameter is used to indicate if there is an acive transmission of data + * This parameter is used to indicate if there is an active transmission of data * using DMA to handle it. This flag is set when a transmission starts and it is * cleared when it ends. */ @@ -166,7 +166,7 @@ typedef struct /** * \brief Active reception using IRQ flag * - * This parameter is used to indicate if there is an acive reception of data + * This parameter is used to indicate if there is an active reception of data * using interrupts to handle it. This flag is set when a reception starts and * it is cleared when it ends. */ @@ -174,7 +174,7 @@ typedef struct /** * \brief Active reception using DMA flag * - * This parameter is used to indicate if there is an acive reception of data + * This parameter is used to indicate if there is an active reception of data * using DMA to handle it. This flag is set when a reception starts and it is * cleared when it ends. */ @@ -182,7 +182,7 @@ typedef struct /** * \brief Number of bytes pending to be received * - * This parameter holds the number of bytes pending to be recevied in the current + * This parameter holds the number of bytes pending to be received in the current * transaction. This parameter is initialized when the reception starts, and * is decremented after the reception of each byte. */ @@ -226,7 +226,7 @@ typedef struct void *data; /* IRQ functions */ /** - * \defgroup harware_irq_pointers Hardware IRQ related function pointeris + * \defgroup hardware_irq_pointers Hardware IRQ related function pointers * * This set of functions, that must be implemented by the low level hardware * communication module (either USART, I2C, SPI or any other communication @@ -270,7 +270,7 @@ typedef struct /**@}*/ /* DMA functions */ /** - * \defgroup harware_dma_pointers Hardware DMA related function pointers + * \defgroup hardware_dma_pointers Hardware DMA related function pointers * * This set of functions, that must be implemented by the low level hardware * communication module (either USART, I2C, SPI or any other communication @@ -285,20 +285,20 @@ typedef struct * \brief Pointer to a function to start a transmission using DMA * * This function should configure and enable the corresponding DMA channel - * to transfer the desired ammount of data from the internal buffer to the + * to transfer the desired amount of data from the internal buffer to the * communication device. TX DMA interrupts should be enabled so that the * corresponding IRQ handler is called when the transaction is complete or - * when an error ocurrs. + * when an error occurs. */ unsigned char (*send_dma)(unsigned char *data,unsigned short int length); /** * \brief Pointer to a function to start a reception using DMA * * This function should configure and enable the corresponding DMA channel - * to transfer the desired ammount of data from the communication device to + * to transfer the desired amount of data from the communication device to * the internal buffer. RX DMA interrupts should be enabled so that the * corresponding IRQ handler is called when the transaction is complete or - * when an error ocurrs. + * when an error occurs. */ unsigned char (*receive_dma)(unsigned char *data,unsigned short int length); /** @@ -314,7 +314,7 @@ typedef struct * \defgroup callback_irq_pointers User IRQ related function pointers * * This set of functions, that must be implemented by the user module that - * uses the coomunication structure, are intended to handle the specific + * uses the communication structure, are intended to handle the specific * requirements of each application using interrupt driven communications. * * This function pointers must be assigned by the initialization function @@ -346,7 +346,7 @@ typedef struct * \defgroup callback_dma_pointers User DMA related function pointers * * This set of functions, that must be implemented by the user module that - * uses the coomunication structure, are intended to handle the specific + * uses the communication structure, are intended to handle the specific * requirements of each application using DMA driven communications. * * This function pointers must be assigned by the initialization function @@ -380,16 +380,16 @@ typedef struct * * This functions allows to enable or disable the use of the DMA. This * option can not be modified afterwards. The TTime structure, if provided, - * will allow the comunicatin device to use timeouts during reception. + * will allow the communication device to use timeouts during reception. * Otherwise, the timeout feature will be disabled. * * \param dev pointer to a valid TComm structure to be initialized. If * memory is not pre-allocated before calling this function, its * behavior is unpredictable. * \param use_dma flag to enable (0x01) or disable (0x00) the use of - * the DMA for the communcations structure. Any other value is + * the DMA for the communications structure. Any other value is * interpreted as an enable. - * \param time a pointer to an initiliazed TTime structure to enable the + * \param time a pointer to an initialized TTime structure to enable the * use of timeouts. If timeouts are not desired or required, this * parameter must be set to NULL (0x00000000). */ @@ -410,11 +410,11 @@ void comm_init(TComm *dev,unsigned char use_dma,TTime *time); * behavior is unpredictable. * \param data pointer to a vector where the data to be transmitted is stored. * Memory for this parameter must be pre-allocated before calling this - * function to avoid unexpected behaviour. + * function to avoid unexpected behavior. * \param length Number of bytes to be transmitted. * * \return the status of the transmission. The possible values are the elements - * in the comm_error ennumeraiton. + * in the comm_error enumeration. */ comm_error comm_send(TComm *dev,unsigned char *data,unsigned short int length); /** @@ -426,20 +426,20 @@ comm_error comm_send(TComm *dev,unsigned char *data,unsigned short int length); * reception is used. * * This function blocks until all bytes have been received, there has been an - * error or the ammount of time specified as timeout has elapsed. + * error or the amount of time specified as timeout has elapsed. * * \param dev pointer to a valid TComm structure to be initialized. If * memory is not pre-allocated before calling this function, its * behavior is unpredictable. * \param data pointer to a vector where the received data is to be stored. * Memory for this parameter must be pre-allocated before calling this - * function to avoid unexpected behaviour. + * function to avoid unexpected behavior. * \param length Number of bytes to be received. - * \param timeout maximum time in micro-seconds to wait for the desired ammount + * \param timeout maximum time in micro-seconds to wait for the desired amount * of bytes. If the TTime structure is not valid this parameter is ignored. * * \return the status of the transmission. The possible values are the elements - * in the comm_error ennumeraiton. + * in the comm_error enumeration. */ comm_error comm_receive(TComm *dev,unsigned char *data,unsigned short int *length,unsigned long int timeout); /* IRQ functions */ @@ -447,7 +447,7 @@ comm_error comm_receive(TComm *dev,unsigned char *data,unsigned short int *lengt * \brief Function to start an interrupt driven transmission * * This function is used to start a transmission in IRQ driven mode. This function - * starts sending the data but returns immediatelly, reporting an error, if any. + * starts sending the data but returns immediately, reporting an error, if any. * The data in the input parameter is copied to the internal buffer before it * returns. * @@ -459,11 +459,11 @@ comm_error comm_receive(TComm *dev,unsigned char *data,unsigned short int *lengt * behavior is unpredictable. * \param data pointer to a vector where the data to be transmitted is stored. * Memory for this parameter must be pre-allocated before calling this - * function to avoid unexpected behaviour. + * function to avoid unexpected behavior. * \param length Number of bytes to be transmitted. * * \return the status of the transmission. The possible values are the elements - * in the comm_error ennumeraiton. + * in the comm_error enumeration. */ comm_error comm_send_irq(TComm *dev,unsigned char *data,unsigned short int length); /** @@ -474,7 +474,7 @@ comm_error comm_send_irq(TComm *dev,unsigned char *data,unsigned short int lengt * transfer being sent, it calls the corresponding DMA transmission callback * function. * - * If this function is called as a result of a byte beign sent in an IRQ driven + * If this function is called as a result of a byte being sent in an IRQ driven * transfer, this function calls the corresponding IRQ transmission callback * function. When the last byte has been sent, this function automatically stops * the current transmission, and returns a value of 0x00 to report it. @@ -501,7 +501,7 @@ unsigned char comm_do_irq_send(TComm *dev,unsigned char *byte); * \brief Function to start an interrupt driven reception * * This function is used to start a reception in IRQ driven mode. This function - * starts the reception process but returns immediatelly, reporting an error, if any. + * starts the reception process but returns immediately, reporting an error, if any. * The received data is stored into the internal buffer, and the comm_get_received_data() * function should be used to get it. * @@ -514,7 +514,7 @@ unsigned char comm_do_irq_send(TComm *dev,unsigned char *byte); * \param length Number of bytes to be transmitted. * * \return the status of the reception. The possible values are the elements - * in the comm_error ennumeraiton. + * in the comm_error enumeration. */ comm_error comm_receive_irq(TComm *dev,unsigned short int length); @@ -523,7 +523,7 @@ comm_error comm_receive_irq(TComm *dev,unsigned short int length); * * This function should be called from the interrupt handler each time a byte has * been received. When this function is called, it first call the user defined - * function pointed by the irq_receive_cb parameter to check the receoved data + * function pointed by the irq_receive_cb parameter to check the received data * (if necessary). * * If the callback function returns 0x00, the received byte is ignored and @@ -591,7 +591,7 @@ void comm_cancel_irq_receive(TComm *dev); * behavior is unpredictable. * \param data pointer to a vector where the data to be transmitted is stored. * Memory for this parameter must be pre-allocated before calling this - * function to avoid unexpected behaviour. + * function to avoid unexpected behavior. * \param length Number of bytes to be transmitted. * * \return COMM_SUCCESS if the transmission has started successfully or COMM_BUSY @@ -626,7 +626,7 @@ void comm_do_dma_send(TComm *dev); * behavior is unpredictable. * \param data pointer to a vector where the received data will be stored. * Memory for this parameter must be pre-allocated before calling this - * function to avoid unexpected behaviour. The contents of this vector + * function to avoid unexpected behavior. The contents of this vector * are not valid until the operation has ended. * \param length Number of bytes to be received. * @@ -664,7 +664,7 @@ void comm_cancel_dma_receive(TComm *dev); /** * \brief Function to check whether the current transmission has ended or not * - * This funcion is used to check whether there is an active transmission or + * This function is used to check whether there is an active transmission or * not. In the case the transmission has ended, this function indicates if * there has been an error or not. In case of an error, use the comm_get_error() * function to get it. @@ -681,7 +681,7 @@ comm_error comm_is_send_done(TComm *dev); /** * \brief Function to check whether the current reception has ended or not * - * This funcion is used to check whether there is an active reception or + * This function is used to check whether there is an active reception or * not. In the case the reception has ended, this function indicates if * there has been an error or not. In case of an error, use the comm_get_error() * function to get it. @@ -706,7 +706,7 @@ comm_error comm_is_receive_done(TComm *dev); * behavior is unpredictable. * * \return the error of the last operation or COMM_BUSY if the operation - * is still in progess. + * is still in progress. */ inline unsigned char comm_get_error(TComm *dev); /** diff --git a/dynamixel_base/include/dynamixel.h b/dynamixel_base/include/dynamixel.h index 7be750a114b663b580e27b06116e6b6a39990309..ce76479b70e5bc89402ee07379eef854986570aa 100755 --- a/dynamixel_base/include/dynamixel.h +++ b/dynamixel_base/include/dynamixel.h @@ -10,10 +10,30 @@ #define DYN_ERROR_OFF 4 #define DYN_DATA_OFF 5 +/** + * \brief + * + */ void dyn_copy_packet(unsigned char *source, unsigned char *destination); +/** + * \brief + * + */ inline unsigned char dyn_get_id(unsigned char *packet); +/** + * \brief + * + */ inline unsigned char dyn_get_length(unsigned char *packet); +/** + * \brief + * + */ inline TDynInstruction dyn_get_instruction(unsigned char *packet); +/** + * \brief + * + */ unsigned char dyn_check_checksum(unsigned char *packet); // instruction packet @@ -27,32 +47,108 @@ typedef struct{ unsigned char checksum; }TDynInst; */ +/** + * \brief + * + */ unsigned char dyn_convert_v2_inst_packet(unsigned char *source, unsigned char *destination); /* ping instruction */ +/** + * \brief + * + */ void dyn_init_ping_packet(unsigned char *packet,unsigned char id); /* read instruction */ +/** + * \brief + * + */ void dyn_init_read_packet(unsigned char *packet,unsigned char id,unsigned char address,unsigned char length); +/** + * \brief + * + */ inline unsigned char dyn_get_read_length(unsigned char *packet); +/** + * \brief + * + */ inline unsigned char dyn_get_read_address(unsigned char *packet); /* write instruction */ +/** + * \brief + * + */ void dyn_init_write_packet(unsigned char *packet,unsigned char id,unsigned char address,unsigned char length,unsigned char *data); +/** + * \brief + * + */ inline unsigned char dyn_get_write_address(unsigned char *packet); +/** + * \brief + * + */ inline unsigned char dyn_get_write_length(unsigned char *packet); +/** + * \brief + * + */ inline unsigned char dyn_get_write_data(unsigned char *packet,unsigned char *data); /* registered write instruction */ +/** + * \brief + * + */ void dyn_init_reg_write_packet(unsigned char *packet,unsigned char id,unsigned char address,unsigned char length,unsigned char *data); +/** + * \brief + * + */ inline unsigned char dyn_get_reg_write_address(unsigned char *packet); +/** + * \brief + * + */ inline unsigned char dyn_get_reg_write_length(unsigned char *packet); +/** + * \brief + * + */ unsigned char dyn_get_reg_write_data(unsigned char *packet,unsigned char *data); /* action instruction */ +/** + * \brief + * + */ void dyn_init_action_packet(unsigned char *packet); /* reset instruction */ +/** + * \brief + * + */ void dyn_init_reset_packet(unsigned char *packet,unsigned char id); /* sync write instruction */ +/** + * \brief + * + */ void dyn_init_sync_write_packet(unsigned char *packet,unsigned char num_servos,unsigned char *servo_ids,unsigned char address,unsigned char length,unsigned char * const data[]); +/** + * \brief + * + */ unsigned char dyn_sync_write_id_present(unsigned char *packet,unsigned char id,unsigned char *address,unsigned char *length,unsigned char *data); /* bulk read instruction */ +/** + * \brief + * + */ void dyn_init_bulk_read_packet(unsigned char *packet,unsigned char num_servos,unsigned char *servo_ids,unsigned char *address,unsigned char *length); +/** + * \brief + * + */ unsigned char dyn_bulk_read_id_present(unsigned char *packet,unsigned char id,unsigned char *address,unsigned char *length); // status packet @@ -67,11 +163,31 @@ typedef struct{ }TDynStatus; */ +/** + * \brief + * + */ unsigned char dyn_convert_v2_status_packet(unsigned char *source, unsigned char *destination); +/** + * \brief + * + */ void dyn_init_status_packet(unsigned char *packet,unsigned char id,TDynError error,unsigned char length,unsigned char *data); +/** + * \brief + * + */ inline TDynError dyn_get_status_error(unsigned char *packet); /* read instruction status packet */ +/** + * \brief + * + */ unsigned char dyn_get_read_status_data(unsigned char *packet,unsigned char *data); +/** + * \brief + * + */ inline unsigned char dyn_get_read_status_id(unsigned char *packet); #endif diff --git a/dynamixel_base/include/dynamixel2.h b/dynamixel_base/include/dynamixel2.h index 94b3fd79cd4bdaa279bbb02dc92dabf702dc2857..a84821557ccf3a079fed9793e9b3c7ca3ab96133 100644 --- a/dynamixel_base/include/dynamixel2.h +++ b/dynamixel_base/include/dynamixel2.h @@ -11,10 +11,30 @@ #define DYN2_ERROR_OFF 8 #define DYN2_DATA_OFF 8 +/** + * \brief + * + */ void dyn2_copy_packet(unsigned char *source, unsigned char *destination); +/** + * \brief + * + */ inline unsigned char dyn2_get_id(unsigned char *packet); +/** + * \brief + * + */ inline unsigned short int dyn2_get_length(unsigned char *packet); +/** + * \brief + * + */ inline TDynInstruction dyn2_get_instruction(unsigned char *packet); +/** + * \brief + * + */ unsigned char dyn2_check_checksum(unsigned char *packet); // instruction packet @@ -28,38 +48,130 @@ typedef struct{ unsigned char checksum; }TDynInst; */ +/** + * \brief + * + */ unsigned char dyn2_convert_v1_inst_packet(unsigned char *source, unsigned char *destination); /* ping instruction */ +/** + * \brief + * + */ void dyn2_init_ping_packet(unsigned char *packet,unsigned char id); /* read instruction */ +/** + * \brief + * + */ void dyn2_init_read_packet(unsigned char *packet,unsigned char id,unsigned short int address,unsigned short int length); +/** + * \brief + * + */ inline unsigned short int dyn2_get_read_length(unsigned char *packet); +/** + * \brief + * + */ inline unsigned short int dyn2_get_read_address(unsigned char *packet); /* write instruction */ +/** + * \brief + * + */ void dyn2_init_write_packet(unsigned char *packet,unsigned char id,unsigned short int address,unsigned short int length,unsigned char *data); +/** + * \brief + * + */ inline unsigned short int dyn2_get_write_address(unsigned char *packet); +/** + * \brief + * + */ inline unsigned short int dyn2_get_write_length(unsigned char *packet); +/** + * \brief + * + */ inline unsigned short int dyn2_get_write_data(unsigned char *packet,unsigned char *data); /* registered write instruction */ +/** + * \brief + * + */ void dyn2_init_reg_write_packet(unsigned char *packet,unsigned char id,unsigned short int address,unsigned short int length,unsigned char *data); +/** + * \brief + * + */ inline unsigned short int dyn2_get_reg_write_address(unsigned char *packet); +/** + * \brief + * + */ inline unsigned short int dyn2_get_reg_write_length(unsigned char *packet); +/** + * \brief + * + */ unsigned short int dyn2_get_reg_write_data(unsigned char *packet,unsigned char *data); /* action instruction */ +/** + * \brief + * + */ void dyn2_init_action_packet(unsigned char *packet); /* reset instruction */ +/** + * \brief + * + */ void dyn2_init_reset_packet(unsigned char *packet,unsigned char id,unsigned char mode); /* sync write instruction */ +/** + * \brief + * + */ void dyn2_init_sync_write_packet(unsigned char *packet,unsigned char num_servos,unsigned char *servo_ids,unsigned short int address,unsigned short int length,unsigned char * const data[]); +/** + * \brief + * + */ unsigned char dyn2_sync_write_id_present(unsigned char *packet,unsigned char id,unsigned short int *address,unsigned short int *length,unsigned char *data); /* sync read instruction */ +/** + * \brief + * + */ void dyn2_init_sync_read_packet(unsigned char *packet,unsigned char num_servos,unsigned char *servo_ids,unsigned short int address,unsigned short int length); +/** + * \brief + * + */ unsigned char dyn2_sync_read_id_present(unsigned char *packet,unsigned char id,unsigned short int *address,unsigned short int *length); /* bulk read instruction */ +/** + * \brief + * + */ void dyn2_init_bulk_read_packet(unsigned char *packet,unsigned char num_servos,unsigned char *servo_ids,unsigned short int *address,unsigned short int *length); +/** + * \brief + * + */ unsigned char dyn2_bulk_read_id_present(unsigned char *packet,unsigned char id,unsigned short int *address,unsigned short int *length); /* bulk write instruction */ +/** + * \brief + * + */ void dyn2_init_bulk_write_packet(unsigned char *packet,unsigned char num_servos,unsigned char *servo_ids,unsigned short int *address,unsigned short int *length,unsigned char * const data[]); +/** + * \brief + * + */ unsigned char dyn2_bulk_write_id_present(unsigned char *packet,unsigned char id,unsigned short int *address,unsigned short int *length,unsigned char *data); // status packet @@ -74,11 +186,31 @@ typedef struct{ }TDynStatus; */ +/** + * \brief + * + */ unsigned char dyn2_convert_v1_status_packet(TDynInstruction inst,unsigned char *source, unsigned char *destination); +/** + * \brief + * + */ void dyn2_init_status_packet(unsigned char *packet,unsigned char id,TDynError error,unsigned short int length,unsigned char *data); +/** + * \brief + * + */ inline TDynError dyn2_get_status_error(unsigned char *packet); /* read instruction status packet */ +/** + * \brief + * + */ unsigned short int dyn2_get_read_status_data(unsigned char *packet,unsigned char *data); +/** + * \brief + * + */ inline unsigned char dyn2_get_read_status_id(unsigned char *packet); #endif diff --git a/dynamixel_base/include/dynamixel_common.h b/dynamixel_base/include/dynamixel_common.h index 97f44b15e91d70caa343715c0a756f1b08614857..1ec207d610aea42fa96b6d26c8d52ed46fe8df2b 100644 --- a/dynamixel_base/include/dynamixel_common.h +++ b/dynamixel_base/include/dynamixel_common.h @@ -1,3 +1,5 @@ +/** @file */ + #ifndef _DYNAMIXEL_COMMON_H #define _DYNAMIXEL_COMMON_H @@ -13,34 +15,55 @@ #define DYN_COMM_ERROR 4 #define DYN_BUSY 5 -typedef enum{no_return=0x00, - return_only_read=0x01, - return_all=0x02} return_level_t; +/** + * \brief Possible return levels + * + */ +typedef enum{no_return=0x00,/*!< Only the PING command will return an aswer */ + return_only_read=0x01,/*!< Only the read commands will return an answer */ + return_all=0x02/*!< All commands will return an aswer. This is the default value */ + } return_level_t; // possible packet types -typedef enum{DYN_PING=0x01, - DYN_READ=0x02, - DYN_WRITE=0x03, - DYN_REG_WRITE=0x04, - DYN_ACTION=0x05, - DYN_RESET=0x06, - DYN_SYNC_READ=0x82, - DYN_SYNC_WRITE=0x83, - DYN_BULK_READ=0x92, - DYN_BULK_WRITE=0x93} TDynInstruction; +/** + * \brief Possible instructions + * + */ +typedef enum{DYN_PING=0x01,/*!< Ping. Instruction to detect the presence of dynamixel devices */ + DYN_READ=0x02,/*!< Read. Instruction to read a consecutive number of registers starting from a given address from a single device */ + DYN_WRITE=0x03,/*!< Write. Instruction to write a consecutive number of registers starting at a given address to a given device*/ + DYN_REG_WRITE=0x04,/*!< Registerd write. Instruction to execute a delayed write operation */ + DYN_ACTION=0x05,/*!< Action. Instruction to actually load the data of a previous registeres write instruction*/ + DYN_RESET=0x06,/*!< Reset. Instruction to reset the device to a default state */ + DYN_SYNC_READ=0x82,/*!< Synchronous read. Instruction to read a consecutive number of registers starting from a given address from multiples devices */ + DYN_SYNC_WRITE=0x83,/*!< Synchronous write. Instruction to write a consecutive number of registers starting at a given address to multiple devices */ + DYN_BULK_READ=0x92,/*!< Bulk read. Instruction to read a set of consecutive registers from multiples devices, starting at a different address for each device */ + DYN_BULK_WRITE=0x93/*!< Bulk write. Instruction to write a set of consecutive registers to multiples devices, starting at a different address for each device */ + } TDynInstruction; // boradcast ID -#define DYN_BROADCAST_ID 0xFE +#define DYN_BROADCAST_ID 0xFE/*!< Broadcast ID */ // status packet -typedef enum{DYN_NO_ERROR=0x00, - DYN_INST_ERROR=0x40, - DYN_OVERLOAD_ERROR=0x20, - DYN_CHECKSUM_ERROR=0x10, - DYN_RANGE_ERROR=0x08, - DYN_OVERTEMP_ERROR=0x04, - DYN_ANGLE_ERROR=0x02, - DYN_VOLTAGE_ERROR=0x01} TDynError; - -typedef enum{DYN_VER1=0x01,DYN_VER2=0x02} TDynVersion; +/** + * \brief Possible errors + * + */ +typedef enum{DYN_NO_ERROR=0x00,/*!< No error */ + DYN_INST_ERROR=0x40,/*!< Invalid Instruction identifier */ + DYN_OVERLOAD_ERROR=0x20,/*!< Servo exceeded the maximum torque value */ + DYN_CHECKSUM_ERROR=0x10,/*!< Invalid checksum on the instruction packet */ + DYN_RANGE_ERROR=0x08,/*!< Register value out of the allowed range */ + DYN_OVERTEMP_ERROR=0x04,/*!< Temperature exceeded the maximum value */ + DYN_ANGLE_ERROR=0x02,/*!< Target position out of range */ + DYN_VOLTAGE_ERROR=0x01/*!< Power supply voltage out of range */ + } TDynError; + +/** + * \brief Dynamixel versions + * + */ +typedef enum{DYN_VER1=0x01,/*!< Dynamixel version 1.0 */ + DYN_VER2=0x02/*!< Dynamixel version 2.0 */ + } TDynVersion; #endif diff --git a/dynamixel_base/include/dynamixel_master.h b/dynamixel_base/include/dynamixel_master.h index cdadf096faf39dc2fd2cd60943f9aa7e5eb98072..47af3de41b3ca73dfbef33300363ade0ec8a53e0 100644 --- a/dynamixel_base/include/dynamixel_master.h +++ b/dynamixel_base/include/dynamixel_master.h @@ -14,42 +14,174 @@ #define MAX_DYN_MASTER_RX_BUFFER_LEN 1024 #endif +/** + * \brief + * + */ typedef struct { + /** + * \brief + * + */ TComm *comm_dev; + /** + * \brief + * + */ TDynVersion version; + /** + * \brief + * + */ unsigned short int op_length; + /** + * \brief + * + */ unsigned char tx_buffer[MAX_DYN_MASTER_TX_BUFFER_LEN]; + /** + * \brief + * + */ unsigned char rx_buffer[MAX_DYN_MASTER_RX_BUFFER_LEN]; + /** + * \brief + * + */ return_level_t return_level; + /** + * \brief + * + */ unsigned char packet_ready; + /** + * \brief + * + */ unsigned char received_bytes; + /** + * \brief + * + */ void (*set_tx_mode)(void); + /** + * \brief + * + */ void (*set_rx_mode)(void); + /** + * \brief + * + */ unsigned short int rx_timeout_ms; + /** + * \brief + * + */ unsigned char rx_no_answer; + /** + * \brief + * + */ unsigned char rx_num_packets; }TDynamixelMaster; /* public functions */ +/** + * \brief + * + */ void dyn_master_init(TDynamixelMaster *master,TComm *dev,TDynVersion version); +/** + * \brief + * + */ inline void dyn_master_set_rx_timeout(TDynamixelMaster *master,unsigned short int timeout_ms); +/** + * \brief + * + */ inline void dyn_master_set_return_level(TDynamixelMaster *master,return_level_t level); +/** + * \brief + * + */ inline return_level_t dyn_master_get_return_level(TDynamixelMaster *master); +/** + * \brief + * + */ void dyn_master_scan(TDynamixelMaster *master,unsigned char *num,unsigned char *ids); +/** + * \brief + * + */ unsigned char dyn_master_ping(TDynamixelMaster *master,unsigned char id); +/** + * \brief + * + */ unsigned char dyn_master_read_byte(TDynamixelMaster *master,unsigned char id,unsigned short int address,unsigned char *data); +/** + * \brief + * + */ unsigned char dyn_master_read_word(TDynamixelMaster *master,unsigned char id,unsigned short int address,unsigned short int *data); +/** + * \brief + * + */ unsigned char dyn_master_read_table(TDynamixelMaster *master,unsigned char id,unsigned short int address,unsigned short int length,unsigned char *data); +/** + * \brief + * + */ unsigned char dyn_master_write_byte(TDynamixelMaster *master,unsigned char id, unsigned short int address, unsigned char data); +/** + * \brief + * + */ unsigned char dyn_master_write_word(TDynamixelMaster *master,unsigned char id, unsigned short int address, unsigned short int data); +/** + * \brief + * + */ unsigned char dyn_master_write_table(TDynamixelMaster *master,unsigned char id, unsigned short int address, unsigned short int length,unsigned char *data); +/** + * \brief + * + */ unsigned char dyn_master_reg_write(TDynamixelMaster *master,unsigned char id, unsigned short int address, unsigned short int length,unsigned char *data); +/** + * \brief + * + */ unsigned char dyn_master_action(TDynamixelMaster *master); +/** + * \brief + * + */ unsigned char dyn_master_sync_write(TDynamixelMaster *master,unsigned char num,unsigned char *ids,unsigned short int address, unsigned short int length, unsigned char * const data[]); +/** + * \brief + * + */ unsigned char dyn_master_sync_read(TDynamixelMaster *master,unsigned char num,unsigned char *ids,unsigned short int address, unsigned short int length, unsigned char * const data[]); +/** + * \brief + * + */ unsigned char dyn_master_bulk_read(TDynamixelMaster *master,unsigned char num,unsigned char *ids,unsigned short int *address, unsigned short int *length, unsigned char * const data[]); +/** + * \brief + * + */ unsigned char dyn_master_bulk_write(TDynamixelMaster *master,unsigned char num,unsigned char *ids,unsigned short int *address, unsigned short int *length, unsigned char * const data[]); +/** + * \brief + * + */ unsigned char dyn_master_relay(TDynamixelMaster *master,unsigned char *inst_pkt,unsigned char *status_pkt); #endif diff --git a/dynamixel_base/include/dynamixel_slave.h b/dynamixel_base/include/dynamixel_slave.h index 0d1e51492bad1096687da25e2eee01632110b805..dc6f65e82e22c3239413301a36f7aaa9bbaf19a9 100644 --- a/dynamixel_base/include/dynamixel_slave.h +++ b/dynamixel_base/include/dynamixel_slave.h @@ -17,46 +17,194 @@ #define MAX_DYN_SLAVE_REG_BUFFER_LEN 1024 #endif +/** + * \brief + * + */ typedef struct { + /** + * \brief + * + */ TComm *comm_dev; + /** + * \brief + * + */ TDynVersion version; + /** + * \brief + * + */ unsigned char address; + /** + * \brief + * + */ unsigned char return_delay; + /** + * \brief + * + */ return_level_t return_level; + /** + * \brief + * + */ unsigned char packet_ready; + /** + * \brief + * + */ unsigned char received_bytes; + /** + * \brief + * + */ unsigned short int rx_timeout_ms; + /** + * \brief + * + */ unsigned short int op_length; + /** + * \brief + * + */ unsigned char tx_buffer[MAX_DYN_SLAVE_TX_BUFFER_LEN]; + /** + * \brief + * + */ unsigned char rx_buffer[MAX_DYN_SLAVE_RX_BUFFER_LEN]; + /** + * \brief + * + */ unsigned short int reg_address; + /** + * \brief + * + */ unsigned short int reg_length; + /** + * \brief + * + */ unsigned char reg_buffer[MAX_DYN_SLAVE_REG_BUFFER_LEN]; + /** + * \brief + * + */ unsigned short int sync_bulk_address; + /** + * \brief + * + */ unsigned short int sync_bulk_length; + /** + * \brief + * + */ unsigned char sync_bulk_prev_id; + /** + * \brief + * + */ unsigned char sync_read_pending; + /** + * \brief + * + */ unsigned char bulk_read_pending; + /** + * \brief + * + */ void (*set_tx_mode)(void); + /** + * \brief + * + */ void (*set_rx_mode)(void); + /** + * \brief + * + */ void (*on_ping)(void); + /** + * \brief + * + */ unsigned char (*on_read)(unsigned short int address,unsigned short int length,unsigned char *data); + /** + * \brief + * + */ unsigned char (*on_write)(unsigned short int address,unsigned short int length,unsigned char *data); + /** + * \brief + * + */ unsigned char (*on_reset)(void); + /** + * \brief + * + */ unsigned char (*on_relay)(TDynVersion version,unsigned char *inst_pkt,unsigned char *status_pkt); }TDynamixelSlave; /* public functions */ +/** + * \brief + * + */ void dyn_slave_init(TDynamixelSlave *slave,TComm *dev,unsigned char address,TDynVersion version); +/** + * \brief + * + */ inline void dyn_slave_set_rx_timeout(TDynamixelSlave *slave,unsigned short int timeout_ms); +/** + * \brief + * + */ inline void dyn_slave_set_address(TDynamixelSlave *slave,unsigned char address); +/** + * \brief + * + */ inline unsigned char dyn_slave_get_address(TDynamixelSlave *slave); +/** + * \brief + * + */ inline void dyn_slave_set_return_delay(TDynamixelSlave *slave,unsigned char delay); +/** + * \brief + * + */ inline unsigned char dyn_slave_get_return_delay(TDynamixelSlave *slave); +/** + * \brief + * + */ inline void dyn_slave_set_return_level(TDynamixelSlave *slave,return_level_t level); +/** + * \brief + * + */ inline return_level_t dyn_slave_get_return_level(TDynamixelSlave *slave); +/** + * \brief + * + */ inline TDynVersion dyn_slave_get_version(TDynamixelSlave *slave); +/** + * \brief + * + */ void dyn_slave_loop(TDynamixelSlave *slave); diff --git a/utils/include/buffer.h b/utils/include/buffer.h index 794c92c04d209e91deb1a11504ab52814e4ec8ec..18382d2460faab2935d1830ffcd8102c0dc603c4 100644 --- a/utils/include/buffer.h +++ b/utils/include/buffer.h @@ -1,4 +1,4 @@ -/** @file */ +/** @file */ #ifndef _BUFFER_H #define _BUFFER_H @@ -151,7 +151,7 @@ unsigned char buffer_write_byte(TBuffer *buffer,unsigned char data); * behavior is unpredictable. * \param data pointer to a byte variable to store the buffer data. Memory for * this parameter must be pre-allocated before calling this function - * to avoid unexpected behaviour. + * to avoid unexpected behavior. * * \return This function returns 1 on success and 0 otherwise. */ @@ -172,11 +172,11 @@ unsigned char buffer_read_byte(TBuffer *buffer,unsigned char *data); * behavior is unpredictable. * \param data pointer to a byte vector variable with the data to be written to * the buffer. Memory for this parameter must be pre-allocated before calling - * this function to avoid unexpected behaviour. + * this function to avoid unexpected behavior. * \param length number of bytes to be written into the buffer. * * \return number of bytes actually written into the buffer. This value can be used - * to check wether the function was successfull or not. + * to check whether the function was successful or not. */ unsigned short int buffer_write(TBuffer *buffer,unsigned char *data,unsigned short int length); /** @@ -194,11 +194,11 @@ unsigned short int buffer_write(TBuffer *buffer,unsigned char *data,unsigned sho * behavior is unpredictable. * \param data pointer to a byte vector variable to store the buffer data. Memory for * this parameter must be pre-allocated before calling this function to avoid - * unexpected behaviour. + * unexpected behavior. * \param length number of bytes to be read from the buffer. * * \return number of bytes actually read from the buffer. This value can be used - * to check wether the function was successfull or not. + * to check whether the function was successful or not. */ unsigned short int buffer_read(TBuffer *buffer,unsigned char *data,unsigned short int length); diff --git a/utils/include/stm32_time.h b/utils/include/stm32_time.h index 2eed9f5908db54df8e8366294fe629d51a884477..22d7f45268c7274bda8d58ab8f1d41dfcbe700f5 100644 --- a/utils/include/stm32_time.h +++ b/utils/include/stm32_time.h @@ -1,4 +1,4 @@ -/** @file */ +/** @file */ #ifndef _STM32_TIME_H #define _STM32_TIME_H @@ -17,7 +17,7 @@ * * A time structure is first initialized by calling the time_init() function. * Using this structure, it is possible to implement delays in - * seconds (time_delay_s()), milli-seconds (time_delay_ms()) and micro-seconds + * seconds (time_delay_s()), Milli-seconds (time_delay_ms()) and micro-seconds * (time_delay_us()), and also start (time_set_timeout()) and cancel * (time_cancel_timeout()) timeout, as well as checks its status (time_is_timeout()). * @@ -55,7 +55,7 @@ typedef struct * and returns the accumulated number of timer counts since the last reset as an * unsigned long long variable (8 bytes in most architectures). * - * This pointer must be provided at initilaization time when the time_init() function + * This pointer must be provided at initialization time when the time_init() function * is called, and should not be modified afterwards. * */ @@ -83,7 +83,7 @@ void time_init(TTime *time,int counts_per_us,unsigned long long int(*get_time)(v * \brief Function to set the desired timeout in micro-seconds * * This functions sets the desired time to generate a timeout event if it is not - * canceller by the time_cancel_timeout() function. After calling this function, + * canceled by the time_cancel_timeout() function. After calling this function, * the time_is_timeout() function will return true if the current time is past * the time when this function was called plus the desired timeout value. * @@ -129,9 +129,9 @@ void time_cancel_timeout(TTime *time); /** * \brief Function to wait a given time in micro-seconds * - * This function blocks until the specifierd time in micro-seconds has elapsed. + * This function blocks until the specified time in micro-seconds has elapsed. * If this function is called when there is an active timeout, the timeout is - * automatically cancelled. + * automatically canceled. * * \param time pointer to a valid TTime structure to be initialized. If * memory is not pre-allocated before calling this function, its @@ -140,24 +140,24 @@ void time_cancel_timeout(TTime *time); */ void time_delay_us(TTime *time,int delay_us); /** - * \brief Function to wait a given time in milli-seconds + * \brief Function to wait a given time in Milli-seconds * - * This function blocks until the specifierd time in milli-seconds has elapsed. + * This function blocks until the specified time in Milli-seconds has elapsed. * If this function is called when there is an active timeout, the timeout is - * automatically cancelled. + * automatically canceled. * * \param time pointer to a valid TTime structure to be initialized. If * memory is not pre-allocated before calling this function, its * behavior is unpredictable. - * \param delay_ms value of the desired delay in milli-seconds + * \param delay_ms value of the desired delay in Milli-seconds */ void time_delay_ms(TTime *time,int delay_ms); /** * \brief Function to wait a given time in seconds * - * This function blocks until the specifierd time in seconds has elapsed. + * This function blocks until the specified time in seconds has elapsed. * If this function is called when there is an active timeout, the timeout is - * automatically cancelled. + * automatically canceled. * * \param time pointer to a valid TTime structure to be initialized. If * memory is not pre-allocated before calling this function, its