mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feat(esp_driver_spi): add config for data io default level
This commit is contained in:
parent
8fcc57b12f
commit
ab53d300d0
@ -116,6 +116,7 @@ typedef struct {
|
||||
int data5_io_num; ///< GPIO pin for spi data5 signal in octal mode, or -1 if not used.
|
||||
int data6_io_num; ///< GPIO pin for spi data6 signal in octal mode, or -1 if not used.
|
||||
int data7_io_num; ///< GPIO pin for spi data7 signal in octal mode, or -1 if not used.
|
||||
bool data_io_default_level; ///< Output data IO default level when no transaction.
|
||||
int max_transfer_sz; ///< Maximum transfer size, in bytes. Defaults to 4092 if 0 when DMA enabled, or to `SOC_SPI_MAXIMUM_BUFFER_SIZE` if DMA is disabled.
|
||||
uint32_t flags; ///< Abilities of bus to be checked by the driver. Or-ed value of ``SPICOMMON_BUSFLAG_*`` flags.
|
||||
esp_intr_cpu_affinity_t isr_cpu_id; ///< Select cpu core to register SPI ISR.
|
||||
|
@ -314,6 +314,7 @@ static esp_err_t spi_master_init_driver(spi_host_device_t host_id)
|
||||
spi_ll_enable_clock(host_id, true);
|
||||
}
|
||||
spi_hal_init(&host->hal, host_id);
|
||||
spi_hal_config_io_default_level(&host->hal, bus_attr->bus_cfg.data_io_default_level);
|
||||
|
||||
if (host_id != SPI1_HOST) {
|
||||
//SPI1 attributes are already initialized at start up.
|
||||
|
@ -168,6 +168,14 @@ typedef struct {
|
||||
*/
|
||||
void spi_hal_init(spi_hal_context_t *hal, uint32_t host_id);
|
||||
|
||||
/**
|
||||
* Config default output IO level when don't have transaction
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param level IO level to config
|
||||
*/
|
||||
void spi_hal_config_io_default_level(spi_hal_context_t *hal, bool level);
|
||||
|
||||
/**
|
||||
* Deinit the peripheral (and the context if needed).
|
||||
*
|
||||
|
@ -26,11 +26,6 @@ void spi_hal_init(spi_hal_context_t *hal, uint32_t host_id)
|
||||
memset(hal, 0, sizeof(spi_hal_context_t));
|
||||
spi_dev_t *hw = SPI_LL_GET_HW(host_id);
|
||||
hal->hw = hw;
|
||||
|
||||
#if SPI_LL_MOSI_FREE_LEVEL
|
||||
// Change default data line level to low which same as esp32
|
||||
spi_ll_set_mosi_free_level(hw, 0);
|
||||
#endif
|
||||
spi_ll_master_init(hw);
|
||||
|
||||
//Force a transaction done interrupt. This interrupt won't fire yet because
|
||||
@ -43,6 +38,17 @@ void spi_hal_init(spi_hal_context_t *hal, uint32_t host_id)
|
||||
spi_ll_apply_config(hw);
|
||||
}
|
||||
|
||||
void spi_hal_config_io_default_level(spi_hal_context_t *hal, bool level)
|
||||
{
|
||||
#if SPI_LL_MOSI_FREE_LEVEL
|
||||
// Config default output data line level when don't have transaction
|
||||
spi_ll_set_mosi_free_level(hal->hw, level);
|
||||
spi_ll_apply_config(hal->hw);
|
||||
#else
|
||||
HAL_LOGW(SPI_HAL_TAG, "The target don't support this config")
|
||||
#endif
|
||||
}
|
||||
|
||||
void spi_hal_deinit(spi_hal_context_t *hal)
|
||||
{
|
||||
spi_dev_t *hw = hal->hw;
|
||||
|
Loading…
Reference in New Issue
Block a user