Wakeup Light with touch user interface, anti-aliased Font, SD card access and RTC usage on STM32F746NG-DISCO board

Dependencies:   BSP_DISCO_F746NG_patch_fixed LCD_DISCO_F746NG TS_DISCO_F746NG FATFileSystem TinyJpgDec_interwork mbed-src

Committer:
the_sz
Date:
Thu Nov 12 21:21:48 2015 +0000
Revision:
7:dc29f6647486
f746 patch used

Who changed what in which revision?

UserRevisionLine numberNew contents of line
the_sz 7:dc29f6647486 1 #include "WakeupLight.h"
the_sz 7:dc29f6647486 2
the_sz 7:dc29f6647486 3 //#define USE_RTC
the_sz 7:dc29f6647486 4
the_sz 7:dc29f6647486 5 #define CT_MAGIC_VALUE 0x546865DF // 'Theß'
the_sz 7:dc29f6647486 6
the_sz 7:dc29f6647486 7 #ifdef USE_RTC
the_sz 7:dc29f6647486 8 uint32_t *rtcBackupRegisters;
the_sz 7:dc29f6647486 9 #else
the_sz 7:dc29f6647486 10 uint32_t configSpace[CT_MAX];
the_sz 7:dc29f6647486 11 #endif
the_sz 7:dc29f6647486 12
the_sz 7:dc29f6647486 13 void Config_Init(void)
the_sz 7:dc29f6647486 14 {
the_sz 7:dc29f6647486 15 uint32_t index;
the_sz 7:dc29f6647486 16
the_sz 7:dc29f6647486 17 #ifdef USE_RTC
the_sz 7:dc29f6647486 18
the_sz 7:dc29f6647486 19 RTC_TypeDef *rtc;
the_sz 7:dc29f6647486 20
the_sz 7:dc29f6647486 21 rtc=(RTC_TypeDef *)RTC_BASE;
the_sz 7:dc29f6647486 22 rtcBackupRegisters=(uint32_t *)&rtc->BKP0R;
the_sz 7:dc29f6647486 23
the_sz 7:dc29f6647486 24 if (rtcBackupRegisters[CT_MAGIC]!=CT_MAGIC_VALUE)
the_sz 7:dc29f6647486 25 {
the_sz 7:dc29f6647486 26 DPrintf("Config_Init: Reset config because of 0x%08X.\r\n",rtcBackupRegisters[CT_MAGIC]);
the_sz 7:dc29f6647486 27
the_sz 7:dc29f6647486 28 for (index=0;index<=CT_MAX;index++)
the_sz 7:dc29f6647486 29 rtcBackupRegisters[index]=0;
the_sz 7:dc29f6647486 30
the_sz 7:dc29f6647486 31 rtcBackupRegisters[CT_MAGIC]=CT_MAGIC_VALUE;
the_sz 7:dc29f6647486 32 }
the_sz 7:dc29f6647486 33
the_sz 7:dc29f6647486 34 #else
the_sz 7:dc29f6647486 35
the_sz 7:dc29f6647486 36 for (index=0;index<=CT_MAX;index++)
the_sz 7:dc29f6647486 37 configSpace[index]=0;
the_sz 7:dc29f6647486 38
the_sz 7:dc29f6647486 39 configSpace[CT_MAGIC]=CT_MAGIC_VALUE;
the_sz 7:dc29f6647486 40
the_sz 7:dc29f6647486 41 #endif
the_sz 7:dc29f6647486 42 }
the_sz 7:dc29f6647486 43
the_sz 7:dc29f6647486 44 uint32_t Config_Get(CONFIG_TYPE_ENUM type)
the_sz 7:dc29f6647486 45 {
the_sz 7:dc29f6647486 46 if (type>CT_MAX)
the_sz 7:dc29f6647486 47 return 0;
the_sz 7:dc29f6647486 48
the_sz 7:dc29f6647486 49 DPrintf_("Config_Get: %u -> 0x%X.\r\n",type,configSpace[type]);
the_sz 7:dc29f6647486 50
the_sz 7:dc29f6647486 51 #ifdef USE_RTC
the_sz 7:dc29f6647486 52 return rtcBackupRegisters[type];
the_sz 7:dc29f6647486 53 #else
the_sz 7:dc29f6647486 54 return configSpace[type];
the_sz 7:dc29f6647486 55 #endif
the_sz 7:dc29f6647486 56 }
the_sz 7:dc29f6647486 57
the_sz 7:dc29f6647486 58 void Config_Set(CONFIG_TYPE_ENUM type,uint32_t value)
the_sz 7:dc29f6647486 59 {
the_sz 7:dc29f6647486 60 if (type>CT_MAX)
the_sz 7:dc29f6647486 61 return;
the_sz 7:dc29f6647486 62
the_sz 7:dc29f6647486 63 DPrintf_("Config_Set: %u -> 0x%X.\r\n",type,value);
the_sz 7:dc29f6647486 64
the_sz 7:dc29f6647486 65 #ifdef USE_RTC
the_sz 7:dc29f6647486 66
the_sz 7:dc29f6647486 67 RTC_TypeDef *rtc;
the_sz 7:dc29f6647486 68
the_sz 7:dc29f6647486 69 rtc=(RTC_TypeDef *)RTC_BASE;
the_sz 7:dc29f6647486 70 rtc->WPR=0xCA;
the_sz 7:dc29f6647486 71 rtc->WPR=0x53;
the_sz 7:dc29f6647486 72
the_sz 7:dc29f6647486 73 rtcBackupRegisters[type]=value;
the_sz 7:dc29f6647486 74
the_sz 7:dc29f6647486 75 rtc->WPR=0xFF;
the_sz 7:dc29f6647486 76
the_sz 7:dc29f6647486 77 #else
the_sz 7:dc29f6647486 78
the_sz 7:dc29f6647486 79 configSpace[type]=value;
the_sz 7:dc29f6647486 80
the_sz 7:dc29f6647486 81 #endif
the_sz 7:dc29f6647486 82 }