mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
SPI: Fix comment for 3wire, make GPIO pins GPIO_MODE_INPUT_OUTOUT. Fixes https://github.com/espressif/esp-idf/issues/533
This commit is contained in:
parent
4c06dca15c
commit
cecb846450
@ -31,7 +31,7 @@ extern "C"
|
|||||||
#define SPI_DEVICE_TXBIT_LSBFIRST (1<<0) ///< Transmit command/address/data LSB first instead of the default MSB first
|
#define SPI_DEVICE_TXBIT_LSBFIRST (1<<0) ///< Transmit command/address/data LSB first instead of the default MSB first
|
||||||
#define SPI_DEVICE_RXBIT_LSBFIRST (1<<1) ///< Receive data LSB first instead of the default MSB first
|
#define SPI_DEVICE_RXBIT_LSBFIRST (1<<1) ///< Receive data LSB first instead of the default MSB first
|
||||||
#define SPI_DEVICE_BIT_LSBFIRST (SPI_TXBIT_LSBFIRST|SPI_RXBIT_LSBFIRST); ///< Transmit and receive LSB first
|
#define SPI_DEVICE_BIT_LSBFIRST (SPI_TXBIT_LSBFIRST|SPI_RXBIT_LSBFIRST); ///< Transmit and receive LSB first
|
||||||
#define SPI_DEVICE_3WIRE (1<<2) ///< Use spiq for both sending and receiving data
|
#define SPI_DEVICE_3WIRE (1<<2) ///< Use spid for both sending and receiving data
|
||||||
#define SPI_DEVICE_POSITIVE_CS (1<<3) ///< Make CS positive during a transaction instead of negative
|
#define SPI_DEVICE_POSITIVE_CS (1<<3) ///< Make CS positive during a transaction instead of negative
|
||||||
#define SPI_DEVICE_HALFDUPLEX (1<<4) ///< Transmit data before receiving it, instead of simultaneously
|
#define SPI_DEVICE_HALFDUPLEX (1<<4) ///< Transmit data before receiving it, instead of simultaneously
|
||||||
#define SPI_DEVICE_CLK_AS_CS (1<<5) ///< Output clock on CS line if CS is active
|
#define SPI_DEVICE_CLK_AS_CS (1<<5) ///< Output clock on CS line if CS is active
|
||||||
|
@ -184,7 +184,6 @@ config can be done using the IOMUX instead of using the GPIO matrix.
|
|||||||
esp_err_t spicommon_bus_initialize_io(spi_host_device_t host, const spi_bus_config_t *bus_config, int dma_chan, int flags, bool *is_native)
|
esp_err_t spicommon_bus_initialize_io(spi_host_device_t host, const spi_bus_config_t *bus_config, int dma_chan, int flags, bool *is_native)
|
||||||
{
|
{
|
||||||
bool native=true;
|
bool native=true;
|
||||||
bool is_master=(flags&SPICOMMON_BUSFLAG_MASTER)?true:false;
|
|
||||||
bool use_quad=(flags&SPICOMMON_BUSFLAG_QUAD)?true:false;
|
bool use_quad=(flags&SPICOMMON_BUSFLAG_QUAD)?true:false;
|
||||||
|
|
||||||
SPI_CHECK(bus_config->mosi_io_num<0 || GPIO_IS_VALID_OUTPUT_GPIO(bus_config->mosi_io_num), "spid pin invalid", ESP_ERR_INVALID_ARG);
|
SPI_CHECK(bus_config->mosi_io_num<0 || GPIO_IS_VALID_OUTPUT_GPIO(bus_config->mosi_io_num), "spid pin invalid", ESP_ERR_INVALID_ARG);
|
||||||
@ -218,31 +217,31 @@ esp_err_t spicommon_bus_initialize_io(spi_host_device_t host, const spi_bus_conf
|
|||||||
//Use GPIO
|
//Use GPIO
|
||||||
if (bus_config->mosi_io_num>0) {
|
if (bus_config->mosi_io_num>0) {
|
||||||
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[bus_config->mosi_io_num], PIN_FUNC_GPIO);
|
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[bus_config->mosi_io_num], PIN_FUNC_GPIO);
|
||||||
gpio_set_direction(bus_config->mosi_io_num, is_master?GPIO_MODE_OUTPUT:GPIO_MODE_INPUT);
|
gpio_set_direction(bus_config->mosi_io_num, GPIO_MODE_INPUT_OUTPUT);
|
||||||
gpio_matrix_out(bus_config->mosi_io_num, io_signal[host].spid_out, false, false);
|
gpio_matrix_out(bus_config->mosi_io_num, io_signal[host].spid_out, false, false);
|
||||||
gpio_matrix_in(bus_config->mosi_io_num, io_signal[host].spid_in, false);
|
gpio_matrix_in(bus_config->mosi_io_num, io_signal[host].spid_in, false);
|
||||||
}
|
}
|
||||||
if (bus_config->miso_io_num>0) {
|
if (bus_config->miso_io_num>0) {
|
||||||
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[bus_config->miso_io_num], PIN_FUNC_GPIO);
|
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[bus_config->miso_io_num], PIN_FUNC_GPIO);
|
||||||
gpio_set_direction(bus_config->miso_io_num, is_master?GPIO_MODE_INPUT:GPIO_MODE_OUTPUT);
|
gpio_set_direction(bus_config->miso_io_num, GPIO_MODE_INPUT_OUTPUT);
|
||||||
gpio_matrix_out(bus_config->miso_io_num, io_signal[host].spiq_out, false, false);
|
gpio_matrix_out(bus_config->miso_io_num, io_signal[host].spiq_out, false, false);
|
||||||
gpio_matrix_in(bus_config->miso_io_num, io_signal[host].spiq_in, false);
|
gpio_matrix_in(bus_config->miso_io_num, io_signal[host].spiq_in, false);
|
||||||
}
|
}
|
||||||
if (use_quad && bus_config->quadwp_io_num>0) {
|
if (use_quad && bus_config->quadwp_io_num>0) {
|
||||||
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[bus_config->quadwp_io_num], PIN_FUNC_GPIO);
|
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[bus_config->quadwp_io_num], PIN_FUNC_GPIO);
|
||||||
gpio_set_direction(bus_config->quadwp_io_num, is_master?GPIO_MODE_OUTPUT:GPIO_MODE_INPUT);
|
gpio_set_direction(bus_config->quadwp_io_num, GPIO_MODE_INPUT_OUTPUT);
|
||||||
gpio_matrix_out(bus_config->quadwp_io_num, io_signal[host].spiwp_out, false, false);
|
gpio_matrix_out(bus_config->quadwp_io_num, io_signal[host].spiwp_out, false, false);
|
||||||
gpio_matrix_in(bus_config->quadwp_io_num, io_signal[host].spiwp_in, false);
|
gpio_matrix_in(bus_config->quadwp_io_num, io_signal[host].spiwp_in, false);
|
||||||
}
|
}
|
||||||
if (use_quad && bus_config->quadhd_io_num>0) {
|
if (use_quad && bus_config->quadhd_io_num>0) {
|
||||||
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[bus_config->quadhd_io_num], PIN_FUNC_GPIO);
|
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[bus_config->quadhd_io_num], PIN_FUNC_GPIO);
|
||||||
gpio_set_direction(bus_config->quadhd_io_num, is_master?GPIO_MODE_OUTPUT:GPIO_MODE_INPUT);
|
gpio_set_direction(bus_config->quadhd_io_num, GPIO_MODE_INPUT_OUTPUT);
|
||||||
gpio_matrix_out(bus_config->quadhd_io_num, io_signal[host].spihd_out, false, false);
|
gpio_matrix_out(bus_config->quadhd_io_num, io_signal[host].spihd_out, false, false);
|
||||||
gpio_matrix_in(bus_config->quadhd_io_num, io_signal[host].spihd_in, false);
|
gpio_matrix_in(bus_config->quadhd_io_num, io_signal[host].spihd_in, false);
|
||||||
}
|
}
|
||||||
if (bus_config->sclk_io_num>0) {
|
if (bus_config->sclk_io_num>0) {
|
||||||
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[bus_config->sclk_io_num], PIN_FUNC_GPIO);
|
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[bus_config->sclk_io_num], PIN_FUNC_GPIO);
|
||||||
gpio_set_direction(bus_config->sclk_io_num, is_master?GPIO_MODE_OUTPUT:GPIO_MODE_INPUT);
|
gpio_set_direction(bus_config->sclk_io_num, GPIO_MODE_INPUT_OUTPUT);
|
||||||
gpio_matrix_out(bus_config->sclk_io_num, io_signal[host].spiclk_out, false, false);
|
gpio_matrix_out(bus_config->sclk_io_num, io_signal[host].spiclk_out, false, false);
|
||||||
gpio_matrix_in(bus_config->sclk_io_num, io_signal[host].spiclk_in, false);
|
gpio_matrix_in(bus_config->sclk_io_num, io_signal[host].spiclk_in, false);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user