Skip to content

Commit 73cb209

Browse files
committed
fixes compilation for spi_3wire
1 parent 792eca0 commit 73cb209

File tree

3 files changed

+32
-32
lines changed

3 files changed

+32
-32
lines changed

ext_mod/lcd_bus/esp32_include/spi_3wire.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
#if SOC_LCD_I80_SUPPORTED || SOC_LCD_RGB_SUPPORTED
1616

17-
#define LCD_SPI_3WIRE_CMD_BITS_MAX (sizeof(uint32_t) * 8) // Maximum number of bytes for LCD command
18-
#define LCD_SPI_3WIRE_PARAM_BITS_MAX (sizeof(uint32_t) * 8) // Maximum number of bytes for LCD parameter
19-
#define LCD_SPI_3WIRE_CLK_MAX (500 * 1000UL)
17+
#define SPI_3WIRE_CMD_BITS_MAX (sizeof(uint32_t) * 8) // Maximum number of bytes for LCD command
18+
#define SPI_3WIRE_PARAM_BITS_MAX (sizeof(uint32_t) * 8) // Maximum number of bytes for LCD parameter
19+
#define SPI_3WIRE_CLK_MAX (500 * 1000UL)
2020

21-
#define LCD_SPI_3WIRE_DATA_DC_BIT_0 (0) // DC bit = 0
22-
#define LCD_SPI_3WIRE_DATA_DC_BIT_1 (1) // DC bit = 1
23-
#define LCD_SPI_3WIRE_DATA_NO_DC_BIT (2) // No DC bit
24-
#define LCD_SPI_3WIRE_WRITE_ORDER_LSB_MASK (0x01) // Bit mask for LSB first write order
25-
#define LCD_SPI_3WIRE_WRITE_ORDER_MSB_MASK (0x80) // Bit mask for MSB first write order
21+
#define SPI_3WIRE_DATA_DC_BIT_0 (0) // DC bit = 0
22+
#define SPI_3WIRE_DATA_DC_BIT_1 (1) // DC bit = 1
23+
#define SPI_3WIRE_DATA_NO_DC_BIT (2) // No DC bit
24+
#define SPI_3WIRE_WRITE_ORDER_LSB_MASK (0x01) // Bit mask for LSB first write order
25+
#define SPI_3WIRE_WRITE_ORDER_MSB_MASK (0x80) // Bit mask for MSB first write order
2626

2727

2828
typedef struct _mp_spi_3wire_obj_t {
@@ -46,8 +46,8 @@
4646

4747
extern const mp_obj_type_t mp_spi_3wire_type;
4848

49-
mp_lcd_err_t mp_spi_3wire_init(mp_spi_3wire_obj_t *self, uint8_t cmd_bits, uint8_t param_bits);
50-
esp_err_t mp_spi_3wire_tx_param(mp_spi_3wire_obj_t *self, int lcd_cmd, const void *param, size_t param_size);
49+
void mp_spi_3wire_init(mp_spi_3wire_obj_t *self, uint8_t cmd_bits, uint8_t param_bits);
50+
void mp_spi_3wire_tx_param(mp_spi_3wire_obj_t *self, int lcd_cmd, const void *param, size_t param_size);
5151
void mp_spi_3wire_deinit(mp_spi_3wire_obj_t *self);
5252

5353
#endif /* SOC_LCD_I80_SUPPORTED */

ext_mod/lcd_bus/esp32_src/i80_bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@
256256

257257
if (self->spi_3wire != NULL) {
258258
mp_spi_3wire_tx_param(self->spi_3wire, lcd_cmd, param, param_size);
259-
ret = LCD_OK
259+
ret = LCD_OK;
260260
} else {
261261
ret = esp_lcd_panel_io_tx_param(self->panel_io_handle.panel_io, lcd_cmd, param, param_size);
262262
}

ext_mod/lcd_bus/esp32_src/spi_3wire.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "driver/spi_master.h"
1717
#include "freertos/FreeRTOS.h"
1818
#include "freertos/task.h"
19-
#include "esp_check.h
19+
#include "esp_check.h"
2020

2121
static void _reset_gpios(int64_t gpio_mask)
2222
{
@@ -46,20 +46,20 @@
4646
ARG_sda,
4747
ARG_cs,
4848
ARG_freq,
49-
ARG_polarity
50-
ARG_phase
51-
ARG_use_dc_bit
52-
ARG_dc_data_high
53-
ARG_lsb_first
54-
ARG_cs_active_high
55-
ARG_del_keep_cs_active
49+
ARG_polarity,
50+
ARG_phase,
51+
ARG_use_dc_bit,
52+
ARG_dc_data_high,
53+
ARG_lsb_first,
54+
ARG_cs_active_high,
55+
ARG_del_keep_cs_active,
5656
};
5757

5858
const mp_arg_t make_new_args[] = {
5959
{ MP_QSTR_scl, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
6060
{ MP_QSTR_sda, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
6161
{ MP_QSTR_cs, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
62-
{ MP_QSTR_freq, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = LCD_SPI_3WIRE_CLK_MAX } },
62+
{ MP_QSTR_freq, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = SPI_3WIRE_CLK_MAX } },
6363
{ MP_QSTR_polarity, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 0 } },
6464
{ MP_QSTR_phase, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 0 } },
6565
{ MP_QSTR_use_dc_bit, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } },
@@ -86,15 +86,15 @@
8686
self->scl_half_period_us = 1000000 / ((uint32_t)args[ARG_freq].u_int * 2);
8787

8888
if ((bool)args[ARG_use_dc_bit].u_bool) {
89-
self->param_dc_bit = (bool)args[ARG_dc_data_high].u_bool ? LCD_SPI_3WIRE_DATA_DC_BIT_1 : LCD_SPI_3WIRE_DATA_DC_BIT_0;
90-
self->cmd_dc_bit = (bool)args[ARG_dc_data_high].u_bool ? LCD_SPI_3WIRE_DATA_DC_BIT_0 : LCD_SPI_3WIRE_DATA_DC_BIT_1;
89+
self->param_dc_bit = (bool)args[ARG_dc_data_high].u_bool ? SPI_3WIRE_DATA_DC_BIT_1 : SPI_3WIRE_DATA_DC_BIT_0;
90+
self->cmd_dc_bit = (bool)args[ARG_dc_data_high].u_bool ? SPI_3WIRE_DATA_DC_BIT_0 : SPI_3WIRE_DATA_DC_BIT_1;
9191
} else {
92-
self->param_dc_bit = LCD_SPI_3WIRE_DATA_NO_DC_BIT;
93-
self->cmd_dc_bit = LCD_SPI_3WIRE_DATA_NO_DC_BIT;
92+
self->param_dc_bit = SPI_3WIRE_DATA_NO_DC_BIT;
93+
self->cmd_dc_bit = SPI_3WIRE_DATA_NO_DC_BIT;
9494
}
9595

96-
self->write_order_mask = (bool)args[ARG_lsb_first].u_bool ? LCD_SPI_3WIRE_WRITE_ORDER_LSB_MASK : LCD_SPI_3WIRE_WRITE_ORDER_MSB_MASK;
97-
self->cs_high_active = (int)args[ARG_cs_active_high].u_bool
96+
self->write_order_mask = (bool)args[ARG_lsb_first].u_bool ? SPI_3WIRE_WRITE_ORDER_LSB_MASK : SPI_3WIRE_WRITE_ORDER_MSB_MASK;
97+
self->cs_high_active = (int)args[ARG_cs_active_high].u_bool;
9898
self->del_keep_cs_inactive = (bool)args[ARG_del_keep_cs_active].u_bool ? 0 : 1;
9999

100100
uint32_t spi_mode = (uint32_t)args[ARG_phase].u_int | ((uint32_t)args[ARG_polarity].u_int << 1);
@@ -184,7 +184,7 @@
184184
}
185185

186186

187-
static mp_obj_t lcd_spi_3wire_init(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
187+
static mp_obj_t spi_3wire_init(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
188188
{
189189
enum { ARG_self, ARG_cmd_bits, ARG_param_bits };
190190
const mp_arg_t allowed_args[] = {
@@ -201,11 +201,11 @@
201201
self,
202202
(uint8_t)args[ARG_cmd_bits].u_int,
203203
(uint8_t)args[ARG_param_bits].u_int
204-
)
204+
);
205205
return mp_const_none;
206206
}
207207

208-
static MP_DEFINE_CONST_FUN_OBJ_KW(lcd_spi_3wire_init_obj, 3, lcd_spi_3wire_init);
208+
static MP_DEFINE_CONST_FUN_OBJ_KW(spi_3wire_init_obj, 3, spi_3wire_init);
209209

210210

211211
void mp_spi_3wire_tx_param(mp_spi_3wire_obj_t *self, int lcd_cmd, const void *param, size_t param_size)
@@ -287,7 +287,7 @@
287287
static esp_err_t spi_3wire_write_byte(mp_spi_3wire_obj_t *self, int dc_bit, uint8_t data)
288288
{
289289
uint16_t data_temp = data;
290-
uint8_t data_bits = (dc_bit != DATA_NO_DC_BIT) ? 9 : 8;
290+
uint8_t data_bits = (dc_bit != SPI_3WIRE_DATA_NO_DC_BIT) ? 9 : 8;
291291
uint16_t write_order_mask = self->write_order_mask;
292292
uint32_t scl_active_before_level = self->scl_active_rising_edge ? 0 : 1;
293293
uint32_t scl_active_after_level = !scl_active_before_level;
@@ -301,7 +301,7 @@
301301
// SDA set to data bit
302302
gpio_set_level(self->sda, data_temp & write_order_mask);
303303
// Get next bit
304-
data_temp = (write_order_mask == WRITE_ORDER_LSB_MASK) ? data_temp >> 1 : data_temp << 1;
304+
data_temp = (write_order_mask == SPI_3WIRE_WRITE_ORDER_LSB_MASK) ? data_temp >> 1 : data_temp << 1;
305305
}
306306
// Generate SCL active edge
307307
gpio_set_level(self->scl, scl_active_before_level);
@@ -337,7 +337,7 @@
337337
if (i == 0) {
338338
spi_3wire_write_byte(self, data_dc_bit, swap_data & 0xff);
339339
} else {
340-
spi_3wire_write_byte(self, DATA_NO_DC_BIT, swap_data & 0xff);
340+
spi_3wire_write_byte(self, SPI_3WIRE_DATA_NO_DC_BIT, swap_data & 0xff);
341341
}
342342
swap_data >>= 8;
343343
}

0 commit comments

Comments
 (0)