Exemplo n.º 1
0
Arquivo: LCD.c Projeto: TheCbac/OV5620
/*******************************************************************************
*  Function Name: LCD_WrDatNib
********************************************************************************
*
* Summary:
*  Writes a data nibble to the LCD module.
*
* Parameters:
*  nibble:  byte containing nibble in least significant nibble to be written
*           to LCD module.
*
* Return:
*  None.
*
*******************************************************************************/
static void LCD_WrDatNib(uint8 nibble) 
{
    LCD_IsReady();

    /* RS shoul be low to select data register */
    LCD_PORT_DR_REG |= LCD_RS;
    /* Reset RW for write operation */
    LCD_PORT_DR_REG &= ((uint8)(~LCD_RW));

    /* Two following lines of code will provide us with 40ns delay */
    /* Clear data pins */
    LCD_PORT_DR_REG &= ((uint8)(~LCD_DATA_MASK));

    /* Write in data, bring E high*/
    #if(0u != LCD_PORT_SHIFT) /* MISRA forbids shift by 0 so need to handle that */
        LCD_PORT_DR_REG |= 
            (LCD_E | ((uint8)(((uint8) nibble) << LCD_PORT_SHIFT)));
    #else
        LCD_PORT_DR_REG |= (LCD_E | nibble);
    #endif /* (0u != LCD_PORT_SHIFT) */

    /* Minimum of 230 ns delay */
    CyDelayUs(1u);

    LCD_PORT_DR_REG &= ((uint8)(~LCD_E));
}
Exemplo n.º 2
0
/*******************************************************************************
* Function Name: LCD_LoadCustomFonts
********************************************************************************
*
* Summary:
*  Loads 8 custom font characters into the LCD Module for use.  Cannot use
*  characters from two different font sets at once, but font sets can be
*  switched out during runtime.
*
* Parameters:
*  customData:  pointer to a constant array of 64 bytes representing 8 custom
*               font characters.
* Return:
*  None.
*
* Theory:
*  Prior to using this function user need to import the pointer to custom
*  font array to your project by writting the following in the source code file
*  where custom font will be used:
*       extern uint8 const CYCODE LCD_Char_customFonts[];
*  This function is not automatically called by the Start() routine and must be
*  called manually by the user.
*
*******************************************************************************/
void LCD_LoadCustomFonts(uint8 const customData[]) 
{
    uint8 indexU8;

    LCD_IsReady();

    /* Set starting address in the LCD Module.
    * Optionally: Read the current address to restore at a later time.
    */
    LCD_WriteControl(LCD_CGRAM_0);

    /* Load in the 64 bytes of CustomChar Data */
    for(indexU8 = 0u; indexU8 < LCD_CUSTOM_CHAR_SET_LEN; indexU8++)
    {
        LCD_WriteData(customData[indexU8]);
    }

    LCD_IsReady();
    LCD_WriteControl(LCD_DDRAM_0);
}
Exemplo n.º 3
0
Arquivo: LCD.c Projeto: TheCbac/OV5620
/*******************************************************************************
*  Function Name: LCD_WriteData
********************************************************************************
*
* Summary:
*  Writes a data byte to the LCD module's Data Display RAM.
*
* Parameters:
*  dByte:  byte to be written to LCD module.
*
* Return:
*  None.
*
*******************************************************************************/
void LCD_WriteData(uint8 dByte) 
{
    uint8 nibble;

    LCD_IsReady();
    nibble = dByte >> LCD_NIBBLE_SHIFT;

    /* Write high nibble */
    LCD_WrDatNib(nibble);

    nibble = dByte & LCD_NIBBLE_MASK;
    /* Write low nibble */
    LCD_WrDatNib(nibble);
}
Exemplo n.º 4
0
Arquivo: LCD.c Projeto: TheCbac/OV5620
/*******************************************************************************
*  Function Name: LCD_WriteControl
********************************************************************************
*
* Summary:
*  Writes a command byte to the LCD module.
*
* Parameters:
*  cByte:   byte to be written to LCD module.
*
* Return:
*  None.
*
*******************************************************************************/
void LCD_WriteControl(uint8 cByte) 
{
    uint8 nibble;

    LCD_IsReady();

    nibble = cByte >> LCD_NIBBLE_SHIFT;
    
    /* WrCntrlNib(High Nibble) */
    LCD_WrCntrlNib(nibble);
    nibble = cByte & LCD_NIBBLE_MASK;

    /* WrCntrlNib(Low Nibble) */
    LCD_WrCntrlNib(nibble);
}
Exemplo n.º 5
0
/*******************************************************************************
*  Function Name: LCD_WrDatNib
********************************************************************************
*
* Summary:
*  Writes a data nibble to the LCD module.
*
* Parameters:
*  nibble:  byte containing nibble in least significant nibble to be written
*           to LCD module.
*
* Return:
*  None.
*
*******************************************************************************/
void LCD_WrDatNib(uint8 nibble) 
{
    LCD_IsReady();
	
	/* RS shoul be low to select data register */
    LCD_PORT_DR_REG |= LCD_RS;
    /* Reset RW for write operation */
    LCD_PORT_DR_REG &= ~LCD_RW;
    
	/* Two following lines of code will provide us with 40ns delay */
    /* Clear data pins */
    LCD_PORT_DR_REG &= ~LCD_DATA_MASK;	        
    
    /* Write in data, bring E high*/
    LCD_PORT_DR_REG |= (LCD_E | (nibble << LCD_PORT_SHIFT));
    
    /* Minimum of 230 ns delay */
    CyDelayUs(1u);
    
    LCD_PORT_DR_REG &= ~LCD_E;
}