return ERRCODE_SUCC;
}
+// #include "vibrator.h"
+
+// void Vibrator_swtich(uint8_t cmd)
+// {
+// g_Vibrator_swtich(cmd);
+// }
+
+#include "lcd_common.h"
+
+void lcd_getid(void)
+{
+ lcd_drv_common *lcd_drv_comm_api = NULL;
+ lcd_drv_cfg *lcd_cfg = NULL;
+
+ lcd_drv_comm_api = lcd_drv_get_common_api();
+ if (lcd_drv_comm_api == NULL) {
+ PRINT("lcd_drv_comm_api is null.\r\n");
+ }
+ else
+ {
+ lcd_cfg = lcd_drv_comm_api->get_lcd_config();
+ if (lcd_cfg == NULL) {
+ PRINT("lcd_cfg is null.\r\n");
+ }else
+ PRINT("LCD ID : 0x%x\r\n",(uint32_t)lcd_cfg->lcd_id);
+ }
+}
+
+
+#include "ft6x46_touch1.h"
+#define FTS_REG_CHIP_ID 0xA3
+#define FTS_REG_CHIP_ID2 0x9F
+
+void touch_getid(void)
+{
+ ext_errno ret;
+ uint8_t chip_id[2] = { 0 };
+ /*get chip id*/
+ ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID, &chip_id[0], 1);
+ if (ret != EXT_ERR_SUCCESS) {
+ PRINT("get ic information error1");
+ } else {
+ ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID2, &chip_id[1], 1);
+ if (ret != EXT_ERR_SUCCESS) {
+ PRINT("get ic information error2");
+ } else
+ PRINT("TOUCH CHIP ID = 0x%02x%02x", chip_id[0], chip_id[1]);
+ }
+
+}
+
+#include "touch_screen_drv.h"
+
+void touch_getstate(void)
+{
+ int32_t state;
+ state = uapi_get_screen_state();
+ PRINT("state : %d\r\n",state);
+}
+
+#include "MMC5603.h"
+
+void mmc5603_getid(void)
+{
+ MMC5603_GETID();
+}
+
+
+#include "battery_hal.h"
+void charge_getstate(void)
+{
+ if(get_charge_stat())
+ PRINT("charging\r\n");
+ else
+ PRINT("uncharged\r\n");
+}
+
+#include "battery_service.h"
+#define batteryservice_VOLTAGE_MAX (4.2f)
+#define batteryservice_VOLTAGE_MIN (3.2f)
+
+void battery_getpower(void)
+{
+ float vol = 0;
+ uint8_t per;
+ battery_info_t *current_battery_info = get_current_battery_info();
+ vol = current_battery_info->battery_voltage;
+ per = (vol - batteryservice_VOLTAGE_MIN)*100/(batteryservice_VOLTAGE_MAX - batteryservice_VOLTAGE_MIN) ;
+ if(per <= 0)
+ per = 0;
+ else if(per >= 100)
+ per = 100;
+ PRINT("power : %d \r\n",per);
+}
+
+void battery_getvoltage(void)
+{
+ battery_info_t *current_battery_info = get_current_battery_info();
+ batteryservice_get_voltage_by_channel(¤t_battery_info->battery_voltage,ADC_CHANNEL_BAT_VOLTAGE);
+ PRINT("voltage : %f \r\n",current_battery_info->battery_voltage);
+}
+
+
+#include "flash.h"
+
+void flash_erase(void)
+{
+ if (uapi_flash_chip_erase(CHIP_FLASH_ID) != ERRCODE_SUCC)
+ PRINT("flash erase err !!! \r\n");
+ else
+ PRINT("flash erase succ !!! \r\n");
+}
+
+#include "stdio.h"
+
+/**** 静态全局变量 ****/
+static int width = 200; //LCD X 分辨率
+static int height = 200; //LCD Y 分辨率
+static uint32_t *bmp_buf = NULL; //bmp_buf
+static unsigned long line_length; //LCD 一行的长度(字节为单位)
+
+/**** BMP 文件头数据结构 ****/
+typedef struct {
+ unsigned char type[2]; //文件类型
+ unsigned int size; //文件大小
+ unsigned short reserved1; //保留字段 1
+ unsigned short reserved2; //保留字段 2
+ unsigned int offset; //到位图数据的偏移量
+} __attribute__ ((packed)) bmp_file_header;
+
+/**** 位图信息头数据结构 ****/
+typedef struct {
+ unsigned int size; //位图信息头大小
+ int width; //图像宽度
+ int height; //图像高度
+ unsigned short planes; //位面数
+ unsigned short bpp; //像素深度
+ unsigned int compression; //压缩方式
+ unsigned int image_size; //图像大小
+ int x_pels_per_meter; //像素/米
+ int y_pels_per_meter; //像素/米
+ unsigned int clr_used;
+ unsigned int clr_omportant;
+} __attribute__ ((packed)) bmp_info_header;
+
+int set_bmp(void)
+{
+ unsigned short *line_buf = NULL; //行缓冲区
+ unsigned long line_bytes; //BMP 图像一行的字节的大小
+ unsigned int min_h, min_bytes;
+
+ const char *path = {"/system/1.bmp"};
+ bmp_file_header file_h;
+ bmp_info_header info_h;
+
+ int j;
+
+ /* 打开BMP 文件 */
+ FILE *fp = fopen(path, "r");
+ if (fp == NULL) {
+ fclose(fp);
+ PRINT("file open failed !!!\r\n");
+ return -1;
+ }
+ PRINT("file open succ !!!\r\n");
+ /* 读取 BMP 文件头 */
+ if (sizeof(bmp_file_header) != fread(&file_h, 1, sizeof(bmp_file_header),fp) )
+ {
+ PRINT(" read bmp_file_header failed !!!\r\n");
+ fclose(fp);
+ return -1;
+ }
+ PRINT("file read succ !!!\r\n");
+ if (0 != memcmp(file_h.type, "BM", 2))
+ {
+ PRINT("it's not a BMP file !!!\r\n");
+ fclose(fp);
+ return -1;
+ }
+
+ /* 读取位图信息头 */
+ if (sizeof(bmp_info_header) != fread(&info_h, 1,sizeof(bmp_info_header),fp) )
+ {
+ PRINT("read bmp_info_header error !!!\r\n");
+ fclose(fp);
+ return -1;
+ }
+ /* 打印信息 */
+ PRINT("文件大小: %d\n"
+ "位图数据的偏移量: %d\n"
+ "位图信息头大小: %d\n"
+ "图像分辨率: %d*%d\n"
+ "像素深度: %d\n", file_h.size, file_h.offset,
+ info_h.size, info_h.width, info_h.height,
+ info_h.bpp);
+
+ /* 将文件读写位置移动到图像数据开始处 */
+ if (-1 == fseek(fp, file_h.offset, SEEK_SET))
+ {
+ PRINT("file lseek error !!!\r\n");
+ fclose(fp);
+ return -1;
+ }
+ PRINT("file lseek succ !!!\r\n");
+
+ /* 申请一个 buf、暂存 bmp 图像的一行数据 */
+ line_bytes = info_h.width * info_h.bpp / 8;
+ line_buf = malloc(line_bytes);
+ bmp_buf = malloc(file_h.size);
+ if (NULL == line_buf)
+ {
+ fclose(fp);
+ return -1;
+ }
+ else
+ PRINT("malloc succ !!!\r\n");
+
+
+ if (line_length > line_bytes)
+ min_bytes = line_bytes;
+ else
+ min_bytes = line_length;
+
+ if (0 < info_h.height)
+ {//倒向位图
+ if (info_h.height > height)
+ {
+ min_h = height;
+ fseek(fp, (info_h.height - height) * line_bytes, SEEK_CUR);
+ bmp_buf += width * (height - 1); //定位到屏幕左下角位置
+ }
+ else
+ {
+ min_h = info_h.height;
+ bmp_buf += width * (info_h.height - 1);
+ }
+ for (j = min_h; j > 0; bmp_buf -= width, j--)
+ {
+ fread( line_buf, 1, line_bytes ,fp); //读取出图像数据
+ memcpy(bmp_buf, line_buf, min_bytes);//
+ }
+ }
+ else
+ { //正向位图
+ int temp = 0 - info_h.height; //负数转成正数
+ if (temp > height)
+ min_h = height;
+ else
+ min_h = temp;
+ for (j = 0; j < min_h; j++, bmp_buf += width)
+ {
+ fread(line_buf, 1 ,line_bytes , fp);
+ memcpy(bmp_buf, line_buf, min_bytes);
+ }
+ }
+
+ int size = strlen(bmp_buf);
+ PRINT("bmp_buf size : %d\r\n",size);
+
+ /* 关闭文件、函数返回 */
+ fclose(fp);
+ free(line_buf);
+ return 1;
+}
+
+int enter_recovery(void)
+{
+ if(set_bmp() == -1)
+ {
+ PRINT("set bmp failed !!! \r\n");
+ return -1;
+ }
+ return 1;
+ //upg_reboot();
+}
+
+
return ERRCODE_SUCC;
}
+// static uint32_t custom_vibrator_swtich(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+// {
+// UNUSED(strCommonCmd);
+
+// uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN] = { 0 };
+// uint32_t argc = 0;
+
+// int ret = ConvertCmdToParam(para, paraLen, argv, &argc);
+// if (ret != CUSTOM_UTILS_SUCCESS) {
+// PRINT("CUSTOM_UTILSTEST ATCMD Convert Command Failed\n");
+// return ERRCODE_FAIL;
+// }
+
+// if (argc != 1) {
+// PRINT("CUSTOM_UTILSTEST ATCMD Set Parameter Failed argc %d\n",argc);
+// return ERRCODE_FAIL;
+// }
+
+// uint8_t cmd = atoi((char*)argv[0]);
+
+// Vibrator_swtich(cmd);
+
+// return ERRCODE_SUCC;
+// }
+
+static uint32_t custom_lcd_getid(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+
+ UNUSED(strCommonCmd);
+
+ lcd_getid();
+
+ return ERRCODE_SUCC;
+}
+
+static uint32_t custom_touch_getid(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+
+ UNUSED(strCommonCmd);
+
+ touch_getid();
+
+ return ERRCODE_SUCC;
+}
+
+static uint32_t custom_touch_getstate(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+
+ UNUSED(strCommonCmd);
+
+ touch_getstate();
+
+ return ERRCODE_SUCC;
+}
+
+static uint32_t custom_mmc5603_getid(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+
+ UNUSED(strCommonCmd);
+
+ mmc5603_getid();
+
+ return ERRCODE_SUCC;
+}
+
+static uint32_t custom_charge_getstate(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+
+ UNUSED(strCommonCmd);
+
+ charge_getstate();
+
+ return ERRCODE_SUCC;
+}
+
+static uint32_t custom_battery_getpower(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+
+ UNUSED(strCommonCmd);
+
+ battery_getpower();
+
+ return ERRCODE_SUCC;
+}
+
+static uint32_t custom_battery_getvoltage(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+
+ UNUSED(strCommonCmd);
+
+ battery_getvoltage();
+
+ return ERRCODE_SUCC;
+}
+
+static uint32_t custom_flash_erase(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+
+ UNUSED(strCommonCmd);
+
+ flash_erase();
+
+ return ERRCODE_SUCC;
+}
+
+static uint32_t custom_enter_recovery(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+
+ UNUSED(strCommonCmd);
+
+ if(enter_recovery() == -1)
+ return ERRCODE_FAIL;
+
+ return ERRCODE_SUCC;
+}
+
+
+
+// { (char *)"AT^VIBRATOR", custom_vibrator_swtich, (char *)" " },
static const at_cmd_table_t g_custom_utils_cmd[] = {
{ (char *)"AT^CUSTOM_SN", custom_utils_setsn, (char *)"123456789ABCDEF2345678" },
{ (char *)"AT^CUSTOM_SN_REQ", custom_utils_getsn, (char *)" " },
{ (char *)"AT^DOWNLOADOTA", custom_start_ota_download, (char *)" " },
{ (char *)"AT^STARTOTA", custom_start_ota, (char *)" " },
+
+
+ { (char *)"AT^LCDID", custom_lcd_getid, (char *)" " },
+
+ { (char *)"AT^TOUCHID", custom_touch_getid, (char *)" " },
+
+ { (char *)"AT^TOUCHSTATE", custom_touch_getstate, (char *)" " },
+
+ { (char *)"AT^MMC5603ID", custom_mmc5603_getid, (char *)" " },
+
+ { (char *)"AT^CHARGESTATE", custom_charge_getstate, (char *)" " },
+
+ { (char *)"AT^GETPOWER", custom_battery_getpower, (char *)" " },
+
+ { (char *)"AT^GETVOLTAGE", custom_battery_getvoltage, (char *)" " },
+
+ { (char *)"AT^FLASHERASE", custom_flash_erase, (char *)" " },
+
+ { (char *)"AT^RECOVERY", custom_enter_recovery, (char *)" " },
};
at_cmd_table_t *get_custom_utils_cmd_table(uint32_t *cmd_count)