Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 32d5654

Browse filesBrowse files
authored
Implement rmtLoop to be able to continuously send pulses (espressif#3650)
Number of pulses is limited to the reserved RMT memory for the channel. Very useful for PWM, Servo and other repeatable signals.
1 parent 7637a73 commit 32d5654
Copy full SHA for 32d5654

File tree

Expand file treeCollapse file tree

2 files changed

+26
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+26
-4
lines changed

‎cores/esp32/esp32-hal-rmt.c

Copy file name to clipboardExpand all lines: cores/esp32/esp32-hal-rmt.c
+20-4Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static xSemaphoreHandle g_rmt_block_lock = NULL;
128128
*/
129129
static void _initPin(int pin, int channel, bool tx_not_rx);
130130

131-
static bool _rmtSendOnce(rmt_obj_t* rmt, rmt_data_t* data, size_t size);
131+
static bool _rmtSendOnce(rmt_obj_t* rmt, rmt_data_t* data, size_t size, bool continuous);
132132

133133
static void IRAM_ATTR _rmt_isr(void* arg);
134134

@@ -234,6 +234,21 @@ bool rmtDeinit(rmt_obj_t *rmt)
234234
return true;
235235
}
236236

237+
bool rmtLoop(rmt_obj_t* rmt, rmt_data_t* data, size_t size)
238+
{
239+
if (!rmt) {
240+
return false;
241+
}
242+
243+
int channel = rmt->channel;
244+
int allocated_size = MAX_DATA_PER_CHANNEL * rmt->buffers;
245+
246+
if (size > allocated_size) {
247+
return false;
248+
}
249+
return _rmtSendOnce(rmt, data, size, true);
250+
}
251+
237252
bool rmtWrite(rmt_obj_t* rmt, rmt_data_t* data, size_t size)
238253
{
239254
if (!rmt) {
@@ -282,10 +297,10 @@ bool rmtWrite(rmt_obj_t* rmt, rmt_data_t* data, size_t size)
282297
RMT_MUTEX_UNLOCK(channel);
283298

284299
// start the transation
285-
return _rmtSendOnce(rmt, data, MAX_DATA_PER_ITTERATION);
300+
return _rmtSendOnce(rmt, data, MAX_DATA_PER_ITTERATION, false);
286301
} else {
287302
// use one-go mode if data fits one buffer
288-
return _rmtSendOnce(rmt, data, size);
303+
return _rmtSendOnce(rmt, data, size, false);
289304
}
290305
}
291306

@@ -553,7 +568,7 @@ rmt_obj_t* rmtInit(int pin, bool tx_not_rx, rmt_reserve_memsize_t memsize)
553568
/**
554569
* Private methods definitions
555570
*/
556-
bool _rmtSendOnce(rmt_obj_t* rmt, rmt_data_t* data, size_t size)
571+
bool _rmtSendOnce(rmt_obj_t* rmt, rmt_data_t* data, size_t size, bool continuous)
557572
{
558573
if (!rmt) {
559574
return false;
@@ -571,6 +586,7 @@ bool _rmtSendOnce(rmt_obj_t* rmt, rmt_data_t* data, size_t size)
571586
}
572587

573588
RMT_MUTEX_LOCK(channel);
589+
RMT.conf_ch[channel].conf1.tx_conti_mode = continuous;
574590
RMT.conf_ch[channel].conf1.mem_rd_rst = 1;
575591
RMT.conf_ch[channel].conf1.tx_start = 1;
576592
RMT_MUTEX_UNLOCK(channel);

‎cores/esp32/esp32-hal-rmt.h

Copy file name to clipboardExpand all lines: cores/esp32/esp32-hal-rmt.h
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ float rmtSetTick(rmt_obj_t* rmt, float tick);
7373
*/
7474
bool rmtWrite(rmt_obj_t* rmt, rmt_data_t* data, size_t size);
7575

76+
/**
77+
* Loop data up to the reserved memsize continuously
78+
*
79+
*/
80+
bool rmtLoop(rmt_obj_t* rmt, rmt_data_t* data, size_t size);
81+
7682
/**
7783
* Initiates async receive, event flag indicates data received
7884
*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.