示例#1
0
unsigned char _ADBOpen()
{
	u32 wait=0;
	
	h = ADBOpen("tcp:2000", &ADBreceive);
	while ((wait<1000)&&(!ADBChannelReady(h))) 
		{
			ADBTasks();
			Delayms(1);
			wait++;
		}
	if (wait<1000) return TRUE;
	else return FALSE;
}
示例#2
0
void USE_LCD(void)
{
    CSOUT &= ~CS;        //片选信号  CS
    Delayms(15);
    //为DA
    UCB0CTL1 |= UCSWRST;                      // **Put state machine in reset**
    UCB0CTL0 = UCMST+UCSYNC+UCCKPL+UCMSB;    // 3-pin, 8-bit SPI master
    // Clock polarity high, MSB
    UCB0CTL1 |= UCSSEL_2;                     // SMCLK
    UCB0BR0 = 0x00;                           // /2
    UCB0BR1 = 0;                              //
    // No modulation
    UCB0CTL1 &= ~UCSWRST;
}
示例#3
0
文件: button.c 项目: eseawind/MCU
int main()
{
    while(1)
    {
        if(P2 != 0xff)    // some button was down
        {
            Button_Test();
            Delayms(100);
        }
        P0 = 0xff;
    }

    return 0;
}
/*APRIMORAR E TESTAR*/
void menu(void){
    int b1, b2, digital = 0;
    int menu = 0;

	while(!digital){
        digital = readJSButton();
        b1 = readButtons('1');
        b2 = readButtons('2');

        if(b1||b2){
        	menu++;
        	menu %= 2;
        }

        if(menu == 0){
            TM_HD44780_Clear();
            TM_HD44780_Puts(0, 0, "MODO AUTONOMO");
            TM_HD44780_PutCustom(15, 0, 0);
            TM_HD44780_Puts(0, 1, "MODO MANUAL");
            Delayms(50);
        }else if(menu == 1){
            TM_HD44780_Clear();
            TM_HD44780_Puts(0, 0, "MODO AUTONOMO");
            TM_HD44780_Puts(0, 1, "MODO MANUAL");
            TM_HD44780_PutCustom(15, 1, 0);
            Delayms(50);
        }
    TM_HD44780_Clear();
	}

	if(menu == 0){
		modoPerfuracao();
		//setDesenhaQuadrado();
	}else if(menu == 1){
		manualControl();
	}
}
示例#5
0
void IRsend_sendSharp(u32 data, u16 nbits)
{
  u32 invertdata = data ^ SHARP_TOGGLE_MASK;
  u16 i;
  PWM_setFrequency(38000);
  
  for (i = 0; i < nbits; i++) {
    if (data & 0x4000) {
      IRsend_mark(SHARP_BIT_MARK);
      IRsend_space(SHARP_ONE_SPACE);
    }
    else {
      IRsend_mark(SHARP_BIT_MARK);
      IRsend_space(SHARP_ZERO_SPACE);
    }
    data <<= 1;
  }
  
  IRsend_mark(SHARP_BIT_MARK);
  IRsend_space(SHARP_ZERO_SPACE);
  Delayms(46);
  
  for (i = 0; i < nbits; i++) {
    if (invertdata & 0x4000) {
      IRsend_mark(SHARP_BIT_MARK);
      IRsend_space(SHARP_ONE_SPACE);
    }
    else {
      IRsend_mark(SHARP_BIT_MARK);
      IRsend_space(SHARP_ZERO_SPACE);
    }
    invertdata <<= 1;
  }
  IRsend_mark(SHARP_BIT_MARK);
  IRsend_space(SHARP_ZERO_SPACE);
  Delayms(46);
}
示例#6
0
int main(void){
	SystemInit();
	TM_DELAY_Init();
	TM_ILI9341_Init();
	TM_ILI9341_SetLayer1();

	/* Initialize USART2 at 115200 baud, TX: PD5, RX: PD6 */
	TM_USART_Init(USART2, TM_USART_PinsPack_2, 115200);
	
	uint8_t wacc = 0x3A; // 0xA6
	uint8_t racc = 0x3B; // 0xA7

	// 0x2D POWER_CTL: Power-saving features control
	TM_I2C_Write(I2C2, wacc, 0x2D, 0x08);
	// 0x31 DATA_FORMAT: Data format control
	//TM_I2C_Write(I2C1, wacc, 0x31, 0x0B); // FULL_RES and +- 16g
	TM_I2C_Write(I2C2, wacc, 0x31, 0x01); // fixed resolution and +- 4g
	// 0x2C BW_RATE: Data rate and power mode control
	TM_I2C_Write(I2C2, wacc, 0x2C, 0x0A);
	
	char str[16] = {0};
	sprintf(str, "delay = 100");
	TM_USART_Puts(USART2, str); 
	while(1){

		TM_ILI9341_Fill(ILI9341_COLOR_WHITE);
		TM_ILI9341_Puts(30, 30, str, &TM_Font_11x18, ILI9341_COLOR_WHITE, ILI9341_COLOR_BLUE2);
		uint8_t buff[6] = {0};
		int16_t tri[3] = {0};
		TM_I2C_ReadMulti(I2C2, racc, 0x32, buff, 6);
		
		// original read digit
		tri[0] = (int16_t) ((uint16_t)buff[1] << 8 | (uint16_t)buff[0]);	
		tri[1] = (int16_t) ((uint16_t)buff[3] << 8 | (uint16_t)buff[2]);	
		tri[2] = (int16_t) ((uint16_t)buff[5] << 8 | (uint16_t)buff[4]);	
		
		float ftri[3] = {0}, divisor = 128.0f;
		ftri[0] = (float) tri[0] / divisor;
		ftri[1] = (float) tri[1] / divisor;
		ftri[2] = (float) tri[2] / divisor;
	
		sprintf(str, "%.3f,%.3f,%.3f\n\r", ftri[0], ftri[1], ftri[2]);
		TM_USART_Puts(USART2, str); 
		TM_ILI9341_Puts(30, 50, str, &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_WHITE);
		
		Delayms(100);
	}

}
示例#7
0
文件: main.c 项目: Acse/stm32f429
int main(void) {
	/* Initialize system */
	SystemInit();
	
	/* Initialize delay */
	TM_DELAY_Init();
	
	/* Initialize leds on board */
	TM_DISCO_LedInit();
	
	/* Turn on all leds */
	TM_DISCO_LedOn(LED_ALL);
	
	/* Delay 2 seconds */
	Delayms(2000);
	
	while (1) {
		/* Toggle leds */
		TM_DISCO_LedToggle(LED_ALL);
		
		/* Wait 500ms */
		Delayms(500);
	}
}
示例#8
0
文件: LCD.c 项目: eseawind/MCU
void LCD_Op5()     // 返回键操作
{
    //0000 1           D        C       B
    LCD_W_Cmd(0x0c);//显示on,光标off,  光标闪烁off
    Delayms(1);
    LCD_Display();

    if(POS >= 8)  // 配置闹钟,则不需要重新保存时间
        Alarm_Save();
    else
        Time_Save();

    POS = 0;
    TR0 = 1;    // 重新开始时钟
}
示例#9
0
  /*
********************************************************************************
** 函数名称 : main(void)
** 函数功能 : 主函数
** 输    入	: 无
** 输    出	: 无
** 返    回	: 无
********************************************************************************
*/
int main(void)
{ 
  RCC_Configuration();		 //配置RCC
  GPIO_Configuration();		 //配置GPIO
  USART1_Configuration();	 //配置串口1
  I2C_GPIO_Config();		 //配置IIC使用端口
  Delayms(10);				 //延时
  Init_MPU3050();		     //初始化MPU3050
  while(1)
 {
	READ_MPU3050();	         //读取MPU3050数据
    DATA_printf(TX_DATA,T_X);//转换X轴数据到数组
	Send_data('X');			 //发送X轴数
	DATA_printf(TX_DATA,T_Y);//转换Y轴数据到数组
	Send_data('Y');			 //发送Y轴数
	DATA_printf(TX_DATA,T_Z);//转换Z轴数据到数组
	Send_data('Z');			 //发送Z轴数
	DATA_printf(TX_DATA,T_T);//转换温度数据到数组
	Send_data('T');			 //发送温度数据
	USART1_SendData(0X0D);	 //换行
	USART1_SendData(0X0A);	 //回车
	Delayms(5);				 //延时
  }
}
示例#10
0
文件: LCD.c 项目: eseawind/MCU
void LCD_Init()    //LCD初始化设定
{
    unsigned char i = 0;

    //显示模式设置 0011 1000, 16*2显示,5*7点阵,8位数据接口
    LCD_W_Cmd(0x38);
    Delayms(1);

    //0000 1           D        C       B
    LCD_W_Cmd(0x0c);//显示on,光标off,  光标闪烁off
    Delayms(1);

    //0000 01          N                   S
    LCD_W_Cmd(0x06);//读写操作后指针加/减  写入字符后整屏是否左移
    Delayms(1);

    // 01H 数据指针清零,显示清零        02H 数据指针清零
    LCD_W_Cmd(0x01);     //清除LCD的显示内容
    Delayms(10);

    Time_Load(); // 载入时间数据
    //显示数据
    LCD_Display();
}
示例#11
0
文件: miscm.c 项目: mrugala/pm
void HDStartSeq(void)
{
	TM_HD44780_CreateChar(0, &customChar[0]);

	TM_HD44780_Puts(0, 0, "Servo Driver\n\rSTM32F4");

	Delayms(3000);

	TM_HD44780_Clear();

	TM_HD44780_Puts(3, 0, "MANY FUN!");
	TM_HD44780_Puts(6, 1, "WOW!");

	Delayms(1000);

	TM_HD44780_PutCustom(0, 0, 0);
	TM_HD44780_PutCustom(14, 0, 0);
	TM_HD44780_PutCustom(1, 1, 0);
	TM_HD44780_PutCustom(15, 1, 0);

	Delayms(1000);

	TM_HD44780_Clear();
}
示例#12
0
void RTNA_LCD_Init(void)
{
	MMPF_PANEL_ATTR panelAttr;

#if (SECONDARY_DISPLAY == 1) 
    RTNA_LCD_Init2ndLCD();   
#else
    RTNA_LCD_InitMainLCD();
#endif
	
	MMPF_LCD_Write16BitCmd(&m_PanelAttr, 0x051E);   
	Delayms(10); 
	MMPF_LCD_Write16BitCmd(&m_PanelAttr, 0x055D);
	MMPF_LCD_Write16BitCmd(&m_PanelAttr, 0x2B01); 
	Delayms(10); 
	MMPF_LCD_Write16BitCmd(&m_PanelAttr, 0x000A);   
	MMPF_LCD_Write16BitCmd(&m_PanelAttr, 0x0B81);   
	MMPF_LCD_Write16BitCmd(&m_PanelAttr, 0x0194);   
	MMPF_LCD_Write16BitCmd(&m_PanelAttr, 0x041B);   
	MMPF_LCD_Write16BitCmd(&m_PanelAttr, 0x0695);   
	MMPF_LCD_Write16BitCmd(&m_PanelAttr, 0x07F0);
	MMPF_LCD_Write16BitCmd(&m_PanelAttr, 0x1600);
	MMPF_LCD_Write16BitCmd(&m_PanelAttr, 0x1777);
    MMPF_LCD_Write16BitCmd(&m_PanelAttr, 0x1855);
	MMPF_LCD_Write16BitCmd(&m_PanelAttr, 0x1901);
	MMPF_LCD_Write16BitCmd(&m_PanelAttr, 0x1A20);
	Delayms(10); 
    // 1st cmd
        
    
 
    
    

   
}
示例#13
0
/*******************************************************************************
* 函 数 名 :LEDdisplay
* 函数功能 :循环显示各个位上的数据
* 输    入 :num要显示的数据
* 输    出 :无
*******************************************************************************/
void LEDdisplay(unsigned int num)
{
	unsigned char qian,bai,shi,ge;
	qian=num/1000;
	bai=num%1000/100;
	shi=num%100/10;
	ge=num%10;
	
	wela_1 = 1;	  //关闭所有数码管
	wela_2 = 1;
	wela_3 = 1;
	wela_4 = 1;	

	wela_4=0;  //显示千位
	LED_PORT=table[qian];
	Delayms(1);
	LED_PORT = 0xff;
	wela_4=1;
	
	wela_3=0;  //显示百位
	LED_PORT=table[bai];
	Delayms(1);
	LED_PORT = 0xff;
	wela_3=1;
	
	wela_2=0;  //显示十位
	LED_PORT=table[shi];
	Delayms(1);
	LED_PORT = 0xff;
	wela_2=1;
	
	wela_1=0;  //显示个位
	LED_PORT=table[ge];
	Delayms(1);
	LED_PORT = 0xff;
}
示例#14
0
/*******************************************************************************
* 函 数 名 :KeyScan
* 函数功能 :按键扫描
* 输    入 :无
* 输    出 :无
*******************************************************************************/
void KeyScan(void)
{
		if(key_inc==0)
		{
			
			Delayms(5);
			if(key_inc==0);
			{	
			    while(key_inc==0);
				speed++;
				if(speed > MAX_SPEED)	speed = MAX_SPEED;
			}
		}
			if(key_dec==0)
		{
			Delayms(5);
			if(key_dec==0);
			{
			    while(key_dec==0);
				if(speed <= MIN_SPEED)	speed = MIN_SPEED;
				speed--;	
			}
		}
}
/*****************************************************************************
* 函 数 名:initial_ds1302
* 函数功能:初始化DS1302子程序
* 输    入:time[](全局变量)
* 输    出:
*****************************************************************************/
void InitDs1302()
{
	WriteDs1302(0x8e,0x00);		//写保护寄存器,在对时钟或RAM写前WP一定要为0
	Delayms(5);
	WriteDs1302(0x8c,time[0]);		//年
	Delayms(5);
	WriteDs1302(0x88,time[1]);		//月
	Delayms(5);
	WriteDs1302(0x86,time[2]);		//日
	Delayms(5);
	WriteDs1302(0x8A,time[3]);		//星期
	Delayms(5);
	WriteDs1302(0x84,time[4]);		//时
	Delayms(5);
	WriteDs1302(0x82,time[5]);		//分
	Delayms(5);
	WriteDs1302(0x80,time[6]);		//秒
	Delayms(5);
	WriteDs1302(0x8e,0x80);		//写保护寄存器
	Delayms(5);
}
示例#16
0
void Eraseleds(void) {
    unsigned char g = 0;

    for (g = 0; g < 192; g++) {
        SHIFT_DATA = 0;
        SHIFT_CLOCK = 1;
        Delayus(1);
        SHIFT_CLOCK = 0;
        Delayus(1);
    }
    SHIFT_DATA = 0;
    SHIFT_STROBE = 1;
    Delayus(1);
    SHIFT_STROBE = 0;
    Delayms(1);
}
示例#17
0
void loop()
{
int valor[8];
int a=0;
u8 buf[80];
for(a=0;a<8;a++)
{
valor[a]=analogread(13+a);
Delayus(1);
}

sprintf(buf, " %i,%i,%i,%i,%i,%i,%i,%i\n\r", valor[0],valor[1],valor[2],valor[3],valor[4],valor[5],valor[6],valor[7]);

    usbsend(buf,39);
    Delayms(1);
}
示例#18
0
/*******************************************************************************
* 函 数 名:	
* 功    能:	
* 参    数:
* 返    回:	
*******************************************************************************/
uint8_t RTC_Init(uint32_t pre_value, uint32_t alarm_value, uint32_t count_value)
{	
	uint8_t count;
    NVIC_InitTypeDef NVIC_InitStructure;
	//RTC全局中断
	NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn;		
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;	
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;	
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;		
	NVIC_Init(&NVIC_InitStructure);		

	RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR , ENABLE);	
	PWR_BackupAccessCmd(ENABLE);
	//设置外部低速晶振(LSE),使用外设低速晶振
	RCC_LSEConfig(RCC_LSE_ON);	
	//检查指定的RCC标志位设置与否,等待低速晶振就绪
	while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)	
	{
		count++;
		Delayms(10);
	}
	if(count>=250)
		return 1;
	//设置RTC时钟(RTCCLK),选择LSE作为RTC时钟   
	RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);		 
	RCC_RTCCLKCmd(ENABLE);	
	//等待最近一次对RTC寄存器的读操作完成
	RTC_WaitForSynchro();
	//等待最近一次对RTC寄存器的写操作完成
	RTC_WaitForLastTask();	
	//设置报警时间
	RTC_SetAlarm(alarm_value);
	RTC_WaitForLastTask();	
	//配置中断
	RTC_ITConfig( RTC_IT_SEC|RTC_IT_ALR|RTC_IT_OW, ENABLE);	
	RTC_WaitForLastTask();	
	//设置RTC预分频的值
	RTC_SetPrescaler(pre_value); 
	RTC_WaitForLastTask();	
	//清除RCC的复位标志位
	RCC_ClearFlag();
	
 	RTC_WaitForLastTask();	
	RTC_SetCounter(count_value);	
	RTC_WaitForLastTask();	
	return 0;
}
示例#19
0
void display_init(void)
{
	// Reset wyœwietlacza
	SetPin_LowE(_RES);
	Delayms(50);
	SetPin_HighE(_RES);

	SetPin_LowE(A0);
	SetPin_HighE(_RD);
	SetPin_LowE(_WR);

	// POWER SAVER SHOULD BE HERE
	//D7_to_D0(SPLC501C_DISPLAY_REVERSE);
	//send();
	//D7_to_D0(SPLC501C_RESET);
	//send();
	//D7_to_D0(SPLC501C_START_LINE | 0); //0
	//send();
	D7_to_D0(SPLC501C_BIAS_19);
	send();
	D7_to_D0(SPLC501C_ADC_NORMAL);
	send();
	D7_to_D0(SPLC501C_COM63);
	send();
	D7_to_D0(SPLC501C_VOLUME_MODE);
	send();
	D7_to_D0(0x14);//"00010100");
	send();
	D7_to_D0(SPLC501C_DISPLAY_ON);
	send();
	D7_to_D0(SPLC501C_DISPLAY_NORMAL);
	send();
	D7_to_D0(SPLC501C_POWERON);
	send();

	/*
	D7_to_D0(SPLC501C_COLUMN_ADDRESS_LO); //0
	send();
	D7_to_D0(SPLC501C_COLUMN_ADDRESS_HI); //0
	send();
	D7_to_D0(SPLC501C_START_LINE | 0); //0
	send();
	D7_to_D0(SPLC501C_PAGE_ADDRESS | 0); //0
	send();
*/
}
示例#20
0
文件: time.c 项目: eseawind/MCU
void Time_Save()         // 保存时间数据
{
    Send_Str(AT24C02, 0, &YEAR1, 1);       // 要有足够的间隔时间去等待AT24C02接受数据
    Delayms(2);
    Send_Str(AT24C02, 1, &YEAR2, 1);
    Delayms(2);
    Send_Str(AT24C02, 2, &MONTH, 1);
    Delayms(2);
    Send_Str(AT24C02, 3, &DAY, 1);
    Delayms(2);
    Send_Str(AT24C02, 4, &WEEK, 1);
    Delayms(2);
    Send_Str(AT24C02, 5, &HOUR, 1);
    Delayms(2);
    Send_Str(AT24C02, 6, &MINUTE, 1);
    Delayms(2);
    Send_Str(AT24C02, 7, &SECOND, 1);
    Delayms(2);
}
示例#21
0
int8_t SIM300Init()
{
	//Init USART lib
	

	//Check communication line
	SIM300Cmd("AT");	//Test command
	
	//Now wait for response
	uint16_t i=0;
	int z=0;
	//correct response is 6 byte long
	//So wait until we have got 6 bytes
	//in buffer.
	while(i<10)
	{
		if(TM_USART_Available(USART1) < 6)
		{
			i++;
			
			Delayms(10);
			SIM300Cmd("AT");
			continue;
		}			
		else
		{
			//We got a response that is 6 bytes long
			//Now check it	

			z = TM_USART_GetAll(USART1,sim300_buffer,8);	//Read serial Data
			printf("%d bytes read from GSM module\n",z);
			for (int i=0; i<z+1; i++)
				printf("GSM USART data byte %d: %02x | %c\n",i,sim300_buffer[i],sim300_buffer[i]);
			TM_USART_ClearBuffer(USART1);
			return SIM300CheckResponse(sim300_buffer,"OK",6);
				
		}			
	}
	
	//We waited so long but got no response
	//So tell caller that we timed out

	return SIM300_TIMEOUT;
			
}
示例#22
0
///*
int main(void)
{  
    char keyVal;
    static bool sw_adxl345 = true,sw_l3g4200d = true, sw_hmc5883l=true,sw_bmp085 =true;
    
    SystemInit();
    USART3_Config();
    I2C_config();
    L3G4200D_Init();
    printf("Initial successed!\n\r");
    while(1)
    {
       // L3G4200D_MultRead(&l3g4200d);   //讀陀螺儀數據(速度:較快)
	L3G4200D_Read(&l3g4200d);
	L3G4200D_Printf(&l3g4200d);
        Delayms(10);    
    }
}
示例#23
0
void DCMI_0V7670_PWDN_Init(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;

	/* Enable GPIOs clocks */
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
		
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;  
	GPIO_Init(GPIOB, &GPIO_InitStructure);
	/*PWDN*/
	GPIO_ResetBits(GPIOA, GPIO_Pin_2);
	Delayms(10);
	GPIO_SetBits(GPIOA, GPIO_Pin_2);	
}
示例#24
0
int8_t SIM300GetNetStat()
{
	//Send Command
	SIM300Cmd("AT+CREG?");
	
	//Now wait for response
	uint16_t i=0;
	
	//correct response is 20 byte long
	//So wait until we have got 20 bytes
	//in buffer.
	while(i<10)
	{
		if(TM_USART_Available(USART1)<20)
		{
			i++;
			
			Delayms(10);
			
			continue;
		}
		else
		{
			//We got a response that is 20 bytes long
			//Now check it
			TM_USART_Gets(USART1,sim300_buffer,20);	//Read serial Data
			
			if(sim300_buffer[11]=='1')
				return SIM300_NW_REGISTERED_HOME;
			else if(sim300_buffer[11]=='2')
				return SIM300_NW_SEARCHING;
			else if(sim300_buffer[11]=='5')
				return SIM300_NW_REGISTED_ROAMING;
			else
				return SIM300_NW_ERROR;			
		}
	}
	
	//We waited so long but got no response
	//So tell caller that we timed out
	
	return SIM300_TIMEOUT;
	
}
示例#25
0
int main(void) {
	/* Init system clock for maximum system speed */
	TM_RCC_InitSystem();
	
	/* Init HAL layer */
	HAL_Init();
	
	/* Initialize delay */
	TM_DELAY_Init();
	
	/* Initialize leds on board */
	TM_DISCO_LedInit();
	
	/* Init button */
	TM_DISCO_ButtonInit();
	
	/* Init USART6, TX: PC6, 921600 baud */
	TM_USART_Init(USART6, TM_USART_PinsPack_1, 921600);
	
	/* Get system reset source and clear flags after read */
	printf("System reset source: %d\n", (uint8_t)TM_GENERAL_GetResetSource(1));
	
	/* Get system reset source and clear flags after read */
	/* You should see number which corresponds to "None", because we cleared flags in statement above */
	printf("System reset source: %d\n", (uint8_t)TM_GENERAL_GetResetSource(1));
	
	/* Get system core and PCLK1 (Peripheral Clock 1, APB1) clocks */
	printf("System core clock: %u Hz; PCLK1 clock: %u Hz\n", 
		TM_GENERAL_GetClockSpeed(TM_GENERAL_Clock_SYSCLK),
		TM_GENERAL_GetClockSpeed(TM_GENERAL_Clock_PCLK1)
	);
	
	while (1) {
		/* If button pressed */
		if (TM_DISCO_ButtonOnPressed()) {
			/* Send to USER */
			printf("Software reset will happen in a moment\n");
			/* Wait a little */
			Delayms(500);
			/* Perform system software reset */
			TM_GENERAL_SystemReset();
		}
	}
}
示例#26
0
void BarrierProc()
{
		if(distance_cm < 10)//前方有障碍物
	{
		unsigned int dis_left;//左边距离
		unsigned int dis_right;//右边距离
		unsigned int dis_direct;//右边距离
		if(distance_cm < 8)
		{
			CarBack();
			Delayms(400);
		}
		
		while(1)
		{
			GetAllDistance(&dis_left,&dis_right,&dis_direct);
			if(dis_direct < 5)
			{
				CarBack();
				Delayms(300);
				continue;
			}
			else if((dis_left < 5) || (dis_right < 5))
			{
				CarBack();
				Delayms(300);
				continue;
			}
			else if(dis_direct >= dis_left && dis_direct >= dis_right)//前方距离最远
			{
				CarGo();
				Delayms(600);
				return;
			}
			else if(dis_left <= dis_right)//右转
			{
				CarRight();
				Delayms(500);
			}
			else if(dis_right < dis_left)
			{
				CarLeft();
				Delayms(500);
			}
		}
	}
	else
	{
		CarGo();
	}
}
示例#27
0
int main()
{
  /* Initialize system */
  SystemInit();

  /* Initialize delay */
  TM_DELAY_Init();

  // Pin GPIO H4 for use by logic analyser.
  ConfigureDebugOutputPin();

  USART3_Configuration();
  printf("\r***************************************************************\r");
  printf("* DS18B20 Temperature Controller                              *\r");
  printf("***************************************************************\r");

  // Setup the GPIO port and pin to talk to OneWire devices.
  DS18B20_Init();

  //Search for devices and show their ROM codes.
  ShowROMCodesOfDevices();
  printf(" \r");


  char buffer[80];
  while (1)
  {
    // Read the temperature.  Blocks the processor for 700us or so.
    //BlockAndReadRawTemperature();

    // Read the temperature.  Non-blocking.
    DS18B20ReadTemperature();

    if (DS18B20Status == TEMPERATURE_AVAILABLE)
    {
      //float celsius = (float)roundf(GetTemperatureCelsius() * 100) / 100;
      float celsius = GetTemperatureCelsius();
      printf("Temp:  %s\r", FormatFloatToString(celsius, buffer, 2));
    }

    Delayms(500);
  }
}
示例#28
0
//初始化命令
void wifi_rst()
{
  
  reset_value();
  printf("AT+RST\r\n");
  //UART1_ReceiverWakeUpCmd(ENABLE);
  do
  {
    Delayms(10);
  Refresh_WWDG_Window();
    ptr1 = strstr(RxBuffer1, rest);  //判断是否存在ready
    if(ptr1!=NULL)
    {
      //printf("find ERROR !!\r\n");
      status=0;
    }
   // Delayms(1000);
  }while(status);
}
示例#29
0
文件: LCD.c 项目: eseawind/MCU
void LCD_Display()        // 显示数据
{
    LCD_W_Cmd(0x01);   //清屏
    Delayms(2);

    LCD_Set(0x01, YEAR1);
    LCD_Set(0x03, YEAR2);
    LCD_W_Data('-');
    LCD_Set(0x06, MONTH);
    LCD_W_Data('-');
    LCD_Set(0x09, DAY);
    LCD_Set_Week(WEEK);

    LCD_Set(0x41, HOUR);
    LCD_W_Data(':');
    LCD_Set(0x44, MINUTE);
    LCD_W_Data(':');
    LCD_Set(0x47, SECOND);
}
示例#30
0
int main(void) {
	//Initialize system */
	SystemInit();
	
	/* Initialize delay */
	TM_DELAY_Init();
	
	/* Initialize onboard leds */
	TM_DISCO_LedInit();

	while (1) {
		/* Toggle leds */
		TM_DISCO_LedToggle(LED_GREEN);
		/* Delay 500ms */
		Delayms(500);
		/* Delay 500 us */
		//Delay(500);
	}
}