force common intr alloc flags for all platform components that use rmt

remove ESP_INTR_FLAG_IRAM to fix #2564
This commit is contained in:
devsaurus 2019-05-31 23:34:15 +02:00
parent 5faf76b762
commit e30904b607
6 changed files with 44 additions and 32 deletions

View File

@ -25,6 +25,7 @@
* ****************************************************************************/ * ****************************************************************************/
#include "platform.h" #include "platform.h"
#include "platform_rmt.h"
#include "driver/rmt.h" #include "driver/rmt.h"
#include "driver/gpio.h" #include "driver/gpio.h"
@ -91,7 +92,7 @@ static int dht_init( uint8_t gpio_num )
rmt_rx.rx_config.filter_ticks_thresh = 30; rmt_rx.rx_config.filter_ticks_thresh = 30;
rmt_rx.rx_config.idle_threshold = DHT_DURATION_RX_IDLE; rmt_rx.rx_config.idle_threshold = DHT_DURATION_RX_IDLE;
if (rmt_config( &rmt_rx ) == ESP_OK) { if (rmt_config( &rmt_rx ) == ESP_OK) {
if (rmt_driver_install( rmt_rx.channel, 512, ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_SHARED ) == ESP_OK) { if (rmt_driver_install( rmt_rx.channel, 512, PLATFORM_RMT_INTR_FLAGS ) == ESP_OK) {
rmt_get_ringbuf_handle( dht_rmt.channel, &dht_rmt.rb ); rmt_get_ringbuf_handle( dht_rmt.channel, &dht_rmt.rb );

View File

@ -179,30 +179,6 @@ int platform_i2c_send_byte( unsigned id, uint8_t data, int ack_check_en );
int platform_i2c_recv_byte( unsigned id, int ack_val ); int platform_i2c_recv_byte( unsigned id, int ack_val );
// *****************************************************************************
// RMT platform interface
/**
* @brief Allocate an RMT channel.
*
* @param num_mem Number of memory blocks.
*
* @return
* - Channel number when successful
* - -1 if no channel available
*
*/
int platform_rmt_allocate( uint8_t num_mem );
/**
* @brief Release a previously allocated RMT channel.
*
* @param channel Channel number.
*
*/
void platform_rmt_release( uint8_t channel );
// ***************************************************************************** // *****************************************************************************
// Onewire platform interface // Onewire platform interface

View File

@ -0,0 +1,33 @@
#ifndef _PLATFORM_RMT_H_
#define _PLATFORM_RMT_H_
#include "driver/rmt.h"
// define a common set of esp interrupt allocation flags for common use
#define PLATFORM_RMT_INTR_FLAGS (ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_SHARED)
// *****************************************************************************
// RMT platform interface
/**
* @brief Allocate an RMT channel.
*
* @param num_mem Number of memory blocks.
*
* @return
* - Channel number when successful
* - -1 if no channel available
*
*/
int platform_rmt_allocate( uint8_t num_mem );
/**
* @brief Release a previously allocated RMT channel.
*
* @param channel Channel number.
*
*/
void platform_rmt_release( uint8_t channel );
#endif

View File

@ -59,6 +59,7 @@ sample code bearing this copyright.
*/ */
#include "platform.h" #include "platform.h"
#include "platform_rmt.h"
#include "driver/rmt.h" #include "driver/rmt.h"
#include "driver/gpio.h" #include "driver/gpio.h"
@ -127,7 +128,7 @@ static int onewire_rmt_init( uint8_t gpio_num )
rmt_tx.tx_config.idle_output_en = true; rmt_tx.tx_config.idle_output_en = true;
rmt_tx.rmt_mode = RMT_MODE_TX; rmt_tx.rmt_mode = RMT_MODE_TX;
if (rmt_config( &rmt_tx ) == ESP_OK) { if (rmt_config( &rmt_tx ) == ESP_OK) {
if (rmt_driver_install( rmt_tx.channel, 0, ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_SHARED ) == ESP_OK) { if (rmt_driver_install( rmt_tx.channel, 0, PLATFORM_RMT_INTR_FLAGS ) == ESP_OK) {
rmt_config_t rmt_rx; rmt_config_t rmt_rx;
rmt_rx.channel = ow_rmt.rx; rmt_rx.channel = ow_rmt.rx;
@ -139,7 +140,7 @@ static int onewire_rmt_init( uint8_t gpio_num )
rmt_rx.rx_config.filter_ticks_thresh = 30; rmt_rx.rx_config.filter_ticks_thresh = 30;
rmt_rx.rx_config.idle_threshold = OW_DURATION_RX_IDLE; rmt_rx.rx_config.idle_threshold = OW_DURATION_RX_IDLE;
if (rmt_config( &rmt_rx ) == ESP_OK) { if (rmt_config( &rmt_rx ) == ESP_OK) {
if (rmt_driver_install( rmt_rx.channel, 512, ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_SHARED ) == ESP_OK) { if (rmt_driver_install( rmt_rx.channel, 512, PLATFORM_RMT_INTR_FLAGS ) == ESP_OK) {
rmt_get_ringbuf_handle( ow_rmt.rx, &ow_rmt.rb ); rmt_get_ringbuf_handle( ow_rmt.rx, &ow_rmt.rb );

View File

@ -1,6 +1,6 @@
#include "platform.h"
#include <string.h> #include <string.h>
#include "platform_rmt.h"
#include "driver/rmt.h" #include "driver/rmt.h"

View File

@ -24,6 +24,7 @@
* ****************************************************************************/ * ****************************************************************************/
#include "platform.h" #include "platform.h"
#include "platform_rmt.h"
#include "driver/rmt.h" #include "driver/rmt.h"
#include "driver/gpio.h" #include "driver/gpio.h"
@ -79,7 +80,7 @@ static ws2812_chain_t ws2812_chains[RMT_CHANNEL_MAX];
static intr_handle_t ws2812_intr_handle; static intr_handle_t ws2812_intr_handle;
static void IRAM_ATTR ws2812_fill_memory_encoded( rmt_channel_t channel, const uint8_t *data, size_t len, size_t tx_offset ) static void ws2812_fill_memory_encoded( rmt_channel_t channel, const uint8_t *data, size_t len, size_t tx_offset )
{ {
for (size_t idx = 0; idx < len; idx++) { for (size_t idx = 0; idx < len; idx++) {
uint8_t byte = data[idx]; uint8_t byte = data[idx];
@ -93,7 +94,7 @@ static void IRAM_ATTR ws2812_fill_memory_encoded( rmt_channel_t channel, const u
} }
static void IRAM_ATTR ws2812_isr(void *arg) static void ws2812_isr(void *arg)
{ {
uint32_t intr_st = RMT.int_st.val; uint32_t intr_st = RMT.int_st.val;
@ -195,7 +196,7 @@ int platform_ws2812_send( void )
res = PLATFORM_ERR; res = PLATFORM_ERR;
break; break;
} }
if (rmt_driver_install( channel, 0, ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_SHARED ) != ESP_OK) { if (rmt_driver_install( channel, 0, PLATFORM_RMT_INTR_FLAGS ) != ESP_OK) {
res = PLATFORM_ERR; res = PLATFORM_ERR;
break; break;
} }
@ -204,7 +205,7 @@ int platform_ws2812_send( void )
// hook-in our shared ISR // hook-in our shared ISR
esp_intr_alloc( ETS_RMT_INTR_SOURCE, ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_SHARED, ws2812_isr, NULL, &ws2812_intr_handle ); esp_intr_alloc( ETS_RMT_INTR_SOURCE, PLATFORM_RMT_INTR_FLAGS, ws2812_isr, NULL, &ws2812_intr_handle );
// start selected channels one by one // start selected channels one by one