⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menu.c

📁 stm32.rar
💻 C
📖 第 1 页 / 共 3 页
字号:
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
* File Name          : menu.c
* Author             : MCD Application Team
* Version            : V1.1.1
* Date               : 06/13/2008
* Description        : This file includes the menu navigation driver for the
*                      STM3210E-EVAL demonstration.
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include <stdio.h>
#include <string.h>

/* Private typedef -----------------------------------------------------------*/
typedef void (* tMenuFunc)(void);
typedef struct sMenuItem * tMenuItem;
typedef struct sMenu * tMenu;

/* Private define ------------------------------------------------------------*/
#define NumberOfIcons 10

/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
u8 MenuItemIndex = 0, nMenuLevel = 0;
u8 ItemNumb[MAX_MENU_LEVELS];

tMenuItem psMenuItem, psCurrentMenuItem;
tMenu psPrevMenu[MAX_MENU_LEVELS];
tMenu psCurrentMenu;

struct sMenuItem
{
  u8* pszTitle;
  tMenuFunc pfMenuFunc;
  tMenuFunc pfUpDownMenuFunc;
  tMenu psSubMenu;
};

struct sMenu
{
  u8* pszTitle;
  tMenuItem psItems;
  u8 nItems;
};

NOR_IDTypeDef NOR_ID;

#if STM3210E
uc32 IconsAddr[] = {0x64FCAC7E, 0x64FCCCC0, 0x64FCED02, 0x64FD0D44, 0x64FD2D86,
                    0x64FD4DC8, 0x64FD6E0A, 0x64FD8E4C, 0x64FDAE8E, 0x64FDCED0,
                    0x64FDEF12};
uc32 SlideAddr[14] = {0x64D7285E, 0x64D980A0, 0x64DBD8E2, 0x64DE3124, 0x64E08966,
                      0x64E2E1A8, 0x64E539EA, 0x64E7922C, 0x64E9EA6E, 0x64EC42B0,
                      0x64EE9AF2, 0x64F0F334, 0x64F34B76, 0x64F5A3B8};
#else
#define ICONS         0x007A9D6A
#define ICON_SZ       0x00002042
uc32 IconsAddr[] = {  ICONS           ,
                      ICONS+ 1*ICON_SZ,
                      ICONS+ 2*ICON_SZ,
                      ICONS+ 3*ICON_SZ,
                      ICONS+ 4*ICON_SZ,
                      ICONS+ 5*ICON_SZ,
                      ICONS+ 6*ICON_SZ,
                      ICONS+ 7*ICON_SZ,
                      ICONS+ 8*ICON_SZ,
                      ICONS+ 9*ICON_SZ,
                      ICONS+10*ICON_SZ};
#define SLIDES        0x0055194A
#define SLIDE_SZ      0x00025842
uc32 SlideAddr[14] = {SLIDES            , 
                      SLIDES+ 1*SLIDE_SZ,
                      SLIDES+ 2*SLIDE_SZ,
                      SLIDES+ 3*SLIDE_SZ,
                      SLIDES+ 4*SLIDE_SZ,
                      SLIDES+ 5*SLIDE_SZ,
                      SLIDES+ 6*SLIDE_SZ,
                      SLIDES+ 7*SLIDE_SZ,
                      SLIDES+ 8*SLIDE_SZ,
                      SLIDES+ 9*SLIDE_SZ,
                      SLIDES+10*SLIDE_SZ,
                      SLIDES+11*SLIDE_SZ,
                      SLIDES+12*SLIDE_SZ,
                      SLIDES+13*SLIDE_SZ};
#endif

                      
#if STM3210E
uc32 SlidesSpeech[14] = {0x00000000, 0x0006A166, 0x000D341C, 0x000F244E, 0x00150702,
                         0x00209D54, 0x0026B400, 0x002EB6AA, 0x00374BF0, 0x003B9778,
                         0x0043AF32, 0x00496000, 0x00521800, 0x0057AC40};

uc32 DelayTiming[14] = {2420, 2600, 800, 2400, 4725, 2100, 3300, 3500, 1600, 3300,
                        2420, 3400, 2275, 1670};
#else
uc32 SlidesSpeech[14] = {0x00000000, 0x0006A166, 0x000D341C, 0x000F244E, 0x00150702,
                         0x00209D54, 0x0026B400, 0x002EB6AA, 0x00374BF0, 0x003B9778,
                         0x0043AF32, 0x00000000, 0x0006A166, 0x000D341C};

uc32 DelayTiming[14] = {2420, 2600, 800, 2400, 4725, 2100, 3300, 3500, 1600, 3300,
                        2420, 2400, 2600, 800};
#endif

u8 SlidesCheck[6] = {0x42, 0x4D, 0x42, 0x58, 0x02, 0x00};
u8 Icons64Check[6] = {0x42, 0x4D, 0x42, 0x20, 0x00, 0x00};
u8 Icons128Check[6] = {0x42, 0x4D, 0x42, 0x80, 0x00, 0x00};


#if STM3210E
u32 STM32Banner[50] = {0x6461EB7A, 0x646443BC, 0x64669BFE, 0x6468F440, 0x646B4C82,
                       0x646DA4C4, 0x646FFD06, 0x64725548, 0x6474AD8A, 0x647705CC,
                       0x64795E0E, 0x647BB650, 0x647E0E92, 0x648066D4, 0x6482BF16,
                       0x64851758, 0x64876F9A, 0x6489C7DC, 0x648C201E, 0x648E7860,
                       0x6490D0A2, 0x649328E4, 0x64958126, 0x6497D968, 0x649A31AA,
                       0x649C89EC, 0x649EE22E, 0x64A13A70, 0x64A392B2, 0x64A5EAF4,
                       0x64A84336, 0x64AA9B78, 0x64ACF3BA, 0x64AF4BFC, 0x64B1A43E,
                       0x64B3FC80, 0x64B654C2, 0x64B8AD04, 0x64BB0546, 0x64BD5D88,
                       0x64BFB5CA, 0x64C20E0C, 0x64C4664E, 0x64C6BE90, 0x64C916D2,
                       0x64CB6F14, 0x64CDC756, 0x64D01F98, 0x64D277DA, 0x64D4D01C};
#else
#define BANNER         0x00496000
#define BANNER_IMG_SZ  0x00025842
u32 STM32Banner[50] = {BANNER+ 0*BANNER_IMG_SZ,
                       BANNER+ 1*BANNER_IMG_SZ,
                       BANNER+ 2*BANNER_IMG_SZ,
                       BANNER+ 3*BANNER_IMG_SZ,
                       BANNER+ 4*BANNER_IMG_SZ,
                       BANNER+ 3*BANNER_IMG_SZ,
                       BANNER+ 2*BANNER_IMG_SZ,
                       BANNER+ 1*BANNER_IMG_SZ,
                       BANNER+ 0*BANNER_IMG_SZ,
                       BANNER+ 1*BANNER_IMG_SZ,
                       BANNER+ 2*BANNER_IMG_SZ,
                       BANNER+ 3*BANNER_IMG_SZ,
                       BANNER+ 4*BANNER_IMG_SZ,
                       BANNER+ 3*BANNER_IMG_SZ,
                       BANNER+ 2*BANNER_IMG_SZ,
                       BANNER+ 1*BANNER_IMG_SZ,
                       BANNER+ 0*BANNER_IMG_SZ,
                       BANNER+ 1*BANNER_IMG_SZ,
                       BANNER+ 2*BANNER_IMG_SZ,
                       BANNER+ 3*BANNER_IMG_SZ,
                       BANNER+ 4*BANNER_IMG_SZ,
                       BANNER+ 3*BANNER_IMG_SZ,
                       BANNER+ 2*BANNER_IMG_SZ,
                       BANNER+ 1*BANNER_IMG_SZ,
                       BANNER+ 0*BANNER_IMG_SZ,
                       BANNER+ 1*BANNER_IMG_SZ,
                       BANNER+ 2*BANNER_IMG_SZ,
                       BANNER+ 3*BANNER_IMG_SZ,
                       BANNER+ 4*BANNER_IMG_SZ,
                       BANNER+ 3*BANNER_IMG_SZ,
                       BANNER+ 2*BANNER_IMG_SZ,
                       BANNER+ 1*BANNER_IMG_SZ,
                       BANNER+ 0*BANNER_IMG_SZ,
                       BANNER+ 1*BANNER_IMG_SZ,
                       BANNER+ 2*BANNER_IMG_SZ,
                       BANNER+ 3*BANNER_IMG_SZ,
                       BANNER+ 4*BANNER_IMG_SZ,
                       BANNER+ 3*BANNER_IMG_SZ,
                       BANNER+ 2*BANNER_IMG_SZ,
                       BANNER+ 1*BANNER_IMG_SZ,
                       BANNER+ 0*BANNER_IMG_SZ,
                       BANNER+ 1*BANNER_IMG_SZ,
                       BANNER+ 2*BANNER_IMG_SZ,
                       BANNER+ 3*BANNER_IMG_SZ,
                       BANNER+ 4*BANNER_IMG_SZ,
                       BANNER+ 3*BANNER_IMG_SZ,
                       BANNER+ 2*BANNER_IMG_SZ,
                       BANNER+ 1*BANNER_IMG_SZ,
                       BANNER+ 0*BANNER_IMG_SZ,
                       BANNER+ 1*BANNER_IMG_SZ};
#endif

static vu32 CardInserted = 0;
static vu32 SmartCardStatus = 0;
extern SC_ATR SC_A2R;

/*------------------------------ Menu level 4 -------------------------------*/

/*------------------------------ Menu level 3 -------------------------------*/

struct sMenuItem STOPMenuItems[] = {{"    Exit: EXTI      ", EnterSTOPMode_EXTI, IdleFunc},
                                    {"  Exit: RTC Alarm   ", EnterSTOPMode_RTCAlarm, IdleFunc},
                                    {"       Return       ", ReturnFunc, IdleFunc}};
struct sMenu STOPMenu = {"     STOP Mode      ", STOPMenuItems, countof(STOPMenuItems)};

struct sMenuItem STANDBYMenuItems[] = {{"  Exit: Wakeup Pin  ", EnterSTANDBYMode_WAKEUP, IdleFunc},
                                       {"  Exit: RTC Alarm   ", EnterSTANDBYMode_RTCAlarm, IdleFunc},
                                       {"       Return       ", ReturnFunc, IdleFunc}};
struct sMenu STANDBYMenu = {"   STANDBY Mode     ", STANDBYMenuItems, countof(STANDBYMenuItems)};


struct sMenuItem SettingTimeMenuItems[] = { {"       Adjust       ", Time_Adjust, IdleFunc},
                                            {"        Show        ", Time_Show, IdleFunc},
                                            {"       Return       ", ReturnFunc, IdleFunc}};
struct sMenu TimeMenu = {"        Time        ", SettingTimeMenuItems, countof(SettingTimeMenuItems)};

struct sMenuItem SettingDateMenuItems[] = { {"       Adjust       ", Date_Adjust, IdleFunc},
                                            {"        Show        ", Date_Show, IdleFunc},
                                            {"       Return       ", ReturnFunc, IdleFunc}};
struct sMenu DateMenu = {"        Date        ", SettingDateMenuItems, countof(SettingDateMenuItems)};

struct sMenuItem SettingAlarmMenuItems[] = { {"       Adjust       ", Alarm_Adjust, IdleFunc},
                                             {"        Show        ", Alarm_Show, IdleFunc},
                                             {"       Return       ", ReturnFunc, IdleFunc}};
struct sMenu AlarmMenu = {"        Alarm       ", SettingAlarmMenuItems, countof(SettingAlarmMenuItems)};

/*------------------------------ Menu level 2 -------------------------------*/

struct sMenuItem AboutMenuItems[] = {{"       About        ", AboutFunc, IdleFunc},
                                     {"       Return       ", ReturnFunc, IdleFunc}};
struct sMenu AboutMenu = {"       About        ", AboutMenuItems, countof(AboutMenuItems)};

struct sMenuItem HelpMenuItems[] = {{"        Help        ", HelpFunc, IdleFunc},
                                    {"       Return       ", ReturnFunc, IdleFunc}};
struct sMenu HelpMenu = {"        Help        ", HelpMenuItems, countof(HelpMenuItems)};

struct sMenuItem TempSensorMenuItems[] = {{"    Temperature     ", Thermometer_Temperature, IdleFunc},
                                          {"       Return       ", ReturnFunc, IdleFunc}};
struct sMenu TempSensorMenu = {"    Thermometer     ", TempSensorMenuItems, countof(TempSensorMenuItems)};


struct sMenuItem SmartCardMenuItems[] = {{"     Smart Card     ", SmartCard_Start, IdleFunc},
                                         {"       Return       ", ReturnFunc, IdleFunc}};
struct sMenu SmartCardMenu = {"Smart Card Interface", SmartCardMenuItems, countof(SmartCardMenuItems)};


struct sMenuItem LowPowerMenuItems[] = {{"        STOP        ", IdleFunc, IdleFunc, &STOPMenu},
                                        {"       STANDBY      ", IdleFunc, IdleFunc, &STANDBYMenu},
                                        {"       Return       ", ReturnFunc, IdleFunc}};
struct sMenu LowPowerMenu = {"    Low Power Mode  ", LowPowerMenuItems, countof(LowPowerMenuItems)};


struct sMenuItem WavePlayerMenuItems[] = {{"    Wave Player     ", WavePlayer_StartSpeaker, IdleFunc},
                                          {"       Return       ", ReturnFunc, IdleFunc}};
struct sMenu WavePlayerMenu = {"    Wave Player     ", WavePlayerMenuItems, countof(WavePlayerMenuItems)};

struct sMenuItem AnimMenuItems[] = {{"    STM32 Banner    ", STM32BannerFunc, IdleFunc},
                                    {" STM32 Display Speed", STM32BannerSpeedFunc, IdleFunc},
                                    {"       Return       ", ReturnFunc, IdleFunc}};
struct sMenu AnimMenu = {"      Animation     ", AnimMenuItems, countof(AnimMenuItems)};

struct sMenuItem USBMassMenuItems[] = {{"       Start        ", Mass_Storage_Start, IdleFunc},
                                       {"NAND Physical Format", Mass_Storage_Recovery, IdleFunc},
                                       {"       Return       ", ReturnFunc, IdleFunc}};
struct sMenu USBMassMenu = {"  USB Mass Storage  ", USBMassMenuItems, countof(USBMassMenuItems)};


struct sMenuItem CalendarMenuItems[] = {{"        Time        ", IdleFunc, IdleFunc, &TimeMenu},
                                        {"        Date        ", IdleFunc, IdleFunc, &DateMenu},
                                        {"        Alarm       ", IdleFunc, IdleFunc, &AlarmMenu},
                                        {"        Return      ", ReturnFunc, IdleFunc}};
struct sMenu CalendarMenu = {"       Calendar     ", CalendarMenuItems, countof(CalendarMenuItems)};

struct sMenuItem ProdPresMenuItems[] = {{"       Start        ", ProductPres, IdleFunc},
                                        {"       Return       ", ReturnFunc, IdleFunc}};
struct sMenu ProdPresMenu = {"Product Presentation", ProdPresMenuItems, countof(ProdPresMenuItems)};

/*------------------------------ Menu level 1 -------------------------------*/
struct sMenuItem MainMenuItems[] = {
  {"Product Presentation", IdleFunc, IdleFunc, &ProdPresMenu},
  {"       Calendar     ", IdleFunc, IdleFunc, &CalendarMenu},
  {"      Animation     ", IdleFunc, IdleFunc, &AnimMenu},
  {"    Wave Player     ", IdleFunc, IdleFunc, &WavePlayerMenu},
  {"  USB Mass Storage  ", IdleFunc, IdleFunc, &USBMassMenu},
  {"  Low Power Modes   ", IdleFunc, IdleFunc, &LowPowerMenu},
  {"Smart Card Interface", IdleFunc, IdleFunc, &SmartCardMenu},
  {"    Thermometer     ", IdleFunc, IdleFunc, &TempSensorMenu},
  {"         Help       ", IdleFunc, IdleFunc, &HelpMenu},
  {"        About       ", IdleFunc, IdleFunc, &AboutMenu}};
struct sMenu MainMenu = {"     Main menu      ", MainMenuItems, countof(MainMenuItems)};

/* Private function prototypes -----------------------------------------------*/
static u8 Buffercmp(u8* pBuffer1, u8* pBuffer2, u16 BufferLength);
static void ADC_Config(void);
static u8 HexToAsciiLow(u8 byte);
static u8 HexToAsciiHigh(u8 byte);

/* Private functions ---------------------------------------------------------*/

/*******************************************************************************
* Function Name  : Menu_Init
* Description    : Initializes the navigation menu.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Menu_Init(void)
{
  psCurrentMenu = &MainMenu;
  psPrevMenu[nMenuLevel] = psCurrentMenu;
  psMenuItem = MainMenuItems;
}

/*******************************************************************************
* Function Name  : DisplayMenu
* Description    : Displays the current menu.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void DisplayMenu(void)
{
  u32 Line = 0, index = 0;
  tMenuItem psMenuItem2;

  /* Set the Back Color */
  LCD_SetBackColor(Blue);
  /* Set the Text Color */
  LCD_SetTextColor(White);

  /* Clear the LCD Screen */
  LCD_Clear(White);

  LCD_DisplayStringLine(Line, psCurrentMenu->pszTitle);
  Line += 24;

  /* Set the Back Color */
  LCD_SetBackColor(White);

  /* Set the Text Color */
  LCD_SetTextColor(Blue);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -