void LCD_init(void)
{
  
  LCDGPIO_init();//所需io初始化
  LCD_RST_L;     // 产生一个让LCD复位的低电平脉冲
  delay_1us();
  //  DELAY_MS(1) ;
  LCD_RST_H;
  
  LCD_CE_L;     // 关闭LCD
  delay_1us();
  //  DELAY_MS(1) ;
  LCD_CE_H;     // 使能LCD
  delay_1us();
  //  DELAY_MS(1) ;
  
  LCD_write_byte(0x21, 0);	// 使用扩展命令设置LCD模式
  LCD_write_byte(0xc8, 0);	// 设置液晶偏置电压
  LCD_write_byte(0x06, 0);	// 温度校正
  LCD_write_byte(0x13, 0);	// 1:48
  LCD_write_byte(0x20, 0);	// 使用基本命令,V=0,水平寻址
  LCD_clear();	           // 清屏
  LCD_write_byte(0x0c, 0);	// 设定显示模式,正常显示
  
  LCD_CE_L;      // 关闭LCD
}
예제 #2
0
파일: sld.c 프로젝트: jpalider/sld
static void sld_hw_e(void)
{
	gpio_set_value(PIN_E, 1);
	delay_1us();
	gpio_set_value(PIN_E, 0);
	delay_1us();
}
예제 #3
0
void LCD_init(void)
{
    GPIO_WriteBit(GPIOC,GPIO_Pin_7,Bit_SET);//LCD_RST = 0;
    // 产生一个让LCD复位的低电平脉冲
    GPIO_WriteBit(GPIO_LCD_RST_PORT,GPIO_LCD_RST,Bit_RESET);//LCD_RST = 0;
    delay_1us();

    GPIO_WriteBit(GPIO_LCD_RST_PORT,GPIO_LCD_RST,Bit_SET);//LCD_RST = 1;

    // 关闭LCD
    GPIO_WriteBit(GPIO_LCD_CE_PORT,GPIO_LCD_CE,Bit_RESET);//LCD_CE = 0;
    delay_1us();
    // 使能LCD
    GPIO_WriteBit(GPIO_LCD_CE_PORT,GPIO_LCD_CE,Bit_SET);//LCD_CE = 1;
    delay_1us();

    LCD_write_byte(0x21, 0);	// 使用扩展命令设置LCD模式
    LCD_write_byte(0xc8, 0);	// 设置偏置电压
    LCD_write_byte(0x06, 0);	// 温度校正
    LCD_write_byte(0x13, 0);	// 1:48
    LCD_write_byte(0x20, 0);	// 使用基本命令
    LCD_clear();	        // 清屏
    LCD_write_byte(0x0c, 0);	// 设定显示模式,正常显示

    // 关闭LCD
    GPIO_WriteBit(GPIO_LCD_CE_PORT,GPIO_LCD_CE,Bit_RESET);//LCD_CE = 0;
}
예제 #4
0
파일: sld.c 프로젝트: jpalider/sld
static unsigned char sld_hw_dbus_read()
{
	int i;
	unsigned char val;
	unsigned char out = 0;

	for (i = 0; i < 8; i++) {
		gpio_direction_input(dbus_to_pin[i]);
	}
	
	delay_1us();
	gpio_set_value(PIN_E, 1);
	delay_1us();

	for (i = 0; i < 8; i++) {
		val = gpio_get_value(dbus_to_pin[i]) ? 1 : 0;
		out |= val << i;
		gpio_direction_output(dbus_to_pin[i], 0);
	}

	gpio_set_value(PIN_E, 0);
	delay_1us();

	return out;
}
예제 #5
0
void LCD_write_byte(BYTE RS, BYTE ch) {
	/* Wait for any instruction being performed on LCD */
	while ((LCD_get_BF() & 0x80) == 1) ;

	/* Wait done... continuing ... */
	lcd_DB4_tris = 0;
	lcd_DB5_tris = 0;
	lcd_DB6_tris = 0;
	lcd_DB7_tris = 0;

	lcd_RS_tris = 0;
	lcd_RW_tris = 0;
	lcd_E_tris = 0;

	lcd_RW = 0;
	lcd_RS = RS;

	lcd_DB7_out = ((ch & 0x80) == 0x80);
	lcd_DB6_out = ((ch & 0x40) == 0x40);
	lcd_DB5_out = ((ch & 0x20) == 0x20);
	lcd_DB4_out = ((ch & 0x10) == 0x10);

	delay_1us();
	delay_1us();

	lcd_E = 1;

	delay_1us();
	delay_1us();

	lcd_E = 0;

	delay_1us();
	delay_1us();

	lcd_DB7_out = ((ch & 0x08) == 0x08);
	lcd_DB6_out = ((ch & 0x04) == 0x04);
	lcd_DB5_out = ((ch & 0x02) == 0x02);
	lcd_DB4_out = ((ch & 0x01) == 0x01);

	delay_1us();
	delay_1us();

	lcd_E = 1;

	delay_1us();
	delay_1us();

	lcd_E = 0;

	delay_10us(5);
}
예제 #6
0
파일: sld.c 프로젝트: jpalider/sld
static int sld_hw_write_diff(unsigned char *buffer, size_t count,
			     unsigned char *buffer_diff)
{
	int i;
	int jump = 0;
	int k = 40;
	for (i = 0; i < count; i++) {
		printk("%c\t", buffer[i]);

		if ( i == CHARS_PER_LINE) {
			/* works for 2 lines only: TODO */
			printk("switch to line 1\n");
			sld_hw_line(LINE_1);
		}
		
		/* if (!(buffer[i]-buffer_diff[i])) { */
		/* 	jump++; */
		/* 	printk(KERN_ERR "jumping"); */
		/* 	continue; */
		/* } */
		/* sld_hw_set_addr(i+jump); */
		/* printk(KERN_ERR "jumped: %d\n", jump); */
		/* jump = 0; */
		sld_hw_dbus_write(buffer[i], RS_DATA);
		k = 50;
		while(k--) {
			/* if ( sld_hw_busy() ) */
			/* 	delay_1us(); */
			/* else */
			/* 	break; */
			delay_1us();
		}
	}
	return 0;
}
예제 #7
0
파일: time.c 프로젝트: zuzy/lumlink_STM8
void delay_us(unsigned int i)
{
    while(i--)
    {
      delay_1us();
    }
}
예제 #8
0
void LCD_init(void)
  {
            // 产生一个让LCD复位的低电平脉冲
   LCD_pin_config();
   LCD_RST = 0;
   // delay_1us();    

   LCD_RST = 1;
    
		// 关闭LCD
   LCD_CE = 0;
  //  delay_1us();
		// 使能LCD
   LCD_CE = 1;
    delay_1us();

    LCD_write_byte(0x21, 0);	// 使用扩展命令设置LCD模式
    LCD_write_byte(0xc0, 0);	// 设置偏置电压   供电电压高时该值调小
    LCD_write_byte(0x07, 0);	// 温度校正
    LCD_write_byte(0x13, 0);	// 1:48
    LCD_write_byte(0x20, 0);	// 使用基本命令
    LCD_clear();	        // 清屏
    LCD_write_byte(0x0c, 0);	// 设定显示模式,正常显示
        
           // 关闭LCD
   LCD_CE = 0;
  }
예제 #9
0
파일: time.c 프로젝트: zuzy/lumlink_STM8
void delay_ms(u32 nTime)
{
  u16 i;
  while(nTime--)  
  for(i=900;i>0;i--)
  delay_1us();
}
예제 #10
0
void SPIx_WriteByte(uint8 dat)
{
    uint8 i;
    for(i=0; i<8; i++)
    {
        if(dat & 0x80)
            MOSI_SET;
        else
            MOSI_CLEAR;
        delay_1us();
        SCK_SET;
        delay_1us();
        SCK_CLEAR;
        dat=dat<<1;
        delay_1us();
    }
}
예제 #11
0
void SPIx_WriteWord(uint16 wrd)
{
    uint8 i;
	  MOSI_CLEAR;
    for(i=0; i<16; i++)
    {
        if(wrd & 0x8000)
            MOSI_SET;
        else
            MOSI_CLEAR;
        delay_1us();
        SCK_SET;
        delay_1us();
        SCK_CLEAR;
        wrd=wrd<<1;
        delay_1us();
    }
}
예제 #12
0
파일: sld.c 프로젝트: jpalider/sld
static void sld_hw_dbus_write(unsigned char c, unsigned int reg)
{
	gpio_set_value(PIN_RW, RW_WRITE);
	gpio_set_value(PIN_RS, reg);
	delay_1us();
	sld_hw_dbus_set(c);
	sld_hw_e();

}
예제 #13
0
void StepperMotor::step() {
	// do nothing if motor is stopped
	if (m_direction == STOP) {
		return;
	}
	digitalWrite(m_stepPin, HIGH);
	delay_1us();
	digitalWrite(m_stepPin, LOW);
	m_logger.log("step()");
}
예제 #14
0
BYTE LCD_get_BF(void) {
	BYTE low,high;
	
	lcd_DB4_tris = 1;
	lcd_DB5_tris = 1;
	lcd_DB6_tris = 1;
	lcd_DB7_tris = 1;

	lcd_RS = 0;
	lcd_RW = 1;

	delay_1us();

	lcd_E = 1;

	delay_1us();
	delay_1us();
	
	high = ((lcd_DB7_in << 3) | (lcd_DB6_in << 2) |
			(lcd_DB5_in << 1) | lcd_DB4_in);

	lcd_E = 0;
	
	delay_1us();
	delay_1us();

	lcd_E = 1;

	delay_1us();
	delay_1us();

	low = ((lcd_DB7_in << 3) | (lcd_DB6_in << 2) |
			(lcd_DB5_in << 1) | lcd_DB4_in);

	lcd_E = 0;

	delay_1us();
	delay_1us();

	lcd_DB4_tris = 0;
	lcd_DB5_tris = 0;
	lcd_DB6_tris = 0;
	lcd_DB7_tris = 0;

	delay_10us(5);

	return ((high << 4) | low);
}
예제 #15
0
uint8 SPIx_ReadByte(void)
{
	uint8 i,tmp=0;
	MOSI_IN();
	for(i=0; i<8; i++)
	{
        if(MOSI_DATA)
            tmp = 0x01|(tmp << 1);
        else
            tmp = tmp << 1;
				delay_1us();
        SCK_SET;
        delay_1us();
        SCK_CLEAR;
        //tmp = tmp << 1;
        delay_1us();
     }
	MOSI_OUT();
	return tmp;
}
예제 #16
0
void DHT_Start(){
    DHT11_SIGNAL_CONFIG = 0; // PORT RA1 as OUTPUT from MCU
    DHT11_SIGNAL = 1;
    delay_10us(5);
    DHT11_SIGNAL = 0;
    delay_1ms(30);
    DHT11_SIGNAL = 1;
    delay_10us(3);
    DHT11_SIGNAL = 0;
    delay_1us(1);
    DHT11_SIGNAL_CONFIG = 1;  // PORT RA1 as INPUT to MCU
}
예제 #17
0
void LCD_4write(BYTE RS, BYTE RW, BYTE DB7, BYTE DB6, BYTE DB5, BYTE DB4) {
	lcd_DB4_tris = 0;
	lcd_DB5_tris = 0;
	lcd_DB6_tris = 0;
	lcd_DB7_tris = 0;

	lcd_RS_tris = 0;
	lcd_RW_tris = 0;
	lcd_E_tris = 0;

	lcd_RW = RW;
	lcd_RS = RS;

	lcd_DB7_out = DB7;
	lcd_DB6_out = DB6;
	lcd_DB5_out = DB5;
	lcd_DB4_out = DB4;

	delay_1us();
	delay_1us();

	lcd_E = 1;
	delay_1us();
	delay_1us();
	lcd_E = 0;

	delay_1us();
	delay_1us();
}
예제 #18
0
uint16 SPIx_ReadWord(void)
{
	uint8  i;
	uint16 tmp=0;
	MOSI_CLEAR;
	MOSI_IN();	
	for(i=0; i<16; i++)
	{
            if(MOSI_DATA)
                tmp = 0x01|(tmp << 1);
            else
                tmp = tmp << 1;
            delay_1us();
            SCK_SET;
            delay_1us();
            SCK_CLEAR;
              //tmp = tmp << 1;
            delay_1us();
     }
	MOSI_OUT();
     return tmp;
}
예제 #19
0
uint8_t spi_recv(const struct spi *spi)
{
	/*
	 * The AT86RF231 requires a delay of 250 ns between the LSB of the
	 * preceding byte and the MSB of a byte being received. We use 1 us
	 * here because that's the delay a port read produces.
	 */

	delay_1us(spi);

	SPI_I2S_SendData(spi->dev, 0);
	while (SPI_I2S_GetFlagStatus(spi->dev, SPI_I2S_FLAG_RXNE) == RESET);
	return SPI_I2S_ReceiveData(spi->dev);
}
예제 #20
0
void LCD_8write(BYTE RS, BYTE RW, BYTE DB7, BYTE DB6, BYTE DB5, BYTE DB4,
                BYTE DB3, BYTE DB2, BYTE DB1, BYTE DB0) {
	lcd_DB4_tris = 0;
	lcd_DB5_tris = 0;
	lcd_DB6_tris = 0;
	lcd_DB7_tris = 0;

	lcd_RS_tris = 0;
	lcd_RW_tris = 0;
	lcd_E_tris = 0;

	lcd_RW = RW;
	lcd_RS = RS;

	lcd_DB7_out = DB7;
	lcd_DB6_out = DB6;
	lcd_DB5_out = DB5;
	lcd_DB4_out = DB4;

	delay_1us();
	delay_1us();

	lcd_E = 1;

	delay_1us();
	delay_1us();

	lcd_E = 0;

	delay_1us();
	delay_1us();

	lcd_DB7_out = DB3;
	lcd_DB6_out = DB2;
	lcd_DB5_out = DB1;
	lcd_DB4_out = DB0;

	delay_1us();
	delay_1us();

	lcd_E = 1;

	delay_1us();
	delay_1us();

	lcd_E = 0;

	delay_1us();
	delay_1us();
}
예제 #21
0
파일: lcd_driver.cpp 프로젝트: 4408/opentx
void delay_1_5us(uint16_t ms)
{
  for (uint16_t i=0; i<ms; i++) delay_1us();
}
예제 #22
0
void delay_us(uint32_t us)
{
	while (us--)
		delay_1us();
}