Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* USER CODE BEGIN Header */
- /**
- ******************************************************************************
- * @file : W25Q128JV.h
- * @brief : Header for W25Q128JV.c file
- * This file contains the defines of W25Q128JV.c
- ******************************************************************************
- * @attention
- * This library outputs debug messages to UART3, so it requires UART_HandleTypeDef huart3; to be defined in main.c
- * This library is fine-tuned to work for a specific project, don't use as a general library
- *
- * All rights reserved.
- *
- *
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
- /*
- | Sector # | Start Addr | End Addr |
- | -------- | ---------- | -------- |
- | 0 | 0x000000 | 0x000FFF |
- | 1 | 0x001000 | 0x001FFF |
- | 2 | 0x002000 | 0x002FFF |
- | 3 | 0x003000 | 0x003FFF |
- | ... | ... | ... |
- | 4093 | 0xFFD000 | 0xFFDFFF |
- | 4094 | 0xFFE000 | 0xFFEFFF |
- | 4095 | 0xFFF000 | 0xFFFFFF |
- flow region spans:
- 0x000000 ... 0xFFDFFF
- sector fill log region:
- 0xFFE000 ... 0xFFFFF9
- reserved to be in erased state, necessary for function "W25Q_sector_scan":
- 0xFFFFFA - 0xFFFFFB
- reserved for erase chip count:
- 0xFFFFFC - 0xFFFFFF
- */
- /* USER CODE END Header */
- /* USER CODE BEGIN */
- #ifndef __W25Q128JV_H
- #define __W25Q128JV_H
- #ifdef __cplusplus
- extern "C" {
- #endif /* __cplusplus */
- #include "main.h" // for SPI and UART handles
- #include <stdint.h> // for uint8_t, uint16_t, uint32_t
- // Function declarations
- uint8_t W25Q_WaitBusyWithTimeout(uint32_t timeout_ms);
- void W25Q_Reset(void);
- uint8_t W25Q_SR_Reset(void);
- uint32_t W25Q_ReadJedecID(void);
- uint8_t W25Q_ReadUniqueID(uint8_t *arr);
- uint16_t W25Q_sector_scan(void);
- uint32_t W25Q_get_flow(uint16_t valid_sector_num);
- void W25Q_PageProgram_flow(uint32_t address, uint32_t flow_value);
- uint8_t W25Q_ChipErase(void);
- uint32_t W25Q_ReadData_4B(uint32_t address);
- extern SPI_HandleTypeDef hspi1; // STM32 interfaces with W25Q128JV via SPI
- extern UART_HandleTypeDef huart3;
- extern char msg[128]; // Or however large it is in main.c
- extern uint8_t write_e_cmd;
- extern uint8_t spi_t_result, e_spi_r; // for error logging
- extern uint8_t read_st_r1_cmd; // Read Status Register-1
- extern uint8_t read_st_r2_cmd; // Read Status Register-2
- extern uint8_t read_st_r3_cmd; // Read Status Register-3
- extern uint8_t sr1; // for holding status registers' values
- extern uint8_t sr2;
- extern uint8_t sr3;
- extern uint8_t W25Q_ChipErase_flag;
- extern uint32_t last_saved_flow_value; // to store in W25Q
- extern uint32_t next_flow_addr; // this variable tells "W25Q_PageProgram_flow" at which address to write new flow value
- extern uint16_t last_sector_num_written; // used in function "W25Q_PageProgram_flow"
- extern uint16_t last_valid_sector;
- #endif // __W25Q128JV_H
- /* USER CODE END */
Advertisement
Add Comment
Please, Sign In to add comment