From e5c7ff6102fffbbeacb5fa82724974f8843f8630 Mon Sep 17 00:00:00 2001 From: "Pavel V. Shatov (Meister)" Date: Wed, 18 May 2016 10:05:54 +0300 Subject: Initial commit of code, that talks to the FPGA config memory (and keystore memory). --- alpha_n25q128.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 alpha_n25q128.h (limited to 'alpha_n25q128.h') diff --git a/alpha_n25q128.h b/alpha_n25q128.h new file mode 100644 index 0000000..cc60008 --- /dev/null +++ b/alpha_n25q128.h @@ -0,0 +1,56 @@ +//----------------------------------------------------------------------------- +// alpha_n25q128.h +//----------------------------------------------------------------------------- + + +//----------------------------------------------------------------------------- +// Interface Map +//----------------------------------------------------------------------------- +#define N25Q128_SPI_HANDLE (&hspi2) + + +//----------------------------------------------------------------------------- +// Defined Values +//----------------------------------------------------------------------------- +#define N25Q128_COMMAND_READ_ID 0x9E +#define N25Q128_COMMAND_READ_PAGE 0x03 +#define N25Q128_COMMAND_READ_STATUS 0x05 +#define N25Q128_COMMAND_WRITE_ENABLE 0x06 +#define N25Q128_COMMAND_ERASE_SECTOR 0xD8 +#define N25Q128_COMMAND_PAGE_PROGRAM 0x02 + +#define N25Q128_PAGE_SIZE 0x100 // 256 +#define N25Q128_NUM_PAGES 0x10000 // 65536 + +#define N25Q128_SECTOR_SIZE 0x10000 // 65536 +#define N25Q128_NUM_SECTORS 0x100 // 256 + +#define N25Q128_SPI_TIMEOUT 1000 + +#define N25Q128_ID_MANUFACTURER 0x20 +#define N25Q128_ID_DEVICE_TYPE 0xBA +#define N25Q128_ID_DEVICE_CAPACITY 0x18 + + +//----------------------------------------------------------------------------- +// Macros +//----------------------------------------------------------------------------- +#define _n25q128_select() HAL_GPIO_WritePin(PROM_CS_N_GPIO_Port,PROM_CS_N_Pin,GPIO_PIN_RESET); +#define _n25q128_deselect() HAL_GPIO_WritePin(PROM_CS_N_GPIO_Port,PROM_CS_N_Pin,GPIO_PIN_SET); + + +//----------------------------------------------------------------------------- +// Prototypes +//----------------------------------------------------------------------------- +int n25q128_check_id (void); +int n25q128_get_wip_flag (void); +int n25q128_read_page (uint32_t page_offset, uint8_t *page_buffer); +int n25q128_write_page (uint32_t page_offset, uint8_t *page_buffer); +int n25q128_erase_sector (uint32_t sector_offset); + +int _n25q128_get_wel_flag (void); + + +//----------------------------------------------------------------------------- +// End-of-File +//----------------------------------------------------------------------------- -- cgit v1.2.3