diff --git a/robotis_lib/Release Note.txt b/robotis_lib/Release Note.txt deleted file mode 100755 index f28ac0b2cefcacc75d2fb7f52d64d16ac599d12c..0000000000000000000000000000000000000000 --- a/robotis_lib/Release Note.txt +++ /dev/null @@ -1,32 +0,0 @@ -====================================================== - CM-510 Library & Example Version / v1.01 -====================================================== - ->>> New functionality/features: <<< - - * First released. - ->>> Changes: <<< - - * None - ->>> Bug fixes: <<< - - * 'Dynamixel.c' bug fixed. - - -====================================================== - CM-510 Library & Example Version / v1.00 -====================================================== - ->>> New functionality/features: <<< - - * First released. - ->>> Changes: <<< - - * None - ->>> Bug fixes: <<< - - * None \ No newline at end of file diff --git a/robotis_lib/example/Button/Button.c b/robotis_lib/example/Button/Button.c deleted file mode 100755 index 6e693b2138c0d649e291228fd104c602802f5798..0000000000000000000000000000000000000000 --- a/robotis_lib/example/Button/Button.c +++ /dev/null @@ -1,53 +0,0 @@ -//########################################################## -//## R O B O T I S ## -//## CM-510 (Atmega2561) Example code for Button. ## -//## 2009.11.10 ## -//########################################################## - - -#include <avr/io.h> - -#define LED_BAT 0x01 -#define LED_TxD 0x02 -#define LED_RxD 0x04 -#define LED_AUX 0x08 -#define LED_MANAGE 0x10 -#define LED_PROGRAM 0x20 -#define LED_PLAY 0x40 - -#define BTN_UP 0x10 -#define BTN_DOWN 0x20 -#define BTN_LEFT 0x40 -#define BTN_RIGHT 0x80 -#define BTN_START 0x01 - -int main(void) -{ - DDRC = 0x7F; - PORTC = 0x7E; - - DDRD = 0x70; - PORTD = 0x11; - - DDRE = 0x0C; - PORTE = 0xF0; - - while (1) - { - if(~PINE & BTN_UP) - PORTC &= ~LED_MANAGE; - else if(~PINE & BTN_DOWN) - PORTC &= ~LED_AUX; - - else if(~PINE & BTN_LEFT) - PORTC &= ~LED_PROGRAM; - - else if(~PINE & BTN_RIGHT) - PORTC &= ~LED_PLAY; - - else if(~PIND & BTN_START) - PORTC = ~(LED_BAT|LED_TxD|LED_RxD|LED_AUX|LED_MANAGE|LED_PROGRAM|LED_PLAY); - else PORTC = LED_BAT|LED_TxD|LED_RxD|LED_AUX|LED_MANAGE|LED_PROGRAM|LED_PLAY; - } - return 1; -} diff --git a/robotis_lib/example/Buzzer/Buzzer.c b/robotis_lib/example/Buzzer/Buzzer.c deleted file mode 100755 index 6a6ebcd16decd9d7ecde1040e15a3affbefa72ec..0000000000000000000000000000000000000000 --- a/robotis_lib/example/Buzzer/Buzzer.c +++ /dev/null @@ -1,54 +0,0 @@ -//########################################################## -//## R O B O T I S ## -//## CM-510 (Atmega2561) Example code for Buzzer. ## -//## 2009.11.10 ## -//########################################################## - - -#include <avr/io.h> -#include <util/delay.h> - -#define LED_BAT 0x01 -#define LED_TxD 0x02 -#define LED_RxD 0x04 -#define LED_AUX 0x08 -#define LED_MANAGE 0x10 -#define LED_PROGRAM 0x20 -#define LED_PLAY 0x40 - -#define SW_UP 0x10 -#define SW_DOWN 0x20 -#define SW_LEFT 0x40 -#define SW_RIGHT 0x80 -#define SW_START 0x01 - -int main(void) -{ - DDRB = 0x20; - PORTB = 0x00; - - DDRC = 0x7F; - PORTC = 0x7E; - - DDRD = 0x70; - PORTD = 0x11; - - while (1) - { - if(~PIND & SW_START) - { - PORTC = ~(LED_BAT|LED_TxD|LED_RxD|LED_AUX|LED_MANAGE|LED_PROGRAM|LED_PLAY); - _delay_ms(1); - PORTB |= 0x20; - _delay_ms(1); - PORTB &= ~0x20; - } - else - { - PORTC = LED_BAT|LED_TxD|LED_RxD|LED_AUX|LED_MANAGE|LED_PROGRAM|LED_PLAY; - PORTB &= ~0x20; - } - } - return 1; -} - diff --git a/robotis_lib/example/Dynamixel_Read_Write/Read_Write.c b/robotis_lib/example/Dynamixel_Read_Write/Read_Write.c deleted file mode 100755 index fae95ced61efe012bf99f7df42d8323236d12fc9..0000000000000000000000000000000000000000 --- a/robotis_lib/example/Dynamixel_Read_Write/Read_Write.c +++ /dev/null @@ -1,135 +0,0 @@ -//########################################################## -//## R O B O T I S ## -//## CM-510 (Atmega2561) Example code for Dynamixel. ## -//## 2009.11.10 ## -//########################################################## - -#include <avr/io.h> -#include <avr/interrupt.h> -#include <stdio.h> - -#include "dynamixel.h" -#include "serial.h" - -/// Control table address -#define P_GOAL_POSITION_L 30 -#define P_GOAL_POSITION_H 31 -#define P_PRESENT_POSITION_L 36 -#define P_PRESENT_POSITION_H 37 -#define P_MOVING 46 - -// Defulat setting -#define DEFAULT_BAUDNUM 1 // 1Mbps -#define DEFAULT_ID 1 - -void PrintCommStatus(int CommStatus); -void PrintErrorCode(void); - -int main(void) -{ - unsigned short GoalPos[2] = {0, 1023}; - //unsigned short GoalPos[2] = {0, 4095}; // for EX series - int index = 0; - int id = 1; - int bMoving, wPresentPos; - int CommStatus; - - serial_initialize(57600); - dxl_initialize( 0, DEFAULT_BAUDNUM ); // Not using device index - sei(); // Interrupt Enable - - printf( "\n\nRead/Write example for CM-510\n\n" ); - - while(1) - { - // Check moving done - bMoving = dxl_read_byte( id, P_MOVING ); - CommStatus = dxl_get_result(); - if( CommStatus == COMM_RXSUCCESS ) - { - if( bMoving == 0 ) - { - // Change goal position - if( index == 0 ) - index = 1; - else - index = 0; - - // Write goal position - dxl_write_word( id, P_GOAL_POSITION_L, GoalPos[index] ); - } - - PrintErrorCode(); - - // Read present position - wPresentPos = dxl_read_word( id, P_PRESENT_POSITION_L ); - printf( "%d %d\n",GoalPos[index], wPresentPos ); - } - else - PrintCommStatus(CommStatus); - - } - - return 0; -} - -// Print communication result -void PrintCommStatus(int CommStatus) -{ - switch(CommStatus) - { - case COMM_TXFAIL: - printf("COMM_TXFAIL: Failed transmit instruction packet!\n"); - break; - - case COMM_TXERROR: - printf("COMM_TXERROR: Incorrect instruction packet!\n"); - break; - - case COMM_RXFAIL: - printf("COMM_RXFAIL: Failed get status packet from device!\n"); - break; - - case COMM_RXWAITING: - printf("COMM_RXWAITING: Now recieving status packet!\n"); - break; - - case COMM_RXTIMEOUT: - printf("COMM_RXTIMEOUT: There is no status packet!\n"); - break; - - case COMM_RXCORRUPT: - printf("COMM_RXCORRUPT: Incorrect status packet!\n"); - break; - - default: - printf("This is unknown error code!\n"); - break; - } -} - -// Print error bit of status packet -void PrintErrorCode() -{ - if(dxl_get_rxpacket_error(ERRBIT_VOLTAGE) == 1) - printf("Input voltage error!\n"); - - if(dxl_get_rxpacket_error(ERRBIT_ANGLE) == 1) - printf("Angle limit error!\n"); - - if(dxl_get_rxpacket_error(ERRBIT_OVERHEAT) == 1) - printf("Overheat error!\n"); - - if(dxl_get_rxpacket_error(ERRBIT_RANGE) == 1) - printf("Out of range error!\n"); - - if(dxl_get_rxpacket_error(ERRBIT_CHECKSUM) == 1) - printf("Checksum error!\n"); - - if(dxl_get_rxpacket_error(ERRBIT_OVERLOAD) == 1) - printf("Overload error!\n"); - - if(dxl_get_rxpacket_error(ERRBIT_INSTRUCTION) == 1) - printf("Instruction code error!\n"); -} - diff --git a/robotis_lib/example/Dynamixel_Sync_Write/Sync_Write.c b/robotis_lib/example/Dynamixel_Sync_Write/Sync_Write.c deleted file mode 100755 index 3787c88776eb47940a542a93ce612003db2da550..0000000000000000000000000000000000000000 --- a/robotis_lib/example/Dynamixel_Sync_Write/Sync_Write.c +++ /dev/null @@ -1,157 +0,0 @@ -//########################################################## -//## R O B O T I S ## -//## CM-510 (Atmega2561) Example code for Dynamixel. ## -//## 2009.11.10 ## -//########################################################## - -#include <avr/io.h> -#include <avr/interrupt.h> -#include <stdio.h> -#include <math.h> -#include <util/delay.h> - -#include "serial.h" -#include "dynamixel.h" - -#define PI 3.141592f - -/// Control table address -#define P_GOAL_POSITION_L 30 -#define P_GOAL_POSITION_H 31 -#define P_GOAL_SPEED_L 32 -#define P_GOAL_SPEED_H 33 - -// Defulat setting -#define DEFAULT_BAUDNUM 1 // 1Mbps -#define NUM_ACTUATOR 3 // Number of actuator -#define STEP_THETA (PI / 100.0f) // Large value is more fast -#define CONTROL_PERIOD (10) // msec (Large value is more slow) - -void PrintCommStatus(int CommStatus); -void PrintErrorCode(void); - -int main(void) -{ - int id[NUM_ACTUATOR]; - float phase[NUM_ACTUATOR]; - float theta = 0; - int AmpPos = 512; - //int AmpPos = 2048; // for EX series - int GoalPos; - int i; - int CommStatus; - - serial_initialize(57600); - dxl_initialize( 0, DEFAULT_BAUDNUM ); // Not using device index - sei(); // Interrupt Enable - - printf( "\n\nSyncWrite example for CM-510\n\n" ); - - for( i=0; i<NUM_ACTUATOR; i++ ) - { - id[i] = i+1; - phase[i] = 2*PI * (float)i / (float)NUM_ACTUATOR; - } - - // Set goal speed - dxl_write_word( BROADCAST_ID, P_GOAL_SPEED_L, 0 ); - // Set goal position - dxl_write_word( BROADCAST_ID, P_GOAL_POSITION_L, AmpPos ); - _delay_ms(1000); - - while(1) - { - // Make syncwrite packet - dxl_set_txpacket_id(BROADCAST_ID); - dxl_set_txpacket_instruction(INST_SYNC_WRITE); - dxl_set_txpacket_parameter(0, P_GOAL_POSITION_L); - dxl_set_txpacket_parameter(1, 2); - for( i=0; i<NUM_ACTUATOR; i++ ) - { - dxl_set_txpacket_parameter(2+3*i, id[i]); - GoalPos = (int)((sin(theta+phase[i]) + 1.0) * (float)AmpPos); - printf( "%d ", GoalPos ); - dxl_set_txpacket_parameter(2+3*i+1, dxl_get_lowbyte(GoalPos)); - dxl_set_txpacket_parameter(2+3*i+2, dxl_get_highbyte(GoalPos)); - } - dxl_set_txpacket_length((2+1)*NUM_ACTUATOR+4); - - printf( "\n" ); - - dxl_txrx_packet(); - CommStatus = dxl_get_result(); - if( CommStatus == COMM_RXSUCCESS ) - PrintErrorCode(); - else - PrintCommStatus(CommStatus); - - theta += STEP_THETA; - - if( theta > 2*PI ) - theta -= 2*PI; - _delay_ms(CONTROL_PERIOD); - } - - return 0; -} - -// Print communication result -void PrintCommStatus(int CommStatus) -{ - switch(CommStatus) - { - case COMM_TXFAIL: - printf("COMM_TXFAIL: Failed transmit instruction packet!\n"); - break; - - case COMM_TXERROR: - printf("COMM_TXERROR: Incorrect instruction packet!\n"); - break; - - case COMM_RXFAIL: - printf("COMM_RXFAIL: Failed get status packet from device!\n"); - break; - - case COMM_RXWAITING: - printf("COMM_RXWAITING: Now recieving status packet!\n"); - break; - - case COMM_RXTIMEOUT: - printf("COMM_RXTIMEOUT: There is no status packet!\n"); - break; - - case COMM_RXCORRUPT: - printf("COMM_RXCORRUPT: Incorrect status packet!\n"); - break; - - default: - printf("This is unknown error code!\n"); - break; - } -} - -// Print error bit of status packet -void PrintErrorCode() -{ - if(dxl_get_rxpacket_error(ERRBIT_VOLTAGE) == 1) - printf("Input voltage error!\n"); - - if(dxl_get_rxpacket_error(ERRBIT_ANGLE) == 1) - printf("Angle limit error!\n"); - - if(dxl_get_rxpacket_error(ERRBIT_OVERHEAT) == 1) - printf("Overheat error!\n"); - - if(dxl_get_rxpacket_error(ERRBIT_RANGE) == 1) - printf("Out of range error!\n"); - - if(dxl_get_rxpacket_error(ERRBIT_CHECKSUM) == 1) - printf("Checksum error!\n"); - - if(dxl_get_rxpacket_error(ERRBIT_OVERLOAD) == 1) - printf("Overload error!\n"); - - if(dxl_get_rxpacket_error(ERRBIT_INSTRUCTION) == 1) - printf("Instruction code error!\n"); -} - diff --git a/robotis_lib/example/IR/IR.c b/robotis_lib/example/IR/IR.c deleted file mode 100755 index 444248887319a9475c63e140cc8eea302bff95d5..0000000000000000000000000000000000000000 --- a/robotis_lib/example/IR/IR.c +++ /dev/null @@ -1,56 +0,0 @@ -//########################################################## -//## R O B O T I S ## -//## CM-510 (Atmega2561) Example code for IR Sensor. ## -//## 2009.11.10 ## -//########################################################## - - -#include <avr/io.h> -#include <stdio.h> -#include <util/delay.h> -#include <avr/interrupt.h> -#include "serial.h" - -#define ADC_PORT_1 1 -#define ADC_PORT_2 2 -#define ADC_PORT_3 3 -#define ADC_PORT_4 4 -#define ADC_PORT_5 5 -#define ADC_PORT_6 6 - -int main(void) -{ - DDRA = 0xFC; - PORTA = 0xFC; - - serial_initialize(57600); - sei(); - - ADCSRA = (1 << ADEN) | (1 << ADPS2) | (1 << ADPS1); // ADC Enable, Clock 1/64div. - ADMUX = ADC_PORT_1; // ADC Port 1 Select - - printf( "\n\nIR example for CM-510\n\n" ); - - while (1) - { - PORTA &= ~0x80; // ADC Port 1 IR ON -// PORTA &= ~0x40; // ADC Port 2 IR ON -// PORTA &= ~0x20; // ADC Port 3 IR ON -// PORTA &= ~0x10; // ADC Port 4 IR ON -// PORTA &= ~0x08; // ADC Port 5 IR ON -// PORTA &= ~0x04; // ADC Port 6 IR ON - - _delay_us(12); // Short Delay for rising sensor signal - ADCSRA |= (1 << ADIF); // AD-Conversion Interrupt Flag Clear - ADCSRA |= (1 << ADSC); // AD-Conversion Start - - while( !(ADCSRA & (1 << ADIF)) ); // Wait until AD-Conversion complete - - PORTA = 0xFC; // IR-LED Off - - printf( "%d\r\n", ADC); // Print Value on USART - - _delay_ms(50); - } - return 1; -} diff --git a/robotis_lib/example/LED/LED.c b/robotis_lib/example/LED/LED.c deleted file mode 100755 index f93c933d626536f33a7027938dfcbc4db25d6afb..0000000000000000000000000000000000000000 --- a/robotis_lib/example/LED/LED.c +++ /dev/null @@ -1,26 +0,0 @@ -//########################################################## -//## R O B O T I S ## -//## CM-510 (Atmega2561) Example code for LED. ## -//## 2009.11.10 ## -//########################################################## - - -#include <avr/io.h> -#include <util/delay.h> - -int main(void) -{ - DDRC = 0x7F; - PORTC = 0x7E; - - while (1) - { - int i; - for(i = 0; i <= 6; i++) - { - PORTC = ~(1<<i); - _delay_ms(250); - } - } - return 1; -} diff --git a/robotis_lib/example/Mic/Mic.c b/robotis_lib/example/Mic/Mic.c deleted file mode 100755 index 14c73af32f3319649420627542c1397622c385d0..0000000000000000000000000000000000000000 --- a/robotis_lib/example/Mic/Mic.c +++ /dev/null @@ -1,39 +0,0 @@ -//########################################################## -//## R O B O T I S ## -//## CM-510 (Atmega2561) Example code for Mic. ## -//## 2009.11.10 ## -//########################################################## - - -#include <avr/io.h> -#include <util/delay.h> - -#define LED_BAT 0x01 -#define LED_TxD 0x02 -#define LED_RxD 0x04 -#define LED_AUX 0x08 -#define LED_MANAGE 0x10 -#define LED_PROGRAM 0x20 -#define LED_PLAY 0x40 - -#define MIC_SIGNAL 0x02 - -int main(void) -{ - DDRC = 0x7F; - PORTC = 0x7E; - - DDRD = 0x70; - PORTD = 0x13; - - while (1) - { - if(~PIND & MIC_SIGNAL) - { - PORTC = ~(LED_BAT|LED_TxD|LED_RxD|LED_AUX|LED_MANAGE|LED_PROGRAM|LED_PLAY); - _delay_ms(1000); - } - else PORTC = LED_BAT|LED_TxD|LED_RxD|LED_AUX|LED_MANAGE|LED_PROGRAM|LED_PLAY; - } - return 1; -} diff --git a/robotis_lib/example/Serial/Serial.c b/robotis_lib/example/Serial/Serial.c deleted file mode 100755 index 8e1e79112bc6d5f28c27bc80a09feb96d8f08ad2..0000000000000000000000000000000000000000 --- a/robotis_lib/example/Serial/Serial.c +++ /dev/null @@ -1,33 +0,0 @@ -//########################################################## -//## R O B O T I S ## -//## CM-510 (Atmega2561) Example code for Serial Comm. ## -//## 2009.11.10 ## -//########################################################## - - -#include <avr/io.h> -#include <stdio.h> -#include <avr/interrupt.h> -#include "serial.h" - -int main(void) -{ - int Value = 0; - - serial_initialize(57600); // USART Initialize - sei(); - - printf( "\n\nSerial Comm. example for CM-510\n\n" ); - - while (1) - { - unsigned char ReceivedData = getchar(); - if(ReceivedData == 'u') - Value++; - else if(ReceivedData == 'd') - Value--; - - printf("%d\r\n", Value); - } - return 1; -} diff --git a/robotis_lib/example/ZigBee_RC100/ZigBee_RC100.c b/robotis_lib/example/ZigBee_RC100/ZigBee_RC100.c deleted file mode 100755 index fd51f5f9d5e928589b5b2d6620c87cf82170480e..0000000000000000000000000000000000000000 --- a/robotis_lib/example/ZigBee_RC100/ZigBee_RC100.c +++ /dev/null @@ -1,60 +0,0 @@ -//########################################################## -//## R O B O T I S ## -//## CM-510 (Atmega2561) Example code for Dynamixel. ## -//## 2009.11.10 ## -//########################################################## - -#include <avr/io.h> -#include <avr/interrupt.h> -#include <stdio.h> -#include <util/delay.h> - -#include "zigbee.h" - -#define LED_BAT 0x01 -#define LED_TxD 0x02 -#define LED_RxD 0x04 -#define LED_AUX 0x08 -#define LED_MANAGE 0x10 -#define LED_PROGRAM 0x20 -#define LED_PLAY 0x40 - -int main(void) -{ - int RcvData; - - DDRC = 0x7F; - PORTC = 0x7E; - - PORTD &= ~0x80; //PORT_LINK_PLUGIN = 0; // no pull up - PORTD &= ~0x20; //PORT_ENABLE_RXD_LINK_PC = 0; - PORTD |= 0x40; //PORT_ENABLE_RXD_LINK_ZIGBEE = 1; - - zgb_initialize( 0 ); // Not using device index - sei(); // Interrupt Enable - - while(1) - { - if(zgb_rx_check() == 1) - { - RcvData = zgb_rx_data(); - if(RcvData & RC100_BTN_1) - PORTC &= ~LED_MANAGE; - else - PORTC |= LED_MANAGE; - - if(RcvData & RC100_BTN_2) - PORTC &= ~LED_PROGRAM; - else - PORTC |= LED_PROGRAM; - - if(RcvData & RC100_BTN_3) - PORTC &= ~LED_PLAY; - else - PORTC |= LED_PLAY; - } - } - - return 0; -} - diff --git a/robotis_lib/include/dynamixel.h b/robotis_lib/include/dynamixel.h deleted file mode 100755 index cf1636a4213b410853eae462ff008af22650a174..0000000000000000000000000000000000000000 --- a/robotis_lib/include/dynamixel.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef _DYNAMIXEL_HEADER -#define _DYNAMIXEL_HEADER - -#ifdef __cplusplus -extern "C" { -#endif - - -///////////// device control methods //////////////////////// -int dxl_initialize( int devIndex, int baudnum ); -void dxl_terminate(); - - -///////////// set/get packet methods ////////////////////////// -#define MAXNUM_TXPARAM (150) -#define MAXNUM_RXPARAM (60) - -void dxl_set_txpacket_id(int id); -#define BROADCAST_ID (254) - -void dxl_set_txpacket_instruction(int instruction); -#define INST_PING (1) -#define INST_READ (2) -#define INST_WRITE (3) -#define INST_REG_WRITE (4) -#define INST_ACTION (5) -#define INST_RESET (6) -#define INST_SYNC_WRITE (131) - -void dxl_set_txpacket_parameter(int index, int value); -void dxl_set_txpacket_length(int length); - -int dxl_get_rxpacket_error(int errbit); -#define ERRBIT_VOLTAGE (1) -#define ERRBIT_ANGLE (2) -#define ERRBIT_OVERHEAT (4) -#define ERRBIT_RANGE (8) -#define ERRBIT_CHECKSUM (16) -#define ERRBIT_OVERLOAD (32) -#define ERRBIT_INSTRUCTION (64) - -int dxl_get_rxpacket_length(void); -int dxl_get_rxpacket_parameter(int index); - - -// utility for value -int dxl_makeword(int lowbyte, int highbyte); -int dxl_get_lowbyte(int word); -int dxl_get_highbyte(int word); - - -////////// packet communication methods /////////////////////// -void dxl_tx_packet(void); -void dxl_rx_packet(void); -void dxl_txrx_packet(void); - -int dxl_get_result(void); -#define COMM_TXSUCCESS (0) -#define COMM_RXSUCCESS (1) -#define COMM_TXFAIL (2) -#define COMM_RXFAIL (3) -#define COMM_TXERROR (4) -#define COMM_RXWAITING (5) -#define COMM_RXTIMEOUT (6) -#define COMM_RXCORRUPT (7) - - -//////////// high communication methods /////////////////////// -int dxl_ping(int id); -int dxl_read_byte(int id, int address); -void dxl_write_byte(int id, int address, int value); -int dxl_read_word(int id, int address); -void dxl_write_word(int id, int address, int value); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/robotis_lib/include/serial.h b/robotis_lib/include/serial.h deleted file mode 100755 index 001d05a074d855a037c8e7555b9c2501d82d9faa..0000000000000000000000000000000000000000 --- a/robotis_lib/include/serial.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _SERIAL_HEADER -#define _SERIAL_HEADER - -#ifdef __cplusplus -extern "C" { -#endif - - -void serial_initialize(long ubrr); -void serial_write( unsigned char *pData, int numbyte ); -unsigned char serial_read( unsigned char *pData, int numbyte ); -int serial_get_qstate(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/robotis_lib/include/zigbee.h b/robotis_lib/include/zigbee.h deleted file mode 100755 index a520adb8650e590a8b6403b486a64a2c13fb493d..0000000000000000000000000000000000000000 --- a/robotis_lib/include/zigbee.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _ZIGBEE_HEADER -#define _ZIGBEE_HEADER - -#ifdef __cplusplus -extern "C" { -#endif - -///////////// device control methods //////////////////////// -int zgb_initialize( int devIndex ); -void zgb_terminate(void); - -////////// communication methods /////////////////////// -int zgb_tx_data(int data); -int zgb_rx_check(void); -int zgb_rx_data(void); - -////////// define RC-100 button key value //////////////// -#define RC100_BTN_U (1) -#define RC100_BTN_D (2) -#define RC100_BTN_L (4) -#define RC100_BTN_R (8) -#define RC100_BTN_1 (16) -#define RC100_BTN_2 (32) -#define RC100_BTN_3 (64) -#define RC100_BTN_4 (128) -#define RC100_BTN_5 (256) -#define RC100_BTN_6 (512) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/robotis_lib/src/Dynamixel/Makefile b/robotis_lib/src/Dynamixel/Makefile deleted file mode 100755 index 9e5efd9e3a53c5be92ca8f2716105f537f29313b..0000000000000000000000000000000000000000 --- a/robotis_lib/src/Dynamixel/Makefile +++ /dev/null @@ -1,620 +0,0 @@ -# Hey Emacs, this is a -*- makefile -*- -#---------------------------------------------------------------------------- -# WinAVR Makefile Template written by Eric B. Weddington, J?rg Wunsch, et al. -# -# Released to the Public Domain -# -# Additional material for this makefile was written by: -# Peter Fleury -# Tim Henigan -# Colin O'Flynn -# Reiner Patommel -# Markus Pfaff -# Sander Pool -# Frederik Rouleau -# Carlos Lamas -# -#---------------------------------------------------------------------------- -# On command line: -# -# make all = Make software. -# -# make clean = Clean out built project files. -# -# make coff = Convert ELF to AVR COFF. -# -# make extcoff = Convert ELF to AVR Extended COFF. -# -# make program = Download the hex file to the device, using avrdude. -# Please customize the avrdude settings below first! -# -# make debug = Start either simulavr or avarice as specified for debugging, -# with avr-gdb or avr-insight as the front end for debugging. -# -# make filename.s = Just compile filename.c into the assembler code only. -# -# make filename.i = Create a preprocessed source file for use in submitting -# bug reports to the GCC project. -# -# To rebuild project do "make clean" then "make all". -#---------------------------------------------------------------------------- - - -# MCU name -MCU = atmega2561 - - -# Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency. You can then use this symbol in your source code to -# calculate timings. Do NOT tack on a 'UL' at the end, this will be done -# automatically to create a 32-bit value in your source code. -# Typical values are: -# F_CPU = 1000000 -# F_CPU = 1843200 -# F_CPU = 2000000 -# F_CPU = 3686400 -# F_CPU = 4000000 -# F_CPU = 7372800 -# F_CPU = 8000000 -# F_CPU = 11059200 -# F_CPU = 14745600 -# F_CPU = 16000000 -# F_CPU = 18432000 -# F_CPU = 20000000 -F_CPU = 16000000 - - -# Output format. (can be srec, ihex, binary) -FORMAT = ihex - - -# Target file name (without extension). -TARGET = libdynamixel - - -# Object files directory -# To put object files in current directory, use a dot (.), do NOT make -# this an empty or blank macro! -OBJDIR = ./output - - -# List C source files here. (C dependencies are automatically generated.) -SRC = dynamixel.c dxl_hal.c - - -# List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = - - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = - - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) -OPT = s - - -# Debugging format. -# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. -# AVR Studio 4.10 requires dwarf-2. -# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. -DEBUG = dwarf-2 - - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRAINCDIRS = ../../include/ - - -# Compiler flag to set the C Standard level. -# c89 = "ANSI" C -# gnu89 = c89 plus GCC extensions -# c99 = ISO C99 standard (not yet fully implemented) -# gnu99 = c99 plus GCC extensions -CSTANDARD = -std=gnu99 - - -# Place -D or -U options here for C sources -CDEFS = -DF_CPU=$(F_CPU)UL - - -# Place -D or -U options here for ASM sources -ADEFS = -DF_CPU=$(F_CPU) - - -# Place -D or -U options here for C++ sources -CPPDEFS = -DF_CPU=$(F_CPU)UL -#CPPDEFS += -D__STDC_LIMIT_MACROS -#CPPDEFS += -D__STDC_CONSTANT_MACROS - - - -#---------------- Compiler Options C ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CFLAGS = -g$(DEBUG) -CFLAGS += $(CDEFS) -CFLAGS += -O$(OPT) -CFLAGS += -funsigned-char -CFLAGS += -funsigned-bitfields -CFLAGS += -fpack-struct -CFLAGS += -fshort-enums -CFLAGS += -Wall -CFLAGS += -Wstrict-prototypes -#CFLAGS += -mshort-calls -#CFLAGS += -fno-unit-at-a-time -#CFLAGS += -Wundef -#CFLAGS += -Wunreachable-code -#CFLAGS += -Wsign-compare -CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -CFLAGS += $(CSTANDARD) - - -#---------------- Compiler Options C++ ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CPPFLAGS = -g$(DEBUG) -CPPFLAGS += $(CPPDEFS) -CPPFLAGS += -O$(OPT) -CPPFLAGS += -funsigned-char -CPPFLAGS += -funsigned-bitfields -CPPFLAGS += -fpack-struct -CPPFLAGS += -fshort-enums -CPPFLAGS += -fno-exceptions -CPPFLAGS += -Wall -CPPFLAGS += -Wundef -#CPPFLAGS += -mshort-calls -#CPPFLAGS += -fno-unit-at-a-time -#CPPFLAGS += -Wstrict-prototypes -#CPPFLAGS += -Wunreachable-code -#CPPFLAGS += -Wsign-compare -CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) -CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -#CPPFLAGS += $(CSTANDARD) - - -#---------------- Assembler Options ---------------- -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns: create listing -# -gstabs: have the assembler create line number information; note that -# for use in COFF files, additional information about filenames -# and function names needs to be present in the assembler source -# files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex -# dump that will be displayed for a given single line of source input. -ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 - - -#---------------- Library Options ---------------- -# Minimalistic printf version -PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min - -# Floating point printf version (requires MATH_LIB = -lm below) -PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt - -# If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = -#PRINTF_LIB = $(PRINTF_LIB_MIN) -#PRINTF_LIB = $(PRINTF_LIB_FLOAT) - - -# Minimalistic scanf version -SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min - -# Floating point + %[ scanf version (requires MATH_LIB = -lm below) -SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt - -# If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = -#SCANF_LIB = $(SCANF_LIB_MIN) -#SCANF_LIB = $(SCANF_LIB_FLOAT) - - -MATH_LIB = -lm - - -# List any extra directories to look for libraries here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = - - - -#---------------- External Memory Options ---------------- - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# used for variables (.data/.bss) and heap (malloc()). -#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# only used for heap (malloc()). -#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff - -EXTMEMOPTS = - - - -#---------------- Linker Options ---------------- -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += $(EXTMEMOPTS) -LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) -LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) -#LDFLAGS += -T linker_script.x - - - -#---------------- Programming Options (avrdude) ---------------- - -# Programming hardware -# Type: avrdude -c ? -# to get a full listing. -# -AVRDUDE_PROGRAMMER = stk500v2 - -# com1 = serial port. Use lpt1 to connect to parallel port. -AVRDUDE_PORT = com1 # programmer connected to serial device - -AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex -#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep - - -# Uncomment the following if you want avrdude's erase cycle counter. -# Note that this counter needs to be initialized first using -Yn, -# see avrdude manual. -#AVRDUDE_ERASE_COUNTER = -y - -# Uncomment the following if you do /not/ wish a verification to be -# performed after programming the device. -#AVRDUDE_NO_VERIFY = -V - -# Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> -# to submit bug reports. -#AVRDUDE_VERBOSE = -v -v - -AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) -AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) -AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) - - - -#---------------- Debugging Options ---------------- - -# For simulavr only - target MCU frequency. -DEBUG_MFREQ = $(F_CPU) - -# Set the DEBUG_UI to either gdb or insight. -# DEBUG_UI = gdb -DEBUG_UI = insight - -# Set the debugging back-end to either avarice, simulavr. -DEBUG_BACKEND = avarice -#DEBUG_BACKEND = simulavr - -# GDB Init Filename. -GDBINIT_FILE = __avr_gdbinit - -# When using avarice settings for the JTAG -JTAG_DEV = /dev/com1 - -# Debugging port used to communicate between GDB / avarice / simulavr. -DEBUG_PORT = 4242 - -# Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when -# avarice is running on a different computer. -DEBUG_HOST = localhost - - - -#============================================================================ - - -# Define programs and commands. -SHELL = sh -CC = avr-gcc -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size -AR = avr-ar rcs -NM = avr-nm -AVRDUDE = avrdude -REMOVE = rm -f -REMOVEDIR = rm -rf -COPY = cp -WINSHELL = cmd - - -# Define Messages -# English -MSG_ERRORS_NONE = Errors: none -MSG_BEGIN = -------- begin -------- -MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: -MSG_SIZE_AFTER = Size after: -MSG_COFF = Converting to AVR COFF: -MSG_EXTENDED_COFF = Converting to AVR Extended COFF: -MSG_FLASH = Creating load file for Flash: -MSG_EEPROM = Creating load file for EEPROM: -MSG_EXTENDED_LISTING = Creating Extended Listing: -MSG_SYMBOL_TABLE = Creating Symbol Table: -MSG_LINKING = Linking: -MSG_COMPILING = Compiling C: -MSG_COMPILING_CPP = Compiling C++: -MSG_ASSEMBLING = Assembling: -MSG_CLEANING = Cleaning project: -MSG_CREATING_LIBRARY = Creating library: - - - - -# Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) - -# Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) - - -# Compiler flags to generate dependency files. -GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d - - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) -ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - - - - -# Default target. -all: begin gccversion sizebefore build sizeafter end - -# Change the build target to build a HEX file or a library. -#build: elf hex eep lss sym -build: lib - - -elf: $(TARGET).elf -hex: $(TARGET).hex -eep: $(TARGET).eep -lss: $(TARGET).lss -sym: $(TARGET).sym -LIBNAME=$(TARGET).a -lib: ../../lib/$(LIBNAME) - - - -# Eye candy. -# AVR Studio 3.x does not check make's exit code but relies on -# the following magic strings to be generated by the compile job. -begin: - @echo - @echo $(MSG_BEGIN) - -end: - @echo $(MSG_END) - @echo - - -# Display size of file. -HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex -ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf - -sizebefore: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ - 2>/dev/null; echo; fi - -sizeafter: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ - 2>/dev/null; echo; fi - - - -# Display compiler version information. -gccversion : - @$(CC) --version - - - -# Program the device. -program: $(TARGET).hex $(TARGET).eep - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) - - -# Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set -# a breakpoint at main(). -gdb-config: - @$(REMOVE) $(GDBINIT_FILE) - @echo define reset >> $(GDBINIT_FILE) - @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) - @echo end >> $(GDBINIT_FILE) - @echo file $(TARGET).elf >> $(GDBINIT_FILE) - @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) -ifeq ($(DEBUG_BACKEND),simulavr) - @echo load >> $(GDBINIT_FILE) -endif - @echo break main >> $(GDBINIT_FILE) - -debug: gdb-config $(TARGET).elf -ifeq ($(DEBUG_BACKEND), avarice) - @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. - @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ - $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) - @$(WINSHELL) /c pause - -else - @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ - $(DEBUG_MFREQ) --port $(DEBUG_PORT) -endif - @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) - - - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT = $(OBJCOPY) --debugging -COFFCONVERT += --change-section-address .data-0x800000 -COFFCONVERT += --change-section-address .bss-0x800000 -COFFCONVERT += --change-section-address .noinit-0x800000 -COFFCONVERT += --change-section-address .eeprom-0x810000 - - - -coff: $(TARGET).elf - @echo - @echo $(MSG_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-avr $< $(TARGET).cof - - -extcoff: $(TARGET).elf - @echo - @echo $(MSG_EXTENDED_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof - - - -# Create final output files (.hex, .eep) from ELF output file. -%.hex: %.elf - @echo - @echo $(MSG_FLASH) $@ - $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@ - -%.eep: %.elf - @echo - @echo $(MSG_EEPROM) $@ - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 - -# Create extended listing file from ELF output file. -%.lss: %.elf - @echo - @echo $(MSG_EXTENDED_LISTING) $@ - $(OBJDUMP) -h -S -z $< > $@ - -# Create a symbol table from ELF output file. -%.sym: %.elf - @echo - @echo $(MSG_SYMBOL_TABLE) $@ - $(NM) -n $< > $@ - - - -# Create library from object files. -.SECONDARY : $(TARGET).a -.PRECIOUS : $(OBJ) -%.a: $(OBJ) - @echo - @echo $(MSG_CREATING_LIBRARY) $@ - $(AR) $@ $(OBJ) - - -# Link: create ELF output file from object files. -.SECONDARY : $(TARGET).elf -.PRECIOUS : $(OBJ) -%.elf: $(OBJ) - @echo - @echo $(MSG_LINKING) $@ - $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) - - -# Compile: create object files from C source files. -$(OBJDIR)/%.o : %.c - @echo - @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create object files from C++ source files. -$(OBJDIR)/%.o : %.cpp - @echo - @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -%.s : %.c - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C++ source files. -%.s : %.cpp - $(CC) -S $(ALL_CPPFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -$(OBJDIR)/%.o : %.S - @echo - @echo $(MSG_ASSEMBLING) $< - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - -# Create preprocessed source for use in sending a bug report. -%.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ - - -# Target: clean project. -clean: begin clean_list end - -clean_list : - @echo - @echo $(MSG_CLEANING) - $(REMOVE) $(TARGET).hex - $(REMOVE) $(TARGET).eep - $(REMOVE) $(TARGET).cof - $(REMOVE) $(TARGET).elf - $(REMOVE) $(TARGET).map - $(REMOVE) $(TARGET).sym - $(REMOVE) $(TARGET).lss - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) - $(REMOVE) $(SRC:.c=.s) - $(REMOVE) $(SRC:.c=.d) - $(REMOVE) $(SRC:.c=.i) - $(REMOVE) $(LIBNAME) - $(REMOVEDIR) .dep - - -# Create object files directory -$(shell mkdir $(OBJDIR) 2>/dev/null) - - -# Include the dependency files. --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) - - -# Listing of phony targets. -.PHONY : all begin finish end sizebefore sizeafter gccversion \ -build elf hex eep lss sym coff extcoff \ -clean clean_list program debug gdb-config - - diff --git a/robotis_lib/src/Dynamixel/dxl_hal.c b/robotis_lib/src/Dynamixel/dxl_hal.c deleted file mode 100755 index 3c39f70bc45bf3eec167102affdd74d45b96486f..0000000000000000000000000000000000000000 --- a/robotis_lib/src/Dynamixel/dxl_hal.c +++ /dev/null @@ -1,209 +0,0 @@ -#include <avr/io.h> -#include <avr/interrupt.h> - -// this is needed for the delay on the new avr-libc-1.7.0 -#ifndef __DELAY_BACKWARD_COMPATIBLE__ -#define __DELAY_BACKWARD_COMPATIBLE__ -#endif - -#include <util/delay.h> -#include "dxl_hal.h" - -#define MAXNUM_DXLBUFF 256 -// Porting -#define DIR_TXD PORTE &= ~0x08, PORTE |= 0x04 -#define DIR_RXD PORTE &= ~0x04, PORTE |= 0x08 - - -volatile unsigned char gbDxlBuffer[MAXNUM_DXLBUFF] = {0}; -volatile unsigned char gbDxlBufferHead = 0; -volatile unsigned char gbDxlBufferTail = 0; -volatile double gfByteTransTime_us; -volatile unsigned int gwCountNum; -volatile unsigned int gwTimeoutCountNum; -volatile unsigned int gwReturnDelayCountNum; - -int dxl_hal_get_qstate(void); -void dxl_hal_put_queue( unsigned char data ); -unsigned char dxl_hal_get_queue(void); - - -int dxl_hal_open(int devIndex, float baudrate) -{ - // Opening device - // devIndex: Device index - // baudrate: Real baudrate (ex> 115200, 57600, 38400...) - // Return: 0(Failed), 1(Succeed) - - unsigned short Divisor; - - // dynamixel communication using UART0 - - // set UART register A - //Bit 7: USART Receive Complete - //Bit 6: USART Transmit Complete - //Bit 5: USART Data Resigter Empty - //Bit 4: Frame Error - //Bit 3: Data OverRun - //Bit 2: Parity Error - //Bit 1: Double The USART Transmission Speed - //Bit 0: Multi-Processor Communication Mode - UCSR0A = 0b01000010; - - // set UART register B - // bit7: enable rx interrupt - // bit6: enable tx interrupt - // bit4: enable rx - // bit3: enable tx - // bit2: set sendding size(0 = 8bit) - UCSR0B = 0b10011000; - - // set UART register C - // bit6: communication mode (1 = synchronize, 0 = asynchronize) - // bit5,bit4: parity bit(00 = no parity) - // bit3: stop bit(0 = stop bit 1, 1 = stop bit 2) - // bit2,bit1: data size(11 = 8bit) - UCSR0C = 0b00000110; - - // Set baudrate - Divisor = (unsigned short)(2000000.0 / baudrate) - 1; - UBRR0H = (unsigned char)((Divisor & 0xFF00) >> 8); - UBRR0L = (unsigned char)(Divisor & 0x00FF); - - gfByteTransTime_us = 1000000.0 / (double)baudrate * 12.0; - gwReturnDelayCountNum = (unsigned int)(250.0 / gfByteTransTime_us); - - // initialize - DIR_RXD; - UDR0 = 0xFF; - gbDxlBufferHead = 0; - gbDxlBufferTail = 0; - return 1; -} - -void dxl_hal_close(void) -{ - // Closing device -} - -void dxl_hal_clear(void) -{ - // Clear communication buffer - gbDxlBufferHead = gbDxlBufferTail; -} - -int dxl_hal_tx( unsigned char *pPacket, int numPacket ) -{ - // Transmiting date - // *pPacket: data array pointer - // numPacket: number of data array - // Return: number of data transmitted. -1 is error. - int count; - - cli(); - DIR_TXD; - for( count=0; count<numPacket; count++ ) - { - while(!bit_is_set(UCSR0A,5)); - - UCSR0A |= 0x40; - UDR0 = pPacket[count]; - } - while( !bit_is_set(UCSR0A,6) ); - DIR_RXD; - sei(); - return count; -} - -int dxl_hal_rx( unsigned char *pPacket, int numPacket ) -{ - // Recieving date - // *pPacket: data array pointer - // numPacket: number of data array - // Return: number of data recieved. -1 is error. - int count, numgetbyte; - - if( gbDxlBufferHead == gbDxlBufferTail ) - return 0; - - numgetbyte = dxl_hal_get_qstate(); - if( numgetbyte > numPacket ) - numgetbyte = numPacket; - - for( count=0; count<numgetbyte; count++ ) - pPacket[count] = dxl_hal_get_queue(); - - return numgetbyte; -} - -void dxl_hal_set_timeout( int NumRcvByte ) -{ - // Start stop watch - // NumRcvByte: number of recieving data(to calculate maximum waiting time) - gwCountNum = 0; - gwTimeoutCountNum = (NumRcvByte + 10) + gwReturnDelayCountNum; -} - -int dxl_hal_timeout(void) -{ - // Check timeout - // Return: 0 is false, 1 is true(timeout occurred) - gwCountNum++; - - if( gwCountNum > gwTimeoutCountNum ) - { - return 1; - } - - _delay_us(gfByteTransTime_us); - return 0; -} - -int dxl_hal_get_qstate(void) -{ - short NumByte; - - if( gbDxlBufferHead == gbDxlBufferTail ) - NumByte = 0; - else if( gbDxlBufferHead < gbDxlBufferTail ) - NumByte = gbDxlBufferTail - gbDxlBufferHead; - else - NumByte = MAXNUM_DXLBUFF - (gbDxlBufferHead - gbDxlBufferTail); - - return (int)NumByte; -} - -void dxl_hal_put_queue( unsigned char data ) -{ - if( dxl_hal_get_qstate() == (MAXNUM_DXLBUFF-1) ) - return; - - gbDxlBuffer[gbDxlBufferTail] = data; - - if( gbDxlBufferTail == (MAXNUM_DXLBUFF-1) ) - gbDxlBufferTail = 0; - else - gbDxlBufferTail++; -} - -unsigned char dxl_hal_get_queue(void) -{ - unsigned char data; - - if( gbDxlBufferHead == gbDxlBufferTail ) - return 0xff; - - data = gbDxlBuffer[gbDxlBufferHead]; - - if( gbDxlBufferHead == (MAXNUM_DXLBUFF-1) ) - gbDxlBufferHead = 0; - else - gbDxlBufferHead++; - - return data; -} - -SIGNAL(USART0_RX_vect) -{ - dxl_hal_put_queue( UDR0 ); -} diff --git a/robotis_lib/src/Dynamixel/dxl_hal.h b/robotis_lib/src/Dynamixel/dxl_hal.h deleted file mode 100755 index ba235f5752ec78172ef54c2feccdbb3d249fb3cf..0000000000000000000000000000000000000000 --- a/robotis_lib/src/Dynamixel/dxl_hal.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _DYNAMIXEL_HAL_HEADER -#define _DYNAMIXEL_HAL_HEADER - - -#ifdef __cplusplus -extern "C" { -#endif - -int dxl_hal_open(int devIndex, float baudrate); -void dxl_hal_close(void); -void dxl_hal_clear(void); -int dxl_hal_tx( unsigned char *pPacket, int numPacket ); -int dxl_hal_rx( unsigned char *pPacket, int numPacket ); -void dxl_hal_set_timeout( int NumRcvByte ); -int dxl_hal_timeout(void); - - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/robotis_lib/src/Dynamixel/dynamixel.c b/robotis_lib/src/Dynamixel/dynamixel.c deleted file mode 100755 index c7b1d9ef33f682cbfc3c84dd5d8daa6890495b56..0000000000000000000000000000000000000000 --- a/robotis_lib/src/Dynamixel/dynamixel.c +++ /dev/null @@ -1,353 +0,0 @@ -#include "dxl_hal.h" -#include "dynamixel.h" - -#define ID (2) -#define LENGTH (3) -#define INSTRUCTION (4) -#define ERRBIT (4) -#define PARAMETER (5) -#define DEFAULT_BAUDNUMBER (1) - -unsigned char gbInstructionPacket[MAXNUM_TXPARAM+10] = {0}; -unsigned char gbStatusPacket[MAXNUM_RXPARAM+10] = {0}; -unsigned char gbRxPacketLength = 0; -unsigned char gbRxGetLength = 0; -int gbCommStatus = COMM_RXSUCCESS; -int giBusUsing = 0; - - -int dxl_initialize( int devIndex, int baudnum ) -{ - float baudrate; - baudrate = 2000000.0f / (float)(baudnum + 1); - - if( dxl_hal_open(devIndex, baudrate) == 0 ) - return 0; - - gbCommStatus = COMM_RXSUCCESS; - giBusUsing = 0; - return 1; -} - -void dxl_terminate() -{ - dxl_hal_close(); -} - -void dxl_tx_packet() -{ - unsigned char i; - unsigned char TxNumByte, RealTxNumByte; - unsigned char checksum = 0; - - if( giBusUsing == 1 ) - return; - - giBusUsing = 1; - - if( gbInstructionPacket[LENGTH] > (MAXNUM_TXPARAM+2) ) - { - gbCommStatus = COMM_TXERROR; - giBusUsing = 0; - return; - } - - if( gbInstructionPacket[INSTRUCTION] != INST_PING - && gbInstructionPacket[INSTRUCTION] != INST_READ - && gbInstructionPacket[INSTRUCTION] != INST_WRITE - && gbInstructionPacket[INSTRUCTION] != INST_REG_WRITE - && gbInstructionPacket[INSTRUCTION] != INST_ACTION - && gbInstructionPacket[INSTRUCTION] != INST_RESET - && gbInstructionPacket[INSTRUCTION] != INST_SYNC_WRITE ) - { - gbCommStatus = COMM_TXERROR; - giBusUsing = 0; - return; - } - - gbInstructionPacket[0] = 0xff; - gbInstructionPacket[1] = 0xff; - for( i=0; i<(gbInstructionPacket[LENGTH]+1); i++ ) - checksum += gbInstructionPacket[i+2]; - gbInstructionPacket[gbInstructionPacket[LENGTH]+3] = ~checksum; - - if( gbCommStatus == COMM_RXTIMEOUT || gbCommStatus == COMM_RXCORRUPT ) - dxl_hal_clear(); - - TxNumByte = gbInstructionPacket[LENGTH] + 4; - RealTxNumByte = dxl_hal_tx( (unsigned char*)gbInstructionPacket, TxNumByte ); - - if( TxNumByte != RealTxNumByte ) - { - gbCommStatus = COMM_TXFAIL; - giBusUsing = 0; - return; - } - - if( gbInstructionPacket[INSTRUCTION] == INST_READ ) - dxl_hal_set_timeout( gbInstructionPacket[PARAMETER+1] + 6 ); - else - dxl_hal_set_timeout( 6 ); - - gbCommStatus = COMM_TXSUCCESS; -} - -void dxl_rx_packet() -{ - unsigned char i, j, nRead; - unsigned char checksum = 0; - - if( giBusUsing == 0 ) - return; - - if( gbInstructionPacket[ID] == BROADCAST_ID ) - { - gbCommStatus = COMM_RXSUCCESS; - giBusUsing = 0; - return; - } - - if( gbCommStatus == COMM_TXSUCCESS ) - { - gbRxGetLength = 0; - gbRxPacketLength = 6; - } - - nRead = dxl_hal_rx( (unsigned char*)&gbStatusPacket[gbRxGetLength], gbRxPacketLength - gbRxGetLength ); - gbRxGetLength += nRead; - if( gbRxGetLength < gbRxPacketLength ) - { - if( dxl_hal_timeout() == 1 ) - { - if(gbRxGetLength == 0) - gbCommStatus = COMM_RXTIMEOUT; - else - gbCommStatus = COMM_RXCORRUPT; - giBusUsing = 0; - return; - } - } - - // Find packet header - for( i=0; i<(gbRxGetLength-1); i++ ) - { - if( gbStatusPacket[i] == 0xff && gbStatusPacket[i+1] == 0xff ) - { - break; - } - else if( i == gbRxGetLength-2 && gbStatusPacket[gbRxGetLength-1] == 0xff ) - { - break; - } - } - if( i > 0 ) - { - for( j=0; j<(gbRxGetLength-i); j++ ) - gbStatusPacket[j] = gbStatusPacket[j + i]; - - gbRxGetLength -= i; - } - - if( gbRxGetLength < gbRxPacketLength ) - { - gbCommStatus = COMM_RXWAITING; - return; - } - - // Check id pairing - if( gbInstructionPacket[ID] != gbStatusPacket[ID]) - { - gbCommStatus = COMM_RXCORRUPT; - giBusUsing = 0; - return; - } - - gbRxPacketLength = gbStatusPacket[LENGTH] + 4; - if( gbRxGetLength < gbRxPacketLength ) - { - nRead = dxl_hal_rx( (unsigned char*)&gbStatusPacket[gbRxGetLength], gbRxPacketLength - gbRxGetLength ); - gbRxGetLength += nRead; - if( gbRxGetLength < gbRxPacketLength ) - { - gbCommStatus = COMM_RXWAITING; - return; - } - } - - // Check checksum - for( i=0; i<(gbStatusPacket[LENGTH]+1); i++ ) - checksum += gbStatusPacket[i+2]; - checksum = ~checksum; - - if( gbStatusPacket[gbStatusPacket[LENGTH]+3] != checksum ) - { - gbCommStatus = COMM_RXCORRUPT; - giBusUsing = 0; - return; - } - - gbCommStatus = COMM_RXSUCCESS; - giBusUsing = 0; -} - -void dxl_txrx_packet() -{ - dxl_tx_packet(); - - if( gbCommStatus != COMM_TXSUCCESS ) - return; - - do{ - dxl_rx_packet(); - }while( gbCommStatus == COMM_RXWAITING ); -} - -int dxl_get_result() -{ - return gbCommStatus; -} - -void dxl_set_txpacket_id( int id ) -{ - gbInstructionPacket[ID] = (unsigned char)id; -} - -void dxl_set_txpacket_instruction( int instruction ) -{ - gbInstructionPacket[INSTRUCTION] = (unsigned char)instruction; -} - -void dxl_set_txpacket_parameter( int index, int value ) -{ - gbInstructionPacket[PARAMETER+index] = (unsigned char)value; -} - -void dxl_set_txpacket_length( int length ) -{ - gbInstructionPacket[LENGTH] = (unsigned char)length; -} - -int dxl_get_rxpacket_error( int errbit ) -{ - if( gbStatusPacket[ERRBIT] & (unsigned char)errbit ) - return 1; - - return 0; -} - -int dxl_get_rxpacket_length() -{ - return (int)gbStatusPacket[LENGTH]; -} - -int dxl_get_rxpacket_parameter( int index ) -{ - return (int)gbStatusPacket[PARAMETER+index]; -} - -int dxl_makeword( int lowbyte, int highbyte ) -{ - unsigned short word; - - word = highbyte; - word = word << 8; - word = word + lowbyte; - return (int)word; -} - -int dxl_get_lowbyte( int word ) -{ - unsigned short temp; - - temp = word & 0xff; - return (int)temp; -} - -int dxl_get_highbyte( int word ) -{ - unsigned short temp; - - temp = word & 0xff00; - temp = temp >> 8; - return (int)temp; -} - -int dxl_ping( int id ) -{ - while(giBusUsing); - - gbInstructionPacket[ID] = (unsigned char)id; - gbInstructionPacket[INSTRUCTION] = INST_PING; - gbInstructionPacket[LENGTH] = 2; - - dxl_txrx_packet(); - - if (gbCommStatus == COMM_RXSUCCESS) - { - // return the error code - return (int)gbStatusPacket[ERRBIT]; - // check if servo exists (via timeout) - } else if( gbCommStatus == COMM_RXTIMEOUT ) - { - return -1; - } else { - return 0; - } -} - -int dxl_read_byte( int id, int address ) -{ - while(giBusUsing); - - gbInstructionPacket[ID] = (unsigned char)id; - gbInstructionPacket[INSTRUCTION] = INST_READ; - gbInstructionPacket[PARAMETER] = (unsigned char)address; - gbInstructionPacket[PARAMETER+1] = 1; - gbInstructionPacket[LENGTH] = 4; - - dxl_txrx_packet(); - - return (int)gbStatusPacket[PARAMETER]; -} - -void dxl_write_byte( int id, int address, int value ) -{ - while(giBusUsing); - - gbInstructionPacket[ID] = (unsigned char)id; - gbInstructionPacket[INSTRUCTION] = INST_WRITE; - gbInstructionPacket[PARAMETER] = (unsigned char)address; - gbInstructionPacket[PARAMETER+1] = (unsigned char)value; - gbInstructionPacket[LENGTH] = 4; - - dxl_txrx_packet(); -} - -int dxl_read_word( int id, int address ) -{ - while(giBusUsing); - - gbInstructionPacket[ID] = (unsigned char)id; - gbInstructionPacket[INSTRUCTION] = INST_READ; - gbInstructionPacket[PARAMETER] = (unsigned char)address; - gbInstructionPacket[PARAMETER+1] = 2; - gbInstructionPacket[LENGTH] = 4; - - dxl_txrx_packet(); - - return dxl_makeword((int)gbStatusPacket[PARAMETER], (int)gbStatusPacket[PARAMETER+1]); -} - -void dxl_write_word( int id, int address, int value ) -{ - while(giBusUsing); - - gbInstructionPacket[ID] = (unsigned char)id; - gbInstructionPacket[INSTRUCTION] = INST_WRITE; - gbInstructionPacket[PARAMETER] = (unsigned char)address; - gbInstructionPacket[PARAMETER+1] = (unsigned char)dxl_get_lowbyte(value); - gbInstructionPacket[PARAMETER+2] = (unsigned char)dxl_get_highbyte(value); - gbInstructionPacket[LENGTH] = 5; - - dxl_txrx_packet(); -} diff --git a/robotis_lib/src/Serial/Makefile b/robotis_lib/src/Serial/Makefile deleted file mode 100755 index 9aa77fa58fd47cf475db2a4bfd58d70adac57775..0000000000000000000000000000000000000000 --- a/robotis_lib/src/Serial/Makefile +++ /dev/null @@ -1,620 +0,0 @@ -# Hey Emacs, this is a -*- makefile -*- -#---------------------------------------------------------------------------- -# WinAVR Makefile Template written by Eric B. Weddington, J?rg Wunsch, et al. -# -# Released to the Public Domain -# -# Additional material for this makefile was written by: -# Peter Fleury -# Tim Henigan -# Colin O'Flynn -# Reiner Patommel -# Markus Pfaff -# Sander Pool -# Frederik Rouleau -# Carlos Lamas -# -#---------------------------------------------------------------------------- -# On command line: -# -# make all = Make software. -# -# make clean = Clean out built project files. -# -# make coff = Convert ELF to AVR COFF. -# -# make extcoff = Convert ELF to AVR Extended COFF. -# -# make program = Download the hex file to the device, using avrdude. -# Please customize the avrdude settings below first! -# -# make debug = Start either simulavr or avarice as specified for debugging, -# with avr-gdb or avr-insight as the front end for debugging. -# -# make filename.s = Just compile filename.c into the assembler code only. -# -# make filename.i = Create a preprocessed source file for use in submitting -# bug reports to the GCC project. -# -# To rebuild project do "make clean" then "make all". -#---------------------------------------------------------------------------- - - -# MCU name -MCU = atmega2561 - - -# Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency. You can then use this symbol in your source code to -# calculate timings. Do NOT tack on a 'UL' at the end, this will be done -# automatically to create a 32-bit value in your source code. -# Typical values are: -# F_CPU = 1000000 -# F_CPU = 1843200 -# F_CPU = 2000000 -# F_CPU = 3686400 -# F_CPU = 4000000 -# F_CPU = 7372800 -# F_CPU = 8000000 -# F_CPU = 11059200 -# F_CPU = 14745600 -# F_CPU = 16000000 -# F_CPU = 18432000 -# F_CPU = 20000000 -F_CPU = 16000000 - - -# Output format. (can be srec, ihex, binary) -FORMAT = ihex - - -# Target file name (without extension). -TARGET = libserial - - -# Object files directory -# To put object files in current directory, use a dot (.), do NOT make -# this an empty or blank macro! -OBJDIR = ./output - - -# List C source files here. (C dependencies are automatically generated.) -SRC = serial.c - - -# List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = - - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = - - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) -OPT = s - - -# Debugging format. -# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. -# AVR Studio 4.10 requires dwarf-2. -# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. -DEBUG = dwarf-2 - - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRAINCDIRS = ../../include/ - - -# Compiler flag to set the C Standard level. -# c89 = "ANSI" C -# gnu89 = c89 plus GCC extensions -# c99 = ISO C99 standard (not yet fully implemented) -# gnu99 = c99 plus GCC extensions -CSTANDARD = -std=gnu99 - - -# Place -D or -U options here for C sources -CDEFS = -DF_CPU=$(F_CPU)UL - - -# Place -D or -U options here for ASM sources -ADEFS = -DF_CPU=$(F_CPU) - - -# Place -D or -U options here for C++ sources -CPPDEFS = -DF_CPU=$(F_CPU)UL -#CPPDEFS += -D__STDC_LIMIT_MACROS -#CPPDEFS += -D__STDC_CONSTANT_MACROS - - - -#---------------- Compiler Options C ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CFLAGS = -g$(DEBUG) -CFLAGS += $(CDEFS) -CFLAGS += -O$(OPT) -CFLAGS += -funsigned-char -CFLAGS += -funsigned-bitfields -CFLAGS += -fpack-struct -CFLAGS += -fshort-enums -CFLAGS += -Wall -CFLAGS += -Wstrict-prototypes -#CFLAGS += -mshort-calls -#CFLAGS += -fno-unit-at-a-time -#CFLAGS += -Wundef -#CFLAGS += -Wunreachable-code -#CFLAGS += -Wsign-compare -CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -CFLAGS += $(CSTANDARD) - - -#---------------- Compiler Options C++ ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CPPFLAGS = -g$(DEBUG) -CPPFLAGS += $(CPPDEFS) -CPPFLAGS += -O$(OPT) -CPPFLAGS += -funsigned-char -CPPFLAGS += -funsigned-bitfields -CPPFLAGS += -fpack-struct -CPPFLAGS += -fshort-enums -CPPFLAGS += -fno-exceptions -CPPFLAGS += -Wall -CPPFLAGS += -Wundef -#CPPFLAGS += -mshort-calls -#CPPFLAGS += -fno-unit-at-a-time -#CPPFLAGS += -Wstrict-prototypes -#CPPFLAGS += -Wunreachable-code -#CPPFLAGS += -Wsign-compare -CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) -CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -#CPPFLAGS += $(CSTANDARD) - - -#---------------- Assembler Options ---------------- -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns: create listing -# -gstabs: have the assembler create line number information; note that -# for use in COFF files, additional information about filenames -# and function names needs to be present in the assembler source -# files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex -# dump that will be displayed for a given single line of source input. -ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 - - -#---------------- Library Options ---------------- -# Minimalistic printf version -PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min - -# Floating point printf version (requires MATH_LIB = -lm below) -PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt - -# If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = -#PRINTF_LIB = $(PRINTF_LIB_MIN) -#PRINTF_LIB = $(PRINTF_LIB_FLOAT) - - -# Minimalistic scanf version -SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min - -# Floating point + %[ scanf version (requires MATH_LIB = -lm below) -SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt - -# If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = -#SCANF_LIB = $(SCANF_LIB_MIN) -#SCANF_LIB = $(SCANF_LIB_FLOAT) - - -MATH_LIB = -lm - - -# List any extra directories to look for libraries here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = - - - -#---------------- External Memory Options ---------------- - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# used for variables (.data/.bss) and heap (malloc()). -#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# only used for heap (malloc()). -#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff - -EXTMEMOPTS = - - - -#---------------- Linker Options ---------------- -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += $(EXTMEMOPTS) -LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) -LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) -#LDFLAGS += -T linker_script.x - - - -#---------------- Programming Options (avrdude) ---------------- - -# Programming hardware -# Type: avrdude -c ? -# to get a full listing. -# -AVRDUDE_PROGRAMMER = stk500v2 - -# com1 = serial port. Use lpt1 to connect to parallel port. -AVRDUDE_PORT = com1 # programmer connected to serial device - -AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex -#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep - - -# Uncomment the following if you want avrdude's erase cycle counter. -# Note that this counter needs to be initialized first using -Yn, -# see avrdude manual. -#AVRDUDE_ERASE_COUNTER = -y - -# Uncomment the following if you do /not/ wish a verification to be -# performed after programming the device. -#AVRDUDE_NO_VERIFY = -V - -# Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> -# to submit bug reports. -#AVRDUDE_VERBOSE = -v -v - -AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) -AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) -AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) - - - -#---------------- Debugging Options ---------------- - -# For simulavr only - target MCU frequency. -DEBUG_MFREQ = $(F_CPU) - -# Set the DEBUG_UI to either gdb or insight. -# DEBUG_UI = gdb -DEBUG_UI = insight - -# Set the debugging back-end to either avarice, simulavr. -DEBUG_BACKEND = avarice -#DEBUG_BACKEND = simulavr - -# GDB Init Filename. -GDBINIT_FILE = __avr_gdbinit - -# When using avarice settings for the JTAG -JTAG_DEV = /dev/com1 - -# Debugging port used to communicate between GDB / avarice / simulavr. -DEBUG_PORT = 4242 - -# Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when -# avarice is running on a different computer. -DEBUG_HOST = localhost - - - -#============================================================================ - - -# Define programs and commands. -SHELL = sh -CC = avr-gcc -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size -AR = avr-ar rcs -NM = avr-nm -AVRDUDE = avrdude -REMOVE = rm -f -REMOVEDIR = rm -rf -COPY = cp -WINSHELL = cmd - - -# Define Messages -# English -MSG_ERRORS_NONE = Errors: none -MSG_BEGIN = -------- begin -------- -MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: -MSG_SIZE_AFTER = Size after: -MSG_COFF = Converting to AVR COFF: -MSG_EXTENDED_COFF = Converting to AVR Extended COFF: -MSG_FLASH = Creating load file for Flash: -MSG_EEPROM = Creating load file for EEPROM: -MSG_EXTENDED_LISTING = Creating Extended Listing: -MSG_SYMBOL_TABLE = Creating Symbol Table: -MSG_LINKING = Linking: -MSG_COMPILING = Compiling C: -MSG_COMPILING_CPP = Compiling C++: -MSG_ASSEMBLING = Assembling: -MSG_CLEANING = Cleaning project: -MSG_CREATING_LIBRARY = Creating library: - - - - -# Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) - -# Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) - - -# Compiler flags to generate dependency files. -GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d - - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) -ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - - - - -# Default target. -all: begin gccversion sizebefore build sizeafter end - -# Change the build target to build a HEX file or a library. -#build: elf hex eep lss sym -build: lib - - -elf: $(TARGET).elf -hex: $(TARGET).hex -eep: $(TARGET).eep -lss: $(TARGET).lss -sym: $(TARGET).sym -LIBNAME=$(TARGET).a -lib: ../../lib/$(LIBNAME) - - - -# Eye candy. -# AVR Studio 3.x does not check make's exit code but relies on -# the following magic strings to be generated by the compile job. -begin: - @echo - @echo $(MSG_BEGIN) - -end: - @echo $(MSG_END) - @echo - - -# Display size of file. -HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex -ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf - -sizebefore: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ - 2>/dev/null; echo; fi - -sizeafter: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ - 2>/dev/null; echo; fi - - - -# Display compiler version information. -gccversion : - @$(CC) --version - - - -# Program the device. -program: $(TARGET).hex $(TARGET).eep - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) - - -# Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set -# a breakpoint at main(). -gdb-config: - @$(REMOVE) $(GDBINIT_FILE) - @echo define reset >> $(GDBINIT_FILE) - @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) - @echo end >> $(GDBINIT_FILE) - @echo file $(TARGET).elf >> $(GDBINIT_FILE) - @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) -ifeq ($(DEBUG_BACKEND),simulavr) - @echo load >> $(GDBINIT_FILE) -endif - @echo break main >> $(GDBINIT_FILE) - -debug: gdb-config $(TARGET).elf -ifeq ($(DEBUG_BACKEND), avarice) - @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. - @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ - $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) - @$(WINSHELL) /c pause - -else - @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ - $(DEBUG_MFREQ) --port $(DEBUG_PORT) -endif - @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) - - - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT = $(OBJCOPY) --debugging -COFFCONVERT += --change-section-address .data-0x800000 -COFFCONVERT += --change-section-address .bss-0x800000 -COFFCONVERT += --change-section-address .noinit-0x800000 -COFFCONVERT += --change-section-address .eeprom-0x810000 - - - -coff: $(TARGET).elf - @echo - @echo $(MSG_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-avr $< $(TARGET).cof - - -extcoff: $(TARGET).elf - @echo - @echo $(MSG_EXTENDED_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof - - - -# Create final output files (.hex, .eep) from ELF output file. -%.hex: %.elf - @echo - @echo $(MSG_FLASH) $@ - $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@ - -%.eep: %.elf - @echo - @echo $(MSG_EEPROM) $@ - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 - -# Create extended listing file from ELF output file. -%.lss: %.elf - @echo - @echo $(MSG_EXTENDED_LISTING) $@ - $(OBJDUMP) -h -S -z $< > $@ - -# Create a symbol table from ELF output file. -%.sym: %.elf - @echo - @echo $(MSG_SYMBOL_TABLE) $@ - $(NM) -n $< > $@ - - - -# Create library from object files. -.SECONDARY : $(TARGET).a -.PRECIOUS : $(OBJ) -%.a: $(OBJ) - @echo - @echo $(MSG_CREATING_LIBRARY) $@ - $(AR) $@ $(OBJ) - - -# Link: create ELF output file from object files. -.SECONDARY : $(TARGET).elf -.PRECIOUS : $(OBJ) -%.elf: $(OBJ) - @echo - @echo $(MSG_LINKING) $@ - $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) - - -# Compile: create object files from C source files. -$(OBJDIR)/%.o : %.c - @echo - @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create object files from C++ source files. -$(OBJDIR)/%.o : %.cpp - @echo - @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -%.s : %.c - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C++ source files. -%.s : %.cpp - $(CC) -S $(ALL_CPPFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -$(OBJDIR)/%.o : %.S - @echo - @echo $(MSG_ASSEMBLING) $< - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - -# Create preprocessed source for use in sending a bug report. -%.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ - - -# Target: clean project. -clean: begin clean_list end - -clean_list : - @echo - @echo $(MSG_CLEANING) - $(REMOVE) $(TARGET).hex - $(REMOVE) $(TARGET).eep - $(REMOVE) $(TARGET).cof - $(REMOVE) $(TARGET).elf - $(REMOVE) $(TARGET).map - $(REMOVE) $(TARGET).sym - $(REMOVE) $(TARGET).lss - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) - $(REMOVE) $(SRC:.c=.s) - $(REMOVE) $(SRC:.c=.d) - $(REMOVE) $(SRC:.c=.i) - $(REMOVE) $(LIBNAME) - $(REMOVEDIR) .dep - - -# Create object files directory -$(shell mkdir $(OBJDIR) 2>/dev/null) - - -# Include the dependency files. --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) - - -# Listing of phony targets. -.PHONY : all begin finish end sizebefore sizeafter gccversion \ -build elf hex eep lss sym coff extcoff \ -clean clean_list program debug gdb-config - - diff --git a/robotis_lib/src/Serial/serial.c b/robotis_lib/src/Serial/serial.c deleted file mode 100755 index 343b6be38bc1c81a6442d4780659a973be033a8a..0000000000000000000000000000000000000000 --- a/robotis_lib/src/Serial/serial.c +++ /dev/null @@ -1,177 +0,0 @@ -#include <avr/io.h> -#include <stdio.h> -#include <avr/interrupt.h> -#include "serial.h" - -#define MAXNUM_SERIALBUFF 128 -#define DEFAULT_BAUDRATE 34 // 57132(57600)bps - -#define DIR_RXD PORTE &= ~0x04, PORTE |= 0x08 - -volatile unsigned char gbSerialBuffer[MAXNUM_SERIALBUFF] = {0}; -volatile unsigned char gbSerialBufferHead = 0; -volatile unsigned char gbSerialBufferTail = 0; -static FILE *device; - - -void serial_put_queue( unsigned char data ); -unsigned char serial_get_queue(void); -int std_putchar(char c); -int std_getchar(void); - - -void serial_initialize(long ubrr) -{ - // Serial communication using UART1 - int baud = (unsigned short)(2000000.0 / ubrr) - 1; - - // set UART register A - //Bit 7: USART Receive Complete - //Bit 6: USART Transmit Complete - //Bit 5: USART Data Resigter Empty - //Bit 4: Frame Error - //Bit 3: Data OverRun - //Bit 2: Parity Error - //Bit 1: Double The USART Transmission Speed - //Bit 0: Multi-Processor Communication Mode - UCSR1A = 0b01000010; - - // set UART register B - // bit7: enable rx interrupt - // bit6: enable tx interrupt - // bit4: enable rx - // bit3: enable tx - // bit2: set sendding size(0 = 8bit) - UCSR1B = 0b10011000; - - // set UART register C - // bit6: communication mode (1 = synchronize, 0 = asynchronize) - // bit5,bit4: parity bit(00 = no parity) - // bit3: stop bit(0 = stop bit 1, 1 = stop bit 2) - // bit2,bit1: data size(11 = 8bit) - UCSR1C = 0b00000110; - - // initialize - UDR1 = 0xFF; - gbSerialBufferHead = 0; - gbSerialBufferTail = 0; - - // set baudrate - UBRR1H = (unsigned char)(baud>>8); - UBRR1L = (unsigned char)(baud & 0xFF); - DIR_RXD; - device = fdevopen( std_putchar, std_getchar ); -} - -void serial_write( unsigned char *pData, int numbyte ) -{ - int count; - - for( count=0; count<numbyte; count++ ) - { - while(!bit_is_set(UCSR1A,5)); - UDR1 = pData[count]; - } -} - -unsigned char serial_read( unsigned char *pData, int numbyte ) -{ - int count, numgetbyte; - - if( gbSerialBufferHead == gbSerialBufferTail ) - return 0; - - numgetbyte = serial_get_qstate(); - if( numgetbyte > numbyte ) - numgetbyte = numbyte; - - for( count=0; count<numgetbyte; count++ ) - pData[count] = serial_get_queue(); - - return numgetbyte; -} - -int serial_get_qstate(void) -{ - short NumByte; - - if( gbSerialBufferHead == gbSerialBufferTail ) - NumByte = 0; - else if( gbSerialBufferHead < gbSerialBufferTail ) - NumByte = gbSerialBufferTail - gbSerialBufferHead; - else - NumByte = MAXNUM_SERIALBUFF - (gbSerialBufferHead - gbSerialBufferTail); - - return (int)NumByte; -} - -void serial_put_queue( unsigned char data ) -{ - if( serial_get_qstate() == (MAXNUM_SERIALBUFF-1) ) - return; - - gbSerialBuffer[gbSerialBufferTail] = data; - - if( gbSerialBufferTail == (MAXNUM_SERIALBUFF-1) ) - gbSerialBufferTail = 0; - else - gbSerialBufferTail++; -} - -unsigned char serial_get_queue(void) -{ - unsigned char data; - - if( gbSerialBufferHead == gbSerialBufferTail ) - return 0xff; - - data = gbSerialBuffer[gbSerialBufferHead]; - - if( gbSerialBufferHead == (MAXNUM_SERIALBUFF-1) ) - gbSerialBufferHead = 0; - else - gbSerialBufferHead++; - - return data; -} - -SIGNAL(USART1_RX_vect) -{ - serial_put_queue( UDR1 ); -} - - - -int std_putchar(char c) -{ - char tx[2]; - - if( c == '\n' ) - { - tx[0] = '\r'; - tx[1] = '\n'; - serial_write( (unsigned char*)tx, 2 ); - } - else - { - tx[0] = c; - serial_write( (unsigned char*)tx, 1 ); - } - - return 0; -} - -int std_getchar(void) -{ - char rx; - - while( serial_get_qstate() == 0 ); - rx = serial_get_queue(); - - if( rx == '\r' ) - rx = '\n'; - - return rx; -} - - diff --git a/robotis_lib/src/ZigBee/Makefile b/robotis_lib/src/ZigBee/Makefile deleted file mode 100755 index bb8d4a818540e53b386b0a33f83c916b5559cb70..0000000000000000000000000000000000000000 --- a/robotis_lib/src/ZigBee/Makefile +++ /dev/null @@ -1,620 +0,0 @@ -# Hey Emacs, this is a -*- makefile -*- -#---------------------------------------------------------------------------- -# WinAVR Makefile Template written by Eric B. Weddington, J?rg Wunsch, et al. -# -# Released to the Public Domain -# -# Additional material for this makefile was written by: -# Peter Fleury -# Tim Henigan -# Colin O'Flynn -# Reiner Patommel -# Markus Pfaff -# Sander Pool -# Frederik Rouleau -# Carlos Lamas -# -#---------------------------------------------------------------------------- -# On command line: -# -# make all = Make software. -# -# make clean = Clean out built project files. -# -# make coff = Convert ELF to AVR COFF. -# -# make extcoff = Convert ELF to AVR Extended COFF. -# -# make program = Download the hex file to the device, using avrdude. -# Please customize the avrdude settings below first! -# -# make debug = Start either simulavr or avarice as specified for debugging, -# with avr-gdb or avr-insight as the front end for debugging. -# -# make filename.s = Just compile filename.c into the assembler code only. -# -# make filename.i = Create a preprocessed source file for use in submitting -# bug reports to the GCC project. -# -# To rebuild project do "make clean" then "make all". -#---------------------------------------------------------------------------- - - -# MCU name -MCU = atmega2561 - - -# Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency. You can then use this symbol in your source code to -# calculate timings. Do NOT tack on a 'UL' at the end, this will be done -# automatically to create a 32-bit value in your source code. -# Typical values are: -# F_CPU = 1000000 -# F_CPU = 1843200 -# F_CPU = 2000000 -# F_CPU = 3686400 -# F_CPU = 4000000 -# F_CPU = 7372800 -# F_CPU = 8000000 -# F_CPU = 11059200 -# F_CPU = 14745600 -# F_CPU = 16000000 -# F_CPU = 18432000 -# F_CPU = 20000000 -F_CPU = 16000000 - - -# Output format. (can be srec, ihex, binary) -FORMAT = ihex - - -# Target file name (without extension). -TARGET = libzigbee - - -# Object files directory -# To put object files in current directory, use a dot (.), do NOT make -# this an empty or blank macro! -OBJDIR = ./output - - -# List C source files here. (C dependencies are automatically generated.) -SRC = zigbee.c zgb_hal.c - - -# List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = - - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = - - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) -OPT = s - - -# Debugging format. -# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. -# AVR Studio 4.10 requires dwarf-2. -# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. -DEBUG = dwarf-2 - - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRAINCDIRS = ../../include/ - - -# Compiler flag to set the C Standard level. -# c89 = "ANSI" C -# gnu89 = c89 plus GCC extensions -# c99 = ISO C99 standard (not yet fully implemented) -# gnu99 = c99 plus GCC extensions -CSTANDARD = -std=gnu99 - - -# Place -D or -U options here for C sources -CDEFS = -DF_CPU=$(F_CPU)UL - - -# Place -D or -U options here for ASM sources -ADEFS = -DF_CPU=$(F_CPU) - - -# Place -D or -U options here for C++ sources -CPPDEFS = -DF_CPU=$(F_CPU)UL -#CPPDEFS += -D__STDC_LIMIT_MACROS -#CPPDEFS += -D__STDC_CONSTANT_MACROS - - - -#---------------- Compiler Options C ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CFLAGS = -g$(DEBUG) -CFLAGS += $(CDEFS) -CFLAGS += -O$(OPT) -CFLAGS += -funsigned-char -CFLAGS += -funsigned-bitfields -CFLAGS += -fpack-struct -CFLAGS += -fshort-enums -CFLAGS += -Wall -CFLAGS += -Wstrict-prototypes -#CFLAGS += -mshort-calls -#CFLAGS += -fno-unit-at-a-time -#CFLAGS += -Wundef -#CFLAGS += -Wunreachable-code -#CFLAGS += -Wsign-compare -CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -CFLAGS += $(CSTANDARD) - - -#---------------- Compiler Options C++ ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CPPFLAGS = -g$(DEBUG) -CPPFLAGS += $(CPPDEFS) -CPPFLAGS += -O$(OPT) -CPPFLAGS += -funsigned-char -CPPFLAGS += -funsigned-bitfields -CPPFLAGS += -fpack-struct -CPPFLAGS += -fshort-enums -CPPFLAGS += -fno-exceptions -CPPFLAGS += -Wall -CPPFLAGS += -Wundef -#CPPFLAGS += -mshort-calls -#CPPFLAGS += -fno-unit-at-a-time -#CPPFLAGS += -Wstrict-prototypes -#CPPFLAGS += -Wunreachable-code -#CPPFLAGS += -Wsign-compare -CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) -CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -#CPPFLAGS += $(CSTANDARD) - - -#---------------- Assembler Options ---------------- -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns: create listing -# -gstabs: have the assembler create line number information; note that -# for use in COFF files, additional information about filenames -# and function names needs to be present in the assembler source -# files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex -# dump that will be displayed for a given single line of source input. -ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 - - -#---------------- Library Options ---------------- -# Minimalistic printf version -PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min - -# Floating point printf version (requires MATH_LIB = -lm below) -PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt - -# If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = -#PRINTF_LIB = $(PRINTF_LIB_MIN) -#PRINTF_LIB = $(PRINTF_LIB_FLOAT) - - -# Minimalistic scanf version -SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min - -# Floating point + %[ scanf version (requires MATH_LIB = -lm below) -SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt - -# If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = -#SCANF_LIB = $(SCANF_LIB_MIN) -#SCANF_LIB = $(SCANF_LIB_FLOAT) - - -MATH_LIB = -lm - - -# List any extra directories to look for libraries here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = - - - -#---------------- External Memory Options ---------------- - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# used for variables (.data/.bss) and heap (malloc()). -#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# only used for heap (malloc()). -#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff - -EXTMEMOPTS = - - - -#---------------- Linker Options ---------------- -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += $(EXTMEMOPTS) -LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) -LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) -#LDFLAGS += -T linker_script.x - - - -#---------------- Programming Options (avrdude) ---------------- - -# Programming hardware -# Type: avrdude -c ? -# to get a full listing. -# -AVRDUDE_PROGRAMMER = stk500v2 - -# com1 = serial port. Use lpt1 to connect to parallel port. -AVRDUDE_PORT = com1 # programmer connected to serial device - -AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex -#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep - - -# Uncomment the following if you want avrdude's erase cycle counter. -# Note that this counter needs to be initialized first using -Yn, -# see avrdude manual. -#AVRDUDE_ERASE_COUNTER = -y - -# Uncomment the following if you do /not/ wish a verification to be -# performed after programming the device. -#AVRDUDE_NO_VERIFY = -V - -# Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> -# to submit bug reports. -#AVRDUDE_VERBOSE = -v -v - -AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) -AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) -AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) - - - -#---------------- Debugging Options ---------------- - -# For simulavr only - target MCU frequency. -DEBUG_MFREQ = $(F_CPU) - -# Set the DEBUG_UI to either gdb or insight. -# DEBUG_UI = gdb -DEBUG_UI = insight - -# Set the debugging back-end to either avarice, simulavr. -DEBUG_BACKEND = avarice -#DEBUG_BACKEND = simulavr - -# GDB Init Filename. -GDBINIT_FILE = __avr_gdbinit - -# When using avarice settings for the JTAG -JTAG_DEV = /dev/com1 - -# Debugging port used to communicate between GDB / avarice / simulavr. -DEBUG_PORT = 4242 - -# Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when -# avarice is running on a different computer. -DEBUG_HOST = localhost - - - -#============================================================================ - - -# Define programs and commands. -SHELL = sh -CC = avr-gcc -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size -AR = avr-ar rcs -NM = avr-nm -AVRDUDE = avrdude -REMOVE = rm -f -REMOVEDIR = rm -rf -COPY = cp -WINSHELL = cmd - - -# Define Messages -# English -MSG_ERRORS_NONE = Errors: none -MSG_BEGIN = -------- begin -------- -MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: -MSG_SIZE_AFTER = Size after: -MSG_COFF = Converting to AVR COFF: -MSG_EXTENDED_COFF = Converting to AVR Extended COFF: -MSG_FLASH = Creating load file for Flash: -MSG_EEPROM = Creating load file for EEPROM: -MSG_EXTENDED_LISTING = Creating Extended Listing: -MSG_SYMBOL_TABLE = Creating Symbol Table: -MSG_LINKING = Linking: -MSG_COMPILING = Compiling C: -MSG_COMPILING_CPP = Compiling C++: -MSG_ASSEMBLING = Assembling: -MSG_CLEANING = Cleaning project: -MSG_CREATING_LIBRARY = Creating library: - - - - -# Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) - -# Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) - - -# Compiler flags to generate dependency files. -GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d - - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) -ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - - - - -# Default target. -all: begin gccversion sizebefore build sizeafter end - -# Change the build target to build a HEX file or a library. -#build: elf hex eep lss sym -build: lib - - -elf: $(TARGET).elf -hex: $(TARGET).hex -eep: $(TARGET).eep -lss: $(TARGET).lss -sym: $(TARGET).sym -LIBNAME=$(TARGET).a -lib: ../../lib/$(LIBNAME) - - - -# Eye candy. -# AVR Studio 3.x does not check make's exit code but relies on -# the following magic strings to be generated by the compile job. -begin: - @echo - @echo $(MSG_BEGIN) - -end: - @echo $(MSG_END) - @echo - - -# Display size of file. -HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex -ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf - -sizebefore: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ - 2>/dev/null; echo; fi - -sizeafter: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ - 2>/dev/null; echo; fi - - - -# Display compiler version information. -gccversion : - @$(CC) --version - - - -# Program the device. -program: $(TARGET).hex $(TARGET).eep - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) - - -# Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set -# a breakpoint at main(). -gdb-config: - @$(REMOVE) $(GDBINIT_FILE) - @echo define reset >> $(GDBINIT_FILE) - @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) - @echo end >> $(GDBINIT_FILE) - @echo file $(TARGET).elf >> $(GDBINIT_FILE) - @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) -ifeq ($(DEBUG_BACKEND),simulavr) - @echo load >> $(GDBINIT_FILE) -endif - @echo break main >> $(GDBINIT_FILE) - -debug: gdb-config $(TARGET).elf -ifeq ($(DEBUG_BACKEND), avarice) - @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. - @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ - $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) - @$(WINSHELL) /c pause - -else - @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ - $(DEBUG_MFREQ) --port $(DEBUG_PORT) -endif - @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) - - - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT = $(OBJCOPY) --debugging -COFFCONVERT += --change-section-address .data-0x800000 -COFFCONVERT += --change-section-address .bss-0x800000 -COFFCONVERT += --change-section-address .noinit-0x800000 -COFFCONVERT += --change-section-address .eeprom-0x810000 - - - -coff: $(TARGET).elf - @echo - @echo $(MSG_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-avr $< $(TARGET).cof - - -extcoff: $(TARGET).elf - @echo - @echo $(MSG_EXTENDED_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof - - - -# Create final output files (.hex, .eep) from ELF output file. -%.hex: %.elf - @echo - @echo $(MSG_FLASH) $@ - $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@ - -%.eep: %.elf - @echo - @echo $(MSG_EEPROM) $@ - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 - -# Create extended listing file from ELF output file. -%.lss: %.elf - @echo - @echo $(MSG_EXTENDED_LISTING) $@ - $(OBJDUMP) -h -S -z $< > $@ - -# Create a symbol table from ELF output file. -%.sym: %.elf - @echo - @echo $(MSG_SYMBOL_TABLE) $@ - $(NM) -n $< > $@ - - - -# Create library from object files. -.SECONDARY : $(TARGET).a -.PRECIOUS : $(OBJ) -%.a: $(OBJ) - @echo - @echo $(MSG_CREATING_LIBRARY) $@ - $(AR) $@ $(OBJ) - - -# Link: create ELF output file from object files. -.SECONDARY : $(TARGET).elf -.PRECIOUS : $(OBJ) -%.elf: $(OBJ) - @echo - @echo $(MSG_LINKING) $@ - $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) - - -# Compile: create object files from C source files. -$(OBJDIR)/%.o : %.c - @echo - @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create object files from C++ source files. -$(OBJDIR)/%.o : %.cpp - @echo - @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -%.s : %.c - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C++ source files. -%.s : %.cpp - $(CC) -S $(ALL_CPPFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -$(OBJDIR)/%.o : %.S - @echo - @echo $(MSG_ASSEMBLING) $< - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - -# Create preprocessed source for use in sending a bug report. -%.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ - - -# Target: clean project. -clean: begin clean_list end - -clean_list : - @echo - @echo $(MSG_CLEANING) - $(REMOVE) $(TARGET).hex - $(REMOVE) $(TARGET).eep - $(REMOVE) $(TARGET).cof - $(REMOVE) $(TARGET).elf - $(REMOVE) $(TARGET).map - $(REMOVE) $(TARGET).sym - $(REMOVE) $(TARGET).lss - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) - $(REMOVE) $(SRC:.c=.s) - $(REMOVE) $(SRC:.c=.d) - $(REMOVE) $(SRC:.c=.i) - $(REMOVE) $(LIBNAME) - $(REMOVEDIR) .dep - - -# Create object files directory -$(shell mkdir $(OBJDIR) 2>/dev/null) - - -# Include the dependency files. --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) - - -# Listing of phony targets. -.PHONY : all begin finish end sizebefore sizeafter gccversion \ -build elf hex eep lss sym coff extcoff \ -clean clean_list program debug gdb-config - - diff --git a/robotis_lib/src/ZigBee/zgb_hal.c b/robotis_lib/src/ZigBee/zgb_hal.c deleted file mode 100755 index 503f90cab04d56e262d71d93aed9c7d48455ff84..0000000000000000000000000000000000000000 --- a/robotis_lib/src/ZigBee/zgb_hal.c +++ /dev/null @@ -1,155 +0,0 @@ -// Atmega2561 version -#include <avr/io.h> -#include <avr/interrupt.h> -#include <util/delay.h> - -#include "zgb_hal.h" - -#define MAXNUM_ZGBBUFF 256 - -volatile unsigned char gbZgbBuffer[MAXNUM_ZGBBUFF] = {0}; -volatile unsigned char gbZgbBufferHead = 0; -volatile unsigned char gbZgbBufferTail = 0; - -int zgb_hal_get_qstate(void); -void zgb_hal_put_queue( unsigned char data ); -unsigned char zgb_hal_get_queue(void); - -int zgb_hal_open( int devIndex, float baudrate ) -{ - // Opening device - // devIndex: Device index - // baudrate: Real baudrate (ex> 115200, 57600, 38400...) - // Return: 0(Failed), 1(Succeed) - - unsigned short Divisor; - - // Serial communication using UART1 - - // set UART register A - //Bit 7: USART Receive Complete - //Bit 6: USART Transmit Complete - //Bit 5: USART Data Resigter Empty - //Bit 4: Frame Error - //Bit 3: Data OverRun - //Bit 2: Parity Error - //Bit 1: Double The USART Transmission Speed - //Bit 0: Multi-Processor Communication Mode - UCSR1A = 0b01000010; - - // set UART register B - // bit7: enable rx interrupt - // bit6: enable tx interrupt - // bit4: enable rx - // bit3: enable tx - // bit2: set sendding size(0 = 8bit) - UCSR1B = 0b10011000; - - // set UART register C - // bit6: communication mode (1 = synchronize, 0 = asynchronize) - // bit5,bit4: parity bit(00 = no parity) - // bit3: stop bit(0 = stop bit 1, 1 = stop bit 2) - // bit2,bit1: data size(11 = 8bit) - UCSR1C = 0b00000110; - - // Set baudrate - Divisor = (unsigned short)(2000000.0 / baudrate) - 1; - UBRR0H = (unsigned char)((Divisor & 0xFF00) >> 8); - UBRR0L = (unsigned char)(Divisor & 0x00FF); - - // initialize - UDR1 = 0xFF; - gbZgbBufferHead = 0; - gbZgbBufferTail = 0; - return 1; -} - -void zgb_hal_close(void) -{ - // Closing device - -} - -int zgb_hal_tx( unsigned char *pPacket, int numPacket ) -{ - // Transmiting date - // *pPacket: data array pointer - // numPacket: number of data array - // Return: number of data transmitted. -1 is error. - int count; - - for( count=0; count<numPacket; count++ ) - { - while(!bit_is_set(UCSR1A,5)); - UDR1 = pPacket[count]; - } - - return count; -} - -int zgb_hal_rx( unsigned char *pPacket, int numPacket ) -{ - // Recieving date - // *pPacket: data array pointer - // numPacket: number of data array - // Return: number of data recieved. -1 is error. - int count, numgetbyte; - - numgetbyte = zgb_hal_get_qstate(); - if( numgetbyte > numPacket ) - numgetbyte = numPacket; - - for( count=0; count<numgetbyte; count++ ) - pPacket[count] = zgb_hal_get_queue(); - - return numgetbyte; -} - -int zgb_hal_get_qstate(void) -{ - short NumByte; - - if( gbZgbBufferHead == gbZgbBufferTail ) - NumByte = 0; - else if( gbZgbBufferHead < gbZgbBufferTail ) - NumByte = gbZgbBufferTail - gbZgbBufferHead; - else - NumByte = MAXNUM_ZGBBUFF - (gbZgbBufferHead - gbZgbBufferTail); - - return (int)NumByte; -} - -void zgb_hal_put_queue( unsigned char data ) -{ - if( zgb_hal_get_qstate() == (MAXNUM_ZGBBUFF-1) ) - return; - - gbZgbBuffer[gbZgbBufferTail] = data; - - if( gbZgbBufferTail == (MAXNUM_ZGBBUFF-1) ) - gbZgbBufferTail = 0; - else - gbZgbBufferTail++; -} - -unsigned char zgb_hal_get_queue(void) -{ - unsigned char data; - - if( zgb_hal_get_qstate() == 0 ) - return 0xff; - - data = gbZgbBuffer[gbZgbBufferHead]; - - if( gbZgbBufferHead == (MAXNUM_ZGBBUFF-1) ) - gbZgbBufferHead = 0; - else - gbZgbBufferHead++; - - return data; -} - -SIGNAL(USART1_RX_vect) -{ - zgb_hal_put_queue( UDR1 ); -} diff --git a/robotis_lib/src/ZigBee/zgb_hal.h b/robotis_lib/src/ZigBee/zgb_hal.h deleted file mode 100755 index 68d46f8c3c98a2cc5fa50d44f1e72e050e5e0f90..0000000000000000000000000000000000000000 --- a/robotis_lib/src/ZigBee/zgb_hal.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _ZIGBEE_HAL_HEADER -#define _ZIGBEE_HAL_HEADER - -#ifdef __cplusplus -extern "C" { -#endif - -int zgb_hal_open( int devIndex, float baudrate ); -void zgb_hal_close(void); -int zgb_hal_tx( unsigned char *pPacket, int numPacket ); -int zgb_hal_rx( unsigned char *pPacket, int numPacket ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/robotis_lib/src/ZigBee/zigbee.c b/robotis_lib/src/ZigBee/zigbee.c deleted file mode 100755 index 2ce3e1bec4ae1ad46e61cc331a6242378c5b0239..0000000000000000000000000000000000000000 --- a/robotis_lib/src/ZigBee/zigbee.c +++ /dev/null @@ -1,121 +0,0 @@ -#include "zgb_hal.h" -#include "zigbee.h" -#include <avr/io.h> - -unsigned char gbRcvPacket[6]; -unsigned char gbRcvPacketNum; -unsigned short gwRcvData; -unsigned char gbRcvFlag; - -int zgb_initialize( int devIndex ) -{ - if( zgb_hal_open( devIndex, 57600 ) == 0) // Always fixed baudrate - return 0; - - gbRcvFlag = 0; - gwRcvData = 0; - gbRcvPacketNum = 0; - return 1; -} - -void zgb_terminate(void) -{ - zgb_hal_close(); -} - -int zgb_tx_data(int data) -{ - unsigned char SndPacket[6]; - unsigned short word = (unsigned short)data; - unsigned char lowbyte = (unsigned char)(word & 0xff); - unsigned char highbyte = (unsigned char)((word >> 8) & 0xff); - - SndPacket[0] = 0xff; - SndPacket[1] = 0x55; - SndPacket[2] = lowbyte; - SndPacket[3] = ~lowbyte; - SndPacket[4] = highbyte; - SndPacket[5] = ~highbyte; - - if( zgb_hal_tx( SndPacket, 6 ) != 6 ) - return 0; - - return 1; -} - -int zgb_rx_check(void) -{ - int RcvNum; - unsigned char checksum; - int i, j; - - if(gbRcvFlag == 1) - return 1; - // Fill packet buffer - if(gbRcvPacketNum < 6) - { - RcvNum = zgb_hal_rx( &gbRcvPacket[gbRcvPacketNum], (6 - gbRcvPacketNum) ); - if( RcvNum != -1 ) - gbRcvPacketNum += RcvNum; - } - // Find header - - if(gbRcvPacketNum >= 2) - { - for( i=0; i<gbRcvPacketNum; i++ ) - { - if(gbRcvPacket[i] == 0xff) - { - if(i <= (gbRcvPacketNum - 2)) - { - if(gbRcvPacket[i+1] == 0x55) - break; - } - } - } - if(i > 0) - { - if(i == gbRcvPacketNum) - { - // Can not find header - if(gbRcvPacket[i - 1] == 0xff) - i--; - } - - // Remove data before header - for( j=i; j<gbRcvPacketNum; j++) - { - gbRcvPacket[j - i] = gbRcvPacket[j]; - } - gbRcvPacketNum -= i; - } - } - // Verify packet - if(gbRcvPacketNum == 6) - { - if(gbRcvPacket[0] == 0xff && gbRcvPacket[1] == 0x55) - { - checksum = ~gbRcvPacket[3]; - if(gbRcvPacket[2] == checksum) - { - checksum = ~gbRcvPacket[5]; - if(gbRcvPacket[4] == checksum) - { - gwRcvData = (unsigned short)((gbRcvPacket[4] << 8) & 0xff00); - gwRcvData += gbRcvPacket[2]; - gbRcvFlag = 1; - } - } - } - - gbRcvPacket[0] = 0x00; - gbRcvPacketNum = 0; - } - return gbRcvFlag; -} - -int zgb_rx_data(void) -{ - gbRcvFlag = 0; - return (int)gwRcvData; -}