Skip to content

Initial version of rmt driver #1525

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 18 commits into from
Sep 17, 2018
Merged

Conversation

david-cermak
Copy link
Contributor

This is an initial version of RMT driver which supports

  • initialise/allocate channel buffers based on the data needed
  • sending data spanning over multiple channel data field
  • sending more data within one channel data buffer with interrupt scrolling (continuous mode)
  • synchronous and asynchronous reception

Please look mainly at the interface if this is viable and convenient for users; Please comment.

Still missing feature for using carrier frequency and a lot of testing needed...

@lbernstone
Copy link
Contributor

The header file needs a define at the beginning to prevent reloading.

#ifndef MAIN_ESP32_HAL_RMT_H_
#define MAIN_ESP32_HAL_RMT_H_

struct rmt_obj_s;

typedef enum {
e_reserve_64_items = 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets have the enum names in capital letters and name them like RMT_MEM_64 and so on

* (more data being send while updating buffers in interrupts)
*
*/
bool rmtSend(rmt_obj_t* rmt, uint32_t* data, size_t size);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets not use uint32_t and instead expose a proper item structure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also name of te function should be rmtWrite to follow Arduino's code style

* Initiates async receive, event flag indicates data received
*
*/
bool rmtReceive(rmt_obj_t* rmt, uint32_t* data, size_t size, void* eventFlag, bool waitForData, uint32_t timeout);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets rename this to rmtReadAsync and add rmtRead method that will default event flag (RX+ERROR?), true for waitForData and some sane timeout that can be adjusted by rmtSetRxTimeout(time_ms)

* Reads the data for particular channel
*
*/
bool rmtGetData(rmt_obj_t* rmt, uint32_t* data, size_t size);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rmtGetData -> rmtReadData



void setup()
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Serial.begin(115200); to init serial here.

{
if ((rmt_send = rmtInit(18, true, 2, 1000)) == NULL)
{
printf("init sender failed\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace such messages with Serial.println("init sender failed");. Note! Serial.printf(...) also exists.



float realTick = rmtSetTick(rmt_send, 400);
printf("real tick set to: %f\n", realTick);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serial.print("real tick set to: ");
Serial.println(realTick, 2);

data[255] = 0;

// Start receiving
rmtReceiveAsync(rmt_recv, 0x4F, my_data, 60, events);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those do not exist anymore :)


#include "esp32-hal.h"

#define LED_MATRIX_SIZE 8*4*24
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make 8*4 to be NUMBER_PIXELS.

#include "esp32-hal.h"

#define NR_OF_LEDS 8*4
#define NR_OF_PIXELS 24*NR_OF_LEDS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be number of bits. each led is a pixel

for (col=0; col<3; col++ ) {
for (bit=0; bit<8; bit++){
if ( (color[col] & (1<<(8-bit))) && (led == led_index) ) {
led_data[i].val = 0x80070006;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this value? please use the struct fields

led_data[i].level0 = 1;
led_data[i].duration0 = 8;
led_data[i].level1 = 0;
led_data[i].duration1 = 1;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These values are different,. a direct conversion between the .val and fields would be

led_data[i].level0 = 1;
led_data[i].duration0 = 7;
led_data[i].level1 = 0;
led_data[i].duration1 = 6;

Did you want to change the values?

Chuck

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you chuck, good catch!

Indeed I meant to update the values (to be in line with the diagrams), but not that much. wanted to use pulses 8/4 instead of 7/6 (the led's are quite tolerant so it's accepted)

@me-no-dev me-no-dev merged commit 4e96bff into espressif:master Sep 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants