From 0260cd7aa2cb8cd9349e9c7c877419c83006145f Mon Sep 17 00:00:00 2001 From: Polarix Date: Fri, 31 Jan 2020 00:11:38 +0800 Subject: [PATCH] 2020-01-31: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BSP代码中提供UC1604C的驱动程序。 订正了GB2312资源文件的编码错误。 删除一些混杂的备份文件。 --- DemoProc/inc/DemoProc.h.bak | 117 ----- DemoProc/inc/DemoResource_ASCII.h.bak | 49 -- DemoProc/inc/DemoResource_GB2312.h | 89 ++-- DemoProc/inc/Resource.h | 5 +- DemoProc/src/DemoProc.c | 73 +-- .../MiniDevCore/BSP/inc/{oled.h => screen.h} | 24 +- .../MiniDevCore/BSP/inc/trigger_flags.h | 6 +- .../MiniDevCore/BSP/inc/uc1604c_softspi.h | 15 + .../MiniDevCore/BSP/src/{oled.c => screen.c} | 49 +- .../MiniDevCore/BSP/src/trigger_flags.c | 7 +- .../MiniDevCore/BSP/src/uc1604c_softspi.c | 237 +++++++++ .../MiniDevCore/DemoProc/src/DemoProc.c | 453 ++++++++++++++++++ 12 files changed, 805 insertions(+), 319 deletions(-) delete mode 100644 DemoProc/inc/DemoProc.h.bak delete mode 100644 DemoProc/inc/DemoResource_ASCII.h.bak rename Transplant/MiniDevCore/BSP/inc/{oled.h => screen.h} (52%) create mode 100644 Transplant/MiniDevCore/BSP/inc/uc1604c_softspi.h rename Transplant/MiniDevCore/BSP/src/{oled.c => screen.c} (84%) create mode 100644 Transplant/MiniDevCore/BSP/src/uc1604c_softspi.c create mode 100644 Transplant/MiniDevCore/DemoProc/src/DemoProc.c diff --git a/DemoProc/inc/DemoProc.h.bak b/DemoProc/inc/DemoProc.h.bak deleted file mode 100644 index 2bb37f1..0000000 --- a/DemoProc/inc/DemoProc.h.bak +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef __INCLUDE_DEMO_PROC_H__ -#define __INCLUDE_DEMO_PROC_H__ -//=======================================================================// -//= Include files. =// -//=======================================================================// -#include -#include -#include "SGUI_Typedef.h" -#include "SGUI_Common.h" -#include "HMI_Engine.h" -#include "DemoActions.h" -#ifdef _SIMPLE_GUI_NON_ASCII_ -#ifdef _SIMPLE_GUI_ENCODE_TEXT_ -#include "DemoResource_UTF8.h" -#else -#include "DemoResource_GB2312.h" -#endif // _SIMPLE_GUI_ENCODE_TEXT_ -#else -#include "DemoResource_ASCII.h" -#endif -#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ -#include "SDKInterface.h" -#endif - -//=======================================================================// -//= Data type definition. =// -//=======================================================================// -// HMI action type -typedef enum -{ - EVENT_ID_UNKNOW = 0, - // User defined action type. - EVENT_ID_KEY_PRESS, - EVENT_ID_TIMER, - EVENT_ID_RTC, - // User defined action above. - EVENT_ID_MAX -}EVENT_ID; - -// HMI event type. -typedef enum -{ - EVENT_TYPE_ANY = 0, - EVENT_TYPE_ACTION, - EVENT_TYPE_DATA, -}EVENT_TYPE; - -enum DEMO_PROC_ACTION_ID -{ - HMI_DEMO_PROC_NO_ACT = 0, - HMI_DEMO_PROC_CONFIRM = 1, - HMI_DEMO_PROC_CANCEL = 2, -}; - -typedef struct -{ - SGUI_UINT16 uiKeyValue; -}KEY_EVENT_DATA; - -typedef struct -{ - SGUI_INT iValue; -}DUMMY_DATA_EVENT_DATA; - -HMI_EVENT_TYPE_DECLARE(KEY_PRESS_EVENT, KEY_EVENT_DATA) -HMI_EVENT_TYPE_DECLARE(DATA_EVENT, DUMMY_DATA_EVENT_DATA); - -//=======================================================================// -//= User Macro definition. =// -//=======================================================================// -#define HMI_SCREEN_ID_DEMO_SCROLLING_TEXT (1001) -#define HMI_SCREEN_ID_DEMO_PAINT_TEXT (1002) -#define HMI_SCREEN_ID_DEMO_LIST (1003) -#define HMI_SCREEN_ID_DEMO_TEXT_NOTICE (1004) -#define HMI_SCREEN_ID_DEMO_BASIC_PAINT (1005) -#define HMI_SCREEN_ID_DEMO_VARIABLE_BOX (1006) -#define HMI_SCREEN_ID_DEMO_REAL_TIME_GRAPH (1007) -#define HMI_SCREEN_ID_DEMO_MENU (1008) - -#define DEMO_HEART_BEAT_INTERVAL_MS (20) - -//=======================================================================// -//= Public variable declaration. =// -//=======================================================================// -/* HMI engine object. */ -extern HMI_ENGINE_OBJECT g_stDemoEngine; -/* Screen display objects. */ -extern HMI_SCREEN_OBJECT g_stHMIDemo_ScrollingText; -extern HMI_SCREEN_OBJECT g_stHMIDemo_List; -extern HMI_SCREEN_OBJECT g_stHMIDemo_Notice; -extern HMI_SCREEN_OBJECT g_stHMIDemo_RTCNotice; -extern HMI_SCREEN_OBJECT g_stHMIDemo_VariableBox; -extern HMI_SCREEN_OBJECT g_stHMIDemo_RealtimeGraph; -extern HMI_SCREEN_OBJECT g_stHMIDemo_Menu; -extern HMI_SCREEN_OBJECT g_stHMIDemo_BasicPaint; -extern HMI_SCREEN_OBJECT g_stHMIDemo_TextPaint; -//=======================================================================// -//= Function declare. =// -//=======================================================================// -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ -HMI_ENGINE_RESULT InitializeHMIEngineObj(void); -void DemoMainProcess(void); - -bool SysTickTimerTriggered(void); -bool RTCTimerTriggered(void); -bool UserEventTriggered(void); - -void SysTickTimerEnable(bool bEnable); -void RTCTimerEnable(bool bEnable); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif // __INCLUDE_DEMO_PROC_H__ diff --git a/DemoProc/inc/DemoResource_ASCII.h.bak b/DemoProc/inc/DemoResource_ASCII.h.bak deleted file mode 100644 index dbe6417..0000000 --- a/DemoProc/inc/DemoResource_ASCII.h.bak +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _INCLUDE_DEMO_RESOURCE_UTF8_H_ -#define _INCLUDE_DEMO_RESOURCE_UTF8_H_ - -/* Screen 1: List Components. */ -/* Start screen with list. */ -#define SCR1_TITLE ("List Components") -#define SCR1_LIST_ITEM1 ("Basic Paint") -#define SCR1_LIST_ITEM2 ("Text") -#define SCR1_LIST_ITEM3 ("Variable box") -#define SCR1_LIST_ITEM4 ("Realtime graph") -#define SCR1_LIST_ITEM5 ("Menu") -#define SCR1_LIST_ITEM6 ("Notice box") - -/* Screen 2: Basic Paint*/ -/* No text used. */ - -/* Screen 3: Text demo*/ -/* For internal font resources. */ -#define SCR3_TEXT_MIN_NUM ("1+2+8/4*5=13") -#define SCR3_TEXT_INNER_8 ("Hello Simple GUI.") -#define SCR3_TEXT_INNER_12 ("Welcome!") -#define SCR3_TEXT_INNER_16 ("I don't like this.") -#define SCR3_TEXT_MULTILINE_12 ("Multiline demo text with 12-pixel font.") - -/* Screen 4: Variable box. */ -#define SCR4_VAR_BOX_TITLE ("Variable box") -#define SCR4_HELP_NOTICE ("Press TAB to switch focus.\nUp&Down to change value。\nSend \"SPACE\" to continue.") - -/* Screen 5: Realtime graph. */ -#define SCR5_RT_GRAPH_TITLE ("Realtime graph") - -/* Screen 6: Variable box. */ -#define SCR6_MENU_ITEM1 ("Item 1") -#define SCR6_MENU_ITEM2 ("Item 2") -#define SCR6_MENU_ITEM3 ("Item 3") -#define SCR6_MENU_ITEM4 ("Item 4") -#define SCR6_MENU_ITEM5 ("Item 5") -#define SCR6_MENU_ITEM6 ("Item 6") -#define SCR6_MENU_ITEM7 ("Item 7") -#define SCR6_MENU_ITEM8 ("Item 8") -#define SCR6_SUB_MENU_ITEM1 ("Sub 1") -#define SCR6_SUB_MENU_ITEM2 ("Sub 2") -#define SCR6_SUB_MENU_ITEM3 ("Sub 3") -#define SCR6_SUB_MENU_ITEM4 ("Sub 4") - -/* Screen 7: Notice box. */ -#define SCR7_NOTICE_TEXT ("This is a test notice.") - -#endif // _INCLUDE_DEMO_RESOURCE_UTF8_H_ diff --git a/DemoProc/inc/DemoResource_GB2312.h b/DemoProc/inc/DemoResource_GB2312.h index ed074e9..0bcc0f1 100644 --- a/DemoProc/inc/DemoResource_GB2312.h +++ b/DemoProc/inc/DemoResource_GB2312.h @@ -1,56 +1,49 @@ -#ifndef __INCLUDE_DEMO_RESOURCE_UTF8_H__ -#define __INCLUDE_DEMO_RESOURCE_UTF8_H__ +#ifndef _INCLUDE_DEMO_RESOURCE_UTF8_H_ +#define _INCLUDE_DEMO_RESOURCE_UTF8_H_ -#if defined ( __CC_ARM ) - //#pragma diag_suppress 177 // Disabled "declared but never referenced." warning. -#endif +/* Screen 1: List Components. */ +/* Start screen with list. */ +#define SCR1_TITLE ("б") +#define SCR1_LIST_ITEM1 ("ͼӿ") +#define SCR1_LIST_ITEM2 ("ı") +#define SCR1_LIST_ITEM3 ("") +#define SCR1_LIST_ITEM4 ("ʵʱ") +#define SCR1_LIST_ITEM5 ("˵") +#define SCR1_LIST_ITEM6 ("Ϣ") +/* Screen 2: Basic Paint*/ +/* No text used. */ -/* Screen 1: Multiple lines text. */ -/* Start screen scroll text. */ -#define DEMO_START_NOTICE (\ -" ӭSimpleGUIʾ̣ʾGUIͼHMIģͽʹ÷\ -Լʾʹôģ̲ʽΪ115200/N/8/1ÿ\ -ֽģһμ̶οDemoActions.hļ\n\ - Ϳո(0x0020)ʼʾ"\ -) +/* Screen 3: Text demo*/ +/* For internal font resources. */ +#define SCR3_TEXT_MIN_NUM ("1+2+8/4*5=13") +#define SCR3_TEXT_INNER_8 ("Hello Simple GUI.") +#define SCR3_TEXT_INNER_12 ("Welcome!") +#define SCR3_TEXT_EXTEN_12 ("Ҳϲ") +#define SCR3_TEXT_MULTILINE_12 ("12صĶıʾ") -/* Screen 2: List*/ -/* Demo list title. */ -#define DEMO_LIST_TITLE ("б") -/* Enumed list item choice type. */ -#define DEMO_LIST_ITEM_NOTICE_TEXT ("Ϣ") -#define DEMO_LIST_ITEM_NOTICE_TIME ("ϵͳʱ") -#define DEMO_LIST_ITEM_ENUM_VALUE1 ("ö1") -#define DEMO_LIST_ITEM_ENUM_VALUE2 ("ö2") -#define DEMO_LIST_ITEM_ENUM_VALUE3 ("ö3") +/* Screen 4: Variable box. */ +#define SCR4_VAR_BOX_TITLE ("") +#define SCR4_HELP_NOTICE ("Press TAB to switch focus.\nUp&Down to change value\nSend \"SPACE\" to continue.") +/* Screen 5: Realtime graph. */ +#define SCR5_RT_GRAPH_TITLE ("Realtime graph") -/* List items data. Sign ListText List item type List value Decimal point Enumed text list */ -/* init. min. max. init. min. max. */ -#define DEMO_LIST_ITEM_0 {0, "б", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} -#define DEMO_LIST_ITEM_1 {1, "öб", LIST_ITEM_ENUM, {0, 0, 1 }, {0, 0, 0 }, s_arrszNoticeType} -#define DEMO_LIST_ITEM_2 {2, "б", LIST_ITEM_DIGIT, {0, -50, 50 }, {0, 0, 3 }, NULL} -#define DEMO_LIST_ITEM_3 {3, "Сб", LIST_ITEM_DIGIT, {1, -50, 50 }, {2, 0, 5 }, NULL} -#define DEMO_LIST_ITEM_4 {4, "ֵļб", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} -#define DEMO_LIST_ITEM_5 {5, "༭", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} -#define DEMO_LIST_ITEM_6 {6, "ʵʱ", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} -#define DEMO_LIST_ITEM_7 {7, "Ŀ1", LIST_ITEM_NORMAL, {0, 0, 0 }, {0, 0, 0 }, NULL} -#define DEMO_LIST_ITEM_8 {8, "Ŀ2", LIST_ITEM_ENUM, {0, 0, 2 }, {0, 0, 0 }, s_arrszEnumedValue} -#define DEMO_LIST_ITEM_9 {9, "Ŀ3", LIST_ITEM_DIGIT, {0, -50, 50 }, {0, 0, 3 }, NULL} +/* Screen 6: Variable box. */ +#define SCR6_MENU_ITEM1 ("Item 1") +#define SCR6_MENU_ITEM2 ("Item 2") +#define SCR6_MENU_ITEM3 ("Item 3") +#define SCR6_MENU_ITEM4 ("Item 4") +#define SCR6_MENU_ITEM5 ("Item 5") +#define SCR6_MENU_ITEM6 ("Item 6") +#define SCR6_MENU_ITEM7 ("Item 7") +#define SCR6_MENU_ITEM8 ("Item 8") +#define SCR6_SUB_MENU_ITEM1 ("Sub 1") +#define SCR6_SUB_MENU_ITEM2 ("Sub 2") +#define SCR6_SUB_MENU_ITEM3 ("Sub 3") +#define SCR6_SUB_MENU_ITEM4 ("Sub 4") -/* Screen 3: Text notice box. */ -/* List notice text format. */ -#define DEMO_LIST_NOTICE_TEXT_FMT ("ѡб%u.") +/* Screen 7: Notice box. */ +#define SCR7_NOTICE_TEXT ("һϢʾûͼꡣ") -/* Screen 4: RTC notice box. */ -#define DEMO_RTC_NOTICE_TEXT_FMT ("ϵͳʱ\n%04u-%02u-%02u\n%02u:%02u:%02u") - -/* Screen 5: Variable box. */ -#define DEMO_VARIABLE_BOX_TITLE ("ֵ/ı༭ʾ") -#define DEMO_VARIABLE_BOX_HELPER ("TABл༭\n¼ͷֵ\nҼͷַ\nո") - -/* Others */ -#define DEMO_TEST_TEXT ("") - -#endif // __INCLUDE_DEMO_RESOURCE_UTF8_H__ +#endif // _INCLUDE_DEMO_RESOURCE_UTF8_H_ diff --git a/DemoProc/inc/Resource.h b/DemoProc/inc/Resource.h index 119a840..ffc844a 100644 --- a/DemoProc/inc/Resource.h +++ b/DemoProc/inc/Resource.h @@ -2,8 +2,9 @@ #define _INCLUDE_RESOURCE_H_ #include "SGUI_Typedef.h" -//#include "DemoResource_UTF8.h" -#include "DemoResource_ASCII.h" +#include "DemoResource_UTF8.h" +//#include "DemoResource_ASCII.h" +//#include "DemoResource_GB2312.h" extern const SGUI_FONT_RES GB2312_FZXS12; diff --git a/DemoProc/src/DemoProc.c b/DemoProc/src/DemoProc.c index 8f5962b..e5178e9 100644 --- a/DemoProc/src/DemoProc.c +++ b/DemoProc/src/DemoProc.c @@ -13,7 +13,7 @@ #include "SDKInterface.h" #include "SGUI_FontResource.h" #else -#include "oled.h" +#include "screen.h" #include "usart.h" #include "rtc.h" #include "base_timer.h" @@ -38,10 +38,6 @@ HMI_SCREEN_OBJECT* g_arrpstScreenObjs[] = }; HMI_ENGINE_OBJECT g_stDemoEngine; -#ifndef _SIMPLE_GUI_IN_VIRTUAL_SDK_ -static unsigned int s_uiKeyValue; -#endif - //=======================================================================// //= Static function declare. =// //=======================================================================// @@ -50,7 +46,7 @@ static void RTCEventProc(void); static void SysTickTimerEventProc(void); #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ static bool CheckEventFlag(ENV_FLAG_INDEX eIndex); -#endif // _SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ +#endif //_SIMPLE_GUI_IN_VIRTUAL_SDK_ //=======================================================================// //= Function define. =// @@ -93,14 +89,7 @@ HMI_ENGINE_RESULT InitializeHMIEngineObj(void) g_stDeviceInterface.fnClear = SGUI_SDK_ClearDisplay; g_stDeviceInterface.fnSyncBuffer = SGUI_SDK_RefreshDisplay; #else - /* Initialize display size. */ - g_stDeviceInterface.stSize.iWidth = 128; - g_stDeviceInterface.stSize.iHeight = 64; - /* Initialize interface object. */ - g_stDeviceInterface.fnSetPixel = OLED_SetPixel; - g_stDeviceInterface.fnGetPixel = OLED_GetPixel; - g_stDeviceInterface.fnClear = OLED_ClearDisplay; - g_stDeviceInterface.fnSyncBuffer = OLED_RefreshScreen; + #error Add screen device object initialize process here. #endif do { @@ -246,7 +235,7 @@ void KeyPressEventProc(void) #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ stEvent.Data.uiKeyValue = SGUI_SDK_GetKeyEventData(); #else - stEvent.Data.uiKeyValue = s_uiKeyValue; + #error Add key event data prepare process here. #endif // Post key press event. HMI_ProcessEvent((HMI_EVENT_BASE*)(&stEvent)); @@ -318,26 +307,13 @@ void RTCEventProc(void) /*****************************************************************************/ bool SysTickTimerTriggered(void) { -#ifndef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - bool bIsTriggered; -#endif /*----------------------------------*/ /* Process */ /*----------------------------------*/ #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ return CheckEventFlag(ENV_FLAG_IDX_SDK_TIM_EVENT); #else - // Dummy sys-tick Timer interrupt triggered process. - bIsTriggered = BaseTimerIsTrigger(); - if(true == bIsTriggered) - { - BaseTimerTriggerReset(); - } - - return bIsTriggered; + #error Add sys-tick timer trigger process here. #endif } @@ -350,26 +326,13 @@ bool SysTickTimerTriggered(void) /*****************************************************************************/ bool RTCTimerTriggered(void) { -#ifndef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - bool bIsTriggered; -#endif /*----------------------------------*/ /* Process */ /*----------------------------------*/ #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ return CheckEventFlag(ENV_FLAG_IDX_SDK_RTC_EVENT); #else - // RTC interrupt triggered process. - bIsTriggered = RTCTimerIsTrigger(); - if(true == bIsTriggered) - { - RTCTimerTriggerReset(); - } - - return bIsTriggered; + #error Add RTC timer trigger process here. #endif } @@ -382,27 +345,13 @@ bool RTCTimerTriggered(void) /*****************************************************************************/ bool UserEventTriggered(void) { -#ifndef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - bool bIsTriggered; - -#endif /*----------------------------------*/ /* Process */ /*----------------------------------*/ #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ return CheckEventFlag(ENV_FLAG_IDX_SDK_KEY_EVENT); #else - // User event triggered process. - bIsTriggered = UsartIsReceived(); - if(true == bIsTriggered) - { - s_uiKeyValue = GetReceivedCode(); - UsartTriggerReset(); - } - return bIsTriggered; + #error Add user event trigger process here. #endif } @@ -422,8 +371,7 @@ void SysTickTimerEnable(bool bEnable) #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ (void)SGUI_SDK_ConfigHearBeatTimer(bEnable?DEMO_HEART_BEAT_INTERVAL_MS:0); #else - // Add Dummy sys-tick timer interrupt enable change operation here. - BASE_TIMER_ActiveInterrupt(TIM3, bEnable); + #error Add sys-tick timer enable/disable process here. #endif } @@ -444,10 +392,7 @@ void RTCTimerEnable(bool bEnable) #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ (void)SGUI_SDK_EnableRTCInterrupt(bEnable); #else - // Add RTC interrupt enable change operation here. - RTC_WaitForSynchro(); - RTC_ITConfig(RTC_IT_SEC, bEnable?ENABLE:DISABLE); - RTC_WaitForLastTask(); + #error Add RTC timer enable/disable process here. #endif } diff --git a/Transplant/MiniDevCore/BSP/inc/oled.h b/Transplant/MiniDevCore/BSP/inc/screen.h similarity index 52% rename from Transplant/MiniDevCore/BSP/inc/oled.h rename to Transplant/MiniDevCore/BSP/inc/screen.h index 5b92938..93da3df 100644 --- a/Transplant/MiniDevCore/BSP/inc/oled.h +++ b/Transplant/MiniDevCore/BSP/inc/screen.h @@ -1,5 +1,5 @@ -#ifndef __INCLUDE_OLED_H__ -#define __INCLUDE_OLED_H__ +#ifndef _INCLUDE_SCREEN_H__ +#define _INCLUDE_SCREEN_H__ #define LCD_SIZE_WIDTH (128) #define LCD_SIZE_HEIGHT (64) @@ -8,20 +8,20 @@ typedef enum { - OLED_COLOR_BKG = 0, - OLED_COLOR_FRG = 1, - OLED_COLOR_TRS = 2, -}OLED_COLOR; + SCREEN_COLOR_BKG = 0, + SCREEN_COLOR_FRG = 1, + SCREEN_COLOR_TRS = 2, +}SCREEN_COLOR; //Common operation #define SET_PAGE_BIT(PAGE, Bit) ((PAGE) = (PAGE) | (0x01 << (Bit))) #define CLR_PAGE_BIT(PAGE, Bit) ((PAGE) = (PAGE) & (~(0x01 << (Bit)))) #define GET_PAGE_BIT(PAGE, Bit) ((((PAGE) & (0x01 << (Bit)))>0)?1:0) -void OLED_SetPixel(int iPosX, int iPosY, int iColor); -int OLED_GetPixel(int iPosX, int iPosY); -void OLED_Initialize(void); -void OLED_ClearDisplay(void); -void OLED_RefreshScreen(void); +void SCREEN_SetPixel(int iPosX, int iPosY, int iColor); +int SCREEN_GetPixel(int iPosX, int iPosY); +void SCREEN_Initialize(void); +void SCREEN_ClearDisplay(void); +void SCREEN_RefreshScreen(void); -#endif /* __INCLUDE_OLED_H__ */ +#endif /* _INCLUDE_SCREEN_H__ */ diff --git a/Transplant/MiniDevCore/BSP/inc/trigger_flags.h b/Transplant/MiniDevCore/BSP/inc/trigger_flags.h index 5598f55..7c78c85 100644 --- a/Transplant/MiniDevCore/BSP/inc/trigger_flags.h +++ b/Transplant/MiniDevCore/BSP/inc/trigger_flags.h @@ -17,8 +17,8 @@ typedef union typedef struct { KEY_VALUE unKeyValue; - bool bIsTriggered; - bool bHalfRev; + __IO bool bIsTriggered; + __IO bool bHalfRev; }USART_INPUT; @@ -35,5 +35,7 @@ void RTCInterruptProc(uint32_t uiTimeStamp); bool RTCTimerIsTrigger(void); void RTCTimerTriggerReset(void); +void KeyEventProc(uint16_t uiKeyCode, KEY_EVENT eEvent); + #endif diff --git a/Transplant/MiniDevCore/BSP/inc/uc1604c_softspi.h b/Transplant/MiniDevCore/BSP/inc/uc1604c_softspi.h new file mode 100644 index 0000000..8209839 --- /dev/null +++ b/Transplant/MiniDevCore/BSP/inc/uc1604c_softspi.h @@ -0,0 +1,15 @@ +#ifndef _INCLUDE_UC1604C_SOFT_SPI_H_ +#define _INCLUDE_UC1604C_SOFT_SPI_H_ +////////////////////////////////////////////////////////////////////////////////// +// include +////////////////////////////////////////////////////////////////////////////////// +#include + +#define COLUMN_MAX 192 +#define PAGE_MAX 8 + +void UC1604C_Initialize(void); +void UC1604C_SetPosition(uint8_t uiColumn, uint8_t uiPage); +void UC1604C_WriteData(uint8_t uiData); +void UC1604C_Fill(uint8_t bmp_dat); +#endif //_INCLUDE_UC1604C_SOFT_SPI_H_ diff --git a/Transplant/MiniDevCore/BSP/src/oled.c b/Transplant/MiniDevCore/BSP/src/screen.c similarity index 84% rename from Transplant/MiniDevCore/BSP/src/oled.c rename to Transplant/MiniDevCore/BSP/src/screen.c index 0090610..427d371 100644 --- a/Transplant/MiniDevCore/BSP/src/oled.c +++ b/Transplant/MiniDevCore/BSP/src/screen.c @@ -1,5 +1,6 @@ -#include "ssd1306_softspi.h" -#include "oled.h" +//#include "ssd1306_softspi.h" +#include "uc1604c_softspi.h" +#include "screen.h" static struct { @@ -13,11 +14,11 @@ static struct uint16_t auiDisplayCache[LCD_SIZE_WIDTH][LCD_SIZE_PAGES]; }s_stLCDBuffer; -static void OLED_UpdateChangedBufferAreaRecord(uint8_t uiPageIndex, uint8_t uiColumnIndex); -static void OLED_ClearDisplayBuffer(void); +static void SCREEN_UpdateChangedBufferAreaRecord(uint8_t uiPageIndex, uint8_t uiColumnIndex); +static void SCREEN_ClearDisplayBuffer(void); /*************************************************************************/ -/** Function Name: OLED_UpdateChangedBufferAreaRecord **/ +/** Function Name: SCREEN_UpdateChangedBufferAreaRecord **/ /** Purpose: Check changed area recodr and update. **/ /** Resources: None. **/ /** Params: **/ @@ -26,7 +27,7 @@ static void OLED_ClearDisplayBuffer(void); /** Return: None. **/ /** Limitation: None. **/ /*************************************************************************/ -void OLED_UpdateChangedBufferAreaRecord(uint8_t uiPageIndex, uint8_t uiColumnIndex) +void SCREEN_UpdateChangedBufferAreaRecord(uint8_t uiPageIndex, uint8_t uiColumnIndex) { // Check and set page and column index. if(uiPageIndex < s_stLCDBuffer.stUpdateArea.uiStartPageIndex) @@ -55,7 +56,7 @@ void OLED_UpdateChangedBufferAreaRecord(uint8_t uiPageIndex, uint8_t uiColumnInd /** Return: None. **/ /** Limitation: None. **/ /*************************************************************************/ -void OLED_ClearDisplayBuffer(void) +void SCREEN_ClearDisplayBuffer(void) { uint16_t uiCurrentPageIndex, uiCurrentColumnIndex; @@ -73,7 +74,7 @@ void OLED_ClearDisplayBuffer(void) } /*************************************************************************/ -/** Function Name: OLED_SetPixel **/ +/** Function Name: SCREEN_SetPixel **/ /** Purpose: Set a pixel color or draw a point. **/ /** Resources: None. **/ /** Params: **/ @@ -83,15 +84,15 @@ void OLED_ClearDisplayBuffer(void) /** Return: None. **/ /** Limitation: None. **/ /*************************************************************************/ -void OLED_SetPixel(int iPosX, int iPosY, int iColor) +void SCREEN_SetPixel(int iPosX, int iPosY, int iColor) { // Operating position check. if((iPosX < LCD_SIZE_WIDTH) && (iPosY < LCD_SIZE_HEIGHT)) { // Check and set page and column index. - OLED_UpdateChangedBufferAreaRecord(iPosY/8, iPosX); + SCREEN_UpdateChangedBufferAreaRecord(iPosY/8, iPosX); // Set point data. - if(OLED_COLOR_FRG == iColor) + if(SCREEN_COLOR_FRG == iColor) { SET_PAGE_BIT(s_stLCDBuffer.auiDisplayCache[iPosX][iPosY/8], iPosY%8); } @@ -103,7 +104,7 @@ void OLED_SetPixel(int iPosX, int iPosY, int iColor) } /*************************************************************************/ -/** Function Name: OLED_GetPixel **/ +/** Function Name: SCREEN_GetPixel **/ /** Purpose: Get a pixel from buffer. **/ /** Resources: None. **/ /** Params: **/ @@ -112,7 +113,7 @@ void OLED_SetPixel(int iPosX, int iPosY, int iColor) /** Return: None. **/ /** Limitation: None. **/ /*************************************************************************/ -int OLED_GetPixel(int iPosX, int iPosY) +int SCREEN_GetPixel(int iPosX, int iPosY) { // Operating position check. if((iPosX < LCD_SIZE_WIDTH) && (iPosY < LCD_SIZE_HEIGHT)) @@ -126,17 +127,17 @@ int OLED_GetPixel(int iPosX, int iPosY) } /*************************************************************************/ -/** Function Name: OLED_Initialize **/ +/** Function Name: SCREEN_Initialize **/ /** Purpose: Simple delay function for KS0108 controler. **/ /** Resources: None. **/ /** Params: None. **/ /** Return: None. **/ /** Limitation: None. **/ /*************************************************************************/ -void OLED_Initialize(void) +void SCREEN_Initialize(void) { - SSD1306_Initialize(); - OLED_ClearDisplayBuffer(); + UC1604C_Initialize(); + SCREEN_ClearDisplayBuffer(); } /*************************************************************************/ @@ -147,7 +148,7 @@ void OLED_Initialize(void) /** Return: None. **/ /** Limitation: None. **/ /*************************************************************************/ -void OLED_RefreshScreen(void) +void SCREEN_RefreshScreen(void) { uint8_t uiChangedPageIndex, uiChangedColumnIndex; @@ -164,12 +165,12 @@ void OLED_RefreshScreen(void) while(uiChangedPageIndex <= s_stLCDBuffer.stUpdateArea.uiEndPageIndex) { uiChangedColumnIndex = s_stLCDBuffer.stUpdateArea.uiStartColumnIndex; - SSD1306_SetPosition(s_stLCDBuffer.stUpdateArea.uiStartColumnIndex, uiChangedPageIndex); + UC1604C_SetPosition(s_stLCDBuffer.stUpdateArea.uiStartColumnIndex, uiChangedPageIndex); // Loop for each changed column data in current page. while(uiChangedColumnIndex <= s_stLCDBuffer.stUpdateArea.uiEndColumnIndex) { // Write data to screen controler. - SSD1306_WriteData(s_stLCDBuffer.auiDisplayCache[uiChangedColumnIndex][uiChangedPageIndex]); + UC1604C_WriteData(s_stLCDBuffer.auiDisplayCache[uiChangedColumnIndex][uiChangedPageIndex]); uiChangedColumnIndex++; } uiChangedPageIndex++; @@ -183,16 +184,16 @@ void OLED_RefreshScreen(void) } /*************************************************************************/ -/** Function Name: OLED_ClearDisplay **/ +/** Function Name: SCREEN_ClearDisplay **/ /** Purpose: Clean display buffer. **/ /** Resources: None. **/ /** Params: None. **/ /** Return: None. **/ /** Limitation: None. **/ /*************************************************************************/ -void OLED_ClearDisplay(void) +void SCREEN_ClearDisplay(void) { - OLED_ClearDisplayBuffer(); - SSD1306_Fill(0x00); + SCREEN_ClearDisplayBuffer(); + UC1604C_Fill(0x00); } diff --git a/Transplant/MiniDevCore/BSP/src/trigger_flags.c b/Transplant/MiniDevCore/BSP/src/trigger_flags.c index 8a03202..c379e3a 100644 --- a/Transplant/MiniDevCore/BSP/src/trigger_flags.c +++ b/Transplant/MiniDevCore/BSP/src/trigger_flags.c @@ -1,4 +1,5 @@ #include "trigger_flags.h" +#include static bool s_bBaseTimerTrigger = false; static bool s_bRTCTimerTrigger = false; @@ -27,7 +28,11 @@ void USARTReceiveProc(USART_INT_REASON eReason, uint8_t uiReceiveData) void KeyEventProc(uint16_t uiKeyCode, KEY_EVENT eEvent) { - + if(KEY_EVENT_DOWN == eEvent) + { + printf("Key 0x%02X is down.", uiKeyCode); + printf("\r\n"); + } } void TimerInterruptProc(void) diff --git a/Transplant/MiniDevCore/BSP/src/uc1604c_softspi.c b/Transplant/MiniDevCore/BSP/src/uc1604c_softspi.c new file mode 100644 index 0000000..bcafb68 --- /dev/null +++ b/Transplant/MiniDevCore/BSP/src/uc1604c_softspi.c @@ -0,0 +1,237 @@ +#include "uc1604c_softspi.h" +#include +#include +#include + +#define SPI_UC1604C_CTRL SPI2 +#define SPI_UC1604C_APBxClock_FUN RCC_APB1PeriphClockCmd +#define SPI_UC1604C_CLK RCC_APB1Periph_SPI2 + +#define SPI_UC1604C_GPIO_APBxClock_FUN RCC_APB2PeriphClockCmd +#define SPI_UC1604C_GPIO_CLK RCC_APB2Periph_GPIOD +#define SPI_UC1604C_GPIO_PORT GPIOD + +//RST +#define SPI_UC1604C_RST_PIN GPIO_Pin_1 +#define SPI_UC1604C_RST_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_RST_PIN) +#define SPI_UC1604C_RST_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_RST_PIN) +//DC +#define SPI_UC1604C_DC_PIN GPIO_Pin_0 +#define SPI_UC1604C_DC_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_DC_PIN) +#define SPI_UC1604C_DC_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_DC_PIN) +#define SPI_UC1604C_MODE_CMD() SPI_UC1604C_DC_LOW() +#define SPI_UC1604C_MODE_DAT() SPI_UC1604C_DC_HIGH() + +//CS(NSS) +#define SPI_UC1604C_CS_PIN GPIO_Pin_2 +#define SPI_UC1604C_CS_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_CS_PIN) +#define SPI_UC1604C_CS_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_CS_PIN) +#define SPI_UC1604C_CS_ENABLE() SPI_UC1604C_CS_LOW() +#define SPI_UC1604C_CS_DISABLE() SPI_UC1604C_CS_HIGH() + +//SCLK +#define SPI_UC1604C_SCLK_PIN GPIO_Pin_4 +#define SPI_UC1604C_SCLK_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_SCLK_PIN) +#define SPI_UC1604C_SCLK_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_SCLK_PIN) +//MOSI +#define SPI_UC1604C_MOSI_PIN GPIO_Pin_3 +#define SPI_UC1604C_MOSI_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_MOSI_PIN) +#define SPI_UC1604C_MOSI_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_MOSI_PIN) + +static void UC1604C_InitializeGPIO(void); +static void UC1604C_WriteByte(uint8_t uiData); +static void UC1604C_WriteCommand(uint8_t uiCommand); + +void UC1604C_Delay(uint32_t uiDelay) +{ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + uint32_t uiDelayTime; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + while(uiDelay--) + { + uiDelayTime = 1000; + while(--uiDelayTime); + } +} + +/*****************************************************************************/ +/** Function Name: UC1604C_InitializeGPIO. **/ +/** Purpose: Initialize GPIO for SPI Pin. **/ +/** Params: None. **/ +/** Return: None. **/ +/*****************************************************************************/ +void UC1604C_InitializeGPIO(void) +{ + // Initialize data structure. + GPIO_InitTypeDef GPIO_InitStructure; + // Initialize GPIO. + SPI_UC1604C_GPIO_APBxClock_FUN(SPI_UC1604C_GPIO_CLK, ENABLE); + // Enable GPIO. + GPIO_InitStructure.GPIO_Pin = SPI_UC1604C_RST_PIN|SPI_UC1604C_DC_PIN|SPI_UC1604C_CS_PIN|SPI_UC1604C_SCLK_PIN|SPI_UC1604C_MOSI_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_Init(SPI_UC1604C_GPIO_PORT, &GPIO_InitStructure); + GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_DC_PIN|SPI_UC1604C_CS_PIN|SPI_UC1604C_SCLK_PIN|SPI_UC1604C_MOSI_PIN); + GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_RST_PIN); +} + +/*****************************************************************************/ +/** Function Name: UC1604C_WriteByte. **/ +/** Purpose: Simulate SPI communication timing to write a byte to **/ +/** LCD controller. **/ +/** Params: **/ +/** @ uiData: Byte will be write. **/ +/** Return: None. **/ +/*****************************************************************************/ +void UC1604C_WriteByte(uint8_t uiByte) +{ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + uint16_t i; + uint8_t uiSendByte; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + uiSendByte = uiByte; + SPI_UC1604C_CS_LOW(); + for(i=0;i<8;i++) + { + if(uiSendByte & 0x80) + { + SPI_UC1604C_MOSI_HIGH(); + } + else + { + SPI_UC1604C_MOSI_LOW(); + } + SPI_UC1604C_SCLK_LOW(); + SPI_UC1604C_SCLK_HIGH(); + + uiSendByte <<= 1; + } + SPI_UC1604C_CS_HIGH(); +} + +/*****************************************************************************/ +/** Function Name: UC1604C_WriteData. **/ +/** Purpose: Write a data byte to OLED coltroler. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ uiData: One byte data will be write. **/ +/** Return: None. **/ +/*****************************************************************************/ +void UC1604C_WriteData(uint8_t uiData) +{ + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + SPI_UC1604C_MODE_DAT(); + UC1604C_WriteByte(uiData); +} + +/*****************************************************************************/ +/** Function Name: UC1604C_WriteCommand. **/ +/** Purpose: Write a command byte to OLED coltroler. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ uiData: One byte command will be write. **/ +/** Return: None. **/ +/*****************************************************************************/ +void UC1604C_WriteCommand(uint8_t uiCommand) +{ + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + SPI_UC1604C_MODE_CMD(); + UC1604C_WriteByte(uiCommand); +} + +/*****************************************************************************/ +/** Function Name: UC1604C_SetPosition. **/ +/** Purpose: Set current position of page and colomn. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ uiColumn: Position of column. **/ +/** @ uiPage: Position of page. **/ +/** Return: None. **/ +/*****************************************************************************/ +void UC1604C_SetPosition(uint8_t uiColumn, uint8_t uiPage) +{ + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + UC1604C_WriteCommand(0xB0 | uiPage); + UC1604C_WriteCommand(((uiColumn & 0xF0)>>4)|0x10); + UC1604C_WriteCommand((uiColumn & 0x0F)); +} + +/*****************************************************************************/ +/** Function Name: UC1604C_Fill. **/ +/** Purpose: Fill screen. **/ +/** Params: **/ +/** @ uiByte: Filled data. **/ +/** Return: None. **/ +/*****************************************************************************/ +void UC1604C_Fill(uint8_t uiByte)//全屏填充 +{ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + uint8_t uiPage, uiColumn; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + for(uiPage=0; uiPagepstActions) + && (NULL != g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions->Initialize) + ) + { + g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions->Initialize(&g_stDeviceInterface); + g_stDemoEngine.ScreenObjPtr[iIndex]->pstPrevious = NULL; + } + } + } + else + { + + } + /* Active engine object. */ + eProcessResult = HMI_ActiveEngine(&g_stDemoEngine, HMI_SCREEN_ID_DEMO_LIST); + //eProcessResult = HMI_ActiveEngine(&g_stDemoEngine, HMI_SCREEN_ID_DEMO_ITEMS_BASE); + if(HMI_PROCESS_FAILED(eProcessResult)) + { + /* Active engine failed. */ + break; + } + /* Start engine process. */ + eProcessResult = HMI_StartEngine(NULL); + if(HMI_PROCESS_FAILED(eProcessResult)) + { + /* Start engine failed. */ + break; + } + }while(0); + + return eProcessResult; +} + +#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ +/*****************************************************************************/ +/** Function Name: CheckEventFlag **/ +/** Purpose: Check SimpleGUI virtual SDK event trigger flag and **/ +/** reset for next trigger and check. **/ +/** Parameters: **/ +/** @ eIndex[in]: Checked flag index. **/ +/** Return: true for event is trigger, false for not. **/ +/** Notice: This function only used in SimpleGUI virtual SDK **/ +/*****************************************************************************/ +bool CheckEventFlag(ENV_FLAG_INDEX eIndex) +{ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + bool bReturn; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + bReturn = SGUI_SDK_GetEventSyncFlag(eIndex); + + if(true == bReturn) + { + SGUI_SDK_SetEvnetSyncFlag(eIndex, false); + } + + return bReturn; +} +#endif // _SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ + +/*****************************************************************************/ +/** Function Name: DemoMainProcess **/ +/** Purpose: It is a dummy main function for SimpleGUI Virtual SDK, **/ +/** or run demo process in demo process. **/ +/** Parameters: None. **/ +/** Return: Terminal code, seam as main function return code. **/ +/** Notice: None. **/ +/*****************************************************************************/ +void DemoMainProcess(void) +{ + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + // Initialize HMI Engine. + InitializeHMIEngineObj(); + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + while(1) + { + // Check and process heart-beat timer event. + if(true == SysTickTimerTriggered()) + { + SysTickTimerEventProc(); + } + // Check and process key press event. + if(true == UserEventTriggered()) + { + KeyPressEventProc(); + } + // Check and process RTC event. + if(true == RTCTimerTriggered()) + { + RTCEventProc(); + } + } +} + +/*****************************************************************************/ +/** Function Name: KeyPressEventProc **/ +/** Purpose: Deal with user key process in demo process. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: The button is just abstract, and the message may come **/ +/** from a touch screen, a serial port, and so on. **/ +/*****************************************************************************/ +void KeyPressEventProc(void) +{ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + KEY_PRESS_EVENT stEvent; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + HMI_EVENT_INIT(stEvent); + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + stEvent.Head.iType = EVENT_TYPE_ACTION; + stEvent.Head.iID = EVENT_ID_KEY_PRESS; +#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ + stEvent.Data.uiKeyValue = SGUI_SDK_GetKeyEventData(); +#else + stEvent.Data.uiKeyValue = s_uiKeyValue; +#endif + // Post key press event. + HMI_ProcessEvent((HMI_EVENT_BASE*)(&stEvent)); +} + +/*****************************************************************************/ +/** Function Name: SysTickTimerEventProc **/ +/** Purpose: Deal with heartbeat timer event in demo process. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: It is usually used to simulate ADC or other sensors. **/ +/*****************************************************************************/ +void SysTickTimerEventProc(void) +{ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + DATA_EVENT stEvent; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + HMI_EVENT_INIT(stEvent); + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + stEvent.Head.iType = EVENT_TYPE_DATA; + stEvent.Head.iID = EVENT_ID_TIMER; + stEvent.Data.iValue = (rand() % 200)-100; + // Post timer event. + HMI_ProcessEvent((HMI_EVENT_BASE*)&stEvent); +} + +/*****************************************************************************/ +/** Function Name: RTCEventProc **/ +/** Purpose: Deal with RTC timer event in demo process. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: It is usually used to simulate ADC or other sensors. **/ +/*****************************************************************************/ +void RTCEventProc(void) +{ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_GENERAL_EVENT stEvent; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + HMI_EVENT_INIT(stEvent); + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + stEvent.Head.iType = EVENT_TYPE_DATA; + stEvent.Head.iID = EVENT_ID_RTC; + // Post RTC update message to a screen. + HMI_ProcessEvent((HMI_EVENT_BASE*)&stEvent); +} + +/*****************************************************************************/ +/** Function Name: SysTickTimerTriggered **/ +/** Purpose: Check sys-tick timer interrupt is triggered. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: None. **/ +/*****************************************************************************/ +bool SysTickTimerTriggered(void) +{ +#ifndef _SIMPLE_GUI_IN_VIRTUAL_SDK_ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + bool bIsTriggered; +#endif + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ +#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ + return CheckEventFlag(ENV_FLAG_IDX_SDK_TIM_EVENT); +#else + // Dummy sys-tick Timer interrupt triggered process. + bIsTriggered = BaseTimerIsTrigger(); + if(true == bIsTriggered) + { + BaseTimerTriggerReset(); + } + + return bIsTriggered; +#endif +} + +/*****************************************************************************/ +/** Function Name: RTCTimerTriggered **/ +/** Purpose: Check RTC timer interrupt is triggered. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: None. **/ +/*****************************************************************************/ +bool RTCTimerTriggered(void) +{ +#ifndef _SIMPLE_GUI_IN_VIRTUAL_SDK_ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + bool bIsTriggered; +#endif + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ +#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ + return CheckEventFlag(ENV_FLAG_IDX_SDK_RTC_EVENT); +#else + // RTC interrupt triggered process. + bIsTriggered = RTCTimerIsTrigger(); + if(true == bIsTriggered) + { + RTCTimerTriggerReset(); + } + + return bIsTriggered; +#endif +} + +/*****************************************************************************/ +/** Function Name: UserEventTriggered **/ +/** Purpose: Check user event is triggered. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: None. **/ +/*****************************************************************************/ +bool UserEventTriggered(void) +{ +#ifndef _SIMPLE_GUI_IN_VIRTUAL_SDK_ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + bool bIsTriggered; + +#endif + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ +#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ + return CheckEventFlag(ENV_FLAG_IDX_SDK_KEY_EVENT); +#else + // User event triggered process. + bIsTriggered = UsartIsReceived(); + if(true == bIsTriggered) + { + s_uiKeyValue = GetReceivedCode(); + UsartTriggerReset(); + } + return bIsTriggered; +#endif +} + +/*****************************************************************************/ +/** Function Name: SysTickTimerEnable **/ +/** Purpose: Enable or disable sys-tick timer. **/ +/** Parameters: **/ +/** @ bEnable[in]: True for enable sys-tick timer, false for disable. **/ +/** Return: None. **/ +/** Notice: None. **/ +/*****************************************************************************/ +void SysTickTimerEnable(bool bEnable) +{ + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ +#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ + (void)SGUI_SDK_ConfigHearBeatTimer(bEnable?DEMO_HEART_BEAT_INTERVAL_MS:0); +#else + // Add Dummy sys-tick timer interrupt enable change operation here. + BASE_TIMER_ActiveInterrupt(TIM3, bEnable); +#endif +} + +/*****************************************************************************/ +/** Function Name: RTCTimerEnable **/ +/** Purpose: Enable or disable RTC timer. **/ +/** Parameters: **/ +/** @ bEnable[in]: True for enable RTC timer, false for disable. **/ +/** Return: None. **/ +/** Notice: None. **/ +/*****************************************************************************/ +void RTCTimerEnable(bool bEnable) +{ + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ +#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ + (void)SGUI_SDK_EnableRTCInterrupt(bEnable); +#else + // Add RTC interrupt enable change operation here. + RTC_WaitForSynchro(); + RTC_ITConfig(RTC_IT_SEC, bEnable?ENABLE:DISABLE); + RTC_WaitForLastTask(); +#endif +} +