cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_DSI_Read() - how to use it??

TDJ
Senior III

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().");
}

1 ACCEPTED SOLUTION

Accepted Solutions
TDJ
Senior III

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().");
}

View solution in original post

4 REPLIES 4
TDJ
Senior III

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().");
}

AELGH1
Associate II

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.

TDJ
Senior III

I am glad it help 🙂

DShub.1
Associate II

Thanks a lot 👍