below is my code :
Code: Select all
#include <stdio.h>
#include <stdbool.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/spi_master.h"
#define PIN_NUM_MISO 5
#define PIN_NUM_MOSI 21
#define PIN_NUM_CLK 19
#define PIN_NUM_CS 17
spi_device_handle_t spi;
uint8_t test;
void app_main()
{
spi_bus_config_t spi_bus=
{
.miso_io_num=PIN_NUM_MISO,
.mosi_io_num=PIN_NUM_MOSI,
.sclk_io_num=PIN_NUM_CLK,
.quadwp_io_num=-1,
.quadhd_io_num=-1,
.max_transfer_sz = 0 ,
};
spi_bus_initialize(HSPI_HOST, &spi_bus, 0);
spi_device_interface_config_t devcfg=
{
.command_bits = 8 ,
.address_bits = 24 ,
.dummy_bits = 3 ,
.duty_cycle_pos = 0 ,
.clock_speed_hz=10*1000*1000, //Clock out at 10 MHz
.mode=0, //SPI mode 0
.spics_io_num=PIN_NUM_CS, //CS pin
.queue_size=7, //We want to be able to queue 7 transactions at a time
};
spi_bus_add_device(HSPI_HOST, &devcfg, &spi);
spi_transaction_t t ;
t.addr=0x000000;
t.cmd =0x90;
t.length = 56 ;
t.rx_buffer = &test ;
t.rxlength = 24 ;
spi_transaction_ext_t t1 ;
t1.address_bits = 24 ;
t1.command_bits = 8 ;
t1.base = t ;
spi_device_transmit(spi,&t);
while(1);
}
Zhang anderson