void init_devices (void) //use this function to initialize all devices { cli(); //disable all interrupts init_ports(); timer5_init(); sei(); //re-enable interrupts }
//Function to initialize all the peripherals void init_devices(void) { cli(); //disable all interrupts port_init(); timer1_init(); timer5_init(); sei(); //re-enable interrupts }
void init_devices (void) { cli(); //Clears the global interrupts port_init(); adc_init(); timer5_init(); sei(); //Enables the global interrupts }
void init_devices(void) { cli(); //Clears the global interrupts port_init(); //Initializes all the ports uart1_init(); //Initialize UART1 for serial communication timer5_init(); sei(); //Enables the global interrupts }
void init_devices_motion(void) { cli(); //disable all interrupts port_init_motion(); // motion pin config&& lcd pig config port_init_lcd(); // lcd initialisation timer5_init(); sei(); //re-enable interrupts }
void init_devices_adc (void) { cli(); //Clears the global interrupts port_init_adc(); // adc pin configuration adc_init(); timer5_init(); sei(); //Enables the global interrupts }
void init() { cli(); //Clears the global interrupts port_init(); //Initializes all the ports uart0_init(); //Initialize UART0 for serial communication left_encoder_interrupt_init(); //Initialize interrupts for left encoder right_encoder_interrupt_init(); //Initialize interrupts for right encoder timer5_init(); //Initialize TIMER5 for PWM sei(); //Enables the global interrupts }
void init_devices (void) { cli(); //Clears the global interrupts port_init(); uart0_init(); //Initailize UART1 for serial communiaction adc_init(); timer5_init(); timer1_init(); sei(); //Enables the global interrupts }
/* * Function For Devices Initialisation */ void init_devices (void) { cli(); ///< Clears the global interrupts port_init(); ///< initialise the ports adc_init(); uart0_init(); timer5_init(); timer1_init(); sei(); //Enables the global interrupts }
void init_devices (void) { cli(); //Clears the global interrupts port_init(); adc_init(); lcd_init(); timer5_init(); TIMSK5 = 0x01; //timer5 overflow interrupt enable. sei(); //Enables the global interrupts }
void init_devices (void) { cli(); //Clears the global interrupts timer1_init(); port_init(); adc_init(); timer5_init(); left_position_encoder_interrupt_init(); right_position_encoder_interrupt_init(); sei(); //Enables the global interrupts }
void init_devices1 (void) { cli(); //Clears the global interrupts lcd_port_config(); // configure the LCD port lcd_set_4bit(); lcd_init(); port_init(); timer5_init(); sei(); //Enables the global interrupts }
//Function to initialize all the devices void init_devices() { cli(); //Clears the global interrupt port_init(); //Initializes all the ports timer5_init(); timer3_init(); timer1_init(); left_position_encoder_interrupt_init(); right_position_encoder_interrupt_init(); ext_position_encoder_interrupt_init (); sei(); // Enables the global interrupt }
//Function to initialize all the devices void init_devices() { cli(); //Clears the global interrupt port_init(); //Initializes all the ports left_position_encoder_interrupt_init(); right_position_encoder_interrupt_init(); timer5_init(); uart0_init(); //Initailize UART1 for serial communiaction sei(); // Enables the global interrupt }
void init_devices (void) { cli(); //Clears the global interrupts port_init(); adc_init(); timer5_init(); left_position_encoder_interrupt_init(); right_position_encoder_interrupt_init(); sei(); //Enables the global interrupts // To initialize the direction of the bot to north init_location(); }
/*! initialize all devices. call all other initialization function */ void init_devices (void) { cli(); //Clears the global interrupts port_init(); adc_init(); uart3_init(); timer5_init(); timer4_init(); TCCR4B = 0x00; TIMSK4 = 0x01; //timer4 overflow interrupt enable TIMSK3 = 0x01; sei(); //Enables the global interrupts }
void init_devices (void) { cli(); //Clears the global interrupts port_init(); adc_init(); timer5_init(); left_position_encoder_interrupt_init(); right_position_encoder_interrupt_init(); uart0_init(); //Initailize UART1 for serial communiaction c2_position_encoder_interrupt_init(); //Slider_position_encoder_interrupt_init(); timer1_init(); sei(); //Enables the global interrupts }
//Function to initialize all the devices void init_devices() { cli(); //Clears the global interrupt port_init(); //Initializes all the ports left_position_encoder_interrupt_init(); right_position_encoder_interrupt_init(); timer4_init(); adc_init(); timer5_init(); store_init(); uart2_init(); TIMSK4 = 0x01; sei(); // Enables the global interrupt }
void init_devices(void) { cli(); //Clears the global interrupt port_init_poz(); //Initializes all the ports left_position_encoder_interrupt_init(); right_position_encoder_interrupt_init(); port_init(); //Initializes all the ports color_sensor_pin_interrupt_init(); adc_init(); motion_pin_config(); timer5_init(); timer1_init(); sei(); // Enables the global interrupt }
void PD2_INT_Handler(void) { if(trig_num3==0) { timer5_init(); trig_num3 ++; *(RP)(GPIO_PORTD_INTLEL) |= (0x1<<2);//change PA1 to trailing edge下降沿触发 } else { // serial_puts("end\n"); time3 = *(RP)(TIMER_T5CCR); } *(RP)(GPIO_PORTD_INTCLR) |= (0x1<<2);//clear PA1 interrupt }
//------------------------------------------------------------------------------- //call this routine to initialize all peripherals void init_devices(void) { //stop errant interrupts until set up cli(); //disable all interrupts port_init(); uart2_init(); adc_init(); timer1_init(); timer5_init(); lcd_set_4bit(); lcd_init(); spi_init(); // below for lines are important for Encoder init left_position_encoder_interrupt_init(); right_position_encoder_interrupt_init(); EICRB = 0x0A; //pin change int edge 4:7 EIMSK = 0x30; sei(); //re-enable interrupts //all peripherals are now initialized }
int main(int argc, char *argv[]) { int i=0; int h=0; int bupi=0; cli(); memset(command,'$',58); init(); timer0_init(); timer1_init(); timer3_init(); timer4_init(); timer5_init(); //lcd_init(); //lcd_string("Welcome"); //lcd_move(0,1); //lcdconfig(); //lcd_string("Give me a code:"); //lcd_move(0,2); UART_init(); //adc_init(); //lcdsenddata('F'); //lcd_num(123456); _delay_ms(1500); sei(); while(1) { //-------------------------------------------------scan for input while(mode==0) { while(1)//scan line { if(command[comm]=USART_Receive()) { if((command[comm]==13||command[comm]=='\n'||command[comm]==59)&&(comm<59)) { break; } if(echo==1) { //USART_Transmit('['); // USART_Transmit(comm+48); // USART_Transmit(']'); USART_Transmit(command[comm]); } comm++; } else { } } mode=1; if(echo==1) { USART_String_Transmit("\nTransition to parsing."); } } //-------------------------------------------------parse commands while(mode==1)//parse commands { for(i=0;i<comm;i++)//cycling i till \n-1 { if(command[i]=='N'&&command[i+1]>47&&command[i+1]<58)//GET LINE NUMBER { if(echo) { USART_String_Transmit("\n Getting line number."); } temp_line_number=fetchlong(command,i,'N'); } if(command[i]=='M'&&command[i+1]=='1'&&command[i+2]=='0'&&command[i+3]=='5')//GET EXTRUDER TEMP { } if(command[i]=='M'&&command[i+1]=='1'&&command[i+2]=='0'&&command[i+3]=='4')//SET EXTRUDER TEMP FAST SXXX { } if(command[i]=='M'&&command[i+1]=='1'&&command[i+2]=='0'&&command[i+3]=='9')//SET EXTRUDER TEMP AND WAIT RXXX { } if(command[i]=='M'&&command[i+1]=='1'&&command[i+2]=='4'&&command[i+3]=='0')//SET BED TEMP FAST SXXX { } if(command[i]=='M'&&command[i+1]=='1'&&command[i+2]=='9'&&command[i+3]=='0')//WAIT FOR BED TEMP TO HIT RXXX { } if(command[i]=='M'&&command[i+1]=='1'&&command[i+2]=='0'&&command[i+3]=='7')//FAN OFF { } if(command[i]=='M'&&command[i+1]=='1'&&command[i+2]=='0'&&command[i+3]=='6')//FAN ON WITH FAN SPEED S255MAX { } if(command[i]=='M'&&command[i+1]=='8'&&command[i+2]=='2'&&command[i+3]==' ')//EXTRUDER TO ABSOLUTE MODE { } if(command[i]=='G'&&command[i+1]=='2'&&command[i+2]=='1'&&command[i+3]==' ')//METRIC VALUES { } if(command[i]=='G'&&command[i+1]=='9'&&command[i+2]=='0'&&command[i+3]==' ')//ABSOLUTE POSITIONING { } if(command[i]=='G'&&command[i+1]=='9'&&command[i+2]=='2'&&command[i+3]==' ')//ZERO EXTRUDED LENGTH WITH E0 otherwise set origin? { } if(command[i]=='G'&&command[i+1]=='0'&&command[i+2]==' ')//MOVE WITHOUT EXTUSION { if(echo) { USART_String_Transmit("\nG0 command."); } line_engine(double_scan_x,double_scan_y,double_scan_z,double_scan_e,i); if((echo==1)&&(xroll==1)&&(yroll=1)) { USART_String_Transmit("\n Xroll=1"); USART_String_Transmit("\n Yroll=1"); } mode==2; } if(command[i]=='G'&&command[i+1]=='1'&&command[i+2]==' ')//MOVE WITH EXTRUSION { } if(command[i]=='Q'&&command[i+1]=='1')//MOTOR TEST { { if(echo) { USART_String_Transmit("\n Motor test on."); //xroll=1; yroll=1; //testval=(threefetchdouble(command,i,'E')/0.01)*16; } } if(command[i]=='Q'&&command[i+1]=='0')//MOTOR TEST { if(echo) { USART_String_Transmit("\n Motor test off."); } //xroll=0; yroll=0; } } mode=2; if(echo) { USART_String_Transmit("\nTransition to set outputs."); } } //-------------------------------------------------setting outputs while(mode==2) { while(zroll==1||eroll==1||xroll==1||yroll==1) { if(USART_Receive()=='.') { zroll=0; eroll=0; xroll=0; yroll=0; USART_String_Transmit("\nSW Emergency stopped, please reset!"); // PINK|=0b00000001; // PINA|=0b00000100; // PINF|=0b00000100; // PIND|=0b10000000; } } if(zroll==0&&eroll==0&&xroll==0&&yroll==0) { if(echo) { USART_String_Transmit("\nTransition to mode 3, reseting parameters."); } mode=3; } } //-------------------------------------------------clear things while(mode==3) { cli(); memset(command,'$',58); comm=0; i=0; double_scan_x=-1.0; double_scan_y=-1.0; double_scan_z=-1.0; double_scan_e=-1.0; if(echo) { USART_String_Transmit("\nParameters reseted returning to scanning mode"); } USART_String_Transmit("\n\rok"); sei(); mode=0; } //------------------------------------------------- while(mode==4) { } } return 0; }
void main() { unsigned int value,value1; int a=0,b=0; cli(); INIT_PORTS(); //Initialize ports uart0_init(); //Initialize UART0 for xbee communication timer5_init(); sei(); INIT_PORTS_ROTATE(); //Initialize ports right_position_encoder_interrupt_init(); //Initialize control registers for wheel left_position_encoder_interrupt_init(); // encoders. init_devices(); lcd_set_4bit(); //LCD initialization functions. lcd_init(); unsigned char angle = 0; init_devices_servo(); //Initialize servo motors. data='0'; sharp = ADC_Conversion(11); //Stores the Analog value of front sharp connected to ADC channel 11 into variable "sharp" value = Sharp_GP2D12_estimation(sharp); //Stores Distance calsulated in a variable "value". // lcd_print(1,1,value,3); // sharp1 = ADC_Conversion(10); //Stores the Analog value of front sharp connected to ADC channel 11 into variable "sharp" // value1 = Sharp_GP2D12_estimation(sharp1); //Stores Distance calsulated in a variable "value". // lcd_print(1,5,value1,3); // set servo for camera to ground zero servo_1(0); // code to bring the camera to ground state _delay_ms(1000); // set servo for incline to ground zero servo_2(90); // align camera _delay_ms(500); // the bot rotating slowly trying to find the bot int terminate = 0; while(data=='0' && terminate < 150) { velocity(150,150); //If no ball is detected the rotate and scan angle_rotate_left(3); // for ball in the arena. _delay_ms(500); stop(); _delay_ms(500); sharp = ADC_Conversion(11); //Stores the Analog value of front sharp connected to ADC channel 11 into variable "sharp" value = Sharp_GP2D12_estimation(sharp); //Stores Distance calsulated in a variable "value". terminate++; // lcd_print(1,1,value,3); } if(terminate == 60) { buzzer_on(); return; } /*If a ball(red colour) is detected then matlab code sends a '5' signal through zigbee.If a '5' is received then the robot stops rotating and moves towards the ball*/ value2 = 100; if(atoi(data) > 5) { lcd_print(1,5,value2,2); } velocity(160,184); // change value while(value>140) { sharp = ADC_Conversion(11); //Stores the Analog value of front sharp connected to ADC channel 11 into variable "sharp" value = Sharp_GP2D12_estimation(sharp); //Stores Distance calsulated in a variable "value". lcd_print(1,1,value,3); forward(); } stop(); _delay_ms(2000); /* the servo_1 is for the camera and the servo_2 is for the inclined plane */ // rotate 90 at left left90_at_place(); _delay_ms(1000); // rotate the camera 90 degrees to the right servo_1(90); _delay_ms(1000); //rotate in circle rotate_in_circle(); int perceived_height; perceived_height = atoi(data); lcd_print(1,5,perceived_height,5); // rotate 90 degrees to the right to face the ball again right90_at_place(); stop(); _delay_ms(2000); // rotate camera also to ground state to face the ball again servo_1(0); // code to bring the camera to ground state _delay_ms(1000); // set servo for incline int angle_of_inclination = get_angle(perceived_height); lcd_print(1,2,angle_of_inclination,5); servo_2(angle_of_inclination); _delay_ms(1000); while(1); }