Example #1
0
void usbh_ohci_hw_delay_ms (U32 ms) {

  ms <<= 12;
  while (ms--) {
    __nop(); __nop(); __nop();
  }
}
Example #2
0
void FOE_writebuffer(uint8_t data)
{
//    char                 buf[64];

    if(ESCvar.fbufposition < FOE_PAGESIZE)
    {
        ESCvar.fposition++;
        fbuffer[ESCvar.fbufposition++] = data;
    }
    else
    {
        if(!ESCvar.fbufstate)
        {
            m25px0_sector_erase(drv_m25px0_1, ESCvar.fposition - FOE_PAGESIZE);
            while (m25px0_status(drv_m25px0_1) & 0x0001) __nop();
//            terminal_putchar(drv_terminal_1,'+');
//            sprintf(buf,"%i\n\r",ESCvar.fposition);
//            uart8_write(drv_uart8_1,buf,strlen(buf));
        }
        m25px0_program_page(drv_m25px0_1, ESCvar.fposition - FOE_PAGESIZE, &fbuffer[0], FOE_PAGESIZE);
        while (m25px0_status(drv_m25px0_1) & 0x0001) __nop();
//        terminal_putchar(drv_terminal_1,'-');
//        sprintf(buf,"%i\n\r",ESCvar.fbufstate);
//        uart8_write(drv_uart8_1,buf,strlen(buf));

        ESCvar.fbufposition = 0;
//        if(++ESCvar.fbufstate >= PAGESPERBLOCK)
//            ESCvar.fbufstate = 0;
        ESCvar.fbufstate++;
        ESCvar.fposition++;
        fbuffer[ESCvar.fbufposition++] = data;
    }
}
Example #3
0
EF_spiFlashStatus EF_spiFlashPageWrite(u32 address, u8 *buffer,u32 byteLength)
{
	u16 i;
	EF_spiFlashStatus status=SPIFLASH_STATUS_NOERR;
	while( EF_spiFlashIsBusy())	__nop();
	if ((address+byteLength)>MX66_Flash_Size) 	 
		return SPIFLASH_STATUS_WRONGADDR;
	if (((address&0x000000FF)+byteLength)>MX66_Page_Offset) 
		return SPIFLASH_STATUS_PAGEEX;
	// Enable writing
	if (!EF_spiFlashIsWriteEnabled()) 	
		EF_spiFlashWriteEnable();
	__nop();
	SPIFLASH_CS_L;
	//send the Write request and the address in 24 bit
	EF_spiFlashRW(SPIFLASH_CMD_PP4B);
	EF_spiFlashRW(address >> 24);
	EF_spiFlashRW(address >> 16);
	EF_spiFlashRW(address >> 8);
	EF_spiFlashRW(address);
	for(i=0;i<byteLength;i++)
	{
		EF_spiFlashRW(buffer[i]);
	}
	SPIFLASH_CS_H;
	__nop();
	//wait till memory finish
	status=EF_spiFlashWaitForReady(MX66_PageProgramCycleTime*2);
	__nop();
	EF_spiFlashWriteDisable();
	__nop();
	return status;
}
Example #4
0
TextLCD::TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1,
                 PinName d2, PinName d3, LCDType type) : _rs(rs), _rw(rw),
        _e(e), _d(d0, d1, d2, d3), _type(type) {
    _rs = 0;            // command mode
    _rw = 0;
    _e  = 0;            
    _d.output();        // data out

    wait(0.05);        // Wait 50ms to ensure powered up

    // send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus)
    for (int i=0; i<3; i++) {
        _e = 1;
        __nop();
        _d = 0x3;
        __nop();
        _e = 0;
        wait(0.004f); // 4ms
       }
    _e = 1;
    __nop();
    _d = 0x2;           // 4 Bit mode
    __nop(); 
    _e = 0;
    
    writeCommand(0x28); // Function set 4 Bit, 2Line, 5*7
   writeCommand(0x08); // Display off
    writeCommand(0x01); // clear Display
    writeCommand(0x04); // cursor right, Display is not shifted
    writeCommand(0x0C); // Display on , Cursor off 
}
Example #5
0
void DMA1_Stream4_IRQHandler(void)
{
	u16 i;
	u8 tmp;
	if(DMA_GetITStatus(DMA1_Stream4, DMA_IT_TCIF4) == SET)
	{
		TP3_L;
		DMA_ClearITPendingBit(DMA1_Stream4, DMA_IT_TCIF4);
		for(i=0;i<200;i++)
		{
			__nop();
		}
		DMA_Cmd(DMA1_Stream4,DISABLE);
		SPI_I2S_DMACmd(SPIFLASH_SPI,SPI_I2S_DMAReq_Tx,DISABLE);
		tmp=SPI_I2S_ReceiveData(SPIFLASH_SPI);
		SPIFLASH_CS_H;
		DMA_Tx_Busy = 0;
		TP3_H;
	}
	else if(DMA_GetITStatus(DMA1_Stream4,DMA_IT_TEIF4) == SET)
	{
		__nop();
		DMA_ClearITPendingBit(DMA1_Stream4, DMA_IT_TEIF4);
	}
}
Example #6
0
/************************************
** ADS_Read_AD :
** SPI Reading
** Read adc value  
************************************/
uint16_t ADS_Read_AD(uint8_t CMD)	  
{ 	 
	uint8_t i;
	uint8_t count=0; 	  
	uint16_t Num=0; 
	T_DCLK_L;						 
	T_CS_L; 						 
	ADS_Write_Byte(CMD);		
	for(i=200;i>0;i--);
	T_DCLK_H;					
	__nop();__nop();
	__nop();__nop(); 	    
	T_DCLK_L; 	 
	for(count=0;count<16;count++)  
	{ 				  
		Num<<=1; 
		T_DCLK_L;				 
		__nop();__nop();
		__nop();__nop();
		T_DCLK_H;
		__nop();__nop();
		if(T_DIN)Num++; 		 
	}  	
	Num>>=4;   					
	T_CS_H;							 
	return(Num);   
}
Example #7
0
// SPI basic Read/Write function
u8 SPI_RW_Byte(SPI_TypeDef* SPIx,unsigned char Byte)
{
		while( SPI_I2S_GetFlagStatus(SPIx, SPI_I2S_FLAG_TXE) == RESET)   	  __nop();
		SPI_I2S_SendData(SPIx, Byte);
		while (SPI_I2S_GetFlagStatus(SPIx, SPI_I2S_FLAG_RXNE) == RESET)  	  __nop();
		return SPI_I2S_ReceiveData(SPIx);
}
int main( void )
{
  int i,j;    
  int value;
  register int temp;
  double a,b,c,d;
  a = 1.;b=2.;c=3.;
        
  d = __fmadd(a,b,c);
  a = __fmadd(c,b,d);
  d = __fmadd(a,b,c);

  __lwsync();
  __nop();
  __lwsync();
  __nop();
  d = __fctidz(a);
  d = __fctidz(d);
  b = __fctid(a);
  b = __fctid(b);
  c = __fcfid(a);
  c = __fcfid(c);
  __dcbzl(32,&value);
  __dcbzl(&value,0);
        
  return a+b+c+d;
}
void LED_CUBE_Timer (void) {
	int j=0;
	static int cube_show_layer = 0;
	
	LED_CUBE_Layers_Set(0x00);
	
	__nop();
	
	for (j=0; j<8; j++) {
		LED_CUBE_Outputs_Set(~cube[cube_show_layer][j]);
		__nop();
		LED_CUBE_Clock_Set(j, TRUE);
		__nop();
		LED_CUBE_Clock_Set(j, FALSE);
		__nop();
	}

	LED_CUBE_Layer_Set(cube_show_layer, TRUE);
	Delay_us(100);
	LED_CUBE_Layers_Set(0x00);

	__nop();
	
	if (cube_show_layer < 7) {
		cube_show_layer++;
	} else {
		cube_show_layer = 0;
	}
}
Example #10
0
EF_spiFlashStatus EF_spiFlashRead(u32 address, u8 *buffer, u32 byteLength)
{
	u32 i=0;
	while( DMA_Tx_Busy == 1) __nop();
	while( EF_spiFlashIsBusy())	__nop();
	if ((address+byteLength)>MX66_Flash_Size)   
		return   SPIFLASH_STATUS_WRONGADDR;
	SPIFLASH_CS_L;
	//send the Read request and the address in 24 bit + 1 dummy byte
#ifdef FASTREADMODE_ON
	EF_spiFlashRW(SPIFLASH_CMD_FASTREAD4B);
#else
	EF_spiFlashRW(SPIFLASH_CMD_READ4B);
#endif
	EF_spiFlashRW(address >> 24);
	EF_spiFlashRW(address >> 16);
	EF_spiFlashRW(address >> 8);
	EF_spiFlashRW(address);
#ifdef FASTREADMODE_ON
	EF_spiFlashRW(SPIFLASH_CMD_DUMMY);//For FASTREAD mode.
#endif
	for(i=0;i<byteLength;i++)
	{
		buffer[i]=EF_spiFlashRW(SPIFLASH_CMD_DUMMY);
	}
	SPIFLASH_CS_H;
  return SPIFLASH_STATUS_NOERR;
}
Example #11
0
//spi flashrom initialization
void EF_spiFlashInit(void)
{
	u8 flash_init_retry=5;
	EF_spiFlashGpioInit();
	EF_spiFlashSpiInit();
	EF_spiFlashDmaInit();
	EF_spiFlashNvicInit();
	__nop();
	while(EF_spiFlashGetID()!=(u32)MX66_DeviceID && flash_init_retry>0)
	{
		EF_spiFlashSoftReset();
		DelayMs(320);
		flash_init_retry--;
	}
	if(flash_init_retry == 0)
	{
		////////////////////////////
		led_On(LED_Red);
		while(1)
			__nop();
	}
	DelayMs(10);
	EF_spiFlash4BModeOn();
	DelayMs(10);
}
Example #12
0
//spi basic read/write function
u8 EF_spiFlashRW(u8 data)
{
	while( DMA_Tx_Busy == 1) __nop();
	while( SPI_GetFlagStatus(SPIFLASH_SPI,SPI_I2S_FLAG_TXE)==RESET ) 		__nop();
	SPI_SendData(SPIFLASH_SPI,(u16)data);
	while( SPI_GetFlagStatus(SPIFLASH_SPI,SPI_I2S_FLAG_RXNE)==RESET ) 	__nop();
	return (u8)SPI_ReceiveData(SPIFLASH_SPI);
}
Example #13
0
static __INLINE void CardDetectDelay(void)
{
	__nop();
	__nop();
	__nop();
	__nop();
	__nop();
}
Example #14
0
MOZ_NOINLINE 
static void WINAPI
AfterThreadProc (void)
{
    __nop();
    __nop();
    __nop();
    __nop();
}
Example #15
0
File: ccd.c Project: oldjohnh/car
/*************************************************************************
*
*  函数名称:void DelayNs(void)
*  功能说明:CCD延时程序 200ns
*  参数说明:
*  函数返回:无
*  修改时间:
*  备    注:
*************************************************************************/
void DelayNs(void)
{	
	uint8_t i;
	for(i = 0;i < 1;i++)
	{
		__nop();
		__nop();
	}
}
static void pin10_sigal()
{
  nrf_gpio_cfg_output(10);
  nrf_gpio_pin_set(10);
  __nop();
  __nop();
  __nop();
  __nop();
  nrf_gpio_pin_clear(10);
}
Example #17
0
// Load the sounds used in the game
void JukeBox::loadSounds() {
	if (!boarderSoundBuffer.loadFromFile("resources/unclick.wav")) __nop();
	boarderSound.setBuffer(boarderSoundBuffer);

	if (!paddleSoundBuffer.loadFromFile("resources/menu1.wav")) __nop();
	paddleSound.setBuffer(paddleSoundBuffer);

	if (!scoreSoundBuffer.loadFromFile("resources/launch_deny2.wav")) __nop();
	scoreSound.setBuffer(scoreSoundBuffer);
}
Example #18
0
void delay_ns(u32 ns)
{
  u32 i;
  for(i=0;i<ns;i++)
  {
    __nop();
    __nop();
    __nop();
  }
}
Example #19
0
void CCD_gather(void)
{
	uint8_t i;
	
//采集上次曝光的得到的图像
	CCD_CLK(0);
	__nop();
	CCD_SI(1);  //开始SI
	__nop();
	CCD_CLK(1);
	__nop();
	CCD_SI(0);
	__nop();
	
	
	for(i=0;i<128;i++)   //采集1-128个像素点
	{
	  CCD_CLK(0);
	  __nop();
		CCD_original_data[i+2] = ADC_QuickReadValue(ADC0_SE8_PB0);
		CCD_CLK(1);
		__nop();
	}
	
	__nop();   //发送第129个CLK
	CCD_CLK(1);
	__nop();
	CCD_CLK(0);
	__nop();
	
	DelayMs(30);	//曝光时间
}
Example #20
0
static uint8_t mx_data_poll(uint8_t val) {
    // 200us * 5 => 1ms
    uint8_t max_try = 200;
    uint8_t data = 0;
    TRISA = 0xFF;

    while ((max_try--)>0) {
        CSL; 
        __nop();
        data = PORTA;
        CSH;

        if ((val & 0x80) == (data & 0x80)) {
            TRISA = 0x00;
            return 0;
        }
        __nop();
        __nop();
        __nop();
        __nop();
        __nop();
        __nop();
        __nop();
        __nop();
    }

    //error ...
    return 0xFF;
}
Example #21
0
void TextLCD::writeByte(int value) {
    _e = 1;
    __nop();    
    _d = value >> 4;
    __nop();
    _e = 0;
    __nop();
    _e = 1;
    __nop();
    _d = value >> 0;
    __nop();
    _e = 0;
}
Example #22
0
static void USER_FUNC lum_sendStudyWaveData(ORIGIN_WAVE_DATA* pWaveInfo)
{
	static U8 g_sendCount = 0;
	U8 index;
	U16 clkCount;
	BOOL gpioHighLevel;


	//lum_disableAllIrq();
	if(pWaveInfo->firstHighlevel != 0)
	{
		GpioSetRegOneBit(GPIO_C_OUT, 0x04);
		lum_delay15us(300);
	}
	for(index=0; index<pWaveInfo->waveCount; index++)
	{
		gpioHighLevel = ((index%2) == pWaveInfo->firstHighlevel)?TRUE:FALSE;
		for(clkCount = 0; clkCount<pWaveInfo->waveData[index]; clkCount++) //only for clk timing
		{
			if(gpioHighLevel)
			{
				GpioSetRegOneBit(GPIO_C_OUT, 0x04);
			}
			else
			{
				GpioClrRegOneBit(GPIO_C_OUT, 0x04);
			}
			lum_delay15us(1);
			__nop(); // 1
			__nop(); // 2
			__nop(); // 3
			__nop(); // 4
			__nop(); // 5
			__nop(); // 6
			__nop(); // 7
			__nop(); // 8
			__nop(); // 9

		}
	}

	//lum_enableAllIrq();
	hfgpio_fset_out_low(HFGPIO_F_SDO_2);

	g_sendCount++;
	if(g_sendCount < MAX_WAVE_RESEND_COUNT)
	{
		lum_start433StudyTimer(MAX_SEND_WAVE_TIME_DELAY);
	}
	else
	{
		g_sendCount = 0;
		lum_setRfMode(RF_SLEEP);
		g_searchFreqData.chipStatus = SX1208_IDLE;
	}
}
Example #23
0
void Code_0(void)
{
	uint8_t i;
	GPIOB->BSRR = GPIO_Pin_1;
	for(i=0;i<1;i++)
		__nop();
	__nop();
	GPIOB->BRR = GPIO_Pin_1;
	for(i=3;i>0;i--)
	{
		__nop();__nop();
	}
	__nop();
}
Example #24
0
/********************Stop*************************/
void I2CStop(void)
{
    CLK_L ;
  #ifdef tm1651_delay_EN
   tm1651_delay();
	__nop() ;
	__nop() ;
  #endif
	DIO_L ;
  #ifdef tm1651_delay_EN
   tm1651_delay();
	__nop() ;
	__nop() ;
  #endif
	CLK_H ;
  #ifdef tm1651_delay_EN
   tm1651_delay();
	__nop() ;
	__nop() ;
	__nop() ;
  #endif
	DIO_H ;
  #ifdef tm1651_delay_EN
	__nop() ;
   tm1651_delay();
  #endif
	CLK_L ;
	DIO_L ;
}
Example #25
0
/* ------------------------------------------------------------------------- *
 * Block waiting of specified timer
 * ------------------------------------------------------------------------- */
void WaitTim(TIM_Indx indx, uint32_t value)
{
  LoadTim(indx, value);

  while (GetTim(indx) != 0)
    __nop();
}
Example #26
0
/********************Start*************************/
void I2CStart (void)
{
 DIO_H ;
 CLK_H ;
  #ifdef tm1651_delay_EN
__nop() ;
  tm1651_delay();
  #endif
 DIO_H ;

 DIO_L ;
  #ifdef tm1651_delay_EN
 __nop() ;
  #endif
 CLK_L ;
}
Example #27
0
// __asm__ blocks are only checked for inline functions that end up being
// emitted, so call functions with __asm__ blocks to make sure their inline
// assembly parses.
void f() {
  __movsb(0, 0, 0);
  __movsd(0, 0, 0);
  __movsw(0, 0, 0);

  __stosd(0, 0, 0);
  __stosw(0, 0, 0);

#ifdef _M_X64
  __movsq(0, 0, 0);
  __stosq(0, 0, 0);
#endif

  int info[4];
  __cpuid(info, 0);
  __cpuidex(info, 0, 0);
  _xgetbv(0);
  __halt();
  __nop();
  __readmsr(0);

  // FIXME: Call these in 64-bit too once the intrinsics have been fixed to
  // work there, PR19301
#ifndef _M_X64
  __readcr3();
  __writecr3(0);
#endif

#ifdef _M_ARM
  __dmb(_ARM_BARRIER_ISHST);
#endif
}
Example #28
0
int main() {
  int driverPointer = 0;
  // Stop the watchdog
  WDTCTL = WDTPW |  WDTHOLD;
  // enable output for pins connected to LEDs on Launchpad
  // init the peripherals
  initClocks();	
  initTimer();

  P1DIR |= BIT0 | BIT1 | BIT2 | BIT4;
  P1OUT |= BIT0 | BIT1 | BIT2 | BIT4;
  P1REN &= ~(BIT0|BIT1|BIT2|BIT4);

  // enable interrupts
  __bis_status_register(GIE);
  

  while(1) {
    __nop();
    __bis_status_register(CPUOFF);
    if (P1IN & BIT3){
      driverPointer +=1;
      TACCR0 = SIDEREAL_RATE;
    } else {
      driverPointer -= 1;
      TACCR0 = 300;
    }
    driverPointer = driverPointer & ((sizeof DRIVER_TABLE / sizeof *DRIVER_TABLE)-1);
    
    setDriver(DRIVER_TABLE[driverPointer]);
  }
}
Example #29
0
void nop(void){
unsigned int i=0;
	while(i<20){
	__nop();
		i++;
	}
} 
Example #30
0
void SysCLK_config_clock_select(uint32 CLKSRC)
{
	
	uint8 i;
	/*執行以下代碼選擇外部12M晶振作為時鐘源*/
	SYSCON->PDRUNCFG     &= ~(1 << 5);          //系統振蕩器上電   
  SYSCON->SYSOSCCTRL    = 0x00000000;			//振蕩器未被旁路,1~20Mhz頻率輸入
  for (i = 0; i < 200; i++) __nop();		    //等待振蕩器穩定
	SYSCON->SYSPLLCLKSEL  = CLKSRC;         	//PLL時鐘源選擇“系統振蕩器” 01, 
																						//IRC: 00 (default).
  SYSCON->SYSPLLCLKUEN  = 0x01;               //更新PLL選擇時鐘源
  SYSCON->SYSPLLCLKUEN  = 0x00;               //先寫0,再寫1達到更新時鐘源的目的(數據手冊規定)
  SYSCON->SYSPLLCLKUEN  = 0x01;
  
	while (!(SYSCON->SYSPLLCLKUEN & 0x01));     //確定時鐘源更新后向下執行
	
	/*執行以下代碼倍頻為48MHz*/
	SYSCON->SYSPLLCTRL    = 0x00000023;     	//設置M=4;P=2; FCLKOUT=12*4=48Mhz
  SYSCON->PDRUNCFG     &= ~(1 << 7);          //PLL上電
  while (!(SYSCON->SYSPLLSTAT & 0x01));	    //確定PLL鎖定以后向下執行
	/*主時鐘源選擇倍頻以后的時鐘*/
	SYSCON->MAINCLKSEL    = 0x00000003;			//主時鐘源選擇PLL后的時鐘
	SYSCON->MAINCLKUEN    = 0x01;				//更新主時鐘源
	SYSCON->MAINCLKUEN    = 0x00;				//先寫0,再寫1達到更新時鐘源的目的(數據手冊規定)
	SYSCON->MAINCLKUEN    = 0x01;
	
	while (!(SYSCON->MAINCLKUEN & 0x01));	    //確定主時鐘鎖定以后向下執行

	SYSCON->SYSAHBCLKDIV  = 0x01;				//AHB時鐘分頻值為1,使AHB時鐘設置為48Mhz
	SYSCON->SYSAHBCLKCTRL |= (1<<6);            //使能GPIO時鐘(用單片機好像沒有不用GPIO的時候)
}