Skip to content

Revert "RMT refactor" #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,060 changes: 754 additions & 306 deletions cores/esp32/esp32-hal-rmt.c

Large diffs are not rendered by default.

19 changes: 1 addition & 18 deletions cores/esp32/esp32-hal-rmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ extern "C" {
#define RMT_FLAG_ERROR (4)
#define RMT_FLAGS_ALL (RMT_FLAG_TX_DONE | RMT_FLAG_RX_DONE | RMT_FLAG_ERROR)

#define RMT_TX_MODE true
#define RMT_RX_MODE false

struct rmt_obj_s;

typedef enum {
Expand Down Expand Up @@ -57,13 +54,6 @@ typedef struct {
};
} rmt_data_t;


/**
* Prints object information
*
*/
void _rmtDumpStatus(rmt_obj_t* rmt);

/**
* Initialize the object
*
Expand All @@ -79,17 +69,10 @@ float rmtSetTick(rmt_obj_t* rmt, float tick);
/**
* Sending data in one-go mode or continual mode
* (more data being send while updating buffers in interrupts)
* Non-Blocking mode - returns right after executing
*
*/
bool rmtWrite(rmt_obj_t* rmt, rmt_data_t* data, size_t size);

/**
* Sending data in one-go mode or continual mode
* (more data being send while updating buffers in interrupts)
* Blocking mode - only returns when data has been sent
*/
bool rmtWriteBlocking(rmt_obj_t* rmt, rmt_data_t* data, size_t size);

/**
* Loop data up to the reserved memsize continuously
*
Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP32/examples/RMT/RMTCallback/RMTCallback.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MyProcessor {

public:
MyProcessor(uint8_t pin, float nanoTicks) {
assert((rmt_recv = rmtInit(21, RMT_RX_MODE, RMT_MEM_192)));
assert((rmt_recv = rmtInit(21, false, RMT_MEM_192)));

realNanoTick = rmtSetTick(rmt_recv, nanoTicks);
};
Expand Down Expand Up @@ -61,4 +61,4 @@ void loop()
{
Serial.printf("GPIO 4: %08x 5: %08x 6: %08x\n", mp1.val(), mp2.val(), mp3.val());
delay(500);
}
}
18 changes: 3 additions & 15 deletions libraries/ESP32/examples/RMT/RMTLoopback/RMTLoopback.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@

#include "esp32-hal.h"

#if CONFIG_IDF_TARGET_ESP32C3
// ESP32 C3 has only 2 channels for RX and 2 for TX, thus MAX RMT_MEM is 128
#define RMT_TX_PIN 4
#define RMT_RX_PIN 5
#define RMT_MEM_RX RMT_MEM_128
#else
#define RMT_TX_PIN 18
#define RMT_RX_PIN 21
#define RMT_MEM_RX RMT_MEM_192
#endif

rmt_data_t my_data[256];
rmt_data_t data[256];

Expand All @@ -29,19 +18,18 @@ void setup()
Serial.begin(115200);
events = xEventGroupCreate();

if ((rmt_send = rmtInit(RMT_TX_PIN, RMT_TX_MODE, RMT_MEM_64)) == NULL)
if ((rmt_send = rmtInit(18, true, RMT_MEM_64)) == NULL)
{
Serial.println("init sender failed\n");
}
if ((rmt_recv = rmtInit(RMT_RX_PIN, RMT_RX_MODE, RMT_MEM_RX)) == NULL)
if ((rmt_recv = rmtInit(21, false, RMT_MEM_192)) == NULL)
{
Serial.println("init receiver failed\n");
}

float realTick = rmtSetTick(rmt_send, 100);
printf("real tick set to: %fns\n", realTick);
// both will keep same tick
realTick = rmtSetTick(rmt_recv, 100);

}

void loop()
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP32/examples/RMT/RMTReadXJT/RMTReadXJT.ino
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void setup()
Serial.begin(115200);

// Initialize the channel to capture up to 192 items
if ((rmt_recv = rmtInit(21, RMT_RX_MODE, RMT_MEM_192)) == NULL)
if ((rmt_recv = rmtInit(21, false, RMT_MEM_192)) == NULL)
{
Serial.println("init receiver failed\n");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void setup()
{
Serial.begin(115200);

if ((rmt_send = rmtInit(18, RMT_TX_MODE, RMT_MEM_64)) == NULL)
if ((rmt_send = rmtInit(18, true, RMT_MEM_64)) == NULL)
{
Serial.println("init sender failed\n");
}
Expand Down
14 changes: 1 addition & 13 deletions libraries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ arduino-esp32 includes libraries for Arduino compatibility along with some objec
### ESPmDNS
mDNS service advertising

### Ethernet
Ethernet networking

### FFat
FAT indexed filesystem on SPI flash

Expand All @@ -55,12 +52,6 @@ arduino-esp32 includes libraries for Arduino compatibility along with some objec
### HTTPUpdate
Download a firmware update from HTTPd and apply it using Update

### HTTPUpdateServer
Upload a firmware for the update from HTTPd

### LittleFS
LittleFS (File System)

### NetBIOS
NetBIOS name advertiser

Expand Down Expand Up @@ -88,9 +79,6 @@ arduino-esp32 includes libraries for Arduino compatibility along with some objec
### Update
Sketch Update using ESP32 OTA functionality

### USB
Universal Serial Bus driver (device only)

### WebServer
A simple HTTP daemon

Expand All @@ -101,4 +89,4 @@ arduino-esp32 includes libraries for Arduino compatibility along with some objec
Arduino compatible WiFi client object using embedded encryption

### Wire
Arduino compatible I2C driver
Arduino compatible I2C driver (master only)
6 changes: 3 additions & 3 deletions platform.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tools/platformio-build-esp32.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
"UNITY_INCLUDE_CONFIG_H",
"WITH_POSIX",
"_GNU_SOURCE",
("IDF_VER", '\\"v4.4-beta1-189-ga79dc75f0a\\"'),
("IDF_VER", '\\"v4.4-beta1-183-gf23dcd3555\\"'),
"ESP_PLATFORM",
"_POSIX_READER_WRITER_LOCKS",
"ARDUINO_ARCH_ESP32",
Expand Down
2 changes: 1 addition & 1 deletion tools/platformio-build-esp32c3.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
"UNITY_INCLUDE_CONFIG_H",
"WITH_POSIX",
"_GNU_SOURCE",
("IDF_VER", '\\"v4.4-beta1-189-ga79dc75f0a\\"'),
("IDF_VER", '\\"v4.4-beta1-183-gf23dcd3555\\"'),
"ESP_PLATFORM",
"_POSIX_READER_WRITER_LOCKS",
"ARDUINO_ARCH_ESP32",
Expand Down
2 changes: 1 addition & 1 deletion tools/platformio-build-esp32s2.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
"UNITY_INCLUDE_CONFIG_H",
"WITH_POSIX",
"_GNU_SOURCE",
("IDF_VER", '\\"v4.4-beta1-189-ga79dc75f0a\\"'),
("IDF_VER", '\\"v4.4-beta1-183-gf23dcd3555\\"'),
"ESP_PLATFORM",
"_POSIX_READER_WRITER_LOCKS",
"ARDUINO_ARCH_ESP32",
Expand Down
6 changes: 2 additions & 4 deletions tools/sdk/esp32/include/config/sdkconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,7 @@
#define CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS 5
#define CONFIG_LWIP_ICMP 1
#define CONFIG_LWIP_MAX_RAW_PCBS 16
#define CONFIG_LWIP_SNTP_MAX_SERVERS 3
#define CONFIG_LWIP_DHCP_GET_NTP_SRV 1
#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1
#define CONFIG_LWIP_SNTP_MAX_SERVERS 1
#define CONFIG_LWIP_SNTP_UPDATE_DELAY 3600000
#define CONFIG_LWIP_ESP_LWIP_ASSERT 1
#define CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT 1
Expand Down Expand Up @@ -679,5 +677,5 @@
#define CONFIG_ULP_COPROC_RESERVE_MEM CONFIG_ESP32_ULP_COPROC_RESERVE_MEM
#define CONFIG_WARN_WRITE_STRINGS CONFIG_COMPILER_WARN_WRITE_STRINGS
#define CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
#define CONFIG_ARDUINO_IDF_COMMIT "a79dc75f0a"
#define CONFIG_ARDUINO_IDF_COMMIT "f23dcd3555"
#define CONFIG_ARDUINO_IDF_BRANCH "release/v4.4"
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,19 @@ namespace dl
this->output_exponent = input.exponent;
if (!this->inplace)
{
if (this->output == NULL)
if (this->output != NULL)
{
this->output = new Tensor<feature_t>;
}
this->output->set_exponent(this->output_exponent);
this->output->set_shape(input.shape);
this->output->set_shape(this->output_shape);
this->output->expand_dims(this->axis);
this->output->free_element();
}
else
{
this->output = &input;
this->output->set_shape(this->output_shape);
this->output->expand_dims(this->axis);
}
this->output_shape = this->output->shape;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace dl
this->output_shape = {input.get_size()};
if (!this->inplace)
{
if (this->output == NULL)
if (this->output != NULL)
{
this->output = new Tensor<feature_t>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ namespace dl
namespace layer
{
/**
* @brief LeakyRelu(input).
* @brief LeakyReLU(input).
*
* @tparam feature_t supports int16_t and int8_t,
* - int16_t: stands for operation in int16_t quantize
* - int8_t: stands for operation in int8_t quantize
*/
template <typename feature_t>
class LeakyRelu : public Layer
class LeakyReLU : public Layer
{
private:
feature_t activation_alpha; /*<! quantized alpha >*/
Expand All @@ -28,26 +28,26 @@ namespace dl
std::vector<int> output_shape; /*<! output shape of leakyrelu >*/
public:
/**
* @brief Construct a new LeakyRelu object
* @brief Construct a new LeakyReLU object
*
* @param activation_alpha quantized alpha
* @param activation_exponent exponent of quantized alpha
* @param name name of leakyrelu
* @param inplace true: the output will store to input0
* false: the output will store to a separate memory
*/
LeakyRelu(const int activation_alpha, const int activation_exponent, const char *name = "LeakyRelu", bool inplace = false) : Layer(name), output(NULL), output_shape({})
LeakyReLU(const int activation_alpha, const int activation_exponent, const char *name = "LeakyReLU", bool inplace = false) : Layer(name), output(NULL), output_shape({})
{
this->activation_alpha = activation_alpha;
this->activation_exponent = activation_exponent;
this->inplace = inplace;
}

/**
* @brief Destroy the LeakyRelu object
* @brief Destroy the LeakyReLU object
*
*/
~LeakyRelu()
~LeakyReLU()
{
if ((!this->inplace) && (this->output != NULL))
{
Expand All @@ -66,7 +66,7 @@ namespace dl
this->output_shape = input.shape;
if (!this->inplace)
{
if (this->output == NULL)
if (this->output != NULL)
{
this->output = new Tensor<feature_t>;
}
Expand All @@ -90,19 +90,19 @@ namespace dl
/**
* @brief Get the output
*
* @return Tensor<feature_t>& LeakyRelu result
* @return Tensor<feature_t>& LeakyReLU result
*/
Tensor<feature_t> &get_output()
{
return *this->output;
}

/**
* @brief Call LeakyRelu operation.
* @brief Call LeakyReLU operation.
*
* @param input as an input
* @param assign_core not effective yet
* @return LeakyRelu result
* @return LeakyReLU result
*/
Tensor<feature_t> &call(Tensor<feature_t> &input, const std::vector<int> &assign_core = CONFIG_DEFAULT_ASSIGN_CORE)
{
Expand Down Expand Up @@ -130,7 +130,7 @@ namespace dl
{
this->output->set_shape(this->output_shape);
}
nn::leakyrelu(*this->output, input, this->activation_alpha, this->activation_exponent, assign_core);
nn::leakyrelu<true>(*this->output, input, this->activation_alpha, this->activation_exponent, assign_core);
DL_LOG_LAYER_LATENCY_END(this->name, "leakyrelu");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace dl

if (!this->inplace)
{
if (this->output == NULL)
if (this->output != NULL)
{
this->output = new Tensor<feature_t>;
}
Expand Down Expand Up @@ -132,7 +132,7 @@ namespace dl
{
this->output->set_shape(this->output_shape);
}
nn::max2d(*this->output, input0, input1, assign_core);
nn::max2d<true>(*this->output, input0, input1, assign_core);
DL_LOG_LAYER_LATENCY_END(this->name, "max2d");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace dl

if (!this->inplace)
{
if (this->output == NULL)
if (this->output != NULL)
{
this->output = new Tensor<feature_t>;
}
Expand Down Expand Up @@ -132,7 +132,7 @@ namespace dl
{
this->output->set_shape(this->output_shape);
}
nn::min2d(*this->output, input0, input1, assign_core);
nn::min2d<true>(*this->output, input0, input1, assign_core);
DL_LOG_LAYER_LATENCY_END(this->name, "min2d");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace dl

if (!this->inplace)
{
if (this->output == NULL)
if (this->output != NULL)
{
this->output = new Tensor<feature_t>;
}
Expand Down Expand Up @@ -140,7 +140,7 @@ namespace dl
{
this->output->set_shape(this->output_shape);
}
nn::mul2d(*this->output, input0, input1, this->activation, assign_core);
nn::mul2d<true>(*this->output, input0, input1, this->activation, assign_core);
DL_LOG_LAYER_LATENCY_END(this->name, "mul2d");
}

Expand Down
Loading