Quantcast
Channel: acassis – Alan C. Assis
Viewing all articles
Browse latest Browse all 870

Snippet code for read manufacturer and device ID of W25X32 SPI NOR Flash on NuttX

$
0
0

This simple snippet of code demonstrate how to read the manufacturer and the device ID of a W32X32 SPI Nor flash using NuttX RTOS :

int spi_nor_flash(void)
{
        uint8_t tx[6], rx[6];

        struct spi_dev_s *spi = up_spiinitialize(0);

        SPI_SETBITS(spi, 8);

        tx[0] = 0x90;
        tx[1] = 0;
        tx[2] = 0;
        tx[3] = 0;
        tx[4] = 0;
        tx[5] = 0;

        kl_gpiowrite(PIN_SPI0_CS, false);
        SPI_EXCHANGE(spi, &tx, &rx, 6);
        kl_gpiowrite(PIN_SPI0_CS, true);

        printf("Manuf. = 0x%02X | Device = 0x%02X\n", rx[4], rx[5]);

        return 0;
}


Viewing all articles
Browse latest Browse all 870

Latest Images

Trending Articles



Latest Images