nimaltd/spif

repository·master·Indexed 20 days ago

https://github.com/nimaltd/spif

A specialized SPI Flash library for STM32 microcontrollers, provided as an STM32CubeMX pack (.pdsc). It simplifies interfacing with SPI Flash chips such as the W25Q64 and includes functions like SPIF_Init() for peripheral initialization using the SPIF_HandleTypeDef structure.

Tokens
395
Snippets
2
Records
2
Agent score
22%

What's inside spif

  1. Install and setup the SPI FLASH Library in STM32CubeMX

    master

    To use this library in your STM32 project, follow these steps:

    1. Install the Pack: Download and install the .pdsc file from the following URL into your STM32CubeMX/IDE: https://github.com/nimaltd/STM32-PACK/raw/main/SPIF/NimaLTD.I-CUBE-SPIF.pdsc
    2. Enable the Library: Add the library to your project and ensure it is enabled.
    3. Hardware Configuration:
      • Enable the SPI peripheral.
      • Configure a GPIO as output-pushpull to serve as the CS (Chip Select) pin.
      • Connect the flash chip's WP (Write Protect) and HOLD pins to VCC.
    4. Code Generation Settings:
      • In the Code Generator tab, select: Generate peripheral initialization as a pair of .c/.h files per peripheral.
      • Generate the code.
    5. Software Initialization:
      • Define an instance of the SPIF_HandleTypeDef structure.
      • Call SPIF_Init() to initialize the peripheral.
    // 1. Define the handle
    SPIF_HandleTypeDef hspi_flash;
    
    // 2. Initialize
    SPIF_Init(&hspi_flash);
  2. Initialize the SPI FLASH library with SPIF_Init()

    master

    After configuring the hardware in STM32CubeMX, you must initialize the library in your application code. This requires defining a SPIF_HandleTypeDef structure and passing its address to the SPIF_Init() function. This library has been tested with the w25q64 device; users of other devices should verify compatibility.

    SPIF_HandleTypeDef hspi_flash;
    SPIF_Init(&hspi_flash);