ESP32-HUB75-MatrixPanel-DMA/esp32_i2s_parallel.h

66 lines
1.4 KiB
C
Raw Permalink Normal View History

#ifndef I2S_PARALLEL_H
#define I2S_PARALLEL_H
#if defined(ESP32) || defined(IDF_VER)
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "driver/gpio.h"
#include "soc/i2s_struct.h"
#if defined(IDF_VER)
#include "esp32/rom/lldesc.h"
#elif defined(ESP32)
#include "rom/lldesc.h"
#endif
#define DMA_MAX (4096-4)
//#define DMA_MAX (512)
typedef enum {
2020-07-29 11:44:38 +02:00
I2S_PARALLEL_BITS_8=8,
I2S_PARALLEL_BITS_16=16,
I2S_PARALLEL_BITS_32=32,
} i2s_parallel_cfg_bits_t;
typedef struct {
void *memory;
size_t size;
} i2s_parallel_buffer_desc_t;
typedef struct {
int gpio_bus[24];
int gpio_clk;
int clkspeed_hz;
i2s_parallel_cfg_bits_t bits;
i2s_parallel_buffer_desc_t *bufa;
2020-07-29 11:44:38 +02:00
i2s_parallel_buffer_desc_t *bufb; // only used with double buffering
int desccount_a;
2020-07-29 11:44:38 +02:00
int desccount_b; // only used with double buffering
lldesc_t * lldesc_a;
2020-07-29 11:44:38 +02:00
lldesc_t * lldesc_b; // only used with double buffering
} i2s_parallel_config_t;
void i2s_parallel_setup_without_malloc(i2s_dev_t *dev, const i2s_parallel_config_t *cfg);
2020-07-29 11:44:38 +02:00
void link_dma_desc(volatile lldesc_t *dmadesc, volatile lldesc_t *prevdmadesc, void *memory, size_t size);
void i2s_parallel_flip_to_buffer(i2s_dev_t *dev, int bufid);
bool i2s_parallel_is_previous_buffer_free();
2020-07-29 11:44:38 +02:00
typedef void (*callback)(void);
void setShiftCompleteCallback(callback f);
#ifdef __cplusplus
}
#endif
#endif
#endif