コード例 #1
0
ファイル: lcd.c プロジェクト: nceruchalu/easypay
/*
 * LcdWaitBF
 * Description: This procedure simply loops until the LCD is not busy.
 *              This clears the RS bit.
 *
 * Argument:    None
 * Return:      None
 *
 * Input:       LCD's Busy Flag
 * Output:      None
 *
 * Operation:   Keep on looping and reading the LCD busy flag. Exit when it 
 *              indicates the LCD is not busy.
 *
 * Revision History:
 *   Dec. 16, 2012      Nnoduka Eruchalu     Initial Revision
 */
void LcdWaitBF(void)
{
  unsigned char busy, status=0x00;
  LCD_DATA_TRIS = 0xFF;        /* when reading a port change it to an input */
  
  CLEAR_RS();                  /* prepare to read BF and Address Counter */
  SET_RW();                    /* and put the LCD in read mode */
  
  do {
    SET_E();                   /* during reads the E has to be active */
    __delay_us(0.5);           /* wait tPW for data to become available */
    
    status = LCD_DATA_PORT;    /* read in value on data lines */
    busy = status & 0x80;      /* busy flag is highest status bit */
    
    __delay_us(0.5);
    
    CLEAR_E();                 /* pull E low for at least tC-tPW */ 
    __delay_us(1);            
  } while(busy);
  
  /* put the LCD in write mode */
  CLEAR_RW();                  /* in write mode when R/W\ is cleared */
  LCD_DATA_TRIS = 0x00;        /* and the I/O pins are set as outputs */
}
コード例 #2
0
void LCDBusyLoop()
{
	//This function waits till lcd is BUSY

	uint8_t busy,status=0x00,temp;

	//Change Port to input type because we are reading data
	LCD_DATA_TRIS|=(0x0f<<LCD_DATA_POS);

	//change LCD mode
	SET_RW();		//Read mode
	CLEAR_RS();		//Read status

	//Let the RW/RS lines stabilize

	__delay_us(0.5);		//tAS


	do
	{

		SET_E();

		//Wait tDA for data to become available
		__delay_us(0.5);

		status=(LCD_DATA_PORT>>LCD_DATA_POS);
		status=status<<4;

		__delay_us(0.5);

		//Pull E low
		CLEAR_E();
		__delay_us(1);	//tEL

		SET_E();
		__delay_us(0.5);

		temp=(LCD_DATA_PORT>>LCD_DATA_POS);
		temp&=0x0F;

		status=status|temp;

		busy=status & 0b10000000;

		__delay_us(0.5);

                CLEAR_E();
		__delay_us(1);	//tEL
	}while(busy);

	CLEAR_RW();		//write mode

        //Change Port to output
	LCD_DATA_TRIS&=(~(0x0F<<LCD_DATA_POS));

}
コード例 #3
0
ファイル: sc2004.c プロジェクト: sosoru/TrainUtilizingSystem
inline void sc2004_ReturnHome(void)
{	
	SET_DDR_DATA_OUT;
	
	SET_RS(0);
	SET_RW(0);
	SET_DATA(1<<DB1);
	
	sc2004_PulseEnable();
}
コード例 #4
0
ファイル: sc2004.c プロジェクト: sosoru/TrainUtilizingSystem
inline void sc2004_ClearDisplay(void)
{
	SET_DDR_DATA_OUT;
	
	SET_RS(0);
	SET_RW(0);
	SET_DATA(1<<DB0);
	
	sc2004_PulseEnable();
}
コード例 #5
0
ファイル: sc2004.c プロジェクト: sosoru/TrainUtilizingSystem
inline uint8_t sc2004_ReadData()
{
	SET_DDR_DATA_IN;
	
	SET_RS(1);
	SET_RW(1);
	
	sc2004_PulseEnable();
	
	return GET_DATA;
}
コード例 #6
0
ファイル: sc2004.c プロジェクト: sosoru/TrainUtilizingSystem
inline void sc2004_WriteData(uint8_t data)
{
	SET_DDR_DATA_OUT;
	
	SET_RS(1);
	SET_RW(0);
	
	SET_DATA(data);
	sc2004_PulseEnable();
	
}
コード例 #7
0
ファイル: lcd.c プロジェクト: cillino25/SENSE
void LCDBusyLoop()
{
    //This function waits till lcd is BUSY

    uint8_t busy,status=0x00,temp;

    //Change Port to input type because we are reading data
    LCD_DATA_DDR&=0xF0;

    //change LCD mode
    SET_RW();		//Read mode
    CLEAR_RS();		//Read status

    //Let the RW/RS lines stabilize

    _delay_us(HALF);		//tAS

    do
    {

        SET_E();

        //Wait tDA for data to become available
        _delay_us(HALF);

        status=LCD_DATA_PIN;
        status=status<<4;

        _delay_us(HALF);

        //Pull E low
        CLEAR_E();
        _delay_us(ONE);	//tEL

        SET_E();
        _delay_us(HALF);

        temp=LCD_DATA_PIN;
        temp&=0x0F;

        status=status|temp;

        busy=status & 0b10000000;

        _delay_us(HALF);
        CLEAR_E();
        _delay_us(ONE);	//tEL
    } while(busy);

    CLEAR_RW();		//write mode
    //Change Port to output
    LCD_DATA_DDR|=0x0F;

}
コード例 #8
0
ファイル: sc2004.c プロジェクト: sosoru/TrainUtilizingSystem
inline void sc2004_SetAddr_DDRAM(uint8_t addr)
{
	SET_DDR_DATA_OUT;
	
	SET_RS(0);
	SET_RW(0);
	SET_DATA( (1 << DB7)
			| (addr & 0b01111111)
			);
			
	sc2004_PulseEnable();
}
コード例 #9
0
ファイル: sc2004.c プロジェクト: sosoru/TrainUtilizingSystem
inline void sc2004_EntryMode(uint8_t increment_direction, uint8_t display_shift)
{	
	SET_DDR_DATA_OUT;
	
	SET_RS(0);
	SET_RW(0);
	SET_DATA( (1<<DB2)
			| (increment_direction<<DB1)
			| (display_shift<<DB0)
			);

	sc2004_PulseEnable();
} 
コード例 #10
0
ファイル: sc2004.c プロジェクト: sosoru/TrainUtilizingSystem
inline void sc2004_CursorDisplayShift(uint8_t shift_display_or_cursor, uint8_t direction_right)
{
	SET_DDR_DATA_OUT;
	
	SET_RS(0);
	SET_RW(0);
	SET_DATA( (1<<DB4)
			| (shift_display_or_cursor<<DB3)
			| (direction_right<<DB2)
			);
	
	sc2004_PulseEnable();
}	
コード例 #11
0
ファイル: sc2004.c プロジェクト: sosoru/TrainUtilizingSystem
inline void sc2004_DisplayMode(uint8_t display, uint8_t cursor, uint8_t cur_blink)
{
	SET_DDR_DATA_OUT;
	
	SET_RS(0);
	SET_RW(0);
	SET_DATA( (1<<DB3)
			| (display<<DB2)
			| (cursor <<DB1)
			| (cur_blink<<DB0)
			);
	
	sc2004_PulseEnable();
}
コード例 #12
0
ファイル: sc2004.c プロジェクト: sosoru/TrainUtilizingSystem
inline void sc2004_FunctionSet(uint8_t length_is_8bit, uint8_t double_line, uint8_t wide_font)
{
	SET_DDR_DATA_OUT;
	
	SET_RS(0);
	SET_RW(0);
	SET_DATA( (1<<DB5)
			| (length_is_8bit<<DB4)
			| (double_line << DB3)
			| (wide_font << DB2)
			);
	
	sc2004_PulseEnable();
}
コード例 #13
0
ファイル: sc2004.c プロジェクト: sosoru/TrainUtilizingSystem
inline uint8_t sc2004_ReadBusyAndAddress(uint8_t * addr)
{
	uint8_t data;
	
	SET_DDR_DATA_IN;
	SET_RS(0);
	SET_RW(1);
	
	sc2004_PulseEnable();
	
	data = GET_DATA;
	if(addr)
		*addr = data & 0b01111111;
		
	return data & (1 << DB7);
};