Display Steuerung für Lampen per Relais. https://www.youtube.com/watch?v=_CupBMcZ8Xc
Dependencies: BSP_DISCO_F746NG F746_GUI LCD_DISCO_F746NG TS_DISCO_F746NG mbed
flash.cpp@1:f316de154ff7, 2017-04-23 (annotated)
- Committer:
- hexfactory
- Date:
- Sun Apr 23 17:15:53 2017 +0000
- Revision:
- 1:f316de154ff7
- Parent:
- 0:da00b5dd65c6
Helligkeitssensor und T?rkontaktsensor - Display Steuerung [DE]; https://www.youtube.com/watch?v=9OA7kxGMPo8
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hexfactory | 1:f316de154ff7 | 1 | /*============================================================================================= |
hexfactory | 1:f316de154ff7 | 2 | section 1 - includes |
hexfactory | 1:f316de154ff7 | 3 | ==============================================================================================*/ |
hexfactory | 1:f316de154ff7 | 4 | /* imported libs */ |
hexfactory | 1:f316de154ff7 | 5 | #include "mbed.h" |
hexfactory | 0:da00b5dd65c6 | 6 | #include "stm32746g_discovery_qspi.h" |
hexfactory | 0:da00b5dd65c6 | 7 | |
hexfactory | 1:f316de154ff7 | 8 | /* project files */ |
hexfactory | 1:f316de154ff7 | 9 | #include "flash.h" |
hexfactory | 1:f316de154ff7 | 10 | |
hexfactory | 1:f316de154ff7 | 11 | /*============================================================================================= |
hexfactory | 1:f316de154ff7 | 12 | section 2 - private defines / enumerations |
hexfactory | 1:f316de154ff7 | 13 | ==============================================================================================*/ |
hexfactory | 0:da00b5dd65c6 | 14 | #define FLASH_START_ADDRESS 0 |
hexfactory | 0:da00b5dd65c6 | 15 | #define FLASH_START_BLOCK 0 |
hexfactory | 0:da00b5dd65c6 | 16 | |
hexfactory | 1:f316de154ff7 | 17 | /*============================================================================================= |
hexfactory | 1:f316de154ff7 | 18 | section 3 - private typedefs |
hexfactory | 1:f316de154ff7 | 19 | ==============================================================================================*/ |
hexfactory | 1:f316de154ff7 | 20 | |
hexfactory | 1:f316de154ff7 | 21 | /*============================================================================================= |
hexfactory | 1:f316de154ff7 | 22 | section 4 - private macros |
hexfactory | 1:f316de154ff7 | 23 | ==============================================================================================*/ |
hexfactory | 1:f316de154ff7 | 24 | |
hexfactory | 1:f316de154ff7 | 25 | /*============================================================================================= |
hexfactory | 1:f316de154ff7 | 26 | section 5 - public constants definition |
hexfactory | 1:f316de154ff7 | 27 | ==============================================================================================*/ |
hexfactory | 1:f316de154ff7 | 28 | |
hexfactory | 1:f316de154ff7 | 29 | /*============================================================================================= |
hexfactory | 1:f316de154ff7 | 30 | section 6 - public variables/pointers definition |
hexfactory | 1:f316de154ff7 | 31 | ==============================================================================================*/ |
hexfactory | 1:f316de154ff7 | 32 | |
hexfactory | 1:f316de154ff7 | 33 | /*============================================================================================= |
hexfactory | 1:f316de154ff7 | 34 | section 7 - private constants definition |
hexfactory | 1:f316de154ff7 | 35 | ==============================================================================================*/ |
hexfactory | 1:f316de154ff7 | 36 | |
hexfactory | 1:f316de154ff7 | 37 | /*============================================================================================= |
hexfactory | 1:f316de154ff7 | 38 | section 8 - private variables/objects/pointers definition |
hexfactory | 1:f316de154ff7 | 39 | ==============================================================================================*/ |
hexfactory | 1:f316de154ff7 | 40 | static uint8_t localFlashData[FLASH_DATA_SIZE]; |
hexfactory | 1:f316de154ff7 | 41 | |
hexfactory | 1:f316de154ff7 | 42 | /*============================================================================================= |
hexfactory | 1:f316de154ff7 | 43 | section 9 - private functions - declaration |
hexfactory | 1:f316de154ff7 | 44 | ==============================================================================================*/ |
hexfactory | 1:f316de154ff7 | 45 | |
hexfactory | 1:f316de154ff7 | 46 | /*============================================================================================= |
hexfactory | 1:f316de154ff7 | 47 | section 10 - private functions - implementation (definition) |
hexfactory | 1:f316de154ff7 | 48 | ==============================================================================================*/ |
hexfactory | 1:f316de154ff7 | 49 | |
hexfactory | 1:f316de154ff7 | 50 | /*============================================================================================= |
hexfactory | 1:f316de154ff7 | 51 | section 11 - public functions - implementation (definition) |
hexfactory | 1:f316de154ff7 | 52 | ==============================================================================================*/ |
hexfactory | 1:f316de154ff7 | 53 | void flash_init(void) |
hexfactory | 0:da00b5dd65c6 | 54 | { |
hexfactory | 0:da00b5dd65c6 | 55 | BSP_QSPI_Init(); |
hexfactory | 1:f316de154ff7 | 56 | BSP_QSPI_Read(localFlashData, FLASH_START_ADDRESS, FLASH_DATA_SIZE); |
hexfactory | 0:da00b5dd65c6 | 57 | } |
hexfactory | 0:da00b5dd65c6 | 58 | |
hexfactory | 1:f316de154ff7 | 59 | /* liest Flash Daten aus der lokale RAM Kopie */ |
hexfactory | 1:f316de154ff7 | 60 | uint8_t flash_read(E_FLASH_INDEX index) |
hexfactory | 1:f316de154ff7 | 61 | { |
hexfactory | 1:f316de154ff7 | 62 | return localFlashData[index]; |
hexfactory | 1:f316de154ff7 | 63 | } |
hexfactory | 1:f316de154ff7 | 64 | |
hexfactory | 1:f316de154ff7 | 65 | /* schreibt Flash Daten in die lokale RAM Kopie */ |
hexfactory | 1:f316de154ff7 | 66 | void flash_write(E_FLASH_INDEX index, uint8_t data) |
hexfactory | 1:f316de154ff7 | 67 | { |
hexfactory | 1:f316de154ff7 | 68 | localFlashData[index] = data; |
hexfactory | 0:da00b5dd65c6 | 69 | } |
hexfactory | 0:da00b5dd65c6 | 70 | |
hexfactory | 1:f316de154ff7 | 71 | void flash_task(void) |
hexfactory | 1:f316de154ff7 | 72 | { |
hexfactory | 1:f316de154ff7 | 73 | uint8_t tmpFlashData[FLASH_DATA_SIZE]; |
hexfactory | 1:f316de154ff7 | 74 | uint8_t isNotEqual = 0; |
hexfactory | 1:f316de154ff7 | 75 | uint8_t i; |
hexfactory | 1:f316de154ff7 | 76 | |
hexfactory | 1:f316de154ff7 | 77 | /* prüfe ob die RAM Daten != den ROM Daten sind */ |
hexfactory | 1:f316de154ff7 | 78 | BSP_QSPI_Read(tmpFlashData, FLASH_START_ADDRESS, FLASH_DATA_SIZE); |
hexfactory | 1:f316de154ff7 | 79 | for (i = 0; i < FLASH_DATA_SIZE; i++) |
hexfactory | 1:f316de154ff7 | 80 | { |
hexfactory | 1:f316de154ff7 | 81 | if (tmpFlashData[i] != localFlashData[i]) |
hexfactory | 1:f316de154ff7 | 82 | { /* Daten ungleich */ |
hexfactory | 1:f316de154ff7 | 83 | isNotEqual = 1; |
hexfactory | 1:f316de154ff7 | 84 | } |
hexfactory | 1:f316de154ff7 | 85 | } |
hexfactory | 1:f316de154ff7 | 86 | |
hexfactory | 1:f316de154ff7 | 87 | /* schreibe RAM Daten in das Flash ROM falls RAM Daten != ROM Daten */ |
hexfactory | 1:f316de154ff7 | 88 | if (1 == isNotEqual) |
hexfactory | 1:f316de154ff7 | 89 | { |
hexfactory | 1:f316de154ff7 | 90 | BSP_QSPI_Erase_Block(FLASH_START_BLOCK); |
hexfactory | 1:f316de154ff7 | 91 | BSP_QSPI_Write(localFlashData, FLASH_START_ADDRESS, FLASH_DATA_SIZE); |
hexfactory | 1:f316de154ff7 | 92 | } |
hexfactory | 1:f316de154ff7 | 93 | } |
hexfactory | 1:f316de154ff7 | 94 | |
hexfactory | 1:f316de154ff7 | 95 | /*============================================================================================= |
hexfactory | 1:f316de154ff7 | 96 | section 12 - interrupt service routines (ISRs) |
hexfactory | 1:f316de154ff7 | 97 | ==============================================================================================*/ |
hexfactory | 1:f316de154ff7 | 98 | |
hexfactory | 1:f316de154ff7 | 99 | /*============================================================================================= |
hexfactory | 1:f316de154ff7 | 100 | end of file |
hexfactory | 1:f316de154ff7 | 101 | ==============================================================================================*/ |