Skip to content

Commit e4257c1

Browse files
committed
feat(rmt_uart): remove parity support
1 parent c7ba0df commit e4257c1

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

rmt_soft_uart/include/rmt_uart_type.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@ typedef enum {
2828
} rmt_uart_word_length_t;
2929

3030
typedef enum {
31-
RMT_UART_STOP_BITS_1 = 0x1, /*!< stop bit: 1bit*/
32-
RMT_UART_STOP_BITS_2 = 0x2, /*!< stop bit: 2bits*/
31+
RMT_UART_STOP_BITS_1 = 0x0, /*!< stop bit: 1bit*/
32+
RMT_UART_STOP_BITS_2 = 0x1, /*!< stop bit: 2bits*/
3333
} rmt_uart_stop_bits_t;
3434

3535
typedef enum {
3636
RMT_UART_PARITY_DISABLE = 0x0, /*!< Disable UART parity*/
37-
RMT_UART_PARITY_EVEN = 0x1, /*!< Enable UART even parity*/
38-
RMT_UART_PARITY_ODD = 0x2, /*!< Enable UART odd parity*/
3937
} rmt_uart_parity_t;
4038

4139
/**

rmt_soft_uart/src/rmt_uart.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ static bool rmt_uart_process_level(uint8_t level, uint32_t duration, int bit_tic
8080
{
8181
int bit_count = ROUND_CLOSEST(duration, bit_ticks);
8282
uint8_t data_bits = uart_device->data_bits;
83-
uint8_t has_parity = (uart_device->parity != RMT_UART_PARITY_DISABLE);
8483
uint8_t stop_bits = (uart_device->stop_bits == RMT_UART_STOP_BITS_1) ? 1 : 2;
85-
uint8_t total_bits = 1 + data_bits + has_parity + stop_bits;
84+
uint8_t total_bits = 1 + data_bits + stop_bits;
8685

8786
for (int i = 0; i < bit_count; i++) {
8887
// if the current bit is not a start bit, stop the decoding
@@ -104,23 +103,6 @@ static bool rmt_uart_process_level(uint8_t level, uint32_t duration, int bit_tic
104103
// extract the data byte
105104
uint8_t data_byte = (decode_context->raw_data >> 1) & ((1 << data_bits) - 1);
106105

107-
// check the parity
108-
if (has_parity) {
109-
uint8_t parity_bit = (decode_context->raw_data >> (1 + data_bits)) & 0x01;
110-
uint8_t parity_calc = __builtin_parity(data_byte);
111-
bool parity_ok = (uart_device->parity == RMT_UART_PARITY_EVEN)
112-
? parity_calc == parity_bit
113-
: parity_calc != parity_bit;
114-
115-
// if the parity is wrong, stop the decoding
116-
if (!parity_ok) {
117-
ESP_LOGE(TAG, "Parity error @ byte %d", decode_context->byte_pos);
118-
decode_context->bit_pos = 0;
119-
decode_context->raw_data = 0;
120-
return decode_context->continue_on_error;
121-
}
122-
}
123-
124106
// if the stop bit is wrong, stop the decoding
125107
if ((decode_context->raw_data >> (total_bits - 1)) != 1) {
126108
ESP_LOGE(TAG, "Invalid stop bit @ byte %d", decode_context->byte_pos);
@@ -215,7 +197,6 @@ esp_err_t rmt_new_uart_device(const rmt_uart_config_t *uart_config, rmt_uart_dev
215197
rmt_uart_device_t *uart_device = heap_caps_calloc(1, sizeof(rmt_uart_device_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
216198
ESP_RETURN_ON_FALSE(uart_device, ESP_ERR_NO_MEM, TAG, "no mem for rmt_uart_device");
217199
ESP_RETURN_ON_FALSE(uart_config->data_bits == RMT_UART_DATA_8_BITS, ESP_ERR_INVALID_ARG, TAG, "Invalid data bits");
218-
ESP_RETURN_ON_FALSE(uart_config->parity == RMT_UART_PARITY_DISABLE, ESP_ERR_INVALID_ARG, TAG, "Invalid parity");
219200
uart_device->baud_rate = uart_config->baud_rate;
220201
uart_device->data_bits = uart_config->data_bits;
221202
uart_device->stop_bits = uart_config->stop_bits;

0 commit comments

Comments
 (0)