46 #define ADDR_OTP_START 0x1FFF7800 47 #define ADDR_OTP_LOCK_START 0x1FFF7A00 49 #define OTP_LOCK_LOCKED 0x00 50 #define OTP_LOCK_UNLOCKED 0xFF 61 #define F_ERROR_PROGRAM 3 62 #define F_ERROR_OPERATION 4 67 volatile unsigned long key;
74 #define PERIPH_BASE ((unsigned long)0x40000000) //Peripheral base address 75 #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000) 76 #define F_R_BASE (AHB1PERIPH_BASE + 0x3C00) 77 #define FLASH ((flash_registers *) F_R_BASE) 79 #define F_BSY ((unsigned long)0x00010000) //FLASH Busy flag bit 80 #define F_OPERR ((unsigned long)0x00000002) //FLASH operation Error flag bit 81 #define F_WRPERR ((unsigned long)0x00000010) //FLASH Write protected error flag bit 82 #define CR_PSIZE_MASK ((unsigned long)0xFFFFFCFF) 83 #define F_PSIZE_WORD ((unsigned long)0x00000200) 84 #define F_PSIZE_BYTE ((unsigned long)0x00000000) 85 #define F_CR_PG ((unsigned long)0x00000001) // a bit in the F_CR register 86 #define F_CR_LOCK ((unsigned long)0x80000000) // also another bit. 88 #define F_KEY1 ((unsigned long)0x45670123) 89 #define F_KEY2 ((unsigned long)0xCDEF89AB) 90 #define IS_F_ADDRESS(ADDRESS) ((((ADDRESS) >= 0x08000000) && ((ADDRESS) < 0x080FFFFF)) || (((ADDRESS) >= 0x1FFF7800) && ((ADDRESS) < 0x1FFF7A0F))) 122 #define ADDR_F_SIZE 0x1FFF7A22 124 #pragma pack(push, 1) volatile unsigned long optioncontrol
__EXPORT int lock_otp(void)
__BEGIN_DECLS __EXPORT void F_unlock(void)
volatile unsigned long control
__EXPORT int F_write_word(unsigned long Address, uint32_t Data)
uint32_t vid
1 byte < 0 for USB VID, 1 for generic VID
volatile unsigned long status
volatile unsigned long key
__EXPORT int write_otp(uint8_t id_type, uint32_t vid, uint32_t pid, char *signature)
__EXPORT int val_write(volatile void *dest, const void *src, int bytes)
__EXPORT void F_lock(void)
uint8_t id_type
4 bytes < 'P' 'X' '4' ' '
__EXPORT int val_read(void *dest, volatile const void *src, int bytes)
volatile unsigned long accesscontrol
volatile unsigned long optionkey
__EXPORT int F_write_byte(unsigned long Address, uint8_t Data)
char signature[128]
19 bytes