Some SPI displays require cs_post adjusted per speed - release

This commit is contained in:
Philippe G
2022-01-05 11:53:29 -08:00
parent d0461d55e4
commit df777e83d1
3 changed files with 10 additions and 6 deletions

View File

@@ -86,7 +86,6 @@ struct GDS_Device {
struct {
spi_device_handle_t SPIHandle;
int8_t CSPin;
int8_t CS_pre, CS_post, SPI_mode;
};
};
@@ -125,6 +124,8 @@ struct GDS_Device {
// may provide for optimization
void (*DrawRGB)( struct GDS_Device* Device, uint8_t *Image,int x, int y, int Width, int Height, int RGB_Mode );
void (*ClearWindow)( struct GDS_Device* Device, int x1, int y1, int x2, int y2, int Color );
// may provide for tweaking
void (*SPIParams)(int Speed, uint8_t *mode, uint8_t *CS_pre, uint8_t *CS_post);
// interface-specific methods
WriteCommandProc WriteCommand;

View File

@@ -51,10 +51,9 @@ bool GDS_SPIAttachDevice( struct GDS_Device* Device, int Width, int Height, int
SPIDeviceConfig.spics_io_num = CSPin;
SPIDeviceConfig.queue_size = 1;
SPIDeviceConfig.flags = SPI_DEVICE_NO_DUMMY;
SPIDeviceConfig.cs_ena_pretrans = Device->CS_pre;
SPIDeviceConfig.cs_ena_posttrans = Device->CS_post;
SPIDeviceConfig.mode = Device->SPI_mode;
if (Device->SPIParams) Device->SPIParams(SPIDeviceConfig.clock_speed_hz, &SPIDeviceConfig.mode,
&SPIDeviceConfig.cs_ena_pretrans, &SPIDeviceConfig.cs_ena_posttrans);
ESP_ERROR_CHECK_NONFATAL( spi_bus_add_device( SPIHost, &SPIDeviceConfig, &SPIDevice ), return false );
Device->WriteCommand = SPIDefaultWriteCommand;