diff --git a/bes2600/liteos_m/components/drivers/BUILD.gn b/bes2600/liteos_m/components/drivers/BUILD.gn old mode 100644 new mode 100755 index 364b69abef3e9f005b53652cfb589182e8e74447..4ae2bb10e21b1e9b993456e0b3b0f16a0472ab38 --- a/bes2600/liteos_m/components/drivers/BUILD.gn +++ b/bes2600/liteos_m/components/drivers/BUILD.gn @@ -15,9 +15,9 @@ import("//drivers/adapter/khdf/liteos_m/hdf.gni") module_group("drivers") { modules = [ - "display", - "flash", - "mipi_dsi", - "touch", + "peripheral/display/", + "misc/flash", + "platform/mipi/", + "peripheral/touch", ] } diff --git a/bes2600/liteos_m/components/drivers/flash/BUILD.gn b/bes2600/liteos_m/components/drivers/misc/flash/BUILD.gn similarity index 100% rename from bes2600/liteos_m/components/drivers/flash/BUILD.gn rename to bes2600/liteos_m/components/drivers/misc/flash/BUILD.gn diff --git a/bes2600/liteos_m/components/drivers/flash/flash.c b/bes2600/liteos_m/components/drivers/misc/flash/flash.c old mode 100644 new mode 100755 similarity index 85% rename from bes2600/liteos_m/components/drivers/flash/flash.c rename to bes2600/liteos_m/components/drivers/misc/flash/flash.c index 2c01cd06f14855a89d67051fab0dd3e3812a1bf2..f874b55c55233010b2873ed7c3a589a2c5946b65 --- a/bes2600/liteos_m/components/drivers/flash/flash.c +++ b/bes2600/liteos_m/components/drivers/misc/flash/flash.c @@ -14,7 +14,6 @@ */ #include #include -#include "flash.h" #include "cmsis_os.h" #include "cmsis_os2.h" #include "hal_trace.h" @@ -24,6 +23,7 @@ #include "cmsis.h" #include "pmu.h" #include "crc32_c.h" +#include "flash.h" #if BES_HAL_DEBUG #define ENTER_FUNCTION() printf("%s enter ->\n", __FUNCTION__) @@ -45,7 +45,7 @@ #define RW_MAX_BLOCK 13 #define RW_MAX_PARTITION 3 #define MAX_FLASH_OPTIONS 3 -extern const hal_logic_partition_t g_halPartitions[]; +extern const hal_logic_partition_t g_halPartitions[HAL_PARTITION_MAX]; static bootinfo_zone cur_bootinfo_zone = BOOTINFO_ZONE_MAX; static bootinfo_zone cur_bootinfoBK_zone = BOOTINFO_ZONE_MAX; @@ -132,7 +132,8 @@ int bes_check_user_write_flash_addr(const uint32_t addr, const uint32_t size) break; } - if ((info.partition_start_addr <= addr) && ((addr + size) <= (info.partition_start_addr + info.partition_length))) { + if ((info.partition_start_addr <= addr) + && ((addr + size) <= (info.partition_start_addr + info.partition_length))) { ret = 0; break; } @@ -153,15 +154,15 @@ static void FlashosMutexWait(void) void *my_memcpy(void *dst, void *src, size_t num) { - int offset1 = (4 - ((uint32_t)dst & 3)) & 3; - int offset2 = (4 - ((uint32_t)src & 3)) & 3; + int offset1 = (4 - ((uint32_t)dst & 3)) & 3; // 4 3 + int offset2 = (4 - ((uint32_t)src & 3)) & 3; // 4 3 if (offset1 != offset2) { return memcpy(dst, src, num); } - int wordnum = num > offset1 ? (num - offset1) / 8 : 0; - int slice = num > offset1 ? (num - offset1) % 8 : 0; + int wordnum = num > offset1 ? (num - offset1) / 8 : 0; // 8 + int slice = num > offset1 ? (num - offset1) % 8 : 0; // 8 char *pdst = (char *)dst; char *psrc = (char *)src; long long *pintsrc = NULL; @@ -258,7 +259,10 @@ static int32_t SetFlashOptionInfo(hal_partition_t partition, uint32_t size, uint { uint32_t blockNum; - if (((partition != HAL_PARTITION_DATA) && (partition != HAL_PARTITION_LOG) && (partition != HAL_PARTITION_RESOURCE)) || (option >= MAX_FLASH_OPTIONS)) { + if (((partition != HAL_PARTITION_DATA) + && (partition != HAL_PARTITION_LOG) + && (partition != HAL_PARTITION_RESOURCE)) + || (option >= MAX_FLASH_OPTIONS)) { TRACE(0, "%s---%d----%d-----%d\r\n", __FUNCTION__, partition, size, option); return -1; } @@ -292,7 +296,10 @@ static int32_t SetFlashOptionInfo(hal_partition_t partition, uint32_t size, uint static int32_t SetFlashBadOptionInfo(hal_partition_t partition, uint32_t size, uint32_t option) { - if (((partition != HAL_PARTITION_DATA) && (partition != HAL_PARTITION_LOG) && (partition != HAL_PARTITION_RESOURCE)) || (option >= MAX_FLASH_OPTIONS)) { + if (((partition != HAL_PARTITION_DATA) + && (partition != HAL_PARTITION_LOG) + && (partition != HAL_PARTITION_RESOURCE)) + || (option >= MAX_FLASH_OPTIONS)) { return -1; } @@ -410,6 +417,7 @@ int32_t hal_flash_write(hal_partition_t in_partition, uint32_t *off_set, const v int32_t ret = 0; uint32_t start_addr; uint32_t partition_end; + uint32_t temp_in_buffer_len = in_buf_len; hal_logic_partition_t info; ENTER_FUNCTION(); @@ -427,9 +435,9 @@ int32_t hal_flash_write(hal_partition_t in_partition, uint32_t *off_set, const v goto RETURN; } - if ((start_addr + in_buf_len) > partition_end) { - in_buf_len = partition_end - start_addr; - TRACE(0, "flash over write, new len is %d\r\n", in_buf_len); + if ((start_addr + temp_in_buffer_len) > partition_end) { + temp_in_buffer_len = partition_end - start_addr; + TRACE(0, "flash over write, new len is %d\r\n", temp_in_buffer_len); } ret = SetFlashOptionInfo(in_partition, start_addr, FLASH_WRITE); @@ -437,9 +445,9 @@ int32_t hal_flash_write(hal_partition_t in_partition, uint32_t *off_set, const v TRACE(0, "SetFlashOptionInfo FAIL\r\n"); } - ret = flash_write(start_addr, in_buf, in_buf_len); + ret = flash_write(start_addr, in_buf, temp_in_buffer_len); if (!ret) { - *off_set += in_buf_len; + *off_set += temp_in_buffer_len; } else { SetFlashBadOptionInfo(in_partition, start_addr, FLASH_WRITE); } @@ -467,6 +475,7 @@ int32_t hal_flash_erase_write(hal_partition_t in_partition, uint32_t *off_set, c int32_t ret = 0; uint32_t start_addr; uint32_t partition_end; + uint32_t temp_in_buf_len = in_buf_len; hal_logic_partition_t info; ENTER_FUNCTION(); @@ -485,9 +494,9 @@ int32_t hal_flash_erase_write(hal_partition_t in_partition, uint32_t *off_set, c goto RETURN; } - if ((start_addr + in_buf_len) > partition_end) { - in_buf_len = partition_end - start_addr; - TRACE(0, "flash over write, new len is %d\r\n", in_buf_len); + if ((start_addr + temp_in_buf_len) > partition_end) { + temp_in_buf_len = partition_end - start_addr; + TRACE(0, "flash over write, new len is %d\r\n", temp_in_buf_len); } ret = SetFlashOptionInfo(in_partition, start_addr, FLASH_ERASE); @@ -495,7 +504,7 @@ int32_t hal_flash_erase_write(hal_partition_t in_partition, uint32_t *off_set, c TRACE(0, "SetFlashOptionInfo FAIL\r\n"); } - ret = flash_erase(start_addr, in_buf_len); + ret = flash_erase(start_addr, temp_in_buf_len); if (ret) { TRACE(0, "flash erase fail\r\n"); ret = -1; @@ -508,9 +517,9 @@ int32_t hal_flash_erase_write(hal_partition_t in_partition, uint32_t *off_set, c TRACE(0, "SetFlashOptionInfo FAIL\r\n"); } - ret = flash_write(start_addr, in_buf, in_buf_len); + ret = flash_write(start_addr, in_buf, temp_in_buf_len); if (!ret) { - *off_set += in_buf_len; + *off_set += temp_in_buf_len; } else { SetFlashBadOptionInfo(in_partition, start_addr, FLASH_WRITE); } @@ -681,7 +690,7 @@ int ota_write_bootinfo_to_flash(MiscDataInfo *info, bootinfo_block block, bootin pmu_flash_write_config(); memcpy(buffer, (uint8_t *)info, sizeof(MiscDataInfo)); - //erase current sector + // erase current sector lock = int_lock_global(); ret = NORFLASH_API_WRAP(hal_norflash_erase)(HAL_FLASH_ID_0, cur_addr, FLASH_SECTOR_SIZE_IN_BYTES); int_unlock_global(lock); @@ -871,27 +880,27 @@ int SetMiscData(MiscDataType type, const void *data, uint32_t dataLen) } switch (type) { - case MISC_CUR_BOOT_AREA: - memcpy(&ctrl.curbootArea, data, dataLen); - break; - case MISC_UPG_MODE: - memcpy(&ctrl.upgMode, data, dataLen); - break; - case MISC_QUIET_UPG_FLAG: - memcpy(&ctrl.quietUpgFlg, data, dataLen); - break; - case MISC_TIMER_REBOOT_FLAG: - memcpy(&ctrl.timerRebootFlg, data, dataLen); - break; - case MISC_BOOT_TIMES: - memcpy(&ctrl.bootTimes, data, dataLen); - break; - case MISC_RD_MODE_INFO: - memcpy(&ctrl.rdMode.rdDataLen, data, dataLen); - ctrl.len += dataLen; - break; - default: - return ERR_PARAMETER; + case MISC_CUR_BOOT_AREA: + memcpy(&ctrl.curbootArea, data, dataLen); + break; + case MISC_UPG_MODE: + memcpy(&ctrl.upgMode, data, dataLen); + break; + case MISC_QUIET_UPG_FLAG: + memcpy(&ctrl.quietUpgFlg, data, dataLen); + break; + case MISC_TIMER_REBOOT_FLAG: + memcpy(&ctrl.timerRebootFlg, data, dataLen); + break; + case MISC_BOOT_TIMES: + memcpy(&ctrl.bootTimes, data, dataLen); + break; + case MISC_RD_MODE_INFO: + memcpy(&ctrl.rdMode.rdDataLen, data, dataLen); + ctrl.len += dataLen; + break; + default: + return ERR_PARAMETER; } ret = ota_set_bootinfo_to_zoneAB(&ctrl); @@ -920,32 +929,32 @@ int GetMiscData(MiscDataType type, void *data, uint32_t dataLen) osMutexRelease(FlashMutex); switch (type) { - case MISC_CRC_VALUE: - memcpy(data, &ctrl.crcVal, dataLen); - break; - case MISC_DATA_LENGTH: - memcpy(data, &ctrl.len, dataLen); - break; - case MISC_CUR_BOOT_AREA: - memcpy(data, &ctrl.curbootArea, dataLen); - break; - case MISC_UPG_MODE: - memcpy(data, &ctrl.upgMode, dataLen); - break; - case MISC_QUIET_UPG_FLAG: - memcpy(data, &ctrl.quietUpgFlg, dataLen); - break; - case MISC_TIMER_REBOOT_FLAG: - memcpy(data, &ctrl.timerRebootFlg, dataLen); - break; - case MISC_BOOT_TIMES: - memcpy(data, &ctrl.bootTimes, dataLen); - break; - case MISC_RD_MODE_INFO: - memcpy(data, &ctrl.rdMode.rdDataLen, dataLen); - break; - default: - return ERR_PARAMETER; + case MISC_CRC_VALUE: + memcpy(data, &ctrl.crcVal, dataLen); + break; + case MISC_DATA_LENGTH: + memcpy(data, &ctrl.len, dataLen); + break; + case MISC_CUR_BOOT_AREA: + memcpy(data, &ctrl.curbootArea, dataLen); + break; + case MISC_UPG_MODE: + memcpy(data, &ctrl.upgMode, dataLen); + break; + case MISC_QUIET_UPG_FLAG: + memcpy(data, &ctrl.quietUpgFlg, dataLen); + break; + case MISC_TIMER_REBOOT_FLAG: + memcpy(data, &ctrl.timerRebootFlg, dataLen); + break; + case MISC_BOOT_TIMES: + memcpy(data, &ctrl.bootTimes, dataLen); + break; + case MISC_RD_MODE_INFO: + memcpy(data, &ctrl.rdMode.rdDataLen, dataLen); + break; + default: + return ERR_PARAMETER; } return ERR_OK; @@ -958,7 +967,7 @@ int ota_flash_read(const hal_partition_t partition, const uint32_t addr, uint8_t hal_logic_partition_t partitionInfo; uint32_t flash_offset = 0; - if (NULL == dst) { + if (dst == NULL) { ret = -1; goto RETURN; } @@ -989,7 +998,11 @@ static void ota_feed_watchdog(void) #endif } -static int ota_partition_common_erase_write(const hal_partition_t partition, uint32_t start_addr, uint32_t erase_len, uint8_t *src_buf, uint32_t src_len) +static int ota_partition_common_erase_write(const hal_partition_t partition, + uint32_t start_addr, + uint32_t erase_len, + uint8_t *src_buf, + uint32_t src_len) { int ret = 0; uint32_t lock = 0; @@ -1015,7 +1028,10 @@ static int ota_partition_common_erase_write(const hal_partition_t partition, uin return ret; } -static int ota_partition_erase_write(const hal_partition_t partition, uint32_t *start_addr, uint8_t *src_buf, uint32_t src_len) +static int ota_partition_erase_write(const hal_partition_t partition, + uint32_t *start_addr, + uint8_t *src_buf, + uint32_t src_len) { int ret = 0; uint32_t lock = 0, num = 0; @@ -1046,7 +1062,13 @@ static int ota_partition_erase_write(const hal_partition_t partition, uint32_t * return ret; } -static int ota_partition_read_erase_write(const hal_partition_t partition, uint32_t start_addr, uint8_t *dst_buf, uint32_t dst_buf_len, uint32_t dst_offset, uint8_t *src_buf, uint32_t src_len) +static int ota_partition_read_erase_write(const hal_partition_t partition, + uint32_t start_addr, + uint8_t *dst_buf, + uint32_t dst_buf_len, + uint32_t dst_offset, + uint8_t *src_buf, + uint32_t src_len) { int ret = 0; uint32_t lock; @@ -1085,10 +1107,16 @@ static int ota_partition_check_magic(const hal_partition_t partition, const uint uint32_t flash_offset = partition_info.partition_start_addr; magic_buf[0] = 0x1c; magic_buf[1] = 0xec; - magic_buf[2] = 0x57; - magic_buf[3] = 0xbe; - - ret = ota_partition_read_erase_write(partition, flash_offset, read_buf, sizeof(read_buf), 0, magic_buf, sizeof(magic_buf)); + magic_buf[2] = 0x57; // 2 + magic_buf[3] = 0xbe; // 3 + + ret = ota_partition_read_erase_write(partition, + flash_offset, + read_buf, + sizeof(read_buf), + 0, + magic_buf, + sizeof(magic_buf)); if (ret != HAL_NORFLASH_OK) { return ERR_RETURN; } @@ -1115,8 +1143,9 @@ int ota_flash_write(const hal_partition_t partition, const uint32_t addr, const if ((addr % OTA_MALLOC_BUF_SIZE != 0) || (lengthToBurn % OTA_MALLOC_BUF_SIZE != 0)) { buf = (uint8_t *)malloc(OTA_MALLOC_BUF_SIZE); - if (!buf) + if (!buf) { return ERR_RETURN; + } } ota_feed_watchdog(); @@ -1128,7 +1157,13 @@ int ota_flash_write(const hal_partition_t partition, const uint32_t addr, const left_len = OTA_MALLOC_BUF_SIZE - flash_offset % OTA_MALLOC_BUF_SIZE; fill_len = (left_len >= lengthToBurn) ? lengthToBurn : left_len; align_len = flash_offset - flash_offset % OTA_MALLOC_BUF_SIZE; - ret = ota_partition_read_erase_write(partition, align_len, buf, OTA_MALLOC_BUF_SIZE, (flash_offset % OTA_MALLOC_BUF_SIZE), ptrSource, fill_len); + ret = ota_partition_read_erase_write(partition, + align_len, + buf, + OTA_MALLOC_BUF_SIZE, + (flash_offset % OTA_MALLOC_BUF_SIZE), + ptrSource, + fill_len); if (ret != HAL_NORFLASH_OK) goto end; lengthToBurn -= fill_len; @@ -1141,7 +1176,13 @@ int ota_flash_write(const hal_partition_t partition, const uint32_t addr, const goto end; if (lengthToBurn % OTA_MALLOC_BUF_SIZE) { - ret = ota_partition_read_erase_write(partition, flash_offset, buf, OTA_MALLOC_BUF_SIZE, 0, ptrSource, (lengthToBurn % OTA_MALLOC_BUF_SIZE)); + ret = ota_partition_read_erase_write(partition, + flash_offset, + buf, + OTA_MALLOC_BUF_SIZE, + 0, + ptrSource, + (lengthToBurn % OTA_MALLOC_BUF_SIZE)); if (ret != HAL_NORFLASH_OK) goto end; } @@ -1213,11 +1254,11 @@ int32_t GetFlashType(int32_t *factoryID, int32_t *deviceID) NORFLASH_API_WRAP(hal_norflash_get_id)(HAL_FLASH_ID_0, flash_id, ARRAY_SIZE(flash_id)); - TRACE(3, "FLASH_ID: %02X-%02X-%02X", flash_id[0], flash_id[1], flash_id[2]); + TRACE(3, "FLASH_ID: %02X-%02X-%02X", flash_id[0], flash_id[1], flash_id[2]); // 3 2 *factoryID = flash_id[0]; - a = 0xffff00ff | (flash_id[1] << 8); - b = 0xffffff00 | flash_id[2]; + a = 0xffff00ff | (flash_id[1] << 8); // 8 bit + b = 0xffffff00 | flash_id[2]; // 2 *deviceID = a & b; @@ -1230,7 +1271,10 @@ int32_t GetFlashType(int32_t *factoryID, int32_t *deviceID) * 读或者写:op * 获取该块号的写或者擦的次数:times */ -int32_t GetFlashRewriteCycle(hal_partition_t partition, uint32_t blockNum, uint32_t op, uint32_t *times) +int32_t GetFlashRewriteCycle(hal_partition_t partition, + uint32_t blockNum, + uint32_t op, + uint32_t *times) { struct HAL_FLASH_RW_INFO *FlashRwInfo = NULL; @@ -1302,7 +1346,9 @@ int32_t GetFlashStatisticInfo(hal_partition_t partition, uint32_t blockNum, uint for (size_t i = 0; i < BLOCK_MAX_INFO; i++) { flashBadInfo = &g_flashBadInfo[i]; - if ((flashBadInfo->partition == partition) && (flashBadInfo->blocknum <= blockNum) && (flashBadInfo->partition == op)) { + if ((flashBadInfo->partition == partition) + && (flashBadInfo->blocknum <= blockNum) + && (flashBadInfo->partition == op)) { blockcount++; } } diff --git a/bes2600/liteos_m/components/drivers/flash/flash.h b/bes2600/liteos_m/components/drivers/misc/flash/flash.h old mode 100644 new mode 100755 similarity index 100% rename from bes2600/liteos_m/components/drivers/flash/flash.h rename to bes2600/liteos_m/components/drivers/misc/flash/flash.h index e84cdd243e57e0570ba58e43fa31ad47edafbcee..55dbf497fa0a2f6cfd27833526823d2d9469da6d --- a/bes2600/liteos_m/components/drivers/flash/flash.h +++ b/bes2600/liteos_m/components/drivers/misc/flash/flash.h @@ -15,12 +15,12 @@ #ifndef HAL_FLASH_H #define HAL_FLASH_H +#include + #ifdef __cplusplus extern "C" { #endif -#include - #define PAR_OPT_READ_POS (0) #define PAR_OPT_WRITE_POS (1) diff --git a/bes2600/liteos_m/components/drivers/flash/flash_conf.c b/bes2600/liteos_m/components/drivers/misc/flash/flash_conf.c old mode 100644 new mode 100755 similarity index 87% rename from bes2600/liteos_m/components/drivers/flash/flash_conf.c rename to bes2600/liteos_m/components/drivers/misc/flash/flash_conf.c index 55db603cd571d29bd74d453d691ae9b999855e51..895ff63a7d316f31dbbb206c88413f73b93a3206 --- a/bes2600/liteos_m/components/drivers/flash/flash_conf.c +++ b/bes2600/liteos_m/components/drivers/misc/flash/flash_conf.c @@ -28,105 +28,105 @@ hal_logic_partition_t g_halPartitions[] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "boot1", .partition_start_addr = 0x0, - .partition_length = 0x10000, //64KB + .partition_length = 0x10000, // 64KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, [HAL_PARTITION_BOOT2A] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "boot2A", .partition_start_addr = 0x10000, - .partition_length = 0x10000, //64KB + .partition_length = 0x10000, // 64KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, [HAL_PARTITION_BOOT2B] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "boot2B", .partition_start_addr = 0x20000, - .partition_length = 0x10000, //64KB + .partition_length = 0x10000, // 64KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, [HAL_PARTITION_TRUSTZONEA] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "trustzoneA", .partition_start_addr = 0x30000, - .partition_length = 0x26000, //152KB + .partition_length = 0x26000, // 152KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, [HAL_PARTITION_TRUSTZONEB] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "trustzoneB", .partition_start_addr = 0x56000, - .partition_length = 0x26000, //152KB + .partition_length = 0x26000, // 152KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, [HAL_PARTITION_TZ_INFO] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "trustzoneInfo", .partition_start_addr = 0x7C000, - .partition_length = 0x4000, //16KB + .partition_length = 0x4000, // 16KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, [HAL_PARTITION_CM33_MAIN] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "cm33_main", .partition_start_addr = 0x80000, - .partition_length = 0x7E0000, //8064KB + .partition_length = 0x7E0000, // 8064KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, [HAL_PARTITION_SYSTEM_MINI] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "system_mini", .partition_start_addr = 0x860000, - .partition_length = 0x300000, //3072KB + .partition_length = 0x300000, // 3072KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, [HAL_PARTITION_RESOURCE] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "littlefs", .partition_start_addr = 0xB60000, - .partition_length = 0x400000, //4096KB + .partition_length = 0x400000, // 4096KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, [HAL_PARTITION_LOG] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "log", .partition_start_addr = 0xF60000, - .partition_length = 0x30000, //192KB + .partition_length = 0x30000, // 192KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, [HAL_PARTITION_DATA] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "data", .partition_start_addr = 0xF90000, - .partition_length = 0x40000, //256KB + .partition_length = 0x40000, // 256KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, [HAL_PARTITION_MISC] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "misc", .partition_start_addr = 0xFD0000, - .partition_length = 0xC000, //48KB + .partition_length = 0xC000, // 48KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, [HAL_PARTITION_USERDATA] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "userdata", .partition_start_addr = 0xFDC000, - .partition_length = 0x4000, //16KB + .partition_length = 0x4000, // 16KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, [HAL_PARTITION_ENV] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "factory", .partition_start_addr = 0xFE0000, - .partition_length = 0x10000, //64KB + .partition_length = 0x10000, // 64KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, [HAL_PARTITION_ENV_REDUND] = { .partition_owner = HAL_FLASH_EMBEDDED, .partition_description = "factory_backup", .partition_start_addr = 0xFF0000, - .partition_length = 0x10000, //64KB + .partition_length = 0x10000, // 64KB .partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN, }, }; @@ -157,7 +157,8 @@ static uint32_t FlashGetResource() g_halPartitions[partition].partition_start_addr = start_addr[i]; g_halPartitions[partition].partition_length = length[i]; g_halPartitions[partition].partition_options = options[i]; - HDF_LOGD("%s: partition[%u] owner=%u, description=%s, start_addr=0x%x, length=0x%x, options=%u", __func__, partition, + HDF_LOGD("%s: partition[%u] owner=%u, description=%s, start_addr=0x%x, length=0x%x, options=%u", + __func__, partition, g_halPartitions[partition].partition_owner, g_halPartitions[partition].partition_description, g_halPartitions[partition].partition_start_addr, g_halPartitions[partition].partition_length, g_halPartitions[partition].partition_options); @@ -187,27 +188,33 @@ static uint32_t FlashGetResource(const struct DeviceResourceNode *resourceNode) HDF_LOGE("%s: invalid partition %u", __func__, partition); return HDF_FAILURE; } - if (resource->GetUint32ArrayElem(resourceNode, "owner", i, (uint32_t *)&g_halPartitions[partition].partition_owner, 0) != HDF_SUCCESS) { + if (resource->GetUint32ArrayElem(resourceNode, "owner", + i, (uint32_t *)&g_halPartitions[partition].partition_owner, 0) != HDF_SUCCESS) { HDF_LOGE("%s: failed to get owner", __func__); return HDF_FAILURE; } - if (resource->GetStringArrayElem(resourceNode, "description", i, &g_halPartitions[partition].partition_description, NULL) != HDF_SUCCESS) { + if (resource->GetStringArrayElem(resourceNode, "description", + i, &g_halPartitions[partition].partition_description, NULL) != HDF_SUCCESS) { HDF_LOGE("%s: failed to get mount_points", __func__); return HDF_FAILURE; } - if (resource->GetUint32ArrayElem(resourceNode, "start_addr", i, &g_halPartitions[partition].partition_start_addr, 0) != HDF_SUCCESS) { + if (resource->GetUint32ArrayElem(resourceNode, "start_addr", + i, &g_halPartitions[partition].partition_start_addr, 0) != HDF_SUCCESS) { HDF_LOGE("%s: failed to get block_size", __func__); return HDF_FAILURE; } - if (resource->GetUint32ArrayElem(resourceNode, "length", i, &g_halPartitions[partition].partition_length, 0) != HDF_SUCCESS) { + if (resource->GetUint32ArrayElem(resourceNode, "length", + i, &g_halPartitions[partition].partition_length, 0) != HDF_SUCCESS) { HDF_LOGE("%s: failed to get block_count", __func__); return HDF_FAILURE; } - if (resource->GetUint32ArrayElem(resourceNode, "options", i, &g_halPartitions[partition].partition_options, 0) != HDF_SUCCESS) { + if (resource->GetUint32ArrayElem(resourceNode, "options", + i, &g_halPartitions[partition].partition_options, 0) != HDF_SUCCESS) { HDF_LOGE("%s: failed to get block_count", __func__); return HDF_FAILURE; } - HDF_LOGD("%s: partition[%u] owner=%u, description=%s, start_addr=0x%x, length=0x%x, options=%u", __func__, partition, + HDF_LOGD("%s: partition[%u] owner=%u, description=%s, start_addr=0x%x, length=0x%x, options=%u", + __func__, partition, g_halPartitions[partition].partition_owner, g_halPartitions[partition].partition_description, g_halPartitions[partition].partition_start_addr, g_halPartitions[partition].partition_length, g_halPartitions[partition].partition_options); diff --git a/bes2600/liteos_m/components/drivers/display/BUILD.gn b/bes2600/liteos_m/components/drivers/peripheral/display/BUILD.gn similarity index 100% rename from bes2600/liteos_m/components/drivers/display/BUILD.gn rename to bes2600/liteos_m/components/drivers/peripheral/display/BUILD.gn diff --git a/bes2600/liteos_m/components/drivers/display/hal/BUILD.gn b/bes2600/liteos_m/components/drivers/peripheral/display/hal/BUILD.gn similarity index 100% rename from bes2600/liteos_m/components/drivers/display/hal/BUILD.gn rename to bes2600/liteos_m/components/drivers/peripheral/display/hal/BUILD.gn diff --git a/bes2600/liteos_m/components/drivers/display/hal/disp_hal.c b/bes2600/liteos_m/components/drivers/peripheral/display/hal/disp_hal.c old mode 100644 new mode 100755 similarity index 98% rename from bes2600/liteos_m/components/drivers/display/hal/disp_hal.c rename to bes2600/liteos_m/components/drivers/peripheral/display/hal/disp_hal.c index 9b1e0ac61aef74212ba88e8802d9004870a5cb26..01479546e8bf4d9b00d3caf3ac126c57add47dd9 --- a/bes2600/liteos_m/components/drivers/display/hal/disp_hal.c +++ b/bes2600/liteos_m/components/drivers/peripheral/display/hal/disp_hal.c @@ -117,7 +117,7 @@ int32_t DispSetBacklight(uint32_t devId, uint32_t level) #define HDF_MIPI_DSI_SERVICE "HDF_PLATFORM_MIPI_DSI" -static struct MipiDsiService *GetDispService() +static struct MipiDsiService *GetDispService(void) { static struct MipiDsiService *service = NULL; if (service == NULL) { diff --git a/bes2600/liteos_m/components/drivers/display/hal/disp_hal.h b/bes2600/liteos_m/components/drivers/peripheral/display/hal/disp_hal.h similarity index 100% rename from bes2600/liteos_m/components/drivers/display/hal/disp_hal.h rename to bes2600/liteos_m/components/drivers/peripheral/display/hal/disp_hal.h diff --git a/bes2600/liteos_m/components/drivers/display/hal/lcd_abs_if.c b/bes2600/liteos_m/components/drivers/peripheral/display/hal/lcd_abs_if.c old mode 100644 new mode 100755 similarity index 90% rename from bes2600/liteos_m/components/drivers/display/hal/lcd_abs_if.c rename to bes2600/liteos_m/components/drivers/peripheral/display/hal/lcd_abs_if.c index fab3fb7ff62df1786c69f078bd04064358954bfd..9e499473df32fd6fdd43fbfb6945d0940f3eb94d --- a/bes2600/liteos_m/components/drivers/display/hal/lcd_abs_if.c +++ b/bes2600/liteos_m/components/drivers/peripheral/display/hal/lcd_abs_if.c @@ -70,18 +70,18 @@ int32_t GetBitsPerPixel(enum DsiOutFormat format) int32_t bpp; switch (format) { - case FORMAT_RGB_16_BIT: - bpp = 16; - break; - case FORMAT_RGB_18_BIT: - bpp = 18; - break; - case FORMAT_RGB_24_BIT: - bpp = 24; - break; - default: - bpp = 32; - break; + case FORMAT_RGB_16_BIT: + bpp = 16; // 16 bit + break; + case FORMAT_RGB_18_BIT: + bpp = 18; // 18 bit + break; + case FORMAT_RGB_24_BIT: + bpp = 24; // 24 bit + break; + default: + bpp = 32; // 32 bit + break; } return bpp; } diff --git a/bes2600/liteos_m/components/drivers/display/hal/lcd_abs_if.h b/bes2600/liteos_m/components/drivers/peripheral/display/hal/lcd_abs_if.h similarity index 100% rename from bes2600/liteos_m/components/drivers/display/hal/lcd_abs_if.h rename to bes2600/liteos_m/components/drivers/peripheral/display/hal/lcd_abs_if.h diff --git a/bes2600/liteos_m/components/drivers/display/hal/panel/a064.c b/bes2600/liteos_m/components/drivers/peripheral/display/hal/panel/a064.c similarity index 81% rename from bes2600/liteos_m/components/drivers/display/hal/panel/a064.c rename to bes2600/liteos_m/components/drivers/peripheral/display/hal/panel/a064.c index 02d2b0898cb4fa9af9affa4a328828ffb085e424..1c670e3bf8e7345fa91d996adde8b869fc45a84c 100755 --- a/bes2600/liteos_m/components/drivers/display/hal/panel/a064.c +++ b/bes2600/liteos_m/components/drivers/peripheral/display/hal/panel/a064.c @@ -59,24 +59,55 @@ static uint8_t cmd21[] = {0x9A, 0x79}; static uint8_t cmd22[] = {0x9B, 0x62}; static uint8_t cmd23[] = {0x82, 0x34, 0x34}; static uint8_t cmd24[] = {0xB1, 0x90}; // 10 REV-0-BGR-X-X-X-GS-SS //mipi -static uint8_t cmd25[] = {0x6D, 0x00, 0x1F, 0x19, 0x1A, 0x10, 0x0e, 0x0c, 0x0a, 0x02, 0x07, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x08, 0x01, 0x09, 0x0b, 0x0D, 0x0F, 0x1a, 0x19, 0x1f, 0x00}; -static uint8_t cmd26[] = {0x64, 0x38, 0x05, 0x01, 0xdb, 0x03, 0x03, 0x38, 0x04, 0x01, 0xdc, 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A}; -static uint8_t cmd27[] = {0x65, 0x38, 0x03, 0x01, 0xdd, 0x03, 0x03, 0x38, 0x02, 0x01, 0xde, 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A}; -static uint8_t cmd28[] = {0x66, 0x38, 0x01, 0x01, 0xdf, 0x03, 0x03, 0x38, 0x00, 0x01, 0xe0, 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A}; -static uint8_t cmd29[] = {0x67, 0x30, 0x01, 0x01, 0xe1, 0x03, 0x03, 0x30, 0x02, 0x01, 0xe2, 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A}; -static uint8_t cmd30[] = {0x68, 0x00, 0x08, 0x15, 0x08, 0x15, 0x7A, 0x7A, 0x08, 0x15, 0x08, 0x15, 0x7A, 0x7A}; +static uint8_t cmd25[] = {0x6D, 0x00, 0x1F, 0x19, 0x1A, 0x10, 0x0e, 0x0c, 0x0a, 0x02, 0x07, + 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, + 0x1E, 0x08, 0x01, 0x09, 0x0b, 0x0D, 0x0F, 0x1a, 0x19, 0x1f, 0x00}; +static uint8_t cmd26[] = {0x64, 0x38, 0x05, 0x01, 0xdb, 0x03, 0x03, 0x38, 0x04, 0x01, 0xdc, + 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A}; +static uint8_t cmd27[] = {0x65, 0x38, 0x03, 0x01, 0xdd, 0x03, 0x03, 0x38, 0x02, 0x01, 0xde, + 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A}; +static uint8_t cmd28[] = {0x66, 0x38, 0x01, 0x01, 0xdf, 0x03, 0x03, 0x38, 0x00, 0x01, 0xe0, + 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A}; +static uint8_t cmd29[] = {0x67, 0x30, 0x01, 0x01, 0xe1, 0x03, 0x03, 0x30, 0x02, 0x01, 0xe2, + 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A}; +static uint8_t cmd30[] = {0x68, 0x00, 0x08, 0x15, 0x08, 0x15, 0x7A, 0x7A, 0x08, 0x15, 0x08, + 0x15, 0x7A, 0x7A}; static uint8_t cmd31[] = {0x60, 0x38, 0x07, 0x7A, 0x7A, 0x38, 0x08, 0x7A, 0x7A}; static uint8_t cmd32[] = {0x63, 0x31, 0xe4, 0x7A, 0x7A, 0x31, 0xe5, 0x7A, 0x7A}; static uint8_t cmd33[] = {0x69, 0x04, 0x22, 0x14, 0x22, 0x14, 0x22, 0x08}; static uint8_t cmd34[] = {0x6B, 0x07}; static uint8_t cmd35[] = {0x7A, 0x08, 0x13}; static uint8_t cmd36[] = {0x7B, 0x08, 0x13}; -static uint8_t cmd37[] = {0xD1, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF}; -static uint8_t cmd38[] = {0xD2, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF}; -static uint8_t cmd39[] = {0xD3, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF}; -static uint8_t cmd40[] = {0xD4, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF}; -static uint8_t cmd41[] = {0xD5, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF}; -static uint8_t cmd42[] = {0xD6, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF}; +static uint8_t cmd37[] = {0xD1, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, + 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, + 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, + 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, + 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF}; +static uint8_t cmd38[] = {0xD2, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, + 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, + 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, + 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, + 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF}; +static uint8_t cmd39[] = {0xD3, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, + 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, + 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, + 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, + 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF}; +static uint8_t cmd40[] = {0xD4, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, + 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, + 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, + 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, + 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF}; +static uint8_t cmd41[] = {0xD5, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, + 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, + 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, + 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, + 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF}; +static uint8_t cmd42[] = {0xD6, 0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18, 0x00, 0x21, + 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47, 0x00, 0x56, 0x00, 0x90, 0x00, + 0xe5, 0x01, 0x68, 0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6, + 0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba, 0x03, 0xc5, 0x03, + 0xd0, 0x03, 0xE0, 0x03, 0xea, 0x03, 0xFa, 0x03, 0xFF}; static uint8_t cmd43[] = {0x11}; static uint8_t cmd44[] = {0x29}; static uint8_t cmd45[] = {0x28}; @@ -232,30 +263,30 @@ static void PanelPowerControl(bool on) hal_iomux_init(&priv.pin_rst, 1); hal_iomux_init(&priv.pin_te, 1); hal_gpio_pin_set_dir(priv.pin_rst.pin, HAL_GPIO_DIR_OUT, 1); - osDelay(10); + osDelay(10); // delay 10 ms hal_gpio_pin_clr(priv.pin_rst.pin); - osDelay(10); + osDelay(10); // delay 10 ms hal_gpio_pin_set(priv.pin_rst.pin); - osDelay(10); + osDelay(10); // delay 10 ms } else { - osDelay(20); + osDelay(20); // delay 20 ms hal_gpio_pin_clr(priv.pin_rst.pin); - osDelay(120); + osDelay(120); // delay 120 ms hal_gpio_pin_clr(priv.pin_led.pin); } } static int32_t PanelReadId() { - uint8_t read_id[3] = {0}; + uint8_t read_id[3] = {0}; // 3 uint8_t payload[] = {0x04}; struct DsiCmdDesc cmd = {0x06, 0, sizeof(payload), payload}; - int32_t ret = MipiDsiRx(priv.mipiHandle, &cmd, 3, read_id); + int32_t ret = MipiDsiRx(priv.mipiHandle, &cmd, 3, read_id); // 3 if (ret != HDF_SUCCESS) { HDF_LOGE("%s: MipiDsiRx failed", __func__); return HDF_FAILURE; } - HDF_LOGI("%s: read id %02X-%02X-%02X", __func__, read_id[0], read_id[1], read_id[2]); + HDF_LOGI("%s: read id %02X-%02X-%02X", __func__, read_id[0], read_id[1], read_id[2]); // 2 return HDF_SUCCESS; } #define DSI_INIT_DELAY 100 @@ -304,7 +335,7 @@ static int32_t PanelOn(struct PanelData *panel) MipiDsiSetHsMode(priv.mipiHandle); PanelCheckStatus(panel); hal_gpio_pin_set_dir(priv.pin_led.pin, HAL_GPIO_DIR_OUT, 1); - osDelay(20); + osDelay(20); // delay 20 ms return HDF_SUCCESS; } diff --git a/bes2600/liteos_m/components/drivers/display/hal/panel/icna3311.c b/bes2600/liteos_m/components/drivers/peripheral/display/hal/panel/icna3311.c old mode 100644 new mode 100755 similarity index 93% rename from bes2600/liteos_m/components/drivers/display/hal/panel/icna3311.c rename to bes2600/liteos_m/components/drivers/peripheral/display/hal/panel/icna3311.c index 2c8158335adff838b311c1919865ab7868a367a3..7c436b7b41425ed91da88aeca5abebd1cbbd8b00 --- a/bes2600/liteos_m/components/drivers/display/hal/panel/icna3311.c +++ b/bes2600/liteos_m/components/drivers/peripheral/display/hal/panel/icna3311.c @@ -46,14 +46,14 @@ static struct DsiCmdDesc g_OnCmd[] = { {0x15, 0, sizeof(g_payLoad5), g_payLoad5}, {0x39, 0, sizeof(g_payLoad6), g_payLoad6}, {0x39, 0, sizeof(g_payLoad7), g_payLoad7}, - {0x05, 120, sizeof(g_payLoad8), g_payLoad8}, - {0x05, 120, sizeof(g_payLoad9), g_payLoad9}, + {0x05, 120, sizeof(g_payLoad8), g_payLoad8}, // 120 + {0x05, 120, sizeof(g_payLoad9), g_payLoad9}, // 120 }; static struct DsiCmdDesc g_offCmd[] = { {0x15, 0, sizeof(g_payLoad0), g_payLoad0}, - {0x05, 20, sizeof(g_payLoad10), g_payLoad10}, - {0x05, 120, sizeof(g_payLoad11), g_payLoad11}, + {0x05, 20, sizeof(g_payLoad10), g_payLoad10}, // 20 + {0x05, 120, sizeof(g_payLoad11), g_payLoad11}, // 120 }; struct PanelDevice { @@ -69,13 +69,13 @@ static struct PanelDevice priv = { .panelInfo = { .width = WIDTH, .height = HEIGHT, - .hbp = 8, - .hfp = 8, - .hsw = 2, - .vbp = 8, - .vfp = 8, - .vsw = 2, - .frameRate = 60, + .hbp = 8, // 8 + .hfp = 8, // 8 + .hsw = 2, // 2 + .vbp = 8, // 8 + .vfp = 8, // 8 + .vsw = 2, // 2 + .frameRate = 60, // 60 .intfType = MIPI_DSI, .intfSync = OUTPUT_USER, .mipi = {DSI_1_LANES, DSI_CMD_MODE, VIDEO_BURST_MODE, FORMAT_RGB_24_BIT}, @@ -146,13 +146,13 @@ static void PanelPowerControl(bool on) hal_gpio_pin_set_dir(priv.pin_rst.pin, HAL_GPIO_DIR_OUT, 0); hal_gpio_pin_set_dir(priv.pin_vci.pin, HAL_GPIO_DIR_OUT, 0); hal_gpio_pin_set(priv.pin_vci.pin); - osDelay(20); + osDelay(20); // delay 20 ms hal_gpio_pin_set(priv.pin_rst.pin); - osDelay(20); + osDelay(20); // delay 20 ms } else { - osDelay(120); + osDelay(120); // delay 120 ms hal_gpio_pin_clr(priv.pin_rst.pin); - osDelay(20); + osDelay(20); // delay 20 ms hal_gpio_pin_clr(priv.pin_vci.pin); } } diff --git a/bes2600/liteos_m/components/drivers/display/hal/panel/ili9488.c b/bes2600/liteos_m/components/drivers/peripheral/display/hal/panel/ili9488.c old mode 100644 new mode 100755 similarity index 95% rename from bes2600/liteos_m/components/drivers/display/hal/panel/ili9488.c rename to bes2600/liteos_m/components/drivers/peripheral/display/hal/panel/ili9488.c index 3d88742f83c8d3f03b38f4801cd0bad42f1a521b..49bd76dc011bff1b182f74024f83bbeb81de58e7 --- a/bes2600/liteos_m/components/drivers/display/hal/panel/ili9488.c +++ b/bes2600/liteos_m/components/drivers/peripheral/display/hal/panel/ili9488.c @@ -34,8 +34,10 @@ static void PanelPowerControl(bool on); static int32_t PanelCheckStatus(struct PanelData *panel); static int32_t PanelReadId(); -static uint8_t cmd0[] = {0xE0, 0x00, 0x13, 0x18, 0x04, 0x0F, 0x06, 0x3A, 0x56, 0x4D, 0x03, 0x0A, 0x06, 0x30, 0x3E, 0x0F}; -static uint8_t cmd1[] = {0xE1, 0x00, 0x13, 0x18, 0x01, 0x11, 0x06, 0x38, 0x34, 0x4D, 0x06, 0x0D, 0x0B, 0x31, 0x37, 0x0F}; +static uint8_t cmd0[] = {0xE0, 0x00, 0x13, 0x18, 0x04, 0x0F, 0x06, 0x3A, 0x56, + 0x4D, 0x03, 0x0A, 0x06, 0x30, 0x3E, 0x0F}; +static uint8_t cmd1[] = {0xE1, 0x00, 0x13, 0x18, 0x01, 0x11, 0x06, 0x38, 0x34, + 0x4D, 0x06, 0x0D, 0x0B, 0x31, 0x37, 0x0F}; static uint8_t cmd2[] = {0x35, 0x00}; static uint8_t cmd3[] = {0XC0, 0x18, 0x17}; // Power Control 1 static uint8_t cmd4[] = {0xC1, 0x41}; // Power Control 2 @@ -70,13 +72,13 @@ static struct DsiCmdDesc g_OnCmd[] = { {0x15, 0, sizeof(cmd12), cmd12}, {0x39, 0, sizeof(cmd13), cmd13}, {0x05, 0, sizeof(cmd14), cmd14}, - {0x05, 150, sizeof(cmd15), cmd15}, - {0x05, 50, sizeof(cmd16), cmd16}, + {0x05, 150, sizeof(cmd15), cmd15}, // 150 + {0x05, 50, sizeof(cmd16), cmd16}, // 50 }; struct DsiCmdDesc g_offCmd[] = { - {0x05, 150, sizeof(cmd17), cmd17}, - {0x05, 50, sizeof(cmd18), cmd18}, + {0x05, 150, sizeof(cmd17), cmd17}, // 150 + {0x05, 50, sizeof(cmd18), cmd18}, // 50 }; struct PanelDevice { @@ -176,15 +178,15 @@ static void PanelPowerControl(bool on) hal_iomux_init(&priv.pin_rst, 1); hal_iomux_init(&priv.pin_te, 1); hal_gpio_pin_set_dir(priv.pin_rst.pin, HAL_GPIO_DIR_OUT, 1); - osDelay(10); + osDelay(10); // delay 10 ms hal_gpio_pin_clr(priv.pin_rst.pin); - osDelay(50); + osDelay(50); // delay 50 ms hal_gpio_pin_set(priv.pin_rst.pin); - osDelay(150); + osDelay(150); // delay 150 ms } else { - osDelay(50); + osDelay(50); // delay 50 ms hal_gpio_pin_clr(priv.pin_rst.pin); - osDelay(150); + osDelay(150); // delay 150 ms hal_gpio_pin_clr(priv.pin_led.pin); } } @@ -199,7 +201,7 @@ static int32_t PanelReadId() HDF_LOGE("%s: MipiDsiRx failed", __func__); return HDF_FAILURE; } - HDF_LOGI("%s: read id %02X-%02X-%02X", __func__, read_id[0], read_id[1], read_id[2]); + HDF_LOGI("%s: read id %02X-%02X-%02X", __func__, read_id[0], read_id[1], read_id[2]); // 2 return HDF_SUCCESS; } #define DSI_INIT_DELAY 100 @@ -248,7 +250,7 @@ static int32_t PanelOn(struct PanelData *panel) MipiDsiSetHsMode(priv.mipiHandle); PanelCheckStatus(panel); hal_gpio_pin_set_dir(priv.pin_led.pin, HAL_GPIO_DIR_OUT, 1); - osDelay(100); + osDelay(100); // delay 100 ms return HDF_SUCCESS; } diff --git a/bes2600/liteos_m/components/drivers/display/hal/panel/rm69330.c b/bes2600/liteos_m/components/drivers/peripheral/display/hal/panel/rm69330.c old mode 100644 new mode 100755 similarity index 99% rename from bes2600/liteos_m/components/drivers/display/hal/panel/rm69330.c rename to bes2600/liteos_m/components/drivers/peripheral/display/hal/panel/rm69330.c index 0b4cefc5b5a300729879b3fbae86577d2ed7619c..9efa0373f338c5131d5e9563ac2e95035aa10d84 --- a/bes2600/liteos_m/components/drivers/display/hal/panel/rm69330.c +++ b/bes2600/liteos_m/components/drivers/peripheral/display/hal/panel/rm69330.c @@ -126,9 +126,9 @@ static void PanelPowerControl(bool on) hal_iomux_init(&priv.pin_rst, 1); hal_iomux_init(&priv.pin_te, 1); hal_gpio_pin_set_dir(priv.pin_rst.pin, HAL_GPIO_DIR_OUT, 0); - osDelay(20); + osDelay(20); // delay 20 ms hal_gpio_pin_set(priv.pin_rst.pin); - osDelay(20); + osDelay(20); // delay 20 ms } } diff --git a/bes2600/liteos_m/components/drivers/display/hdi/BUILD.gn b/bes2600/liteos_m/components/drivers/peripheral/display/hdi/BUILD.gn similarity index 100% rename from bes2600/liteos_m/components/drivers/display/hdi/BUILD.gn rename to bes2600/liteos_m/components/drivers/peripheral/display/hdi/BUILD.gn diff --git a/bes2600/liteos_m/components/drivers/display/hdi/display_gfx.c b/bes2600/liteos_m/components/drivers/peripheral/display/hdi/display_gfx.c similarity index 100% rename from bes2600/liteos_m/components/drivers/display/hdi/display_gfx.c rename to bes2600/liteos_m/components/drivers/peripheral/display/hdi/display_gfx.c diff --git a/bes2600/liteos_m/components/drivers/display/hdi/display_gralloc.c b/bes2600/liteos_m/components/drivers/peripheral/display/hdi/display_gralloc.c similarity index 100% rename from bes2600/liteos_m/components/drivers/display/hdi/display_gralloc.c rename to bes2600/liteos_m/components/drivers/peripheral/display/hdi/display_gralloc.c diff --git a/bes2600/liteos_m/components/drivers/display/hdi/display_layer.c b/bes2600/liteos_m/components/drivers/peripheral/display/hdi/display_layer.c old mode 100644 new mode 100755 similarity index 100% rename from bes2600/liteos_m/components/drivers/display/hdi/display_layer.c rename to bes2600/liteos_m/components/drivers/peripheral/display/hdi/display_layer.c index 990f581e6b635894bfcfc1c1b46f176d349db6cb..d5bdb66dc8c0ff63850087a3b8e25645959ae7f1 --- a/bes2600/liteos_m/components/drivers/display/hdi/display_layer.c +++ b/bes2600/liteos_m/components/drivers/peripheral/display/hdi/display_layer.c @@ -13,10 +13,10 @@ * limitations under the License. */ #include -#include "display_layer.h" #include "disp_hal.h" #include "display_type.h" #include "hdf_log.h" +#include "display_layer.h" #define DEV_ID 0 #define LAYER_ID 0 diff --git a/bes2600/liteos_m/components/drivers/touch/BUILD.gn b/bes2600/liteos_m/components/drivers/peripheral/touch/BUILD.gn similarity index 100% rename from bes2600/liteos_m/components/drivers/touch/BUILD.gn rename to bes2600/liteos_m/components/drivers/peripheral/touch/BUILD.gn diff --git a/bes2600/liteos_m/components/drivers/touch/include/touch_if.h b/bes2600/liteos_m/components/drivers/peripheral/touch/include/touch_if.h similarity index 100% rename from bes2600/liteos_m/components/drivers/touch/include/touch_if.h rename to bes2600/liteos_m/components/drivers/peripheral/touch/include/touch_if.h diff --git a/bes2600/liteos_m/components/drivers/touch/touch.c b/bes2600/liteos_m/components/drivers/peripheral/touch/touch.c similarity index 99% rename from bes2600/liteos_m/components/drivers/touch/touch.c rename to bes2600/liteos_m/components/drivers/peripheral/touch/touch.c index 783004c5fc1161cd30b30700f408ef81b184cda6..b389a5ac4f065292240f2b7ba92e2d7030a7cf22 100755 --- a/bes2600/liteos_m/components/drivers/touch/touch.c +++ b/bes2600/liteos_m/components/drivers/peripheral/touch/touch.c @@ -103,7 +103,7 @@ DevHandle TouchOpen(int id) } osThreadAttr_t attr = {0}; - attr.stack_size = 2048; + attr.stack_size = 2048; // 2048 attr.priority = osPriorityNormal; attr.name = dev->name; dev->tid = osThreadNew((osThreadFunc_t)touch_task, dev, &attr); diff --git a/bes2600/liteos_m/components/drivers/touch/touch.h b/bes2600/liteos_m/components/drivers/peripheral/touch/touch.h similarity index 100% rename from bes2600/liteos_m/components/drivers/touch/touch.h rename to bes2600/liteos_m/components/drivers/peripheral/touch/touch.h diff --git a/bes2600/liteos_m/components/drivers/touch/touch_fts.c b/bes2600/liteos_m/components/drivers/peripheral/touch/touch_fts.c old mode 100644 new mode 100755 similarity index 89% rename from bes2600/liteos_m/components/drivers/touch/touch_fts.c rename to bes2600/liteos_m/components/drivers/peripheral/touch/touch_fts.c index fa9073ee114aa753d74d7e486fa24f68e494a611..9e6e6e5b92942d7784f35008f6799e8131acf4f0 --- a/bes2600/liteos_m/components/drivers/touch/touch_fts.c +++ b/bes2600/liteos_m/components/drivers/peripheral/touch/touch_fts.c @@ -35,10 +35,10 @@ struct tpd_priv { static struct tpd_priv priv = { .gpio_rst = 5, // TSP_RST - GPIO05 - .gpio_int = 23, // TSP_INT - GPIO27 + .gpio_int = 23, // TSP_INT - GPIO23 .i2c_client = { .id = 1, // TSP_SCL/SDA - I2C1 = GPIO06/GPIO07 - .addr = 0x38, + .addr = 0x38, // i2c address 0x38 }}; /***************************************************************************** @@ -72,11 +72,12 @@ static int fts_i2c_read(struct i2c_client *client, uint8_t *writebuf, int writel }, }; for (i = 0; i < I2C_RETRY_NUMBER; i++) { - ret = I2cTransfer(client->handle, msgs, 2); + ret = I2cTransfer(client->handle, msgs, 2); // 2 msg if (ret < 0) { HDF_LOGE("[IIC]: i2c_transfer(write) error, ret=%d!!", ret); - } else + } else { break; + } } } else { struct I2cMsg msgs[] = { @@ -91,8 +92,9 @@ static int fts_i2c_read(struct i2c_client *client, uint8_t *writebuf, int writel ret = I2cTransfer(client->handle, msgs, 1); if (ret < 0) { HDF_LOGE("[IIC]: i2c_transfer(read) error, ret=%d!!", ret); - } else + } else { break; + } } } } @@ -123,8 +125,9 @@ static int fts_i2c_write(struct i2c_client *client, uint8_t *writebuf, int write ret = I2cTransfer(client->handle, msgs, 1); if (ret < 0) { HDF_LOGE("[IIC]: i2c_transfer(write) error, ret=%d!!", ret); - } else + } else { break; + } } } @@ -133,7 +136,7 @@ static int fts_i2c_write(struct i2c_client *client, uint8_t *writebuf, int write static int fts_i2c_write_reg(struct i2c_client *client, uint8_t regaddr, uint8_t regvalue) { - uint8_t buf[2] = {0}; + uint8_t buf[2] = {0}; // 2 Byte buf[0] = regaddr; buf[1] = regvalue; @@ -148,18 +151,18 @@ static int fts_i2c_read_reg(struct i2c_client *client, uint8_t regaddr, uint8_t static void fts_i2c_hid2std(struct i2c_client *client) { int ret = 0; - uint8_t buf[3] = {0xeb, 0xaa, 0x09}; + uint8_t buf[3] = {0xeb, 0xaa, 0x09}; // 3 byte - ret = fts_i2c_write(client, buf, 3); - if (ret < 0) + ret = fts_i2c_write(client, buf, 3); // 3 byte + if (ret < 0) { HDF_LOGE("hid2std cmd write fail"); - else { - osDelay(10); - buf[0] = buf[1] = buf[2] = 0; - ret = fts_i2c_read(client, NULL, 0, buf, 3); - if (ret < 0) + } else { + osDelay(10); // delay 10ms + buf[0] = buf[1] = buf[2] = 0; // 2 byte + ret = fts_i2c_read(client, NULL, 0, buf, 3); // 3 byte + if (ret < 0) { HDF_LOGE("hid2std cmd read fail"); - else if ((0xeb == buf[0]) && (0xaa == buf[1]) && (0x08 == buf[2])) { + } else if ((0xeb == buf[0]) && (0xaa == buf[1]) && (0x08 == buf[2])) { // 2 HDF_LOGE("hidi2c change to stdi2c successful"); } else { HDF_LOGE("hidi2c change to stdi2c fail"); @@ -190,11 +193,15 @@ static int fts_get_chip_types(struct fts_ts_data *ts_data, uint8_t id_h, uint8_t HDF_LOGI("verify id:0x%02x%02x", id_h, id_l); for (i = 0; i < ctype_entries; i++) { if (VALID == fw_valid) { - if ((id_h == ctype[i].chip_idh) && (id_l == ctype[i].chip_idl)) + if ((id_h == ctype[i].chip_idh) && (id_l == ctype[i].chip_idl)) { break; + } } else { - if (((id_h == ctype[i].rom_idh) && (id_l == ctype[i].rom_idl)) || ((id_h == ctype[i].pb_idh) && (id_l == ctype[i].pb_idl)) || ((id_h == ctype[i].bl_idh) && (id_l == ctype[i].bl_idl))) + if (((id_h == ctype[i].rom_idh) && (id_l == ctype[i].rom_idl)) + || ((id_h == ctype[i].pb_idh) && (id_l == ctype[i].pb_idl)) + || ((id_h == ctype[i].bl_idh) && (id_l == ctype[i].bl_idl))) { break; + } } } @@ -210,8 +217,8 @@ static int fts_get_ic_information(struct fts_ts_data *ts_data) { int ret = 0; int cnt = 0; - uint8_t chip_id[2] = {0}; - uint8_t id_cmd[4] = {0}; + uint8_t chip_id[2] = {0}; // 2 + uint8_t id_cmd[4] = {0}; // 4 uint32_t id_cmd_len = 0; struct i2c_client *client = ts_data->client; @@ -224,10 +231,11 @@ static int fts_get_ic_information(struct fts_ts_data *ts_data) HDF_LOGD("i2c read invalid, read:0x%02x%02x", chip_id[0], chip_id[1]); } else { ret = fts_get_chip_types(ts_data, chip_id[0], chip_id[1], VALID); - if (!ret) + if (!ret) { break; - else + } else { HDF_LOGD("TP not ready, read:0x%02x%02x", chip_id[0], chip_id[1]); + } } cnt++; @@ -242,7 +250,7 @@ static int fts_get_ic_information(struct fts_ts_data *ts_data) id_cmd[0] = FTS_CMD_START1; id_cmd[1] = FTS_CMD_START2; - ret = fts_i2c_write(client, id_cmd, 2); + ret = fts_i2c_write(client, id_cmd, 2); // 2 byte if (ret < 0) { HDF_LOGE("start cmd write fail"); return ret; @@ -250,12 +258,13 @@ static int fts_get_ic_information(struct fts_ts_data *ts_data) osDelay(FTS_CMD_START_DELAY); id_cmd[0] = FTS_CMD_READ_ID; - id_cmd[1] = id_cmd[2] = id_cmd[3] = 0x00; - if (ts_data->ic_info.is_incell) + id_cmd[1] = id_cmd[2] = id_cmd[3] = 0x00; // 2 3 + if (ts_data->ic_info.is_incell) { id_cmd_len = FTS_CMD_READ_ID_LEN_INCELL; - else + } else { id_cmd_len = FTS_CMD_READ_ID_LEN; - ret = fts_i2c_read(client, id_cmd, id_cmd_len, chip_id, 2); + } + ret = fts_i2c_read(client, id_cmd, id_cmd_len, chip_id, 2); // 2 byte if ((ret < 0) || (0x0 == chip_id[0]) || (0x0 == chip_id[1])) { HDF_LOGE("read boot id fail"); return -EIO; @@ -276,7 +285,7 @@ static int fts_get_ic_information(struct fts_ts_data *ts_data) static int fts_reset_proc(int hdelayms) { GpioWrite(priv.gpio_rst, 0); - osDelay(5); + osDelay(5); // delay 5ms GpioWrite(priv.gpio_rst, 1); if (hdelayms) { osDelay(hdelayms); @@ -308,8 +317,8 @@ static int fts_read_touchdata(struct fts_ts_data *data) data->point_num = buf[FTS_TOUCH_POINT_NUM] & 0x0F; if (data->ic_info.is_incell) { - if ((data->point_num == 0x0F) && (buf[1] == 0xFF) && (buf[2] == 0xFF) && (buf[3] == 0xFF) && - (buf[4] == 0xFF) && (buf[5] == 0xFF) && (buf[6] == 0xFF)) { + if ((data->point_num == 0x0F) && (buf[1] == 0xFF) && (buf[2] == 0xFF) && (buf[3] == 0xFF) && // 2 3 + (buf[4] == 0xFF) && (buf[5] == 0xFF) && (buf[6] == 0xFF)) { // 4 5 6 HDF_LOGI("touch buff is 0xff, need recovery state"); return -EIO; } @@ -322,23 +331,23 @@ static int fts_read_touchdata(struct fts_ts_data *data) for (i = 0; i < max_touch_num; i++) { base = FTS_ONE_TCH_LEN * i; - pointid = (buf[FTS_TOUCH_ID_POS + base]) >> 4; - if (pointid >= FTS_MAX_ID) + pointid = (buf[FTS_TOUCH_ID_POS + base]) >> 4; // 4 bit + if (pointid >= FTS_MAX_ID) { break; - else if (pointid >= max_touch_num) { + } else if (pointid >= max_touch_num) { HDF_LOGE("ID(%d) beyond max_touch_number", pointid); return -EINVAL; } data->touch_point++; - events[i].x = ((buf[FTS_TOUCH_X_H_POS + base] & 0x0F) << 8) + + events[i].x = ((buf[FTS_TOUCH_X_H_POS + base] & 0x0F) << 8) + // 8 bite (buf[FTS_TOUCH_X_L_POS + base] & 0xFF); - events[i].y = ((buf[FTS_TOUCH_Y_H_POS + base] & 0x0F) << 8) + + events[i].y = ((buf[FTS_TOUCH_Y_H_POS + base] & 0x0F) << 8) + // 8 bite (buf[FTS_TOUCH_Y_L_POS + base] & 0xFF); - events[i].flag = buf[FTS_TOUCH_EVENT_POS + base] >> 6; - events[i].id = buf[FTS_TOUCH_ID_POS + base] >> 4; - events[i].area = buf[FTS_TOUCH_AREA_POS + base] >> 4; + events[i].flag = buf[FTS_TOUCH_EVENT_POS + base] >> 6; // 6 bite + events[i].id = buf[FTS_TOUCH_ID_POS + base] >> 4; // 4 bite + events[i].area = buf[FTS_TOUCH_AREA_POS + base] >> 4; // 4 bite events[i].p = buf[FTS_TOUCH_PRE_POS + base]; if (EVENT_DOWN(events[i].flag) && (data->point_num == 0)) { @@ -369,7 +378,7 @@ static int fts_input_init(struct fts_ts_data *ts_data) int ret = 0; point_num = FTS_TOUCH_POINT_NUM; - ts_data->pnt_buf_size = point_num * FTS_ONE_TCH_LEN + 3; + ts_data->pnt_buf_size = point_num * FTS_ONE_TCH_LEN + 3; // 3 bite ts_data->point_buf = (uint8_t *)malloc(ts_data->pnt_buf_size); if (!ts_data->point_buf) { HDF_LOGE("failed to alloc memory for point buf!"); @@ -421,7 +430,7 @@ static int tpd_probe(struct i2c_client *client) goto err_input_init; } - fts_reset_proc(200); + fts_reset_proc(200); // 200 ret = fts_get_ic_information(ts_data); if (ret) { HDF_LOGE("not focal IC, unregister driver"); @@ -449,13 +458,15 @@ err_input_init: return ret; } -static int tpd_remove() +static int tpd_remove(struct i2c_client *client) { + (void)client; if (fts_data) { free(fts_data->point_buf); free(fts_data->events); free(fts_data); } + fts_data = NULL; return 0; } @@ -479,12 +490,12 @@ static int tpd_get_point(struct touch_device *dev, struct touch_msg *msg) static int tpd_interrupt_handler(uint16_t gpio, void *arg) { (void)arg; - if (gpio != priv.gpio_int) + if (gpio != priv.gpio_int) { return -1; - - if (priv.dev && priv.dev->sem) + } + if (priv.dev && priv.dev->sem) { osSemaphoreRelease(priv.dev->sem); - + } return 0; } diff --git a/bes2600/liteos_m/components/drivers/touch/touch_fts.h b/bes2600/liteos_m/components/drivers/peripheral/touch/touch_fts.h old mode 100644 new mode 100755 similarity index 88% rename from bes2600/liteos_m/components/drivers/touch/touch_fts.h rename to bes2600/liteos_m/components/drivers/peripheral/touch/touch_fts.h index fc047a84fc1c9cac7001d555220e85ebff2c4505..e47aa2fd20fbaa8ae345b0fd9631b15aeadb92c7 --- a/bes2600/liteos_m/components/drivers/touch/touch_fts.h +++ b/bes2600/liteos_m/components/drivers/peripheral/touch/touch_fts.h @@ -17,7 +17,7 @@ #include "touch.h" -#define FTS_CHIP_TYPE 0x6336D003 //_FT6336U +#define FTS_CHIP_TYPE 0x6336D003 // _FT6336U #define FLAGBIT(x) (0x00000001 << (x)) #define FLAGBITS(x, y) ((0xFFFFFFFF >> (32 - (y)-1)) << (x)) @@ -27,7 +27,7 @@ #define FTS_CHIP_IDC ((FTS_CHIP_TYPE & FLAGBIT(FLAG_IDC_BIT)) == FLAGBIT(FLAG_IDC_BIT)) #define FTS_HID_SUPPORTTED ((FTS_CHIP_TYPE & FLAGBIT(FLAG_HID_BIT)) == FLAGBIT(FLAG_HID_BIT)) -#define FTS_CHIP_TYPE_MAPPING {{0x03,0x64, 0x26, 0x64, 0x26, 0x00, 0x00, 0x79, 0x1C}} +#define FTS_CHIP_TYPE_MAPPING {{0x03, 0x64, 0x26, 0x64, 0x26, 0x00, 0x00, 0x79, 0x1C}} #define I2C_BUFFER_LENGTH_MAXINUM 256 #define FILE_NAME_LENGTH 128 @@ -41,7 +41,7 @@ #define FTS_CMD_READ_ID 0x90 #define FTS_CMD_READ_ID_LEN 4 #define FTS_CMD_READ_ID_LEN_INCELL 1 -/*register address*/ +/* register address */ #define FTS_REG_INT_CNT 0x8F #define FTS_REG_FLOW_WORK_CNT 0x91 #define FTS_REG_WORKMODE 0x00 @@ -92,11 +92,11 @@ #define FTS_TOUCH_DOWN 0 #define FTS_TOUCH_UP 1 #define FTS_TOUCH_CONTACT 2 -#define EVENT_DOWN(flag) ((FTS_TOUCH_DOWN == flag) || (FTS_TOUCH_CONTACT == flag)) -#define EVENT_UP(flag) (FTS_TOUCH_UP == flag) -#define EVENT_NO_DOWN(data) (!data->point_num) -#define KEY_EN 0 //(tpd_dts_data.use_tpd_button) -#define TOUCH_IS_KEY(y, key_y) (y > key_y) +#define EVENT_DOWN(flag) ((FTS_TOUCH_DOWN == (flag)) || (FTS_TOUCH_CONTACT == (flag))) +#define EVENT_UP(flag) (FTS_TOUCH_UP == (flag)) +#define EVENT_NO_DOWN(data) (!(data)->point_num) +#define KEY_EN 0 // (tpd_dts_data.use_tpd_button) +#define TOUCH_IS_KEY(y, key_y) ((y) > (key_y)) #ifndef RTPM_PRIO_TPD #define RTPM_PRIO_TPD 0x04 @@ -131,13 +131,13 @@ struct ts_ic_info { struct ft_chip_t ids; }; -/*touch event info*/ +/* touch event info */ struct ts_event { - int x; /*x coordinate */ - int y; /*y coordinate */ + int x; /* x coordinate */ + int y; /* y coordinate */ int p; /* pressure */ int flag; /* touch event flag: 0 -- down; 1-- up; 2 -- contact */ - int id; /*touch ID */ + int id; /* touch ID */ int area; }; struct fts_ts_data { diff --git a/bes2600/liteos_m/components/drivers/touch/touch_ztw523.c b/bes2600/liteos_m/components/drivers/peripheral/touch/touch_ztw523.c old mode 100644 new mode 100755 similarity index 93% rename from bes2600/liteos_m/components/drivers/touch/touch_ztw523.c rename to bes2600/liteos_m/components/drivers/peripheral/touch/touch_ztw523.c index 660969a0ff624b2285891bab27469d3a5d9b9fa2..b269d906be84b5531de7f7b40fc4d8ec1ad539aa --- a/bes2600/liteos_m/components/drivers/touch/touch_ztw523.c +++ b/bes2600/liteos_m/components/drivers/peripheral/touch/touch_ztw523.c @@ -90,9 +90,10 @@ static int ztw_read(struct ztw_priv *priv, uint16_t reg_addr, void *buffer, uint }; while (retries < IIC_RETRY_NUM) { - ret = I2cTransfer(priv->i2c, msgs, 2); - if (ret == 2) + ret = I2cTransfer(priv->i2c, msgs, 2); // 2 + if (ret == 2) { // 2 break; + } retries++; DelayMs(1); } @@ -101,20 +102,20 @@ static int ztw_read(struct ztw_priv *priv, uint16_t reg_addr, void *buffer, uint LOG_E("i2c transfer failed ret %d", ret); return -1; } - return (ret == 2) ? 0 : -1; + return (ret == 2) ? 0 : -1; // 2 } static int ztw_write(struct ztw_priv *priv, uint16_t reg_addr, const void *buffer, uint16_t length) { - uint8_t send_buffer[length + 2]; + uint8_t send_buffer[length + 2]; // 2 send_buffer[0] = reg_addr & 0xff; - send_buffer[1] = (reg_addr >> 8) & 0xff; - memcpy(&send_buffer[2], buffer, length); + send_buffer[1] = (reg_addr >> 8) & 0xff; // 8 bits + memcpy(&send_buffer[2], buffer, length); // 2 struct I2cMsg msg = { .addr = priv->i2c_addr, .flags = 0, - .len = length + 2, + .len = length + 2, // 2 .buf = send_buffer, }; @@ -124,12 +125,12 @@ static int ztw_write(struct ztw_priv *priv, uint16_t reg_addr, const void *buffe static int ztw_write_reg(struct ztw_priv *priv, uint16_t reg_addr, uint16_t data) { - return ztw_write(priv, reg_addr, (uint8_t *)&data, 2); + return ztw_write(priv, reg_addr, (uint8_t *)&data, 2); // 2 Byte } static int ztw_read_reg(struct ztw_priv *priv, uint16_t reg_addr, uint16_t *data) { - return ztw_read(priv, reg_addr, (uint8_t *)data, 2); + return ztw_read(priv, reg_addr, (uint8_t *)data, 2); // 2 Byte } static int ztw_write_cmd(struct ztw_priv *priv, uint16_t cmd) @@ -188,9 +189,9 @@ static void ztw_reset(struct ztw_priv *priv, bool enable) if (enable) { DelayMs(1); GpioWrite(priv->gpio_rst, 1); - DelayMs(10); + DelayMs(10); // delay 10 ms GpioWrite(priv->gpio_rst, 0); - DelayMs(100); + DelayMs(100); // delay 100 ms GpioWrite(priv->gpio_rst, 1); DelayMs(CHIP_ON_DELAY); } else { @@ -206,26 +207,26 @@ static int ztw_power_sequence(struct ztw_priv *priv) LOG_E("power sequence error (vendor cmd enable)"); return -1; } - DelayUs(10); + DelayUs(10); // delay 10 us if (ztw_read_reg(priv, ZINITIX_CHIP_ID_REG, &chip_code) != 0) { LOG_E("fail to read chip code"); return -1; } LOG_I("chip code = 0x%x", chip_code); - DelayUs(10); + DelayUs(10); // delay 10 us if (ztw_write_cmd(priv, ZINITIX_INTN_CLEAR_CMD) != 0) { LOG_E("power sequence error (int clear)"); return -1; } - DelayUs(10); + DelayUs(10); // delay 10 us if (ztw_write_reg(priv, ZINITIX_NVM_REG, 0x0001) != 0) { LOG_E("power sequence error (nvm init)"); return -1; } - DelayMs(2); + DelayMs(2); // delay 2 ms if (ztw_write_reg(priv, ZINITIX_PROGRAM_START_CMD, 0x0001) != 0) { LOG_E("power sequence error (program start)"); @@ -273,18 +274,16 @@ static int ztw_init(struct touch_device *dev) } uint8_t i; - for (i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { // 10 if (ztw_write_cmd(&priv, ZINITIX_SWRESET_CMD) == 0) break; - DelayMs(10); + DelayMs(10); // delay 10 ms } uint16_t reg_val = 0; zinitix_bit_set(reg_val, BIT_PT_CNT_CHANGE); zinitix_bit_set(reg_val, BIT_DOWN); zinitix_bit_set(reg_val, BIT_MOVE); zinitix_bit_set(reg_val, BIT_UP); - // zinitix_bit_set(reg_val, BIT_PALM); - // zinitix_bit_set(reg_val, BIT_PT_EXIST); uint16_t eeprom_info; if (ztw_read_reg(&priv, ZINITIX_EEPROM_INFO, &eeprom_info) != 0) { @@ -301,9 +300,9 @@ static int ztw_init(struct touch_device *dev) ztw_write_reg(&priv, ZINITIX_TOUCH_MODE, TOUCH_POINT_MODE); ztw_write_reg(&priv, ZINITIX_INT_ENABLE_FLAG, reg_val); - for (i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { // 10 ztw_write_cmd(&priv, ZINITIX_CLEAR_INT_STATUS_CMD); - DelayUs(10); + DelayUs(10); // delay 10 us } return 0; } diff --git a/bes2600/liteos_m/components/drivers/touch/touch_ztw523.h b/bes2600/liteos_m/components/drivers/peripheral/touch/touch_ztw523.h similarity index 100% rename from bes2600/liteos_m/components/drivers/touch/touch_ztw523.h rename to bes2600/liteos_m/components/drivers/peripheral/touch/touch_ztw523.h diff --git a/bes2600/liteos_m/components/drivers/mipi_dsi/BUILD.gn b/bes2600/liteos_m/components/drivers/platform/mipi/BUILD.gn similarity index 100% rename from bes2600/liteos_m/components/drivers/mipi_dsi/BUILD.gn rename to bes2600/liteos_m/components/drivers/platform/mipi/BUILD.gn diff --git a/bes2600/liteos_m/components/drivers/mipi_dsi/mipi_dsi.c b/bes2600/liteos_m/components/drivers/platform/mipi/mipi_dsi.c similarity index 88% rename from bes2600/liteos_m/components/drivers/mipi_dsi/mipi_dsi.c rename to bes2600/liteos_m/components/drivers/platform/mipi/mipi_dsi.c index b83cf469a40510f99b4a6dd679db8c41211fa317..52061e2faa718d57eb72fab6265917a15e3c68df 100755 --- a/bes2600/liteos_m/components/drivers/mipi_dsi/mipi_dsi.c +++ b/bes2600/liteos_m/components/drivers/platform/mipi/mipi_dsi.c @@ -54,9 +54,9 @@ struct MipiDsiDevice { static struct MipiDsiDevice priv = { .buffers = { PSRAMUHS_BASE + PSRAMUHS_SIZE - BUFSIZE_MAX, - PSRAMUHS_BASE + PSRAMUHS_SIZE - BUFSIZE_MAX * 2, + PSRAMUHS_BASE + PSRAMUHS_SIZE - BUFSIZE_MAX * 2, // 2 #if (BUF_NUM == 3) - PSRAMUHS_BASE + PSRAMUHS_SIZE - BUFSIZE_MAX * 3, + PSRAMUHS_BASE + PSRAMUHS_SIZE - BUFSIZE_MAX * 3, // 3 #endif }, .buf_size = BUFSIZE_MAX, @@ -67,14 +67,14 @@ static struct MipiDsiDevice priv = { .cfg = { .active_width = WIDTH + 1, .active_height = HEIGHT + 1, - .h_front_porch = 13, - .h_back_porch = 13, - .v_front_porch = 13, - .v_back_porch = 13, - .total_width = WIDTH + 32, - .total_height = HEIGHT + 32, + .h_front_porch = 13, // 13 + .h_back_porch = 13, // 13 + .v_front_porch = 13, // 13 + .v_back_porch = 13, // 13 + .total_width = WIDTH + 32, // 32 + .total_height = HEIGHT + 32, // 32 - .g_mem_pitch = WIDTH * 4, + .g_mem_pitch = WIDTH * 4, // 4 .graphic_h_sa = 1, .graphic_v_sa = 1, .graphic_width = WIDTH, @@ -82,10 +82,10 @@ static struct MipiDsiDevice priv = { .zm_graphic_width = WIDTH, .zm_graphic_height = HEIGHT, - .cursor_h_sa = 90, - .cursor_v_sa = 90, - .cursor_width = 28, - .cursor_height = 28, + .cursor_h_sa = 90, // 90 + .cursor_v_sa = 90, // 90 + .cursor_width = 28, // 28 + .cursor_height = 28, // 28 .hwc_color1 = 0x0000ff, .hwc_color2 = 0x00ff00, @@ -131,7 +131,7 @@ static int32_t MipiDsiDevSetCntlrCfg(struct MipiDsiCntlr *cntlr) uint32_t dsi_pclk = cntlr->cfg.pixelClk; priv.cfg.active_width = cntlr->cfg.timing.xPixels; priv.cfg.active_height = cntlr->cfg.timing.ylines; - // FIXME + if (cntlr->cfg.mode == DSI_CMD_MODE) { priv.cfg.active_width += 1; priv.cfg.active_height += 1; @@ -146,7 +146,7 @@ static int32_t MipiDsiDevSetCntlrCfg(struct MipiDsiCntlr *cntlr) priv.cfg.total_height = cntlr->cfg.timing.ylines + cntlr->cfg.timing.vfpLines + cntlr->cfg.timing.vbpLines + cntlr->cfg.timing.vsaLines; - priv.cfg.g_mem_pitch = cntlr->cfg.timing.xPixels * 4; + priv.cfg.g_mem_pitch = cntlr->cfg.timing.xPixels * 4; // 4 priv.cfg.graphic_width = cntlr->cfg.timing.xPixels; priv.cfg.graphic_height = cntlr->cfg.timing.ylines; priv.cfg.zm_graphic_width = cntlr->cfg.timing.xPixels; @@ -189,21 +189,21 @@ static void MipiDsiDevCallback(uint8_t layerId, uint8_t channel, uint32_t addr) uint8_t ready_buf_idx; priv.free_chan = channel; switch (priv.buf_state) { - case READY: - // free channel = next channel - if (priv.buf_idx >= 1) { - ready_buf_idx = priv.buf_idx - 1; - } else { - ready_buf_idx = BUF_NUM - 1; - } - hal_lcdc_update_addr(1, channel, priv.buffers[ready_buf_idx]); - priv.buf_state = (priv.mode == DSI_VIDEO_MODE) ? BUSY : IDLE; - break; - case BUSY: - priv.buf_state = IDLE; - break; - default: - break; + case READY: + // free channel = next channel + if (priv.buf_idx >= 1) { + ready_buf_idx = priv.buf_idx - 1; + } else { + ready_buf_idx = BUF_NUM - 1; + } + hal_lcdc_update_addr(1, channel, priv.buffers[ready_buf_idx]); + priv.buf_state = (priv.mode == DSI_VIDEO_MODE) ? BUSY : IDLE; + break; + case BUSY: + priv.buf_state = IDLE; + break; + default: + break; } } @@ -232,11 +232,11 @@ void *MipiDsiDevMmap(uint32_t size) return NULL; } priv.buf_size = size; -#if (BUF_NUM < 3) +#if (BUF_NUM < 3) // 3 // ensure the buffers are exchanged uint32_t cnt = 0; while (priv.buf_state == READY) { - if (cnt++ > 100) { + if (cnt++ > 100) { // 100 HDF_LOGW("READY -> BUSY error, chan %d, cur_buf %d", priv.free_chan, priv.buf_idx); break; } @@ -255,7 +255,7 @@ void MipiDsiDevFlush(void) uint32_t cnt = 0; hal_cache_sync(HAL_CACHE_ID_D_CACHE, (uint32_t)priv.buffers[priv.buf_idx], priv.buf_size); while (priv.buf_state != IDLE) { - if (cnt++ > 100) { + if (cnt++ > 100) { // 100 HDF_LOGW("!IDLE, stat %d, cur_buf %d", priv.buf_state, priv.buf_idx); break; } diff --git a/bes2600/liteos_m/components/drivers/mipi_dsi/mipi_dsi.h b/bes2600/liteos_m/components/drivers/platform/mipi/mipi_dsi.h old mode 100644 new mode 100755 similarity index 100% rename from bes2600/liteos_m/components/drivers/mipi_dsi/mipi_dsi.h rename to bes2600/liteos_m/components/drivers/platform/mipi/mipi_dsi.h diff --git a/bes2600/liteos_m/components/hdf_config/device_info.hcs b/bes2600/liteos_m/components/hdf_config/device_info.hcs index 4bc7bc2068327944be1057077fb2a940ee99a529..c0cd0fb7554bfa18a9e56d5c216a3b0425d14e77 100755 --- a/bes2600/liteos_m/components/hdf_config/device_info.hcs +++ b/bes2600/liteos_m/components/hdf_config/device_info.hcs @@ -35,14 +35,14 @@ root { priority = 50; moduleName = "HDF_PLATFORM_I2C_MANAGER"; serviceName = "HDF_PLATFORM_I2C_MANAGER"; - } + }/* i2c0 :: deviceNode { policy = 0; priority = 100; moduleName = "BES_I2C_MODULE_HDF"; serviceName = ""; deviceMatchAttr = "i2c0_config"; - } + }*/ i2c1 :: deviceNode { policy = 0; priority = 100; @@ -51,6 +51,7 @@ root { deviceMatchAttr = "i2c1_config"; } } + /* device_pwm :: device { pwm0 :: deviceNode { policy = 2; @@ -85,6 +86,7 @@ root { deviceMatchAttr = "uart0_config"; } } + */ device_mipi_dsi :: device { mipi_dsi0 :: deviceNode { policy = 2; @@ -98,18 +100,6 @@ root { hostName = "display_host"; priority = 100; device_panel :: device { - /*panel_rm69330 :: deviceNode { - policy = 0; - priority = 100; - moduleName = "HDF_PANEL_RM69330"; - deviceMatchAttr = "rm69330_config"; - } - panel_icna3311 :: deviceNode { - policy = 0; - priority = 100; - moduleName = "HDF_PANEL_ICNA3311"; - deviceMatchAttr = "icna3311_config"; - }*/ panel_a064 :: deviceNode { policy = 0; priority = 100; @@ -122,12 +112,6 @@ root { hostName = "input_host"; priority = 100; device_touch :: device { - /*touch_ztw523 :: deviceNode { - policy = 0; - priority = 100; - moduleName = "HDF_TOUCH_ZTW523"; - deviceMatchAttr = "touch_ztw523_config"; - }*/ touch_fts :: deviceNode { policy = 0; priority = 100; diff --git a/bes2600/liteos_m/components/hdf_config/hdf.hcs b/bes2600/liteos_m/components/hdf_config/hdf.hcs old mode 100644 new mode 100755 index a45d81295e67a13e001f78649e2561431ef6fc64..bb9401d0635951dc94f8ba9ead75008a1fe71b8a --- a/bes2600/liteos_m/components/hdf_config/hdf.hcs +++ b/bes2600/liteos_m/components/hdf_config/hdf.hcs @@ -9,19 +9,6 @@ root { pinNum = 2; } i2c_config { - i2c0 { - match_attr = "i2c0_config"; - port = 0; - speed = 200000; - // TSP_SCL/SDA - I2C0 = GPIO04/GPIO05 - scl_pin = 4; - sda_pin = 5; - use_dma = 0; - use_sync = 1; - as_master = 1; - address_width = 8; - mode = 0; - } i2c1 { match_attr = "i2c1_config"; port = 1; @@ -38,22 +25,8 @@ root { } display { panel_config { - /*rm69330_config { - match_attr = "rm69330_config"; - // EVB_V3: RST - GPIO03, TE - GPIO21 - rst_pin = 3; - te_pin = 21; - } - icna3311_config { - match_attr = "icna3311_config"; - // EVB_V3: RST - GPIO03, TE - GPIO21, VCI_EN - GPIO02 - rst_pin = 3; - te_pin = 21; - vci_pin = 2; - }*/ a064_config { match_attr = "a064_config"; - // EVB_V3: RST - GPIO03, TE - GPIO21, LED_EN - GPIO26 rst_pin = 3; te_pin = 21; led_pin = 26; @@ -62,13 +35,6 @@ root { } input { touch_config { - /*touch_ztw523 { - match_attr = "touch_ztw523_config"; - gpio_rst = 0; - gpio_int = 1; - i2c_id = 0; - i2c_addr = 0x20; - }*/ touch_fts { match_attr = "touch_fts_config"; gpio_rst = 0;