Guest User

W25Q128JV.h

a guest
Aug 11th, 2025
17
0
13 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.04 KB | Source Code | 0 0
  1. /* USER CODE BEGIN Header */
  2. /**
  3.   ******************************************************************************
  4.   * @file           : W25Q128JV.h
  5.   * @brief          : Header for W25Q128JV.c file
  6.   *                   This file contains the defines of W25Q128JV.c
  7.   ******************************************************************************
  8.   * @attention
  9.   * This library outputs debug messages to UART3, so it requires UART_HandleTypeDef huart3; to be defined in main.c
  10.   * This library is fine-tuned to work for a specific project, don't use as a general library
  11.   *
  12.   * All rights reserved.
  13.   *
  14.   *
  15.   * If no LICENSE file comes with this software, it is provided AS-IS.
  16.   *
  17.   ******************************************************************************
  18.   */
  19.   /*
  20.     | Sector # | Start Addr | End Addr |
  21.     | -------- | ---------- | -------- |
  22.     | 0        | 0x000000   | 0x000FFF |
  23.     | 1        | 0x001000   | 0x001FFF |
  24.     | 2        | 0x002000   | 0x002FFF |
  25.     | 3        | 0x003000   | 0x003FFF |
  26.     | ...      | ...        | ...      |
  27.     | 4093     | 0xFFD000   | 0xFFDFFF |
  28.     | 4094     | 0xFFE000   | 0xFFEFFF |
  29.     | 4095     | 0xFFF000   | 0xFFFFFF |
  30.  
  31.  
  32.     flow region spans:
  33.     0x000000 ... 0xFFDFFF
  34.  
  35.     sector fill log region:
  36.     0xFFE000 ... 0xFFFFF9
  37.  
  38.     reserved to be in erased state, necessary for function "W25Q_sector_scan":
  39.     0xFFFFFA - 0xFFFFFB
  40.  
  41.     reserved for erase chip count:
  42.     0xFFFFFC - 0xFFFFFF
  43.  */
  44.  
  45. /* USER CODE END Header */
  46.  
  47. /* USER CODE BEGIN */
  48. #ifndef __W25Q128JV_H
  49. #define __W25Q128JV_H
  50.  
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif /* __cplusplus */
  54.  
  55. #include "main.h"      // for SPI and UART handles
  56. #include <stdint.h>    // for uint8_t, uint16_t, uint32_t
  57.  
  58. // Function declarations
  59. uint8_t W25Q_WaitBusyWithTimeout(uint32_t timeout_ms);
  60. void W25Q_Reset(void);
  61. uint8_t W25Q_SR_Reset(void);
  62. uint32_t W25Q_ReadJedecID(void);
  63. uint8_t W25Q_ReadUniqueID(uint8_t *arr);
  64. uint16_t W25Q_sector_scan(void);
  65. uint32_t W25Q_get_flow(uint16_t valid_sector_num);
  66. void W25Q_PageProgram_flow(uint32_t address, uint32_t flow_value);
  67. uint8_t W25Q_ChipErase(void);
  68. uint32_t W25Q_ReadData_4B(uint32_t address);
  69.  
  70.  
  71. extern SPI_HandleTypeDef hspi1; // STM32 interfaces with W25Q128JV via SPI
  72. extern UART_HandleTypeDef huart3;
  73. extern char msg[128];  // Or however large it is in main.c
  74.  
  75. extern uint8_t write_e_cmd;
  76. extern uint8_t spi_t_result, e_spi_r; // for error logging
  77.  
  78. extern uint8_t read_st_r1_cmd; // Read Status Register-1
  79. extern uint8_t read_st_r2_cmd; // Read Status Register-2
  80. extern uint8_t read_st_r3_cmd; // Read Status Register-3
  81.  
  82. extern uint8_t sr1;  // for holding status registers' values
  83. extern uint8_t sr2;
  84. extern uint8_t sr3;
  85.  
  86. extern uint8_t W25Q_ChipErase_flag;
  87.  
  88. extern uint32_t last_saved_flow_value; // to store in W25Q
  89. extern uint32_t next_flow_addr;    // this variable tells "W25Q_PageProgram_flow" at which address to write new flow value
  90.  
  91. extern uint16_t last_sector_num_written; // used in function "W25Q_PageProgram_flow"
  92. extern uint16_t last_valid_sector;
  93.  
  94. #endif // __W25Q128JV_H
  95. /* USER CODE END */
Tags: W25Q
Advertisement
Add Comment
Please, Sign In to add comment