• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ delay_ms函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中delay_ms函数的典型用法代码示例。如果您正苦于以下问题:C++ delay_ms函数的具体用法?C++ delay_ms怎么用?C++ delay_ms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了delay_ms函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

 int main(void)
 {		
	u16 sta , i=0;
	int t = 200;
	delay_init();	    	 //延时函数初始化	
	LED_Init();
	LED0 = 0;delay_ms(200); LED0 = 1;
	LED1 = 0;delay_ms(200); LED1 = 1;
	LED2 = 0;delay_ms(200); LED2 = 1;
	LED3 = 0;delay_ms(200); LED3 = 1;
	 
	NVIC_Configuration(); 	 //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
	uart_init(9600);	 	//串口初始化为9600
	 
	EXTIX_Init( );
 	NRF24L01_Init();    	//初始化NRF24L01 
	
	NRF24L01_RX_Mode();		
 	while(NRF24L01_Check() == 1)//检查NRF24L01是否在位.	
	{
			LED3=!LED3;				printf("NRF ERROR!!\r\n");

			delay_ms(100 );
	}
	printf("NRF okk!!\r\n");
	sta=NRF24L01_Read_Reg(STATUS);  //读取状态寄存器的值    	 
	NRF24L01_Write_Reg(WRITE_REG_NRF+STATUS,sta); //清除TX_DS或MAX_RT中断标志
	NRF24L01_Write_Reg(FLUSH_RX,0xff);//清除RX FIFO寄存器
	
	
	TIM2_PWM_Init(999,9);  //PWM OUT
	TIM3_Int_Init(0xffff,71);  //做计时器用

	IIC_Init();	 
	InitMPU6050();
	Init_HMC5883();
	suanfa_GetOrigin(); //初始欧拉角 
	

	
	TIM4_Int_Init(49,7199);	  		//PID调速中断 放在最后初始化,防止打断角度校准
	LOCK = 1;
	UN_LOCK = 0;
	
	while(1){
		
		
		if(LOCK)
		{
			
			lock();
			LED0 = 0;delay_ms(500);LED0 = 1;
			Power = 0;
			Target_x = 0;
			Target_y = 0;
				
		}
		
		if(UN_LOCK)
		{
			suanfa();
			printf("%.2lf  %.2lf  %.2lf\r\n",EA.Roll,EA.Pitch,EA.Yaw);	
// 			TIM_Cmd(TIM4, ENABLE);
			Data_Receive_Anl();
		}
		
// 		printf("--p\r\n");
			 
			
					}
}
开发者ID:Eacaen,项目名称:Quadrotor,代码行数:71,代码来源:main.c


示例2: p_dr_RtcInit

u8 p_dr_RtcInit(void)
{
    //检查是不是第一次配置时钟
    u8 temp=0;
    RTC_NVIC_Config();
    //if(BKP->DR1!=0X5050)//第一次配置
    if (BKP_ReadBackupRegister(BKP_DR1) != 0x5050)      //从指定的后备寄存器中读出数据:读出了与写入的指定数据不相乎
    {
        /* Enable PWR and BKP clocks */
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);    //使能PWR和BKP外设时钟

        /* Allow access to BKP Domain */
        PWR_BackupAccessCmd(ENABLE);    //使能RTC和后备寄存器访问

        /* Reset Backup Domain */
        BKP_DeInit();   //将外设BKP的全部寄存器重设为缺省值


        /* Enable LSE */
        RCC_LSEConfig(RCC_LSE_ON);  //设置外部低速晶振(LSE),使用外设低速晶振
        /* Wait till LSE is ready */
        while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) //检查指定的RCC标志位设置与否,等待低速晶振就绪
        {
            temp++;
            delay_ms(10);
        }
        if(temp>=250)return 1;//初始化时钟失败,晶振有问题
        /* Select LSE as RTC Clock Source */
        RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);     //设置RTC时钟(RTCCLK),选择LSE作为RTC时钟
        /* Enable RTC Clock */
        RCC_RTCCLKCmd(ENABLE);  //使能RTC时钟
        /* Wait for RTC registers synchronization */
        RTC_WaitForSynchro();       //等待最近一次对RTC寄存器的写操作完成
        /* Wait until last write operation on RTC registers has finished */
        RTC_WaitForLastTask();  //等待最近一次对RTC寄存器的写操作完成
        /* Enable the RTC Second */
        RTC_ITConfig(RTC_IT_SEC, ENABLE);       //使能RTC秒中断
        /* Wait until last write operation on RTC registers has finished */
        RTC_WaitForLastTask();  //等待最近一次对RTC寄存器的写操作完成
        /* Set RTC prescaler: set RTC period to 1sec */
        /* RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) */
        RTC_SetPrescaler(32767); //设置RTC预分频的值
        /* Wait until last write operation on RTC registers has finished */
        RTC_WaitForLastTask();  //等待最近一次对RTC寄存器的写操作完成
        p_dr_RtcSet(2009,12,2,10,0,55);  //设置时间
        BKP_WriteBackupRegister(BKP_DR1, 0X5050);   //向指定的后备寄存器中写入用户程序数据
    }
    else//系统继续计时
    {
        /* Check if the Power On Reset flag is set */
        if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET)    //检查指定的RCC标志位设置与否:POR/PDR复位
        {
            //printf("\rPower On Reset occurred....");
        }
        /* Check if the Pin Reset flag is set */
        else if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET)   //检查指定的RCC标志位设置与否:管脚复位
        {
            //printf("\rExternal Reset occurred....");
        }

        //printf("\rNo need to configure RTC....");
        /* Wait for RTC registers synchronization */
        RTC_WaitForSynchro();   //等待最近一次对RTC寄存器的写操作完成

        /* Enable the RTC Second */
        RTC_ITConfig(RTC_IT_SEC, ENABLE);   //使能RTC秒中断
        /* Wait until last write operation on RTC registers has finished */
        RTC_WaitForLastTask();  //等待最近一次对RTC寄存器的写操作完成
    }
    p_dr_RtcGet();//更新时间

    /* Clear reset flags */
    RCC_ClearFlag();    //清除RCC的复位标志位

    return 0; //ok
}
开发者ID:Yegz,项目名称:STM32_Project,代码行数:76,代码来源:rtc.c


示例3: main

void main()
{		
			uchar i=0, j=0;
			uint chksum=0;
			uchar buffer[17];
			uchar temp=0;
			init();	
			LED1 = 1;								// Blink LED twice - slave
			delay_ms(500);			
			LED1 = 0;
			delay_ms(500);
			LED1 = 1;								// Blink LED twice - slave
			delay_ms(500);
			LED1 = 0;
			
			WriteCMD(0xCA81);
			WriteCMD(0xCA83);						// Enable FIFO	
		
			while(1)
			{
				while(RFM12_IRQ==0)
				{	
					temp=	ReadFifo();		// read in next Rx byte					
					buffer[i++] = temp;
					if(temp!=0){
						for(t=0;t<4;t++){
							LED1=1;						// turn on led
							delay_ms(25);
							LED1=0;						// turn on led
							delay_ms(25);
							}
					}
					
					if (i==17)							// received data + checksum = 17 bytes
					{
						i=0;
						WriteCMD(0xCA81);				// disable FIFO
	
						
						chksum=0;
						for(j=0 ; j<16 ; j++)			// calc checksum
							chksum+=buffer[j];
						chksum&=0x0FF;
						if(chksum==buffer[16]&&buffer[16]!=0)			// if checksum ok
						{
							for(t=0;t<4;t++){
							LED1=1;						// turn on led
							delay_ms(25);
							LED1=0;						// turn on led
							delay_ms(25);
							}
							
						}
					///	LED1=0;
						WriteCMD(0xCA81);				// disable FIFO
						WriteCMD(0xCA83);				// enable FIFO, re-Sync
					}//if
				}//while

			} //while
}
开发者ID:BGCX261,项目名称:zigbeegarcom-svn-to-git,代码行数:61,代码来源:rx.c


示例4: peSetup

void peSetup(void) {
    // setup peripheral
    // SPI Setup
    // SPI interrupt is not used.
    int i;
    
    IFS2bits.SPI2IF = 0; // Clear the Interrupt Flag
    IEC2bits.SPI2IE = 0; // Disable the Interrupt

    // SPI1CON1 Register Settings
    SPI_CON1bits.MSTEN = 1; // Master mode Enabled
        
    SPI_CON1bits.DISSDO = 0; // SDOx pin is controlled by the module
    SPI_CON1bits.SSEN = 0; // SS1 pin controlled by module
    
    SPI_CON1bits.DISSCK = 0; // Internal Serial Clock is Enabled
    
    // Set up SCK frequency of 625kHz for 40 MIPS
    SPI_CON1bits.SPRE = 0b111; // Secondary prescale    1:1
    SPI_CON1bits.PPRE = 0b00; // Primary prescale       64:1

    SPI_CON1bits.SMP = 0; // Input data is sampled at middle of data output time
    SPI_CON1bits.CKE = 0; // Serial output data changes on idle to active transition
    SPI_CON1bits.CKP = 0; // Idle state for clock is a low level;
                            // active state is a high level
    
    SPI_CON1bits.MODE16 = 0; // Communication is byte-wide (8 bits)
    // SPI2CON2 Register Settings
    SPI_CON2 = 0x0000; // Framed SPI2 support disabled

    // SPI2STAT Register Settings
    SPI_STATbits.SPISIDL = 1; // Discontinue module when device enters idle mode
    SPI_STATbits.SPIROV = 0; // Clear Overflow
    
    SPI_STATbits.SPIEN = 1; // Enable SPI module
    
    CS_DIR = 0;
    FAKE_CS_DIR = 0;
    
    cmdPld = payCreateEmpty(1);
    cmdPld->pld_data[0] = 0;
    cmdPld->pld_data[1] = CMD_PYROELEC_COMMAND;
    
    dataPld = payCreateEmpty(8);
    dataPld->pld_data[0] = 0;
    dataPld->pld_data[1] = CMD_PYROELEC_DATA;
    
    for(i=0; i<4; i++) {
        framePlds[i] = payCreateEmpty(66);
        framePlds[i]->pld_data[0] = 0;
        framePlds[i]->pld_data[1] = CMD_PYROELEC_FRAME;
        framePlds[i]->pld_data[2] = (i&1);
        framePlds[i]->pld_data[3] = 0;
    }
    
    for(i=0;i<N_HIST;i++)
        centerHist[i] = 0;
    
    peResetModule();
    
    peSendCommand('M');
    
    delay_ms(5);
    
    peTransaction(NULL,0,NULL,100);
}
开发者ID:abuchan,项目名称:imageproc-lib,代码行数:66,代码来源:pyroelec_sensor.c


示例5: spi_reset

void spi_reset ()
{
	BYTE spicmd[2] = { FLAG, SPI_RESET };


	switch (PortType) {
		case TY_COMM :
			_outp(COM_MCR, 0);		/* RESET,SCK = "L" */
			delay_ms(10);			/* 10msec */
			_outp(COM_MCR, C_RES);	/* RESET = "H" */
			iodly(); iodly();		/* delay */
			_outp(COM_MCR, 0);		/* RESET = "L" */
			break;

		case TY_VCOM :
			EscapeCommFunction(hComm, CLRDTR);
			EscapeCommFunction(hComm, CLRRTS);
			delay_ms(10);
			EscapeCommFunction(hComm, SETDTR);
			iodly(); iodly();
			EscapeCommFunction(hComm, CLRDTR);
			break;

		case TY_BRIDGE :
			delay_ms(10);
			send_bridge(spicmd, 2);
			break;

		case TY_AVRSP :
			_outp(LPT_DAT, B_ENA);
			delay_ms(10);
			_outp(LPT_DAT, B_ENA|B_RES);
			iodly(); iodly();
			_outp(LPT_DAT, B_ENA);
			break;

		case TY_STK200 :
			_outp(LPT_DAT, 0);
			delay_ms(10);
			_outp(LPT_DAT, BS_RES);
			iodly(); iodly();
			_outp(LPT_DAT, 0);
			break;

		case TY_XILINX :
			_outp(LPT_DAT, BX_DIS2);
			delay_ms(10);
			_outp(LPT_DAT, BX_DIS2|BX_RES);
			iodly(); iodly();
			_outp(LPT_DAT, BX_DIS2);
			break;

		case TY_LATTICE :
			_outp(LPT_DAT, 0);
			delay_ms(10);
			_outp(LPT_DAT, BL_RES);
			iodly(); iodly();
			_outp(LPT_DAT, 0);
			break;

		case TY_ALTERA :
			_outp(LPT_DAT, 0);
			delay_ms(10);
			_outp(LPT_DAT, BA_RES);
			iodly(); iodly();
			_outp(LPT_DAT, 0);
			break;

	}
	RcvrFifo.Rp = 0;					/* Flush FIFO */
	RcvrFifo.Wp = 0;
	RcvrFifo.Ctr = 0;
	delay_ms(30);						/* 30msec */
}
开发者ID:BackupTheBerlios,项目名称:rundfunker,代码行数:74,代码来源:hwctrl.c


示例6: LED_simple_all_colors

void LED_simple_all_colors(){ //simple all colors
	TIM_Cmd(LPC_TIM0,DISABLE);	// To start timer 0
//	while(1){
	for (uint8_t i=0;i<16;i++){
//		xprintf(OK "%d",i+1);FFL_();
		GPIO_ClearValue(LED_LE_PORT, LED_LE_BIT);
		for (uint8_t j=0;j<11;j++){
			SSP_SendData(LED_SPI_CHN, 0x0000);
			while(LED_SPI_CHN->SR & SSP_STAT_BUSY);
		}
//		SSP_SendData(LED_SPI_CHN, 0x0001<<i);
		SSP_SendData(LED_SPI_CHN, 0x1249);
		while(LED_SPI_CHN->SR & SSP_STAT_BUSY);
		for (uint8_t k=0;k<0;k++){
			SSP_SendData(LED_SPI_CHN, 0x0000);
			while(LED_SPI_CHN->SR & SSP_STAT_BUSY);
		}
		GPIO_SetValue(LED_LE_PORT, LED_LE_BIT);
		GPIO_ClearValue(LED_LE_PORT, LED_LE_BIT);
		GPIO_ClearValue(LED_OE_PORT, LED_OE_BIT);//LED's on. active low
		delay_ms(150);
	};
	for (uint8_t i=0;i<16;i++){
//		xprintf(OK "%d",i+1);FFL_();
		GPIO_ClearValue(LED_LE_PORT, LED_LE_BIT);
		for (uint8_t j=0;j<11;j++){
			SSP_SendData(LED_SPI_CHN, 0x0000);
			while(LED_SPI_CHN->SR & SSP_STAT_BUSY);
		}
//		SSP_SendData(LED_SPI_CHN, 0x0001<<i);
		SSP_SendData(LED_SPI_CHN, 0x2492);
		while(LED_SPI_CHN->SR & SSP_STAT_BUSY);
		for (uint8_t k=0;k<0;k++){
			SSP_SendData(LED_SPI_CHN, 0x0000);
			while(LED_SPI_CHN->SR & SSP_STAT_BUSY);
		}
		GPIO_SetValue(LED_LE_PORT, LED_LE_BIT);
		GPIO_ClearValue(LED_LE_PORT, LED_LE_BIT);
		GPIO_ClearValue(LED_OE_PORT, LED_OE_BIT);//LED's on. active low
		delay_ms(150);
	};
	for (uint8_t i=0;i<16;i++){
	xprintf(OK "%d",i+1);FFL_();
	GPIO_ClearValue(LED_LE_PORT, LED_LE_BIT);
	for (uint8_t j=0;j<11;j++){
		SSP_SendData(LED_SPI_CHN, 0x0000);
		while(LED_SPI_CHN->SR & SSP_STAT_BUSY);
	}
//	SSP_SendData(LED_SPI_CHN, 0x0001<<i);
	SSP_SendData(LED_SPI_CHN, 0x4924);
	while(LED_SPI_CHN->SR & SSP_STAT_BUSY);
	for (uint8_t k=0;k<0;k++){
		SSP_SendData(LED_SPI_CHN, 0x0000);
		while(LED_SPI_CHN->SR & SSP_STAT_BUSY);
	}
	GPIO_SetValue(LED_LE_PORT, LED_LE_BIT);
	GPIO_ClearValue(LED_LE_PORT, LED_LE_BIT);
	GPIO_ClearValue(LED_OE_PORT, LED_OE_BIT);//LED's on. active low
	delay_ms(150);
	};
	for (uint8_t i=0;i<16;i++){
//		xprintf(OK "%d",i+1);FFL_();
		GPIO_ClearValue(LED_LE_PORT, LED_LE_BIT);
		for (uint8_t j=0;j<11;j++){
			SSP_SendData(LED_SPI_CHN, 0x0000);
			while(LED_SPI_CHN->SR & SSP_STAT_BUSY);
		}
//		SSP_SendData(LED_SPI_CHN, 0x0001<<i);
		SSP_SendData(LED_SPI_CHN, 0xffff);
		while(LED_SPI_CHN->SR & SSP_STAT_BUSY);
		for (uint8_t k=0;k<0;k++){
			SSP_SendData(LED_SPI_CHN, 0x0000);
			while(LED_SPI_CHN->SR & SSP_STAT_BUSY);
		}
		GPIO_SetValue(LED_LE_PORT, LED_LE_BIT);
		GPIO_ClearValue(LED_LE_PORT, LED_LE_BIT);
		GPIO_ClearValue(LED_OE_PORT, LED_OE_BIT);//LED's on. active low
		delay_ms(150);
	};
//	};
	TIM_Cmd(LPC_TIM0,ENABLE);	// To start timer 0
	LED_PATTERN=0;
}
开发者ID:ggaavv,项目名称:Equinox-Clock,代码行数:83,代码来源:ShiftPWM.c


示例7: motor_test

void motor_test()
{
	static char m1_back = 0, m2_back = 0;
	char m1_char, m2_char;

	if(button_is_pressed(BUTTON_A))
	{
		if(m1_speed == 0)
		{
			delay_ms(200);

			// If the button is pressed quickly when the motor is off,
			// reverse direction.
			if(!button_is_pressed(BUTTON_A))
				m1_back = !m1_back;
		}
		
		m1_speed += 10;
	}
	else
		m1_speed -= 20;

	if(button_is_pressed(BUTTON_C))
	{
		if(m2_speed == 0)
		{
			delay_ms(200);

			// If the button is pressed quickly when the motor is off,
			// reverse direction.
			if(!button_is_pressed(BUTTON_C))
				m2_back = !m2_back;
		}

		m2_speed += 10;
	}
	else
		m2_speed -= 20;

	if(m1_speed < 0)
		m1_speed = 0;

	if(m1_speed > 255)
		m1_speed = 255;

	if(m2_speed < 0)
		m2_speed = 0;

	if(m2_speed > 255)
		m2_speed = 255;

	// 255/26 = 9, so this gives values in the range of 0 to 9
	m1_char = bar_graph_characters[m1_speed / 26];
	m2_char = bar_graph_characters[m2_speed / 26];
	print_character(m1_char);
	print_character(m1_back ? 'a' : 'A');
	print_character(m1_char);
	lcd_goto_xy(5,0);
	print_character(m2_char);
	print_character(m2_back ? 'c' : 'C');
	print_character(m2_char);

	set_motors(m1_speed * (m1_back ? -1 : 1), m2_speed * (m2_back ? -1 : 1));
	delay_ms(50);
}
开发者ID:AndySze,项目名称:libpololu-avr,代码行数:65,代码来源:test.c


示例8: IOTest

// *** triggered by middle button ***
// This function tests the eight user I/O pins and the trimmer potentiometer.
// At any given time, one pin is being driven low while the rest are weakly
// pulled high (to 5 V).  At the same time, the LCD is displaying the input
// values on the eight user I/O pins.  If you short a pin to *GROUND* (note:
// do not short the pin to power, only short it to one of the ground pads
// along the top edge of the board), you will see the corresponding bit on
// the LCD go to zero.  The PD1 bit will always read zero as it is being
// pulled down through the red user LED.
unsigned char IOTest()
{
	// the bits of the "outputs" byte will correspond to the pin states of
	// the user I/O lines as follows:

	// outputs:   b7  b6  b5  b4  b3  b2  b1  b0
	// user I/O: PC5 PC4 PC3 PC2 PC1 PC0 PD1 PD0

	// Only one bit of "outputs" will ever be set (1) at a time; the rest will
	// be cleared (0).  The user I/O pin that corresponds to the set bit will
	// be an output that is driven low while all of the other user I/O pins
	// will be inputs with internal pull-ups enabled (i.e. they will be weakly
	// pulled to 5V and will read as high).
	unsigned int outputs = 0x8000;	// binary: 10000000 00000000
	unsigned char *outputsA = (unsigned char *)&outputs;	// pointer to low byte of outputs
	unsigned char *outputsD = outputsA + 1;					// pointer to high byte of outputs
	unsigned char direction = 0;
	unsigned char button;

	red_led(1);
	green_led(1);

	clear();		// clear the LCD
	print("User I/O");
	lcd_goto_xy(0, 1);
	print("DDDDDDDD AAAAAAAA");
	lcd_goto_xy(0, 2);
	print("76543210 76543210");

	set_analog_mode(MODE_8_BIT);	// configure ADC for 8-bit readings

	while (1)			// loop here until we detect a button press and return
	{
		time_reset();				// reset millisecond timer count to zero

		DDRA = 0;					// make PA0 - PA7 inputs
		PORTA = 0;					// PA0 - PA7 -> high impedance inputs
		DDRD = 0;					// make PD0 - PD7 inputs
		PORTD = 0;					// PD0 - PD7 -> high impedance inputs

		PORTD |= ~(*outputsD);
		DDRD |= *outputsD;
		PORTA |= (~(*outputsA)) & 0x3F;
		DDRA |= *outputsA & 0x3F;	// never make PA6 and PA7 outputs


		// The following loop will execute for an amount of time determined
		// by the position of the user trimmer potentiometer (trimpot).
		// When the trimpot is at one extreme, the loop will take 256*2 = 512
		// milliseconds.  When the trimpot is at the other extreme, the
		// loop will only execute once, which takes slightly more than 20 ms.
		// In this way, the trimpot controls the speed at which the output
		// byte changes.
		do
		{
			// The bits of the "inputs" byte reflect the input values of pins
			// PD0, PD1, and PC0 - PC5.  Bit 0 corresponds to PD0, bit 1 to
			// PD1, and bits 2 - 7 to PC0 - PC5, respectively.
			unsigned char inputsA = PINA;
			unsigned char inputsD = PIND;
			lcd_goto_xy(0, 3);		// go to the start of the fourth LCD line
			print_binary(inputsD);	// print the "input" byte in binary
			print(" ");
			print_binary(inputsA);
			delay_ms(20);			// delay here for 20 milliseconds
			// check if top or bottom buttons have been pressed
			button = button_is_pressed(TOP_BUTTON | BOTTOM_BUTTON);
			if (button != 0)	// if so, reset I/O states, return button ID
			{
				DDRA = 0;					// make PA0 - PA7 inputs
				PORTA = 0;					// PA0 - PA7 -> high impedance inputs
				DDRD = 0;					// make PD0 - PD7 inputs
				PORTD = 0;					// PD0 - PD7 -> high impedance inputs
				return button;
			}
		}
		while (get_ms() < read_trimpot() * 2);

		if (direction)
			outputs <<= 1;		// bit-shift our output byte left by one bit
		else
			outputs >>= 1;		// bit-shift our output byte right by one bit

		if (outputs == 1)		// if we have reached the right edge
			direction = 1;		// switch direction to "left"
		if (outputs == 0x8000)	// if we have reached the left edge
			direction = 0;		// switch direction to "right"
	}
}
开发者ID:AndySze,项目名称:libpololu-avr,代码行数:98,代码来源:test.c


示例9: Pic_Data_Process

void  Pic_Data_Process(void)
{
    u8  tmp[40];
    u8   pic_buf[600];
    u16 i = 0;

    DF_TAKE;
    // 1.    Judge   last  package
    PackageLen = _485_content_wr;
    if(PackageLen < PageSIZE)
        CameraState.last_package = 1;
    else if((CameraState.last_package == 0) && (_485_content[510] == 0xFF) && (_485_content[511] == 0xD9))
    {
        CameraState.last_package = 1;
    }
    //  2.    Block ++
    CameraState.block_counter++;
    //   3.    Check   first   packet
    if(CameraState.create_Flag == 1)  // 如果是第一包则创建文件 hhmmss_x.jpg
    {
        CameraState.create_Flag = 0; // clear
        memset(tmp, 0, sizeof(tmp));
        memset(PictureName, 0, sizeof(PictureName));
        //-----------  创建图片文件处理  -------------
        /*
         每张图片占32个page    其中第1个page 为图片索引,后边127个Page为图片内容
         SST25 开辟个区域做图片缓存
        */
        if(CameraState.Camera_Number == 1)
        {
            pic_current_page = PicStart_offset; //起始page 固定为缓存起始地址
            //擦除一个64K的区域用于图片存储

            Api_DFdirectory_Delete(camera_1);

        }
        else if(CameraState.Camera_Number == 2)
        {
            pic_current_page = PicStart_offset2; //起始page 固定为缓存起始地址
            //擦除一个64K的区域用于图片存储
            Api_DFdirectory_Delete(camera_2);
            ;
        }
        else if(CameraState.Camera_Number == 3)
        {
            pic_current_page = PicStart_offset3; //起始page 固定为缓存起始地址
            //擦除一个64K的区域用于图片存储
            Api_DFdirectory_Delete(camera_3);
        }
        else if(CameraState.Camera_Number == 4)
        {
            pic_current_page = PicStart_offset4; //起始page 固定为缓存起始地址
            //擦除一个64K的区域用于图片存储
            Api_DFdirectory_Delete(camera_4);
        }
        DF_delay_ms(150);
        WatchDog_Feed();
        pic_current_page++;  // 图片内容从 第二个page 开始 第一个Page 存储的是图片索引
        pic_PageIn_offset = 0; // 页内偏移清空
        pic_size = 0; // 清除图片大小
        //------------------------------------------
        memset(PictureName, 0, sizeof(PictureName));
		// sprintf((char*)PictureName,"0:%02d%02d%02d%02d%02d%02d-%d.jpg",time_now.year,time_now.month,time_now.day,time_now.hour,time_now.min,time_now.sec,CameraState.Camera_Number); 	
		sprintf((char*)PictureName,"%02d%02d%02d%02d%02d%02d-%d.jpg",time_now.year,time_now.month,time_now.day,time_now.hour,time_now.min,time_now.sec,CameraState.Camera_Number);	 
        if(GB19056.workstate == 0)
            rt_kprintf("\r\n              创建图片名称: %s \r\n           ", PictureName);
        WatchDog_Feed();


        WatchDog_Feed();
        // -----    写图片索引 -------
        Save_MediaIndex(0, PictureName, CameraState.Camera_Number, 0);
    }

    //  4.   填写存储图片内容数据  --------------------
    WatchDog_Feed();
    DF_WriteFlashDirect(pic_current_page, 0, _485_content, PackageLen); // 写一次一个Page 512Bytes
    delay_ms(150);

#ifdef TFCARD
    if(sd_ok)
        sd_writefile(PictureName, _485_content, PackageLen);
#endif
    //  rt_kprintf(" \r\n ---- pkg=%d  \r\n",CameraState.block_counter);

    //---  read compare
    memset(pic_buf, 0, 600);
    DF_ReadFlash(pic_current_page, 0, pic_buf, PackageLen);
    delay_ms(10);
    for(i = 0; i < PackageLen; i++)
    {
        if(pic_buf[i] != _485_content[i])
        {
            if(GB19056.workstate == 0)
                rt_kprintf(" \r\n write--read Error");
            // rt_kprintf(" \r\n ----read not equal write  where i=%d  Rd[i]=%2X  WR[i]=%2X \r\n",i,pic_buf[i],_485_content[i]);
            DF_WriteFlashDirect(pic_current_page, 0, _485_content, PackageLen); // 再写一次一个Page 512Bytes
            delay_ms(100);
            break;
        }
//.........这里部分代码省略.........
开发者ID:nathanlnw,项目名称:tw705_nx_gsm_v1.0,代码行数:101,代码来源:Device_485.c


示例10: FCLOOPCHIP


//.........这里部分代码省略.........
		pPDB[chip]->Add((CONTAINER_ELEMENT)pFCDBState, (CONTAINER_KEY)id);
	}
	
	// skip self (must be at least 2 ?)
	loop_ids--;
	// read the Port Database for each loop ID
	for (int i = 2; loop_ids; i++, loop_ids--)
	{
		int trys = 200;		// set number of retries for get database
		
		id = AL_PA_ID[map[i]];
			
		if (id == 0xff)
			continue;		// invalid AL_PA, skip this one
		
		TRACE_HEX16(TRACE_L2, "\n\rID = ", id);

retry:
		status = FCP_Get_Port_Data_Base(Id, buffer, id, vp_index);
		
		if (status != MB_STS_GOOD)
		{
			TRACE_HEX(TRACE_L2, "\n\rLM_Scan_Loops: FCP_Get_Port_Data_Base Failed - ", status);
		}
		else
		{
			// check for a valid Port Database
			if ((buffer[0x4e] & 0x30) == 0)
			{
				// zero is not valid
				if (--trys)
				{
					// delay 10ms here
					delay_ms(10);
					
					TRACE_HEX16(TRACE_L3, "\n\rLM_Scan_Loops: FCP_Get_Port_Data_Base Rety = ", trys);
					goto retry;
				}
				else
				{
					// no more trys, Get Port DB is never going to work for this ID
					TRACEF(TRACE_L2, ("\n\rLM_Scan_Loops(%d): FCP_Get_Port_Data_Base, no more retries", FCinstance));
					
					status = MB_STS_INVALID_CMD;
				}
			}
			else
			{
				if (trys != 200)
				{
					TRACEF(TRACE_L2, ("\n\rLM_Scan_Loops(%d): FCP_Get_Port_Data_Base, retries=%d", 
															FCinstance, (200 - trys)));
				}
			}
			
			TRACE_DUMP_HEX(TRACE_L3, "\n\rPort Database:", buffer, 128);
			
			// try to get the record from the list
			if ((pPDB[chip]->Get((CONTAINER_ELEMENT &)pFCDBState, (CONTAINER_KEY)id)) == FALSE)
			{
				// did not exist
				pFCDBState = new(tPCI) LM_FCDB_STATE;
				memset(pFCDBState, 0, sizeof(LM_FCDB_STATE));
				pDb = new(tPCI) FCPortDatabaseRecord;
				pFCDBState->pDBR = pDb;
				//pFCDBState->state = FCDB_STATE_ADD;	// Add new entry
开发者ID:JoeAltmaier,项目名称:Odyssey,代码行数:67,代码来源:LoopScan.cpp


示例11: control

//void control(int wake_Flag, SerialPort* telitPort, SerialPort* debugPort) {
void control(int wake_Flag){
	
	//conditional set init state due to what causes uC to wake up
	
	if(wake_Flag){
		current_state = ST_WAIT_PIN;
	}	
	else{
		//Starting from Keypad Press
		current_state = ST_AVAILABLE;		
		Engage_Lock();
		//init should read timestamp and fill position struct on data from GPS
		
		
		//init should read in SIM card info for BIKE ID , battery level
		present_state.repair_state = BIKE_WORKING;
		present_state.owner_state = BIKE_AVAILABLE;
		present_state.lock_state = BIKE_LOCKED;
		for(int i  = 0 ; i < BIKE_ID_LEN +1 ; i++){
			present_state.bike_id[i] = 0 ;
		}
		for(int i = 0 ; i < ACCOUNT_LEN + 1 ; i++){
			present_state.account[i] = 0 ;
		}
		for(int i = 0; i < PIN_LEN + 1 ; i++){
			present_state.pin[i] = 0;
		}
		
		
		present_state.timestamp = 0;
		present_state.battery_level = 0;
		present_state.positions_count = 2;
		//present_state.positions = *(struct position present_position); todo later
		pin_fail_flag = 0;
		//start sleep timeout
		sleep_timeout_flag = 1;
		sleep_timeout_counter = 0;
		sleep_timeout_ready = 0;
		//set locked state
		lock_flag = 1;
		
		turnOffLEDS();
	}
		
				
	
	//initialize gsm module
	
/*
	Toggle_PWRKEY();
	
	uart0SendByte('A');
	uart0SendByte('T');
	uart0SendByte('\n');
	while(1){
	uartFlag = uartReceiveByte(0 , &rData );
	uart1SendByte(rData);
		if(!uartFlag)
			break;
	}

*/
	//rprintfInit(DebugPrint);
	///rprintf("Starting");

			
	 while (current_state != ST_SLEEP) {
		 int i = 0;
		 evnt = getNextEvent();
		 //<----telitEventHandler();
		//sockethandler should  go here , and set flag
		 for (i = 0; i < TRANS_COUNT; i++) {
			 if ( (current_state == trans[i].st) ) {
				 if ( (evnt == trans[i].ev) ) {
					 next_state = (trans[i].fn)();
					 break;
				 }
			 }
		 }
		  current_state = next_state;
		
		  delay_ms(100);
	 }	
	 
	
	//setup sleep state and tell uC to loop in main

}
开发者ID:nanonite,项目名称:fsm_micro,代码行数:89,代码来源:control.c


示例12: main

//=====================================
void main()
//=====================================
{
	u16 i,j,k=0,g;
	SysTime 				= 0;
	SystemFlag 			= 0x00;
	mode 						= 0x01;//lora mode
	Freq_Sel 				= 0x00;//433M
	Power_Sel 			= 0x00;//
	Lora_Rate_Sel 	= 0x06;//
	BandWide_Sel 		= 0x07;
	Fsk_Rate_Sel 		= 0x00;
	
	_asm("sim");               //Disable interrupts.
	mcu_init();
	ITC_SPR4 = 0xf3;//time2 interrupt priority 2¡¢level13
	ITC_SPR5 = 0x3c;//UART1_RX ¡¢UART_TX interrupt priority 2
	ITC_SPR6 = 0x00;//UART3_RX ¡¢UART_TX interrupt priority 2
	_asm("rim");              //Enable interrupts.
	
	GREEN_LED_L();
	RED_LED_L();
	delay_ms(500);
	GREEN_LED_H();
	RED_LED_H();
	sx1278_Config();
  sx1278_LoRaEntryRx();
	TIM1_CR1 |= 0x01;			//enable time1
	MasterModeFlag=0;
	while(1)
	{
	if(GetOption())	//Slave
		{
		if(SystemFlag&PreviousOptionBit)
			{
			sx1278_LoRaEntryRx();
			SystemFlag&=(!PreviousOptionBit);
			}
		if(sx1278_LoRaRxPacket())
			{
			GREEN_LED_L();
			delay_ms(100);
			GREEN_LED_H();
			RED_LED_L();
			sx1278_LoRaEntryTx();
			sx1278_LoRaTxPacket();
			RED_LED_H();
			sx1278_LoRaEntryRx();
			}		
		}
	else					//Master
		{
		if((SystemFlag&PreviousOptionBit)==0)
			{
			MasterModeFlag=0;
			SystemFlag|=PreviousOptionBit;
			}			
		switch(MasterModeFlag)
			{
			case 0:
				if(time_flag==1)
				{
				time_flag=0;
				RED_LED_L();
				sx1278_LoRaEntryTx();
				sx1278_LoRaTxPacket();
				RED_LED_H();
				MasterModeFlag++;
				}
				break;
			case 1:
				sx1278_LoRaEntryRx();
				for(i=0;i<30;i++)
					{
					delay_ms(100);
					if(sx1278_LoRaRxPacket())
						{
						i=50;
						GREEN_LED_L();
						delay_ms(100);
						GREEN_LED_H();			
						}
					}
				MasterModeFlag++;
				break;
			case 2:
				if(time_flag==1)
					{
					time_flag=0;
					MasterModeFlag=0;
					}
				break;
			}
		}
	}
}
开发者ID:LiosonLiu,项目名称:LoRa,代码行数:97,代码来源:main.c


示例13: twl3025_wait_ibic_access

static void twl3025_wait_ibic_access(void)
{
    /* Wait 6 * 32kHz clock cycles for first IBIC access (187us + 10% = 210us) */
    delay_ms(1);
}
开发者ID:techniker,项目名称:osmocomBB,代码行数:5,代码来源:twl3025.c


示例14: LCD_Init

//初始化lcd
//该初始化函数可以初始化各种ILI93XX液晶,但是其他函数是基于ILI9320的!!!
//在其他型号的驱动芯片上没有测试! 
void LCD_Init(void)
{  
     										 
	GPIO_InitTypeDef GPIO_InitStructure;

 	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOB|RCC_APB2Periph_AFIO, ENABLE); 
	GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE);
	
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10|GPIO_Pin_9|GPIO_Pin_8|GPIO_Pin_7|GPIO_Pin_6;	   //GPIO_Pin_10
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;  //推挽输出
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOC, &GPIO_InitStructure); //GPIOC	
    //GPIO_WriteBit(GPIOC,GPIO_Pin_10|GPIO_Pin_9|GPIO_Pin_8|GPIO_Pin_7|GPIO_Pin_6,Bit_SET);
	GPIO_SetBits(GPIOC,GPIO_Pin_10|GPIO_Pin_9|GPIO_Pin_8|GPIO_Pin_7|GPIO_Pin_6);


	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;	//  
	GPIO_Init(GPIOB, &GPIO_InitStructure); //GPIOB
	//GPIO_WriteBit(GPIOC,GPIO_Pin_All,Bit_SET); 
	GPIO_SetBits(GPIOB,GPIO_Pin_All);
 
	delay_ms(50); // delay 50 ms 
	LCD_WriteReg(0x0000,0x0001);
	delay_ms(50); // delay 50 ms 
	DeviceCode = LCD_ReadReg(0x0000);   
	printf(" LCD ID:%x\n",DeviceCode); //打印LCD ID  
	if(DeviceCode==0x9325||DeviceCode==0x9328)//ILI9325
	{
  		LCD_WriteReg(0x00EC,0x108F);// internal timeing  
		LCD_WriteReg(0x00EF,0x1234);// ADD 
		LCD_WriteReg(0x0001,0x0100);     
        LCD_WriteReg(0x0002,0x0700);//电源开启     

		//LCD_WriteReg(0x00e7,0x0010);      
        //LCD_WriteReg(0x0000,0x0001);//开启内部时钟
        LCD_WriteReg(0x0001,0x0100);     
        LCD_WriteReg(0x0002,0x0700);//电源开启                    
		//LCD_WriteReg(0x0003,(1<<3)|(1<<4) ); 	//65K  RGB
		//DRIVE TABLE(寄存器 03H)
		//BIT3=AM BIT4:5=ID0:1
		//AM ID0 ID1   FUNCATION
		// 0  0   0	   R->L D->U
		// 1  0   0	   D->U	R->L
		// 0  1   0	   L->R D->U
		// 1  1   0    D->U	L->R
		// 0  0   1	   R->L U->D
		// 1  0   1    U->D	R->L
		// 0  1   1    L->R U->D 正常就用这个.
		// 1  1   1	   U->D	L->R
        LCD_WriteReg(0x0003,(1<<12)|(3<<4)|(0<<3) );//65K    
        LCD_WriteReg(0x0004,0x0000);                                   
        LCD_WriteReg(0x0008,0x0207);	           
        LCD_WriteReg(0x0009,0x0000);         
        LCD_WriteReg(0x000a,0x0000);//display setting         
        LCD_WriteReg(0x000c,0x0001);//display setting          
        LCD_WriteReg(0x000d,0x0000);//0f3c          
        LCD_WriteReg(0x000f,0x0000);
		//电源配置
        LCD_WriteReg(0x0010,0x0000);   
        LCD_WriteReg(0x0011,0x0007);
        LCD_WriteReg(0x0012,0x0000);                                                                 
        LCD_WriteReg(0x0013,0x0000);                 
        delay_ms(50); 
        LCD_WriteReg(0x0010,0x1590);   
        LCD_WriteReg(0x0011,0x0227);
        delay_ms(50); 
        LCD_WriteReg(0x0012,0x009c);                  
        delay_ms(50); 
        LCD_WriteReg(0x0013,0x1900);   
        LCD_WriteReg(0x0029,0x0023);
        LCD_WriteReg(0x002b,0x000e);
        delay_ms(50); 
        LCD_WriteReg(0x0020,0x0000);                                                            
        LCD_WriteReg(0x0021,0x013f);           
		delay_ms(50); 
		//伽马校正
        LCD_WriteReg(0x0030,0x0007); 
        LCD_WriteReg(0x0031,0x0707);   
        LCD_WriteReg(0x0032,0x0006);
        LCD_WriteReg(0x0035,0x0704);
        LCD_WriteReg(0x0036,0x1f04); 
        LCD_WriteReg(0x0037,0x0004);
        LCD_WriteReg(0x0038,0x0000);        
        LCD_WriteReg(0x0039,0x0706);     
        LCD_WriteReg(0x003c,0x0701);
        LCD_WriteReg(0x003d,0x000f);
        delay_ms(50); 
        LCD_WriteReg(0x0050,0x0000); //水平GRAM起始位置 
        LCD_WriteReg(0x0051,0x00ef); //水平GRAM终止位置                    
        LCD_WriteReg(0x0052,0x0000); //垂直GRAM起始位置                    
        LCD_WriteReg(0x0053,0x013f); //垂直GRAM终止位置  
        
        LCD_WriteReg(0x0060,0xa700);        
        LCD_WriteReg(0x0061,0x0001); 
        LCD_WriteReg(0x006a,0x0000);
        LCD_WriteReg(0x0080,0x0000);
        LCD_WriteReg(0x0081,0x0000);
//.........这里部分代码省略.........
开发者ID:peterzjin,项目名称:vbox,代码行数:101,代码来源:lcd.c


示例15: test

void test()
{
	unsigned char button;

	clear();

	delay(200);
	print("Orangutan");	// print to the top line of the LCD
	delay_ms(400);		// delay 200 ms
	lcd_goto_xy(0, 1);	// go to the start of the second LCD line
	print(" X2");	// print to the bottom line of the LCD

	red_led(1);
	delay_ms(100);
	green_led(1);
	delay_ms(100);
	red_led2(1);
	delay_ms(100);
	green_led2(1);
	delay_ms(100);
	yellow_led(1);
	delay_ms(100);

	red_led(0);
	delay_ms(100);
	green_led(0);
	delay_ms(100);
	red_led2(0);
	delay_ms(100);
	green_led2(0);
	delay_ms(100);
	yellow_led(0);
	delay_ms(100);

	clear();			// clear the LCD, move cursor to start of top line

	print("  VBAT");

	do
	{
		// Perform 10-bit analog-to-digital conversions on ADC channel 6.
		// Average ten readings and return the result, which will be one
		// third of the battery voltage when the "ADC6 = VBAT/3" solder
		// bridge is in place on the bottom of the Orangutan PCB
		int vbat = read_battery_millivolts_x2();
		lcd_goto_xy(0, 1);	// go to the start of the second LCD line
		print_long(vbat);	// display battery voltage in millivolts
		print(" mV ");		// display the units
		delay_ms(50);		// delay for 50 ms
		button = button_is_pressed(ANY_BUTTON);	// check for button press
	}
	while (button == 0);	// loop if no buttons are being pressed


	red_led(1);
	green_led(1);
	red_led2(1);
	green_led2(1);
	yellow_led(1);


	// *** MAIN LOOP ***

	while (1)	// loop forever
	{
		if (button & TOP_BUTTON)			// if the top button is pressed
			button = melodyTest();	// this func. loops until next button press

		else if (button & MIDDLE_BUTTON)	// if the middle button is pressed
			button = IOTest();		// this func. loops until next button press

		else if (button & BOTTOM_BUTTON)	// if the bottom button is pressed
			button = motorTest();	// this func. loops until next button press
	}
}
开发者ID:AndySze,项目名称:libpololu-avr,代码行数:75,代码来源:test.c


示例16: open_ifport

int open_ifport (PORTPROP *pc)
{
	OSVERSIONINFO vinfo = { sizeof(OSVERSIONINFO) };
	LARGE_INTEGER val1;
	BYTE cmdspi[6];
	static const WORD PortsCom[] = { COM1ADR, COM2ADR, COM3ADR, COM4ADR };
	static const WORD PortsLpt[] = { LPT1ADR, LPT2ADR, LPT3ADR };
	char sComm[16];
	DCB dcb = { sizeof(DCB),
				9600, TRUE, FALSE, TRUE, FALSE,
				DTR_CONTROL_DISABLE, FALSE,
				TRUE, FALSE, FALSE, FALSE, FALSE,
				RTS_CONTROL_DISABLE, FALSE, 0, 0,
				10, 10,
				8, NOPARITY, ONESTOPBIT, '\x11', '\x13', '\xFF', '\xFF', 0 };
	COMMTIMEOUTS commtimeouts = { 0, 1, 100, 1, 300};


	/* Check if high resolution timer is supported */
	QueryPerformanceFrequency(&val1);
	if (val1.QuadPart == 0) {
		pc->Info1 = "Incompatible envilonment.\n";
		return 1;
	}

	PortDly = pc->Delay;		/* I/O delay for direct I/O control */
	dcb.BaudRate = pc->Baud;	/* Bit rate for SPI bridge */

	/* Open direct I/O driver if needed */
	if(GetVersionEx(&vinfo) == FALSE) {
		pc->Info1 = "Incompatible envilonment.\n";
		return 1;
	}
	if((vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
	    && ((pc->PortClass == TY_COMM)||(pc->PortClass == TY_LPT))) {
		if(init_driver()) {
			pc->Info1 = "I/O driver initialization failed.\n";
			return 1;
		}
	}

	/* Use COM port in direct I/O */
	if(pc->PortClass == TY_COMM) {
		if((pc->PortNum < 1)||(pc->PortNum > 4)) {
			pc->Info1 = "Invalid Port#.\n";
			return 1;
		}
		PortBase = PortsCom[pc->PortNum - 1];
		sprintf(str_info, "No COM%u(0x%X) port.\n", pc->PortNum, PortBase);
		pc->Info1 = str_info;
		if(check_comport()) {
			if(vinfo.dwPlatformId != VER_PLATFORM_WIN32_NT) return 1;
			sprintf(sComm, "\\\\.\\COM%u", pc->PortNum);
			hComm = CreateFile(sComm, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
			if(hComm == INVALID_HANDLE_VALUE) return 1;
			if(check_comport()) return 1;
		}

		_outp(COM_IMR, 0x00);		/* Mask interrupts */
		pc->Info1 = NULL;
		PortType = TY_COMM;
		return 0;
	}

	/* Use COM port via API */
	if(pc->PortClass == TY_VCOM) {
		sprintf(sComm, "\\\\.\\COM%u", pc->PortNum);
		hComm = CreateFile(sComm, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
		if(hComm == INVALID_HANDLE_VALUE) {
			sprintf(str_info, "%s could not be opened.\n", sComm);
			pc->Info1 = str_info;
			return 1;
		}
		SetCommState(hComm, &dcb);
		EscapeCommFunction(hComm, CLRRTS);
		EscapeCommFunction(hComm, CLRDTR);
		PortType = TY_VCOM;
		return 0;
	}

	/* Use SPI bridge attached on COM port */
	if(pc->PortClass == TY_BRIDGE) {
		sprintf(sComm, "\\\\.\\COM%u", pc->PortNum);
		hComm = CreateFile(sComm, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
		if(hComm == INVALID_HANDLE_VALUE) {
			sprintf(str_info, "%s could not be opened.\n", sComm);
			pc->Info1 = str_info;
			return 1;
		}
		dcb.fOutxCtsFlow = TRUE;
		dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
		SetCommState(hComm, &dcb);
		SetCommTimeouts(hComm, &commtimeouts);
		EscapeCommFunction(hComm, CLRDTR);
		delay_ms(10);
		while(read_bridge(cmdspi, sizeof(cmdspi)));
		cmdspi[0] = FLAG-1;
		cmdspi[1] = FLAG; cmdspi[2] = SPI_ENABLE;	/* Enable Bridge */
		cmdspi[3] = FLAG; cmdspi[4] = SPI_SETDLY; cmdspi[5] = (BYTE)PortDly; /* Set SPI delay */
		send_bridge(cmdspi, 6);		/* Send bridge initialization commands */
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:rundfunker,代码行数:101,代码来源:hwctrl.c


示例17: Delay

void Delay(int ms)
{
 	 int i=0;
	for(i=0;i<ms;i++)
	  delay_ms(1);
}
开发者ID:blueskycoco,项目名称:d4,代码行数:6,代码来源:main.c


示例18: enter_power_down

//#define POWER_OFF_EE
void enter_power_down()
{
	int i;
	unsigned v1,v2,v;
	unsigned rtc_ctrl;
	unsigned power_key,key;
	//*******************************************
	//*  power down flow  
	//*******************************************
	f_serial_puts("\n");
	
	wait_uart_empty();

	// disable jtag
	setbits_le32(P_AO_RTI_PIN_MUX_REG, 1<<13);
	clrbits_le32(P_AO_RTI_PIN_MUX_REG, 1<<14);
	
	// turn off mali clock
	clrbits_le32(P_HHI_MALI_CLK_CNTL, 1 << 8);
	// change RTC filter for 32k
    rtc_ctrl = readl(0xC810074c);
//	writel(0x00800000,0xC810074c);
    writel(0x0,0xC810074c);

	writel(readl(0xC8100024)|((1<<2)|(1<<3)|(1<<6)),0xC8100024);
	// disable all memory accesses.
    disable_mmc_req();
   
    //save registers for clk and ddr
    store_restore_plls(1);
    
    //mmc enter sleep
    mmc_sleep();
    delay_ms(20);
    
    // save ddr power
    APB_Wr(MMC_PHY_CTRL, APB_Rd(MMC_PHY_CTRL)|(1<<0)|(1<<8)|(1<<13));
    APB_Wr(PCTL_PHYCR_ADDR, APB_Rd(PCTL_PHYCR_ADDR)|(1<<6));
    APB_Wr(PCTL_DLLCR9_ADDR, APB_Rd(PCTL_DLLCR9_ADDR)|(1<<31));
 	  delay_ms(20);

 	// power down DDR
 	writel(readl(P_HHI_DDR_PLL_CNTL)|(1<<15),P_HHI_DDR_PLL_CNTL);

	// enable retention
	enable_retention();

 	// reset A9
//	setbits_le32(P_A9_CFG2, 7<<16);
	clrbits_le32(P_HHI_SYS_CPU_CLK_CNTL, 1<<4); // disable APB_CLK
	clrbits_le32(P_HHI_SYS_CPU_CLK_CNTL, 1<<5); // disable AT_CLK
	setbits_le32(P_HHI_SYS_CPU_CLK_CNTL,1<<19);
	udelay(10);
	 
	// enable iso ee for A9
	writel(readl(P_AO_RTI_PWR_CNTL_REG0)&(~(1<<4)),P_AO_RTI_PWR_CNTL 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ delay_us函数代码示例发布时间:2022-05-30
下一篇:
C++ delay_init函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap