Add stopDMAtransfer function

This commit is contained in:
mrfaptastic 2021-02-20 22:29:22 +00:00
parent 6cab840dfc
commit f7aaad842b
3 changed files with 27 additions and 1 deletions

View file

@ -538,6 +538,16 @@ class MatrixPanel_I2S_DMA {
* *
*/ */
const HUB75_I2S_CFG& getCfg() const {return m_cfg;}; const HUB75_I2S_CFG& getCfg() const {return m_cfg;};
/**
* Stop the ESP32 DMA Engine. Screen will forever be black until next ESP reboot.
*/
void stopDMAoutput() {
clearScreen();
i2s_parallel_stop_dma(I2S_NUM_1);
}
// ------- PROTECTED ------- // ------- PROTECTED -------
@ -592,7 +602,6 @@ class MatrixPanel_I2S_DMA {
void fillRectDMA(int16_t x_coord, int16_t y_coord, int16_t w, int16_t h, uint8_t r, uint8_t g, uint8_t b); void fillRectDMA(int16_t x_coord, int16_t y_coord, int16_t w, int16_t h, uint8_t r, uint8_t g, uint8_t b);
#endif #endif
// ------- PRIVATE ------- // ------- PRIVATE -------
private: private:

View file

@ -299,6 +299,22 @@ esp_err_t i2s_parallel_driver_install(i2s_port_t port, i2s_parallel_config_t* co
return ESP_OK; return ESP_OK;
} }
esp_err_t i2s_parallel_stop_dma(i2s_port_t port) {
if(port < I2S_NUM_0 || port >= I2S_NUM_MAX) {
return ESP_ERR_INVALID_ARG;
}
i2s_dev_t* dev = I2S[port];
// Stop all ongoing DMA operations
dev->out_link.stop = 1;
dev->out_link.start = 0;
dev->conf.tx_start = 0;
return ESP_OK;
}
esp_err_t i2s_parallel_send_dma(i2s_port_t port, lldesc_t* dma_descriptor) { esp_err_t i2s_parallel_send_dma(i2s_port_t port, lldesc_t* dma_descriptor) {
if(port < I2S_NUM_0 || port >= I2S_NUM_MAX) { if(port < I2S_NUM_0 || port >= I2S_NUM_MAX) {
return ESP_ERR_INVALID_ARG; return ESP_ERR_INVALID_ARG;

View file

@ -66,6 +66,7 @@ void link_dma_desc(volatile lldesc_t *dmadesc, volatile lldesc_t *prevdmadesc, v
// I2S DMA Peripheral Setup Functions // I2S DMA Peripheral Setup Functions
esp_err_t i2s_parallel_driver_install(i2s_port_t port, i2s_parallel_config_t* conf); esp_err_t i2s_parallel_driver_install(i2s_port_t port, i2s_parallel_config_t* conf);
esp_err_t i2s_parallel_send_dma(i2s_port_t port, lldesc_t* dma_descriptor); esp_err_t i2s_parallel_send_dma(i2s_port_t port, lldesc_t* dma_descriptor);
esp_err_t i2s_parallel_stop_dma(i2s_port_t port);
i2s_dev_t* i2s_parallel_get_dev(i2s_port_t port); i2s_dev_t* i2s_parallel_get_dev(i2s_port_t port);
// For frame buffer flipping / double buffering // For frame buffer flipping / double buffering