Skip to content

Commit 1cb7560

Browse files
committed
added license headers
1 parent 8aa03e7 commit 1cb7560

File tree

6 files changed

+86
-27
lines changed

6 files changed

+86
-27
lines changed

cores/esp32/esp32-hal-rmt.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
#ifndef MAIN_ESP32_HAL_RMT_H_
2-
#define MAIN_ESP32_HAL_RMT_H_
1+
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
314

415
#include "freertos/FreeRTOS.h"
516
#include "freertos/event_groups.h"
@@ -808,5 +819,3 @@ static int IRAM_ATTR _rmt_get_mem_len(uint8_t channel)
808819
}
809820
return idx;
810821
}
811-
812-
#endif /* MAIN_ESP32_HAL_RMT_H_ */

cores/esp32/esp32-hal-rmt.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef MAIN_ESP32_HAL_RMT_H_
16+
#define MAIN_ESP32_HAL_RMT_H_
17+
118
#ifdef __cplusplus
219
extern "C" {
320
#endif
@@ -112,9 +129,9 @@ bool rmtSetFilter(rmt_obj_t* rmt, bool filter_en, uint32_t filter_level);
112129
// * put sanity checks to some macro or inlines
113130
// * doxy comments
114131
// * error reporting
115-
// * release internal buffers
116-
// * rename internal structures to make it more sensibles
117132

118133
#ifdef __cplusplus
119134
}
120-
#endif
135+
#endif
136+
137+
#endif /* MAIN_ESP32_HAL_RMT_H_ */

cores/esp32/esp32-hal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void yield(void);
5656
#include "esp32-hal-spi.h"
5757
#include "esp32-hal-i2c.h"
5858
#include "esp32-hal-ledc.h"
59+
#include "esp32-hal-rmt.h"
5960
#include "esp32-hal-sigmadelta.h"
6061
#include "esp32-hal-timer.h"
6162
#include "esp32-hal-bt.h"

libraries/ESP32/examples/RMT/RMTLoopback/RMTLoopbakc.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "freertos/event_groups.h"
44
#include "Arduino.h"
55

6-
#include "esp32-hal-rmt.h"
6+
#include "esp32-hal.h"
77

88
rmt_data_t my_data[256];
99
rmt_data_t data[256];

libraries/ESP32/examples/RMT/RMTReadXJT/RMTReadXJT.ino

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,40 @@
33
#include "freertos/event_groups.h"
44
#include "Arduino.h"
55

6-
#include "esp32-hal-rmt.h"
7-
8-
#define XJT_VALID(i) (i->level0 && !i->level1 && i->duration0 >= 8 && i->duration0 <= 11)
9-
10-
11-
rmt_obj_t* rmt_recv = NULL;
12-
13-
static uint32_t *s_channels;
14-
15-
static uint32_t channels[16];
16-
static uint8_t xjt_flags = 0x0;
17-
static uint8_t xjt_rxid = 0x0;
18-
19-
6+
#include "esp32-hal.h"
7+
8+
//
9+
// Note: This example uses a FrSKY device communication
10+
// using XJT D12 protocol
11+
//
12+
// ; 0 bit = 6us low/10us high
13+
// ; 1 bit = 14us low/10us high
14+
// ;
15+
// ; --------+ +----------+ +----------+
16+
// ; | | | | |
17+
// ; | 0 | | 1 | |
18+
// ; | | | | |
19+
// ; | | | | |
20+
// ; +-------+ +-----------------+ +---------
21+
// ;
22+
// ; | 6us 10us | 14us 10us |
23+
// ; |-------|----------|-----------------|----------|--------
24+
// ; | 16us | 24us |
25+
26+
// Typedef of received frame
27+
//
28+
// ; 0x00 - Sync, 0x7E (sync header ID)
29+
// ; 0x01 - Rx ID, 0x?? (receiver ID number, 0x00-0x??)
30+
// ; 0x02 - Flags 1, 0x?? (used for failsafe and binding)
31+
// ; 0x03 - Flags 2, 0x00 (reserved)
32+
// ; 0x04-0x06, Channels 1/9 and 2/10
33+
// ; 0x07-0x09, Channels 3/11 and 4/12
34+
// ; 0x0A-0x0C, Channels 5/13 and 6/14
35+
// ; 0x0D-0x0F, Channels 7/15 and 8/16
36+
// ; 0x10 - 0x00, always zero
37+
// ; 0x11 - CRC-16 High
38+
// ; 0x12 - CRC-16 Low
39+
// ; 0x13 - Tail, 0x7E (tail ID)
2040
typedef union {
2141
struct {
2242
uint8_t head;//0x7E
@@ -40,6 +60,15 @@ typedef union {
4060
uint8_t buffer[20];
4161
} xjt_packet_t;
4262

63+
#define XJT_VALID(i) (i->level0 && !i->level1 && i->duration0 >= 8 && i->duration0 <= 11)
64+
65+
rmt_obj_t* rmt_recv = NULL;
66+
67+
static uint32_t *s_channels;
68+
static uint32_t channels[16];
69+
static uint8_t xjt_flags = 0x0;
70+
static uint8_t xjt_rxid = 0x0;
71+
4372
static bool xjtReceiveBit(size_t index, bool bit){
4473
static xjt_packet_t xjt;
4574
static uint8_t xjt_bit_index = 8;
@@ -113,7 +142,7 @@ static bool xjtReceiveBit(size_t index, bool bit){
113142

114143
void parseRmt(rmt_data_t* items, size_t len, uint32_t* channels){
115144
size_t chan = 0;
116-
bool valid = false;
145+
bool valid = true;
117146
rmt_data_t* it = NULL;
118147

119148
if (!channels) {
@@ -122,9 +151,9 @@ void parseRmt(rmt_data_t* items, size_t len, uint32_t* channels){
122151
}
123152
s_channels = channels;
124153

125-
valid = false;
126154
it = &items[0];
127155
for(size_t i = 0; i<len; i++){
156+
128157
if(!valid){
129158
break;
130159
}
@@ -137,6 +166,9 @@ void parseRmt(rmt_data_t* items, size_t len, uint32_t* channels){
137166
} else {
138167
valid = false;
139168
}
169+
} else if(!it->duration1 && !it->level1 && it->duration0 >= 5 && it->duration0 <= 8) {
170+
valid = xjtReceiveBit(i, false);
171+
140172
}
141173
}
142174
}
@@ -158,7 +190,7 @@ void setup()
158190

159191
// Setup 1us tick
160192
float realTick = rmtSetTick(rmt_recv, 1000);
161-
printf("real tick set to: %fns\n", realTick);
193+
Serial.printf("real tick set to: %fns\n", realTick);
162194

163195
// Ask to start reading
164196
rmtRead(rmt_recv, receive_data);

libraries/ESP32/examples/RMT/RMTWriteNeoPixel/RMTWriteNeoPixel.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "freertos/event_groups.h"
44
#include "Arduino.h"
55

6-
#include "esp32-hal-rmt.h"
6+
#include "esp32-hal.h"
77

88
#define LED_MATRIX_SIZE 8*4*24
99

@@ -73,7 +73,7 @@ void loop()
7373
led_data[i].val = 0x80040008;
7474
}
7575
// make the led travel in the pannel
76-
if ((++led_index)>=LED_MATRIX_SIZE) {
76+
if ((++led_index)>=4*8) {
7777
led_index = 0;
7878
}
7979

0 commit comments

Comments
 (0)