/* * lcmComm_dgus.c * * Created on : 2020-10-20 * Update on : 2022-03-01 * Author : Folus Wen, Eason Yang * Version : V0.27 * */ #include "lcmComm_dgus.h" //#define isDebugPrint //======================================= // Basic routine //======================================= void displayMessageDgus(uint8_t *data, uint16_t len, uint8_t isRX) { uint8_t output[8192]; memset(output, 0x00, ARRAY_SIZE(output)); sprintf((char*)output, "%s", (isRX?"RX: ":"TX: ")); for(uint16_t idx = 0;idx= ARRAY_SIZE(tx)) { usleep(100); len = read(fd, rx, rx_len); if(len > 0) { if((rx[0] == CMD_ACK_VALUE_1) && (rx[1] == CMD_ACK_VALUE_2)) { displayMessageDgus(rx, len, YES); result = PASS; } } } else {} return result; } //======================================= // Call function (Write register value function) //======================================= int8_t lcdRegisterWrite(int32_t fd, uint16_t address, uint8_t *data, uint8_t dataLen) { int8_t result = FAIL; uint8_t tx[5 + dataLen]; uint8_t rx[128]; memset(tx, 0x00, sizeof(tx)); memset(rx, 0x00, sizeof(rx)); tx[0] = CMD_HEADER_1; tx[1] = CMD_HEADER_2; tx[2] = (2 + dataLen); tx[3] = CMD_REG_WRITE; tx[4] = (address & 0xff); memcpy(&tx[5], data, dataLen); if(fd > 0) { if(transceiverDgus(fd, tx, ARRAY_SIZE(tx), rx, ARRAY_SIZE(rx)) == PASS) { result = PASS; } else {} } else {} return result; }