forked from espressif/arduino-esp32
v2.0.0 Add support for ESP32S2 and update ESP-IDF to 4.4 (#4996)
This is very much still work in progress and much more will change before the final 2.0.0 Some APIs have changed. New libraries have been added. LittleFS included. Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Mike Dunston <m_dunston@comcast.net> Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com> Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: microDev <70126934+microDev1@users.noreply.github.com> Co-authored-by: tobozo <tobozo@users.noreply.github.com> Co-authored-by: bobobo1618 <bobobo1618@users.noreply.github.com> Co-authored-by: lorol <lorolouis@gmail.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net> Co-authored-by: Sweety <switi.mhaiske@espressif.com> Co-authored-by: Loick MAHIEUX <loick111@gmail.com> Co-authored-by: Larry Bernstone <lbernstone@gmail.com> Co-authored-by: Valerii Koval <valeros@users.noreply.github.com> Co-authored-by: 快乐的我531 <2302004040@qq.com> Co-authored-by: chegewara <imperiaonline4@gmail.com> Co-authored-by: Clemens Kirchgatterer <clemens@1541.org> Co-authored-by: Aron Rubin <aronrubin@gmail.com> Co-authored-by: Pete Lewis <601236+lewispg228@users.noreply.github.com>
This commit is contained in:
@ -0,0 +1,212 @@
|
||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sdmmc_cmd.h"
|
||||
#include "driver/spi_master.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
|
||||
#define ESP_ERR_NOT_FINISHED 0x201 ///< There is still remaining data.
|
||||
|
||||
struct essl_dev_t;
|
||||
/// Handle of an ESSL device
|
||||
typedef struct essl_dev_t* essl_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize the slave.
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
* @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9.
|
||||
* @return ESP_OK if success, or other value returned from lower layer `init`.
|
||||
*/
|
||||
esp_err_t essl_init(essl_handle_t handle, uint32_t wait_ms);
|
||||
|
||||
/** Wait for interrupt of a ESP32 slave device.
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
* @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK if success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_wait_for_ready(essl_handle_t handle, uint32_t wait_ms);
|
||||
|
||||
/** Get buffer num for the host to send data to the slave. The buffers are size of ``buffer_size``.
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
* @param out_tx_num Output of buffer num that host can send data to ESP32 slave.
|
||||
* @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_get_tx_buffer_num(essl_handle_t handle, uint32_t *out_tx_num, uint32_t wait_ms);
|
||||
|
||||
/** Get amount of data the ESP32 slave preparing to send to host.
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
* @param out_rx_size Output of data size to read from slave.
|
||||
* @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_get_rx_data_size(essl_handle_t handle, uint32_t *out_rx_size, uint32_t wait_ms);
|
||||
|
||||
|
||||
/** Reset the counters of this component. Usually you don't need to do this unless you know the slave is reset.
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
*/
|
||||
esp_err_t essl_reset_cnt(essl_handle_t handle);
|
||||
|
||||
/** Send a packet to the ESP32 slave. The slave receive the packet into buffers whose size is ``buffer_size`` (configured during initialization).
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
* @param start Start address of the packet to send
|
||||
* @param length Length of data to send, if the packet is over-size, the it will be divided into blocks and hold into different buffers automatically.
|
||||
* @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_TIMEOUT No buffer to use, or error ftrom SDMMC host controller
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_send_packet(essl_handle_t handle, const void *start, size_t length, uint32_t wait_ms);
|
||||
|
||||
/** Get a packet from ESP32 slave.
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
* @param[out] out_data Data output address
|
||||
* @param size The size of the output buffer, if the buffer is smaller than the size of data to receive from slave, the driver returns ``ESP_ERR_NOT_FINISHED``
|
||||
* @param[out] out_length Output of length the data actually received from slave.
|
||||
* @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success, all the data are read from the slave.
|
||||
* - ESP_ERR_NOT_FINISHED Read success, while there're data remaining.
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_get_packet(essl_handle_t handle, void *out_data, size_t size, size_t *out_length, uint32_t wait_ms);
|
||||
|
||||
/** Write general purpose R/W registers (8-bit) of ESP32 slave.
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
* @param addr Address of register to write. Valid address: 0-59.
|
||||
* @param value Value to write to the register.
|
||||
* @param value_o Output of the returned written value.
|
||||
* @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9.
|
||||
*
|
||||
* @note sdio 28-31 are reserved, the lower API helps to skip.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Address not valid.
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_write_reg(essl_handle_t handle, uint8_t addr, uint8_t value, uint8_t *value_o, uint32_t wait_ms);
|
||||
|
||||
/** Read general purpose R/W registers (8-bit) of ESP32 slave.
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
* @param add Address of register to read. Valid address: 0-27, 32-63 (28-31 reserved, return interrupt bits on read).
|
||||
* @param value_o Output value read from the register.
|
||||
* @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Address not valid.
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_read_reg(essl_handle_t handle, uint8_t add, uint8_t *value_o, uint32_t wait_ms);
|
||||
|
||||
/** wait for an interrupt of the slave
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
* @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_NOT_SUPPORTED Currently our driver doesnot support SDIO with SPI interface.
|
||||
* - ESP_OK If interrupt triggered.
|
||||
* - ESP_ERR_TIMEOUT No interrupts before timeout.
|
||||
*/
|
||||
esp_err_t essl_wait_int(essl_handle_t handle, uint32_t wait_ms);
|
||||
|
||||
/** Clear interrupt bits of ESP32 slave. All the bits set in the mask will be cleared, while other bits will stay the same.
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
* @param intr_mask Mask of interrupt bits to clear.
|
||||
* @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_clear_intr(essl_handle_t handle, uint32_t intr_mask, uint32_t wait_ms);
|
||||
|
||||
/** Get interrupt bits of ESP32 slave.
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
* @param intr_raw Output of the raw interrupt bits. Set to NULL if only masked bits are read.
|
||||
* @param intr_st Output of the masked interrupt bits. set to NULL if only raw bits are read.
|
||||
* @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_INVALID_ARG if both ``intr_raw`` and ``intr_st`` are NULL.
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_get_intr(essl_handle_t handle, uint32_t *intr_raw, uint32_t *intr_st, uint32_t wait_ms);
|
||||
|
||||
/** Set interrupt enable bits of ESP32 slave. The slave only sends interrupt on the line when there is a bit both the raw status and the enable are set.
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
* @param ena_mask Mask of the interrupt bits to enable.
|
||||
* @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_set_intr_ena(essl_handle_t handle, uint32_t ena_mask, uint32_t wait_ms);
|
||||
|
||||
/** Get interrupt enable bits of ESP32 slave.
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
* @param ena_mask_o Output of interrupt bit enable mask.
|
||||
* @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_get_intr_ena(essl_handle_t handle, uint32_t *ena_mask_o, uint32_t wait_ms);
|
||||
|
||||
/** Send interrupts to slave. Each bit of the interrupt will be triggered.
|
||||
*
|
||||
* @param handle Handle of a ``essl`` device.
|
||||
* @param intr_mask Mask of interrupt bits to send to slave.
|
||||
* @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_send_slave_intr(essl_handle_t handle, uint32_t intr_mask, uint32_t wait_ms);
|
@ -0,0 +1,248 @@
|
||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// ESP SDIO slave link used by the ESP host to communicate with ESP32 SDIO slave.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_serial_slave_link/essl.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "driver/sdmmc_defs.h"
|
||||
|
||||
/// Configuration for the essl SDIO device
|
||||
typedef struct {
|
||||
sdmmc_card_t *card; ///< The initialized sdmmc card pointer of the slave.
|
||||
int recv_buffer_size; ///< The pre-negotiated recv buffer size used by both the host and the slave.
|
||||
} essl_sdio_config_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize the ESSL SDIO device and get its handle.
|
||||
*
|
||||
* @param out_handle Output of the handle.
|
||||
* @param config Configuration for the ESSL SDIO device.
|
||||
* @return
|
||||
* - ESP_OK: on success
|
||||
* - ESP_ERR_NO_MEM: memory exhausted.
|
||||
*/
|
||||
esp_err_t essl_sdio_init_dev(essl_handle_t *out_handle, const essl_sdio_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize and free the space used by the ESSL SDIO device.
|
||||
*
|
||||
* @param handle Handle of the ESSL SDIO device to deinit.
|
||||
* @return
|
||||
* - ESP_OK: on success
|
||||
* - ESP_ERR_INVALID_ARG: wrong handle passed
|
||||
*/
|
||||
esp_err_t essl_sdio_deinit_dev(essl_handle_t handle);
|
||||
|
||||
//Please call `essl_` functions witout `sdio` instead of calling these functions directly.
|
||||
/** @cond */
|
||||
/**
|
||||
* SDIO Initialize process of a ESP32 slave device.
|
||||
*
|
||||
* @param arg Context of the ``essl`` component. Send to other functions later.
|
||||
* @param wait_ms Time to wait before operation is done, in ms.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK if success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_sdio_init(void *arg, uint32_t wait_ms);
|
||||
|
||||
/**
|
||||
* Wait for interrupt of a ESP32 slave device.
|
||||
*
|
||||
* @param arg Context of the ``essl`` component.
|
||||
* @param wait_ms Time to wait before operation is done, in ms.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK if success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_sdio_wait_for_ready(void *arg, uint32_t wait_ms);
|
||||
|
||||
/**
|
||||
* Get buffer num for the host to send data to the slave. The buffers are size of ``buffer_size``.
|
||||
*
|
||||
* @param arg Context of the component.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
uint32_t essl_sdio_get_tx_buffer_num(void *arg);
|
||||
|
||||
/** Get amount of data the ESP32 slave preparing to send to host.
|
||||
*
|
||||
* @param arg Context of the component.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
uint32_t essl_sdio_get_rx_data_size(void *arg);
|
||||
|
||||
/**
|
||||
* Send a packet to the ESP32 slave. The slave receive the packet into buffers whose size is ``buffer_size`` in the arg.
|
||||
*
|
||||
* @param arg Context of the component.
|
||||
* @param start Start address of the packet to send
|
||||
* @param length Length of data to send, if the packet is over-size, the it will be divided into blocks and hold into different buffers automatically.
|
||||
* @param wait_ms Time to wait before timeout, in ms.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_TIMEOUT No buffer to use, or error ftrom SDMMC host controller
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_sdio_send_packet(void *arg, const void *start, size_t length, uint32_t wait_ms);
|
||||
|
||||
/**
|
||||
* Get a packet from ESP32 slave.
|
||||
*
|
||||
* @param arg Context of the component.
|
||||
* @param[out] out_data Data output address
|
||||
* @param size The size of the output buffer, if the buffer is smaller than the size of data to receive from slave, the driver returns ``ESP_ERR_NOT_FINISHED``
|
||||
* @param wait_ms Time to wait before timeout, in ms.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success, all the data are read from the slave.
|
||||
* - ESP_ERR_NOT_FINISHED Read success, while there're data remaining.
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_sdio_get_packet(void *arg, void *out_data, size_t size, uint32_t wait_ms);
|
||||
|
||||
/**
|
||||
* Wait for the interrupt from the SDIO slave.
|
||||
*
|
||||
* @param arg Context of the component.
|
||||
* @param wait_ms Time to wait before timeout, in ms.
|
||||
* @return
|
||||
* - ESP_ERR_NOT_SUPPORTED: if the interrupt line is not initialized properly.
|
||||
* - ESP_OK: if interrupt happened
|
||||
* - ESP_ERR_TIMEOUT: if timeout before interrupt happened.
|
||||
* - or other values returned from the `io_int_wait` member of the `card->host` structure.
|
||||
*/
|
||||
esp_err_t essl_sdio_wait_int(void *arg, uint32_t wait_ms);
|
||||
|
||||
/**
|
||||
* Clear interrupt bits of ESP32 slave. All the bits set in the mask will be cleared, while other bits will stay the same.
|
||||
*
|
||||
* @param arg Context of the component.
|
||||
* @param intr_mask Mask of interrupt bits to clear.
|
||||
* @param wait_ms Time to wait before timeout, in ms.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_sdio_clear_intr(void *arg, uint32_t intr_mask, uint32_t wait_ms);
|
||||
|
||||
/**
|
||||
* Get interrupt bits of ESP32 slave.
|
||||
*
|
||||
* @param arg Context of the component.
|
||||
* @param intr_raw Output of the raw interrupt bits. Set to NULL if only masked bits are read.
|
||||
* @param intr_st Output of the masked interrupt bits. set to NULL if only raw bits are read.
|
||||
* @param wait_ms Time to wait before timeout, in ms.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_INVALID_ARG if both ``intr_raw`` and ``intr_st`` are NULL.
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_sdio_get_intr(void *arg, uint32_t *intr_raw, uint32_t *intr_st, uint32_t wait_ms);
|
||||
|
||||
/**
|
||||
* Set interrupt enable bits of ESP32 slave. The slave only sends interrupt on the line when there is a bit both the raw status and the enable are set.
|
||||
*
|
||||
* @param arg Context of the component.
|
||||
* @param ena_mask Mask of the interrupt bits to enable.
|
||||
* @param wait_ms Time to wait before timeout, in ms.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_sdio_set_intr_ena(void *arg, uint32_t ena_mask, uint32_t wait_ms);
|
||||
|
||||
/**
|
||||
* Get interrupt enable bits of ESP32 slave.
|
||||
*
|
||||
* @param arg Context of the component.
|
||||
* @param ena_mask_o Output of interrupt bit enable mask.
|
||||
* @param wait_ms Time to wait before timeout, in ms.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_sdio_get_intr_ena(void *arg, uint32_t *ena_mask_o, uint32_t wait_ms);
|
||||
|
||||
/**
|
||||
* Write general purpose R/W registers (8-bit) of ESP32 slave.
|
||||
*
|
||||
* @param arg Context of the component.
|
||||
* @param addr Address of register to write. Valid address: 0-27, 32-63 (28-31 reserved).
|
||||
* @param value Value to write to the register.
|
||||
* @param wait_ms Time to wait before timeout, in ms.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Address not valid.
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_sdio_write_reg(void *arg, uint8_t addr, uint8_t value, uint8_t *value_o, uint32_t wait_ms);
|
||||
|
||||
/**
|
||||
* Read general purpose R/W registers (8-bit) of ESP32 slave.
|
||||
*
|
||||
* @param arg Context of the component.
|
||||
* @param add Address of register to read. Valid address: 0-27, 32-63 (28-31 reserved, return interrupt bits on read).
|
||||
* @param value Output value read from the register.
|
||||
* @param wait_ms Time to wait before timeout, in ms.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Address not valid.
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_sdio_read_reg(void *arg, uint8_t add, uint8_t *value_o, uint32_t wait_ms);
|
||||
|
||||
/**
|
||||
* Send interrupts to slave. Each bit of the interrupt will be triggered.
|
||||
*
|
||||
* @param arg Context of the component.
|
||||
* @param intr_mask Mask of interrupt bits to send to slave.
|
||||
* @param wait_ms Time to wait before timeout, in ms.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - One of the error codes from SDMMC host controller
|
||||
*/
|
||||
esp_err_t essl_sdio_send_slave_intr(void *arg, uint32_t intr_mask, uint32_t wait_ms);
|
||||
|
||||
/**
|
||||
* @brief Reset the counter on the host side.
|
||||
*
|
||||
* @note Only call when you know the slave has reset its counter, or there will be inconsistent between the master and the slave.
|
||||
*
|
||||
* @param arg Context of the component.
|
||||
*/
|
||||
void essl_sdio_reset_cnt(void *arg);
|
||||
|
||||
/** @endcond */
|
@ -0,0 +1,165 @@
|
||||
// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_serial_slave_link/essl.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Basic commands to communicate with the SPI Slave HD on ESP32-S2
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @brief Read the shared buffer from the slave.
|
||||
*
|
||||
* @note ``out_data`` should be prepared in words and in the DRAM. The buffer may be written in words
|
||||
* by the DMA. When a byte is written, the remaining bytes in the same word will also be
|
||||
* overwritten, even the ``len`` is shorter than a word.
|
||||
*
|
||||
* @param spi SPI device handle representing the slave
|
||||
* @param out_data Buffer for read data, strongly suggested to be in the DRAM and align to 4
|
||||
* @param addr Address of the slave shared buffer
|
||||
* @param len Length to read
|
||||
* @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send.
|
||||
* @return
|
||||
* - ESP_OK: on success
|
||||
* - or other return value from :cpp:func:`spi_device_transmit`.
|
||||
*/
|
||||
esp_err_t essl_spi_rdbuf(spi_device_handle_t spi, uint8_t *out_data, int addr, int len, uint32_t flags);
|
||||
|
||||
/**
|
||||
* @brief Write the shared buffer of the slave.
|
||||
*
|
||||
* @note ``out_data`` should be prepared in words and in the DRAM. The buffer may be written in words
|
||||
* by the DMA. When a byte is written, the remaining bytes in the same word will also be
|
||||
* overwritten, even the ``len`` is shorter than a word.
|
||||
*
|
||||
* @param spi SPI device handle representing the slave
|
||||
* @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4
|
||||
* @param addr Address of the slave shared buffer,
|
||||
* @param len Length to write
|
||||
* @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send.
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - or other return value from :cpp:func:`spi_device_transmit`.
|
||||
*/
|
||||
esp_err_t essl_spi_wrbuf(spi_device_handle_t spi, const uint8_t *data, int addr, int len, uint32_t flags);
|
||||
|
||||
/**
|
||||
* @brief Receive long buffer in segments from the slave through its DMA.
|
||||
*
|
||||
* @note This function combines several :cpp:func:`essl_spi_rddma_seg` and one
|
||||
* :cpp:func:`essl_spi_rddma_done` at the end. Used when the slave is working in segment mode.
|
||||
*
|
||||
* @param spi SPI device handle representing the slave
|
||||
* @param out_data Buffer to hold the received data, strongly suggested to be in the DRAM and align to 4
|
||||
* @param len Total length of data to receive.
|
||||
* @param seg_len Length of each segment, which is not larger than the maximum transaction length
|
||||
* allowed for the spi device. Suggested to be multiples of 4. When set < 0, means send
|
||||
* all data in one segment (the ``rddma_done`` will still be sent.)
|
||||
* @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send.
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - or other return value from :cpp:func:`spi_device_transmit`.
|
||||
*/
|
||||
esp_err_t essl_spi_rddma(spi_device_handle_t spi, uint8_t *out_data, int len, int seg_len, uint32_t flags);
|
||||
|
||||
/**
|
||||
* @brief Read one data segment from the slave through its DMA.
|
||||
*
|
||||
* @note To read long buffer, call :cpp:func:`essl_spi_rddma` instead.
|
||||
*
|
||||
* @param spi SPI device handle representing the slave
|
||||
* @param out_data Buffer to hold the received data, strongly suggested to be in the DRAM and align to 4
|
||||
* @param seg_len Length of this segment
|
||||
* @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send.
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - or other return value from :cpp:func:`spi_device_transmit`.
|
||||
*/
|
||||
esp_err_t essl_spi_rddma_seg(spi_device_handle_t spi, uint8_t *out_data, int seg_len, uint32_t flags);
|
||||
|
||||
/**
|
||||
* @brief Send the ``rddma_done`` command to the slave. Upon receiving this command, the slave will
|
||||
* stop sending the current buffer even there are data unsent, and maybe prepare the next buffer to
|
||||
* send.
|
||||
*
|
||||
* @note This is required only when the slave is working in segment mode.
|
||||
*
|
||||
* @param spi SPI device handle representing the slave
|
||||
* @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send.
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - or other return value from :cpp:func:`spi_device_transmit`.
|
||||
*/
|
||||
esp_err_t essl_spi_rddma_done(spi_device_handle_t spi, uint32_t flags);
|
||||
|
||||
/**
|
||||
* @brief Send long buffer in segments to the slave through its DMA.
|
||||
*
|
||||
* @note This function combines several :cpp:func:`essl_spi_wrdma_seg` and one
|
||||
* :cpp:func:`essl_spi_wrdma_done` at the end. Used when the slave is working in segment mode.
|
||||
*
|
||||
* @param spi SPI device handle representing the slave
|
||||
* @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4
|
||||
* @param len Total length of data to send.
|
||||
* @param seg_len Length of each segment, which is not larger than the maximum transaction length
|
||||
* allowed for the spi device. Suggested to be multiples of 4. When set < 0, means send
|
||||
* all data in one segment (the ``wrdma_done`` will still be sent.)
|
||||
* @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send.
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - or other return value from :cpp:func:`spi_device_transmit`.
|
||||
*/
|
||||
esp_err_t essl_spi_wrdma(spi_device_handle_t spi, const uint8_t *data, int len, int seg_len, uint32_t flags);
|
||||
|
||||
/**
|
||||
* @brief Send one data segment to the slave through its DMA.
|
||||
*
|
||||
* @note To send long buffer, call :cpp:func:`essl_spi_wrdma` instead.
|
||||
*
|
||||
* @param spi SPI device handle representing the slave
|
||||
* @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4
|
||||
* @param seg_len Length of this segment
|
||||
* @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send.
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - or other return value from :cpp:func:`spi_device_transmit`.
|
||||
*/
|
||||
esp_err_t essl_spi_wrdma_seg(spi_device_handle_t spi, const uint8_t *data, int seg_len, uint32_t flags);
|
||||
|
||||
/**
|
||||
* @brief Send the ``wrdma_done`` command to the slave. Upon receiving this command, the slave will
|
||||
* stop receiving, process the received data, and maybe prepare the next buffer to receive.
|
||||
*
|
||||
* @note This is required only when the slave is working in segment mode.
|
||||
*
|
||||
* @param spi SPI device handle representing the slave
|
||||
* @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send.
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - or other return value from :cpp:func:`spi_device_transmit`.
|
||||
*/
|
||||
esp_err_t essl_spi_wrdma_done(spi_device_handle_t spi, uint32_t flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,38 @@
|
||||
// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
// NOTE: From the view of master
|
||||
#define CMD_HD_WRBUF_REG 0x01
|
||||
#define CMD_HD_RDBUF_REG 0x02
|
||||
#define CMD_HD_WRDMA_REG 0x03
|
||||
#define CMD_HD_RDDMA_REG 0x04
|
||||
|
||||
#define CMD_HD_ONEBIT_MODE 0x00
|
||||
#define CMD_HD_DOUT_MODE 0x10
|
||||
#define CMD_HD_QOUT_MODE 0x20
|
||||
#define CMD_HD_DIO_MODE 0x50
|
||||
#define CMD_HD_QIO_MODE 0xA0
|
||||
|
||||
#define CMD_HD_SEG_END_REG 0x05
|
||||
#define CMD_HD_EN_QPI_REG 0x06
|
||||
#define CMD_HD_WR_END_REG 0x07
|
||||
#define CMD_HD_INT0_REG 0x08
|
||||
#define CMD_HD_INT1_REG 0x09
|
||||
#define CMD_HD_INT2_REG 0x0A
|
||||
#define CMD_HD_EX_QPI_REG 0xDD
|
||||
|
||||
#define SPI_SLAVE_HD_BUFFER_SIZE 64
|
@ -0,0 +1,38 @@
|
||||
// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
// NOTE: From the view of master
|
||||
#define CMD_HD_WRBUF_REG 0x01
|
||||
#define CMD_HD_RDBUF_REG 0x02
|
||||
#define CMD_HD_WRDMA_REG 0x03
|
||||
#define CMD_HD_RDDMA_REG 0x04
|
||||
|
||||
#define CMD_HD_ONEBIT_MODE 0x00
|
||||
#define CMD_HD_DOUT_MODE 0x10
|
||||
#define CMD_HD_QOUT_MODE 0x20
|
||||
#define CMD_HD_DIO_MODE 0x50
|
||||
#define CMD_HD_QIO_MODE 0xA0
|
||||
|
||||
#define CMD_HD_SEG_END_REG 0x05
|
||||
#define CMD_HD_EN_QPI_REG 0x06
|
||||
#define CMD_HD_WR_END_REG 0x07
|
||||
#define CMD_HD_INT0_REG 0x08
|
||||
#define CMD_HD_INT1_REG 0x09
|
||||
#define CMD_HD_INT2_REG 0x0A
|
||||
#define CMD_HD_EX_QPI_REG 0xDD
|
||||
|
||||
#define SPI_SLAVE_HD_BUFFER_SIZE 72
|
@ -0,0 +1,38 @@
|
||||
// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
// NOTE: From the view of master
|
||||
#define CMD_HD_WRBUF_REG 0x01
|
||||
#define CMD_HD_RDBUF_REG 0x02
|
||||
#define CMD_HD_WRDMA_REG 0x03
|
||||
#define CMD_HD_RDDMA_REG 0x04
|
||||
|
||||
#define CMD_HD_ONEBIT_MODE 0x00
|
||||
#define CMD_HD_DOUT_MODE 0x10
|
||||
#define CMD_HD_QOUT_MODE 0x20
|
||||
#define CMD_HD_DIO_MODE 0x50
|
||||
#define CMD_HD_QIO_MODE 0xA0
|
||||
|
||||
#define CMD_HD_SEG_END_REG 0x05
|
||||
#define CMD_HD_EN_QPI_REG 0x06
|
||||
#define CMD_HD_WR_END_REG 0x07
|
||||
#define CMD_HD_INT0_REG 0x08
|
||||
#define CMD_HD_INT1_REG 0x09
|
||||
#define CMD_HD_INT2_REG 0x0A
|
||||
#define CMD_HD_EX_QPI_REG 0xDD
|
||||
|
||||
#define SPI_SLAVE_HD_BUFFER_SIZE 64
|
Reference in New Issue
Block a user