Skip to content

Commit 4ca4f69

Browse files
committed
working on adding DSI driver
1 parent 8547d9b commit 4ca4f69

25 files changed

+1374
-940
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef __ALLOCATE_BUFFERS_H__:
2+
#define __ALLOCATE_BUFFERS_H__
3+
4+
int allocate_buffers(uint8_t num_buffs, size_t buf_size, uint8_t *buf1, uint8_t *buf2);
5+
void free_buffers(uint8_t *buf1, uint8_t *buf2);
6+
7+
8+
#endif

ext_mod/lcd_bus/esp32_include/dsi_bus.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
//local_includes
88
#include "lcd_types.h"
9+
#include "lcd_bus_task.h"
910

1011
// micropython includes
1112
#include "mphalport.h"
@@ -29,24 +30,33 @@
2930

3031
mp_obj_t callback;
3132

32-
void *buf1;
33-
void *buf2;
33+
mp_obj_array_t *view1;
34+
mp_obj_array_t *view2;
35+
3436
uint32_t buffer_flags;
3537

36-
bool trans_done;
37-
bool rgb565_byte_swap;
38+
uint8_t trans_done: 1;
39+
40+
lcd_task_t task;
41+
lcd_init_t init;
42+
lcd_bufs_t bufs;
43+
44+
lcd_tx_data_t tx_data;
45+
lcd_tx_cmds_t tx_cmds;
46+
47+
rotation_data_t r_data;
3848

3949
lcd_panel_io_t panel_io_handle;
4050

51+
// ********************** bus specific **********************
4152
esp_lcd_dbi_io_config_t panel_io_config;
4253
esp_lcd_dsi_bus_config_t bus_config;
4354
esp_lcd_dsi_bus_handle_t bus_handle;
4455
esp_lcd_panel_handle_t panel_handle;
4556
esp_lcd_dpi_panel_config_t panel_config;
4657

4758
uint32_t buffer_size;
48-
mp_obj_array_t *view1;
49-
mp_obj_array_t *view2;
59+
5060

5161
void *transmitting_buf;
5262

ext_mod/lcd_bus/esp32_include/i2c_bus.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
//local_includes
77
#include "lcd_types.h"
8+
#include "lcd_bus_task.h"
89

910
// esp-idf includes
1011
#include "esp_lcd_panel_io.h"
@@ -25,10 +26,20 @@
2526

2627
uint32_t buffer_flags;
2728

28-
bool trans_done;
29-
bool rgb565_byte_swap;
29+
uint8_t trans_done: 1;
30+
31+
lcd_task_t task;
32+
lcd_init_t init;
33+
lcd_bufs_t bufs;
34+
35+
lcd_tx_data_t tx_data;
36+
lcd_tx_cmds_t tx_cmds;
37+
38+
rotation_data_t r_data;
3039

3140
lcd_panel_io_t panel_io_handle;
41+
42+
// ********************** bus specific **********************
3243
esp_lcd_panel_io_i2c_config_t panel_io_config;
3344
i2c_config_t bus_config;
3445
esp_lcd_i2c_bus_handle_t bus_handle;

ext_mod/lcd_bus/esp32_include/i80_bus.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
//local_includes
77
#include "lcd_types.h"
8+
#include "lcd_bus_task.h"
89

910
// micropython includes
1011
#include "mphalport.h"
@@ -29,14 +30,24 @@
2930

3031
uint32_t buffer_flags;
3132

32-
bool trans_done;
33-
bool rgb565_byte_swap;
33+
uint8_t trans_done: 1;
34+
35+
lcd_task_t task;
36+
lcd_init_t init;
37+
lcd_bufs_t bufs;
38+
39+
lcd_tx_data_t tx_data;
40+
lcd_tx_cmds_t tx_cmds;
41+
42+
rotation_data_t r_data;
3443

3544
lcd_panel_io_t panel_io_handle;
3645

46+
// ********************** bus specific **********************
3747
esp_lcd_panel_io_i80_config_t panel_io_config;
3848
esp_lcd_i80_bus_config_t bus_config;
3949
esp_lcd_i80_bus_handle_t bus_handle;
50+
4051
} mp_lcd_i80_bus_obj_t;
4152

4253
extern const mp_obj_type_t mp_lcd_i80_bus_type;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include "freertos/FreeRTOS.h"
2+
#include "freertos/task.h"
3+
#include "freertos/semphr.h"
4+
#include "freertos/event_groups.h"
5+
#include "freertos/idf_additions.h"
6+
7+
8+
#ifndef __LCD_BUS_TASK_H__
9+
#define __LCD_BUS_TASK_H__
10+
11+
typedef struct _lcd_bus_lock_t {
12+
SemaphoreHandle_t handle;
13+
StaticSemaphore_t buffer;
14+
} lcd_bus_lock_t;
15+
16+
typedef struct _lcd_bus_event_t {
17+
EventGroupHandle_t handle;
18+
StaticEventGroup_t buffer;
19+
} lcd_bus_event_t;
20+
21+
22+
#define lcd_bus_event_init(lcd_bus_event_t *event) event.handle = xEventGroupCreateStatic(&event.buffer)
23+
#define lcd_bus_event_wait(event) xEventGroupWaitBits(event.handle, (1 << 0), pdFALSE, pdTRUE, portMAX_DELAY)
24+
#define lcd_bus_event_set(event) xEventGroupSetBits(event.handle, (1 << 0))
25+
#define lcd_bus_event_clear(event) xEventGroupClearBits(event.handle, (1 << 0))
26+
#define lcd_bus_event_clear_from_isr(event) xEventGroupClearBitsFromISR(event.handle, (1 << 0))
27+
#define lcd_bus_event_set_from_isr(event) xEventGroupSetBitsFromISR(event.handle, (1 << 0), pdFALSE)
28+
29+
void lcd_bus_event_delete(lcd_bus_event_t *event);
30+
bool lcd_bus_event_isset(lcd_bus_event_t *event);
31+
bool lcd_bus_event_isset_from_isr(lcd_bus_event_t *event);
32+
33+
34+
#define lcd_bus_lock_acquire(lock) xSemaphoreTake(lock.handle, portMAX_DELAY)
35+
#define lcd_bus_lock_release(lock) xSemaphoreGive(lock.handle)
36+
#define lcd_bus_lock_release_from_isr(lock) xSemaphoreGiveFromISR(lock.handle, pdFALSE)
37+
#define lcd_bus_lock_delete(lock) vSemaphoreDelete(lock.handle)
38+
39+
void lcd_bus_lock_init(lcd_bus_lock_t *lock);
40+
41+
void lcd_bus_task(void *self_in);
42+
43+
#endif

ext_mod/lcd_bus/esp32_include/led_bus.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
//local_includes
88
#include "lcd_types.h"
9+
#include "lcd_bus_task.h"
10+
911
#include "../../../micropy_updates/common/mp_spi_common.h"
1012

1113
#include "driver/rmt.h"
@@ -49,20 +51,27 @@
4951

5052
mp_obj_t callback;
5153

52-
void *buf1;
53-
void *buf2;
54+
mp_obj_array_t *view1;
55+
mp_obj_array_t *view2;
56+
5457
uint32_t buffer_flags;
5558

56-
bool trans_done;
57-
bool rgb565_byte_swap;
59+
uint8_t trans_done: 1;
60+
61+
lcd_task_t task;
62+
lcd_init_t init;
63+
lcd_bufs_t bufs;
64+
65+
lcd_tx_data_t tx_data;
66+
lcd_tx_cmds_t tx_cmds;
67+
68+
rotation_data_t r_data;
5869

5970
lcd_panel_io_t panel_io_handle;
6071

72+
// ********************** bus specific **********************
6173
uint32_t buffer_size;
6274

63-
mp_obj_array_t *view1;
64-
mp_obj_array_t *view2;
65-
6675
// common config
6776
mp_lcd_led_pixel_order pixel_order;
6877
uint8_t rgb_order[3];

ext_mod/lcd_bus/esp32_include/rgb565_dither.h

Lines changed: 0 additions & 22 deletions
This file was deleted.

ext_mod/lcd_bus/esp32_include/rgb_bus.h

Lines changed: 12 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
//local_includes
1010
#include "lcd_types.h"
11+
#include "lcd_bus_task.h"
1112

1213
// esp-idf includes
1314
#include "hal/lcd_hal.h"
@@ -50,26 +51,6 @@
5051
uint8_t bb_fb_index; // Current frame buffer index which used by bounce buffer
5152
} rgb_panel_t;
5253

53-
typedef struct _rgb_bus_lock_t {
54-
SemaphoreHandle_t handle;
55-
StaticSemaphore_t buffer;
56-
} rgb_bus_lock_t;
57-
58-
typedef struct _rgb_bus_event_t {
59-
EventGroupHandle_t handle;
60-
StaticEventGroup_t buffer;
61-
} rgb_bus_event_t;
62-
63-
#if LCD_RGB_OPTIMUM_FB_SIZE
64-
typedef struct _rgb_bus_optimum_fb_size_t {
65-
uint16_t flush_count;
66-
uint8_t sample_count;
67-
uint8_t curr_index;
68-
uint16_t *samples;
69-
rgb_bus_lock_t lock;
70-
} rgb_bus_optimum_fb_size_t;
71-
#endif
72-
7354
typedef struct _mp_lcd_rgb_bus_obj_t {
7455
mp_obj_base_t base;
7556

@@ -80,67 +61,28 @@
8061

8162
uint32_t buffer_flags;
8263

83-
bool trans_done;
84-
bool rgb565_byte_swap;
64+
uint8_t trans_done: 1;
65+
66+
lcd_task_t task;
67+
lcd_init_t init;
68+
lcd_bufs_t bufs;
69+
70+
lcd_tx_data_t tx_data;
71+
lcd_tx_cmds_t tx_cmds;
72+
73+
rotation_data_t r_data;
8574

8675
lcd_panel_io_t panel_io_handle;
8776

77+
// ********************** bus specific **********************
8878
esp_lcd_rgb_panel_config_t panel_io_config;
8979
esp_lcd_rgb_timing_t bus_config;
9080

9181
esp_lcd_panel_handle_t panel_handle;
9282
uint32_t buffer_size;
9383

94-
uint8_t *active_fb;
95-
uint8_t *idle_fb;
96-
uint8_t *partial_buf;
97-
98-
int x_start;
99-
int y_start;
100-
int x_end;
101-
int y_end;
102-
uint16_t width;
103-
uint16_t height;
104-
uint8_t rotation: 2;
105-
uint8_t bytes_per_pixel: 2;
106-
uint8_t last_update: 1;
107-
uint8_t rgb565_dither: 1;
108-
109-
rgb_bus_lock_t copy_lock;
110-
rgb_bus_event_t copy_task_exit;
111-
rgb_bus_lock_t tx_color_lock;
112-
rgb_bus_event_t swap_bufs;
113-
rgb_bus_lock_t init_lock;
114-
115-
TaskHandle_t copy_task_handle;
116-
117-
mp_lcd_err_t init_err;
118-
mp_rom_error_text_t init_err_msg;
119-
120-
#if LCD_RGB_OPTIMUM_FB_SIZE
121-
rgb_bus_optimum_fb_size_t optimum_fb;
122-
#endif
123-
12484
} mp_lcd_rgb_bus_obj_t;
12585

126-
void rgb_bus_event_init(rgb_bus_event_t *event);
127-
void rgb_bus_event_delete(rgb_bus_event_t *event);
128-
bool rgb_bus_event_isset(rgb_bus_event_t *event);
129-
void rgb_bus_event_set(rgb_bus_event_t *event);
130-
void rgb_bus_event_clear(rgb_bus_event_t *event);
131-
void rgb_bus_event_clear_from_isr(rgb_bus_event_t *event);
132-
bool rgb_bus_event_isset_from_isr(rgb_bus_event_t *event);
133-
void rgb_bus_event_set_from_isr(rgb_bus_event_t *event);
134-
void rgb_bus_event_wait(rgb_bus_event_t *event);
135-
136-
int rgb_bus_lock_acquire(rgb_bus_lock_t *lock, int32_t wait_ms);
137-
void rgb_bus_lock_release(rgb_bus_lock_t *lock);
138-
void rgb_bus_lock_init(rgb_bus_lock_t *lock);
139-
void rgb_bus_lock_delete(rgb_bus_lock_t *lock);
140-
void rgb_bus_lock_release_from_isr(rgb_bus_lock_t *lock);
141-
142-
void rgb_bus_copy_task(void *self_in);
143-
14486
extern const mp_obj_type_t mp_lcd_rgb_bus_type;
14587

14688
extern void mp_lcd_rgb_bus_deinit_all(void);

ext_mod/lcd_bus/esp32_include/spi_bus.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
//local_includes
77
#include "lcd_types.h"
8+
#include "lcd_bus_task.h"
89
#include "../../../micropy_updates/common/mp_spi_common.h"
910

1011
// esp-idf includes
@@ -29,16 +30,27 @@
2930

3031
uint32_t buffer_flags;
3132

32-
bool trans_done;
33-
bool rgb565_byte_swap;
33+
uint8_t trans_done: 1;
34+
35+
lcd_task_t task;
36+
lcd_init_t init;
37+
lcd_bufs_t bufs;
38+
39+
lcd_tx_data_t tx_data;
40+
lcd_tx_cmds_t tx_cmds;
41+
42+
rotation_data_t r_data;
3443

3544
lcd_panel_io_t panel_io_handle;
45+
46+
// ********************** bus specific **********************
3647
esp_lcd_panel_io_spi_config_t panel_io_config;
3748
spi_bus_config_t bus_config;
3849
esp_lcd_spi_bus_handle_t bus_handle;
3950

4051
spi_host_device_t host;
4152
mp_machine_hw_spi_device_obj_t spi_device;
53+
4254
} mp_lcd_spi_bus_obj_t;
4355

4456
extern const mp_obj_type_t mp_lcd_spi_bus_type;

0 commit comments

Comments
 (0)