]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/common/chibios/flash_stm32.h
STM32 EEPROM Emulation (#3741)
[qmk_firmware.git] / tmk_core / common / chibios / flash_stm32.h
1 /*
2  * This software is experimental and a work in progress.
3  * Under no circumstances should these files be used in relation to any critical system(s).
4  * Use of these files is at your own risk.
5  *
6  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
7  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
8  * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
9  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
10  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
11  * DEALINGS IN THE SOFTWARE.
12  *
13  * This files are free to use from https://github.com/rogerclarkmelbourne/Arduino_STM32 and 
14  * https://github.com/leaflabs/libmaple
15  *
16  * Modifications for QMK and STM32F303 by Yiancar
17  */
18
19 #ifndef __FLASH_STM32_H
20 #define __FLASH_STM32_H
21
22 #ifdef __cplusplus
23  extern "C" {
24 #endif
25
26 #include "ch.h"
27 #include "hal.h"
28
29 typedef enum
30     {
31     FLASH_BUSY = 1,
32     FLASH_ERROR_PG,
33     FLASH_ERROR_WRP,
34     FLASH_ERROR_OPT,
35     FLASH_COMPLETE,
36     FLASH_TIMEOUT,
37     FLASH_BAD_ADDRESS
38     } FLASH_Status;
39
40 #define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) < 0x0807FFFF))
41
42 FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout);
43 FLASH_Status FLASH_ErasePage(uint32_t Page_Address);
44 FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);
45
46 void FLASH_Unlock(void);
47 void FLASH_Lock(void);
48
49 #ifdef __cplusplus
50 }
51 #endif
52
53 #endif /* __FLASH_STM32_H */