コード例 #1
0
ファイル: glcd_ll.c プロジェクト: Manish-cimcon/micro
/*************************************************************************
 * Function Name: GLCD_LLInit
 * Parameters: none
 * Return: none
 *
 * Description: Init Reset and Backlight control outputs
 *
 *************************************************************************/
void GLCD_LLInit (void)
{
	// LCD Reset output
  LCD_RST_FDIR |= LCD_RST_MASK;

  GLCD_SetReset(0);

	// LCD backlight PWM 8bit init
  LCD_BL_PIN_SEL = 3;       // assign P3.26 to PWM1
  PCONP_bit.PCPWM1 = 1;     // enable clock of PWM1
  PWM1TCR_bit.PWMEN = 0;    // enable PWM function
  PWM1TCR_bit.CE = 0;       // disable counting
  PWM1TCR_bit.CR = 1;       // reset
  PWM1CTCR_bit.CM = 0;      // from prescaler
  PWM1MCR = 2;              // Reset on PWMMR0
  PWM1PCR_bit.PWMSEL3 = 0;  // Selects single edge controlled mode for PWM6
  PWM1PCR_bit.PWMENA3 = 1;  // The PWM3 output enabled
  PWM1PR = 0;
  PWM1MR0 = 0xFF;           // 8bit resolution
  PWM1LER_bit.EM0L = 1;
  PWM1MR3 = 0;
  PWM1LER_bit.EM3L = 1;
  PWM1TCR_bit.PWMEN = 1;    // enable PWM function
  PWM1TCR_bit.CR = 0;       // release reset
  PWM1TCR_bit.CE = 1;       // enable counting
  GLCD_Backlight(0);
}
コード例 #2
0
/*************************************************************************
 * Function Name: GLCD_PowerUpInit
 * Parameters: pInt8U pInitData
 * Return: GLCD_Status_t
 *         GLCD_OK - init pass
 *         GLCD_ID_ERROR - unsupported driver type
 * Description: Power-up initialization of Graphic LCD
 *
 *************************************************************************/
GLCD_Status_t GLCD_PowerUpInit (pInt8U pInitData)
{
Int32U Data;
pDATCTR_Data_t pDATCTR_Data;
volatile Int32U i;
   
  // Init SPI and IO
  // Init low level
  GLCD_SPI_Init(GLCD_DEF_CLOCK,GLCD_DEF_WIDTH);
  GLCD_LLInit();
  GLCD_Backlight(BACKLIGHT_ON);
  // H/W Reset
  // Rest L > 10us H
  GLCD_SetReset(0);
  for(i = GLCD_DLY_10US; i ; --i);
  GLCD_SetReset(1);
  // Wait 5 ms
  //DelayResolution100us(GLCD_RESET_DLY);
  for(i = GLCD_DLY_10US * 100; i ; --i);
  // Identify LCD and command interpreter
  Glcd_Iss = GLCD_ISS_0;
  /*GLCD_SendCmd(RDDID,(pInt8U)&Data,0);
  if(((Data        & 0xFF) != GLCD_MANF_ID) ||
     (((Data >> 16)& 0xFF) != GLCD_MOD_ID))
  {
  	// Iss = 1 don't support RDDID command
  	Glcd_Iss = GLCD_ISS_1;
  }*/
  // Power Supply Set
  if(Glcd_Iss == GLCD_ISS_1)
  {
    // Support only 4K colors
    assert(GLCD_DEF_DPL_ML == 0);
	  //  DISCTR (Display Control)
	  //	 - F1/F2 switching period set
	  //	 - Line inversion set
	  Data = 0 | (0x20UL << 8) | (0x11UL << 16);
	  GLCD_SendCmd(DISCTR,(pInt8U)&Data,0);
	  //  OSCON (Oscillator ON)
	  GLCD_SendCmd(OSCON,NULL,0);
    // Set contrast
    Data = 38 | (0x0UL << 8);
    GLCD_SendCmd(VOLCTR,(pInt8U)&Data,0);
  }
  else
  {
    // Set contrast
    Data = 0x3B;
    GLCD_SendCmd(SETCON,(pInt8U)&Data,0);
  }
  // SLPOUT (Sleep mode OFF & OSC/Booster On)
  GLCD_SendCmd(SLPOUT,NULL,0); // Sleep out
  if(Glcd_Iss == GLCD_ISS_0)
  {
    GLCD_SendCmd(BSTRON,NULL,0); // Booster voltage on
  }
  // Display Environment Set
  // Display inversion setting
  GLCD_SendCmd(GLCD_DEF_DPL_INV?INVON:INVOFF,NULL,0);
  // Display color scheme setting
  GLCD_SendCmd(GLCD_DEF_DPL_8_COLOR?IDMON:IDMOFF,NULL,0);
  // Display partial setting
  if(GLCD_DEF_DPL_PARTIAL_MODE)
  {
    GLCD_SendCmd(PTLOUT,NULL,0);
  }
  else
  {
#if GLCD_DEF_DPL_PARTIAL_MODE > 0
#error "PARTIAL_MODE not supported yet"
#endif // GLCD_DEF_DPL_PARTIAL_MODE > 0
  }
  // Memory Data Access Control
  Data = 0;
  pDATCTR_Data = (pDATCTR_Data_t)&Data;
  pDATCTR_Data->RGB = GLCD_DEF_DPL_RGB_ORD; // BGR / RGB order
  pDATCTR_Data->MY = GLCD_DEF_DPL_MY; 			// no mirror Y
  pDATCTR_Data->MX = GLCD_DEF_DPL_MX; 			// no mirror X
  pDATCTR_Data->MV = GLCD_DEF_DPL_V; 				// vertical RAM write in Y/X direction
  pDATCTR_Data->ML = GLCD_DEF_DPL_ML; 			// line address order (bottom to top) / (top to bottom)
  // support only 4k type A colored scheme
  GLCD_SendCmd(DATCTR,(pInt8U)&Data,0);
  // Display Data Write & Display On
  // COLUMN ADDRESS SET and PAGE ADDRESS SET
  Data = 0 | ((GLCD_HORIZONTAL_SIZE - 1)<<8);
  GLCD_SendCmd(RASET,(pInt8U)&Data,0);
  GLCD_SendCmd(CASET,(pInt8U)&Data,0);

  // Init display memory
  if(pInitData == NULL)
  {
    Data = DEF_BACKGND_COLOUR;
    for(i = 0; i < (GLCD_HORIZONTAL_SIZE * GLCD_VERTICAL_SIZE); ++i)
    {
		Data = 0xFFFFFFFF >> (i & 0x1F);
      LCD_WRITE_PIXEL(Data);
    }
    LCD_FLUSH_PIXELS();
  }
コード例 #3
0
ファイル: glcd_ll.c プロジェクト: anderssj/synth
/*************************************************************************
 * Function Name: GLCD_LLInit
 * Parameters: none
 * Return: none
 *
 * Description: Init Reset and Backlight control outputs
 *
 *************************************************************************/
void GLCD_LLInit (void)
{
TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
GPIO_InitTypeDef GPIO_InitStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;

  /* Enable GPIO clock and release reset*/
  RCC_AHB1PeriphClockCmd(LCD_RST_CLK | LCD_BL_CLK, ENABLE);
  RCC_AHB1PeriphResetCmd(LCD_RST_CLK | LCD_BL_CLK,DISABLE);

  /*LCD Reset pin init*/  
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

  GPIO_InitStructure.GPIO_Pin = LCD_RST_MASK;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(LCD_RST_PORT, &GPIO_InitStructure);

  GLCD_SetReset(0);

	/* LCD backlight Init*/ 
  // PWM DAC (TIM3/CH3)
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_Pin = LCD_BL_MASK;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(LCD_BL_PORT, &GPIO_InitStructure);

  GPIO_PinAFConfig(LCD_BL_PORT,LCD_BL_PIN_SOURCE,LCD_BL_PIN_AF);

  // Init PWM TIM3
  // Enable Timer3 clock and release reset
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE);
  RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM3,DISABLE);

  TIM_InternalClockConfig(TIM3);

  // Time base configuration
  TIM_TimeBaseStructure.TIM_Prescaler = 140;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseStructure.TIM_Period = 0xFF; // 8 bit resolution
  TIM_TimeBaseStructure.TIM_ClockDivision = 0;
  TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
  TIM_TimeBaseInit(TIM3,&TIM_TimeBaseStructure);

  // Channel 4 Configuration in PWM mode
  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable;
  TIM_OCInitStructure.TIM_Pulse = 0x00;
  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
  TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_High;
  TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
  TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;
  TIM_OC3Init(TIM3,&TIM_OCInitStructure);
  // Double buffered
  TIM_ARRPreloadConfig(TIM3,ENABLE);
  // TIM3 counter enable
  TIM_Cmd(TIM3,ENABLE);

  GLCD_Backlight(0);
}