Implemented CYD-2432S028R board and update XPT2046 driver (#308)
- Added CONFIG_TT_BOARD_CYD_2432S028R in Kconfig. - Included support for CYD2432S028R in Boards.h and board.cmake. - Updated Xpt2046Touch driver to use configuration->spiDevice instead of SPI2_HOST when creating the SPI handle. - Note: SD card is not working on this board yet. This commit introduces full support for the CYD-2432S028R board and improves the touchscreen driver flexibility by allowing dynamic SPI device configuration. SD card functionality still needs to be implemented.
This commit is contained in:
committed by
GitHub
parent
50007ea9ed
commit
5dfc6d70da
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
// Display backlight (PWM)
|
||||
#define CYD2432S028R_LCD_PIN_BACKLIGHT GPIO_NUM_21
|
||||
|
||||
// Display
|
||||
#define CYD2432S028R_LCD_SPI_HOST SPI2_HOST
|
||||
#define CYD2432S028R_LCD_HORIZONTAL_RESOLUTION 240
|
||||
#define CYD2432S028R_LCD_VERTICAL_RESOLUTION 320
|
||||
#define CYD2432S028R_LCD_DRAW_BUFFER_HEIGHT (CYD2432S028R_LCD_VERTICAL_RESOLUTION / 10)
|
||||
#define CYD2432S028R_LCD_DRAW_BUFFER_SIZE (CYD2432S028R_LCD_HORIZONTAL_RESOLUTION * CYD2432S028R_LCD_DRAW_BUFFER_HEIGHT)
|
||||
#define CYD2432S028R_LCD_PIN_CS GPIO_NUM_15
|
||||
#define CYD2432S028R_LCD_PIN_DC GPIO_NUM_2
|
||||
|
||||
// Touch
|
||||
#define CYD2432S028R_TOUCH_SPI_HOST SPI3_HOST
|
||||
#define CYD2432S028R_TOUCH_PIN_CS GPIO_NUM_33
|
||||
|
||||
// SDCard
|
||||
#define SDCARD_SPI_HOST SPI3_HOST
|
||||
#define SDCARD_PIN_CS GPIO_NUM_5
|
||||
|
||||
// SPI Transfer
|
||||
#define CYD_SPI_TRANSFER_SIZE_LIMIT (CYD2432S028R_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
|
||||
@@ -0,0 +1,42 @@
|
||||
#include "YellowDisplay.h"
|
||||
#include "Xpt2046Touch.h"
|
||||
#include "YellowConstants.h"
|
||||
#include <Ili934xDisplay.h>
|
||||
#include <PwmBacklight.h>
|
||||
|
||||
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
|
||||
auto configuration = std::make_unique<Xpt2046Touch::Configuration>(
|
||||
CYD2432S028R_TOUCH_SPI_HOST,
|
||||
CYD2432S028R_TOUCH_PIN_CS,
|
||||
240,
|
||||
320,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
return std::make_shared<Xpt2046Touch>(std::move(configuration));
|
||||
}
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
auto touch = createTouch();
|
||||
|
||||
auto configuration = std::make_unique<Ili934xDisplay::Configuration>(
|
||||
CYD2432S028R_LCD_SPI_HOST,
|
||||
CYD2432S028R_LCD_PIN_CS,
|
||||
CYD2432S028R_LCD_PIN_DC,
|
||||
CYD2432S028R_LCD_HORIZONTAL_RESOLUTION,
|
||||
CYD2432S028R_LCD_VERTICAL_RESOLUTION,
|
||||
touch,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
CYD2432S028R_LCD_DRAW_BUFFER_SIZE
|
||||
);
|
||||
|
||||
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
|
||||
|
||||
auto display = std::make_shared<Ili934xDisplay>(std::move(configuration));
|
||||
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/display/DisplayDevice.h"
|
||||
#include <memory>
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "YellowSdCard.h"
|
||||
#include "YellowConstants.h"
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
using tt::hal::sdcard::SpiSdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createYellowSdCard() {
|
||||
auto* configuration = new SpiSdCardDevice::Config(
|
||||
SDCARD_PIN_CS,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
std::make_shared<tt::Mutex>(),
|
||||
std::vector<gpio_num_t>(),
|
||||
SDCARD_SPI_HOST
|
||||
);
|
||||
|
||||
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice(
|
||||
std::unique_ptr<SpiSdCardDevice::Config>(configuration)
|
||||
);
|
||||
|
||||
return std::shared_ptr<SdCardDevice>(sdcard);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/sdcard/SdCardDevice.h"
|
||||
|
||||
using tt::hal::sdcard::SdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createYellowSdCard();
|
||||
|
||||
Reference in New Issue
Block a user