68 lines
1.6 KiB
C
68 lines
1.6 KiB
C
|
/*
|
||
|
* flash.h
|
||
|
*
|
||
|
* Created on: Apr 12, 2024
|
||
|
* Author: Francesco Gritti
|
||
|
*/
|
||
|
|
||
|
#ifndef FLASH_H_
|
||
|
#define FLASH_H_
|
||
|
|
||
|
#include "mcu.h"
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
#define FLASH_PSIZE_BYTE 0x00000000U
|
||
|
#define FLASH_PSIZE_HALF_WORD 0x00000100U
|
||
|
#define FLASH_PSIZE_WORD 0x00000200U
|
||
|
#define FLASH_PSIZE_DOUBLE_WORD 0x00000300U
|
||
|
#define CR_PSIZE_MASK 0xFFFFFCFFU
|
||
|
|
||
|
#define FLASH_VOLTAGE_RANGE_1 0x00000000U /*!< Device operating range: 1.8V to 2.1V */
|
||
|
#define FLASH_VOLTAGE_RANGE_2 0x00000001U /*!< Device operating range: 2.1V to 2.7V */
|
||
|
#define FLASH_VOLTAGE_RANGE_3 0x00000002U /*!< Device operating range: 2.7V to 3.6V */
|
||
|
#define FLASH_VOLTAGE_RANGE_4 0x00000003U /*!< Device operating range: 2.7V to 3.6V + External Vpp */
|
||
|
|
||
|
#define FLASH_SECTOR_0 0U /*!< Sector Number 0 */
|
||
|
#define FLASH_SECTOR_1 1U /*!< Sector Number 1 */
|
||
|
#define FLASH_SECTOR_2 2U /*!< Sector Number 2 */
|
||
|
#define FLASH_SECTOR_3 3U /*!< Sector Number 3 */
|
||
|
#define FLASH_SECTOR_4 4U /*!< Sector Number 4 */
|
||
|
#define FLASH_SECTOR_5 5U /*!< Sector Number 5 */
|
||
|
#define FLASH_SECTOR_6 6U /*!< Sector Number 6 */
|
||
|
#define FLASH_SECTOR_7 7U /*!< Sector Number 7 */
|
||
|
|
||
|
#define FLASH_SECTOR_TOTAL 8U
|
||
|
|
||
|
#define FLASH_TIMEOUT_VALUE 50000U /* 50 s */
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
#define flash_is_locked() ((FLASH->CR & FLASH_CR_LOCK) != 0)
|
||
|
|
||
|
|
||
|
void flash_unlock (void);
|
||
|
void flash_lock (void);
|
||
|
|
||
|
void flash_wait_last_op();
|
||
|
|
||
|
void flash_erase_page (u32 page);
|
||
|
u8 flash_program_word (u32 address, u32 data);
|
||
|
u8 flash_program_hword (u32 address, u16 data);
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
#endif /* FLASH_H_ */
|