2020-05-01 01:00 PM
For a test I try to read current LCD brightness - 0x5E register using STM32F769-DISCO board with MB1166 OTM8009A LCD.
DSI has been properly configured for the command mode - writing works OK. I know because display gets properly initialized.
I looked everywhere and I found no example of how to use HAL_DSI_Read().
One post I came across suggests that HAL_DSI_ConfigFlowControl(hdsi, DSI_FLOW_CONTROL_BTA) needs to be called first. It seems to help, there are no timeout errors but nothing gets read.
Please advice. This seems to be reoccurring question with no answer or even a sign someone succeeded. Below is what I have tried.
void test() {
uint8_t buffer[2];
memset(buffer, 0, 2);
MyDsiRead1Param(&hdsi_discovery, 0x5E, buffer, 2);
}
void MyDsiReadCmd(DSI_HandleTypeDef *hdsi, uint8_t cmd, uint8_t *buffer, uint32_t size) {
HAL_StatusTypeDef status = HAL_DSI_ConfigFlowControl(hdsi, DSI_FLOW_CONTROL_BTA);
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_ConfigFlowControl().");
status = HAL_DSI_Read(hdsi, LCD_CHANEL_ID, buffer, size, DSI_DCS_SHORT_PKT_READ, cmd, (uint8_t[]){0, 0});
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_Read().");
}
void MyDsiRead1Param(DSI_HandleTypeDef *hdsi, uint8_t param, uint8_t *buffer, uint32_t size) {
HAL_StatusTypeDef status = HAL_DSI_ConfigFlowControl(hdsi, DSI_FLOW_CONTROL_BTA);
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_ConfigFlowControl().");
status = HAL_DSI_Read(hdsi, LCD_CHANEL_ID, buffer, size, DSI_GEN_SHORT_PKT_READ_P1, 0, (uint8_t[]){param, 0});
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_Read().");
}
Solved! Go to Solution.
2020-05-03 03:16 AM
OK, I have figured it out. MIP-DSI Specification ver. 1.01 does not contain a command for reading arbitrary registry.
Here is now Device Descriptor Block (DDB) can be read. Interestingly, all three MyDsiRead* methods work.
/* @brief Read Device Descriptor Block (DDB), MIPI-DCS Specs ver 1.01, section 6.21 */
void ReadDsiDdb(void) {
const uint8_t len = 5;
uint8_t buffer[len];
memset(buffer, 0, len);
MyDsiRead1Param(&hdsi_discovery, 0xA1, buffer, len);
uint16_t supplierId = (buffer[0] << 8) | buffer[1]; // expect 395 (ORISE)
uint16_t supplierData = (buffer[2] << 8) | buffer[3]; // for OTM8009A expect 0x8009
uint8_t escapeCode = buffer[4]; // 0xFF exit code, 0x00 escape code, any other value: more data to read
}
void MyDsiReadCmd(DSI_HandleTypeDef *hdsi, uint8_t cmd, uint8_t *buffer, uint32_t size) {
HAL_StatusTypeDef status = HAL_DSI_ConfigFlowControl(hdsi, DSI_FLOW_CONTROL_BTA);
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_ConfigFlowControl().");
status = HAL_DSI_Read(hdsi, LCD_CHANEL_ID, buffer, size, DSI_DCS_SHORT_PKT_READ, cmd, (uint8_t[]){0, 0});
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_Read().");
}
void MyDsiRead1Param(DSI_HandleTypeDef *hdsi, uint8_t param, uint8_t *buffer, uint32_t size) {
HAL_StatusTypeDef status = HAL_DSI_ConfigFlowControl(hdsi, DSI_FLOW_CONTROL_BTA);
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_ConfigFlowControl().");
status = HAL_DSI_Read(hdsi, LCD_CHANEL_ID, buffer, size, DSI_GEN_SHORT_PKT_READ_P1, 0, (uint8_t[]){param, 0});
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_Read().");
}
void MyDsiRead2Param(DSI_HandleTypeDef *hdsi, uint16_t param, uint8_t *buffer, uint32_t size) {
uint8_t params[2];
params[0] = param & 0xFF;
params[1] = (param >> 8) & 0xFF;
HAL_StatusTypeDef status = HAL_DSI_ConfigFlowControl(hdsi, DSI_FLOW_CONTROL_BTA);
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_ConfigFlowControl().");
status = HAL_DSI_Read(hdsi, LCD_CHANEL_ID, buffer, size, DSI_GEN_SHORT_PKT_READ_P2, 0, params);
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_Read().");
}
2020-05-03 03:16 AM
OK, I have figured it out. MIP-DSI Specification ver. 1.01 does not contain a command for reading arbitrary registry.
Here is now Device Descriptor Block (DDB) can be read. Interestingly, all three MyDsiRead* methods work.
/* @brief Read Device Descriptor Block (DDB), MIPI-DCS Specs ver 1.01, section 6.21 */
void ReadDsiDdb(void) {
const uint8_t len = 5;
uint8_t buffer[len];
memset(buffer, 0, len);
MyDsiRead1Param(&hdsi_discovery, 0xA1, buffer, len);
uint16_t supplierId = (buffer[0] << 8) | buffer[1]; // expect 395 (ORISE)
uint16_t supplierData = (buffer[2] << 8) | buffer[3]; // for OTM8009A expect 0x8009
uint8_t escapeCode = buffer[4]; // 0xFF exit code, 0x00 escape code, any other value: more data to read
}
void MyDsiReadCmd(DSI_HandleTypeDef *hdsi, uint8_t cmd, uint8_t *buffer, uint32_t size) {
HAL_StatusTypeDef status = HAL_DSI_ConfigFlowControl(hdsi, DSI_FLOW_CONTROL_BTA);
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_ConfigFlowControl().");
status = HAL_DSI_Read(hdsi, LCD_CHANEL_ID, buffer, size, DSI_DCS_SHORT_PKT_READ, cmd, (uint8_t[]){0, 0});
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_Read().");
}
void MyDsiRead1Param(DSI_HandleTypeDef *hdsi, uint8_t param, uint8_t *buffer, uint32_t size) {
HAL_StatusTypeDef status = HAL_DSI_ConfigFlowControl(hdsi, DSI_FLOW_CONTROL_BTA);
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_ConfigFlowControl().");
status = HAL_DSI_Read(hdsi, LCD_CHANEL_ID, buffer, size, DSI_GEN_SHORT_PKT_READ_P1, 0, (uint8_t[]){param, 0});
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_Read().");
}
void MyDsiRead2Param(DSI_HandleTypeDef *hdsi, uint16_t param, uint8_t *buffer, uint32_t size) {
uint8_t params[2];
params[0] = param & 0xFF;
params[1] = (param >> 8) & 0xFF;
HAL_StatusTypeDef status = HAL_DSI_ConfigFlowControl(hdsi, DSI_FLOW_CONTROL_BTA);
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_ConfigFlowControl().");
status = HAL_DSI_Read(hdsi, LCD_CHANEL_ID, buffer, size, DSI_GEN_SHORT_PKT_READ_P2, 0, params);
if (status != HAL_OK) MBED_ERROR(status, "Error calling HAL_DSI_Read().");
}
2021-12-24 04:59 AM
I registered only to say : Thank you.
I wasn't receiving an answer to my read command. Little did I know that DSI only accepted reverse communication if Bus TurnAround was activated.
2021-12-29 02:54 AM - edited 2023-08-22 03:38 AM
I am glad it help :)
2023-07-23 06:47 AM
Thanks a lot :thumbs_up: