2021-05-11 23:26:07 -04:00
|
|
|
/*
|
2023-11-13 04:50:29 -05:00
|
|
|
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
2021-05-11 23:26:07 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2021-08-04 08:11:31 -04:00
|
|
|
#include <stddef.h>
|
2021-09-23 00:06:13 -04:00
|
|
|
#include "sdkconfig.h"
|
2021-05-11 23:26:07 -04:00
|
|
|
#include "soc/soc_caps.h"
|
2021-08-04 08:11:31 -04:00
|
|
|
#include "hal/dma_types.h"
|
2021-09-23 00:06:13 -04:00
|
|
|
#include "esp_intr_alloc.h"
|
|
|
|
#include "esp_heap_caps.h"
|
2021-05-11 23:26:07 -04:00
|
|
|
#if SOC_LCDCAM_SUPPORTED
|
|
|
|
#include "hal/lcd_hal.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-03-03 02:35:43 -05:00
|
|
|
#define LCD_I80_INTR_ALLOC_FLAGS ESP_INTR_FLAG_INTRDISABLED
|
|
|
|
#define LCD_I80_MEM_ALLOC_CAPS MALLOC_CAP_DEFAULT
|
2021-09-23 00:06:13 -04:00
|
|
|
|
2021-05-11 23:26:07 -04:00
|
|
|
#define LCD_PERIPH_CLOCK_PRE_SCALE (2) // This is the minimum divider that can be applied to LCD peripheral
|
|
|
|
|
2023-11-13 04:50:29 -05:00
|
|
|
#if SOC_PERIPH_CLK_CTRL_SHARED
|
|
|
|
#define LCD_CLOCK_SRC_ATOMIC() PERIPH_RCC_ATOMIC()
|
|
|
|
#else
|
|
|
|
#define LCD_CLOCK_SRC_ATOMIC()
|
|
|
|
#endif
|
|
|
|
|
2021-08-04 08:11:31 -04:00
|
|
|
#if SOC_LCDCAM_SUPPORTED
|
|
|
|
|
2021-05-11 23:26:07 -04:00
|
|
|
typedef enum {
|
|
|
|
LCD_COM_DEVICE_TYPE_I80,
|
|
|
|
LCD_COM_DEVICE_TYPE_RGB
|
|
|
|
} lcd_com_device_type_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Register a LCD device to platform
|
|
|
|
*
|
|
|
|
* @param device_type Device type, refer to lcd_com_device_type_t
|
|
|
|
* @param device_obj Device object
|
|
|
|
* @return >=0: member_id, <0: no free lcd bus/panel slots
|
|
|
|
*/
|
|
|
|
int lcd_com_register_device(lcd_com_device_type_t device_type, void *device_obj);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Remove a device from platform
|
|
|
|
*
|
|
|
|
* @param device_type Device type, refer to lcd_com_device_type_t
|
|
|
|
* @param member_id member ID
|
|
|
|
*/
|
|
|
|
void lcd_com_remove_device(lcd_com_device_type_t device_type, int member_id);
|
2021-08-04 08:11:31 -04:00
|
|
|
#endif // SOC_LCDCAM_SUPPORTED
|
|
|
|
|
2021-05-11 23:26:07 -04:00
|
|
|
/**
|
|
|
|
* @brief Mount data to DMA descriptors
|
|
|
|
*
|
|
|
|
* @param desc_head Point to the head of DMA descriptor chain
|
|
|
|
* @param buffer Data buffer
|
|
|
|
* @param len Size of the data buffer, in bytes
|
|
|
|
*/
|
|
|
|
void lcd_com_mount_dma_data(dma_descriptor_t *desc_head, const void *buffer, size_t len);
|
|
|
|
|
2021-08-04 08:11:31 -04:00
|
|
|
/**
|
|
|
|
* @brief Reverse the bytes in the buffer
|
|
|
|
*
|
|
|
|
* @note LCD is big-endian, e.g. to send command 0x1234, byte 0x12 should appear on the bus first
|
|
|
|
* However, the low level peripheral (like i80, i2s) will send 0x34 first.
|
|
|
|
* This helper function is used to reverse the bytes order
|
|
|
|
*
|
|
|
|
* @param buf buffer address
|
|
|
|
* @param start start index of the buffer
|
|
|
|
* @param end end index of the buffer
|
|
|
|
*/
|
|
|
|
static inline void lcd_com_reverse_buffer_bytes(uint8_t *buf, int start, int end)
|
|
|
|
{
|
|
|
|
uint8_t temp = 0;
|
|
|
|
while (start < end) {
|
|
|
|
temp = buf[start];
|
|
|
|
buf[start] = buf[end];
|
|
|
|
buf[end] = temp;
|
|
|
|
start++;
|
|
|
|
end--;
|
|
|
|
}
|
|
|
|
}
|
2021-05-11 23:26:07 -04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|