roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
esp_rgb_common.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#pragma once
7
8#include <stddef.h>
9#include "sdkconfig.h"
10#include "soc/soc_caps.h"
11#include "hal/dma_types.h"
12#include "esp_intr_alloc.h"
13#include "esp_heap_caps.h"
14#if SOC_LCDCAM_SUPPORTED
15#include "hal/lcd_hal.h"
16#endif
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22#define LCD_I80_INTR_ALLOC_FLAGS ESP_INTR_FLAG_INTRDISABLED
23#define LCD_I80_MEM_ALLOC_CAPS MALLOC_CAP_DEFAULT
24
25#define LCD_PERIPH_CLOCK_PRE_SCALE (2) // This is the minimum divider that can be applied to LCD peripheral
26
27#if SOC_LCDCAM_SUPPORTED
28
29typedef enum {
30 LCD_COM_DEVICE_TYPE_I80,
31 LCD_COM_DEVICE_TYPE_RGB
32} lcd_com_device_type_t;
33
34/**
35 * @brief Register a LCD device to platform
36 *
37 * @param device_type Device type, refer to lcd_com_device_type_t
38 * @param device_obj Device object
39 * @return >=0: member_id, <0: no free lcd bus/panel slots
40 */
41int lcd_com_register_device(lcd_com_device_type_t device_type, void *device_obj);
42
43/**
44 * @brief Remove a device from platform
45 *
46 * @param device_type Device type, refer to lcd_com_device_type_t
47 * @param member_id member ID
48 */
49void lcd_com_remove_device(lcd_com_device_type_t device_type, int member_id);
50#endif // SOC_LCDCAM_SUPPORTED
51
52/**
53 * @brief Mount data to DMA descriptors
54 *
55 * @param desc_head Point to the head of DMA descriptor chain
56 * @param buffer Data buffer
57 * @param len Size of the data buffer, in bytes
58 */
59void lcd_com_mount_dma_data(dma_descriptor_t *desc_head, const void *buffer, size_t len);
60
61/**
62 * @brief Reverse the bytes in the buffer
63 *
64 * @note LCD is big-endian, e.g. to send command 0x1234, byte 0x12 should appear on the bus first
65 * However, the low level peripheral (like i80, i2s) will send 0x34 first.
66 * This helper function is used to reverse the bytes order
67 *
68 * @param buf buffer address
69 * @param start start index of the buffer
70 * @param end end index of the buffer
71 */
72static inline void lcd_com_reverse_buffer_bytes(uint8_t *buf, int start, int end)
73{
74 uint8_t temp = 0;
75 while (start < end) {
76 temp = buf[start];
77 buf[start] = buf[end];
78 buf[end] = temp;
79 start++;
80 end--;
81 }
82}
83
84#ifdef __cplusplus
85}
86#endif
static void lcd_com_reverse_buffer_bytes(uint8_t *buf, int start, int end)
Reverse the bytes in the buffer.
void lcd_com_mount_dma_data(dma_descriptor_t *desc_head, const void *buffer, size_t len)
Mount data to DMA descriptors.