Example #1
0
/***************************************************************************//**
 * @brief
 *   Initalize Liquid Crystal Display (LCD) controller
 *
 * @details
 *   This function call will only configure the LCD controller. You must enable
 *   it afterwards, potentially configuring Frame Control and interrupts first
 *   according to requirements.
 *
 * @param[in] lcdInit
 *   Pointer to initialization structure which configures LCD controller.
 *
 ******************************************************************************/
void LCD_Init(const LCD_Init_TypeDef *lcdInit)
{
  uint32_t dispCtrl = LCD->DISPCTRL;

  /* Disable controller before reconfiguration */
  LCD_Enable(false);

  /* Make sure we don't touch other bit fields (i.e. voltage boost) */
  dispCtrl &= ~(
#if defined(_EFM32_TINY_FAMILY) || defined(_EFM32_GIANT_FAMILY)
    _LCD_DISPCTRL_MUXE_MASK |
#endif
    _LCD_DISPCTRL_MUX_MASK |
    _LCD_DISPCTRL_BIAS_MASK |
    _LCD_DISPCTRL_WAVE_MASK |
    _LCD_DISPCTRL_VLCDSEL_MASK |
    _LCD_DISPCTRL_CONCONF_MASK);

  /* Configure controller according to initialization structure */
  dispCtrl |= lcdInit->mux; /* also configures MUXE */
  dispCtrl |= lcdInit->bias;
  dispCtrl |= lcdInit->wave;
  dispCtrl |= lcdInit->vlcd;
  dispCtrl |= lcdInit->contrast;

  /* Update display controller */
  LCD->DISPCTRL = dispCtrl;

  /* Enable controller if wanted */
  if (lcdInit->enable)
  {
    LCD_Enable(true);
  }
}
Example #2
0
/***************************************************************************//**
 * @brief
 *   Initialize the Liquid Crystal Display (LCD) controller.
 *
 * @details
 *   Configures the LCD controller. You must enable
 *   it afterwards, potentially configuring Frame Control and interrupts first
 *   according to requirements.
 *
 * @param[in] lcdInit
 *   A pointer to the initialization structure which configures the LCD controller.
 *
 ******************************************************************************/
void LCD_Init(const LCD_Init_TypeDef *lcdInit)
{
  uint32_t dispCtrl = LCD->DISPCTRL;

  EFM_ASSERT(lcdInit != (void *) 0);

  /* Disable the controller before reconfiguration. */
  LCD_Enable(false);

  /* Make sure the other bit fields don't get affected (i.e., voltage boost). */
  dispCtrl &= ~(0
#if defined(LCD_DISPCTRL_MUXE)
                | _LCD_DISPCTRL_MUXE_MASK
#endif
                | _LCD_DISPCTRL_MUX_MASK
                | _LCD_DISPCTRL_BIAS_MASK
                | _LCD_DISPCTRL_WAVE_MASK
#if defined(_LCD_DISPCTRL_VLCDSEL_MASK)
                | _LCD_DISPCTRL_VLCDSEL_MASK
#endif
#if defined(_LCD_DISPCTRL_CONCONF_MASK)
                | _LCD_DISPCTRL_CONCONF_MASK
#endif
#if defined(_LCD_DISPCTRL_MODE_MASK)
                | _LCD_DISPCTRL_MODE_MASK
#endif
#if defined(_LCD_DISPCTRL_CHGRDST_MASK)
                | _LCD_DISPCTRL_CHGRDST_MASK
#endif
                );

  /* Configure the controller according to the initialization structure. */
  dispCtrl |= lcdInit->mux; /* Also configures MUXE. */
  dispCtrl |= lcdInit->bias;
  dispCtrl |= lcdInit->wave;
#if defined(_SILICON_LABS_32B_SERIES_0)
  dispCtrl |= lcdInit->vlcd;
  dispCtrl |= lcdInit->contrast;
#endif
#if defined(_SILICON_LABS_32B_SERIES_1)
  dispCtrl |= lcdInit->mode;
  dispCtrl |= (lcdInit->chargeRedistribution);
#endif

  /* Update the display controller. */
  LCD->DISPCTRL = dispCtrl;

#if defined(_SILICON_LABS_32B_SERIES_1)
  LCD->FRAMERATE = lcdInit->frameRateDivider;
  LCD_ContrastSet(lcdInit->contrastLevel);
#endif

  /* Enable the controller if needed. */
  if (lcdInit->enable) {
    LCD_Enable(true);
  }
}
/******************************************************************************
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  /* Initialize chip */
  CHIP_Init();
  
  /* Enable code view */
  setupSWO();

  /* Initialize LCD */
  SegmentLCD_Init(false);

  /* Enable the HFPER clock */
  CMU_ClockEnable(cmuClock_HFPER, true);

  /* Configure RTC and GPIO */
  rtc_setup();
  gpio_setup();

  /* Stay in this loop forever */
  while (1)
  {
    /* Wait for Push Button 1 to be pressed */
    while (GPIO_PinInGet(PB0_PORT, PB0_PIN)) ;
    /* and released, so that we do not exit the while loop below immediately */
    while (!GPIO_PinInGet(PB0_PORT, PB0_PIN)) ;

    /* Reset time */
    time = 0;

    /* Disable LCD */
    LCD_Enable(true);

    /* Update time until Push Button 1 is pressed again */
    while (1)
    {
      if (RTC_CounterGet() == 0)
      {
        SegmentLCD_Number(++time);
      }

      if (!GPIO_PinInGet(PB0_PORT, PB0_PIN))
        break;
    }

    /* Delay while showing the result on the LCD */
    for (uint32_t delay = 0; delay < 30; delay++)
    {
      /* Wait for the RTC to overflow once */
      while (RTC_CounterGet() != 0) ;
      while (RTC_CounterGet() == 0) ;
    }

    /* Disable LCD */
    LCD_Enable(false);
  }
}
/**************************************************************************//**
 * @brief LESENSE_IRQHandler
 * Interrupt Service Routine for LESENSE Interrupt Line
 *****************************************************************************/
void LESENSE_IRQHandler(void)
{
  /* Read interrupts flags */
  uint32_t intFlags = LESENSE_IntGet();
  
  /* Clear interrupts */
  LESENSE_IntClear(LESENSE_IFC_DEC | LESENSE_IFC_DECERR);

  /* Enable clock for LCD. */
  CMU_ClockEnable(cmuClock_LCD, true);
  /* Wait until SYNCBUSY_CTRL flag is cleared. */
  LCD_SyncBusyDelay(LCD_SYNCBUSY_CTRL);
  /* Enable LCD. */
  LCD_Enable(true);

  /* If there is a decoder error stop trap execution in this loop */
  if (intFlags & LESENSE_IF_DECERR)
  {
    /* DECODER ERROR */
    SegmentLCD_Write(LCSENSE_ERROR_STRING);
    while (1) ;
  }

  /* Write PCNT counter number the LCD */
  SegmentLCD_Number(PCNT_CounterGet(PCNT0));

  /* Disable RTC first to reset counter */
  RTC_Enable(false);
  /* Set compare value */
  RTC_CompareSet(0, RTC_COMP_VALUE);
  /* Enable RTC */
  RTC_Enable(true);
}
Example #5
0
/*******************************************************************************
 * º¯ÊýÃû(Function):	lpc1788_Lcd_Init
 * ²ÎÊý(Param):				ÎÞ 							
 * ·µ»ØÖµ(Return):		ÎÞ
 * ÃèÊö(Description):	LCD³õʼ»¯º¯Êý
 *******************************************************************************/
void lpc1788_Lcd_Init(void)
{
	LCD_Config_Type lcd_config;

	/* ژҕLCD࠘׆ */
	LCD_Enable (FALSE);
 
	/* ³õʼ»¯SDRAM */
	lpc1788_SDRAM_Init();
 lpc1788_SDRAM_Clean();


 	/* ÅäÖÃLCD²ÎÊý */
  lcd_config.big_endian_byte = 0;
  lcd_config.big_endian_pixel = 0;
  lcd_config.hConfig.hbp = LCD_H_BACK_PORCH;
  lcd_config.hConfig.hfp = LCD_H_FRONT_PORCH;
  lcd_config.hConfig.hsw = LCD_H_PULSE;
  lcd_config.hConfig.ppl = LCD_H_SIZE;
  lcd_config.vConfig.lpp = LCD_V_SIZE;
  lcd_config.vConfig.vbp = LCD_V_BACK_PORCH;
  lcd_config.vConfig.vfp = LCD_V_FRONT_PORCH;
  lcd_config.vConfig.vsw = LCD_V_PULSE;
  lcd_config.panel_clk   = LCD_PIX_CLK;
  lcd_config.polarity.active_high = 1;
  lcd_config.polarity.cpl = LCD_H_SIZE;
  lcd_config.polarity.invert_hsync = 1;
  lcd_config.polarity.invert_vsync = 1;
  lcd_config.polarity.invert_panel_clock = 0;
  lcd_config.lcd_panel_upper =  LCD_VRAM_BASE_ADDR_UPPER;
  lcd_config.lcd_panel_lower =  LCD_VRAM_BASE_ADDR_LOWER;
  lcd_config.lcd_bpp = LCD_BPP_16_565Mode;
  lcd_config.lcd_type = LCD_TFT;
	lcd_config.lcd_palette = NULL;
  lcd_config.lcd_bgr = FALSE;
	LCD_Initialize (&lcd_config);

//  LCD_SetImage(LCD_PANEL_UPPER, NULL);
//  LCD_SetImage(LCD_PANEL_LOWER, NULL);

	/* LCDʹÄÜ */
	LCD_Enable (TRUE);


}
Example #6
0
/*******************************************************************************
* Function Name: LCD_Wakeup
********************************************************************************
*
* Summary:
*  Wakes component from sleep mode. Configures DMA and enables the component for
*  normal operation.
*
* Parameters:
*  LCD_enableState - Global variable.
*
* Return:
*  Status one of standard status for PSoC3 Component
*       CYRET_SUCCESS - Function completed successfully.
*       CYRET_LOCKED - The object was locked, already in use. Some of TDs or
*                      a channel already in use.
*
* Reentrant:
*  No.
*
*******************************************************************************/
void LCD_Wakeup(void) 
{
    LCD_RestoreConfig();

    if(LCD_backup.enableState == 1u)
    {
        LCD_Enable();
    }
}
Example #7
0
__ISR (_CHANGE_NOTICE_VECTOR, IPL7SRS) _CNInterrupt(void) {
    IFS1bits.CNEIF = 0;
    IFS1bits.CNDIF = 0;
    CNCONEbits.ON = 0;
    delayMs(5);
    CNCONEbits.ON = 1;
    if(PORTEbits.RE7 == 1) {
        curr = next;
    }
    if(PORTDbits.RD6 == 0) {
        LCD_Enable();
        LED_On(1);
    }
    if(PORTDbits.RD6 == 1) {
        LCD_Enable();
        LATDbits.LATD1 = 0;
    }
}
Example #8
0
File: LCD.c Project: TheCbac/OV5620
/*******************************************************************************
* Function Name: LCD_Start
********************************************************************************
*
* Summary:
*  Perform initialization required for components normal work.
*  This function initializes the LCD hardware module as follows:
*        Enable 4-bit interface
*        Clear the display
*        Enable auto cursor increment
*        Resets the cursor to start position
*  Also loads custom character set to LCD if it was defined in the customizer.
*  If it was not the first call in this project then it just turns on the
*  display
*
*
* Parameters:
*  LCD_initVar - global variable.
*
* Return:
*  LCD_initVar - global variable.
*
* Reentrant:
*  No.
*
*******************************************************************************/
void LCD_Start(void) 
{
    /* If not initialized then perform initialization */
    if(LCD_initVar == 0u)
    {
        LCD_Init();
        LCD_initVar = 1u;
    }

    /* Turn on the LCD */
    LCD_Enable();
}
Example #9
0
/**
  * @brief  Init the GPIO port of the LCD and LCD peripheral.
  * @param  None 
  * @retval None
  */
void LCD_Seg_Init(void)
{
    uint16_t i;
    LCD_InitPara LCD_InitStructure;

    /* Configure the LCD GPIO pins */
    LCD_GPIO_Config(); 

    /*!< Enable the clock of LCD */
    RCC_APB1PeriphClock_Enable(RCC_APB1PERIPH_LCD, ENABLE);
    for(i=0;i<500;i++);
    /* Configure the LCD interface */
    LCD_InitStructure.LCD_Prescaler = LCD_PRESCALER_1;
    LCD_InitStructure.LCD_Divider = LCD_DIVIDER_16;
    LCD_InitStructure.LCD_Duty = LCD_DUTY_1_4;
    LCD_InitStructure.LCD_VBias = LCD_BIAS_1_3;
    LCD_InitStructure.LCD_VSRC = LCD_VOLTAGESOURCE_INTERNAL;
    LCD_Init(&LCD_InitStructure);

    /* Configure the Pulse On Duration */
    LCD_PulseOnDurationConfig(LCD_PULSEON_DURATION_7);

    /* Configure the Datatime Period */
    LCD_DeadTimeConfig(LCD_DEADTIME_PERIOD_7);

    /* Configure the LCD Contrast LEVEL_7(3.51V) */
    LCD_ContrastConfig(LCD_CONTRAST_LEVEL_7);

    /* Enable high drive function */
    LCD_HighDrive_Enable(ENABLE);

    /* Loop until SYNF flag is set */
    while ((LCD->SFR & LCD_FLAG_SYNF) == (uint32_t)RESET)
    {
    }
    /* Enable LCD peripheral */
    LCD_Enable(ENABLE);

    /* Wait the LCD is enable */
    while(!(LCD_GetBitState(LCD_FLAG_ONF)))
    {
    }

    /* Wait the LCD CFGR register synchronization */
//    while(!(LCD_GetBitState(LCD_FLAG_VRDYF)))
//    {
//    }

}
Example #10
0
//------------------------------------------------------------------------------
/// Displays the contents of the provided buffer on the LCD. The buffer is
/// provided as-is to the LCD DMA and is not copied.
/// If the LCD and DMA are not yet enabled, this function enables them.
/// \param pBuffer  Buffer to display.
/// \return The address of the previously displayed buffer.
//------------------------------------------------------------------------------
void * LCDD_DisplayBuffer(void *pBuffer)
{
    void *pOldBuffer;

    pOldBuffer = LCD_SetFrameBufferAddress(pBuffer);

    // Enable LCD & DMA if needed
    if ((AT91C_BASE_LCDC->LCDC_DMACON & AT91C_LCDC_DMAEN) != AT91C_LCDC_DMAEN) {

        LCD_EnableDma();
        LCD_Enable(0x0C);
    }

    return pOldBuffer;
}
/**************************************************************************//**
 * @brief RTC_IRQHandler
 * Interrupt Service Routine for RTC Interrupt Line
 *****************************************************************************/
void RTC_IRQHandler(void)
{
  /* Clear interrupt flag */
  RTC_IntClear(RTC_IFS_COMP0);
  /* Disable RTC */
  RTC_Enable(false);
  /* Turn off all segments */
  SegmentLCD_AllOff();
  /* Disable LCD to avoid excessive current consumption */
  LCD_Enable(false);
  /* Wait until SYNCBUSY_CTRL flag is cleared. */
  LCD_SyncBusyDelay(LCD_SYNCBUSY_CTRL);
  /* Disable clock for LCD. */
  CMU_ClockEnable(cmuClock_LCD, false);
}
Example #12
0
/* Please note that the configuration file has changed from lab 0.
 * the oscillator is now of a different frequency.
 */
int main(void)
{
    SYSTEMConfigPerformance(10000000);
    enableInterrupts();
    LEDEnable();
    
    LCD_Enable();
    
   
    
    
    TRISGbits.TRISG12 = 0;
    TRISGbits.TRISG15 = 0;
    LATGbits.LATG12 = 0;
    LATGbits.LATG15 = 1;
    
    ANSELEbits.ANSE7 = 0;
    CNPUEbits.CNPUE7 = 1;
    TRISEbits.TRISE7 = 1;
    CNCONEbits.ON = 1;
    CNENEbits.CNIEE7 = 1;
    IFS1bits.CNEIF = 0;
    IPC8bits.CNIP = 7;
    IEC1bits.CNEIE = 1;
    while(1){
        switch(curr) {
            case RUN:
                LATGbits.LATG12 = 0;
                LATGbits.LATG15 = 1;
                next = STOP;
                break;
            case STOP:
                LATGbits.LATG12 = 1;
                LATGbits.LATG15 = 0;
                next = RUN;
                break;
        }
    }
    
    return 0;
}
/**************************************************************************//**
 * @brief PCNT0_IRQHandler
 * Interrupt Service Routine for PCNT0 Interrupt Line
 *****************************************************************************/
void PCNT0_IRQHandler(void)
{
  PCNT_IntGet(PCNT0);
  PCNT_IntClear(PCNT0, PCNT_IEN_DIRCNG);

  /* Enable clock for LCD. */
  CMU_ClockEnable(cmuClock_LCD, true);
  /* Wait until SYNCBUSY_CTRL flag is cleared. */
  LCD_SyncBusyDelay(LCD_SYNCBUSY_CTRL);
  /* Enable LCD. */
  LCD_Enable(true);
  /* Write PCNT counter number the LCD */
  SegmentLCD_Write(PCNT_DIRCHANGE_STRING);

  /* Disable RTC first to reset counter */
  RTC_Enable(false);
  /* Set compare value */
  RTC_CompareSet(0, RTC_COMP_VALUE);
  /* Enable RTC */
  RTC_Enable(true);
}
void Init_LCD(void)
{
	  LCD_Enable (FALSE);

	  lcd_config.big_endian_byte = 0;
	  lcd_config.big_endian_pixel = 0;
	  lcd_config.hConfig.hbp = LCD_H_BACK_PORCH;
	  lcd_config.hConfig.hfp = LCD_H_FRONT_PORCH;
	  lcd_config.hConfig.hsw = LCD_H_PULSE;
	  lcd_config.hConfig.ppl = LCD_H_SIZE;
	  lcd_config.vConfig.lpp = LCD_V_SIZE;
	  lcd_config.vConfig.vbp = LCD_V_BACK_PORCH;
	  lcd_config.vConfig.vfp = LCD_V_FRONT_PORCH;
	  lcd_config.vConfig.vsw = LCD_V_PULSE;
	  lcd_config.panel_clk   = LCD_PIX_CLK;
	  lcd_config.polarity.active_high = 1;
	  lcd_config.polarity.cpl = LCD_H_SIZE;
	  lcd_config.polarity.invert_hsync = 1;
	  lcd_config.polarity.invert_vsync = 1;
	  lcd_config.polarity.invert_panel_clock = 1;

//	  lcd_config.lcd_panel_upper =  LCD_VRAM_BASE_ADDR_START;//				//povodny stav.
//	  lcd_config.lcd_panel_lower =  LCD_VRAM_BASE_ADDR_TOP;
	  lcd_config.lcd_panel_upper =  LCD_VRAM_BASE_ADDR_TOP;					//ToDo: toto bolo naopak.
	  lcd_config.lcd_panel_lower =  LCD_VRAM_BASE_ADDR_START;

	  lcd_config.lcd_bpp = LCD_BPP_16; //LCD_BPP_24;
	  lcd_config.lcd_type = LCD_TFT;
	  lcd_config.lcd_palette = _NULL;
	  lcd_config.lcd_bgr = FALSE;

	  // Init LCD HW
	  LCD_Init (&lcd_config);

	  // clear background.
	  LCD_SetImage(LCD_PANEL_UPPER, NULL);
	  LCD_SetImage(LCD_PANEL_LOWER, NULL);
}
void Disable_LCD(void)
{
	  LCD_Enable (DISABLE);				// Disable LCD
}
// --------------------------------------------------
void Enable_LCD(void)
{
	  LCD_Enable (ENABLE);				// Enable LCD
}
Example #17
0
/*******************************************************************************
* Function Name: LCD_Wakeup
****************************************************************************//**
*
*  Prepares the LCD component for Active mode operation after 
*  Deep Sleep.
*  The “Enable wakeup from Deep Sleep Mode” selection has influence on this 
*  function implementation:
*  - Checked: restores the component Active mode configuration.
*  - Unchecked: enables the component if it was enabled before enter Deep Sleep.
*
*  This function should not be called after exiting Sleep.
*
*  \sideeffect
*   Calling the LCD_Wakeup() function without first calling the 
*   LCD_Sleep() function may produce unexpected behavior.
*
*******************************************************************************/
void LCD_Wakeup(void)
{
#if(LCD_SCB_MODE_UNCONFIG_CONST_CFG)

    if(LCD_SCB_WAKE_ENABLE_CHECK)
    {
        if(LCD_SCB_MODE_I2C_RUNTM_CFG)
        {
            LCD_I2CRestoreConfig();
        }
        else if(LCD_SCB_MODE_EZI2C_RUNTM_CFG)
        {
            LCD_EzI2CRestoreConfig();
        }
    #if(!LCD_CY_SCBIP_V1)
        else if(LCD_SCB_MODE_SPI_RUNTM_CFG)
        {
            LCD_SpiRestoreConfig();
        }
        else if(LCD_SCB_MODE_UART_RUNTM_CFG)
        {
            LCD_UartRestoreConfig();
        }
    #endif /* (!LCD_CY_SCBIP_V1) */
        else
        {
            /* Unknown mode */
        }
    }
    else
    {
        if(0u != LCD_backup.enableState)
        {
            LCD_Enable();
        }
    }

#else

    #if (LCD_SCB_MODE_I2C_CONST_CFG  && LCD_I2C_WAKE_ENABLE_CONST)
        LCD_I2CRestoreConfig();

    #elif (LCD_SCB_MODE_EZI2C_CONST_CFG && LCD_EZI2C_WAKE_ENABLE_CONST)
        LCD_EzI2CRestoreConfig();

    #elif (LCD_SCB_MODE_SPI_CONST_CFG && LCD_SPI_WAKE_ENABLE_CONST)
        LCD_SpiRestoreConfig();

    #elif (LCD_SCB_MODE_UART_CONST_CFG && LCD_UART_WAKE_ENABLE_CONST)
        LCD_UartRestoreConfig();

    #else

        if(0u != LCD_backup.enableState)
        {
            LCD_Enable();
        }

    #endif /* (LCD_I2C_WAKE_ENABLE_CONST) */

#endif /* (LCD_SCB_MODE_UNCONFIG_CONST_CFG) */
}