예제 #1
0
/**
 * \brief main function : do init and loop
 */
int main(void)
{
	system_init();
	configure_console();
	delay_init();

	/* Turn on the backlight. */
	port_pin_set_output_level(SLCD_BACLKLIGHT,true);

	printf("Start SLCD test\r\n");
	/* Initialize the C42412A LCD glass component. */
	c42412a_init();

	c42412a_show_all();
	c42412a_set_contrast(0x8);
	delay_s(1);
	c42412a_clear_all();

	c42412a_icon_test();
	delay_s(1);
	c42412a_blink_test();
	delay_s(1);
	c42412a_text_test();
	delay_s(1);
	c42412a_num_dec_test();
	delay_s(1);
	c42412a_animation_test();
	while (1) {
	}
}
예제 #2
0
u8 dehStop(float arin[12],float arout[8],u8 dout[8])
{ 
    float dehpump,dehperr,dehfan,dehferr; 
	
    APortOut(DE_FAN,0,arout[DE_FAN]);
//	DPortOut(DEFUNSTART,0);	 
    delay_s(5);
    dehfan=APortIn(FANFB,arin[FANFB]);
    dehferr=fabs(dehfan-0); 
//    if(dehferr>=5.0)
//    {
//        return 6;            
//    }
    APortOut(DE_PUMP,0,arout[DE_PUMP]);
//	DPortOut(DEPUMPSTART,0);
	delay_s(5);
	dehpump=APortIn(PUMPFB,arin[PUMPFB]);
//    dehperr=fabs(dehpump-0); 
//	if(dehperr>=5.0)
//	{
//		return 3;            
//	}    
	dout[DESTART]=DESPVALUE;  
	DPortOut(DESTART,dout[DESTART]);
	return 0;	            
}
예제 #3
0
파일: lcd.c 프로젝트: lumberbarons/robot
void splash(const char* message) {
    delay_s(1);
    while(*message != 0) {
        send_character(*message++);
    }
    delay_s(2);
}
예제 #4
0
파일: gsm.c 프로젝트: ChangXiaodong/manhole
void GSMPowerOn_OFF()
{
//    DISABLE_DIO0;
//    DISABLE_DIO1;
    GSM_ON_H;
    delay_s(2);
    GSM_ON_L;
    
    delay_s(30);
    if(!openNet())
    {
        GPRS_Error();
    }
    delay_ms(100);
    if(!initHTTP())
    {
        GPRS_Error();
    }
    delay_ms(100);
    if(!setCID())
    {
        GPRS_Error();
    }
//    ENABLE_DIO0;
//    ENABLE_DIO1;
}
예제 #5
0
파일: gsm.c 프로젝트: ChangXiaodong/manhole
static void GPRS_Send(uint32_t address,uint8_t data_type, uint16_t data)
{
    setURL(address,data_type,data);
    delay_s(2);
    getRequest();
    delay_s(4);
    
}
예제 #6
0
void blink(void){
	ioport_set_pin_level(LED1,ON);
	ioport_set_pin_level(LED2,ON);
	delay_s(1);
	ioport_set_pin_level(LED1,OFF);
	ioport_set_pin_level(LED2,OFF);
	delay_s(1);
}
예제 #7
0
//Main
void main(void) {
	initBoard();
	backlightOn();

	//Configure interrupts
	//Interrupt on RB1 = SW_E
	OpenRB1INT(PORTB_CHANGE_INT_ON & FALLING_EDGE_INT & PORTB_PULLUPS_OFF & PORTB_INT_PRIO_HIGH);

	//Interrupt on RB0 = SW_W
	OpenRB0INT(PORTB_CHANGE_INT_ON & FALLING_EDGE_INT & PORTB_PULLUPS_OFF & PORTB_INT_PRIO_LOW);

	//Enable button input => not needed, see dwengoBoard.c->initBoard();
	TRISB = 0xFF;

	//Init motors
	initializeMotors();
	initializeSensors();
	
	while (TRUE) 
	{
		if(SW_N == 0)
		{
			mode = 0;
			clearLCD();
			printStringToLCD("Doing moves brah", 1, 0);
			leftMotor(700);
			rightMotor(700);
			delay_s(4);
			leftMotor(1000);
			rightMotor(700);
			delay_s(4);
			leftMotor(700);
			rightMotor(1000);
			delay_s(4);
			leftMotor(-700);
			rightMotor(700);
			delay_s(4);
		}
		else if(mode == 1)
		{
			//Light eating
			
		}
		else if(SW_S == 0)
		{
			//Start light eating
			//mode = 1;
			clearLCD();
			printStringToLCD("Going to send string", 0, 0);
			initializeRS232();
			sendData();
		}
		else
		{
			//printStringToLCD("Cool story bro", 0, 0);
		}
	}
}
예제 #8
0
void mode6(void)
{
	set_all_servo(ON);
	deploy_legs();
	delay_s(1);
	warming_up();
	delay_s(2);
	set_all_servo(OFF);
}
예제 #9
0
void menu_lockup (void) {
    char msg[] = "AVR>>RESET:\r";
    usb_cdc_send_string(USB_CMD, msg);
    usb_cdc_send_string(USB_ACL, msg);
    usb_cdc_send_string(USB_CAN, msg);
    delay_s(1);
    PWR_hub_stop();
    delay_s(1);
    RST_CTRL = true; //force SW reset
}
예제 #10
0
static void c42412a_text_test(void)
{
	c42412a_clear_text();
	c42412a_show_text((const uint8_t *)"Hi");
	delay_s(1);
	c42412a_clear_text();
	c42412a_show_text((const uint8_t *)"Hello");
	delay_s(1);
	c42412a_clear_text();
	c42412a_show_text((const uint8_t *)"Atmel");
}
예제 #11
0
파일: RUBIK.c 프로젝트: manraed/Rubik-s
// main program
void main(void) {
    
   /* PR2 = 0b10000000;   periode */
    /*CCPR2L = 0b10000000; /* duty cycle*/
    /*TRISBbits.RB3 = 0; /* als output zetten*/
    /*TRISCbits.RC1 = 0;/* als output zetten */
    /*CCP2CONbits.DC2B1 = 0; /* Duty cycle LSBs */
    /*CCP2CONbits.DC2B0 = 0; /* Duty cycle LSBs */
    /*CCP2CONbits.CCP2M = 0b1100;/* instellen PWM als output*/
    /*T2CONbits.TMR2ON = 1; /* zet timer op voor PWM*/
    //while(0){
    //   delay_s(1);
     //  if(vlag==0){
    //       LATBbits.LATB3 = 1;
    //       CCPR2L = 0b00000000;
    //       vlag = 1;
    //   }
    //   else {
    //       LATBbits.LATB3 = 0;
    //       CCPR2L = 0b10000000;
    //       vlag = 0;
    //   }
    //}
    //CCPR2L = 0;
    //initPWM();
    //delay_s(1);
    //motor2(1,3); /* vooruit */
    //delay_s(2);
    //motor2(0,3); /*  achteruit/open */
  while(0){  motor1(1,3);
    delay_s(1);
    motor2(0,3);
    delay_s(1);
    motor2(1,3);
    delay_s(1);
    motor1(0,3);
    delay_s(1);
    
  }
    
    // servo proberen
    initServo();
    state1 = 100; /* begin altijd bij 1.5 ms*/
    state2 = 25; 
    state3 = 25; 
    state4 = 25;
    while(1){
        
    }
 }
예제 #12
0
unsigned char nrf_dump()
{
	/*
	nrf_write(W_REGISTER + EN_AA, 0x00); // Enable Auto.Ack:Pipe0
	nrf_write(W_REGISTER + EN_RXADDR, 0x01); // Enable Pipe0
	nrf_write(W_REGISTER + RF_CH, 40); // Select RF channel 40
	nrf_write(W_REGISTER + RX_PW_P0, 4);
	nrf_write(W_REGISTER + RF_SETUP, 0x0f);
	nrf_write(W_REGISTER + CONFIG, 0x0f); // Set PWR_UP bit, enable CRC(2 bytes)
	  */
	char ret;
	ret=nrf_read(EN_AA);
	delay_s();
	ret=nrf_read(EN_RXADDR);
	delay_s();
	ret=nrf_read(RF_CH);
	delay_s();
	ret=nrf_read(RX_PW_P0);
	delay_s();
	ret=nrf_read(RF_SETUP);
	delay_s();
	ret=nrf_read(CONFIG);
	delay_s();	  
	ret=nrf_read(CD);
	delay_s();
	ret=nrf_read(STATUS);
	delay_s();
}
예제 #13
0
void mode4(void)
{
	deploy_legs();
	set_all_servo(ON);
	wait_servo(2);
	delay_s(1);
	start_turning(140, 40, -15, 300000);
	delay_s(1);
	for (unsigned int i = 0; i < 5; i++) {
		turn(140, 40, -15, 300000);
	}
	delay_s(1);
	set_all_servo(OFF);
}
예제 #14
0
파일: main.c 프로젝트: bpfender/EmbeddedC
void main(void)
{
    /*Variable Definitions*/
    struct DC_motor motorL, motorR; //declare two DC_motor structures

    motorL.power=0;
    motorL.direction=1;
    motorL.dutyLowByte=(unsigned char *)(&PDC1L);
    motorL.dutyHighByte=(unsigned char *)(&PDC1H);
    motorL.dir_pin=2;
    motorL.PWMperiod=PWMcycle;

    motorR.power=0;
    motorR.direction=1;
    motorR.dutyLowByte=(unsigned char *)(&PDC0L);
    motorR.dutyHighByte=(unsigned char *)(&PDC0H);
    motorR.dir_pin=0;
    motorR.PWMperiod=PWMcycle;

    struct DC_motor * m_L;
    struct DC_motor * m_R;
    m_L=&motorL;            //setup pointer to left motor
    m_R=&motorR;            //setup pointer to right motor

    /*Oscillator Setup*/
    OSCCON = 0x72; //8MHz clock
    while (!OSCCONbits.IOFS); //wait until stable

    /*Setup Registers*/
    TRISB = 0;
        
    initPWM(); //setup PWM registers
    
    while (1)
    {
        fullSpeedAhead(m_L,m_R);
        delay_s(1);
        stop(m_L,m_R);
        turnLeft(m_L,m_R);
        delay_s(1);
        stop(m_L,m_R);
        turnRight(m_L,m_R);
        delay_s(1);
        stop(m_L,m_R);
        backwards(m_L,m_R);
        delay_s(1);
        stop(m_L,m_R);
    }
}
예제 #15
0
static void c42412a_blink_test(void)
{
	c42412a_blink_icon_start(C42412A_ICON_USB);
	c42412a_blink_icon_start(C42412A_ICON_ATMEL);
	delay_s(1);
	c42412a_blink_icon_stop(C42412A_ICON_USB);
}
예제 #16
0
파일: main.c 프로젝트: wangdong/cpod
void loop() {
	am2312_ACInfo ac = {0};
	char buff[32] = "";

	hal_w2_enable(true);
	ac = am2312_read_ac();
	hal_w2_enable(false);

	if (ac.isOK) {
		sprintf(buff, "TEMP: %0.1fC", ac.temperature/10.0f);
		puts8x16(1, 0, buff);

		sprintf(buff, "HUMI: %0.1f%c", ac.humidity/10.0f, '%');
		puts8x16(2, 0, buff);

		puts6x8(7, 122, " ");
	}
	else {
		puts6x8(7, 122, "E");
		++stat_error;
	}

	sprintf(buff, "%s", ANIM_PROGRESS_KEYFRAMES[keyframe]);
	puts8x16(0, 98, buff);
	keyframe = (keyframe+1) % countof(ANIM_PROGRESS_KEYFRAMES);

	stat_all += 1;
	sprintf(buff, "%d/%d", stat_error, stat_all);
	puts6x8(7, 0, buff);

	delay_s(2);
}
예제 #17
0
//*******************************************************************************************************
//主程序
//*******************************************************************************************************
void read_6050data()
{ 

//		Display10BitData(GetData(ACCEL_XOUT_H));	//显示X轴加速度
//		Display10BitData(GetData(ACCEL_YOUT_H));	//显示Y轴加速度
//		Display10BitData(GetData(ACCEL_ZOUT_H));	//显示Z轴加速度
//		Display10BitData(GetData(GYRO_XOUT_H));		//显示X轴角速度
//		Display10BitData(GetData(GYRO_YOUT_H));		//显示Y轴角速度
//		Display10BitData(GetData(GYRO_ZOUT_H));		//显示Z轴角速度
		speed_z=GetData(ACCEL_ZOUT_H);
/*     	SeriPushSend(0x0d); 
   	    SeriPushSend(0x0a);//换行,回车*/
		if(flag_jibu==0)
		{
			if(speed_z>20000) 	flag_jibu=1;
			else flag_jibu=0;
		}
		else 
		{
			if(speed_z<12000) 
			{	
				bushu++;
				flag_jibu=0;  
			}
		}
			
		delay_s(80);
}
예제 #18
0
/**
 * \brief Application entry point for the example.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main(void)
{
	/* Initialize the SAM system */
	sysclk_init();
	board_init();    

	/* Initialize the UART console */
	configure_console();

	/* Output example information */
	puts(STRING_HEADER);

	/* First test sleepwalking in active mode */
	uart_sleepwalking_test_active();

	delay_s(1);

	/* Then test sleepwalking in wait mode */
	uart_sleepwalking_test_wait();

	puts("All test are done.\r\n\r");

	while (1) {
	}
}
예제 #19
0
파일: main.c 프로젝트: eeinz/trochili
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{    
    /*!< At this stage the microcontroller clock setting is already configured, 
    this is done through SystemInit() function which is called from startup
    file (startup_gd32f1x0.s) before to branch to application main.
    */
    SysTick_Config((SystemCoreClock / 1000));
    
    GD_EVAL_LEDInit (LED2);
    
    /* USART configuration */
    USART_Configuration();
    
    /* Configure SystemClock*/ 
    delay_s(20);
    
    /* Wake up from USART DeepSleep mode by Start bit Method */
    WakeUp_StartBitMethod();
    
    /* Configure SystemClock*/
    RestoreConfiguration();
    
    /* Configure and enable the systick timer to generate an interrupt each 1 ms */
    SysTick_Config((SystemCoreClock / 1000));
    
    while (1)
    {
    }
}
예제 #20
0
파일: DELAY.C 프로젝트: Abhyudaykg/study
main()
{

delay_s(1);
	while(1);

}
예제 #21
0
파일: delay_example.c 프로젝트: marekr/asf
int main(void)
{
	system_init();
	delay_init();

	struct port_config pin;
	port_get_config_defaults(&pin);
	pin.direction = PORT_PIN_DIR_OUTPUT;

	port_pin_set_config(LED0_PIN, &pin);
	port_pin_set_output_level(LED0_PIN, LED0_INACTIVE);

	while (true) {
		for (int i = 0; i < 5; i++) {
			port_pin_toggle_output_level(LED0_PIN);
			delay_s(1);
		}

		for (int i = 0; i < 50; i++) {
			port_pin_toggle_output_level(LED0_PIN);
			delay_ms(100);
		}

		for (int i = 0; i < 5000; i++) {
			port_pin_toggle_output_level(LED0_PIN);
			delay_cycles(100);
		}
	}
}
예제 #22
0
int main (void)
{
	board_init();	//Board definition and selection
	sysclk_init();	//System clock init
	
	usart_init_rs232(USART_SERIAL_RFID, &usart_options_RFID);	//UART init
	usart_init_rs232(USART_SERIAL_Monitor, &usart_options_Monitor);
	
	gfx_mono_init();	//LCD init
	PORTE.OUTSET=PIN4_bm;	//LCD Back light on
	
	//RTC Init
	sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_RTC);
	while (RTC32.SYNCCTRL & RTC32_SYNCBUSY_bm);
	if (rtc_vbat_system_check(false) != VBAT_STATUS_OK)
		rtc_init();
	PORTE.DIRCLR=PIN5_bm;
	
	while(1)
	{
		if(Receive())
		{
			card_no=Check();
			if(card_no)
			{
				PORTR.OUTCLR=PIN0_bm;
				gfx_mono_draw_string("Card Detected",0,0,&sysfont);
				gfx_mono_draw_string("Welcome",0,10,&sysfont);
				gfx_mono_draw_string(names[card_no-1],55,10,&sysfont);
				rtc_timestamp=rtc_get_time();
				calendar_timestamp_to_date_tz(rtc_timestamp,5,30,&get_date);
				gfx_mono_draw_string(display_time(get_date,arr),0,20,&sysfont);
				delay_s(1);
				gfx_mono_init();
				PORTR.OUTSET=PIN0_bm;
			}
			else
			{
				PORTR.OUTCLR=PIN1_bm;
				gfx_mono_draw_string("Invalid Card",0,0,&sysfont);
				delay_s(1);
				gfx_mono_init();
				PORTR.OUTSET=PIN1_bm;
			}
		}
	}
}
예제 #23
0
static void c42412a_num_dec_test(void)
{
	c42412a_clear_numeric_dec();
	c42412a_show_numeric_dec(12);
	delay_s(1);
	c42412a_clear_numeric_dec();
	c42412a_show_numeric_dec(345);
	delay_s(1);
	c42412a_clear_numeric_dec();
	c42412a_show_numeric_dec(6789);
	delay_s(1);
	c42412a_clear_numeric_dec();
	c42412a_show_numeric_dec(-98765);
	delay_s(1);
	c42412a_clear_numeric_dec();
	c42412a_show_numeric_dec(-198765);
}
예제 #24
0
void main() {
	
	Init_Registers();
    initPorts();
	LCD_initialize();
    LCD_Clear();

    while (1) {
        TMR0_GATE_LINE  = 0;	            //Turn OFF Gate line
        LCD_print(0,0,    "Line1");      	// LCD_Line1-0
        LCD_printf(0,7,   ":%03d ", 54);    // LCD_Line1-7 
        LCD_printRom(1,0, "Line2");         // LCD_Line2-0
        delay_s(1);
        TMR0_GATE_LINE  = 1;	            //Turn OFF Gate line
        delay_s(1);
    }

}    
예제 #25
0
/**
 * \brief Main entry of example application
 */
int main(void)
{
	struct gfx_mono_spinctrl spinner1;
	struct gfx_mono_spinctrl spinner2;
	struct gfx_mono_spinctrl spinner3;
	struct gfx_mono_spinctrl_spincollection spinners;

	/**
	 * Starts off by initializing the system clock before configuring the
	 * board and the monochrome graphical system.
	 */
	system_init();
	gfx_mono_init();

	int16_t tmp[3];

	// Initialize spinners
	gfx_mono_spinctrl_init(&spinner1, SPINTYPE_STRING, spinnertitle,
			spinner_choicestrings, 0, 3, 0);
	gfx_mono_spinctrl_init(&spinner2, SPINTYPE_INTEGER,
			spinnertitle2, NULL, -60, -41, 0);
	gfx_mono_spinctrl_init(&spinner3, SPINTYPE_INTEGER,
			spinnertitle3, NULL, 19999, 20200, 0);

	// Initialize spincollection
	gfx_mono_spinctrl_spincollection_init(&spinners);

	// Add spinners to spincollection
	gfx_mono_spinctrl_spincollection_add_spinner(&spinner1, &spinners);
	gfx_mono_spinctrl_spincollection_add_spinner(&spinner2, &spinners);
	gfx_mono_spinctrl_spincollection_add_spinner(&spinner3, &spinners);

	// Show spincollection on screen
	gfx_mono_spinctrl_spincollection_show(&spinners);

	// Spincollection is now ready to process input from user

	while(1) {
		gfx_mono_spinctrl_spincollection_process_key(&spinners, GFX_MONO_SPINCTRL_KEYCODE_DOWN, tmp);
		delay_s(1);
		gfx_mono_spinctrl_spincollection_process_key(&spinners, GFX_MONO_SPINCTRL_KEYCODE_ENTER, tmp);
		delay_s(1);
	}
}
예제 #26
0
void main()
{
  Init_CLK();
  LCD_Init();   //TFT³õʼ»¯
  LCD_Clear(WHITE); //ÇåÆÁ
  LCD_Clear(RED);
  delay_s(2);
  LCD_Clear(GREEN);
  delay_s(2);
  LCD_Clear(BLUE);
  delay_s(2);
  
  showimage(); 
  
  while(1)
  {
    ;
  }
}
예제 #27
0
void displayOnOff(void){
	static uint32_t j=0;
	static int32_t SEL =4;
			
			
				   display(15);
				   delay_s(100);
				   display(0);
				   delay_s(100);
				   if (j>6) {
				   pm_switch_to_clock(&AVR32_PM,0); //cambia al RC
				   pm_pll_disable(&AVR32_PM,0); // deshabilita el el PLL 0
				   
				   pm_pll_setup(&AVR32_PM,0,SEL,1,0,16); // lockcount in main clock for the PLL wait lock

				   //_______________________________________________________________________________
				   // Establece la frecuencia de salida del PLL
				   pm_pll_set_option(&AVR32_PM,0,1,0,0);//1 Star-up faster, Start-up normal
				   //_______________________________________________________________________________
				   //Habilita el PLL 0
				   pm_pll_enable(&AVR32_PM,0);
				   //_______________________________________________________________________________
				   //Espera a que se establesca el PLL
				   pm_wait_for_pll0_locked(&AVR32_PM) ;
				   //_______________________________________________________________________________
				   // Set one wait-state (WS) for flash controller
				   flashc_set_wait_state(1);

				   //habilita la salida del PLL0 con 2 y el OSC0 con 1
				   pm_switch_to_clock(&AVR32_PM, 2);
				   SEL-=2;
				   if (SEL<2)
				   {
					   SEL=6;
				   }
				j=0;
			}
			j++;
		
	
	
}
예제 #28
0
 void valveopen(float t)
 {
 u8  timecntF;
 u8    timecntI;
 int i;
 
    DPortOut(SV4,1); 
 timecntI =	floor(t/10)	;
 timecntF = floor(t-10*timecntI);
 for(i=0;i<timecntI;i++)
{
	delay_s(10);

	}

 delay_s(timecntF);

	DPortOut(SV4,0);
 
 }
예제 #29
0
void init()
{
	SystemInit();
	LCD1602_Init();
	NRF24L01_Init();//2.4G无线初始化
	Usart_Configuration();
	Usart_NVIC_Configuration();
	LCD1602_WriteString_At_Pos(0,1,"  STATUS:Normal ");
	LCD1602_WriteString_At_Pos(0,2,"LOCK 1:OFF 2:OFF");
	delay_s(2);
}
예제 #30
0
void Dc_Moto_test(){
  //clockwise_run();
  //delay_s(3);
 // clockwise_stop();
 // delay_ms(10);
  aniclockwise_run();
  delay_s(3);
  aniclockwise_stop();
  
  //MOTO_1AL_INPUT FOR SAVE POWER
 // MOTO_1AL_INPUT;
}