Skip to content

Commit

Permalink
cpu/esp32: port periph/spi to ESP-IDF spi LL API
Browse files Browse the repository at this point in the history
  • Loading branch information
gschorcht committed Jul 15, 2022
1 parent 2276f4f commit fdbe37a
Show file tree
Hide file tree
Showing 2 changed files with 438 additions and 3 deletions.
27 changes: 24 additions & 3 deletions cpu/esp32/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@

#include <stdint.h>
#include "sdkconfig.h"
#include "hal/ledc_types.h"
#include "hal/spi_types.h"
#include "soc/ledc_struct.h"
#include "soc/periph_defs.h"
#include "soc/soc_caps.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -468,12 +473,28 @@ typedef struct {
* @{
*/

#ifndef DOXYGEN
/**
* @brief Override SPI clock speed values
* @{
*/
#define HAVE_SPI_CLK_T
typedef enum {
SPI_CLK_100KHZ = 100000, /**< drive the SPI bus with 100KHz */
SPI_CLK_400KHZ = 400000, /**< drive the SPI bus with 400KHz */
SPI_CLK_1MHZ = 1000000, /**< drive the SPI bus with 1MHz */
SPI_CLK_5MHZ = 5000000, /**< drive the SPI bus with 5MHz */
SPI_CLK_10MHZ = 10000000 /**< drive the SPI bus with 10MHz */
} spi_clk_t;
/** @} */
#endif /* !DOXYGEN */

/**
* @brief SPI controllers that can be used for peripheral interfaces
*/
typedef enum {
HSPI = 2, /**< HSPI interface controller */
VSPI = 3, /**< VSPI interface controller */
HSPI = HSPI_HOST, /**< HSPI interface controller */
VSPI = VSPI_HOST, /**< VSPI interface controller */
} spi_ctrl_t;

/**
Expand All @@ -490,7 +511,7 @@ typedef struct {
/**
* @brief Maximum number of SPI interfaces that can be used by board definitions
*/
#define SPI_NUMOF_MAX 2
#define SPI_NUMOF_MAX (SOC_SPI_PERIPH_NUM - 1)

#define PERIPH_SPI_NEEDS_TRANSFER_BYTE /**< requires function spi_transfer_byte */
#define PERIPH_SPI_NEEDS_TRANSFER_REG /**< requires function spi_transfer_reg */
Expand Down
Loading

0 comments on commit fdbe37a

Please sign in to comment.