#endif
#ifndef USE_CRANE_LCD_MIPI
-# define USE_CRANE_LCD_MIPI 0
-# define USE_CRANE_LCD_MIPI_CMD 0
+# define USE_CRANE_LCD_MIPI 1
+# define USE_CRANE_LCD_MIPI_CMD 1
# define USE_CRANE_LCD_MIPI_VIDEO 0
#endif
# define USE_LCD_PANEL_ICNA3310_MIPI 0
#endif
+#ifndef USE_LCD_PANEL_CO5300_MIPI
+# define USE_LCD_PANEL_CO5300_MIPI 1
+#endif
+
#define USE_LCD_PANEL_ILI9806E_MIPI 0
#ifndef USE_LCD_PANEL_GC9A01_SPI_WATCH
-# define USE_LCD_PANEL_GC9A01_SPI_WATCH 1
+# define USE_LCD_PANEL_GC9A01_SPI_WATCH 0
#endif
#ifndef USE_LCD_PANEL_ST9A01_4_1_SPI_POC
#ifndef USE_HX3918
#define USE_HX3918 1
#endif
+
+#ifndef USE_WMM300
+#define USE_WMM300 0
+#endif
+
/****************heart rate***********/
/****************temperature***********/
display/crane_lcd_mipi_dphy.c
# display/rm69330_mipi.c
display/st9a01_spi.c
- # display/icna3310_mipi.c
+ display/icna3310_mipi.c
+ display/co5300_mipi.c
# display/ili9806e_mipi.c
display/pll2_fc.c
display/gc9a01_spi.c
indev/gh3018_source/HRNet_knWeights.c
indev/gh3018_source/HRNet_knWeightsSmall.c
indev/gh3018_source/pv_v2.0.1_sm_spo2wrnet_for_GH3018_masimo_0f423c.c
+
indev/HX3918/hx3918.c
indev/HX3918/hx3918_check_touch.c
indev/HX3918/hx3918_factory_test.c
indev/HX3918/hx3918_prox.c
indev/HX3918/hx3918_spo2_agc.c
+ indev/WMM300/alg_example.c
+ indev/WMM300/alg_port.c
+
indev/ACNT180.c
indev/ACNT117.c
jpeg/crane_jpuc_common.c
--- /dev/null
+#include "co5300_mipi.h"
+
+#if USE_LCD_PANEL_CO5300_MIPI
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <string.h>
+#include "lvgl/src/lv_core/lv_refr.h"
+#include "lvgl/src/lv_core/lv_disp.h"
+#include "lvgl/src/lv_hal/lv_hal_tick.h"
+#include "crane_lcdc.h"
+#include "crane_lcd_mipi.h"
+#include "crane_lcd_mipi_dsi.h"
+#include "../common/utils.h"
+#include "../common/lv_pm.h"
+#include "../../board.h"
+#include "lv_conf.h"
+
+#define UNLOCK_DELAY 0
+#define LCD_COLOR_DEPTH_BYTE (LV_COLOR_DEPTH / 8)
+
+static lv_disp_drv_t * lcd_disp_drv = NULL;
+
+static lcd_context g_lcd_ctx;
+
+#define ID_TABLE_END 0
+unsigned co5300_id_table[] = {
+ 0x1,
+ 0x33,
+ ID_TABLE_END,
+};
+
+static struct s_dsi_cmd_desc co5300_init_cmds[] = {
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0xFE, 0x20}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0xF4, 0x5A}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0xF5, 0x59}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0xFE, 0x40}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0xC9, 0x15}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x93, 0x08}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0xFE, 0xE0}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x01, 0x02}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x0A, 0x02}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x11, 0x20}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0xFE, 0x00}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x35, 0x00}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x36, 0x08}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x51, 0xFF}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x53, 0x20}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x63, 0xFF}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 5,{0x2A, 0x00,0x0e,0x01,0xD3}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 5,{0x2B, 0x00,0x00,0x01,0xC5}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x13, 0x00}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0xC4, 0x00}},
+
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0xfe, 0x20}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0xf4, 0x5a}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0xf5, 0x59}},
+
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0xfe, 0xd0}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x4d, 0x7f}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x4e, 0x80}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0xfe, 0x40}},
+ // {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x54, 0xaf}},
+
+ {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0xfe, 0x00}},
+ {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x3a, 0x77}},
+ {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x35, 0x00}},
+ {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x36, 0x08}},
+ {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x53, 0x20}},
+ {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x51, 0xff}},
+ {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 2,{0x63, 0xff}},
+ {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 5,{0x2A, 0x00,0x06,0x01,0xd7}},
+ {DSI_DCS_SWRITE1,DSI_LP_MODE,UNLOCK_DELAY, 5,{0x2B, 0x00,0x00,0x01,0xd1}},
+ {DSI_DCS_SWRITE,DSI_LP_MODE,120, 1,{0x11}},
+ {DSI_DCS_SWRITE,DSI_LP_MODE,20, 1,{0x29}},
+
+
+
+
+};
+
+static struct s_dsi_cmd_desc co5300_set_cmds[] = {
+ {DSI_SET_MAX_PKT_SIZE, DSI_LP_MODE, UNLOCK_DELAY, 1, {0x2}},
+};
+
+static struct s_dsi_cmd_desc co5300_read_id_cmds[] = {
+ {DSI_DCS_READ, DSI_LP_MODE, UNLOCK_DELAY, 3, {0x04}},
+};
+
+static struct s_dsi_cmd_desc co5300_display_on_cmds[] = {
+ {DSI_DCS_SWRITE,DSI_LP_MODE,120,1,{0x11}},
+ {DSI_DCS_SWRITE,DSI_LP_MODE,20,1,{0x29}},
+};
+
+static struct s_dsi_cmd_desc co5300_display_off_cmds[] = {
+ {DSI_DCS_SWRITE,DSI_LP_MODE,20,1,{0x28}},
+ {DSI_DCS_SWRITE,DSI_LP_MODE,120,1,{0x10}},
+};
+
+static struct s_dsi_cmd_desc co5300_idle_on_cmds[] = {
+ {DSI_DCS_SWRITE,DSI_LP_MODE,20, 1,{0x39}},
+};
+
+static struct s_dsi_cmd_desc co5300_idle_off_cmds[] = {
+ {DSI_DCS_SWRITE,DSI_LP_MODE,20, 1,{0x38}},
+};
+
+const static struct s_mipi_info lcd_co5300_info = {
+ 466, /*width*/
+ 466, /*height*/
+ 10, /*hfp*/
+ 10, /*hbp*/
+ 10, /*hsync*/!!
+ 10, /*vfp*/
+ 12, /*vbp*/
+ 10, /*vsync*/
+ 60, /*fps*/
+
+ DSI_MODE_CMD, /*work_mode*/ /*can only be cmd mode*/
+ DSI_INPUT_DATA_RGB_MODE_888, /*rgb_mode*/
+ 1, /*lane_number*/ /*can only be 1*/
+ 400000, /*phy_freq: KHz*/
+ 0, /*split_enable*/ /*can only be 0*/
+ 1, /*eotp_enable*/
+
+ DSI_BURST_MODE_BURST, /*burst_mode*/
+
+ /*following force to 0*/
+ 0, /*te_enable*/
+ 0, /*vsync_pol*/
+ 0, /*te_pol*/
+ 0, /*te_mode*/
+
+ /*The following fields need not be set by panel*/
+ 0,
+};
+
+static uint8_t suspend_flag = 0;
+static void co5300_idle_in(void *arg)
+{
+ struct crane_panel_t *p = arg;
+ if(suspend_flag == 1) {
+ return;
+ }
+ cplog_printf("co5300_idle_in\n");
+ /*since disp_refr can be changed by other register,
+ *so if st7789v suspend need use lcd_disp_drv instead of lv_refr_vdb_is_flushing()
+ *refer to lv_disp_refr_task() and lv_refr_vdb_flush()*/
+ if(lcd_disp_drv && lcd_disp_drv->buffer) {
+ // wait flushing finish~~
+ cplog_printf("co5300_idle_in: %d\n", lcd_disp_drv->buffer->flushing);
+ while(lcd_disp_drv->buffer->flushing)
+ ;
+ }
+ p->idle_onoff(1);
+ lcd_mipi_uninit();
+ suspend_flag = 1;
+}
+
+static struct s_dsi_cmd_desc co5300_set_brightness_cmds[] = {
+ {DSI_DCS_SWRITE1, DSI_LP_MODE, UNLOCK_DELAY, 2, {0x51,}},
+};
+
+void isca3310_set_display_brightness(int level)
+{
+ if ((level < 0) || (level > 255)) {
+ cplog_printf("isca3310: invalid brigntness level %d\n", level);
+ }
+ co5300_set_brightness_cmds[0].data[1] = level & 0xFF;
+ lcd_dsi_write_cmds(co5300_set_brightness_cmds, ARRAY_SIZE(co5300_set_brightness_cmds));
+}
+
+static void co5300_idle_out(void *arg)
+{
+ struct crane_panel_t *p = arg;
+ if(suspend_flag == 0) {
+ return;
+ }
+ cplog_printf("co5300_idle_out\n");
+ lcdc_resume();
+ p->idle_onoff(0);
+
+ suspend_flag = 0;
+ lv_obj_invalidate(lv_disp_get_scr_act(NULL));
+ lv_refr_now(_lv_refr_get_disp_refreshing());
+
+ if(lcd_disp_drv && lcd_disp_drv->buffer) {
+ // wait flushing finish~~
+ while(lcd_disp_drv->buffer->flushing)
+ ;
+ }
+}
+
+static void co5300_idle_flush(void)
+{
+ if(suspend_flag == 0) {
+ return;
+ }
+ cplog_printf("co5300_idle_flush\n");
+ lcdc_resume();
+
+ suspend_flag = 0;
+ lv_obj_invalidate(lv_disp_get_scr_act(NULL));
+ lv_refr_now(_lv_refr_get_disp_refreshing());
+
+ if(lcd_disp_drv && lcd_disp_drv->buffer) {
+ // wait flushing finish~~
+ while(lcd_disp_drv->buffer->flushing)
+ ;
+ }
+
+ lcd_mipi_uninit();
+ suspend_flag = 1;
+}
+
+static void co5300_suspend(void *arg)
+{
+ struct crane_panel_t *p = arg;
+ cplog_printf("co5300_suspend\n");
+
+ /*since disp_refr can be changed by other register,
+ *so if st7789v suspend need use lcd_disp_drv instead of lv_refr_vdb_is_flushing()
+ *refer to lv_disp_refr_task() and lv_refr_vdb_flush()*/
+ if(lcd_disp_drv && lcd_disp_drv->buffer) {
+ // wait flushing finish~~
+ while(lcd_disp_drv->buffer->flushing)
+ ;
+ }
+
+ p->panel_onoff(0);
+ lcd_mipi_uninit();
+ suspend_flag = 1;
+}
+extern void Sensor_Hub_Spi_test(void);
+static void co5300_resume(void *arg)
+{
+ struct crane_panel_t *p = arg;
+ cplog_printf("co5300_resume\n");
+ lcdc_resume();
+ p->panel_onoff(1);
+
+ //Sensor_Hub_Spi_test();
+ suspend_flag = 0;
+ lv_obj_invalidate(lv_disp_get_scr_act(NULL));
+ lv_refr_now(_lv_refr_get_disp_refreshing());
+
+ if(lcd_disp_drv && lcd_disp_drv->buffer) {
+ // wait flushing finish~~
+ while(lcd_disp_drv->buffer->flushing)
+ ;
+ }
+}
+
+static void co5300_panel_invalid(uint32_t start_x,
+ uint32_t start_y, uint32_t end_x, uint32_t end_y)
+{
+ struct s_dsi_cmd_desc invalid_cmds[2];
+ start_x += 12;
+ end_x += 12;
+
+ lcd_dsi_update_mipi_info(end_x-start_x + 1, end_y-start_y + 1);
+
+ invalid_cmds[0].cmd_type = DSI_DCS_LWRITE;
+ invalid_cmds[0].lp = DSI_HS_MODE;
+ invalid_cmds[0].delay = UNLOCK_DELAY;
+ invalid_cmds[0].length = 5;
+ invalid_cmds[0].data[0] = 0x2A;
+ invalid_cmds[0].data[1] = (start_x >> 8) & 0xFF;
+ invalid_cmds[0].data[2] = (start_x) & 0xFF;
+ invalid_cmds[0].data[3] = (end_x >> 8) & 0xFF;
+ invalid_cmds[0].data[4] = (end_x) & 0xFF;
+
+ invalid_cmds[1].cmd_type = DSI_DCS_LWRITE;
+ invalid_cmds[1].lp = DSI_HS_MODE;
+ invalid_cmds[1].delay = UNLOCK_DELAY;
+ invalid_cmds[1].length = 5;
+ invalid_cmds[1].data[0] = 0x2B;
+ invalid_cmds[1].data[1] = (start_y >> 8) & 0xFF;
+ invalid_cmds[1].data[2] = (start_y) & 0xFF;
+ invalid_cmds[1].data[3] = (end_y >> 8) & 0xFF;
+ invalid_cmds[1].data[4] = (end_y) & 0xFF;
+
+ lcd_dsi_write_cmds(invalid_cmds, ARRAY_SIZE(invalid_cmds));
+}
+
+static int match_id(unsigned id, unsigned *id_table)
+{
+ int found = 0;
+ unsigned *p = id_table;
+
+ while (*p) {
+ if (id == *p) {
+ found = 1;
+ break;
+ }
+ p++;
+ }
+
+ return (found == 1) ? 1 : 0;
+}
+
+static int co5300_read_id(unsigned *pid)
+{
+ struct s_dsi_rx_buf dbuf;
+ int id[5];
+
+ lcd_dsi_write_cmds(co5300_set_cmds, ARRAY_SIZE(co5300_set_cmds));
+
+ lcd_dsi_read_cmds(&dbuf, co5300_read_id_cmds,ARRAY_SIZE(co5300_read_id_cmds));
+ id[0] = dbuf.data[0];
+ id[1] = dbuf.data[1];
+ id[2] = dbuf.data[2];
+ id[3] = dbuf.data[3];
+ id[4] = dbuf.data[4];
+ cplog_printf("co5300_read_id: data 0 - 4 is 0x%x, 0x%x, 0x%x, 0x%x, 0x%x \n",
+ id[0],id[1],id[2],id[3],id[4]);
+
+ *pid = id[0];
+ return 0;
+}
+
+__attribute__ ((unused)) static int panel_detect_readid(void)
+{
+ unsigned id;
+ if (co5300_read_id(&id) < 0) {
+ cplog_printf("panel read id failed\n");
+ goto err;
+ }
+ cplog_printf("panel_detect_readid ID:0x%x\n",id);
+ if (match_id(id, co5300_id_table) == 0) {
+ cplog_printf("unknown panel id = 0x%x\n", id);
+ goto err;
+ }
+
+ cplog_printf("Found LCD panel co5300-mipi, id: 0x%x\n", id);
+ cplog_printf("panel detect by readid ok\n");
+
+ return 0;
+err:
+ cplog_printf("panel detect by readid failed\n");
+ return -1;
+}
+
+typedef int (*panel_detect_fn_t)(void);
+
+static panel_detect_fn_t detect_fn[] = {
+ panel_detect_readid,
+};
+
+static int panel_detect(void)
+{
+ int cnt = ARRAY_SIZE(detect_fn);
+ int i, ret;
+
+ for (i = 0; i < cnt; i++) {
+ ret = detect_fn[i]();
+ if (ret == 0) {
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+static void co5300_idle_onoff(int on)
+{
+ if (on) {
+ lcd_dsi_write_cmds(co5300_idle_on_cmds, ARRAY_SIZE(co5300_idle_on_cmds));
+ } else { /* off */
+ lcd_dsi_write_cmds(co5300_idle_off_cmds, ARRAY_SIZE(co5300_idle_off_cmds));
+ }
+}
+
+static void co5300_onoff(int on)
+{
+ if (on) {
+ lcd_dsi_write_cmds(co5300_display_on_cmds, ARRAY_SIZE(co5300_display_on_cmds));
+ } else { /* off */
+ lcd_dsi_write_cmds(co5300_display_off_cmds, ARRAY_SIZE(co5300_display_off_cmds));
+ }
+}
+
+static int co5300_probe(unsigned lcd_clk)
+{
+ static int inited = 0;
+ lv_pm_info_t pm_info;
+
+ lcd_mipi_init(lcd_clk, 0, &lcd_co5300_info);
+ lcd_mipi_reset();
+ cplog_printf("co5300_probe!!!!!!!!!!!!!!!!!!!\n");
+ if(inited) {
+ return 0;
+ }
+
+ int silent_reset = startup_silent_reset();
+ if(!silent_reset) {
+ lcdc_reset_panel();
+ }
+
+ if (panel_detect() < 0) {
+ return -1;
+ }
+
+ lcd_dsi_write_cmds(co5300_init_cmds, ARRAY_SIZE(co5300_init_cmds));
+ //while(1);
+ memset(&g_lcd_ctx, 0, sizeof(lcd_context));
+ g_lcd_ctx.bg_color = 0x0000ff; /*bg color : red*/
+ g_lcd_ctx.alpha_mode = LCD_ALPHA_MODE_NORMAL;
+ g_lcd_ctx.output_config.format = MIPI_FORMAT_CMD;
+
+ pm_info.suspend = co5300_suspend;
+ pm_info.resume = co5300_resume;
+ pm_info.data = &co5300_mipi;
+ pm_info.part = LV_PM_PART_DISPLAY;
+ lv_pm_register(&pm_info);
+
+ pm_info.suspend = co5300_idle_in;
+ pm_info.resume = co5300_idle_out;
+ pm_info.data = &co5300_mipi;
+ pm_info.part = LV_PM_PART_TOUCH;
+ lv_pm_register(&pm_info);
+
+ inited = 1;
+
+ return 0;
+}
+
+/*refer to lv_port_disp_template.c, when lcdc_irq come, set lv_disp_flush_ready()*/
+static void co5300_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
+{
+ lcd_disp_drv = disp_drv;
+ if(suspend_flag == 1) {
+ lv_disp_flush_ready(disp_drv);
+ return;
+ }
+
+ uint32_t width, height, stride;
+ unsigned buf_len;
+
+ width = area->x2 - area->x1 + 1;
+ height = area->y2 - area->y1 + 1;
+
+#if (LV_COLOR_DEPTH == 16)
+ stride = width * LCD_COLOR_DEPTH_BYTE;
+#else
+ cplog_printf("lv config is not 16 bits color depth !!!!!!!!!!!\n");
+ return;
+#endif
+ buf_len = stride * height;
+
+ flush_cache((unsigned long)color_p, buf_len);
+ g_lcd_ctx.layer_config_osd1.buf1 = (void *)color_p;
+ g_lcd_ctx.layer_config_osd1.format = LCD_FORMAT_RGB565;
+ g_lcd_ctx.layer_config_osd1.layer_enable = 1;
+ g_lcd_ctx.layer_config_osd1.stride = stride;
+ g_lcd_ctx.layer_config_osd1.x = 0;
+ g_lcd_ctx.layer_config_osd1.y = 0;
+ g_lcd_ctx.layer_config_osd1.width = width;
+ g_lcd_ctx.layer_config_osd1.height = height;
+ g_lcd_ctx.layer_config_osd1.alpha = 0xff;
+
+ g_lcd_ctx.wb_config.wb_enable = 0;
+ g_lcd_ctx.layer_config_img.layer_enable = 0;
+
+ lcdc_update_output_setting(&g_lcd_ctx.output_config, width, height);
+ co5300_panel_invalid(area->x1, area->y1, area->x2, area->y2);
+
+ lcd_dsi_before_refresh();
+ lcdc_sync(&g_lcd_ctx, 0); /* irq mode */
+}
+
+struct crane_panel_t co5300_mipi= {
+ .probe = co5300_probe, /* lcd_init() in board_evb.c also need change */
+ .readid = co5300_read_id,
+ .panel_onoff = co5300_onoff,
+ .flush = co5300_flush,
+ .idle_onoff = co5300_idle_onoff,
+ .idle_flush = co5300_idle_flush,
+};
+
+#endif
--- /dev/null
+#ifndef _CO5300_MIPI_H
+#define _CO5300_MIPI_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "lv_drv_conf.h"
+
+#if USE_LCD_PANEL_CO5300_MIPI
+
+#include "crane_lcdc.h"
+
+extern struct crane_panel_t co5300_mipi;
+
+#endif /* USE_LCD_PANEL_CO5300_MIPI */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* _CO5300_MIPI_H */
#if USE_CRANE_LCD_MIPI
+
+#define LCD_MIPI_DEBUG 0
+#if LCD_MIPI_DEBUG == 1
+#define LCD_MIPI_LOG(msg, ...) LCD_MIPI_LOG( msg, ##__VA_ARGS__)//printf( msg, ##__VA_ARGS__)//
+//#define LCD_MIPI_LOG(msg, ...) printf( msg, ##__VA_ARGS__)//printf( msg, ##__VA_ARGS__)//
+#else
+#define LCD_MIPI_LOG(msg, ...)
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
reg |= (dividor & 0x7) << 17;
reg |= BIT_15 | BIT_16| BIT_31;
pmu_write(PMU_LCD_CLK_RES_CTRL1, reg);
- //printf("0x%x write 0x%x\n", PMU_LCD_CLK_RES_CTRL1, reg);
+ //LCD_MIPI_LOG("0x%x write 0x%x\n", PMU_LCD_CLK_RES_CTRL1, reg);
mdelay(1);
reg = pmu_read(PMU_LCD_CLK_RES_CTRL1);
reg &= ~(BIT_31);
pmu_write(PMU_LCD_CLK_RES_CTRL1, reg);
- //printf("0x%x write 0x%x\n", PMU_LCD_CLK_RES_CTRL1, reg);
+ //LCD_MIPI_LOG("0x%x write 0x%x\n", PMU_LCD_CLK_RES_CTRL1, reg);
mdelay(1);
reg = pmu_read(PMU_LCD_CLK_RES_CTRL1);
- //printf("0x%x readl 0x%x\n", PMU_LCD_CLK_RES_CTRL1, reg);
+ //LCD_MIPI_LOG("0x%x readl 0x%x\n", PMU_LCD_CLK_RES_CTRL1, reg);
#if 0
while(0 != (reg & 0x80000000)){
expec_esc_clk = 0;
real_esc_clk = 52000;
};
- printf("need escclk:%d, real escclk:%d.\n",expec_esc_clk, real_esc_clk);
+ LCD_MIPI_LOG("need escclk:%d, real escclk:%d.\n",expec_esc_clk, real_esc_clk);
return real_esc_clk;
}
static void dump_mipi_info(struct s_mipi_info *mipi_info)
{
- printf("height: %d\n",mipi_info->height);
- printf("width: %d\n",mipi_info->width);
- printf("hfp: %d\n",mipi_info->hfp);
- printf("hbp: %d\n",mipi_info->hbp);
- printf("hsync: %d\n",mipi_info->hsync);
- printf("vfp: %d\n",mipi_info->vfp);
- printf("vbp: %d\n",mipi_info->vbp);
- printf("vsync: %d\n",mipi_info->vsync);
- printf("fps: %d\n",mipi_info->fps);
-
- printf("work_mode: %d\n",mipi_info->work_mode);
- printf("rgb_mode: %d\n",mipi_info->rgb_mode);
- printf("lane_number: %d\n",mipi_info->lane_number);
- printf("phy_freq: %d\n",mipi_info->phy_freq);
- printf("split_enable: %d\n",mipi_info->split_enable);
- printf("eotp_enable: %d\n",mipi_info->eotp_enable);
-
- printf("burst_mode: %d\n",mipi_info->burst_mode);
-
- printf("te_enable: %d\n",mipi_info->te_enable);
- printf("vsync_pol: %d\n",mipi_info->vsync_pol);
- printf("te_pol: %d\n",mipi_info->te_pol);
- printf("te_mode: %d\n",mipi_info->te_mode);
-
- printf("real_fps: %d\n",mipi_info->real_fps);
+ LCD_MIPI_LOG("height: %d\n",mipi_info->height);
+ LCD_MIPI_LOG("width: %d\n",mipi_info->width);
+ LCD_MIPI_LOG("hfp: %d\n",mipi_info->hfp);
+ LCD_MIPI_LOG("hbp: %d\n",mipi_info->hbp);
+ LCD_MIPI_LOG("hsync: %d\n",mipi_info->hsync);
+ LCD_MIPI_LOG("vfp: %d\n",mipi_info->vfp);
+ LCD_MIPI_LOG("vbp: %d\n",mipi_info->vbp);
+ LCD_MIPI_LOG("vsync: %d\n",mipi_info->vsync);
+ LCD_MIPI_LOG("fps: %d\n",mipi_info->fps);
+
+ LCD_MIPI_LOG("work_mode: %d\n",mipi_info->work_mode);
+ LCD_MIPI_LOG("rgb_mode: %d\n",mipi_info->rgb_mode);
+ LCD_MIPI_LOG("lane_number: %d\n",mipi_info->lane_number);
+ LCD_MIPI_LOG("phy_freq: %d\n",mipi_info->phy_freq);
+ LCD_MIPI_LOG("split_enable: %d\n",mipi_info->split_enable);
+ LCD_MIPI_LOG("eotp_enable: %d\n",mipi_info->eotp_enable);
+
+ LCD_MIPI_LOG("burst_mode: %d\n",mipi_info->burst_mode);
+
+ LCD_MIPI_LOG("te_enable: %d\n",mipi_info->te_enable);
+ LCD_MIPI_LOG("vsync_pol: %d\n",mipi_info->vsync_pol);
+ LCD_MIPI_LOG("te_pol: %d\n",mipi_info->te_pol);
+ LCD_MIPI_LOG("te_mode: %d\n",mipi_info->te_mode);
+
+ LCD_MIPI_LOG("real_fps: %d\n",mipi_info->real_fps);
}
static unsigned char calculate_ecc(unsigned char *pdata)
{
if(enable) {
lcd_dsi_set_bits(DSI_CTRL_0, CFG_VPN_TX_EN | CFG_VPN_SLV | CFG_VPN_EN);
- printf("dsi 0x1e8 = 0x%x\n", lcd_dsi_read(DSI_PHY_ANA_CTRL1));
+ LCD_MIPI_LOG("dsi 0x1e8 = 0x%x\n", lcd_dsi_read(DSI_PHY_ANA_CTRL1));
} else {
lcd_dsi_clear_bits(DSI_CTRL_0, CFG_VPN_TX_EN | CFG_VPN_EN);
}
uint32_t len;
if(lp) {
- printf("%d packet data will be write in lp mode\n", count);
+ LCD_MIPI_LOG("%d packet data will be write in lp mode\n", count);
} else {
- printf("%d data will be write in hs mode\n", count);
+ LCD_MIPI_LOG("%d data will be write in hs mode\n", count);
}
/* write all packet bytes to packet data buffer */
tmp = lcd_dsi_read(DSI_CPU_CMD_3);
} while ((tmp & CFG_CPU_DAT_REQ) && timeout);
if (timeout == 0)
- printf("DSI write data to the packet data buffer not done.\n");
+ LCD_MIPI_LOG("DSI write data to the packet data buffer not done.\n");
send_data = 0;
}
}
tmp = lcd_dsi_read(DSI_CPU_CMD_3);
} while ((tmp & CFG_CPU_DAT_REQ) && timeout);
if (timeout == 0)
- printf("DSI write data to the packet data buffer not done.\n");
+ LCD_MIPI_LOG("DSI write data to the packet data buffer not done.\n");
send_data = 0;
}
lv_udelay(50);
} while ((tmp & CFG_CPU_CMD_REQ) && timeout);
if (0 == timeout) {
- printf("DSI send out packet maybe failed. \n");
+ LCD_MIPI_LOG("DSI send out packet maybe failed. \n");
return -1;
}
if(mipi_info->split_enable) {
if(( 0 != (mipi_info->width & 0x1)) || (0 != (mipi_info->lane_number & 0x1))){
- printf("warning:Invalid split config(lane = %d, width = %d)\n",
+ LCD_MIPI_LOG("warning:Invalid split config(lane = %d, width = %d)\n",
mipi_info->lane_number, mipi_info->width);
}
width = mipi_info->width >> 1;
rgb_mode = 0;
break;
default:
- printf("dsi_config_cmd_mode :unsupported rgb format!\n");
+ LCD_MIPI_LOG("dsi_config_cmd_mode :unsupported rgb format!\n");
bpp = 24;
rgb_mode = 0;
}
uint32_t crc, loop;
int ret = 0;
- //printf("%d cmd will be write \n", count);
+ //LCD_MIPI_LOG("%d cmd will be write \n", count);
if(NULL == dsi_ctx) {
- printf("dsi_write_cmd_array : Invalid param\n");
+ LCD_MIPI_LOG("dsi_write_cmd_array : Invalid param\n");
return -1;
}
len += 6;
break;
default:
- printf("data type not supported 0x%8x\n",type);
+ LCD_MIPI_LOG("data type not supported 0x%8x\n",type);
break;
}
uint32_t i, rx_reg, timeout, tmp, packet,
data_pointer, byte_count;
- //printf("%d cmds will be write\n", count);
+ //LCD_MIPI_LOG("%d cmds will be write\n", count);
if(NULL == dsi_ctx) {
- printf("Invalid param\n");
+ LCD_MIPI_LOG("Invalid param\n");
return -1;
}
tmp = lcd_dsi_read(DSI_IRQ_ST);
} while (((tmp & IRQ_RX_PKT) == 0) && timeout);
if (0 == timeout) {
- printf("dsi didn't receive packet, irq status 0x%x\n", tmp);
+ LCD_MIPI_LOG("dsi didn't receive packet, irq status 0x%x\n", tmp);
return -1;
}
if (tmp & IRQ_RX_TRG3)
- printf("not defined package is received\n");
+ LCD_MIPI_LOG("not defined package is received\n");
if (tmp & IRQ_RX_TRG2)
- printf("ACK package is received\n");
+ LCD_MIPI_LOG("ACK package is received\n");
if (tmp & IRQ_RX_TRG1)
- printf("TE trigger is received\n");
+ LCD_MIPI_LOG("TE trigger is received\n");
if (tmp & IRQ_RX_ERR) {
tmp = lcd_dsi_read(DSI_RX_PKT_HDR_0);
- printf("ACK with error report (0x%x)", tmp);
+ LCD_MIPI_LOG("ACK with error report (0x%x)", tmp);
}
packet = lcd_dsi_read(DSI_RX_PKT_ST_0);
rx_reg = lcd_dsi_read(DSI_RX_PKT_CTRL);
} while (rx_reg & CFG_RX_PKT_RD_REQ && count);
if ( 0 == count)
- printf("read Rx packet FIFO error\n");
+ LCD_MIPI_LOG("read Rx packet FIFO error\n");
parameter[i - data_pointer] = rx_reg & 0xff;
}
switch (parameter[0]) {
case DSI_ACK_ERR_RESP:
- printf("Acknowledge with error report\n");
+ LCD_MIPI_LOG("Acknowledge with error report\n");
break;
case DSI_EOTP:
- printf("End of Transmission packet\n");
+ LCD_MIPI_LOG("End of Transmission packet\n");
break;
case DSI_GEN_READ1_RESP:
case DSI_DCS_READ1_RESP:
dbuf->data_type = parameter[0];
dbuf->length = (parameter[2] << 8) | parameter[1];
memcpy(dbuf->data, ¶meter[4], dbuf->length);
- printf("read %d data: 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", dbuf->length,
+ LCD_MIPI_LOG("read %d data: 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", dbuf->length,
parameter[4], parameter[5], parameter[6], parameter[7], parameter[8]);
break;
}
} else {
dphy_config->lane_num = dsi_ctx->mipi_info.lane_number;
}
- printf("dphy_lane_num:%d", dphy_config->lane_num);
+ LCD_MIPI_LOG("dphy_lane_num:%d", dphy_config->lane_num);
dphy_config->status = DPHY_STATUS_UNINIT;
#if 0
lane_number = dsi_ctx->mipi_info.lane_number >> 1;
else
lane_number = dsi_ctx->mipi_info.lane_number;
- printf("lane_num:%d",lane_number);
+ LCD_MIPI_LOG("lane_num:%d",lane_number);
dsi_enable_lptx_lanes(asr_dsi_lane[lane_number]);
dsi_enable_eotp(dsi_ctx->mipi_info.eotp_enable);
}
if(0 != (reg & (IRQ_PHY_FIFO_UNDERRUN |IRQ_REQ_CNT_ERR | IRQ_VPN_REQ_PHY_DLY_ERR |
IRQ_VPN_BF_UNDERRUN_ERR | IRQ_VPN_REQ_ARB_DLY_ERR | IRQ_VPN_BF_OVERRUN_ERR |
IRQ_VPN_TIMING_ERR | IRQ_VPN_BF_FULL | IRQ_CPN_BF_FULL))){
- printf("DSI error: 0x%x!\n", reg);
+ LCD_MIPI_LOG("DSI error: 0x%x!\n", reg);
}
}
// uint32_t reg;
if(NULL == half_clk) {
- printf("dsi_set_bitclk : Invalid param! \n");
+ LCD_MIPI_LOG("dsi_set_bitclk : Invalid param! \n");
return 0;
}
#if 0
}
}
- printf("need bitclk:%d, real bitclk:%d. (parent: %d, div:%d, half:%d) \n",bit_clk,
+ LCD_MIPI_LOG("need bitclk:%d, real bitclk:%d. (parent: %d, div:%d, half:%d) \n",bit_clk,
best_real_clk, parent[best_id], best_div, best_half);
__set_bitclk(best_id, best_div-1);
*half_clk = best_half;
uint32_t real_clk;
lcd_phy_pll2_fc(pll_vco);
reg = get_pll2_vco_freq();
- printf("pll2 set = %d, get = %d\n", pll_vco, reg);
+ LCD_MIPI_LOG("pll2 set = %d, get = %d\n", pll_vco, reg);
__set_bitclk(6, HARD_DIVIDOR - 1);
*half_clk = 0;
real_clk = reg * 1000 / 2 / HARD_DIVIDOR;
- printf("need bitclk:%d, real bitclk:%d. (parent: %d, div:%d, half:%d)\n",bit_clk,
+ LCD_MIPI_LOG("need bitclk:%d, real bitclk:%d. (parent: %d, div:%d, half:%d)\n",bit_clk,
real_clk, pll_vco/2, HARD_DIVIDOR, 0);
return real_clk;
uint32_t half_clk = 0;
if(NULL == mipi_info){
- printf("lcd_dsi_init : Invalid param\n");
+ LCD_MIPI_LOG("lcd_dsi_init : Invalid param\n");
return -1;
}
/*used for assert mode*/
if(DSI_STATUS_UNINIT != dsi_ctx->status){
- printf("lcd_dsi_init : dsi has been initialized! \n");
+ LCD_MIPI_LOG("lcd_dsi_init : dsi has been initialized! \n");
return 0;
}
struct s_dsi_ctx* dsi_ctx = &g_dsi_ctx;
if(DSI_STATUS_INIT != dsi_ctx->status){
- printf("Invalid dsi status\n");
+ LCD_MIPI_LOG("Invalid dsi status\n");
return -1;
}
int lcd_dsi_update(int32_t work_mode)
{
- printf("lcd_dsi_update, workmode: %d \n", work_mode);
+ LCD_MIPI_LOG("lcd_dsi_update, workmode: %d \n", work_mode);
struct s_dsi_ctx* dsi_ctx = &g_dsi_ctx;
if(work_mode != dsi_ctx->work_mode){
struct s_dsi_ctx* dsi_ctx = &g_dsi_ctx;
if(DSI_STATUS_INIT != dsi_ctx->status){
- printf("Invalid dsi status");
+ LCD_MIPI_LOG("Invalid dsi status");
return -1;
}
dsi_ctx->mipi_info.width = width;
int lcd_dsi_before_refresh(void)
{
struct s_dsi_ctx* dsi_ctx = &g_dsi_ctx;
+ LCD_MIPI_LOG("lcd_dsi_before_refresh:%d \n",dsi_ctx->mipi_info.work_mode);
if(DSI_STATUS_INIT != dsi_ctx->status){
- printf("Invalid dsi status \n");
+ LCD_MIPI_LOG("Invalid dsi status \n");
return -1;
}
if(dsi_ctx->mipi_info.work_mode == DSI_MODE_CMD){
struct s_dsi_ctx* dsi_ctx = &g_dsi_ctx;
if(DSI_STATUS_INIT != dsi_ctx->status){
- printf("asr_dsi_suspend : Invalid dsi status \n");
+ LCD_MIPI_LOG("asr_dsi_suspend : Invalid dsi status \n");
return -1;
}
struct s_dsi_ctx* dsi_ctx = &g_dsi_ctx;
if(DSI_STATUS_INIT != dsi_ctx->status){
- printf("asr_dsi_resume : Invalid dsi status \n");
+ LCD_MIPI_LOG("asr_dsi_resume : Invalid dsi status \n");
return -1;
}
{
int i;
for(i=0; i<0x1f0; i+=16){
- printf("dsi (0x%x): 0x%x, 0x%x, 0x%x, 0x%x \n",
+ LCD_MIPI_LOG("dsi (0x%x): 0x%x, 0x%x, 0x%x, 0x%x \n",
i, lcd_dsi_read(i),
lcd_dsi_read(i+4),
lcd_dsi_read(i+8),
struct s_dsi_ctx* dsi_ctx = &g_dsi_ctx;
if((NULL == dsi_ctx) || (NULL == cmds)){
- printf("lcd_dsi_write_cmds : Invalid param \n");
+ LCD_MIPI_LOG("lcd_dsi_write_cmds : Invalid param \n");
return -1;
}
if(DSI_STATUS_INIT != dsi_ctx->status){
- printf("lcd_dsi_write_cmds : Invalid dsi status \n");
+ LCD_MIPI_LOG("lcd_dsi_write_cmds : Invalid dsi status \n");
return -1;
}
struct s_dsi_ctx* dsi_ctx = &g_dsi_ctx;
if(DSI_STATUS_INIT != dsi_ctx->status){
- printf("err : lcd_dsi_after_refresh : Invalid dsi status\n");
+ LCD_MIPI_LOG("err : lcd_dsi_after_refresh : Invalid dsi status\n");
return -1;
}
struct s_dsi_ctx* dsi_ctx = &g_dsi_ctx;
if(NULL == cmds) {
- printf("lcd_dsi_read_cmds : Invalid param \n");
+ LCD_MIPI_LOG("lcd_dsi_read_cmds : Invalid param \n");
return -1;
}
if(DSI_STATUS_INIT != dsi_ctx->status) {
- printf("lcd_dsi_read_cmds : Invalid dsi status \n");
+ LCD_MIPI_LOG("lcd_dsi_read_cmds : Invalid dsi status \n");
return -1;
}
struct s_dsi_ctx* dsi_ctx = &g_dsi_ctx;
if(DSI_STATUS_INIT != dsi_ctx->status){
- printf("asr_dsi_test_mode : Invalid dsi status \n");
+ LCD_MIPI_LOG("asr_dsi_test_mode : Invalid dsi status \n");
return -1;
}
-#include "lv_drv_conf.h"
+#include "lv_drv_conf_CUSTOM.h"
#if USE_HX3918
#include <stdio.h>
int ir_wear = 0;//红外佩戴状态
int cap_wear = 1;//电容佩戴状态
char is_open_sar = 1;//是否打开sar检测
-void hal_gh30x_int_handler(uint32_t *process_data);
+
void HX3918_close(void);
static void hx3918_en_gpio_init(void)
{
}
void Hx3918_Init(void)
{
+ //char data[100]= {0};
+ //int len = 0;
Timer0_Switch(1);
static bool register_dev_flag = false;
if(!register_dev_flag)
hx3918_prox_init();
#endif
hx3918_init(WEAR_MODE);//打开佩戴检测
+ //mfp_config(uart4_pin_mfp_cfgs);
+ uart4_debug();
+ gps_uart_send_data(3,"UART4:1111!!!!!!!\n",sizeof("UART4:1111!!!!!!!\n"));
+ // while(1)
+ // {
+ // len =gps_uart_recv_data(3,data,10);
+ // gps_uart_send_data(3,data,10);
+ // HX3918_LOG("UART4:len:%d str:%s",len,data);
+ // //gps_uart_send_data(3,"UART4:1111!!!!!!!\n",sizeof("UART4:1111!!!!!!!\n"));
+ // }
}
uint8_t get_hx3918_id(void)
#if USE_HX3918
#include "../../lv_drivers/indev/HX3918/hx3918.h"
#endif
+#if USE_WMM300
+#include "../../lv_drivers/indev/WMM300/whale_algo.h"
+#endif
#if USE_ACNT180
#include "../../lv_drivers/indev/ACNT180.h"
#elif USE_ACNT117
{
#if USE_HX3918
return HX3918_result_get_wear_status();
+#elif USE_WMM300
+ return wmm300_result_get_wear_status();
#else
return 1;
#endif
#if USE_HX3918
hx3918_hr_bp_bo_value_clear();
#endif
+#if USE_WMM300
+ wmm300_hr_bp_bo_value_clear();
+#endif
#if USE_GH3018
gh3018_hr_bp_bo_value_clear();
#endif
#if USE_HX3918
hx3918_measure_hr_start();
#endif
+#if USE_WMM300
+ wmm300_measure_hr_start();
+#endif
#if USE_GH3018
gh3018_measure_hr_start();
#endif
#if USE_HX3918
hx3918_measure_bo_start();
#endif
+#if USE_WMM300
+ wmm300_measure_bo_start();
+#endif
#if USE_GH3018
gh3018_measure_bo_start();
#endif
#if USE_HX3918
hx3918_measure_stop();
#endif
+#if USE_WMM300
+ wmm300_measure_stop();
+#endif
#if USE_GH3018
gh3018_measure_stop();
#endif
#if USE_HX3918
hx3918_hr_bp_bo_value_get(hr, bp_high, bp_low, bo);
#endif
+#if USE_WMM300
+ wmm300_hr_bp_bo_value_get(hr, bp_high, bp_low, bo);
+#endif
#if USE_GH3018
gh3018_hr_bp_bo_value_get(hr, bp_high, bp_low, bo);
#endif
return get_gh3018_id();
#elif USE_HX3918
return get_hx3918_id();
-
+#elif USE_WMM300
+ return whale_check_chip();
#else
return 0;
gh3018_measure_hr_start();
#elif USE_HX3918
hx3918_measure_hr_start();
+#elif USE_WMM300
+ wmm300_measure_hr_start();
#else
return;
#endif
#if USE_HX3918
HX3918_ID,
#endif
+#if USE_WMM300
+ WMM300_ID,
+#endif
#if USE_ACNT180
ACNT180_ID,
#endif
cust/bt_sensor_hub/bt_SensorHub.a
cust/bt_sensor_hub/bt_SensorHub_adaptor.a
cust/gps/lib/gps_task.a
- cust/gps/lib/gps_uart.a
+ #cust/gps/lib/gps_uart.a
cust/fit/src/sdknet.a
cust/fit/src/valbase64.a
cust/drivers/tpfw.a
cust/bt_sensor_hub/bt_SensorHub.a
cust/bt_sensor_hub/bt_SensorHub_adaptor.a
cust/gps/lib/gps_task.a
- cust/gps/lib/gps_uart.a
+ #cust/gps/lib/gps_uart.a
cust/fit/src/sdknet.a
cust/fit/src/valbase64.a
cust/drivers/tpfw.a
cust/si24rx/ssp_host.a
cust/si24rx/si24rx_drv.a
cust/HX3918/Gcc_lib_R5_hx3918_hrs_spo2_hrv_20231013_v02a.a
+ cust/WMM300/whale_algo_1031_1.a
cust/gh3018/lib/hbd_communicate_DS5_R5.lib
cust/gh3018/lib/hbd_ctrl_DS5_R5.lib
cust/gh3018/lib/common_cortexR5_armcc-5.06u4.lib
cust/bt_sensor_hub/bt_SensorHub.a
cust/bt_sensor_hub/bt_SensorHub_adaptor.a
cust/gps/lib/gps_task.a
- cust/gps/lib/gps_uart.a
+ #cust/gps/lib/gps_uart.a
cust/fit/src/sdknet.a
cust/fit/src/valbase64.a
cust/drivers/tpfw.a
cust/si24rx/ssp_host.a
cust/si24rx/si24rx_drv.a
cust/HX3918/Gcc_lib_R5_hx3918_hrs_spo2_hrv_20231013_v02a.a
+ cust/WMM300/whale_algo_1031_1.a
cust/gh3018/lib/hbd_communicate_DS5_R5.lib
cust/gh3018/lib/hbd_ctrl_DS5_R5.lib
cust/gh3018/lib/common_cortexR5_armcc-5.06u4.lib
cust/bt_sensor_hub/bt_SensorHub.a
cust/bt_sensor_hub/bt_SensorHub_adaptor.a
cust/gps/lib/gps_task.a
- cust/gps/lib/gps_uart.a
+ #cust/gps/lib/gps_uart.a
cust/fit/src/sdknet.a
cust/fit/src/valbase64.a
cust/drivers/tpfw.a
cust/si24rx/ssp_host.a
cust/si24rx/si24rx_drv.a
cust/HX3918/Gcc_lib_R5_hx3918_hrs_spo2_hrv_20231013_v02a.a
+ cust/WMM300/whale_algo_1031_1.a
cust/gh3018/lib/hbd_communicate_DS5_R5.lib
cust/gh3018/lib/hbd_ctrl_DS5_R5.lib
cust/gh3018/lib/common_cortexR5_armcc-5.06u4.lib
# Package source files, paths not required
PACKAGE_SRC_FILES += gpsnmeaapi.c \
- hal_gps_uart.c
+ hal_gps_uart.c \
+ gps_uart.c
# nmea.c
#define GPS_AP_UART1_BASE 0xD4017000UL
#define GPS_AP_UART2_BASE 0xD4018000UL
#define GPS_AP_UART3_BASE 0xD401F000UL
+#define GPS_AP_UART4_BASE 0xD401F800UL
#define GPS_UART1_IRQ (27)
#define GPS_UART2_IRQ (59)
#define GPS_UART3_IRQ (95)
+#define GPS_UART4_IRQ (34)
#define GPS_UART1_ID 0
#define GPS_UART2_ID 1
#define GPS_UART3_ID 2
+#define GPS_UART4_ID 3
#define GPS_APBC_UART_CLK_RST_APBCLK BIT_0 /* UART APB Bus Clock Enable/Disable */
#define GPS_APBC_UART_CLK_RST_FNCLK BIT_1 /* UART Functional Clock Enable/Disable */
* Register for UART 2*/
#define GPS_APBC_UART3_CLK_RST (GPS_APBC_BASE+0x84) /* 32 bit APBClock Clock/Reset Control
* Register for UART 3, for BT use*/
+#define GPS_APBC_UART4_CLK_RST (GPS_APBC_BASE+0x8C) /* 32 bit APBClock Clock/Reset Control
+ * Register for UART 4, for BT use*/
#define GPS_APBC_UART1_CLK_RST_RST BIT_2 /* UART 1 Reset Generation */
#define GPS_APBC_UART1_CLK_RST_FNCLK BIT_1 /* UART 1 Functional Clock Enable/Disable */
--- /dev/null
+/**
+ * @file gps_uart.c
+ *
+ */
+/*********************
+ * INCLUDES
+ *********************/
+#include <stdlib.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <assert.h>
+#include "mi_api.h"
+#include "gps_uart.h"
+#include "gps_uart_api.h"
+#include "intc.h"
+#include "qspi_dma.h"
+#include "gpsnmeaapi.h"
+
+/*********************
+ * DEFINES
+ *********************/
+#define GPS_VCC_CONTROL (0)
+#define DEBUG_ON 1
+#define DEBUG(fmt,arg...) do{ if(DEBUG_ON) cplog_printf(fmt ,##arg);}while(0)
+
+#define MFPRX_BASE_ADDR (0xD401E000)
+#define MFPRX_GPIO_51 (MFPRX_BASE_ADDR + 0x1A8)
+#define MFPRX_GPIO_52 (MFPRX_BASE_ADDR + 0x1AC)
+#define MFPRX_GPIO_35 (MFPRX_BASE_ADDR + 0x168)
+#define MFPRX_GPIO_36 (MFPRX_BASE_ADDR + 0x16C)
+
+#define MFPRX_GPIO_53 (MFPRX_BASE_ADDR + 0x1B0)
+#define MFPRX_GPIO_54 (MFPRX_BASE_ADDR + 0x1B4)
+
+#define MFPRX_GPIO_71 (MFPRX_BASE_ADDR + 0x1BC)
+#define MFPRX_GPIO_72 (MFPRX_BASE_ADDR + 0x1C0)
+
+#define MODE_X_DIV 16
+
+#define RX_BUF_MAX (8192)
+/**********************
+ * TYPEDEFS
+ **********************/
+typedef void (*TaskHandlerT)(void*);
+/**********************
+ * STATIC PROTOTYPES
+ **********************/
+
+int uartx_rx_hanlder(int id);
+
+/**********************
+ * STATIC VARIABLES
+ **********************/
+int gps_uart_id = GPS_UART2_ID;
+
+static int gps_on = 0;
+
+static char rx_buf_lisr[RX_BUF_MAX];
+static char rx_buf_hisr[RX_BUF_MAX];
+static int rx_buf_w_point=0;
+static int rx_buf_r_point=0;
+
+static gps_uart_cfg uart2_port =
+{
+ GPS_UART2_ID, //port_id
+ 1, //fifo = 1
+ 0, //dma = 0
+ 0, //loopback = 0
+ gps_rx_int, //int_type
+ 0, //highspeed = 0
+ 0, //flowctrl = 0
+ GPS_BAUDRATE_9600, //baudrate = BAUDRATE_115200
+ GPS_DATA_8, //datawidth = DATA_8
+ GPS_PARITY_NONE, //parity = PARITY_NONE
+ (GPS_UartIsrCb)uartx_rx_hanlder,
+ NULL,
+};
+
+static gps_uart_cfg uart3_port =
+{
+ GPS_UART3_ID, //port_id
+ 1, //fifo = 1
+ 0, //dma = 0
+ 0, //loopback = 0
+ gps_rx_int, //int_type
+ 0, //highspeed = 0
+ 0, //flowctrl = 0
+ GPS_BAUDRATE_9600, //GPS_BAUDRATE_9600, //baudrate = BAUDRATE_115200
+ GPS_DATA_8, //datawidth = DATA_8
+ GPS_PARITY_NONE, //parity = PARITY_NONE
+ (GPS_UartIsrCb)uartx_rx_hanlder,
+ NULL,
+};
+
+static gps_uart_cfg uart4_port =
+{
+ GPS_UART4_ID, //port_id
+ 1, //fifo = 1
+ 0, //dma = 0
+ 0, //loopback = 0
+ gps_rx_int, //int_type
+ 0, //highspeed = 0
+ 0, //flowctrl = 0
+ GPS_BAUDRATE_9600, //GPS_BAUDRATE_9600, //baudrate = BAUDRATE_115200
+ GPS_DATA_8, //datawidth = DATA_8
+ GPS_PARITY_NONE, //parity = PARITY_NONE
+ (GPS_UartIsrCb)uartx_rx_hanlder,
+ NULL,
+};
+
+/**********************
+ * MACROS
+ **********************/
+
+/**********************
+ * GLOBAL VARIABLES
+ **********************/
+extern int uart_printf(const char* fmt, ...);
+extern OS_HISR gps_hisr_ref;
+gps_uart_glb_info gps_uart_info[4];
+GPS_UartIsrCb GPS_UartIsrCallback[4][gps_int_max]={NULL, };
+dma_callback_t GPS_UartDmaCallback[4][gps_max_dir]={NULL, };
+uint32 gps_dma_mode = 0;
+
+void gps_uart_callback(void * buffer, UINT16 length)
+{
+ NmeaReceiveProcess(buffer, length);
+}
+
+void gps_ui_delay_us(unsigned int us)
+{
+ int cnt = 50;
+ volatile int i = 0;
+ while(us--) {
+ i = cnt;
+ while(i--);
+ }
+}
+
+static void gps_uart_glb_init(uint32 port_id, uint32 highspeed)
+{
+ uint32 data;
+ switch(port_id)
+ {
+ case GPS_UART1_ID:
+ gps_uart_info[GPS_UART1_ID].base_addr = GPS_AP_UART1_BASE;
+ gps_uart_info[GPS_UART1_ID].apbc_base = GPS_APBC_UART1_CLK_RST;
+ gps_uart_info[GPS_UART1_ID].irq = GPS_UART1_IRQ;
+ gps_uart_info[GPS_UART1_ID].fpga = 0;
+ break;
+ case GPS_UART2_ID:
+ gps_uart_info[GPS_UART2_ID].base_addr = GPS_AP_UART2_BASE;
+ gps_uart_info[GPS_UART2_ID].apbc_base = GPS_APBC_UART2_CLK_RST;
+ gps_uart_info[GPS_UART2_ID].irq = GPS_UART2_IRQ;
+ gps_uart_info[GPS_UART2_ID].fpga = 0;
+ break;
+ case GPS_UART3_ID:
+ gps_uart_info[GPS_UART3_ID].base_addr = GPS_AP_UART3_BASE;
+ gps_uart_info[GPS_UART3_ID].apbc_base = GPS_APBC_UART3_CLK_RST;
+ gps_uart_info[GPS_UART3_ID].irq = GPS_UART3_IRQ;
+ gps_uart_info[GPS_UART3_ID].fpga = 0;
+ break;
+ case GPS_UART4_ID:
+ gps_uart_info[GPS_UART4_ID].base_addr = GPS_AP_UART4_BASE;
+ gps_uart_info[GPS_UART4_ID].apbc_base = GPS_APBC_UART4_CLK_RST;
+ gps_uart_info[GPS_UART4_ID].irq = GPS_UART4_IRQ;
+ gps_uart_info[GPS_UART4_ID].fpga = 0;
+ break;
+ default:
+ break;
+ }
+
+ data = 0;
+ if (highspeed)
+ {
+ data = read32(0xd4051024);
+ data |= 0x100;
+ write32(0xd4051024, data);
+ data &= GPS_APBC_UART_CLK_RST_FNCLKSEL_MASK;
+ data |= (GPS_APBC_UART_CLK_RST_FNCLK | GPS_APBC_UART_CLK_RST_APBCLK);
+ }
+ else
+ {
+ data |= (GPS_APBC_UART_CLK_RST_FNCLK | GPS_APBC_UART_CLK_RST_APBCLK | 0x1 << 4);
+
+ data |= GPS_APBC_UART_CLK_RST_RST;
+ write32 (gps_uart_info[port_id].apbc_base, data);
+
+ gps_ui_delay_us(100);
+
+ data = read32 (gps_uart_info[port_id].apbc_base);
+ data &= ~GPS_APBC_UART_CLK_RST_RST;
+ write32 (gps_uart_info[port_id].apbc_base, data);
+ }
+ return;
+}
+
+
+static void
+gps_uart_base_init (uint32 port_id)
+{
+ volatile uint32 data = 0;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ /* cleanup fifo and interrupts */
+ write32 (uart_test_base + GPS_UART_LCR, 0x0);
+ write32 (uart_test_base + GPS_UART_IER, 0x0);
+ write32 (uart_test_base + GPS_UART_FCR, GPS_UART_FCR_RXSR | GPS_UART_FCR_TXSR);
+
+ /* Clear receive buffer RBR. */
+ data = read32 (GPS_UART_LSR + uart_test_base);
+ while (data & GPS_UART_LSR_DR)
+ {
+ data = read32 (GPS_UART_RBR + uart_test_base);
+ data = read32 (GPS_UART_LSR + uart_test_base);
+ }
+
+ /* Clear modem status register. */
+ data = read32 (GPS_UART_MSR + uart_test_base);
+}
+
+static void
+gps_uart_baudrate (uint32 port_id, uint32 br, uint32 uart_clk)
+{
+ uint32 br_div;
+ volatile uint32 data;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ br_div = uart_clk / 16 / br;
+
+ if (br_div == 0)
+ br_div = 1;
+
+ if(br == GPS_BAUDRATE_3686400)
+ br_div = 1;
+ else if(br == GPS_BAUDRATE_1842000)
+ br_div = 2;
+
+ /* Setup baudrate. 1 stopbit */
+ data = read32 ((GPS_UART_LCR + uart_test_base)) | GPS_UART_LCR_DLAB;
+ data &= ~(GPS_UART_LCR_STB);
+ write32 ((GPS_UART_LCR + uart_test_base), data);
+ write32 ((GPS_UART_DLH + uart_test_base), ((br_div >> 8) & 0xff));
+ data = read32 ((GPS_UART_DLH + uart_test_base));
+ write32 ((GPS_UART_DLL + uart_test_base), (br_div & 0xff));
+
+ /* UART : regular functional */
+ data = read32 ((GPS_UART_LCR + uart_test_base)) & (~GPS_UART_LCR_DLAB);
+ write32 ((GPS_UART_LCR + uart_test_base), data);
+}
+
+static void
+gps_uart_setparity (uint32 port_id, uint32 parity)
+{
+ volatile uint32 data;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ /*Setup Parity */
+ data = read32 ((GPS_UART_LCR + uart_test_base));
+ data &= ~(GPS_UART_LCR_PEN | GPS_UART_LCR_EPS);
+ data |= (parity << 3);
+ write32 ((GPS_UART_LCR + uart_test_base), data);
+}
+
+static void
+gps_uart_setdatawidth (uint32 port_id, uint32 datawidth)
+{
+ volatile uint32 data;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ /*Setup data width */
+ data = read32 ((GPS_UART_LCR + uart_test_base));
+ data &= ~(0x3);
+ data |= (datawidth << 0);
+ write32 ((GPS_UART_LCR + uart_test_base), data);
+}
+
+void
+gps_uart_enable (uint32 port_id, uint32 enable)
+{
+ volatile uint32 data;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ /* UART Unit Enable */
+ data = read32 (GPS_UART_IER + uart_test_base);
+ if (enable)
+ data |= GPS_UART_IER_UUE;
+ else
+ data &= ~GPS_UART_IER_UUE;
+ write32 ((GPS_UART_IER + uart_test_base), data);
+}
+
+static void
+gps_uart_dma_enable (uint32 port_id, uint32 enable)
+{
+ volatile uint32 data;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ /* UART Unit DMA Enable */
+ data = read32 (GPS_UART_IER + uart_test_base);
+ if (enable)
+ data |= GPS_UART_IER_DMAE;
+ else
+ data &= ~GPS_UART_IER_DMAE;
+ write32 ((GPS_UART_IER + uart_test_base), data);
+}
+
+static void
+gps_uart_highspeed_enable (uint32 port_id, uint32 enable)
+{
+ volatile uint32 data;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ /* UART high speed mode Enable */
+ data = read32 (GPS_UART_IER + uart_test_base);
+ if (enable)
+ data |= GPS_UART_IER_HSE;
+ else
+ data &= ~GPS_UART_IER_HSE;
+ write32 ((GPS_UART_IER + uart_test_base), data);
+}
+
+static void
+gps_uart_fifo_control (uint32 port_id, uint32 level, uint32 bwidth, uint32 trailingbyte,
+ uint32 fenable)
+{
+ volatile uint32 data = 0;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ data &= ~0xFF;
+ data |= (1 << 3); //Transmitter Interrupt Level<p>0 = Interrupt/DMA request when FIFO is half empty<p>1 = Interrupt/DMA request when FIFO is empty
+ data |= (level << 6) | (bwidth << 5) | (trailingbyte << 4) | (fenable);
+ write32 ((GPS_UART_FCR + uart_test_base), data);
+}
+
+void
+gps_uart_clear_receive_fifo (uint32 port_id)
+{
+ volatile uint32 data = 0;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ data = read32(GPS_UART_FCR + uart_test_base);
+ data |= GPS_UART_FCR_FIFO_EN | GPS_UART_FCR_CLEAR_RCVR;
+ write32 ((GPS_UART_FCR + uart_test_base), data);
+}
+
+static void
+gps_uart_clear_transfer_fifo (uint32 port_id)
+{
+ volatile uint32 data = 0;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ data = read32(GPS_UART_FCR + uart_test_base);
+ data |= GPS_UART_FCR_CLEAR_XMIT | GPS_UART_FCR_FIFO_EN;
+ write32 ((GPS_UART_FCR + uart_test_base), data);
+}
+
+static void
+gps_uart_enable_int_out (uint32 port_id, uint32 enable)
+{
+ volatile uint32 data;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+
+ data = read32 (GPS_UART_MCR + uart_test_base);
+ if (enable)
+ data |= GPS_UART_MCR_OUT2;
+ else
+ data &= ~(GPS_UART_MCR_OUT2);
+ write32 ((GPS_UART_MCR + uart_test_base), data);
+}
+
+static void
+gps_uart_enable_loopback (uint32 port_id, uint32 enable)
+{
+ volatile uint32 data;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+
+ data = read32 (GPS_UART_MCR + uart_test_base);
+ if (enable)
+ data |= GPS_UART_MCR_LOOP;
+ else
+ data &= ~(GPS_UART_MCR_LOOP);
+ write32 ((GPS_UART_MCR + uart_test_base), data);
+}
+
+static void
+gps_uart_enable_flowctrl (uint32 port_id, uint32 enable)
+{
+ volatile uint32 data;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ data = read32 (GPS_UART_MCR + uart_test_base);
+ if (enable)
+ data |= BIT_1 | BIT_5;
+ else
+ data &= ~(BIT_1 | BIT_5);
+ write32 ((GPS_UART_MCR + uart_test_base), data);
+}
+
+static void
+gps_uart_enable_all_int (uint32 port_id, uint32 enable)
+{
+ volatile uint32 data;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+
+ data = read32 (GPS_UART_IER + uart_test_base);
+ if (enable)
+ data |= BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
+ else
+ data &= ~(BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4);
+ write32 ((GPS_UART_IER + uart_test_base), data);
+}
+
+static void
+gps_uart_enable_int (uint32 port_id, uint32 enable,uint32 mask)
+{
+ volatile uint32 data;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+
+ data = read32 (GPS_UART_IER + uart_test_base);
+ if (enable)
+ data |= mask;
+ else
+ data &= ~(mask);
+ write32 ((GPS_UART_IER + uart_test_base), data);
+}
+
+void
+gps_uart_enable_RxInt (uint32 port_id, uint32 enable)
+{
+ volatile uint32 data;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+
+ data = read32 (GPS_UART_IER + uart_test_base);
+#ifdef SUPPORT_UART_XXXX
+ if (enable)
+ data |= GPS_UART_IER_RAVIE | GPS_UART_IER_RTOIE | GPS_UART_IER_RLSE | GPS_UART_IER_EORIE;
+ else
+ data &= ~(GPS_UART_IER_RAVIE | GPS_UART_IER_RTOIE | GPS_UART_IER_RLSE | GPS_UART_IER_EORIE);
+#else
+ if (enable)
+ data |= (GPS_UART_IER_RAVIE | GPS_UART_IER_RTOIE);
+ else
+ data &= ~(GPS_UART_IER_RAVIE | GPS_UART_IER_RTOIE);
+#endif
+ write32 ((GPS_UART_IER + uart_test_base), data);
+}
+
+static void
+gps_uart_enable_TxInt (uint32 port_id, uint32 enable)
+{
+ volatile uint32 data;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+
+ data = read32 (GPS_UART_IER + uart_test_base);
+ if (enable)
+ data |= GPS_UART_IER_TIE;
+ else
+ data &= ~(GPS_UART_IER_TIE);
+ write32 ((GPS_UART_IER + uart_test_base), data);
+}
+
+int
+gps_uart_putc (uint32 port_id, int c)
+{
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ while ((read32 (uart_test_base + GPS_UART_LSR) & GPS_UART_LSR_THRE) == 0);
+ write32 (uart_test_base + GPS_UART_THR, c);
+
+ return c;
+}
+
+void
+gps_uart_puts (uint32 port_id, char *s)
+{
+ while (*s != '\0')
+ {
+ gps_uart_putc (port_id, *s);
+ s++;
+ }
+
+ return;
+}
+
+static uint32 tick2ms(uint32 after, uint32 before){
+ uint32 Tick, Us = 0;
+ Tick = (after >= before)? after - before : ((0xffffffff - before)+after);
+ Us = ((Tick)>(0xFFFFFFFF/15625)?((Tick/512)*15625+((Tick%512)*15625)/512):(((uint32)(Tick)*15625)/512));
+ return Us/1000;
+}
+
+int
+gps_uart_getc_ex (uint32 port_id, uint32 ms)
+{
+ uint32 data,err = 0;
+ uint32 uart_test_base;
+ uint32 T1, T2;
+ T1 = timerCountRead(1);
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ while (1)
+ {
+ data = read32 (uart_test_base + GPS_UART_LSR) & 0xFF;
+
+ if (data &(GPS_UART_LSR_ERR | GPS_UART_LSR_BI | GPS_UART_LSR_FE |
+ GPS_UART_LSR_PE | GPS_UART_LSR_OE))
+ {
+ err = 1;
+ }
+
+ if (data & GPS_UART_LSR_DR)
+ break;
+
+ T2 = timerCountRead(1);
+ if(tick2ms(T2, T1) > ms)
+ break;
+
+ }
+ if(err)
+ {
+ read32 (uart_test_base + GPS_UART_RBR);
+ return GPS_UART_DATA_ERROR;
+ }
+ else
+ return read32 (uart_test_base + GPS_UART_RBR);
+}
+
+int
+gps_uart_getc (uint32 port_id)
+{
+ uint32 data,err = 0;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ while (1)
+ {
+ data = read32 (uart_test_base + GPS_UART_LSR) & 0xFF;
+ if (data &(GPS_UART_LSR_ERR | GPS_UART_LSR_BI | GPS_UART_LSR_FE |
+ GPS_UART_LSR_PE | GPS_UART_LSR_OE))
+ {
+ //fatal_printf("uart get err: 0x%08X\n", data);
+ err = 1;
+ }
+ if (data & GPS_UART_LSR_DR)
+ break;
+ }
+ if(err)
+ {
+ read32 (uart_test_base + GPS_UART_RBR);
+ return GPS_UART_DATA_ERROR;
+ }
+ else
+ return read32 (uart_test_base + GPS_UART_RBR);
+}
+
+static uint32 gps_uart_get_base_addr(uint32 port_id)
+{
+ uint32 uart_base = 0xCCCCCCCC;
+
+ switch(port_id)
+ {
+ case GPS_UART1_ID:
+ uart_base = GPS_AP_UART1_BASE;
+ break;
+ case GPS_UART2_ID:
+ uart_base = GPS_AP_UART2_BASE;
+ break;
+ case GPS_UART3_ID:
+ uart_base = GPS_AP_UART3_BASE;
+ break;
+ default:
+ break;
+ }
+ return uart_base;
+}
+
+static uint32 gps_uart_get_IntStatus(uint32 port_id)
+{
+ return read32(gps_uart_get_base_addr(port_id) + GPS_UART_IIR);
+}
+
+static BOOL gps_uart_is_RxInt(uint32 port_id)
+{
+ if(gps_uart_get_IntStatus(port_id) & (GPS_UART_IIR_TOD | GPS_UART_IIR_RDI))
+ return TRUE;
+ else
+ return FALSE;
+}
+
+static void gps_uart_mask_RxInt(uint32 port_id, uint32 enable)
+{
+ uint32 int_no = INTCGetIntVirtualNum(gps_uart_info[port_id].irq);
+
+ gps_uart_enable_RxInt(port_id, enable);
+ if(enable)
+ INTCEnable(int_no);
+ else
+ INTCDisable(int_no);
+}
+
+static int gps_uart_flush(uint32 port_id)
+{
+ #define GPS_UART_FLUSH_TIMEOUT_CN 0x2000
+ int i=0;
+ uint32 uart_base, data;
+
+ uart_base = gps_uart_get_base_addr(port_id);
+
+ do{
+ data = read32(uart_base + GPS_UART_LSR);
+ if(!(data & 0x1) && (data & 0x40))
+ break;
+
+ if(data & 0x1)
+ read32(uart_base + GPS_UART_RBR);
+
+ i++;
+ if(i > GPS_UART_FLUSH_TIMEOUT_CN)
+ break;
+ }while(1);
+
+ if(i >= GPS_UART_FLUSH_TIMEOUT_CN )
+ return 1;
+ else
+ return 0;
+}
+
+static int
+gps_uart_getchar_noblock (uint32 port_id)
+{
+ uint32 data;
+
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+ while (1)
+ {
+ data = read32 (uart_test_base + GPS_UART_LSR) & 0xFF;
+ if (data &
+ (GPS_UART_LSR_ERR | GPS_UART_LSR_BI | GPS_UART_LSR_FE | GPS_UART_LSR_PE |
+ GPS_UART_LSR_OE))
+ {
+ //trace ("uart get err: 0x%08X\n", data);
+ return GPS_UART_DATA_ERROR;
+ }
+ if (data & GPS_UART_LSR_DR)
+ break;
+ else
+ return GPS_UART_NONE_DATA;
+ }
+
+ return read32 (uart_test_base + GPS_UART_RBR);
+}
+
+static void
+gps_uart_basic_init (gps_uart_cfg *port)
+{
+ gps_uart_glb_init(port->port_id, port->highspeed);
+
+ //Disable uart in case its enabled
+ gps_uart_enable (port->port_id, FALSE);
+ // intialize uart
+ gps_uart_base_init (port->port_id);
+
+ //configure uart
+ gps_uart_setparity (port->port_id,port->parity);
+ gps_uart_setdatawidth (port->port_id, port->datawidth);
+ gps_uart_baudrate (port->port_id, port->baudrate, GPS_APBC_UART_CLK_FNCLK_REGULAR);
+
+ //enable fifo
+ if (port->dma){
+ gps_uart_fifo_control (port->port_id, 1, 0, 1, TRUE);
+ gps_uart_dma_enable (port->port_id, TRUE);
+ }
+ else if((port->fifo) && !(port->dma)){
+ gps_uart_fifo_control (port->port_id, 1, 0, 0, TRUE);
+ gps_uart_dma_enable (port->port_id, FALSE);
+ }
+ else{
+ gps_uart_fifo_control (port->port_id, 0, 0, 0, FALSE);
+ gps_uart_dma_enable (port->port_id, FALSE);
+ }
+
+ gps_uart_enable_all_int (port->port_id, FALSE);
+ gps_uart_enable_int_out (port->port_id, FALSE);
+
+ if (port->highspeed)
+ gps_uart_highspeed_enable (port->port_id, TRUE);
+ else
+ gps_uart_highspeed_enable (port->port_id, FALSE);
+
+ if (port->loopback)
+ gps_uart_enable_loopback (port->port_id, TRUE);
+ else
+ gps_uart_enable_loopback (port->port_id, FALSE);
+
+ if (port->flowctrl)
+ gps_uart_enable_flowctrl (port->port_id, TRUE);
+ else
+ gps_uart_enable_flowctrl (port->port_id, FALSE);
+
+ //enable uart
+ gps_uart_enable (port->port_id, TRUE);
+ return;
+}
+
+static void gps_dma_transfer_request(gps_uartdir dir, uint32 port_id, uint8 *buf, uint32 size)
+{
+ DMA_CMDx_T cmd;
+ uint32 uart_test_base;
+
+ uart_test_base = gps_uart_info[port_id].base_addr;
+
+ if(dir == gps_uart_rx){
+ cmd.value = 0;
+ cmd.bits.IncSrcAddr = 0;
+ cmd.bits.IncTrgAddr = 1;
+ cmd.bits.FlowTrg = 0;
+ cmd.bits.FlowSrc = 1;
+ cmd.bits.Width = 1;
+ cmd.bits.MaxBurstSize = 1;
+ cmd.bits.Length = size;
+
+ dma_set_reg_nf((uint32)(uart_test_base + GPS_UART_RBR), (uint32_t)buf, &cmd,DMA_DEV_UART1_RX_CH);
+ dma_xfer_start(DMA_DEV_UART1_RX_CH);
+ dma_stop_irq_en(DMA_DEV_UART1_RX_CH);
+ }
+ else{
+ cmd.value = 0;
+ cmd.bits.IncSrcAddr = 1;
+ cmd.bits.IncTrgAddr = 0;
+ cmd.bits.FlowTrg = 1;
+ cmd.bits.FlowSrc = 0;
+ cmd.bits.Width = 1;
+ cmd.bits.MaxBurstSize = 1;
+ cmd.bits.Length = size;
+
+ dma_set_reg_nf((uint32)buf, (uint32)(uart_test_base + GPS_UART_THR), &cmd,DMA_DEV_UART1_TX_CH);
+ dma_xfer_start(DMA_DEV_UART1_TX_CH);
+ dma_stop_irq_en(DMA_DEV_UART1_TX_CH);
+ }
+
+ return;
+}
+
+uint32 gps_uart_send_data(uint32 port_id, uint8 *data, uint32 size)
+{
+ uint32 i = 0;
+
+ if(gps_dma_mode > 0){
+ uint32 len;
+
+ while(size){
+ if(size > DMA_MDMA_NF_XFER_SIZE)
+ len = DMA_MDMA_NF_XFER_SIZE;
+ else
+ len = size;
+
+ gps_dma_transfer_request(gps_uart_tx, port_id, data, len);
+
+ if(len == DMA_MDMA_NF_XFER_SIZE)
+ size -= DMA_MDMA_NF_XFER_SIZE;
+ else
+ size = 0;
+ }
+ }
+ else{
+ while(size){
+ if(size > GPS_UART_FIFO_DEPTH){
+ for(i=0 ; i< GPS_UART_FIFO_DEPTH; i++){
+ gps_uart_putc(port_id,*data);
+ data++;
+ }
+ size = size - GPS_UART_FIFO_DEPTH;
+ }
+ else{
+ for(i=0 ; i< size; i++){
+ gps_uart_putc(port_id, *data);
+ data++;
+ }
+ size = 0;
+ }
+ }
+ }
+
+ return size;
+}
+
+uint32 gps_uart_recv_data(uint32 port_id, uint8 *pbuf, uint32 size)
+{
+ uint32 i = 0;
+ char c;
+ uint32 flag = 0;
+
+ if(gps_dma_mode > 0){
+ uint32 len;
+
+ while(size){
+ if(size > DMA_MDMA_NF_XFER_SIZE)
+ len = DMA_MDMA_NF_XFER_SIZE;
+ else
+ len = size;
+
+ gps_dma_transfer_request(gps_uart_rx, port_id, pbuf, len);
+
+ if(len == DMA_MDMA_NF_XFER_SIZE)
+ size -= DMA_MDMA_NF_XFER_SIZE;
+ else
+ size = 0;
+ }
+ }
+ else{
+ for(i=0; i<size; i++){
+ //gps_ui_delay_us(10);
+ c = gps_uart_getc(port_id);
+ //fatal_printf("receive data:0x%x\r\n", c);
+ if(c == '$')
+ {
+ flag = 1;
+ memset(pbuf,0,size);
+ i=0;
+ }
+ pbuf[i] = c;
+ if(c == '\n' && flag == 1)
+ {
+ break;
+ }
+ }
+
+ size = 0;//fatal_printf("size:%d\r\n", size);
+ }
+ return size;
+}
+
+void gps_uart_set_baudrate(uint32 port_id, uint32 rate)
+{
+ gps_uart_baudrate (port_id, rate, GPS_APBC_UART_CLK_FNCLK_REGULAR);
+}
+
+static void GPS_UartIsrEntry(INTC_InterruptInfo interruptInfo)
+{
+ uint32 status;
+ uint32 port_id;
+ uint32 uart_base;
+
+ //fatal_printf("file:%s,function:%s,line:%d,int_no:%d.\r\n", __FILE__,__func__,__LINE__, interruptInfo);
+
+ if(interruptInfo == 268)
+ port_id = 2;
+ else if(interruptInfo == 232)
+ port_id = 1;
+ else if(interruptInfo == 200)
+ port_id = 0;
+ else if(interruptInfo == 207)
+ port_id = GPS_UART4_ID;
+ else
+ return;
+
+
+ uart_base = gps_uart_info[port_id].base_addr;
+ status = REG32(uart_base + GPS_UART_IIR);
+ if((status&GPS_UART_IIR_RDI)||(status&GPS_UART_IIR_TOD)){
+ if(GPS_UartIsrCallback[port_id][gps_rx_int])
+ GPS_UartIsrCallback[port_id][gps_rx_int](port_id);
+ }
+ else if(status & GPS_UART_IIR_THRI){
+ if(GPS_UartIsrCallback[port_id][gps_tx_int])
+ GPS_UartIsrCallback[port_id][gps_tx_int](port_id);
+ }
+ else if(status & GPS_UART_IIR_RDI)
+ {
+ //raw_uart_log("uart error happened!\r\n");
+ }
+ else{
+
+ }
+ return ;
+}
+
+static int GPS_UartRxDmaCallBackEntry(uint32 val)
+{
+ //raw_uart_log("file:%s,function:%s,line:%d\r\n", __FILE__,__func__,__LINE__);
+ if(GPS_UartDmaCallback[1][gps_uart_rx])
+ GPS_UartDmaCallback[1][gps_uart_rx](1);
+ return 0;
+}
+
+static int GPS_UartTxDmaCallBackEntry(uint32 val)
+{
+ //raw_uart_log("file:%s,function:%s,line:%d\r\n", __FILE__,__func__,__LINE__);
+ if(GPS_UartDmaCallback[1][gps_uart_tx])
+ GPS_UartDmaCallback[1][gps_uart_tx](1);
+ return 0;
+}
+
+
+static void
+gps_uart_irq_init (gps_uart_cfg *port)
+{
+ uint32 int_no;
+
+ if(port->int_tpye){
+ gps_dma_mode = 0;
+ //raw_uart_log("uart irq num:%d\r\n", gps_uart_info[port->port_id].irq);
+ /*config uart interrupt*/
+ //INTCPhase2Init();
+ int_no = INTCGetIntVirtualNum(gps_uart_info[port->port_id].irq);
+ INTCConfigure(int_no, INTC_IRQ, INTC_HIGH_LEVEL);
+ INTCBind(int_no,GPS_UartIsrEntry);
+ INTCEnable(int_no);
+ if (port->int_tpye == gps_all_int)
+ {
+ GPS_UartIsrCallback[port->port_id][gps_rx_int] = port->rx_callback;
+ GPS_UartIsrCallback[port->port_id][gps_tx_int] = port->tx_callback;
+ gps_uart_enable_all_int (port->port_id ,TRUE);
+ gps_uart_enable_int_out (port->port_id, TRUE);
+ }
+ else if (port->int_tpye == gps_rx_int)
+ {
+ GPS_UartIsrCallback[port->port_id][gps_rx_int] = port->rx_callback;
+ GPS_UartIsrCallback[port->port_id][gps_tx_int] = NULL;
+ gps_uart_enable_RxInt(port->port_id, TRUE);
+ gps_uart_enable_int_out (port->port_id, TRUE);
+ }
+ else if(port->int_tpye == gps_tx_int)
+ {
+ GPS_UartIsrCallback[port->port_id][gps_rx_int] = NULL;
+ GPS_UartIsrCallback[port->port_id][gps_tx_int] = port->tx_callback;
+ gps_uart_enable_TxInt(port->port_id, TRUE);
+ gps_uart_enable_int_out (port->port_id, TRUE);
+ }
+ else
+ {
+ gps_uart_enable_all_int (port->port_id, FALSE);
+ gps_uart_enable_int_out (port->port_id, FALSE);
+ }
+ }
+ else if(port->dma){
+ gps_dma_mode = 1;
+ //raw_uart_log("uart work at dma mode.\r\n");
+ if(port->rx_callback){
+ GPS_UartDmaCallback[port->port_id][gps_uart_rx] = port->rx_callback;
+ dma_irq_callback_register(GPS_UartRxDmaCallBackEntry, DMA_DEV_UART1_RX_CH);
+ dma_map_device_to_channel(DMA_REQ_UART2_RX, DMA_DEV_UART1_RX_CH);
+ set_user_aligment(DMA_DEV_UART1_RX_CH);
+ dma_set_mode(DMA_MODE_NONFETCH, DMA_DEV_UART1_RX_CH);
+ }
+ if(port->tx_callback){
+ GPS_UartDmaCallback[port->port_id][gps_uart_tx] = port->tx_callback;
+ dma_irq_callback_register(GPS_UartTxDmaCallBackEntry, DMA_DEV_UART1_TX_CH);
+ dma_map_device_to_channel(DMA_REQ_UART2_TX, DMA_DEV_UART1_TX_CH);
+ set_user_aligment(DMA_DEV_UART1_TX_CH);
+ dma_set_mode(DMA_MODE_NONFETCH, DMA_DEV_UART1_TX_CH);
+ }
+ }
+ else{
+ gps_dma_mode = 0;
+ //raw_uart_log("uart work at polling mode.\r\n");
+ }
+
+ return;
+}
+
+
+void
+gps_uart_init (gps_uart_cfg *port)
+{
+ uint32 int_no;
+
+ gps_uart_basic_init(port);
+
+ if(port->int_tpye){
+ gps_dma_mode = 0;
+
+ int_no = INTCGetIntVirtualNum(gps_uart_info[port->port_id].irq);
+ INTCConfigure(int_no, INTC_IRQ, INTC_HIGH_LEVEL);
+ INTCBind(int_no,GPS_UartIsrEntry);
+ INTCEnable(int_no);
+ if (port->int_tpye == gps_all_int)
+ {
+ GPS_UartIsrCallback[port->port_id][gps_rx_int] = port->rx_callback;
+ GPS_UartIsrCallback[port->port_id][gps_tx_int] = port->tx_callback;
+ gps_uart_enable_all_int (port->port_id ,TRUE);
+ gps_uart_enable_int_out (port->port_id, TRUE);
+ }
+ else if (port->int_tpye == gps_rx_int)
+ {
+ GPS_UartIsrCallback[port->port_id][gps_rx_int] = port->rx_callback;
+ GPS_UartIsrCallback[port->port_id][gps_tx_int] = NULL;
+ gps_uart_enable_RxInt(port->port_id, TRUE);
+ gps_uart_enable_int_out (port->port_id, TRUE);
+ }
+ else if(port->int_tpye == gps_tx_int)
+ {
+ GPS_UartIsrCallback[port->port_id][gps_rx_int] = NULL;
+ GPS_UartIsrCallback[port->port_id][gps_tx_int] = port->tx_callback;
+ gps_uart_enable_TxInt(port->port_id, TRUE);
+ gps_uart_enable_int_out (port->port_id, TRUE);
+ }
+ else
+ {
+ gps_uart_enable_all_int (port->port_id, FALSE);
+ gps_uart_enable_int_out (port->port_id, FALSE);
+ }
+ }
+ else if(port->dma){
+ gps_dma_mode = 1;
+ //raw_uart_log("uart work at dma mode.\r\n");
+ if(port->rx_callback){
+ GPS_UartDmaCallback[port->port_id][gps_uart_rx] = port->rx_callback;
+ dma_irq_callback_register(GPS_UartRxDmaCallBackEntry, DMA_DEV_UART1_RX_CH);
+ dma_map_device_to_channel(DMA_REQ_UART2_RX, DMA_DEV_UART1_RX_CH);
+ set_user_aligment(DMA_DEV_UART1_RX_CH);
+ dma_set_mode(DMA_MODE_NONFETCH, DMA_DEV_UART1_RX_CH);
+ }
+ if(port->tx_callback){
+ GPS_UartDmaCallback[port->port_id][gps_uart_tx] = port->tx_callback;
+ dma_irq_callback_register(GPS_UartTxDmaCallBackEntry, DMA_DEV_UART1_TX_CH);
+ dma_map_device_to_channel(DMA_REQ_UART2_TX, DMA_DEV_UART1_TX_CH);
+ set_user_aligment(DMA_DEV_UART1_TX_CH);
+ dma_set_mode(DMA_MODE_NONFETCH, DMA_DEV_UART1_TX_CH);
+ }
+ }
+ else{
+ gps_dma_mode = 0;
+ //raw_uart_log("uart work at polling mode.\r\n");
+ }
+
+ return;
+}
+
+//@zym W70 used uart2
+//@zym W71 W203 H82 used uart3 53/54
+//@zym W61_V2 A90 H80 used uart3 35/36
+// void gps_uart3_pin_config(void)
+// {
+// uint32 data;
+// //isChip_3601S return true for 3603
+// #if CONFIG_BOARD_SIMWARE_W61_V2 || CONFIG_BOARD_SIMWARE_A90 || CONFIG_BOARD_SIMWARE_A90SH || CONFIG_BOARD_SIMWARE_H80 || CONFIG_BOARD_SIMWARE_W352
+// if(0)
+// #elif CONFIG_BOARD_SIMWARE_H82 || CONFIG_BOARD_SIMWARE_H85
+// if(1)
+// #else
+// if(isChip_3601S())
+// #endif
+// {
+// data = read32(MFPRX_GPIO_53);
+// data = data & ~(0x7) | 0x2;
+// write32(MFPRX_GPIO_53,data);
+
+// data = read32(MFPRX_GPIO_54);
+// data = data & ~(0x7) | 0x2;
+// write32(MFPRX_GPIO_54,data);
+// }
+// else
+// {
+// data = read32(MFPRX_GPIO_35);
+// data = data & ~(0x7) | 0x3;
+// write32(MFPRX_GPIO_35,data);
+
+// data = read32(MFPRX_GPIO_36);
+// data = data & ~(0x7) | 0x3;
+// write32(MFPRX_GPIO_36,data);
+// }
+// }
+
+void gps_uart2_pin_config(void)
+{
+
+ uint32 data;
+
+ data = read32(MFPRX_GPIO_51);
+ data = data & ~(0x7) | 0x1;
+ write32(MFPRX_GPIO_51,data);
+
+ data = read32(MFPRX_GPIO_52);
+ data = data & ~(0x7) | 0x1;
+ write32(MFPRX_GPIO_52,data);
+
+ gps_uart_init(&uart2_port);
+}
+//#include "board.h"
+ #include "../../../cust/bsp/inc/mfpr_api.h"
+//#include "../../../mfpr_api.h"
+static uint32_t uart4_pin_mfp_cfgs[] = {
+ MFP_REG(GPIO_04) | MFP_AF4 | MFP_DRIVE_MEDIUM | MFP_PULL_HIGH | MFP_SLEEP_DIR | MFP_LPM_EDGE_NONE,
+ MFP_REG(GPIO_05) | MFP_AF4 | MFP_DRIVE_MEDIUM | MFP_PULL_HIGH | MFP_SLEEP_DIR | MFP_LPM_EDGE_NONE,
+
+ MFP_EOC
+};
+void gps_uart4_pin_config(void)
+{
+ //uint32 data;
+
+ // data = read32(MFPRX_GPIO_71);
+ // data = data & ~(0x7) | 0x1;
+ // write32(MFPRX_GPIO_71,data);
+
+ // data = read32(MFPRX_GPIO_72);
+ // data = data & ~(0x7) | 0x1;
+ // write32(MFPRX_GPIO_72,data);
+ mfp_config(uart4_pin_mfp_cfgs);
+}
+
+void uart2_debug(void)
+{
+
+ gps_uart_id = GPS_UART2_ID;
+
+ gps_uart2_pin_config();
+
+ gps_uart_init(&uart2_port);
+ gps_uart_clear_receive_fifo(uart2_port.port_id);
+
+ DEBUG("uart2_debug %d\n", gps_uart_id);
+}
+
+void uart3_debug(void)
+{
+
+ gps_uart_id = GPS_UART3_ID;
+ gps_uart3_pin_config();
+
+ gps_uart_init(&uart3_port);
+ gps_uart_clear_receive_fifo(uart3_port.port_id);
+ DEBUG("uart3_debug%d\n", gps_uart_id);
+}
+
+void uart4_debug(void)
+{
+ gps_uart_id = GPS_UART4_ID;
+ gps_uart4_pin_config();
+
+ gps_uart_init(&uart4_port);
+ gps_uart_clear_receive_fifo(uart4_port.port_id);
+ DEBUG("uart4_debug%d\n", gps_uart_id);
+}
+
+int uartx_rx_hanlder(int id)
+{
+
+ uint32 data,err_data,err = 0;
+ uint32 uart_base;
+ gps_uart_enable_RxInt(id,0);
+
+ uart_base = gps_uart_info[id].base_addr;
+ data = read32 (uart_base + GPS_UART_LSR) & 0xFF;
+
+ if(data & GPS_UART_LSR_DR)
+ {
+ do
+ {
+ rx_buf_lisr[rx_buf_w_point] = read32 (uart_base + GPS_UART_RBR);
+ rx_buf_w_point++;
+ if(rx_buf_w_point >= RX_BUF_MAX)
+ {
+ rx_buf_w_point=0;
+ }
+
+ data = read32 (uart_base + GPS_UART_LSR) & 0xFF;
+ } while ((data & GPS_UART_LSR_DR) && (rx_buf_w_point != rx_buf_r_point));
+ }
+ //else
+ // return UART_DATA_ERROR;
+ gps_uart_enable_RxInt(id,1);
+ //gps_uart_callback(p_buf, uart_rx_len);
+ if(gps_hisr_ref == NULL){
+ DEBUG("=================>func=%s,gps_hisr_ref=NULL\r\n",__func__);
+ return;
+ }
+ ASSERT(OS_Activate_HISR(&gps_hisr_ref)== OS_SUCCESS);
+ return 0;
+}
+
+void gps_hisr_function(void)
+{
+ UINT32 cpsr;
+ int readsize = 0, len = 0;
+ readsize = (rx_buf_w_point - rx_buf_r_point + RX_BUF_MAX) % RX_BUF_MAX;
+ if(readsize == 0)
+ {
+ return;
+ }
+
+ if(rx_buf_r_point < rx_buf_w_point)
+ {
+ memcpy(rx_buf_hisr, &rx_buf_lisr[rx_buf_r_point], readsize);
+
+ //cpsr = disableInterrupts();
+ gps_uart_enable_RxInt(gps_uart_id,0);
+ rx_buf_r_point += readsize;
+ //restoreInterrupts(cpsr);
+ gps_uart_enable_RxInt(gps_uart_id,1);
+ }
+ else
+ {
+ if((rx_buf_r_point + readsize) >= RX_BUF_MAX)
+ {
+ len = RX_BUF_MAX - rx_buf_r_point;
+
+ memcpy(rx_buf_hisr, &rx_buf_lisr[rx_buf_r_point], len);
+ memcpy(rx_buf_hisr + len, &rx_buf_lisr[0], readsize - len);
+
+ //cpsr = disableInterrupts();
+ gps_uart_enable_RxInt(gps_uart_id,0);
+ rx_buf_r_point = readsize - len;
+ //restoreInterrupts(cpsr);
+ gps_uart_enable_RxInt(gps_uart_id,1);
+ }
+ else
+ {
+ memcpy(rx_buf_hisr, &rx_buf_lisr[rx_buf_r_point], readsize);
+
+ //cpsr = disableInterrupts();
+ gps_uart_enable_RxInt(gps_uart_id,0);
+ rx_buf_r_point += readsize;
+ //restoreInterrupts(cpsr);
+ gps_uart_enable_RxInt(gps_uart_id,1);
+ }
+
+ }
+ gps_uart_callback(rx_buf_hisr,readsize);
+ return;
+}
+
void lcd_backlight_ctrl(int level)
{
#if USE_LCD_PANEL_ICNA3310_MIPI
+ int level_map_table[6] = {0, 51, 102, 153, 204, 255};
extern void isca3310_set_display_brightness(int level);
- isca3310_set_display_brightness(level);
+ isca3310_set_display_brightness(level_map_table[level]);
+ return;
+#endif
+#if USE_LCD_PANEL_CO5300_MIPI
+ int level_map_table[6] = {0, 51, 102, 153, 204, 255};
+ extern void isca3310_set_display_brightness(int level);
+ isca3310_set_display_brightness(level_map_table[level]);
+ return;
+#endif
+#if USE_LCD_PANEL_RM69330_MIPI
+ int level_map_table[6] = {0, 51, 102, 153, 204, 255};
+ extern void rm69330_set_display_brightness(int level);
+ rm69330_set_display_brightness(level_map_table[level]);
+ return;
+#endif
+
+#if USE_LCD_PANEL_SH8601_MIPI
+ int level_map_table[6] = {0, 51, 102, 153, 204, 255};
+ extern void sh8601_set_display_brightness(int level);
+ sh8601_set_display_brightness(level_map_table[level]);
return;
#endif
#include "lv_drivers/display/st7567_spi.h"
#include "lv_drivers/display/rm69330_mipi.h"
#include "lv_drivers/display/icna3310_mipi.h"
+#include "lv_drivers/display/co5300_mipi.h"
#include "lv_drivers/display/ili9806e_mipi.h"
#include "lv_drivers/display/gc9a01_spi.h"
#include "lv_drivers/indev/ft6x36.h"
#if USE_HX3918
#include "lv_drivers/indev/HX3918/hx3918.h"
#endif
+#if USE_WMM300
+#include "lv_drivers/indev/WMM300/whale_algo.h"
+#endif
#if USE_ACNT180
#include "lv_drivers/indev/ACNT180.h"
#elif USE_ACNT117
TASK_HANDLE *gui_task_id;
/*supported panels */
static struct crane_panel_t *panels[] = {
-#if 0
+#if 1
#if USE_LCD_PANEL_ST7735S_SPI_POC
&st7735s_spi,
#elif USE_LCD_PANEL_ST7567_SPI_4WIRE_1LANE_1IF
&rm69330_mipi,
#elif USE_LCD_PANEL_ICNA3310_MIPI
&icna3310_mipi,
+#elif USE_LCD_PANEL_CO5300_MIPI
+ &co5300_mipi,
#elif USE_LCD_PANEL_ILI9806E_MIPI
&ili9806e_mipi,
#else
#if USE_CRANE_LCD_MIPI
unsigned int lcd_mipi_mfp_cfgs[] = {
MFP_REG(GPIO_26) | MFP_AF2 | MFP_DRIVE_MEDIUM | MFP_PULL_HIGH | MFP_SLEEP_DIR | MFP_LPM_EDGE_NONE, /*RST*/
+ MFP_REG(GPIO_19) | MFP_AF0 | MFP_DRIVE_MEDIUM | MFP_PULL_HIGH | MFP_SLEEP_DIR | MFP_LPM_EDGE_NONE,
+ MFP_REG(GPIO_23) | MFP_AF0 | MFP_DRIVE_MEDIUM | MFP_PULL_HIGH | MFP_SLEEP_DIR | MFP_LPM_EDGE_NONE,
#if LCD_TE_ENABLE
MFP_REG(GPIO_25) | MFP_AF2 | MFP_DRIVE_MEDIUM | MFP_PULL_LOW | MFP_SLEEP_DIR | MFP_LPM_EDGE_NONE, /*TE*/
#endif
#endif
static struct lcd_info_t *lcd_info_detect[]= {
-#if USE_LCD_PANEL_GC9A01_SPI_WATCH
- &gc9a01_lcd_spi_3_2_info,
-#endif
-#if USE_LCD_PANEL_ST9A01_4_1_SPI_POC
- &st9a01_lcd_spi_4_1_info,
-#endif
-#if USE_LCD_PANEL_GC9C01_3_2_SPI_POC
- &gc9c01_lcd_spi_3_2_info,
-#endif
-#if USE_LCD_PANEL_GC9307_4_1_SPI_POC
- &gc9307_lcd_spi_4_1_info,
-#endif
-#if USE_LCD_PANEL_ST7789V2_SPI_WATCH
-#if DRV_PROJECT_Z5_K6
- &st7789v2_lcd_spi_4_1_info,
-#elif DRV_PROJECT_Z5_K7 || DRV_PROJECT_Z5_Z12 || DRV_PROJECT_Z5_I7 || DRV_PROJECT_Z5_HA_K7 || DRV_PROJECT_Z5_DS_Z12XW_QCB
- &st7789v2_lcd_spi_3_2_info,
-#endif
+#if USE_CRANE_LCD_MIPI_CMD
+ &lcd_info,
+#else
+ #if USE_LCD_PANEL_GC9A01_SPI_WATCH
+ &gc9a01_lcd_spi_3_2_info,
+ #endif
+ #if USE_LCD_PANEL_ST9A01_4_1_SPI_POC
+ &st9a01_lcd_spi_4_1_info,
+ #endif
+ #if USE_LCD_PANEL_GC9C01_3_2_SPI_POC
+ &gc9c01_lcd_spi_3_2_info,
+ #endif
+ #if USE_LCD_PANEL_GC9307_4_1_SPI_POC
+ &gc9307_lcd_spi_4_1_info,
+ #endif
+ #if USE_LCD_PANEL_ST7789V2_SPI_WATCH
+ #if DRV_PROJECT_Z5_K6
+ &st7789v2_lcd_spi_4_1_info,
+ #elif DRV_PROJECT_Z5_K7 || DRV_PROJECT_Z5_Z12 || DRV_PROJECT_Z5_I7 || DRV_PROJECT_Z5_HA_K7 || DRV_PROJECT_Z5_DS_Z12XW_QCB
+ &st7789v2_lcd_spi_3_2_info,
+ #endif
+ #endif
#endif
};
#if 0
int cnt, i;
struct crane_panel_t *p;
-
+
+
lcdc_pwr_onoff(1);
if (lcdc_init(&lcd_info) < 0) {
goto error;
struct crane_panel_t *p;
lcdc_pwr_onoff(1);
+
cnt = ARRAY_SIZE(lcd_info_detect);
lv_udelay(1*1000*1000);
return p;
}
}
+
#if 0
//if detect fail, return first
lcd_interface_info = lcd_info_detect[0];
}
#endif
+
+
static int gui_init(void)
{
lcd = lcd_init();
#if USE_HX3918
Hx3918_Init();
#endif
+#if USE_WMM300
+ Wmm300_Init();
+#endif
#if USE_ACNT180
hal_acnt180_init();
#elif USE_ACNT117
--- /dev/null
+#ifndef _CO5300_MIPI_H
+#define _CO5300_MIPI_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "msfota_hal_drv_conf.h"
+
+#if USE_LCD_PANEL_CO5300_MIPI
+
+#include "msfota_halsoc_lcdc.h"
+
+extern struct crane_panel_t co5300_mipi;
+
+#endif /* USE_LCD_PANEL_CO5300_MIPI */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* _CO5300_MIPI_H */
extern void GuilinLcdBackLightLevelRecord(UINT8 level);
void msfota_lcd_backlight_ctrl(int level)
{
-#if USE_LCD_PANEL_ICNA3310_MIPI
+#if USE_LCD_PANEL_ICNA3310_MIPI||USE_LCD_PANEL_CO5300_MIPI
extern void isca3310_set_display_brightness(int level);
isca3310_set_display_brightness(level);
return;
#include "msfota_st7567_spi.h"
#include "msfota_rm69330_mipi.h"
#include "msfota_icna3310_mipi.h"
+#include "msfota_co5300_mipi.h"
#include "msfota_ili9806e_mipi.h"
#include "msfota_hal_board.h"
#include "msfota_gc9c01_spi.h"
&rm69330_mipi,
#elif USE_LCD_PANEL_ICNA3310_MIPI
&icna3310_mipi,
+#elif USE_LCD_PANEL_CO5300_MIPI
+ &co5300_mipi,
#elif USE_LCD_PANEL_ILI9806E_MIPI
&ili9806e_mipi,
#elif USE_LCD_PANEL_GC9C01_3_2_SPI_POC