Beispiel #1
0
/*******************************************************************************
* Function Name  : Menu_Init
* Description    : Initializes the navigation menu.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Menu_Init(void)
{
    DelayResolution100us(Dly);
    GLCD_PowerUpInit(0x0);
    GLCD_Backlight(BACKLIGHT_ON);
    GLCD_SetFont(&Terminal_9_12_6,0xF,0xFFF);
    psCurrentMenu = &MainMenu;
    psPrevMenu[nMenuLevel] = psCurrentMenu;
    psMenuItem = MainMenuItems;
}
Beispiel #2
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
 int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */  
  /* Setup STM32 system (clock, PLL and Flash configuration) */
  SystemInit();
  
  /* GLCD init */
  GLCD_PowerUpInit((pInt8U)IAR_Logo.pPicStream);
  GLCD_Backlight(BACKLIGHT_ON);
  DelayResolution100us(5000);

  GLCD_PowerUpInit((pInt8U)STM32_Logo.pPicStream);
  GLCD_SetFont(&Terminal_9_12_6,0x000F00,0x00FF0);
  GLCD_TextSetPos(4,6);
  GLCD_print("STM32F407ZG-SK");
  GLCD_Backlight(BACKLIGHT_ON);
  
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
    
  /* Menu init */
  Menu_Init();
 
  Joystick_Init();
 
   
  DisplayMenu();
  
   
  /* Infinite loop */
  while (1)
  {
  }	
}
/*************************************************************************
 * Function Name: HD44780_BusyCheck
 * Parameters: Int8U * AddCount, Int32U MaxDly
 * Return: HD44780_ERROR_CODE_DEF
 *         HD44780_OK  0: Pass
 *     HD44780_ERROR 1: Busy check Time Out
 * Description: Wait MaxDly *100u or until the busy flag is clear
 *
 *************************************************************************/
static HD44780_ERROR_CODE_DEF HD44780_BusyCheck (Int8U * AddCount, Int32U MaxDly)
{
#if HD4780_WR > 0
Int8U AddHold;
#endif
  for (;MaxDly;--MaxDly)
  {
#if HD4780_WR > 0
    AddHold = HD44780RdStatus();
    if ((AddHold & HD44780_STATUS_BUSY_MASK) == 0)
    {
      /* Wait 1.5 * Tlcd */
      HD44780_BUS_DLY();
      HD44780_BUS_DLY();
      /* Get current AC */
      AddHold = HD44780RdStatus();
      AddHold &= HD44780_STATUS_AC_MASK;
      if(AddCount != NULL)
      {
        *AddCount = AddHold;
      }
      return HD44780_OK;
    }
#endif
    DelayResolution100us(1);
  }
#if HD4780_WR > 0
  return HD44780_ERROR;
#else
  if(AddCount != NULL)
  {
    *AddCount = DataRamAddHold;
  }
  return HD44780_OK;
#endif
}
/*************************************************************************
 * Function Name: HD44780_Init
 * Parameters: none
 * Return: HD44780_ERROR_CODE_DEF
 *         HD44780_OK  0: Pass
 *     HD44780_ERROR 1: Busy check Time Out
 * Description: Init HD44780 after power-up
 *
 *************************************************************************/
HD44780_ERROR_CODE_DEF HD44780_PowerUpInit (void)
{
Int8U Command;
  HD4478_Ctrl.DisplayPos = 0;
  /* Init MCU IO */
  HD44780SetPU();
  /* Power up init sequence */
  DelayResolution100us(HD44780_POWER_UP_DLY);
  LCD_RS_LOW();
  HD44780WrComm_High(HD44780_FUNCTION_SET+HD44780_FUNCTION_SET_8_BIT);
  DelayResolution100us(HD44780_FIRST_COMM_DLY);
  HD44780WrComm_High(HD44780_FUNCTION_SET+HD44780_FUNCTION_SET_8_BIT);
  DelayResolution100us(HD44780_SECOND_COMM_DLY);
  HD44780WrComm_High(HD44780_FUNCTION_SET+HD44780_FUNCTION_SET_8_BIT);
  DelayResolution100us(HD44780_SECOND_COMM_DLY);
  /* Display Function set */
#if HD44780_BUS_WIDTH == 8
  Command = HD44780_FUNCTION_SET + HD44780_FUNCTION_SET_8_BIT;
#else
  HD44780WrComm_High(HD44780_FUNCTION_SET + HD44780_FUNCTION_SET_4_BIT);
  DelayResolution100us(HD44780_SECOND_COMM_DLY);
  Command = HD44780_FUNCTION_SET + HD44780_FUNCTION_SET_4_BIT;
#endif
  if (HD4478_Ctrl.Line)
  {
    Command |= HD44780_FUNCTION_SET_2_LINE;
  }
  if (HD4478_Ctrl.DotMode)
  {
    Command |= HD44780_FUNCTION_SET_DOT_5_10;
  }
  HD44780WrComm(Command);
  if (HD44780_BusyCheck(NULL,HD44780_SECOND_COMM_DLY) != HD44780_OK)
  {
    return HD44780_ERROR;
  }
  /* Display off */
  HD44780WrComm(HD44780_DISPLAY_CTRL);
  if (HD44780_BusyCheck(NULL,HD44780_MAX_COMM_DLY) != HD44780_OK)
  {
    return HD44780_ERROR;
  }
  /* Display clear */
  if (HD44780_ClearDisplay() != HD44780_OK)
  {
    return HD44780_ERROR;
  }
#if HD4780_WR == 0
  DataRamAddHold = 0;
#endif
  /* Set entry mode */
  Command = HD44780_ENTRY_MODE;
  if (HD4478_Ctrl.AC_Direction)
  {
    Command |= HD44780_ENTRY_MODE_INC;
  }
  if (HD4478_Ctrl.DisplayShift)
  {
    Command |= HD44780_ENTRY_MODE_BOTH_S;
  }
  /* Set Display and cursor mode */
  if (HD44780_SetMode() != HD44780_OK)
  {
    return HD44780_ERROR;
  }
  return HD44780_OK;
}