diff --git a/APP_Framework/Applications/app_test/Kconfig b/APP_Framework/Applications/app_test/Kconfig index 91c24c2e7..bffda4b64 100644 --- a/APP_Framework/Applications/app_test/Kconfig +++ b/APP_Framework/Applications/app_test/Kconfig @@ -29,5 +29,9 @@ menu "test app" config USER_TEST_SEMC bool "Config test semc sdram" default n + + config USER_TEST_LCD + bool "Config test lcd device" + default n endif endmenu diff --git a/APP_Framework/Applications/app_test/Makefile b/APP_Framework/Applications/app_test/Makefile index 29f6341cc..8b6ac8332 100644 --- a/APP_Framework/Applications/app_test/Makefile +++ b/APP_Framework/Applications/app_test/Makefile @@ -12,6 +12,10 @@ ifeq ($(CONFIG_USER_TEST_SEMC),y) SRC_FILES += test_extsram.c endif +ifeq ($(CONFIG_USER_TEST_LCD),y) + SRC_FILES += +endif + ifeq ($(CONFIG_ADD_XIZI_FETURES),y) include $(KERNEL_ROOT)/compiler.mk endif @@ -19,7 +23,7 @@ endif include $(KERNEL_ROOT)/.config ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) include $(APPDIR)/Make.defs - CSRCS += test_extsram.c + CSRCS += test_extsram.c test_lcd.c include $(APPDIR)/Application.mk endif diff --git a/APP_Framework/Applications/app_test/test_extsram.c b/APP_Framework/Applications/app_test/test_extsram.c index 332488868..09b5316ce 100755 --- a/APP_Framework/Applications/app_test/test_extsram.c +++ b/APP_Framework/Applications/app_test/test_extsram.c @@ -20,6 +20,7 @@ */ #include +#include "stdio.h" /* parameters for sram peripheral */ // /* stm32f4 Bank3:0X68000000 */ @@ -52,7 +53,7 @@ int ExtsramTest(void) #endif /* write data */ - printf("Writing the %ld bytes data, waiting....", SRAM_SIZE); + printf("Writing the %ld bytes data, waiting....\n", SRAM_SIZE); start_time = PrivGetTickTime(); for (i = 0; i < SRAM_SIZE / data_width; i++) { @@ -90,7 +91,7 @@ int ExtsramTest(void) data = *(volatile uint32_t *)(SRAM_BANK_ADDR + i * data_width); if (data != 0x55555555) { - printf("SRAM test failed!"); + printf("SRAM test failed!\n"); break; } #endif diff --git a/APP_Framework/Applications/app_test/test_lcd.c b/APP_Framework/Applications/app_test/test_lcd.c new file mode 100755 index 000000000..9133f9628 --- /dev/null +++ b/APP_Framework/Applications/app_test/test_lcd.c @@ -0,0 +1,522 @@ +/**************************************************************************** + * apps/examples/fb/fb_main.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#ifdef ADD_NUTTX_FETURES + +#ifdef CONFIG_K210_LCD + +#include "nuttx/arch.h" +#include "nuttx/lcd/lt768.h" +#include "nuttx/lcd/lt768_lib.h" +#include "nuttx/lcd/k210_lcd.h" + +void LcdDemo(void) +{ + int x1 = 50, y1 = 50, x2 = LCD_XSIZE_TFT - 50, y2 = LCD_YSIZE_TFT - 50; + + Main_Image_Start_Address(LCD_START_ADDR); + Main_Image_Width(LCD_XSIZE_TFT); + Main_Window_Start_XY(0, 0); + Canvas_Image_Start_address(LCD_START_ADDR); + Canvas_image_width(LCD_XSIZE_TFT); + Active_Window_XY(0, 0); + Active_Window_WH(LCD_XSIZE_TFT, LCD_YSIZE_TFT); + up_mdelay(10); + Canvas_Image_Start_address(LCD_START_ADDR); + + for(int i = 0; i < 3; i++) + { + x1 = 50; + y1 = 50; + x2 = LCD_XSIZE_TFT - 50; + y2 = LCD_YSIZE_TFT - 50; + syslog(LOG_NOTICE, "Disp_demo %d (%d,%d - %d,%d)\n", i, x1, y1, x2, y2); + LT768_DrawSquare_Fill(x1, y1, x2, y2, Red); + up_mdelay(2000); + x1 += 20; + y1 += 20; + x2 -= 20; + y2 -= 20; + LT768_DrawSquare_Fill(x1, y1, x2, y2, Green); + up_mdelay(2000); + x1 += 20; + y1 += 20; + x2 -= 20; + y2 -= 20; + LT768_DrawSquare_Fill(x1, y1, x2, y2, Blue); + up_mdelay(2000); + } +} + +#else + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/**************************************************************************** + * Preprocessor Definitions + ****************************************************************************/ + +#define NCOLORS 6 +#define TEST_FB_DEV "/dev/fb0" + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct fb_state_s +{ + int fd; + struct fb_videoinfo_s vinfo; + struct fb_planeinfo_s pinfo; +#ifdef CONFIG_FB_OVERLAY + struct fb_overlayinfo_s oinfo; +#endif + FAR void *fbmem; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const char g_default_fbdev[] = TEST_FB_DEV; + +/* Violet-Blue-Green-Yellow-Orange-Red */ + +static const uint32_t g_rgb24[NCOLORS] = +{ + RGB24_VIOLET, RGB24_BLUE, RGB24_GREEN, + RGB24_YELLOW, RGB24_ORANGE, RGB24_RED +}; + +static const uint16_t g_rgb16[NCOLORS] = +{ + RGB16_VIOLET, RGB16_BLUE, RGB16_GREEN, + RGB16_YELLOW, RGB16_ORANGE, RGB16_RED +}; + +static const uint8_t g_rgb8[NCOLORS] = +{ + RGB8_VIOLET, RGB8_BLUE, RGB8_GREEN, + RGB8_YELLOW, RGB8_ORANGE, RGB8_RED +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * draw_rect + ****************************************************************************/ + +static void draw_rect32(FAR struct fb_state_s *state, + FAR struct fb_area_s *area, int color) +{ + FAR uint32_t *dest; + FAR uint8_t *row; + int x; + int y; + + row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * area->y; + for (y = 0; y < area->h; y++) + { + dest = ((FAR uint32_t *)row) + area->x; + for (x = 0; x < area->w; x++) + { + *dest++ = g_rgb24[color]; + } + + row += state->pinfo.stride; + } +} + +static void draw_rect16(FAR struct fb_state_s *state, + FAR struct fb_area_s *area, int color) +{ + FAR uint16_t *dest; + FAR uint8_t *row; + int x; + int y; + + row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * area->y; + for (y = 0; y < area->h; y++) + { + dest = ((FAR uint16_t *)row) + area->x; + for (x = 0; x < area->w; x++) + { + *dest++ = g_rgb16[color]; + } + + row += state->pinfo.stride; + } +} + +static void draw_rect8(FAR struct fb_state_s *state, + FAR struct fb_area_s *area, int color) +{ + FAR uint8_t *dest; + FAR uint8_t *row; + int x; + int y; + + row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * area->y; + for (y = 0; y < area->h; y++) + { + dest = row + area->x; + for (x = 0; x < area->w; x++) + { + *dest++ = g_rgb8[color]; + } + + row += state->pinfo.stride; + } +} + +static void draw_rect1(FAR struct fb_state_s *state, + FAR struct fb_area_s *area, int color) +{ + FAR uint8_t *pixel; + FAR uint8_t *row; + uint8_t color8 = (color & 1) == 0 ? 0 : 0xff; + uint8_t lmask; + uint8_t rmask; + int startx; + int endx; + int x; + int y; + + /* Calculate the framebuffer address of the first row to draw on */ + + row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * area->y; + + /* Calculate the start byte position rounding down so that we get the + * first byte containing any part of the pixel sequence. Then calculate + * the last byte position with a ceil() operation so it includes any final + * final pixels of the sequence. + */ + + startx = (area->x >> 3); + endx = ((area->x + area->w + 6) >> 3); + + /* Calculate a mask on the first and last bytes of the sequence that may + * not be completely filled with pixel. + */ + + lmask = 0xff << (8 - (area->x & 7)); + rmask = 0xff >> ((area->x + area->w - 1) & 7); + + /* Now draw each row, one-at-a-time */ + + for (y = 0; y < area->h; y++) + { + /* 'pixel' points to the 1st pixel the next row */ + + pixel = row + startx; + + /* Special case: The row is less no more than one byte wide */ + + if (startx == endx) + { + uint8_t mask = lmask | rmask; + + *pixel = (*pixel & mask) | (color8 & ~mask); + } + else + { + /* Special case the first byte of the row */ + + *pixel = (*pixel & lmask) | (color8 & ~lmask); + pixel++; + + /* Handle all middle bytes in the row */ + + for (x = startx + 1; x < endx; x++) + { + *pixel++ = color8; + } + + /* Handle the final byte of the row */ + + *pixel = (*pixel & rmask) | (color8 & ~rmask); + } + + row += state->pinfo.stride; + } +} + +static void draw_rect(FAR struct fb_state_s *state, + FAR struct fb_area_s *area, int color) +{ +#ifdef CONFIG_FB_UPDATE + int ret; +#endif + + switch (state->pinfo.bpp) + { + case 32: + draw_rect32(state, area, color); + break; + + case 16: + draw_rect16(state, area, color); + break; + + case 8: + default: + draw_rect8(state, area, color); + break; + + case 1: + draw_rect1(state, area, color); + break; + } + +#ifdef CONFIG_FB_UPDATE + ret = ioctl(state->fd, FBIO_UPDATE, + (unsigned long)((uintptr_t)area)); + if (ret < 0) + { + int errcode = errno; + fprintf(stderr, "ERROR: ioctl(FBIO_UPDATE) failed: %d\n", + errcode); + } +#endif +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * fb_main + ****************************************************************************/ + +int test_lcd(int argc, FAR char *argv[]) +{ + FAR const char *fbdev = g_default_fbdev; + struct fb_state_s state; + struct fb_area_s area; + int nsteps; + int xstep; + int ystep; + int width; + int height; + int color; + int x; + int y; + int ret; + + /* There is a single required argument: The path to the framebuffer + * driver. + */ + + if (argc == 2) + { + fbdev = argv[1]; + } + else if (argc != 1) + { + fprintf(stderr, "ERROR: Single argument required\n"); + fprintf(stderr, "USAGE: %s []\n", argv[0]); + return EXIT_FAILURE; + } + + /* Open the framebuffer driver */ + + state.fd = open(fbdev, O_RDWR); + if (state.fd < 0) + { + int errcode = errno; + fprintf(stderr, "ERROR: Failed to open %s: %d\n", fbdev, errcode); + return EXIT_FAILURE; + } + + /* Get the characteristics of the framebuffer */ + + ret = ioctl(state.fd, FBIOGET_VIDEOINFO, + (unsigned long)((uintptr_t)&state.vinfo)); + if (ret < 0) + { + int errcode = errno; + fprintf(stderr, "ERROR: ioctl(FBIOGET_VIDEOINFO) failed: %d\n", + errcode); + close(state.fd); + return EXIT_FAILURE; + } + printf("2022-10-14 Mr. Wang commit LCD\n"); + printf("VideoInfo:\n"); + printf(" fmt: %u\n", state.vinfo.fmt); + printf(" xres: %u\n", state.vinfo.xres); + printf(" yres: %u\n", state.vinfo.yres); + printf(" nplanes: %u\n", state.vinfo.nplanes); + +#ifdef CONFIG_FB_OVERLAY + printf("noverlays: %u\n", state.vinfo.noverlays); + + /* Select the first overlay, which should be the composed framebuffer */ + + ret = ioctl(state.fd, FBIO_SELECT_OVERLAY, 0); + if (ret < 0) + { + int errcode = errno; + fprintf(stderr, "ERROR: ioctl(FBIO_SELECT_OVERLAY) failed: %d\n", + errcode); + close(state.fd); + return EXIT_FAILURE; + } + + /* Get the first overlay information */ + + state.oinfo.overlay = 0; + ret = ioctl(state.fd, FBIOGET_OVERLAYINFO, + (unsigned long)((uintptr_t)&state.oinfo)); + if (ret < 0) + { + int errcode = errno; + fprintf(stderr, "ERROR: ioctl(FBIOGET_OVERLAYINFO) failed: %d\n", + errcode); + close(state.fd); + return EXIT_FAILURE; + } + + printf("OverlayInfo (overlay 0):\n"); + printf(" fbmem: %p\n", state.oinfo.fbmem); + printf(" fblen: %lu\n", (unsigned long)state.oinfo.fblen); + printf(" stride: %u\n", state.oinfo.stride); + printf(" overlay: %u\n", state.oinfo.overlay); + printf(" bpp: %u\n", state.oinfo.bpp); + printf(" blank: %u\n", state.oinfo.blank); + printf("chromakey: 0x%08" PRIx32 "\n", state.oinfo.chromakey); + printf(" color: 0x%08" PRIx32 "\n", state.oinfo.color); + printf(" transp: 0x%02x\n", state.oinfo.transp.transp); + printf(" mode: %u\n", state.oinfo.transp.transp_mode); + printf(" area: (%u,%u) => (%u,%u)\n", + state.oinfo.sarea.x, state.oinfo.sarea.y, + state.oinfo.sarea.w, state.oinfo.sarea.h); + printf(" accl: %" PRIu32 "\n", state.oinfo.accl); + +#endif + + ret = ioctl(state.fd, FBIOGET_PLANEINFO, + (unsigned long)((uintptr_t)&state.pinfo)); + if (ret < 0) + { + int errcode = errno; + fprintf(stderr, "ERROR: ioctl(FBIOGET_PLANEINFO) failed: %d\n", + errcode); + close(state.fd); + return EXIT_FAILURE; + } + + printf("PlaneInfo (plane 0):\n"); + printf(" fbmem: %p\n", state.pinfo.fbmem); + printf(" fblen: %lu\n", (unsigned long)state.pinfo.fblen); + printf(" stride: %u\n", state.pinfo.stride); + printf(" display: %u\n", state.pinfo.display); + printf(" bpp: %u\n", state.pinfo.bpp); + + /* Only these pixel depths are supported. viinfo.fmt is ignored, only + * certain color formats are supported. + */ + + if (state.pinfo.bpp != 32 && state.pinfo.bpp != 16 && + state.pinfo.bpp != 8 && state.pinfo.bpp != 1) + { + fprintf(stderr, "ERROR: bpp=%u not supported\n", state.pinfo.bpp); + close(state.fd); + return EXIT_FAILURE; + } + + /* mmap() the framebuffer. + * + * NOTE: In the FLAT build the frame buffer address returned by the + * FBIOGET_PLANEINFO IOCTL command will be the same as the framebuffer + * address. mmap(), however, is the preferred way to get the framebuffer + * address because in the KERNEL build, it will perform the necessary + * address mapping to make the memory accessible to the application. + */ + + state.fbmem = mmap(NULL, state.pinfo.fblen, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_FILE, state.fd, 0); + if (state.fbmem == MAP_FAILED) + { + int errcode = errno; + fprintf(stderr, "ERROR: ioctl(FBIOGET_PLANEINFO) failed: %d\n", + errcode); + close(state.fd); + return EXIT_FAILURE; + } + + printf("Mapped FB: %p\n", state.fbmem); + + /* Draw some rectangles */ + + nsteps = 2 * (NCOLORS - 1) + 1; + xstep = state.vinfo.xres / nsteps; + ystep = state.vinfo.yres / nsteps; + width = state.vinfo.xres; + height = state.vinfo.yres; + + for (x = 0, y = 0, color = 0; + color < NCOLORS; + x += xstep, y += ystep, color++) + { + area.x = x; + area.y = y; + area.w = width; + area.h = height; + + printf("%2d: (%3d,%3d) (%3d,%3d)\n", + color, area.x, area.y, area.w, area.h); + + draw_rect(&state, &area, color); + usleep(500 * 1000); + + width -= (2 * xstep); + height -= (2 * ystep); + } + + printf("Test finished\n"); + munmap(state.fbmem, state.pinfo.fblen); + close(state.fd); + return EXIT_SUCCESS; +} + +void LcdDemo(void) +{ + test_lcd(1, NULL); +} + +#endif +#endif diff --git a/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c b/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c index c28dc262c..da1dff600 100755 --- a/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c +++ b/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c @@ -29,6 +29,7 @@ #ifdef ADD_NUTTX_FETURES #include #include +#include #include "stdio.h" #endif @@ -42,21 +43,47 @@ char tcp_socket_ip[] = {192, 168, 250, 252}; #define lw_error printf #define LWIP_DEMO_TIMES 3 - -/** Create u32_t value from bytes */ -#define LWIP_MAKEU32(a,b,c,d) (((uint32_t)((a) & 0xff) << 24) | \ - ((uint32_t)((b) & 0xff) << 16) | \ - ((uint32_t)((c) & 0xff) << 8) | \ - (uint32_t)((d) & 0xff)) - -#define PP_HTONL(x) ((uint32_t)(x)) -#define LWIP_TARGET_PORT 6000 +#define LWIP_TARGET_PORT 4840 #endif uint16_t tcp_socket_port = LWIP_TARGET_PORT; +char tcp_ip_str[128] = {0}; /******************************************************************************/ -static void TCPSocketRecvTask(void *arg) +void TcpSocketConfigParam(char *ip_str) +{ + int ip1, ip2, ip3, ip4, port = 0; + + if(ip_str == NULL) + { + return; + } + + if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port)) + { + printf("config ip %s port %d\n", ip_str, port); + strcpy(tcp_ip_str, ip_str); + tcp_socket_ip[0] = ip1; + tcp_socket_ip[1] = ip2; + tcp_socket_ip[2] = ip3; + tcp_socket_ip[3] = ip4; + if(port) + tcp_socket_port = port; + return; + } + + if(sscanf(ip_str, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4)) + { + printf("config ip %s\n", ip_str); + tcp_socket_ip[0] = ip1; + tcp_socket_ip[1] = ip2; + tcp_socket_ip[2] = ip3; + tcp_socket_ip[3] = ip4; + strcpy(tcp_ip_str, ip_str); + } +} + +static void TcpSocketRecvTask(void *arg) { int fd = -1, clientfd; int recv_len; @@ -64,15 +91,18 @@ static void TCPSocketRecvTask(void *arg) struct sockaddr_in tcp_addr; socklen_t addr_len; - while(1) { + while(1) + { recv_buf = (char *)malloc(TCP_DEMO_BUF_SIZE); - if (recv_buf == NULL) { + if (recv_buf == NULL) + { lw_error("No memory\n"); continue; } fd = socket(AF_INET, SOCK_STREAM, 0); - if (fd < 0) { + if (fd < 0) + { lw_error("Socket error\n"); free(recv_buf); continue; @@ -83,7 +113,8 @@ static void TCPSocketRecvTask(void *arg) tcp_addr.sin_port = htons(tcp_socket_port); memset(&(tcp_addr.sin_zero), 0, sizeof(tcp_addr.sin_zero)); - if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1) { + if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1) + { lw_error("Unable to bind\n"); close(fd); free(recv_buf); @@ -91,10 +122,11 @@ static void TCPSocketRecvTask(void *arg) } lw_print("tcp bind success, start to receive.\n"); - lw_notice("\n\nLocal Port:%d\n\n", tcp_socket_port); + lw_notice("\nLocal Port:%d\n", tcp_socket_port); // setup socket fd as listening mode - if (listen(fd, 5) != 0 ) { + if (listen(fd, 5) != 0 ) + { lw_error("Unable to listen\n"); close(fd); free(recv_buf); @@ -105,10 +137,13 @@ static void TCPSocketRecvTask(void *arg) clientfd = accept(fd, (struct sockaddr *)&tcp_addr, (socklen_t*)&addr_len); lw_notice("client %s connected\n", inet_ntoa(tcp_addr.sin_addr)); - while(1) { + while(1) + { memset(recv_buf, 0, TCP_DEMO_BUF_SIZE); - recv_len = recvfrom(clientfd, recv_buf, TCP_DEMO_BUF_SIZE, 0, (struct sockaddr *)&tcp_addr, &addr_len); - if(recv_len > 0) { + recv_len = recvfrom(clientfd, recv_buf, TCP_DEMO_BUF_SIZE, 0, + (struct sockaddr *)&tcp_addr, &addr_len); + if(recv_len > 0) + { lw_notice("Receive from : %s\n", inet_ntoa(tcp_addr.sin_addr)); lw_notice("Receive data : %d - %s\n\n", recv_len, recv_buf); } @@ -120,35 +155,39 @@ static void TCPSocketRecvTask(void *arg) free(recv_buf); } -#ifdef ADD_XIZI_FETURES -void TCPSocketRecvTest(int argc, char *argv[]) +void TcpSocketRecvTest(int argc, char *argv[]) { - int result = 0; - - if(argc >= 2) { + if(argc >= 2) + { lw_print("lw: [%s] target ip %s\n", __func__, argv[1]); - if(sscanf(argv[1], "%d.%d.%d.%d:%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3], &tcp_socket_port) == 0) { - sscanf(argv[1], "%d.%d.%d.%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3]); - } + TcpSocketConfigParam(argv[1]); } +#ifdef ADD_XIZI_FETURES lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip); - sys_thread_new("TCPSocketRecvTask", TCPSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); -} -PRIV_SHELL_CMD_FUNCTION(TCPSocketRecvTest, a tcp receive sample, PRIV_SHELL_CMD_MAIN_ATTR); + sys_thread_new("TcpSocketRecvTask", TcpSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); #endif -static void TCPSocketSendTask(void *arg) +#ifdef ADD_NUTTX_FETURES + TcpSocketRecvTask(NULL); +#endif +} +PRIV_SHELL_CMD_FUNCTION(TcpSocketRecvTest, a tcp receive sample, PRIV_SHELL_CMD_MAIN_ATTR); + +static void TcpSocketSendTask(void *arg) { int cnt = LWIP_DEMO_TIMES; int fd = -1; + int ret; char send_msg[128]; + lw_print("2022-10-14 Mr. Wang commit TCP\n"); lw_print("%s start\n", __func__); memset(send_msg, 0, sizeof(send_msg)); fd = socket(AF_INET, SOCK_STREAM, 0); - if (fd < 0) { + if (fd < 0) + { lw_print("Socket error\n"); return; } @@ -156,21 +195,25 @@ static void TCPSocketSendTask(void *arg) struct sockaddr_in tcp_sock; tcp_sock.sin_family = AF_INET; tcp_sock.sin_port = htons(tcp_socket_port); - tcp_sock.sin_addr.s_addr = PP_HTONL(LWIP_MAKEU32(tcp_socket_ip[0], tcp_socket_ip[1], tcp_socket_ip[2], tcp_socket_ip[3])); + tcp_sock.sin_addr.s_addr = inet_addr(tcp_ip_str); + memset(&(tcp_sock.sin_zero), 0, sizeof(tcp_sock.sin_zero)); - if (connect(fd, (struct sockaddr *)&tcp_sock, sizeof(struct sockaddr))) { - lw_print("Unable to connect\n"); + ret = connect(fd, (struct sockaddr *)&tcp_sock, sizeof(struct sockaddr)); + if (ret) + { + lw_print("Unable to connect %s = %d\n", tcp_ip_str, ret); close(fd); return; } - lw_notice("\n\nTarget Port:%d\n\n", tcp_socket_port); + lw_print("TCP connect %s:%d success, start to send.\n", tcp_ip_str, tcp_socket_port); - while (cnt --) { + while (cnt --) + { lw_print("Lwip client is running.\n"); snprintf(send_msg, sizeof(send_msg), "TCP test package times %d\r\n", cnt); - sendto(fd, send_msg, strlen(send_msg), 0, (struct sockaddr*)&tcp_sock, sizeof(struct sockaddr)); + send(fd, send_msg, strlen(send_msg), 0); lw_notice("Send tcp msg: %s ", send_msg); PrivTaskDelay(1000); } @@ -179,32 +222,21 @@ static void TCPSocketSendTask(void *arg) return; } -#ifdef ADD_XIZI_FETURES -void TCPSocketSendTest(int argc, char *argv[]) +void TcpSocketSendTest(int argc, char *argv[]) { - if(argc >= 2) { + if(argc >= 2) + { lw_print("lw: [%s] target ip %s\n", __func__, argv[1]); - if(sscanf(argv[1], "%d.%d.%d.%d:%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3], &tcp_socket_port) == 0) - { - sscanf(argv[1], "%d.%d.%d.%d", &tcp_socket_ip[0], &tcp_socket_ip[1], &tcp_socket_ip[2], &tcp_socket_ip[3]); - } + TcpSocketConfigParam(argv[1]); } +#ifdef ADD_XIZI_FETURES lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip); - sys_thread_new("TCP Socket Send", TCPSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); -} -PRIV_SHELL_CMD_FUNCTION(TCPSocketSendTest, a tcp send sample, PRIV_SHELL_CMD_MAIN_ATTR); + sys_thread_new("Tcp Socket Send", TcpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); #endif - #ifdef ADD_NUTTX_FETURES -void tcp_recv_demo(void) -{ - TCPSocketRecvTask(NULL); -} - -void tcp_send_demo(void) -{ - TCPSocketSendTask(NULL); -} + TcpSocketSendTask(NULL); #endif +} +PRIV_SHELL_CMD_FUNCTION(TcpSocketSendTest, a tcp send sample, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c b/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c index 28eb918cf..62465d4bc 100755 --- a/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c +++ b/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c @@ -31,45 +31,72 @@ #include #define LWIP_DEMO_TIMES 3 -#define LWIP_LOCAL_PORT 6000 +#define LWIP_LOCAL_PORT 4840 #define lw_error printf #define lw_notice printf #define lw_print printf - -/** Create u32_t value from bytes */ -#define LWIP_MAKEU32(a,b,c,d) (((uint32_t)((a) & 0xff) << 24) | \ - ((uint32_t)((b) & 0xff) << 16) | \ - ((uint32_t)((c) & 0xff) << 8) | \ - (uint32_t)((d) & 0xff)) - -#define PP_HTONL(x) ((uint32_t)(x)) - #endif #define UDP_BUF_SIZE 65536 char udp_socket_ip[] = {192, 168, 250, 252}; +char udp_ip_str[128] = {0}; uint16_t udp_socket_port = LWIP_LOCAL_PORT; /*****************************************************************************/ +void UdpSocketConfigParam(char *ip_str) +{ + int ip1, ip2, ip3, ip4, port = 0; + + if(ip_str == NULL) + { + return; + } + + if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port)) + { + printf("config ip %s port %d\n", ip_str, port); + strcpy(udp_ip_str, ip_str); + udp_socket_ip[0] = ip1; + udp_socket_ip[1] = ip2; + udp_socket_ip[2] = ip3; + udp_socket_ip[3] = ip4; + if(port) + udp_socket_port = port; + return; + } + + if(sscanf(ip_str, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4)) + { + printf("config ip %s\n", ip_str); + udp_socket_ip[0] = ip1; + udp_socket_ip[1] = ip2; + udp_socket_ip[2] = ip3; + udp_socket_ip[3] = ip4; + strcpy(udp_ip_str, ip_str); + } +} + static void UdpSocketRecvTask(void *arg) { int fd = -1; char *recv_buf; struct sockaddr_in udp_addr, server_addr; int recv_len; - socklen_t addr_len; - while(1) { + while(1) + { recv_buf = (char *)malloc(UDP_BUF_SIZE); - if(recv_buf == NULL) { + if(recv_buf == NULL) + { lw_error("No memory\n"); continue; } fd = socket(AF_INET, SOCK_DGRAM, 0); - if(fd < 0) { + if(fd < 0) + { lw_error("Socket error\n"); free(recv_buf); continue; @@ -80,25 +107,27 @@ static void UdpSocketRecvTask(void *arg) udp_addr.sin_port = htons(udp_socket_port); memset(&(udp_addr.sin_zero), 0, sizeof(udp_addr.sin_zero)); - if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1) { + if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1) + { lw_error("Unable to bind\n"); close(fd); free(recv_buf); continue; } - lw_notice("UDP bind sucess, start to receive.\n"); + lw_notice("UDP bind success, start to receive.\n"); lw_notice("\n\nLocal Port:%d\n\n", udp_socket_port); - while(1) { + while(1) + { memset(recv_buf, 0, UDP_BUF_SIZE); - recv_len = recvfrom(fd, recv_buf, UDP_BUF_SIZE, 0, (struct sockaddr *)&server_addr, &addr_len); + recv_len = recv(fd, recv_buf, UDP_BUF_SIZE, 0); if(recv_len > 0) { lw_notice("Receive from : %s\n", inet_ntoa(server_addr.sin_addr)); lw_notice("Receive data : %s\n\n", recv_buf); } - sendto(fd, recv_buf, recv_len, 0, (struct sockaddr*)&server_addr, addr_len); + send(fd, recv_buf, recv_len, 0); } close(fd); @@ -106,21 +135,24 @@ static void UdpSocketRecvTask(void *arg) } } -#ifdef ADD_XIZI_FETURES void UdpSocketRecvTest(int argc, char *argv[]) { - if(argc >= 2) { + if(argc >= 2) + { lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]); - if(sscanf(argv[1], "%d.%d.%d.%d:%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3], &udp_socket_port) == 0) { - sscanf(argv[1], "%d.%d.%d.%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3]); - } + UdpSocketConfigParam(argv[1]); } +#ifdef ADD_XIZI_FETURES lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip); - sys_thread_new("UdpSocketRecvTask", UdpSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); + sys_thread_new("UdpSocketRecvTask", UdpSocketRecvTask, NULL, + LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); +#endif +#ifdef ADD_NUTTX_FETURES + UdpSocketRecvTask(NULL); +#endif } PRIV_SHELL_CMD_FUNCTION(UdpSocketRecvTest, a udp receive sample, PRIV_SHELL_CMD_MAIN_ATTR); -#endif static void UdpSocketSendTask(void *arg) { @@ -131,7 +163,8 @@ static void UdpSocketSendTask(void *arg) memset(send_str, 0, sizeof(send_str)); fd = socket(AF_INET, SOCK_DGRAM, 0); - if(fd < 0) { + if(fd < 0) + { lw_error("Socket error\n"); return; } @@ -139,21 +172,24 @@ static void UdpSocketSendTask(void *arg) struct sockaddr_in udp_sock; udp_sock.sin_family = AF_INET; udp_sock.sin_port = htons(udp_socket_port); - udp_sock.sin_addr.s_addr = PP_HTONL(LWIP_MAKEU32(udp_socket_ip[0], udp_socket_ip[1], udp_socket_ip[2], udp_socket_ip[3])); + udp_sock.sin_addr.s_addr = inet_addr(udp_ip_str); memset(&(udp_sock.sin_zero), 0, sizeof(udp_sock.sin_zero)); - if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr))) { + if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr))) + { lw_error("Unable to connect\n"); close(fd); return; } - lw_print("UDP connect success, start to send.\n"); - lw_notice("\n\nTarget Port:%d\n\n", udp_sock.sin_port); + lw_print("UDP connect %s:%d success, start to send.\n", + udp_ip_str, + udp_socket_port); - while (cnt --) { + while(cnt --) + { snprintf(send_str, sizeof(send_str), "UDP test package times %d\r\n", cnt); - sendto(fd, send_str, strlen(send_str), 0, (struct sockaddr*)&udp_sock, sizeof(struct sockaddr)); + send(fd, send_str, strlen(send_str), 0); lw_notice("Send UDP msg: %s ", send_str); PrivTaskDelay(1000); } @@ -162,30 +198,22 @@ static void UdpSocketSendTask(void *arg) return; } -#ifdef ADD_XIZI_FETURES void UdpSocketSendTest(int argc, char *argv[]) { - if(argc >= 2) { + if(argc >= 2) + { lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]); - if(sscanf(argv[1], "%d.%d.%d.%d:%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3], &udp_socket_port) == 0) { - sscanf(argv[1], "%d.%d.%d.%d", &udp_socket_ip[0], &udp_socket_ip[1], &udp_socket_ip[2], &udp_socket_ip[3]); - } + UdpSocketConfigParam(argv[1]); } +#ifdef ADD_XIZI_FETURES lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip); - sys_thread_new("UdpSocketSendTask", UdpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); + sys_thread_new("UdpSocketSendTask", UdpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, + LWIP_DEMO_TASK_PRIO); +#endif +#ifdef ADD_NUTTX_FETURES + UdpSocketSendTask(NULL); +#endif } PRIV_SHELL_CMD_FUNCTION(UdpSocketSendTest, a udp send sample, PRIV_SHELL_CMD_MAIN_ATTR); -#endif -#ifdef ADD_NUTTX_FETURES -void udp_recv_demo(void) -{ - UdpSocketRecvTask(NULL); -} - -void udp_send_demo(void) -{ - UdpSocketSendTask(NULL); -} -#endif diff --git a/APP_Framework/Framework/connection/adapter.c b/APP_Framework/Framework/connection/adapter.c index a4b0f4cc9..eb1356c14 100644 --- a/APP_Framework/Framework/connection/adapter.c +++ b/APP_Framework/Framework/connection/adapter.c @@ -169,7 +169,7 @@ int AdapterDeviceOpen(struct Adapter *adapter) result = priv_done->open(adapter); if (0 == result) { - printf("Device %s open success.\n", adapter->name); + printf("Device %s %p open success.\n", adapter->name, adapter->adapter_param); adapter->adapter_status = INSTALL; } else { if (adapter->fd) { @@ -187,7 +187,7 @@ int AdapterDeviceOpen(struct Adapter *adapter) result = ip_done->open(adapter); if (0 == result) { - printf("Device %s open success.\n", adapter->name); + printf("Device %s param %p open success.\n", adapter->name, adapter->adapter_param); adapter->adapter_status = INSTALL; } else { if (adapter->fd) { diff --git a/APP_Framework/Framework/connection/adapter_agent.c b/APP_Framework/Framework/connection/adapter_agent.c index af9948cd8..344674bfb 100755 --- a/APP_Framework/Framework/connection/adapter_agent.c +++ b/APP_Framework/Framework/connection/adapter_agent.c @@ -139,9 +139,9 @@ int ATOrderSend(ATAgentType agent, uint32_t timeout_s, ATReplyType reply, const abstime.tv_sec = timeout_s; - PrivMutexObtain(&agent->lock); + PrivMutexObtain(&agent->lock); agent->receive_mode = AT_MODE; - + memset(agent->maintain_buffer, 0x00, agent->maintain_max); agent->maintain_len = 0; @@ -154,8 +154,8 @@ int ATOrderSend(ATAgentType agent, uint32_t timeout_s, ATReplyType reply, const const char *cmd = NULL; agent->reply = reply; - PrivMutexAbandon(&agent->lock); - + PrivMutexAbandon(&agent->lock); + if(agent->reply != NULL) { PrivMutexObtain(&agent->lock); reply->reply_len = 0; @@ -211,8 +211,7 @@ int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check) ret = -1; goto __exit; } - printf("[reply result :\n"); - printf("%s]\n", result); + printf("[reply result: %s]\n", result); if(!strstr(result, check)) { printf("%s %d check[%s] reply[%s] failed.\n",__func__,__LINE__,check,result); ret = -1; @@ -230,7 +229,7 @@ char *GetReplyText(ATReplyType reply) } int AtSetReplyLrEnd(ATAgentType agent, char enable) -{ +{ if (!agent) { return -1; } @@ -241,7 +240,7 @@ int AtSetReplyLrEnd(ATAgentType agent, char enable) } int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch) -{ +{ if (!agent) { return -1; } @@ -253,7 +252,7 @@ int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch) } int AtSetReplyCharNum(ATAgentType agent, unsigned int num) -{ +{ if (!agent) { return -1; } @@ -292,18 +291,18 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s) abstime.tv_sec = timeout_s; if(buffer_len > ENTM_RECV_MAX){ printf("read length more then max length[%d] Bytes",ENTM_RECV_MAX); - return -1; + return -1; } - PrivMutexObtain(&agent->lock); + PrivMutexObtain(&agent->lock); agent->receive_mode = ENTM_MODE; agent->read_len = buffer_len; - PrivMutexAbandon(&agent->lock); + PrivMutexAbandon(&agent->lock); //PrivTaskDelay(1000); if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)) { printf("wait sem[%d] timeout\n",agent->entm_rx_notice); return -1; } - PrivMutexObtain(&agent->lock); + PrivMutexObtain(&agent->lock); printf("EntmRecv once len %d.\n", agent->entm_recv_len); @@ -312,7 +311,7 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s) memset(agent->entm_recv_buf, 0, ENTM_RECV_MAX); agent->entm_recv_len = 0; agent->read_len = 0; - PrivMutexAbandon(&agent->lock); + PrivMutexAbandon(&agent->lock); return buffer_len; } @@ -323,7 +322,7 @@ static int GetCompleteATReply(ATAgentType agent) char ch = 0, last_ch = 0; bool is_full = false; - PrivMutexObtain(&agent->lock); + PrivMutexObtain(&agent->lock); memset(agent->maintain_buffer, 0x00, agent->maintain_max); agent->maintain_len = 0; @@ -331,7 +330,7 @@ static int GetCompleteATReply(ATAgentType agent) memset(agent->entm_recv_buf, 0x00, 256); agent->entm_recv_len = 0; - PrivMutexAbandon(&agent->lock); + PrivMutexAbandon(&agent->lock); while (1) { PrivRead(agent->fd, &ch, 1); @@ -359,7 +358,7 @@ static int GetCompleteATReply(ATAgentType agent) } else { printf("entm_recv_buf is_full ...\n"); } - } + } else if (agent->receive_mode == AT_MODE) { if (read_len < agent->maintain_max) { if(ch != 0) { ///< if the char is null then do not save it to the buff @@ -367,13 +366,14 @@ static int GetCompleteATReply(ATAgentType agent) read_len++; agent->maintain_len = read_len; } - + } else { - printf("maintain_len is_full ...\n"); + printf("maintain_len is_full %d ...\n", read_len); is_full = true; } - if (((ch == '\n') && (last_ch == '\r') && (agent->reply_lr_end)) || + if (((ch == '\n') && (agent->reply_lr_end)) || + ((ch == '\n') && (last_ch == '\r') && (agent->reply_lr_end)) || ((ch == agent->reply_end_char) && (agent->reply_end_char) && (last_ch == agent->reply_end_last_char) && (agent->reply_end_last_char)) || ((read_len == agent->reply_char_num) && (agent->reply_char_num))) { @@ -384,7 +384,7 @@ static int GetCompleteATReply(ATAgentType agent) PrivMutexAbandon(&agent->lock); return -1; } - + printf("GetCompleteATReply done\n"); agent->receive_mode = DEFAULT_MODE; PrivMutexAbandon(&agent->lock); @@ -418,7 +418,7 @@ int DeleteATAgent(ATAgentType agent) if(agent->at_handler > 0){ PrivTaskDelete(agent->at_handler, 0); } - + if (agent->fd > 0) { printf("close agent fd = %d\n",agent->fd); PrivClose(agent->fd); @@ -464,7 +464,7 @@ static void *ATAgentReceiveProcess(void *param) while (1) { if (GetCompleteATReply(agent) > 0) { - PrivMutexObtain(&agent->lock); + PrivMutexObtain(&agent->lock); if (agent->reply != NULL) { ATReplyType reply = agent->reply; @@ -521,7 +521,7 @@ static int ATAgentInit(ATAgentType agent) #ifdef ADD_NUTTX_FETURES pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER; attr.priority = 18; - attr.stacksize = 4096; + attr.stacksize = 8192; #else pthread_attr_t attr; @@ -550,7 +550,7 @@ int InitATAgent(const char *agent_name, int agent_fd, uint32 maintain_max) if (GetATAgent(agent_name) != NULL) { return result; } - + while (i < AT_AGENT_MAX && at_agent_table[i].fd > 0) { i++; } diff --git a/APP_Framework/Framework/connection/wifi/adapter_wifi.c b/APP_Framework/Framework/connection/wifi/adapter_wifi.c index b9e1abdfb..53f46603f 100644 --- a/APP_Framework/Framework/connection/wifi/adapter_wifi.c +++ b/APP_Framework/Framework/connection/wifi/adapter_wifi.c @@ -99,8 +99,8 @@ int AdapterWifiInit(void) /******************wifi TEST*********************/ int AdapterWifiTest(void) { - char cmd[64]; - int baud_rate = BAUD_RATE_57600; +// char cmd[64]; +// int baud_rate = BAUD_RATE_57600; struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME); @@ -168,13 +168,13 @@ int AdapterWifiTest(void) const char *wifi_msg = "Wifi Test"; int len = strlen(wifi_msg); - for(int i = 0;i < 10; ++i) { + for(int i = 0; i < 10; ++i) { AdapterDeviceSend(adapter, wifi_msg, len); PrivTaskDelay(4000); } char wifi_recv_msg[128]; - for(int j=0;j<10;++j){ + for(int j = 0; j < 10; ++j){ AdapterDeviceRecv(adapter, wifi_recv_msg, 128); PrivTaskDelay(1000); } @@ -198,7 +198,7 @@ PRIV_SHELL_CMD_FUNCTION(WifiClose, a WiFi close sample, PRIV_SHELL_CMD_MAIN_ATTR int WifiSetup(int argc, char *argv[]) { struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME); - struct WifiParam param; + static struct WifiParam param; memset(¶m,0,sizeof(struct WifiParam)); strncpy((char *)param.wifi_ssid, argv[1], strlen(argv[1])); strncpy((char *)param.wifi_pwd, argv[2], strlen(argv[2])); @@ -292,7 +292,7 @@ enum APT_WIFI_PARAM_NUM }; -#define APT_WIFI_PARAM_LEN 20 +#define APT_WIFI_PARAM_LEN 128 char wifi_param[APT_WIFI_PARAM_NUM][APT_WIFI_PARAM_LEN] = {0}; @@ -301,6 +301,7 @@ ret = __func; \ if(ret != 0){ \ printf("%s %d failed\n", __func__, __LINE__); \ AdapterDeviceClose(adapter); \ + free(adapter->adapter_param); \ return ret; \ }; @@ -309,7 +310,16 @@ void AdapterWifiGetParam(int argc, char *argv[]) int i, j; char *param_str[] = {"ip", "port", "ssid", "pwd", "gw", "server", "mask", "ping"}; char *default_str[] = - {"192.168.137.34", "12345", "test", "tttttttt", "192.168.137.71", "192.168.137.1", "255.255.255.0", "220.181.38.251"}; + { + "192.168.137.34", + "12345", + "test", + "tttttttt", + "192.168.137.71", + "192.168.137.1", + "255.255.255.0", + "220.181.38.251" + }; for(i = 0; i < APT_WIFI_PARAM_NUM; i ++) { @@ -338,21 +348,24 @@ void AdapterWifiGetParam(int argc, char *argv[]) } -int AdapterWifiTest(int argc, char *argv[]) +int AdapterWifiTestWithParam(int argc, char *argv[]) { int i, ret; - struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME); + struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME); AdapterWifiGetParam(argc, argv); enum NetRoleType net_role = CLIENT; enum IpType ip_type = IPV4; - struct WifiParam param; - memset(¶m, 0, sizeof(struct WifiParam)); - strncpy((char *)param.wifi_ssid, wifi_param[APT_WIFI_PARAM_SSID], strlen(wifi_param[APT_WIFI_PARAM_SSID])); - strncpy((char *)param.wifi_pwd, wifi_param[APT_WIFI_PARAM_PWD], strlen(wifi_param[APT_WIFI_PARAM_PWD])); - adapter->adapter_param = ¶m; + adapter->adapter_param = malloc(sizeof(struct WifiParam)); + memset(adapter->adapter_param, 0, sizeof(struct WifiParam)); + struct WifiParam *apt_param = (struct WifiParam *)adapter->adapter_param; + strcpy(apt_param->wifi_ssid, wifi_param[APT_WIFI_PARAM_SSID]); + strcpy(apt_param->wifi_pwd, wifi_param[APT_WIFI_PARAM_PWD]); + + printf("2022-10-14 Mr. Wang commit Wifi\n"); + printf("apt %p ssid %p %s\n", apt_param, apt_param->wifi_ssid); CHECK_RET(AdapterDeviceOpen(adapter)); CHECK_RET(AdapterDeviceSetUp(adapter)); @@ -373,8 +386,9 @@ int AdapterWifiTest(int argc, char *argv[]) PrivTaskDelay(4000); } - char wifi_recv_msg[128]; - for(i = 0; i < 10; i ++) + char wifi_recv_msg[APT_WIFI_PARAM_LEN]; + memset(wifi_recv_msg, 0, APT_WIFI_PARAM_LEN); + for(i = 0; i < APT_WIFI_PARAM_NUM; i ++) { AdapterDeviceRecv(adapter, wifi_recv_msg, 128); PrivTaskDelay(1000); @@ -385,6 +399,7 @@ int AdapterWifiTest(int argc, char *argv[]) // CHECK_RET(AdapterDevicePing(adapter, wifi_param[APT_WIFI_PARAM_PING])); // AdapterDeviceDisconnect(adapter, NULL); ret = AdapterDeviceClose(adapter); + free(adapter->adapter_param); return ret; } diff --git a/APP_Framework/Framework/connection/wifi/adapter_wifi.h b/APP_Framework/Framework/connection/wifi/adapter_wifi.h index 25c6709a7..042dcc092 100644 --- a/APP_Framework/Framework/connection/wifi/adapter_wifi.h +++ b/APP_Framework/Framework/connection/wifi/adapter_wifi.h @@ -31,8 +31,8 @@ struct WifiParam { - uint8_t wifi_ssid[128]; - uint8_t wifi_pwd[128]; + char wifi_ssid[128]; + char wifi_pwd[128]; }; diff --git a/APP_Framework/Framework/connection/wifi/esp07s_wifi/esp07s_wifi.c b/APP_Framework/Framework/connection/wifi/esp07s_wifi/esp07s_wifi.c index 4eba52263..4a1aa830d 100755 --- a/APP_Framework/Framework/connection/wifi/esp07s_wifi/esp07s_wifi.c +++ b/APP_Framework/Framework/connection/wifi/esp07s_wifi/esp07s_wifi.c @@ -196,39 +196,59 @@ static int Esp07sWifiSetUp(struct Adapter *adapter) return -1; } PrivTaskDelay(2000); + + printf("%s check %d adapter %p wifi %p param %p\n", __func__, __LINE__, adapter, param, + adapter->adapter_param); + /* config as softAP+station mode */ ret = AtCmdConfigAndCheck(agent, "AT+CWMODE=3\r\n", "OK"); if(ret < 0) { printf("%s %d cmd[AT+CWMODE=3] config failed!\n",__func__,__LINE__); return -1; } + +// printf("%s check %d pwd %s\n", __func__, __LINE__, param->wifi_pwd); + PrivTaskDelay(2000); /* connect the router */ memset(cmd,0,sizeof(cmd)); - strncpy(cmd,"AT+CWJAP=",strlen("AT+CWJAP=")); + strcpy(cmd,"AT+CWJAP=");//strlen("AT+CWJAP=")); strncat(cmd,"\"",1); - strncat(cmd,param->wifi_ssid,strlen(param->wifi_ssid)); + +// printf("%s check %d len %d\n", __func__, __LINE__, strlen(param->wifi_pwd)); + + strncat(cmd,param->wifi_ssid,128); strncat(cmd,"\"",1); strncat(cmd,",",1); strncat(cmd,"\"",1); + +// printf("%s check %d len %d\n", __func__, __LINE__, strlen(param->wifi_pwd)); + strncat(cmd,param->wifi_pwd,strlen(param->wifi_pwd)); strncat(cmd,"\"",1); strcat(cmd,"\r\n"); + printf("%s check %d\n", __func__, __LINE__); + ret = AtCmdConfigAndCheck(agent, cmd, "OK"); if(ret < 0) { printf("%s %d cmd[%s] connect[%s] failed!\n",__func__,__LINE__,cmd,param->wifi_ssid); return -1; } + printf("%s check %d\n", __func__, __LINE__); + /* check the wifi ip address */ ATReplyType reply = CreateATReply(256); if (NULL == reply) { printf("%s %d at_create_resp failed!\n",__func__,__LINE__); return -1; } + + printf("%s check %d\n", __func__, __LINE__); + ret = ATOrderSend(agent, REPLY_TIME_OUT, reply, "AT+CIFSR\r\n"); if(ret < 0){ printf("%s %d ATOrderSend AT+CIFSR failed.\n",__func__,__LINE__); @@ -238,7 +258,7 @@ static int Esp07sWifiSetUp(struct Adapter *adapter) result = GetReplyText(reply); if (!result) { - printf("%s %n get reply failed.\n",__func__,__LINE__); + printf("%s %d get reply failed.\n",__func__,__LINE__); ret = -1; goto __exit; } @@ -355,7 +375,7 @@ static int Esp07sWifiNetstat(struct Adapter *adapter) result = GetReplyText(reply); if (!result) { - printf("%s %n get reply failed.\n",__func__,__LINE__); + printf("%s %d get reply failed.\n",__func__,__LINE__); ret = -1; goto __exit; } diff --git a/APP_Framework/Framework/connection/zigbee/e18/Kconfig b/APP_Framework/Framework/connection/zigbee/e18/Kconfig index 05751a4dc..0551d4cbf 100644 --- a/APP_Framework/Framework/connection/zigbee/e18/Kconfig +++ b/APP_Framework/Framework/connection/zigbee/e18/Kconfig @@ -47,14 +47,24 @@ if ADD_XIZI_FETURES endif if ADD_NUTTX_FETURES +if ARCH_BOARD_XIDATONG_ARM32 + config ADAPTER_E18_MODEPIN + int "E18 MODE pin number" + default "61" + + config ADAPTER_E18_PIN_DRIVER + string "E18 device pin driver path" + default "/dev/gpio0" +endif +if ARCH_BOARD_XIDATONG_ARM32 config ADAPTER_E18_MODE_PATH string "E18 MODE pin device" default "/dev/gpio2" - +endif config ADAPTER_E18_DRIVER_EXTUART bool "Using extra uart to support zigbee" default y - + config ADAPTER_E18_DRIVER string "E18 device uart driver path" default "/dev/ttyS1" diff --git a/APP_Framework/Framework/connection/zigbee/e18/e18.c b/APP_Framework/Framework/connection/zigbee/e18/e18.c index 41197dc5a..b07a4c3ea 100644 --- a/APP_Framework/Framework/connection/zigbee/e18/e18.c +++ b/APP_Framework/Framework/connection/zigbee/e18/e18.c @@ -40,10 +40,35 @@ char *cmd_set_ch = "AT+CH=11"; /*set channel as 11*/ #define E18_AS_HEX_MODE 0 #define E18_AS_AT_MODE 1 + static int E18HardwareModeGet() { #ifdef ADD_NUTTX_FETURES +#ifdef CONFIG_ARCH_BOARD_XIDATONG_ARM32 + int ret = 0; + int pin_fd; + + pin_fd = PrivOpen(ADAPTER_E18_PIN_DRIVER, O_RDWR); + + struct PinStat pin_stat; + pin_stat.pin = ADAPTER_E18_MODEPIN; + + ret = PrivRead(pin_fd, &pin_stat, 1); + + PrivTaskDelay(200); + + PrivClose(pin_fd); + + if(pin_stat.val == GPIO_HIGH) { + printf(" E18 as AT mode\n"); + return E18_AS_AT_MODE; + } else { + printf(" E18 as HEX mode\n"); + return E18_AS_HEX_MODE; + } +#else return E18_AS_HEX_MODE; +#endif #else int ret = 0; int pin_fd; @@ -66,7 +91,41 @@ static int E18HardwareModeGet() printf(" E18 as HEX mode\n"); return E18_AS_HEX_MODE; } -#endif +#endif +} + +static int E18HardwareModeSet(void) +{ +#ifdef ADD_NUTTX_FETURES +#ifdef CONFIG_ARCH_BOARD_XIDATONG_ARM32 + int ret = 0; + int pin_fd; + + pin_fd = PrivOpen(ADAPTER_E18_PIN_DRIVER, O_RDWR); + + struct PinStat pin_stat; + pin_stat.pin = ADAPTER_E18_MODEPIN; + pin_stat.val = GPIO_HIGH; + +// ret = PrivWrite(pin_fd, &pin_stat, 1); + + ioctl(pin_fd, GPIOC_WRITE, (unsigned long)0); + + PrivTaskDelay(200); + + ret = PrivRead(pin_fd, &pin_stat, 1); + + PrivClose(pin_fd); + + if(pin_stat.val == GPIO_HIGH) { + printf(" E18 set AT mode\n"); + return E18_AS_AT_MODE; + } else { + printf(" E18 set HEX mode\n"); + return E18_AS_HEX_MODE; + } +#endif +#endif } static int E18UartOpen(struct Adapter *adapter) @@ -186,6 +245,8 @@ static int E18NetRoleConfig(struct Adapter *adapter) int ret = 0; int mode = -1; + printf("start %s\n", __func__); +// E18HardwareModeSet(); if (NULL == adapter) { printf("%s %d adapter is null!\n",__func__,__LINE__); diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/lcdnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/lcdnsh/defconfig index df2f82504..3219e42d0 100755 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/lcdnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/lcdnsh/defconfig @@ -107,3 +107,6 @@ CONFIG_EXAMPLES_TOUCHSCREEN_MINOR=0 CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH="/dev/input0" CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES=0 +CONFIG_USER_TEST=y +CONFIG_USER_TEST_LCD=y + diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/netnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/netnsh/defconfig index 9c4f04b90..18e37d804 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/netnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/netnsh/defconfig @@ -23,6 +23,7 @@ CONFIG_BOARD_LOOPSPERMSEC=104926 CONFIG_BUILTIN=y CONFIG_CLOCK_MONOTONIC=y CONFIG_ETH0_PHY_LAN8720=y +CONFIG_FS_PROCFS=y CONFIG_IMXRT_ENET_PHYINIT=y CONFIG_IMXRT_GPIO_IRQ=y CONFIG_IMXRT_GPIO3_0_15_IRQ=y @@ -72,8 +73,8 @@ CONFIG_READLINE_CMD_HISTORY=y CONFIG_READLINE_CMD_HISTORY_LEN=100 CONFIG_READLINE_CMD_HISTORY_LINELEN=120 CONFIG_READLINE_TABCOMPLETION=y -CONFIG_FS_ROMFS=y -CONFIG_NSH_ROMFSETC=y -CONFIG_NSH_ARCHROMFS=y + CONFIG_BOARDCTL_RESET=y CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_APPLICATION_CONNECTION=y +CONFIG_SOCKET_DEMO=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/wifinsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/wifinsh/defconfig index 6fe18f3ff..2d1625113 100755 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/wifinsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/wifinsh/defconfig @@ -47,15 +47,17 @@ CONFIG_SYSTEM_NSH=y CONFIG_DEV_GPIO=y CONFIG_READLINE_CMD_HISTORY=y CONFIG_READLINE_CMD_HISTORY_LEN=100 + CONFIG_READLINE_CMD_HISTORY_LINELEN=120 CONFIG_READLINE_TABCOMPLETION=y CONFIG_FS_ROMFS=y CONFIG_NSH_ROMFSETC=y CONFIG_NSH_ARCHROMFS=y CONFIG_BOARDCTL_RESET=y -CONFIG_CONNECTION_FRAMEWORK_DEBUG=y CONFIG_CONNECTION_ADAPTER_WIFI=y CONFIG_ADAPTER_ESP07S_WIFI=y CONFIG_ADAPTER_WIFI_ESP07S="esp07s_wifi" CONFIG_ADAPTER_ESP07S_DRIVER="/dev/ttyS2" CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_SUPPORT_CONNECTION_FRAMEWORK=y + diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/lcdnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/lcdnsh/defconfig index 062a4e8e7..a5e7abb94 100755 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/lcdnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/lcdnsh/defconfig @@ -62,4 +62,7 @@ CONFIG_K210_HAVE_LCD=y CONFIG_K210_LCD=y CONFIG_K210_LCD_BACKLIGHT=y CONFIG_LCD=y -CONFIG_LCD_LT768=y \ No newline at end of file +CONFIG_LCD_LT768=y + +CONFIG_USER_TEST=y +CONFIG_USER_TEST_LCD=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh.h b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh.h index c899bfd6b..1aba1a1ff 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh.h +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh.h @@ -1454,7 +1454,7 @@ int nsh_foreach_var(FAR struct nsh_vtbl_s *vtbl, nsh_foreach_var_t cb, int cmd_Ch438(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); #endif -#if defined(CONFIG_K210_LCD) && !defined(CONFIG_NSH_DISABLE_LCD) +#if defined(CONFIG_USER_TEST_LCD) && !defined(CONFIG_NSH_DISABLE_USER_TEST_LCD) int cmd_Lcd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); #endif @@ -1462,6 +1462,13 @@ int nsh_foreach_var(FAR struct nsh_vtbl_s *vtbl, nsh_foreach_var_t cb, int cmd_Extsram(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); #endif +#if defined(CONFIG_SOCKET_DEMO) && !defined(CONFIG_NSH_DISABLE_SOCKET_DEMO) + int cmd_Udpsend(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); + int cmd_Udprecv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); + int cmd_Tcpsend(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); + int cmd_Tcprecv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif + #if defined(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS) && !defined(CONFIG_NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS) int cmd_Hcho1os(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); #endif diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c index de46c9f9e..f19fdc9d4 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c @@ -54,7 +54,7 @@ int cmd_Ch438(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) /**************************************************************************** * Name: cmd_lcd ****************************************************************************/ -#if defined(CONFIG_K210_LCD) && !defined(CONFIG_NSH_DISABLE_LCD) +#if defined(CONFIG_USER_TEST_LCD) && !defined(CONFIG_NSH_DISABLE_USER_TEST_LCD) extern void LcdDemo(void); int cmd_Lcd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { @@ -68,11 +68,48 @@ int cmd_Lcd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) * Name: cmd_Extsram ****************************************************************************/ #if defined(CONFIG_USER_TEST_SEMC) && !defined(CONFIG_NSH_DISABLE_USER_TEST_SEMC) -extern int extsram_test(void); +extern int ExtsramTest(void); int cmd_Extsram(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { nsh_output(vtbl, "Hello, extra sdram!\n"); - extsram_test(); + ExtsramTest(); + return OK; +} +#endif + +/**************************************************************************** + * Name: socket test + ****************************************************************************/ +#if defined(CONFIG_SOCKET_DEMO) && !defined(CONFIG_NSH_DISABLE_SOCKET_DEMO) +void UdpSocketRecvTest(int argc, char *argv[]); +int cmd_Udprecv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + nsh_output(vtbl, "Hello, UDP receive!\n"); + UdpSocketRecvTest(argc, argv); + return OK; +} + +void UdpSocketSendTest(int argc, char *argv[]); +int cmd_Udpsend(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + nsh_output(vtbl, "Hello, UDP send!\n"); + UdpSocketSendTest(argc, argv); + return OK; +} + +void TcpSocketRecvTest(int argc, char *argv[]); +int cmd_Tcprecv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + nsh_output(vtbl, "Hello, TCP receive!\n"); + TcpSocketRecvTest(argc, argv); + return OK; +} + +void TcpSocketSendTest(int argc, char *argv[]); +int cmd_Tcpsend(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + nsh_output(vtbl, "Hello, TCP send!\n"); + TcpSocketSendTest(argc, argv); return OK; } #endif @@ -293,46 +330,46 @@ int cmd_WindSpeedQsFs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) ****************************************************************************/ #if defined(CONFIG_CONNECTION_ADAPTER_ZIGBEE) && !defined(CONFIG_NSH_DISABLE_OPENZIGBEE) -extern int openzigbee(void); +extern int OpenZigbee(void); int cmd_openzigbee(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { nsh_output(vtbl, "Hello, world!\n"); FrameworkInit(); - openzigbee(); + OpenZigbee(); return OK; } #endif #if defined(CONFIG_CONNECTION_ADAPTER_ZIGBEE) && !defined(CONFIG_NSH_DISABLE_SENDZIGBEE) -extern int sendzigbee(int argc, char *argv[]); +extern int SendZigbee(int argc, char *argv[]); int cmd_sendzigbee(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { nsh_output(vtbl, "Hello, world!\n"); FrameworkInit(); - sendzigbee(argc,argv); + SendZigbee(argc,argv); return OK; } #endif #if defined(CONFIG_CONNECTION_ADAPTER_ZIGBEE) && !defined(CONFIG_NSH_DISABLE_RECVZIGBEE) -extern int recvzigbee(void); +extern int RecvZigbee(void); int cmd_recvzigbee(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { nsh_output(vtbl, "Hello, world!\n"); FrameworkInit(); - recvzigbee(); + RecvZigbee(); return OK; } #endif #if defined(CONFIG_ADAPTER_ESP07S_WIFI) && !defined(CONFIG_NSH_DISABLE_ADAPTER_WIFI_TEST) -extern int AdapterWifiTest(int argc, char *argv[]); +extern int AdapterWifiTestWithParam(int argc, char *argv[]); int cmd_AdapterWifiTest(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { nsh_output(vtbl, "Hello, world!\n"); FrameworkInit(); - AdapterWifiTest(argc, argv); + AdapterWifiTestWithParam(argc, argv); return OK; } #endif diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_command.c b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_command.c index f513ecf23..e040899fa 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_command.c +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_command.c @@ -600,14 +600,21 @@ static const struct cmdmap_s g_cmdmap[] = { "ch438", cmd_Ch438, 1, 1, "[ch438 demo cmd.]" }, #endif -#if defined(CONFIG_K210_LCD) && !defined(CONFIG_NSH_DISABLE_LCD) - { "lcd", cmd_Lcd, 1, 1, "[LCD demo cmd.]" }, +#if defined(CONFIG_USER_TEST_LCD) && !defined(CONFIG_NSH_DISABLE_USER_TEST_LCD) + { "lcd", cmd_Lcd, 1, 1, "[LCD demo cmd.]" }, #endif #if defined(CONFIG_USER_TEST_SEMC) && !defined(CONFIG_NSH_DISABLE_USER_TEST_SEMC) { "sram", cmd_Extsram, 1, 1, "[Extra sdram demo cmd.]" }, #endif +#if defined(CONFIG_SOCKET_DEMO) && !defined(CONFIG_NSH_DISABLE_SOCKET_DEMO) + { "udpsend", cmd_Udpsend, 1, 2, "[Udp send demo cmd.]" }, + { "udprecv", cmd_Udprecv, 1, 2, "[Udp recv demo cmd.]" }, + { "tcpsend", cmd_Tcpsend, 1, 2, "[Tcp send demo cmd.]" }, + { "tcprecv", cmd_Tcprecv, 1, 2, "[Tcp recv demo cmd.]" }, +#endif + #if defined(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS) && !defined(CONFIG_NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS) { "hcho1os", cmd_Hcho1os, 1, 1, "[get the concentration of formaldehyde with sensor tb600b_wq_hcho1os.]" }, #endif diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/drivers/lcd/lt768.c b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/drivers/lcd/lt768.c index 2d5d1bfdc..2cfffc1ba 100755 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/drivers/lcd/lt768.c +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/drivers/lcd/lt768.c @@ -1,6371 +1,6380 @@ -/********************* COPYRIGHT *********************** -* File Name : LT768.c -* Author : Levetop Electronics -* Version : V1.0 -* Date : 2017-8-25 -* Description : 操作LT768的寄存器函数 - 具体操作哪个寄存器请看LT768.h文件 -*********************************************************/ - -#include -#include "nuttx/arch.h" -#include "nuttx/lcd/lt768.h" -#include "nuttx/lcd/k210_lcd.h" - -//============================================================================== -void LCD_RegisterWrite(unsigned char Cmd,unsigned char Data) -{ - LCD_CmdWrite(Cmd); - LCD_DataWrite(Data); -} - -unsigned char LCD_RegisterRead(unsigned char Cmd) -{ - unsigned char temp; - LCD_CmdWrite(Cmd); - temp=LCD_DataRead(); - return temp; -} - -/******************************************************************************/ -/*Sub program area */ -/******************************************************************************/ -void Check_Mem_WR_FIFO_not_Full(void) -{ - /* 0: Memory Write FIFO is not full. - 1: Memory Write FIFO is full. */ - do - { - } - while(LCD_StatusRead()&0x80); -} -void Check_Mem_WR_FIFO_Empty(void) -{ - /* 0: Memory Write FIFO is not empty. - 1: Memory Write FIFO is empty. */ - do - { - } - while((LCD_StatusRead()&0x40) == 0x00); -} -void Check_Mem_RD_FIFO_not_Full(void) -{ - /* 0: Memory Read FIFO is not full. - 1: Memory Read FIFO is full. */ - do - { - } - while(LCD_StatusRead()&0x20); -} -void Check_Mem_RD_FIFO_not_Empty(void) -{ - /* 0: Memory Read FIFO is not empty. - 1: Memory Read FIFO is empty. - */ - do - { - } - while(LCD_StatusRead()&0x10); -} -void Check_2D_Busy(void) -{ - do - { - } - while(LCD_StatusRead()&0x08); -} -void Check_SDRAM_Ready(void) -{ - /* 0: SDRAM is not ready for access - 1: SDRAM is ready for access */ - unsigned char temp; - - do - { - temp=LCD_StatusRead(); - } - while((temp&0x04) == 0x00); -} - -unsigned char Power_Saving_Status(void) -{ - unsigned char temp; - - if((LCD_StatusRead()&0x02)==0x02) - { - temp = 1; - } - else - { - temp = 0; - } - - return temp; -} - -void Check_Power_is_Normal(void) -{ - /* 0: Normal operation state - 1: Power saving state */ - do - { - } - while(LCD_StatusRead()&0x02); -} -void Check_Power_is_Saving(void) -{ - /* 0: Normal operation state - 1: Power saving state */ - do - { - } - while((LCD_StatusRead()&0x02) == 0x00); -} -void Check_NO_Interrupt(void) -{ - /* 0: without interrupt event - 1: interrupt event occur - */ - do - { - } - while(LCD_StatusRead()&0x01); -} -void Check_Interrupt_Occur(void) -{ - /* 0: without interrupt event - 1: interrupt event occur - */ - do - { - } - while((LCD_StatusRead()&0x01) == 0x00); -} - -void Check_Busy_Draw(void) -{ - unsigned char temp; - - do - { - temp=LCD_StatusRead(); - } - while(temp&0x08); -} - -//[00h]========================================================================= - -void LT768_SW_Reset(void)//IC Reset -{ - unsigned char temp; - LCD_CmdWrite(0x00); - temp = LCD_DataRead(); - temp |= 0x01; - LCD_DataWrite(temp); - - do - { - temp = LCD_DataRead(); - } - while(temp&0x01); -} - -//[01h][01h][01h][01h][01h][01h][01h][01h][01h][01h][01h][01h][01h][01h][01h][01h] -void Enable_PLL(void) -{ - /* 0: PLL disable; allow change PLL parameter. - 1: PLL enable; cannot change PLL parameter.*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp |= cSetb7; - LCD_DataWrite(temp); - up_udelay(1);//PLL -} -void LT768_Sleep(void) -{ - /* 0: Normal mode. - 1: Sleep mode.*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp |= cSetb6; - LCD_DataWrite(temp); -} -void LT768_WakeUp(void) -{ - /* 0: Normal mode. - 1: Sleep mode.*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp &= cClrb6; - LCD_DataWrite(temp); -} -void Key_Scan_Enable(void) -{ - /* 0: Disable. - 1: Enable.*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp |= cSetb5; - LCD_DataWrite(temp); -} -void Key_Scan_Disable(void) -{ - /* 0: Disable. - 1: Enable.*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp &= cClrb5; - LCD_DataWrite(temp); -} -void TFT_24bit(void) -{ - /* 00b: 24-bits output. - 01b: 18-bits output, unused pins are set as GPIO. - 10b: 16-bits output, unused pins are set as GPIO. - 11b: LVDS, all 24-bits unused output pins are set as GPIO.*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp &= cClrb4; - temp &= cClrb3; - LCD_DataWrite(temp); -} -void TFT_18bit(void) -{ - /* 00b: 24-bits output. - 01b: 18-bits output, unused pins are set as GPIO. - 10b: 16-bits output, unused pins are set as GPIO. - 11b: LVDS, all 24-bits unused output pins are set as GPIO.*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp &= cClrb4; - temp |= cSetb3; - LCD_DataWrite(temp); -} -void TFT_16bit(void) -{ - /* 00b: 24-bits output. - 01b: 18-bits output, unused pins are set as GPIO. - 10b: 16-bits output, unused pins are set as GPIO. - 11b: LVDS, all 24-bits unused output pins are set as GPIO.*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp |= cSetb4; - temp &= cClrb3; - LCD_DataWrite(temp); -} -void TFT_LVDS(void) -{ - /* 00b: 24-bits output. - 01b: 18-bits output, unused pins are set as GPIO. - 10b: 16-bits output, unused pins are set as GPIO. - 11b: LVDS, all 24-bits unused output pins are set as GPIO.*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp |= cSetb4; - temp |= cSetb3; - LCD_DataWrite(temp); -} - -void LT768_I2CM_Enable(void) -{ - /* I2C master Interface Enable/Disable - 0: Disable - 1: Enable*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp |= cSetb2; - LCD_DataWrite(temp); -} - -void LT768_I2CM_Disable(void) -{ - /* I2C master Interface Enable/Disable - 0: Disable - 1: Enable*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp &= cClrb2; - LCD_DataWrite(temp); -} - -void Enable_SFlash_SPI(void) -{ - /* Serial Flash SPI Interface Enable/Disable - 0: Disable - 1: Enable*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp |= cSetb1; - LCD_DataWrite(temp); -} - -void Disable_SFlash_SPI(void) -{ - /* Serial Flash SPI Interface Enable/Disable - 0: Disable - 1: Enable*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp &= cClrb1; - LCD_DataWrite(temp); -} -void Host_Bus_8bit(void) -{ - /* Parallel Host Data Bus Width Selection - 0: 8-bit Parallel Host Data Bus. - 1: 16-bit Parallel Host Data Bus.*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp &= cClrb0; - LCD_DataWrite(temp); -} -void Host_Bus_16bit(void) -{ - /* Parallel Host Data Bus Width Selection - 0: 8-bit Parallel Host Data Bus. - 1: 16-bit Parallel Host Data Bus.*/ - unsigned char temp; - LCD_CmdWrite(0x01); - temp = LCD_DataRead(); - temp |= cSetb0; - LCD_DataWrite(temp); -} - -//[02h][02h][02h][02h][02h][02h][02h][02h][02h][02h][02h][02h][02h][02h][02h][02h] - -void RGB_8b_8bpp(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp &= cClrb7; - temp &= cClrb6; - LCD_DataWrite(temp); -} -void RGB_8b_16bpp(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp &= cClrb7; - temp |= cSetb6; - LCD_DataWrite(temp); -} -void RGB_8b_24bpp(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp &= cClrb7; - temp &= cClrb6; - LCD_DataWrite(temp); -} - -void RGB_16b_8bpp(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp |= cSetb7; - temp &= cClrb6; - LCD_DataWrite(temp); -} -void RGB_16b_16bpp(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp &= cClrb7; - temp |= cSetb6; - LCD_DataWrite(temp); -} -void RGB_16b_24bpp_mode1(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp &= cClrb7; - temp &= cClrb6; - LCD_DataWrite(temp); -} -void RGB_16b_24bpp_mode2(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp |= cSetb7; - temp |= cSetb6; - LCD_DataWrite(temp); -} - -void MemRead_Left_Right_Top_Down(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp &= cClrb5; - temp &= cClrb4; - LCD_DataWrite(temp); -} -void MemRead_Right_Left_Top_Down(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp &= cClrb5; - temp |= cSetb4; - LCD_DataWrite(temp); -} -void MemRead_Top_Down_Left_Right(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp |= cSetb5; - temp &= cClrb4; - LCD_DataWrite(temp); -} -void MemRead_Down_Top_Left_Right(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp |= cSetb5; - temp |= cSetb4; - LCD_DataWrite(temp); -} -void MemWrite_Left_Right_Top_Down(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp &= cClrb2; - temp &= cClrb1; - LCD_DataWrite(temp); -} -void MemWrite_Right_Left_Top_Down(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp &= cClrb2; - temp |= cSetb1; - LCD_DataWrite(temp); -} -void MemWrite_Top_Down_Left_Right(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp |= cSetb2; - temp &= cClrb1; - LCD_DataWrite(temp); -} -void MemWrite_Down_Top_Left_Right(void) -{ - unsigned char temp; - LCD_CmdWrite(0x02); - temp = LCD_DataRead(); - temp |= cSetb2; - temp |= cSetb1; - LCD_DataWrite(temp); -} -//[03h][03h][03h][03h][03h][03h][03h][03h][03h][03h][03h][03h][03h][03h][03h][03h] -void Interrupt_Active_Low(void) -{ - /* MPU Interrupt active level - 0 : active low. - 1 : active high.*/ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp &= cClrb7; - LCD_DataWrite(temp); -} -void Interrupt_Active_High(void) -{ - /* MPU Interrupt active level - 0 : active low. - 1 : active high.*/ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp |= cSetb7; - LCD_DataWrite(temp); -} -void ExtInterrupt_Debounce(void) -{ - /* External interrupt de-bounce - 0 : without de-bounce - 1 : enable de-bounce (1024 OSC clock)*/ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp |= cSetb6; - LCD_DataWrite(temp); -} -void ExtInterrupt_Nodebounce(void) -{ - /* External interrupt de-bounce - 0 : without de-bounce - 1 : enable de-bounce (1024 OSC clock)*/ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp &= cClrb6; - LCD_DataWrite(temp); -} -void ExtInterrupt_Input_Low_Level_Trigger(void) -{ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp &= cClrb5; - temp &= cClrb4; - LCD_DataWrite(temp); -} -void ExtInterrupt_Input_High_Level_Trigger(void) -{ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp |= cSetb5; - temp &= cClrb4; - LCD_DataWrite(temp); -} -void ExtInterrupt_Input_Falling_Edge_Trigger(void) -{ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp &= cClrb5; - temp |= cSetb4; - LCD_DataWrite(temp); -} -void ExtInterrupt_Input_Rising_Edge_Trigger(void) -{ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp |= cSetb5; - temp |= cSetb4; - LCD_DataWrite(temp); -} -void LVDS_Format1(void) -{ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp &= cClrb3; - LCD_DataWrite(temp); -} -void LVDS_Format2(void) -{ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp |= cSetb3; - LCD_DataWrite(temp); -} -void Graphic_Mode(void) -{ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp &= cClrb2; - LCD_DataWrite(temp); -} -void Text_Mode(void) -{ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp |= cSetb2; - LCD_DataWrite(temp); -} -void Memory_Select_SDRAM(void) -{ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp &= cClrb1; - temp &= cClrb0; // B - LCD_DataWrite(temp); -} -void Memory_Select_Graphic_Cursor_RAM(void) -{ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp |= cSetb1; - temp &= cClrb0; - LCD_DataWrite(temp); -} -void Memory_Select_Color_Palette_RAM(void) -{ - unsigned char temp; - LCD_CmdWrite(0x03); - temp = LCD_DataRead(); - temp |= cSetb1; - temp |= cSetb0; - LCD_DataWrite(temp); -} - -//[05h]========================================================================= -//[06h]========================================================================= -//[07h]========================================================================= -//[08h]========================================================================= -//[09h]========================================================================= -//[0Ah]========================================================================= -//[0Bh]========================================================================= - -void Enable_Resume_Interrupt(void) -{ - /* - Resume Interrupt Enable - 0: Disable. - 1: Enable. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp |= cSetb7; - LCD_DataWrite(temp); -} -void Disable_Resume_Interrupt(void) -{ - /* - Resume Interrupt Enable - 0: Disable. - 1: Enable. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp &= cClrb7; - LCD_DataWrite(temp); -} -void Enable_ExtInterrupt_Input(void) -{ - /* - External Interrupt (PS[0] pin) Enable - 0: Disable. - 1: Enable. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp |= cSetb6; - LCD_DataWrite(temp); -} -void Disable_ExtInterrupt_Input(void) -{ - /* - External Interrupt (PS[0] pin) Enable - 0: Disable. - 1: Enable. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp &= cClrb6; - LCD_DataWrite(temp); -} -void Enable_I2CM_Interrupt(void) -{ - /* - I2C Master Interrupt Enable - 0: Disable. - 1: Enable. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp |= cSetb5; - LCD_DataWrite(temp); -} -void Disable_I2CM_Interrupt(void) -{ - /* - I2C Master Interrupt Enable - 0: Disable. - 1: Enable. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp &= cClrb5; - LCD_DataWrite(temp); -} -void Enable_Vsync_Interrupt(void) -{ - /* - Vsync time base interrupt Enable Bit - 0: Disable Interrupt. - 1: Enable Interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp |= cSetb4; - LCD_DataWrite(temp); -} -void Disable_Vsync_Interrupt(void) -{ - /* - Vsync time base interrupt Enable Bit - 0: Disable Interrupt. - 1: Enable Interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp &= cClrb4; - LCD_DataWrite(temp); -} -void Enable_KeyScan_Interrupt(void) -{ - /* - Key Scan Interrupt Enable Bit - 0: Disable Key scan interrupt. - 1: Enable Key scan interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp |= cSetb3; - LCD_DataWrite(temp); -} -void Disable_KeyScan_Interrupt(void) -{ - /* - Key Scan Interrupt Enable Bit - 0: Disable Key scan interrupt. - 1: Enable Key scan interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp &= cClrb3; - LCD_DataWrite(temp); -} -void Enable_DMA_Draw_BTE_Interrupt(void) -{ - /* - Serial flash DMA Complete | Draw task finished | BTE Process - Complete etc. Interrupt Enable - 0: Disable Interrupt. - 1: Enable Interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp |= cSetb2; - LCD_DataWrite(temp); -} -void Disable_DMA_Draw_BTE_Interrupt(void) -{ - /* - Serial flash DMA Complete | Draw task finished | BTE Process - Complete etc. Interrupt Enable - 0: Disable Interrupt. - 1: Enable Interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp &= cClrb2; - LCD_DataWrite(temp); -} -void Enable_PWM1_Interrupt(void) -{ - /* - PWM timer 1 Interrupt Enable Bit - 0: Disable Interrupt. - 1: Enable Interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp |= cSetb1; - LCD_DataWrite(temp); -} -void Disable_PWM1_Interrupt(void) -{ - /* - PWM timer 1 Interrupt Enable Bit - 0: Disable Interrupt. - 1: Enable Interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp &= cClrb1; - LCD_DataWrite(temp); -} -void Enable_PWM0_Interrupt(void) -{ - /* - PWM timer 0 Interrupt Enable Bit - 0: Disable Interrupt. - 1: Enable Interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp |= cSetb0; - LCD_DataWrite(temp); -} -void Disable_PWM0_Interrupt(void) -{ - /* - PWM timer 0 Interrupt Enable Bit - 0: Disable Interrupt. - 1: Enable Interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0B); - temp = LCD_DataRead(); - temp &= cClrb0; - LCD_DataWrite(temp); -} - -//[0Ch]========================================================================= -unsigned char Read_Interrupt_status(void) -{ - /* - [Bit7]Read Function ..Resume Interrupt Status - 0: No Resume interrupt happens. - 1: Resume interrupt happens. - [Bit6]Read Function .. PS[0] pin Interrupt Status - 0: No PS[0] pin interrupt happens. - 1: PS[0] pin interrupt happens. - [Bit5]Read Function .. I2C master Interrupt Status - 0: No I2C master interrupt happens. - 1: I2C master interrupt happens. - [Bit4]Read Function .. Vsync Interrupt Status - 0: No interrupt happens. - 1: interrupt happens. - [Bit3]Read Function ..Key Scan Interrupt Status - 0: No Key Scan interrupt happens. - 1: Key Scan interrupt happens. - [Bit2]Read Function..Interrupt Status - 0: No interrupt happens. - 1: interrupt happens. - [Bit1]Read Function..Interrupt Status - 0: No interrupt happens. - 1: interrupt happens. - [Bit0]Read Function..Interrupt Status - 0: No interrupt happens. - 1: interrupt happens. - */ - unsigned char temp; - LCD_CmdWrite(0x0C); - temp = LCD_DataRead(); - return temp; -} -void Clear_Resume_Interrupt_Flag(void) -{ - /* - Resume Interrupt flag - Write Function .. Resume Interrupt Clear Bit - 0: No operation. - 1: Clear Resume interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0C); - temp = LCD_DataRead(); - temp |= cSetb7; - LCD_DataWrite(temp); -} -void Clear_ExtInterrupt_Input_Flag(void) -{ - /* - External Interrupt (PS[0] pin) flag - Write Function .. PS[0] pin edge Interrupt Clear Bit - 0: No operation. - 1: Clear the PS[0] pin edge interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0C); - temp = LCD_DataRead(); - temp |= cSetb6; - LCD_DataWrite(temp); -} -void Clear_I2CM_Interrupt_Flag(void) -{ - /* - I2C master Interrupt flag - Write Function.. I2C master Interrupt Clear Bit - 0: No operation. - 1: Clear the I2C master interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0C); - temp = LCD_DataRead(); - temp |= cSetb5; - LCD_DataWrite(temp); -} -void Clear_Vsync_Interrupt_Flag(void) -{ - /* - Vsync Time base interrupt flag - Write Function ..Vsync Interrupt Clear Bit - 0: No operation. - 1: Clear the interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0C); - temp = LCD_DataRead(); - temp |= cSetb4; - LCD_DataWrite(temp); -} -void Clear_KeyScan_Interrupt_Flag(void) -{ - /* - Key Scan Interrupt flag - Write Function..Key Scan Interrupt Clear Bit - 0: No operation. - 1: Clear the Key Scan interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0C); - temp = LCD_DataRead(); - temp |= cSetb3; - LCD_DataWrite(temp); -} -void Clear_DMA_Draw_BTE_Interrupt_Flag(void) -{ - /* - Serial flash DMA Complete | Draw task finished | BTE - Process Complete etc. Interrupt flag - Write Function.. Interrupt Clear Bit - 0: No operation. - 1: Clear interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0C); - temp = LCD_DataRead(); - temp |= cSetb2; - LCD_DataWrite(temp); -} -void Clear_PWM1_Interrupt_Flag(void) -{ - /* - PWM 1 timer Interrupt flag - Write Function..Interrupt Clear Bit - 0: No operation. - 1: Clear interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0C); - temp = LCD_DataRead(); - temp |= cSetb1; - LCD_DataWrite(temp); -} -void Clear_PWM0_Interrupt_Flag(void) -{ - /* - PWM 0 timer Interrupt flag - Write Function..Interrupt Clear Bit - 0: No operation. - 1: Clear interrupt. - */ - unsigned char temp; - LCD_CmdWrite(0x0C); - temp = LCD_DataRead(); - temp |= cSetb0; - LCD_DataWrite(temp); -} -//[0Dh]========================================================================= -void Mask_Resume_Interrupt_Flag(void) -{ - /* - Mask Resume Interrupt Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp |= cSetb7; - LCD_DataWrite(temp); -} -void Mask_ExtInterrupt_Input_Flag(void) -{ - /* - Mask External Interrupt (PS[0] pin) Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp |= cSetb6; - LCD_DataWrite(temp); -} -void Mask_I2CM_Interrupt_Flag(void) -{ - /* - Mask I2C Master Interrupt Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp |= cSetb5; - LCD_DataWrite(temp); -} -void Mask_Vsync_Interrupt_Flag(void) -{ - /* - Mask Vsync time base interrupt Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp |= cSetb4; - LCD_DataWrite(temp); -} -void Mask_KeyScan_Interrupt_Flag(void) -{ - /* - Mask Key Scan Interrupt Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp |= cSetb3; - LCD_DataWrite(temp); -} -void Mask_DMA_Draw_BTE_Interrupt_Flag(void) -{ - /* - Mask Serial flash DMA Complete | Draw task finished | BTE - Process Complete etc. Interrupt Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp |= cSetb2; - LCD_DataWrite(temp); -} -void Mask_PWM1_Interrupt_Flag(void) -{ - /* - Mask PWM timer 1 Interrupt Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp |= cSetb1; - LCD_DataWrite(temp); -} -void Mask_PWM0_Interrupt_Flag(void) -{ - /* - Mask PWM timer 0 Interrupt Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp |= cSetb0; - LCD_DataWrite(temp); -} - -void Enable_Resume_Interrupt_Flag(void) -{ - /* - Mask Resume Interrupt Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp &= cClrb7; - LCD_DataWrite(temp); -} -void Enable_ExtInterrupt_Inpur_Flag(void) -{ - /* - Mask External Interrupt (PS[0] pin) Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp &= cClrb6; - LCD_DataWrite(temp); -} -void Enable_I2CM_Interrupt_Flag(void) -{ - /* - Mask I2C Master Interrupt Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp &= cClrb5; - LCD_DataWrite(temp); -} -void Enable_Vsync_Interrupt_Flag(void) -{ - /* - Mask Vsync time base interrupt Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp &= cClrb4; - LCD_DataWrite(temp); -} -void Enable_KeyScan_Interrupt_Flag(void) -{ - /* - Mask Key Scan Interrupt Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp &= cClrb3; - LCD_DataWrite(temp); -} -void Enable_DMA_Draw_BTE_Interrupt_Flag(void) -{ - /* - Mask Serial flash DMA Complete | Draw task finished | BTE - Process Complete etc. Interrupt Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp &= cClrb2; - LCD_DataWrite(temp); -} -void Enable_PWM1_Interrupt_Flag(void) -{ - /* - Mask PWM timer 1 Interrupt Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp &= cClrb1; - LCD_DataWrite(temp); -} -void Enable_PWM0_Interrupt_Flag(void) -{ - /* - Mask PWM timer 0 Interrupt Flag - 0: Enable. - 1: Mask. - */ - unsigned char temp; - LCD_CmdWrite(0x0D); - temp = LCD_DataRead(); - temp &= cClrb0; - LCD_DataWrite(temp); -} - -//[0Eh]========================================================================= -void Enable_GPIOF_PullUp(void) -{ - /* - GPIO_F[7:0] Pull-Up Enable (XPDAT[23:19, 15:13]) - 0: Pull-Up Disable - 1: Pull-Up Enable - */ - unsigned char temp; - LCD_CmdWrite(0x0E); - temp = LCD_DataRead(); - temp |= cSetb5; - LCD_DataWrite(temp); -} -void Enable_GPIOE_PullUp(void) -{ - /* - GPIO_E[7:0] Pull-Up Enable (XPDAT[12:10, 7:3]) - 0: Pull-Up Disable - 1: Pull-Up Enable - */ - unsigned char temp; - LCD_CmdWrite(0x0E); - temp = LCD_DataRead(); - temp |= cSetb4; - LCD_DataWrite(temp); -} -void Enable_GPIOD_PullUp(void) -{ - /* - GPIO_D[7:0] Pull-Up Enable (XPDAT[18, 2, 17, 16, 9, 8, 1,0]) - 0: Pull-Up Disable - 1: Pull-Up Enable - */ - unsigned char temp; - LCD_CmdWrite(0x0E); - temp = LCD_DataRead(); - temp |= cSetb3; - LCD_DataWrite(temp); -} -void Enable_GPIOC_PullUp(void) -{ - /* - GPIO_C[6:0] Pull-Up Enable (XSDA, XSCL, XnSFCS1, - XnSFCS0, XMISO, XMOSI , XSCK) - 0: Pull-Up Disable - 1: Pull-Up Enable - */ - unsigned char temp; - LCD_CmdWrite(0x0E); - temp = LCD_DataRead(); - temp |= cSetb2; - LCD_DataWrite(temp); -} -void Enable_XDB15_8_PullUp(void) -{ - /* - XDB[15:8] Pull-Up Enable - 0: Pull-Up Disable - 1: Pull-Up Enable - */ - unsigned char temp; - LCD_CmdWrite(0x0E); - temp = LCD_DataRead(); - temp |= cSetb1; - LCD_DataWrite(temp); -} -void Enable_XDB7_0_PullUp(void) -{ - /* - XDB[7:0] Pull-Up Enable - 0: Pull-Up Disable - 1: Pull-Up Enable - */ - unsigned char temp; - LCD_CmdWrite(0x0E); - temp = LCD_DataRead(); - temp |= cSetb0; - LCD_DataWrite(temp); -} -void Disable_GPIOF_PullUp(void) -{ - /* - GPIO_F[7:0] Pull-Up Enable (XPDAT[23:19, 15:13]) - 0: Pull-Up Disable - 1: Pull-Up Enable - */ - unsigned char temp; - LCD_CmdWrite(0x0E); - temp = LCD_DataRead(); - temp &= cClrb5; - LCD_DataWrite(temp); -} -void Disable_GPIOE_PullUp(void) -{ - /* - GPIO_E[7:0] Pull-Up Enable (XPDAT[12:10, 7:3]) - 0: Pull-Up Disable - 1: Pull-Up Enable - */ - unsigned char temp; - LCD_CmdWrite(0x0E); - temp = LCD_DataRead(); - temp &= cClrb4; - LCD_DataWrite(temp); -} -void Disable_GPIOD_PullUp(void) -{ - /* - GPIO_D[7:0] Pull-Up Enable (XPDAT[18, 2, 17, 16, 9, 8, 1,0]) - 0: Pull-Up Disable - 1: Pull-Up Enable - */ - unsigned char temp; - LCD_CmdWrite(0x0E); - temp = LCD_DataRead(); - temp &= cClrb3; - LCD_DataWrite(temp); -} -void Disable_GPIOC_PullUp(void) -{ - /* - GPIO_C[6:0] Pull-Up Enable (XSDA, XSCL, XnSFCS1, - XnSFCS0, XMISO, XMOSI , XSCK) - 0: Pull-Up Disable - 1: Pull-Up Enable - */ - unsigned char temp; - LCD_CmdWrite(0x0E); - temp = LCD_DataRead(); - temp &= cClrb2; - LCD_DataWrite(temp); -} -void Disable_XDB15_8_PullUp(void) -{ - /* - XDB[15:8] Pull-Up Enable - 0: Pull-Up Disable - 1: Pull-Up Enable - */ - unsigned char temp; - LCD_CmdWrite(0x0E); - temp = LCD_DataRead(); - temp &= cClrb1; - LCD_DataWrite(temp); -} -void Disable_XDB7_0_PullUp(void) -{ - /* - XDB[7:0] Pull-Up Enable - 0: Pull-Up Disable - 1: Pull-Up Enable - */ - unsigned char temp; - LCD_CmdWrite(0x0E); - temp = LCD_DataRead(); - temp &= cClrb0; - LCD_DataWrite(temp); -} -//[0Fh]========================================================================= -void XPDAT18_Set_GPIO_D7(void) -{ - /* - XPDAT[18]  not scan function select - 0: GPIO-D7 - 1: KOUT[4] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp &= cClrb7; - LCD_DataWrite(temp); -} -void XPDAT18_Set_KOUT4(void) -{ - /* - XPDAT[18]  not scan function select - 0: GPIO-D7 - 1: KOUT[4] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp |= cSetb7; - LCD_DataWrite(temp); -} -void XPDAT17_Set_GPIO_D5(void) -{ - /* - XPDAT[17]  not scan function select - 0: GPIO-D5 - 1: KOUT[2] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp &= cClrb6; - LCD_DataWrite(temp); -} -void XPDAT17_Set_KOUT2(void) -{ - /* - XPDAT[17]  not scan function select - 0: GPIO-D5 - 1: KOUT[2] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp |= cSetb6; - LCD_DataWrite(temp); -} -void XPDAT16_Set_GPIO_D4(void) -{ - /* - XPDAT[16]  not scan function select - 0: GPIO-D4 - 1: KOUT[1] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp &= cClrb5; - LCD_DataWrite(temp); -} -void XPDAT16_Set_KOUT1(void) -{ - /* - XPDAT[16]  not scan function select - 0: GPIO-D4 - 1: KOUT[1] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp |= cSetb5; - LCD_DataWrite(temp); -} -void XPDAT9_Set_GPIO_D3(void) -{ - /* - XPDAT[9]  not scan function select - 0: GPIO-D3 - 1: KOUT[3] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp &= cClrb4; - LCD_DataWrite(temp); -} -void XPDAT9_Set_KOUT3(void) -{ - /* - XPDAT[9]  not scan function select - 0: GPIO-D3 - 1: KOUT[3] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp |= cSetb4; - LCD_DataWrite(temp); -} -void XPDAT8_Set_GPIO_D2(void) -{ - /* - XPDAT[8]  not scan function select - 0: GPIO-D2 - 1: KIN[3] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp &= cClrb3; - LCD_DataWrite(temp); -} -void XPDAT8_Set_KIN3(void) -{ - /* - XPDAT[8]  not scan function select - 0: GPIO-D2 - 1: KIN[3] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp |= cSetb3; - LCD_DataWrite(temp); -} -void XPDAT2_Set_GPIO_D6(void) -{ - /* - XPDAT[2]  not scan function select - 0: GPIO-D6 - 1: KIN[4] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp &= cClrb2; - LCD_DataWrite(temp); -} -void XPDAT2_Set_KIN4(void) -{ - /* - XPDAT[2]  not scan function select - 0: GPIO-D6 - 1: KIN[4] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp |= cSetb2; - LCD_DataWrite(temp); -} -void XPDAT1_Set_GPIO_D1(void) -{ - /* - XPDAT[1]  not scan function select - 0: GPIO-D1 - 1: KIN[2] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp &= cClrb1; - LCD_DataWrite(temp); -} -void XPDAT1_Set_KIN2(void) -{ - /* - XPDAT[1]  not scan function select - 0: GPIO-D1 - 1: KIN[2] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp |= cSetb1; - LCD_DataWrite(temp); -} -void XPDAT0_Set_GPIO_D0(void) -{ - /* - XPDAT[0]  not scan function select - 0: GPIO-D0 - 1: KIN[1] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp &= cClrb0; - LCD_DataWrite(temp); -} -void XPDAT0_Set_KIN1(void) -{ - /* - XPDAT[0]  not scan function select - 0: GPIO-D0 - 1: KIN[1] - */ - unsigned char temp; - LCD_CmdWrite(0x0F); - temp = LCD_DataRead(); - temp |= cSetb0; - LCD_DataWrite(temp); -} - -//[10h]========================================================================= -void Enable_PIP1(void) -{ - /* - PIP 1 window Enable/Disable - 0 : PIP 1 window disable. - 1 : PIP 1 window enable - PIP 1 window always on top of PIP 2 window. - */ - unsigned char temp; - LCD_CmdWrite(0x10); - temp = LCD_DataRead(); - temp |= cSetb7; - LCD_DataWrite(temp); -} -void Disable_PIP1(void) -{ - /* - PIP 1 window Enable/Disable - 0 : PIP 1 window disable. - 1 : PIP 1 window enable - PIP 1 window always on top of PIP 2 window. - */ - unsigned char temp; - LCD_CmdWrite(0x10); - temp = LCD_DataRead(); - temp &= cClrb7; - LCD_DataWrite(temp); -} -void Enable_PIP2(void) -{ - /* - PIP 2 window Enable/Disable - 0 : PIP 2 window disable. - 1 : PIP 2 window enable - PIP 1 window always on top of PIP 2 window. - */ - unsigned char temp; - LCD_CmdWrite(0x10); - temp = LCD_DataRead(); - temp |= cSetb6; - LCD_DataWrite(temp); -} -void Disable_PIP2(void) -{ - /* - PIP 2 window Enable/Disable - 0 : PIP 2 window disable. - 1 : PIP 2 window enable - PIP 1 window always on top of PIP 2 window. - */ - unsigned char temp; - LCD_CmdWrite(0x10); - temp = LCD_DataRead(); - temp &= cClrb6; - LCD_DataWrite(temp); -} -void Select_PIP1_Parameter(void) -{ - /* - 0: To configure PIP 1ˇs parameters. - 1: To configure PIP 2ˇs parameters.. - */ - unsigned char temp; - LCD_CmdWrite(0x10); - temp = LCD_DataRead(); - temp &= cClrb4; - LCD_DataWrite(temp); -} -void Select_PIP2_Parameter(void) -{ - /* - 0: To configure PIP 1ˇs parameters. - 1: To configure PIP 2ˇs parameters.. - */ - unsigned char temp; - LCD_CmdWrite(0x10); - temp = LCD_DataRead(); - temp |= cSetb4; - LCD_DataWrite(temp); -} -void Select_Main_Window_8bpp(void) -{ - /* - Main Window Color Depth Setting - 00b: 8-bpp generic TFT, i.e. 256 colors. - 01b: 16-bpp generic TFT, i.e. 65K colors. - 1xb: 24-bpp generic TFT, i.e. 1.67M colors. - */ - unsigned char temp; - LCD_CmdWrite(0x10); - temp = LCD_DataRead(); - temp &= cClrb3; - temp &= cClrb2; - LCD_DataWrite(temp); -} -void Select_Main_Window_16bpp(void) -{ - /* - Main Window Color Depth Setting - 00b: 8-bpp generic TFT, i.e. 256 colors. - 01b: 16-bpp generic TFT, i.e. 65K colors. - 1xb: 24-bpp generic TFT, i.e. 1.67M colors. - */ - unsigned char temp; - LCD_CmdWrite(0x10); - temp = LCD_DataRead(); - temp &= cClrb3; - temp |= cSetb2; - LCD_DataWrite(temp); -} -void Select_Main_Window_24bpp(void) -{ - /* - Main Window Color Depth Setting - 00b: 8-bpp generic TFT, i.e. 256 colors. - 01b: 16-bpp generic TFT, i.e. 65K colors. - 1xb: 24-bpp generic TFT, i.e. 1.67M colors. - */ - unsigned char temp; - LCD_CmdWrite(0x10); - temp = LCD_DataRead(); - temp |= cSetb3; - //temp |= cSetb2; - LCD_DataWrite(temp); -} -//[11h]========================================================================= -void Select_PIP2_Window_8bpp(void) -{ - /* - PIP 1 Window Color Depth Setting - 00b: 8-bpp generic TFT, i.e. 256 colors. - 01b: 16-bpp generic TFT, i.e. 65K colors. - 1xb: 24-bpp generic TFT, i.e. 1.67M colors. - */ - unsigned char temp; - LCD_CmdWrite(0x11); - temp = LCD_DataRead(); - temp &= cClrb1; - temp &= cClrb0; - LCD_DataWrite(temp); -} -void Select_PIP2_Window_16bpp(void) -{ - /* - PIP 1 Window Color Depth Setting - 00b: 8-bpp generic TFT, i.e. 256 colors. - 01b: 16-bpp generic TFT, i.e. 65K colors. - 1xb: 24-bpp generic TFT, i.e. 1.67M colors. - */ - unsigned char temp; - LCD_CmdWrite(0x11); - temp = LCD_DataRead(); - temp &= cClrb1; - temp |= cSetb0; - LCD_DataWrite(temp); -} -void Select_PIP2_Window_24bpp(void) -{ - /* - PIP 1 Window Color Depth Setting - 00b: 8-bpp generic TFT, i.e. 256 colors. - 01b: 16-bpp generic TFT, i.e. 65K colors. - 1xb: 24-bpp generic TFT, i.e. 1.67M colors. - */ - unsigned char temp; - LCD_CmdWrite(0x11); - temp = LCD_DataRead(); - temp |= cSetb1; - temp &= cClrb0; - LCD_DataWrite(temp); -} -void Select_PIP1_Window_8bpp(void) -{ - /* - PIP 2 Window Color Depth Setting - 00b: 8-bpp generic TFT, i.e. 256 colors. - 01b: 16-bpp generic TFT, i.e. 65K colors. - 1xb: 24-bpp generic TFT, i.e. 1.67M colors. - */ - unsigned char temp; - LCD_CmdWrite(0x11); - temp = LCD_DataRead(); - temp &= cClrb3; - temp &= cClrb2; - LCD_DataWrite(temp); -} -void Select_PIP1_Window_16bpp(void) -{ - /* - PIP 2 Window Color Depth Setting - 00b: 8-bpp generic TFT, i.e. 256 colors. - 01b: 16-bpp generic TFT, i.e. 65K colors. - 1xb: 24-bpp generic TFT, i.e. 1.67M colors. - */ - unsigned char temp; - LCD_CmdWrite(0x11); - temp = LCD_DataRead(); - temp &= cClrb3; - temp |= cSetb2; - LCD_DataWrite(temp); -} -void Select_PIP1_Window_24bpp(void) -{ - /* - PIP 2 Window Color Depth Setting - 00b: 8-bpp generic TFT, i.e. 256 colors. - 01b: 16-bpp generic TFT, i.e. 65K colors. - 1xb: 24-bpp generic TFT, i.e. 1.67M colors. - */ - unsigned char temp; - LCD_CmdWrite(0x11); - temp = LCD_DataRead(); - temp |= cSetb3; - temp &= cClrb2; - LCD_DataWrite(temp); -} - -//[12h]========================================================================= -void PCLK_Rising(void) -{ - /* - PCLK Inversion - 0: PDAT, DE, HSYNC etc. Drive(/ change) at PCLK falling edge. - 1: PDAT, DE, HSYNC etc. Drive(/ change) at PCLK rising edge. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp &= cClrb7; - LCD_DataWrite(temp); -} -void PCLK_Falling(void) -{ - /* - PCLK Inversion - 0: PDAT, DE, HSYNC etc. Drive(/ change) at PCLK falling edge. - 1: PDAT, DE, HSYNC etc. Drive(/ change) at PCLK rising edge. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp |= cSetb7; - LCD_DataWrite(temp); -} -void Display_ON(void) -{ - /* - Display ON/OFF - 0b: Display Off. - 1b: Display On. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - syslog(LOG_NOTICE, "Display_ON.pre_read=%02x\n", temp); - temp |= cSetb6; - LCD_DataWrite(temp); - temp = LCD_DataRead(); - syslog(LOG_NOTICE, "Display_ON.write_read=%02x\n", temp); -} - -void Display_OFF(void) -{ - /* - Display ON/OFF - 0b: Display Off. - 1b: Display On. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp &= cClrb6; - LCD_DataWrite(temp); -} -void Color_Bar_ON(void) -{ - /* - Display Test Color Bar - 0b: Disable. - 1b: Enable. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp |= cSetb5; - LCD_DataWrite(temp); -} -void Color_Bar_OFF(void) -{ - /* - Display Test Color Bar - 0b: Disable. - 1b: Enable. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp &= cClrb5; - LCD_DataWrite(temp); -} -void HSCAN_L_to_R(void) -{ - /* - Horizontal Scan Direction - 0 : From Left to Right - 1 : From Right to Left - PIP window will be disabled when HDIR set as 1. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp &= cClrb4; - LCD_DataWrite(temp); -} -void HSCAN_R_to_L(void) -{ - /* - Horizontal Scan Direction - 0 : From Left to Right - 1 : From Right to Left - PIP window will be disabled when HDIR set as 1. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp |= cSetb4; - LCD_DataWrite(temp); -} -void VSCAN_T_to_B(void) -{ - /* - Vertical Scan direction - 0 : From Top to Bottom - 1 : From bottom to Top - PIP window will be disabled when VDIR set as 1. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp &= cClrb3; - LCD_DataWrite(temp); -} -void VSCAN_B_to_T(void) -{ - /* - Vertical Scan direction - 0 : From Top to Bottom - 1 : From bottom to Top - PIP window will be disabled when VDIR set as 1. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp |= cSetb3; - LCD_DataWrite(temp); -} -void PDATA_Set_RGB(void) -{ - /* - parallel PDATA[23:0] Output Sequence - 000b : RGB. - 001b : RBG. - 010b : GRB. - 011b : GBR. - 100b : BRG. - 101b : BGR. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp &=0xf8; - LCD_DataWrite(temp); -} -void PDATA_Set_RBG(void) -{ - /* - parallel PDATA[23:0] Output Sequence - 000b : RGB. - 001b : RBG. - 010b : GRB. - 011b : GBR. - 100b : BRG. - 101b : BGR. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp &=0xf8; - temp |= cSetb0; - LCD_DataWrite(temp); -} -void PDATA_Set_GRB(void) -{ - /* - parallel PDATA[23:0] Output Sequence - 000b : RGB. - 001b : RBG. - 010b : GRB. - 011b : GBR. - 100b : BRG. - 101b : BGR. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp &=0xf8; - temp |= cSetb1; - LCD_DataWrite(temp); -} -void PDATA_Set_GBR(void) -{ - /* - parallel PDATA[23:0] Output Sequence - 000b : RGB. - 001b : RBG. - 010b : GRB. - 011b : GBR. - 100b : BRG. - 101b : BGR. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp &=0xf8; - temp |= cSetb1; - temp |= cSetb0; - LCD_DataWrite(temp); -} -void PDATA_Set_BRG(void) -{ - /* - parallel PDATA[23:0] Output Sequence - 000b : RGB. - 001b : RBG. - 010b : GRB. - 011b : GBR. - 100b : BRG. - 101b : BGR. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp &=0xf8; - temp |= cSetb2; - LCD_DataWrite(temp); -} -void PDATA_Set_BGR(void) -{ - /* - parallel PDATA[23:0] Output Sequence - 000b : RGB. - 001b : RBG. - 010b : GRB. - 011b : GBR. - 100b : BRG. - 101b : BGR. - */ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp &=0xf8; - temp |= cSetb2; - temp |= cSetb0; - LCD_DataWrite(temp); -} - -void PDATA_IDLE_STATE(void) -{ - unsigned char temp; - LCD_CmdWrite(0x12); - temp = LCD_DataRead(); - temp |=0x07; - LCD_DataWrite(temp); -} - - -//[13h]========================================================================= -void HSYNC_Low_Active(void) -{ - /* - HSYNC Polarity - 0 : Low active. - 1 : High active. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp &= cClrb7; - LCD_DataWrite(temp); -} -void HSYNC_High_Active(void) -{ - /* - HSYNC Polarity - 0 : Low active. - 1 : High active. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp |= cSetb7; - LCD_DataWrite(temp); -} -void VSYNC_Low_Active(void) -{ - /* - VSYNC Polarity - 0 : Low active. - 1 : High active. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp &= cClrb6; - LCD_DataWrite(temp); -} -void VSYNC_High_Active(void) -{ - /* - VSYNC Polarity - 0 : Low active. - 1 : High active. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp |= cSetb6; - LCD_DataWrite(temp); -} -void DE_Low_Active(void) -{ - /* - DE Polarity - 0 : High active. - 1 : Low active. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp |= cSetb5; - LCD_DataWrite(temp); -} -void DE_High_Active(void) -{ - /* - DE Polarity - 0 : High active. - 1 : Low active. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp &= cClrb5; - LCD_DataWrite(temp); -} -void Idle_DE_Low(void) -{ - /* - DE IDLE STATE(When STANDBY or DISPLAY OFF ) - 0 : Pin ¨DE〃 output is low. - 1 : Pin ¨DE〃 output is high. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp &= cClrb4; - LCD_DataWrite(temp); -} -void Idle_DE_High(void) -{ - /* - DE IDLE STATE(When STANDBY or DISPLAY OFF ) - 0 : Pin ¨DE〃 output is low. - 1 : Pin ¨DE〃 output is high. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp |= cSetb4; - LCD_DataWrite(temp); -} -void Idle_PCLK_Low(void) -{ - /* - PCLK IDLE STATE(When STANDBY or DISPLAY OFF ) - 0 : Pin ¨PCLK〃 output is low. - 1 : Pin ¨PCLK〃 output is high. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp &= cClrb3; - LCD_DataWrite(temp); -} -void Idle_PCLK_High(void) -{ - /* - PCLK IDLE STATE(When STANDBY or DISPLAY OFF ) - 0 : Pin ¨PCLK〃 output is low. - 1 : Pin ¨PCLK〃 output is high. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp |= cSetb3; - LCD_DataWrite(temp); -} -void Idle_PDAT_Low(void) -{ - /* - PDAT IDLE STATE(When STANDBY or DISPLAY OFF ) - 0 : Pins ¨PDAT[23:0]〃 output is low. - 1 : Pins ¨PCLK[23:0]〃 output is high. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp &= cClrb2; - LCD_DataWrite(temp); -} -void Idle_PDAT_High(void) -{ - /* - PDAT IDLE STATE(When STANDBY or DISPLAY OFF ) - 0 : Pins ¨PDAT[23:0]〃 output is low. - 1 : Pins ¨PCLK[23:0]〃 output is high. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp |= cSetb2; - LCD_DataWrite(temp); -} -void Idle_HSYNC_Low(void) -{ - /* - HSYNC IDLE STATE(When STANDBY or DISPLAY OFF ) - 0 : Pin ¨HSYNC〃 output is low. - 1 : Pin ¨HSYNC〃 output is high. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp &= cClrb1; - LCD_DataWrite(temp); -} -void Idle_HSYNC_High(void) -{ - /* - HSYNC IDLE STATE(When STANDBY or DISPLAY OFF ) - 0 : Pin ¨HSYNC〃 output is low. - 1 : Pin ¨HSYNC〃 output is high. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp |= cSetb1; - LCD_DataWrite(temp); -} -void Idle_VSYNC_Low(void) -{ - /* - VSYNC IDLE STATE(When STANDBY or DISPLAY OFF ) - 0 : Pin ¨VSYNC〃 output is low. - 1 : Pin ¨VSYNC〃 output is high. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp &= cClrb0; - LCD_DataWrite(temp); -} -void Idle_VSYNC_High(void) -{ - /* - VSYNC IDLE STATE(When STANDBY or DISPLAY OFF ) - 0 : Pin ¨VSYNC〃 output is low. - 1 : Pin ¨VSYNC〃 output is high. - */ - unsigned char temp; - LCD_CmdWrite(0x13); - temp = LCD_DataRead(); - temp |= cSetb0; - LCD_DataWrite(temp); -} - -//[14h][15h][1Ah][1Bh]========================================================================= - -void LCD_HorizontalWidth_VerticalHeight(unsigned short WX,unsigned short HY) -{ - /* - [14h] Horizontal Display Width Setting Bit[7:0] - [15h] Horizontal Display Width Fine Tuning (HDWFT) [3:0] - The register specifies the LCD panel horizontal display width in - the unit of 8 pixels resolution. - Horizontal display width(pixels) = (HDWR + 1) * 8 + HDWFTR - - [1Ah] Vertical Display Height Bit[7:0] - Vertical Display Height(Line) = VDHR + 1 - [1Bh] Vertical Display Height Bit[10:8] - Vertical Display Height(Line) = VDHR + 1 - */ - unsigned char temp; - - if(WX<8) - { - LCD_CmdWrite(0x14); - LCD_DataWrite(0x00); - LCD_CmdWrite(0x15); - LCD_DataWrite(WX); - temp=HY-1; - LCD_CmdWrite(0x1A); - LCD_DataWrite(temp); - temp=(HY-1)>>8; - LCD_CmdWrite(0x1B); - LCD_DataWrite(temp); - } - else - { - temp=(WX/8)-1; - LCD_CmdWrite(0x14); - LCD_DataWrite(temp); - temp=WX%8; - LCD_CmdWrite(0x15); - LCD_DataWrite(temp); - temp=HY-1; - LCD_CmdWrite(0x1A); - LCD_DataWrite(temp); - temp=(HY-1)>>8; - LCD_CmdWrite(0x1B); - LCD_DataWrite(temp); - } -} -//[16h][17h]========================================================================= -void LCD_Horizontal_Non_Display(unsigned short WX) -{ - /* - [16h] Horizontal Non-Display Period(HNDR) Bit[4:0] - This register specifies the horizontal non-display period. Also - called back porch. - Horizontal non-display period(pixels) = (HNDR + 1) * 8 + HNDFTR - - [17h] Horizontal Non-Display Period Fine Tuning(HNDFT) [3:0] - This register specifies the fine tuning for horizontal non-display - period; it is used to support the SYNC mode panel. Each level of - this modulation is 1-pixel. - Horizontal non-display period(pixels) = (HNDR + 1) * 8 + HNDFTR - */ - unsigned char temp; - - if(WX<8) - { - LCD_CmdWrite(0x16); - LCD_DataWrite(0x00); - LCD_CmdWrite(0x17); - LCD_DataWrite(WX); - } - else - { - temp=(WX/8)-1; - LCD_CmdWrite(0x16); - LCD_DataWrite(temp); - temp=WX%8; - LCD_CmdWrite(0x17); - LCD_DataWrite(temp); - } -} -//[18h]========================================================================= -void LCD_HSYNC_Start_Position(unsigned short WX) -{ - /* - [18h] HSYNC Start Position[4:0] - The starting position from the end of display area to the - beginning of HSYNC. Each level of this modulation is 8-pixel. - Also called front porch. - HSYNC Start Position(pixels) = (HSTR + 1)x8 - */ - unsigned char temp; - - if(WX<8) - { - LCD_CmdWrite(0x18); - LCD_DataWrite(0x00); - } - else - { - temp=(WX/8)-1; - LCD_CmdWrite(0x18); - LCD_DataWrite(temp); - } -} -//[19h]========================================================================= -void LCD_HSYNC_Pulse_Width(unsigned short WX) -{ - /* - [19h] HSYNC Pulse Width(HPW) [4:0] - The period width of HSYNC. - HSYNC Pulse Width(pixels) = (HPW + 1)x8 - */ - unsigned char temp; - - if(WX<8) - { - LCD_CmdWrite(0x19); - LCD_DataWrite(0x00); - } - else - { - temp=(WX/8)-1; - LCD_CmdWrite(0x19); - LCD_DataWrite(temp); - } -} -//[1Ch][1Dh]========================================================================= -void LCD_Vertical_Non_Display(unsigned short HY) -{ - /* - [1Ch] Vertical Non-Display Period Bit[7:0] - Vertical Non-Display Period(Line) = (VNDR + 1) - - [1Dh] Vertical Non-Display Period Bit[9:8] - Vertical Non-Display Period(Line) = (VNDR + 1) - */ - unsigned char temp; - temp=HY-1; - LCD_CmdWrite(0x1C); - LCD_DataWrite(temp); - LCD_CmdWrite(0x1D); - LCD_DataWrite(temp>>8); -} -//[1Eh]========================================================================= -void LCD_VSYNC_Start_Position(unsigned short HY) -{ - /* - [1Eh] VSYNC Start Position[7:0] - The starting position from the end of display area to the beginning of VSYNC. - VSYNC Start Position(Line) = (VSTR + 1) - */ - unsigned char temp; - temp=HY-1; - LCD_CmdWrite(0x1E); - LCD_DataWrite(temp); -} -//[1Fh]========================================================================= -void LCD_VSYNC_Pulse_Width(unsigned short HY) -{ - /* - [1Fh] VSYNC Pulse Width[5:0] - The pulse width of VSYNC in lines. - VSYNC Pulse Width(Line) = (VPWR + 1) - */ - unsigned char temp; - temp=HY-1; - LCD_CmdWrite(0x1F); - LCD_DataWrite(temp); -} -//[20h][21h][22h][23h]========================================================================= -void Main_Image_Start_Address(unsigned long Addr) -{ - /* - [20h] Main Image Start Address[7:2] - [21h] Main Image Start Address[15:8] - [22h] Main Image Start Address [23:16] - [23h] Main Image Start Address [31:24] - */ - LCD_RegisterWrite(0x20,Addr); - LCD_RegisterWrite(0x21,Addr>>8); - LCD_RegisterWrite(0x22,Addr>>16); - LCD_RegisterWrite(0x23,Addr>>24); -} -//[24h][25h]========================================================================= -void Main_Image_Width(unsigned short WX) -{ - /* - [24h] Main Image Width [7:0] - [25h] Main Image Width [12:8] - Unit: Pixel. - It must be divisible by 4. MIW Bit [1:0] tie to ¨0〃 internally. - The value is physical pixel number. Maximum value is 8188 pixels - */ - LCD_RegisterWrite(0x24,WX); - LCD_RegisterWrite(0x25,WX>>8); -} -//[26h][27h][28h][29h]========================================================================= -void Main_Window_Start_XY(unsigned short WX,unsigned short HY) -{ - /* - [26h] Main Window Upper-Left corner X-coordination [7:0] - [27h] Main Window Upper-Left corner X-coordination [12:8] - Reference Main Image coordination. - Unit: Pixel - It must be divisible by 4. MWULX Bit [1:0] tie to ¨0〃 internally. - X-axis coordination plus Horizontal display width cannot large than 8188. - - [28h] Main Window Upper-Left corner Y-coordination [7:0] - [29h] Main Window Upper-Left corner Y-coordination [12:8] - Reference Main Image coordination. - Unit: Pixel - Range is between 0 and 8191. - */ - LCD_RegisterWrite(0x26,WX); - LCD_RegisterWrite(0x27,WX>>8); - LCD_RegisterWrite(0x28,HY); - LCD_RegisterWrite(0x29,HY>>8); -} -//[2Ah][2Bh][2Ch][2Dh]========================================================================= -void PIP_Display_Start_XY(unsigned short WX,unsigned short HY) -{ - /* - [2Ah] PIP Window Display Upper-Left corner X-coordination [7:0] - [2Bh] PIP Window Display Upper-Left corner X-coordination [12:8] - Reference Main Window coordination. - Unit: Pixel - It must be divisible by 4. PWDULX Bit [1:0] tie to ¨0〃 internally. - X-axis coordination should less than horizontal display width. - According to bit of Select Configure PIP 1 or 2 Windowˇs parameters. - Function bit will be configured for relative PIP window. - - [2Ch] PIP Window Display Upper-Left corner Y-coordination [7:0] - [2Dh] PIP Window Display Upper-Left corner Y-coordination [12:8] - Reference Main Window coordination. - Unit: Pixel - Y-axis coordination should less than vertical display height. - According to bit of Select Configure PIP 1 or 2 Windowˇs parameters. - Function bit will be configured for relative PIP window. - */ - LCD_RegisterWrite(0x2A,WX); - LCD_RegisterWrite(0x2B,WX>>8); - LCD_RegisterWrite(0x2C,HY); - LCD_RegisterWrite(0x2D,HY>>8); -} -//[2Eh][2Fh][30h][31h]========================================================================= -void PIP_Image_Start_Address(unsigned long Addr) -{ - /* - [2Eh] PIP Image Start Address[7:2] - [2Fh] PIP Image Start Address[15:8] - [30h] PIP Image Start Address [23:16] - [31h] PIP Image Start Address [31:24] - */ - LCD_RegisterWrite(0x2E,Addr); - LCD_RegisterWrite(0x2F,Addr>>8); - LCD_RegisterWrite(0x30,Addr>>16); - LCD_RegisterWrite(0x31,Addr>>24); -} -//[32h][33h]========================================================================= -void PIP_Image_Width(unsigned short WX) -{ - /* - [32h] PIP Image Width [7:0] - [33h] PIP Image Width [12:8] - Unit: Pixel. - It must be divisible by 4. PIW Bit [1:0] tie to ¨0〃 internally. - The value is physical pixel number. - This width should less than horizontal display width. - According to bit of Select Configure PIP 1 or 2 Windowˇs parameters. - Function bit will be configured for relative PIP window. - */ - LCD_RegisterWrite(0x32,WX); - LCD_RegisterWrite(0x33,WX>>8); -} -//[34h][35h][36h][37h]========================================================================= -void PIP_Window_Image_Start_XY(unsigned short WX,unsigned short HY) -{ - /* - [34h] PIP 1 or 2 Window Image Upper-Left corner X-coordination [7:0] - [35h] PIP Window Image Upper-Left corner X-coordination [12:8] - Reference PIP Image coordination. - Unit: Pixel - It must be divisible by 4. PWIULX Bit [1:0] tie to ¨0〃 internally. - X-axis coordination plus PIP image width cannot large than 8188. - According to bit of Select Configure PIP 1 or 2 Windowˇs parameters. - Function bit will be configured for relative PIP window. - - [36h] PIP Windows Display Upper-Left corner Y-coordination [7:0] - [37h] PIP Windows Image Upper-Left corner Y-coordination [12:8] - Reference PIP Image coordination. - Unit: Pixel - Y-axis coordination plus PIP window height should less than 8191. - According to bit of Select Configure PIP 1 or 2 Windowˇs parameters. - Function bit will be configured for relative PIP window. - */ - LCD_RegisterWrite(0x34,WX); - LCD_RegisterWrite(0x35,WX>>8); - LCD_RegisterWrite(0x36,HY); - LCD_RegisterWrite(0x37,HY>>8); -} -//[38h][39h][3Ah][3Bh]========================================================================= -void PIP_Window_Width_Height(unsigned short WX,unsigned short HY) -{ - /* - [38h] PIP Window Width [7:0] - [39h] PIP Window Width [10:8] - Unit: Pixel. - It must be divisible by 4. The value is physical pixel number. - Maximum value is 8188 pixels. - According to bit of Select Configure PIP 1 or 2 Windowˇs parameters. - Function bit will be configured for relative PIP window. - - [3Ah] PIP Window Height [7:0] - [3Bh] PIP Window Height [10:8] - Unit: Pixel - The value is physical pixel number. Maximum value is 8191 pixels. - According to bit of Select Configure PIP 1 or 2 Windowˇs parameters. - Function bit will be configured for relative PIP window. - */ - LCD_RegisterWrite(0x38,WX); - LCD_RegisterWrite(0x39,WX>>8); - LCD_RegisterWrite(0x3A,HY); - LCD_RegisterWrite(0x3B,HY>>8); -} - -//[3Ch]========================================================================= -void Enable_Graphic_Cursor(void) -{ - /* - Graphic Cursor Enable - 0 : Graphic Cursor disable. - 1 : Graphic Cursor enable. - */ - unsigned char temp; - LCD_CmdWrite(0x3C); - temp = LCD_DataRead(); - temp |= cSetb4; - LCD_DataWrite(temp); -} -void Disable_Graphic_Cursor(void) -{ - /* - Graphic Cursor Enable - 0 : Graphic Cursor disable. - 1 : Graphic Cursor enable. - */ - unsigned char temp; - LCD_CmdWrite(0x3C); - temp = LCD_DataRead(); - temp &= cClrb4; - LCD_DataWrite(temp); -} -// -void Select_Graphic_Cursor_1(void) -{ - /* - Graphic Cursor Selection Bit - Select one from four graphic cursor types. (00b to 11b) - 00b : Graphic Cursor Set 1. - 01b : Graphic Cursor Set 2. - 10b : Graphic Cursor Set 3. - 11b : Graphic Cursor Set 4. - */ - unsigned char temp; - LCD_CmdWrite(0x3C); - temp = LCD_DataRead(); - temp &= cClrb3; - temp &= cClrb2; - LCD_DataWrite(temp); -} -void Select_Graphic_Cursor_2(void) -{ - /* - Graphic Cursor Selection Bit - Select one from four graphic cursor types. (00b to 11b) - 00b : Graphic Cursor Set 1. - 01b : Graphic Cursor Set 2. - 10b : Graphic Cursor Set 3. - 11b : Graphic Cursor Set 4. - */ - unsigned char temp; - LCD_CmdWrite(0x3C); - temp = LCD_DataRead(); - temp &= cClrb3; - temp |= cSetb2; - LCD_DataWrite(temp); -} -void Select_Graphic_Cursor_3(void) -{ - /* - Graphic Cursor Selection Bit - Select one from four graphic cursor types. (00b to 11b) - 00b : Graphic Cursor Set 1. - 01b : Graphic Cursor Set 2. - 10b : Graphic Cursor Set 3. - 11b : Graphic Cursor Set 4. - */ - unsigned char temp; - LCD_CmdWrite(0x3C); - temp = LCD_DataRead(); - temp |= cSetb3; - temp &= cClrb2; - LCD_DataWrite(temp); -} -void Select_Graphic_Cursor_4(void) -{ - /* - Graphic Cursor Selection Bit - Select one from four graphic cursor types. (00b to 11b) - 00b : Graphic Cursor Set 1. - 01b : Graphic Cursor Set 2. - 10b : Graphic Cursor Set 3. - 11b : Graphic Cursor Set 4. - */ - unsigned char temp; - LCD_CmdWrite(0x3C); - temp = LCD_DataRead(); - temp |= cSetb3; - temp |= cSetb2; - LCD_DataWrite(temp); -} -// -void Enable_Text_Cursor(void) -{ - /* - Text Cursor Enable - 0 : Disable. - 1 : Enable. - Text cursor & Graphic cursor cannot enable simultaneously. - Graphic cursor has higher priority then Text cursor if enabled simultaneously. - */ - unsigned char temp; - LCD_CmdWrite(0x3C); - temp = LCD_DataRead(); - temp |= cSetb1; - LCD_DataWrite(temp); -} -void Disable_Text_Cursor(void) -{ - /* - Text Cursor Enable - 0 : Disable. - 1 : Enable. - Text cursor & Graphic cursor cannot enable simultaneously. - Graphic cursor has higher priority then Text cursor if enabled simultaneously. - */ - unsigned char temp; - LCD_CmdWrite(0x3C); - temp = LCD_DataRead(); - temp &= cClrb1; - LCD_DataWrite(temp); -} -// -void Enable_Text_Cursor_Blinking(void) -{ - /* - Text Cursor Blinking Enable - 0 : Disable. - 1 : Enable. - */ - unsigned char temp; - LCD_CmdWrite(0x3C); - temp = LCD_DataRead(); - temp |= cSetb0; - LCD_DataWrite(temp); -} -void Disable_Text_Cursor_Blinking(void) -{ - /* - Text Cursor Blinking Enable - 0 : Disable. - 1 : Enable. - */ - unsigned char temp; - LCD_CmdWrite(0x3C); - temp = LCD_DataRead(); - temp &= cClrb0; - LCD_DataWrite(temp); -} -//[3Dh]========================================================================= -void Blinking_Time_Frames(unsigned char temp) -{ - /* - Text Cursor Blink Time Setting (Unit: Frame) - 00h : 1 frame time. - 01h : 2 frames time. - 02h : 3 frames time. - : - FFh : 256 frames time. - */ - LCD_CmdWrite(0x3D); - LCD_DataWrite(temp); -} -//[3Eh]========================================================================= -void Text_Cursor_H_V(unsigned short WX,unsigned short HY) -{ - /* - [3Eh] - Text Cursor Horizontal Size Setting[4:0] - Unit : Pixel - Zero-based number. Value ¨0〃 means 1 pixel. - Note : When font is enlarged, the cursor setting will multiply the - same times as the font enlargement. - [3Fh] - Text Cursor Vertical Size Setting[4:0] - Unit : Pixel - Zero-based number. Value ¨0〃 means 1 pixel. - Note : When font is enlarged, the cursor setting will multiply the - same times as the font enlargement. - */ - LCD_CmdWrite(0x3E); - LCD_DataWrite(WX); - LCD_CmdWrite(0x3F); - LCD_DataWrite(HY); -} -//[40h][41h][42h][43h]========================================================================= -void Graphic_Cursor_XY(unsigned short WX,unsigned short HY) -{ - /* - [40h] Graphic Cursor Horizontal Location[7:0] - [41h] Graphic Cursor Horizontal Location[12:8] - [42h] Graphic Cursor Vertical Location[7:0] - [43h] Graphic Cursor Vertical Location[12:8] - Reference main Window coordination. - */ - LCD_RegisterWrite(0x40,WX); - LCD_RegisterWrite(0x41,WX>>8); - LCD_RegisterWrite(0x42,HY); - LCD_RegisterWrite(0x43,HY>>8); -} -//[44h]========================================================================= -void Set_Graphic_Cursor_Color_1(unsigned char temp) -{ - /* - [44h] Graphic Cursor Color 0 with 256 Colors - RGB Format [7:0] = RRRGGGBB. - */ - LCD_RegisterWrite(0x44,temp); -} -//[45h]========================================================================= -void Set_Graphic_Cursor_Color_2(unsigned char temp) -{ - /* - [45h] Graphic Cursor Color 1 with 256 Colors - RGB Format [7:0] = RRRGGGBB. - */ - LCD_RegisterWrite(0x45,temp); -} -//[50h][51h][52h][53h]========================================================================= -void Canvas_Image_Start_address(unsigned long Addr) -{ - /* - [50h] Start address of Canvas [7:0] - [51h] Start address of Canvas [15:8] - [52h] Start address of Canvas [23:16] - [53h] Start address of Canvas [31:24] - */ - LCD_RegisterWrite(0x50,Addr); - LCD_RegisterWrite(0x51,Addr>>8); - LCD_RegisterWrite(0x52,Addr>>16); - LCD_RegisterWrite(0x53,Addr>>24); -} -//[54h][55h]========================================================================= -void Canvas_image_width(unsigned short WX) -{ - /* - [54h] Canvas image width [7:2] - [55h] Canvas image width [12:8] - */ - LCD_RegisterWrite(0x54,WX); - LCD_RegisterWrite(0x55,WX>>8); -} -//[56h][57h][58h][59h]========================================================================= -void Active_Window_XY(unsigned short WX,unsigned short HY) -{ - /* - [56h] Active Window Upper-Left corner X-coordination [7:0] - [57h] Active Window Upper-Left corner X-coordination [12:8] - [58h] Active Window Upper-Left corner Y-coordination [7:0] - [59h] Active Window Upper-Left corner Y-coordination [12:8] - */ - LCD_RegisterWrite(0x56,WX); - LCD_RegisterWrite(0x57,WX>>8); - LCD_RegisterWrite(0x58,HY); - LCD_RegisterWrite(0x59,HY>>8); -} -//[5Ah][5Bh][5Ch][5Dh]========================================================================= -void Active_Window_WH(unsigned short WX,unsigned short HY) -{ - /* - [5Ah] Width of Active Window [7:0] - [5Bh] Width of Active Window [12:8] - [5Ch] Height of Active Window [7:0] - [5Dh] Height of Active Window [12:8] - */ - LCD_RegisterWrite(0x5A,WX); - LCD_RegisterWrite(0x5B,WX>>8); - LCD_RegisterWrite(0x5C,HY); - LCD_RegisterWrite(0x5D,HY>>8); -} -//[5Eh]========================================================================= -void Select_Write_Data_Position(void) -{ - /* - Select to read back Graphic Read/Write position - 0: read back Graphic Write position - 1: read back Graphic Read position - */ - unsigned char temp; - LCD_CmdWrite(0x5E); - temp = LCD_DataRead(); - temp &= cClrb3; - LCD_DataWrite(temp); -} -void Select_Read_Data_Position(void) -{ - /* - Select to read back Graphic Read/Write position - 0: read back Graphic Write position - 1: read back Graphic Read position - */ - unsigned char temp; - LCD_CmdWrite(0x5E); - temp = LCD_DataRead(); - temp |= cSetb3; - LCD_DataWrite(temp); -} -void Memory_XY_Mode(void) -{ - /* - Canvas addressing mode - 0: Block mode (X-Y coordination addressing) - 1: linear mode - */ - unsigned char temp; - LCD_CmdWrite(0x5E); - temp = LCD_DataRead(); - temp &= cClrb2; - LCD_DataWrite(temp); -} -void Memory_Linear_Mode(void) -{ - /* - Canvas addressing mode - 0: Block mode (X-Y coordination addressing) - 1: linear mode - */ - unsigned char temp; - LCD_CmdWrite(0x5E); - temp = LCD_DataRead(); - temp |= cSetb2; - LCD_DataWrite(temp); -} -void Memory_8bpp_Mode(void) -{ - /* - Canvas imageˇs color depth & memory R/W data width - In Block Mode: - 00: 8bpp - 01: 16bpp - 1x: 24bpp - In Linear Mode: - X0: 8-bits memory data read/write. - X1: 16-bits memory data read/write - */ - unsigned char temp; - LCD_CmdWrite(0x5E); - temp = LCD_DataRead(); - temp &= cClrb1; - temp &= cClrb0; - LCD_DataWrite(temp); -} -void Memory_16bpp_Mode(void) -{ - /* - Canvas imageˇs color depth & memory R/W data width - In Block Mode: - 00: 8bpp - 01: 16bpp - 1x: 24bpp - In Linear Mode: - X0: 8-bits memory data read/write. - X1: 16-bits memory data read/write - */ - unsigned char temp; - LCD_CmdWrite(0x5E); - temp = LCD_DataRead(); - temp &= cClrb1; - temp |= cSetb0; - LCD_DataWrite(temp); -} -void Memory_24bpp_Mode(void) -{ - /* - Canvas imageˇs color depth & memory R/W data width - In Block Mode: - 00: 8bpp - 01: 16bpp - 1x: 24bpp - In Linear Mode: - X0: 8-bits memory data read/write. - X1: 16-bits memory data read/write - */ - unsigned char temp; - LCD_CmdWrite(0x5E); - temp = LCD_DataRead(); - temp |= cSetb1; - temp |= cSetb0; - LCD_DataWrite(temp); -} - -//[5Fh][60h][61h][62h]========================================================================= -void Goto_Pixel_XY(unsigned short WX,unsigned short HY) -{ - /* - [Write]: Set Graphic Read/Write position - [Read]: Current Graphic Read/Write position - Read back is Read position or Write position depends on - REG[5Eh] bit3, Select to read back Graphic Read/Write position. - When DPRAM Linear mode:Graphic Read/Write Position [31:24][23:16][15:8][7:0] - When DPRAM Active window mode:Graphic Read/Write - Horizontal Position [12:8][7:0], - Vertical Position [12:8][7:0]. - Reference Canvas image coordination. Unit: Pixel - */ - LCD_RegisterWrite(0x5F,WX); - LCD_RegisterWrite(0x60,WX>>8); - LCD_RegisterWrite(0x61,HY); - LCD_RegisterWrite(0x62,HY>>8); -} -void Goto_Linear_Addr(unsigned long Addr) -{ - LCD_RegisterWrite(0x5F,Addr); - LCD_RegisterWrite(0x60,Addr>>8); - LCD_RegisterWrite(0x61,Addr>>16); - LCD_RegisterWrite(0x62,Addr>>24); -} - - -//[63h][64h][65h][66h]========================================================================= -void Goto_Text_XY(unsigned short WX,unsigned short HY) -{ - /* - Write: Set Text Write position - Read: Current Text Write position - Text Write X-coordination [12:8][7:0] - Text Write Y-coordination [12:8][7:0] - Reference Canvas image coordination. - Unit: Pixel - */ - LCD_RegisterWrite(0x63,WX); - LCD_RegisterWrite(0x64,WX>>8); - LCD_RegisterWrite(0x65,HY); - LCD_RegisterWrite(0x66,HY>>8); -} -//[67h]========================================================================= -/* -[bit7]Draw Line / Triangle Start Signal -Write Function -0 : Stop the drawing function. -1 : Start the drawing function. -Read Function -0 : Drawing function complete. -1 : Drawing function is processing. -[bit5]Fill function for Triangle Signal -0 : Non fill. -1 : Fill. -[bit1]Draw Triangle or Line Select Signal -0 : Draw Line -1 : Draw Triangle -*/ -void Start_Line(void) -{ - LCD_CmdWrite(0x67); - LCD_DataWrite(0x80); - Check_Busy_Draw(); -} -void Start_Triangle(void) -{ - LCD_CmdWrite(0x67); - LCD_DataWrite(0x82);//B1000_0010 - Check_Busy_Draw(); -} -void Start_Triangle_Fill(void) -{ - LCD_CmdWrite(0x67); - LCD_DataWrite(0xA2);//B1010_0010 - Check_Busy_Draw(); -} -//[68h][69h][6Ah][6Bh]========================================================================= -//线起点 -void Line_Start_XY(unsigned short WX,unsigned short HY) -{ - /* - [68h] Draw Line/Square/Triangle Start X-coordination [7:0] - [69h] Draw Line/Square/Triangle Start X-coordination [12:8] - [6Ah] Draw Line/Square/Triangle Start Y-coordination [7:0] - [6Bh] Draw Line/Square/Triangle Start Y-coordination [12:8] - */ - LCD_CmdWrite(0x68); - LCD_DataWrite(WX); - LCD_CmdWrite(0x69); - LCD_DataWrite(WX>>8); - LCD_CmdWrite(0x6A); - LCD_DataWrite(HY); - LCD_CmdWrite(0x6B); - LCD_DataWrite(HY>>8); -} -//[6Ch][6Dh][6Eh][6Fh]========================================================================= -//线终点 -void Line_End_XY(unsigned short WX,unsigned short HY) -{ - /* - [6Ch] Draw Line/Square/Triangle End X-coordination [7:0] - [6Dh] Draw Line/Square/Triangle End X-coordination [12:8] - [6Eh] Draw Line/Square/Triangle End Y-coordination [7:0] - [6Fh] Draw Line/Square/Triangle End Y-coordination [12:8] - */ - LCD_CmdWrite(0x6C); - LCD_DataWrite(WX); - LCD_CmdWrite(0x6D); - LCD_DataWrite(WX>>8); - LCD_CmdWrite(0x6E); - LCD_DataWrite(HY); - LCD_CmdWrite(0x6F); - LCD_DataWrite(HY>>8); -} -//[68h]~[73h]========================================================================= -//à-翴1 -void Triangle_Point1_XY(unsigned short WX,unsigned short HY) -{ - /* - [68h] Draw Line/Square/Triangle Start X-coordination [7:0] - [69h] Draw Line/Square/Triangle Start X-coordination [12:8] - [6Ah] Draw Line/Square/Triangle Start Y-coordination [7:0] - [6Bh] Draw Line/Square/Triangle Start Y-coordination [12:8] - */ - LCD_CmdWrite(0x68); - LCD_DataWrite(WX); - LCD_CmdWrite(0x69); - LCD_DataWrite(WX>>8); - LCD_CmdWrite(0x6A); - LCD_DataWrite(HY); - LCD_CmdWrite(0x6B); - LCD_DataWrite(HY>>8); -} -//à-翴2 -void Triangle_Point2_XY(unsigned short WX,unsigned short HY) -{ - /* - [6Ch] Draw Line/Square/Triangle End X-coordination [7:0] - [6Dh] Draw Line/Square/Triangle End X-coordination [12:8] - [6Eh] Draw Line/Square/Triangle End Y-coordination [7:0] - [6Fh] Draw Line/Square/Triangle End Y-coordination [12:8] - */ - LCD_CmdWrite(0x6C); - LCD_DataWrite(WX); - LCD_CmdWrite(0x6D); - LCD_DataWrite(WX>>8); - LCD_CmdWrite(0x6E); - LCD_DataWrite(HY); - LCD_CmdWrite(0x6F); - LCD_DataWrite(HY>>8); -} -//à-翴3 -void Triangle_Point3_XY(unsigned short WX,unsigned short HY) -{ - /* - [70h] Draw Triangle Point 3 X-coordination [7:0] - [71h] Draw Triangle Point 3 X-coordination [12:8] - [72h] Draw Triangle Point 3 Y-coordination [7:0] - [73h] Draw Triangle Point 3 Y-coordination [12:8] - */ - LCD_CmdWrite(0x70); - LCD_DataWrite(WX); - LCD_CmdWrite(0x71); - LCD_DataWrite(WX>>8); - LCD_CmdWrite(0x72); - LCD_DataWrite(HY); - LCD_CmdWrite(0x73); - LCD_DataWrite(HY>>8); -} -//よ癬翴 -void Square_Start_XY(unsigned short WX,unsigned short HY) -{ - /* - [68h] Draw Line/Square/Triangle Start X-coordination [7:0] - [69h] Draw Line/Square/Triangle Start X-coordination [12:8] - [6Ah] Draw Line/Square/Triangle Start Y-coordination [7:0] - [6Bh] Draw Line/Square/Triangle Start Y-coordination [12:8] - */ - LCD_CmdWrite(0x68); - LCD_DataWrite(WX); - LCD_CmdWrite(0x69); - LCD_DataWrite(WX>>8); - LCD_CmdWrite(0x6A); - LCD_DataWrite(HY); - LCD_CmdWrite(0x6B); - LCD_DataWrite(HY>>8); -} -//よ沧翴 -void Square_End_XY(unsigned short WX,unsigned short HY) -{ - /* - [6Ch] Draw Line/Square/Triangle End X-coordination [7:0] - [6Dh] Draw Line/Square/Triangle End X-coordination [12:8] - [6Eh] Draw Line/Square/Triangle End Y-coordination [7:0] - [6Fh] Draw Line/Square/Triangle End Y-coordination [12:8] - */ - LCD_CmdWrite(0x6C); - LCD_DataWrite(WX); - LCD_CmdWrite(0x6D); - LCD_DataWrite(WX>>8); - LCD_CmdWrite(0x6E); - LCD_DataWrite(HY); - LCD_CmdWrite(0x6F); - LCD_DataWrite(HY>>8); -} -//[76h]========================================================================= -/* -[bit7] -Draw Circle / Ellipse / Square /Circle Square Start Signal -Write Function -0 : Stop the drawing function. -1 : Start the drawing function. -Read Function -0 : Drawing function complete. -1 : Drawing function is processing. -[bit6] -Fill the Circle / Ellipse / Square / Circle Square Signal -0 : Non fill. -1 : fill. -[bit5 bit4] -Draw Circle / Ellipse / Square / Ellipse Curve / Circle Square Select -00 : Draw Circle / Ellipse -01 : Draw Circle / Ellipse Curve -10 : Draw Square. -11 : Draw Circle Square. -[bit1 bit0] -Draw Circle / Ellipse Curve Part Select -00 : -01 : -10 : -11 : -*/ -void Start_Circle_or_Ellipse(void) -{ - LCD_CmdWrite(0x76); - LCD_DataWrite(0x80);//B1000_XXXX - Check_Busy_Draw(); -} -void Start_Circle_or_Ellipse_Fill(void) -{ - LCD_CmdWrite(0x76); - LCD_DataWrite(0xC0);//B1100_XXXX - Check_Busy_Draw(); -} -// -void Start_Left_Down_Curve(void) -{ - LCD_CmdWrite(0x76); - LCD_DataWrite(0x90);//B1001_XX00 - Check_Busy_Draw(); -} -void Start_Left_Up_Curve(void) -{ - LCD_CmdWrite(0x76); - LCD_DataWrite(0x91);//B1001_XX01 - Check_Busy_Draw(); -} -void Start_Right_Up_Curve(void) -{ - LCD_CmdWrite(0x76); - LCD_DataWrite(0x92);//B1001_XX10 - Check_Busy_Draw(); -} -void Start_Right_Down_Curve(void) -{ - LCD_CmdWrite(0x76); - LCD_DataWrite(0x93);//B1001_XX11 - Check_Busy_Draw(); -} -// -void Start_Left_Down_Curve_Fill(void) -{ - LCD_CmdWrite(0x76); - LCD_DataWrite(0xD0);//B1101_XX00 - Check_Busy_Draw(); -} -void Start_Left_Up_Curve_Fill(void) -{ - LCD_CmdWrite(0x76); - LCD_DataWrite(0xD1);//B1101_XX01 - Check_Busy_Draw(); -} -void Start_Right_Up_Curve_Fill(void) -{ - LCD_CmdWrite(0x76); - LCD_DataWrite(0xD2);//B1101_XX10 - Check_Busy_Draw(); -} -void Start_Right_Down_Curve_Fill(void) -{ - LCD_CmdWrite(0x76); - LCD_DataWrite(0xD3);//B1101_XX11 - Check_Busy_Draw(); -} -// -void Start_Square(void) -{ - LCD_CmdWrite(0x76); - LCD_DataWrite(0xA0);//B1010_XXXX - Check_Busy_Draw(); -} -void Start_Square_Fill(void) -{ - LCD_CmdWrite(0x76); - LCD_DataWrite(0xE0);//B1110_XXXX - Check_Busy_Draw(); -} -void Start_Circle_Square(void) -{ - LCD_CmdWrite(0x76); - LCD_DataWrite(0xB0);//B1011_XXXX - Check_Busy_Draw(); -} -void Start_Circle_Square_Fill(void) -{ - LCD_CmdWrite(0x76); - LCD_DataWrite(0xF0);//B1111_XXXX - Check_Busy_Draw(); -} -//[77h]~[7Eh]========================================================================= -//蛾いみ -void Circle_Center_XY(unsigned short WX,unsigned short HY) -{ - /* - [7Bh] Draw Circle/Ellipse/Circle Square Center X-coordination [7:0] - [7Ch] Draw Circle/Ellipse/Circle Square Center X-coordination [12:8] - [7Dh] Draw Circle/Ellipse/Circle Square Center Y-coordination [7:0] - [7Eh] Draw Circle/Ellipse/Circle Square Center Y-coordination [12:8] - */ - LCD_CmdWrite(0x7B); - LCD_DataWrite(WX); - LCD_CmdWrite(0x7C); - LCD_DataWrite(WX>>8); - LCD_CmdWrite(0x7D); - LCD_DataWrite(HY); - LCD_CmdWrite(0x7E); - LCD_DataWrite(HY>>8); -} -//掘蛾いみ -void Ellipse_Center_XY(unsigned short WX,unsigned short HY) -{ - /* - [7Bh] Draw Circle/Ellipse/Circle Square Center X-coordination [7:0] - [7Ch] Draw Circle/Ellipse/Circle Square Center X-coordination [12:8] - [7Dh] Draw Circle/Ellipse/Circle Square Center Y-coordination [7:0] - [7Eh] Draw Circle/Ellipse/Circle Square Center Y-coordination [12:8] - */ - LCD_CmdWrite(0x7B); - LCD_DataWrite(WX); - LCD_CmdWrite(0x7C); - LCD_DataWrite(WX>>8); - LCD_CmdWrite(0x7D); - LCD_DataWrite(HY); - LCD_CmdWrite(0x7E); - LCD_DataWrite(HY>>8); -} -//蛾畖 -void Circle_Radius_R(unsigned short WX) -{ - /* - [77h] Draw Circle/Ellipse/Circle Square Major radius [7:0] - [78h] Draw Circle/Ellipse/Circle Square Major radius [12:8] - [79h] Draw Circle/Ellipse/Circle Square Minor radius [7:0] - [7Ah] Draw Circle/Ellipse/Circle Square Minor radius [12:8] - */ - LCD_CmdWrite(0x77); - LCD_DataWrite(WX); - LCD_CmdWrite(0x78); - LCD_DataWrite(WX>>8); - LCD_CmdWrite(0x79); - LCD_DataWrite(WX); - LCD_CmdWrite(0x7A); - LCD_DataWrite(WX>>8); -} - -//掘蛾畖 -void Ellipse_Radius_RxRy(unsigned short WX,unsigned short HY) -{ - /* - [77h] Draw Circle/Ellipse/Circle Square Major radius [7:0] - [78h] Draw Circle/Ellipse/Circle Square Major radius [12:8] - [79h] Draw Circle/Ellipse/Circle Square Minor radius [7:0] - [7Ah] Draw Circle/Ellipse/Circle Square Minor radius [12:8] - */ - LCD_CmdWrite(0x77); - LCD_DataWrite(WX); - LCD_CmdWrite(0x78); - LCD_DataWrite(WX>>8); - LCD_CmdWrite(0x79); - LCD_DataWrite(HY); - LCD_CmdWrite(0x7A); - LCD_DataWrite(HY>>8); -} - -//よ锣à畖 -void Circle_Square_Radius_RxRy(unsigned short WX,unsigned short HY) -{ - /* - [77h] Draw Circle/Ellipse/Circle Square Major radius [7:0] - [78h] Draw Circle/Ellipse/Circle Square Major radius [12:8] - [79h] Draw Circle/Ellipse/Circle Square Minor radius [7:0] - [7Ah] Draw Circle/Ellipse/Circle Square Minor radius [12:8] - */ - LCD_CmdWrite(0x77); - LCD_DataWrite(WX); - LCD_CmdWrite(0x78); - LCD_DataWrite(WX>>8); - LCD_CmdWrite(0x79); - LCD_DataWrite(HY); - LCD_CmdWrite(0x7A); - LCD_DataWrite(HY>>8); -} - -//[84h]========================================================================= -void Set_PWM_Prescaler_1_to_256(unsigned short WX) -{ - /* - PWM Prescaler Register - These 8 bits determine prescaler value for Timer 0 and 1. - Time base is ¨Core_Freq / (Prescaler + 1)〃 - */ - WX=WX-1; - LCD_CmdWrite(0x84); - LCD_DataWrite(WX); -} -//[85h]========================================================================= -void Select_PWM1_Clock_Divided_By_1(void) -{ - /* - Select MUX input for PWM Timer 1. - 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; - */ - unsigned char temp; - LCD_CmdWrite(0x85); - temp = LCD_DataRead(); - temp &= cClrb7; - temp &= cClrb6; - LCD_DataWrite(temp); -} -void Select_PWM1_Clock_Divided_By_2(void) -{ - /* - Select MUX input for PWM Timer 1. - 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; - */ - unsigned char temp; - LCD_CmdWrite(0x85); - temp = LCD_DataRead(); - temp &= cClrb7; - temp |= cSetb6; - LCD_DataWrite(temp); -} -void Select_PWM1_Clock_Divided_By_4(void) -{ - /* - Select MUX input for PWM Timer 1. - 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; - */ - unsigned char temp; - LCD_CmdWrite(0x85); - temp = LCD_DataRead(); - temp |= cSetb7; - temp &= cClrb6; - LCD_DataWrite(temp); -} -void Select_PWM1_Clock_Divided_By_8(void) -{ - /* - Select MUX input for PWM Timer 1. - 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; - */ - unsigned char temp; - LCD_CmdWrite(0x85); - temp = LCD_DataRead(); - temp |= cSetb7; - temp |= cSetb6; - LCD_DataWrite(temp); -} -void Select_PWM0_Clock_Divided_By_1(void) -{ - /* - Select MUX input for PWM Timer 0. - 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; - */ - unsigned char temp; - LCD_CmdWrite(0x85); - temp = LCD_DataRead(); - temp &= cClrb5; - temp &= cClrb4; - LCD_DataWrite(temp); -} -void Select_PWM0_Clock_Divided_By_2(void) -{ - /* - Select MUX input for PWM Timer 0. - 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; - */ - unsigned char temp; - LCD_CmdWrite(0x85); - temp = LCD_DataRead(); - temp &= cClrb5; - temp |= cSetb4; - LCD_DataWrite(temp); -} -void Select_PWM0_Clock_Divided_By_4(void) -{ - /* - Select MUX input for PWM Timer 0. - 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; - */ - unsigned char temp; - LCD_CmdWrite(0x85); - temp = LCD_DataRead(); - temp |= cSetb5; - temp &= cClrb4; - LCD_DataWrite(temp); -} -void Select_PWM0_Clock_Divided_By_8(void) -{ - /* - Select MUX input for PWM Timer 0. - 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; - */ - unsigned char temp; - LCD_CmdWrite(0x85); - temp = LCD_DataRead(); - temp |= cSetb5; - temp |= cSetb4; - LCD_DataWrite(temp); -} -//[85h].[bit3][bit2]========================================================================= -/* -XPWM[1] pin function control -0X: XPWM[1] output system error flag (REG[00h] bit[1:0], Scan bandwidth insufficient + Memory access out of range) -10: XPWM[1] enabled and controlled by PWM timer 1 -11: XPWM[1] output oscillator clock -//If XTEST[0] set high, then XPWM[1] will become panel scan clock input. -*/ -void Select_PWM1_is_ErrorFlag(void) -{ - unsigned char temp; - LCD_CmdWrite(0x85); - temp = LCD_DataRead(); - temp &= cClrb3; - LCD_DataWrite(temp); -} -void Select_PWM1(void) -{ - unsigned char temp; - LCD_CmdWrite(0x85); - temp = LCD_DataRead(); - temp |= cSetb3; - temp &= cClrb2; - LCD_DataWrite(temp); -} -void Select_PWM1_is_Osc_Clock(void) -{ - unsigned char temp; - LCD_CmdWrite(0x85); - temp = LCD_DataRead(); - temp |= cSetb3; - temp |= cSetb2; - LCD_DataWrite(temp); -} -//[85h].[bit1][bit0]========================================================================= -/* -XPWM[0] pin function control -0X: XPWM[0] becomes GPIO-C[7] -10: XPWM[0] enabled and controlled by PWM timer 0 -11: XPWM[0] output core clock -*/ -void Select_PWM0_is_GPIO_C7(void) -{ - unsigned char temp; - LCD_CmdWrite(0x85); - temp = LCD_DataRead(); - temp &= cClrb1; - LCD_DataWrite(temp); -} -void Select_PWM0(void) -{ - unsigned char temp; - LCD_CmdWrite(0x85); - temp = LCD_DataRead(); - temp |= cSetb1; - temp &= cClrb0; - LCD_DataWrite(temp); -} -void Select_PWM0_is_Core_Clock(void) -{ - unsigned char temp; - LCD_CmdWrite(0x85); - temp = LCD_DataRead(); - temp |= cSetb1; - temp |= cSetb0; - LCD_DataWrite(temp); -} -//[86h]========================================================================= -//[86h]PWM1 -void Enable_PWM1_Inverter(void) -{ - /* - PWM Timer 1 output inverter on/off. - Determine the output inverter on/off for Timer 1. - 0 = Inverter off - 1 = Inverter on for PWM1 - */ - unsigned char temp; - LCD_CmdWrite(0x86); - temp = LCD_DataRead(); - temp |= cSetb6; - LCD_DataWrite(temp); -} -void Disable_PWM1_Inverter(void) -{ - /* - PWM Timer 1 output inverter on/off. - Determine the output inverter on/off for Timer 1. - 0 = Inverter off - 1 = Inverter on for PWM1 - */ - unsigned char temp; - LCD_CmdWrite(0x86); - temp = LCD_DataRead(); - temp &= cClrb6; - LCD_DataWrite(temp); -} -void Auto_Reload_PWM1(void) -{ - /* - PWM Timer 1 auto reload on/off - Determine auto reload on/off for Timer 1. - 0 = One-shot - 1 = Interval mode(auto reload) - */ - unsigned char temp; - LCD_CmdWrite(0x86); - temp = LCD_DataRead(); - temp |= cSetb5; - LCD_DataWrite(temp); -} -void One_Shot_PWM1(void) -{ - /* - PWM Timer 1 auto reload on/off - Determine auto reload on/off for Timer 1. - 0 = One-shot - 1 = Interval mode(auto reload) - */ - unsigned char temp; - LCD_CmdWrite(0x86); - temp = LCD_DataRead(); - temp &= cClrb5; - LCD_DataWrite(temp); -} -void Start_PWM1(void) -{ - /* - PWM Timer 1 start/stop - Determine start/stop for Timer 1. - 0 = Stop - 1 = Start for Timer 1 - */ - unsigned char temp; - LCD_CmdWrite(0x86); - temp = LCD_DataRead(); - temp |= cSetb4; - LCD_DataWrite(temp); -} -void Stop_PWM1(void) -{ - /* - PWM Timer 1 start/stop - Determine start/stop for Timer 1. - 0 = Stop - 1 = Start for Timer 1 - */ - unsigned char temp; - LCD_CmdWrite(0x86); - temp = LCD_DataRead(); - temp &= cClrb4; - LCD_DataWrite(temp); -} -//[86h]PWM0 -void Enable_PWM0_Dead_Zone(void) -{ - /* - PWM Timer 0 Dead zone enable - Determine the dead zone operation. 0 = Disable. 1 = Enable. - */ - unsigned char temp; - LCD_CmdWrite(0x86); - temp = LCD_DataRead(); - temp |= cSetb3; - LCD_DataWrite(temp); -} -void Disable_PWM0_Dead_Zone(void) -{ - /* - PWM Timer 0 Dead zone enable - Determine the dead zone operation. 0 = Disable. 1 = Enable. - */ - unsigned char temp; - LCD_CmdWrite(0x86); - temp = LCD_DataRead(); - temp &= cClrb3; - LCD_DataWrite(temp); -} -void Enable_PWM0_Inverter(void) -{ - /* - PWM Timer 0 output inverter on/off - Determine the output inverter on/off for Timer 0. - 0 = Inverter off - 1 = Inverter on for PWM0 - */ - unsigned char temp; - LCD_CmdWrite(0x86); - temp = LCD_DataRead(); - temp |= cSetb2; - LCD_DataWrite(temp); -} -void Disable_PWM0_Inverter(void) -{ - /* - PWM Timer 0 output inverter on/off - Determine the output inverter on/off for Timer 0. - 0 = Inverter off - 1 = Inverter on for PWM0 - */ - unsigned char temp; - LCD_CmdWrite(0x86); - temp = LCD_DataRead(); - temp &= cClrb2; - LCD_DataWrite(temp); -} -void Auto_Reload_PWM0(void) -{ - /* - PWM Timer 0 auto reload on/off - Determine auto reload on/off for Timer 0. - 0 = One-shot - 1 = Interval mode(auto reload) - */ - unsigned char temp; - LCD_CmdWrite(0x86); - temp = LCD_DataRead(); - temp |= cSetb1; - LCD_DataWrite(temp); -} -void One_Shot_PWM0(void) -{ - /* - PWM Timer 1 auto reload on/off - Determine auto reload on/off for Timer 1. - 0 = One-shot - 1 = Interval mode(auto reload) - */ - unsigned char temp; - LCD_CmdWrite(0x86); - temp = LCD_DataRead(); - temp &= cClrb1; - LCD_DataWrite(temp); -} -void Start_PWM0(void) -{ - /* - PWM Timer 0 start/stop - Determine start/stop for Timer 0. - 0 = Stop - 1 = Start for Timer 0 - */ - unsigned char temp; - LCD_CmdWrite(0x86); - temp = LCD_DataRead(); - temp |= cSetb0; - LCD_DataWrite(temp); -} -void Stop_PWM0(void) -{ - /* - PWM Timer 0 start/stop - Determine start/stop for Timer 0. - 0 = Stop - 1 = Start for Timer 0 - */ - unsigned char temp; - LCD_CmdWrite(0x86); - temp = LCD_DataRead(); - temp &= cClrb0; - LCD_DataWrite(temp); -} -//[87h]========================================================================= -void Set_Timer0_Dead_Zone_Length(unsigned char temp) -{ - /* - Timer 0 Dead zone length register - These 8 bits determine the dead zone length. The 1 unit time of - the dead zone length is equal to that of timer 0. - */ - LCD_CmdWrite(0x87); - LCD_DataWrite(temp); -} -//[88h][89h]========================================================================= -void Set_Timer0_Compare_Buffer(unsigned short WX) -{ - /* - Timer 0 compare buffer register - Compare buffer register total has 16 bits. - When timer counter equal or less than compare buffer register will cause PWM out - high level if inv_on bit is off. - */ - LCD_CmdWrite(0x88); - LCD_DataWrite(WX); - LCD_CmdWrite(0x89); - LCD_DataWrite(WX>>8); -} -//[8Ah][8Bh]========================================================================= -void Set_Timer0_Count_Buffer(unsigned short WX) -{ - /* - Timer 0 count buffer register - Count buffer register total has 16 bits. - When timer counter equal to 0 will cause PWM timer reload Count buffer register if reload_en bit set as enable. - It may read back timer counterˇs real time value when PWM timer start. - */ - LCD_CmdWrite(0x8A); - LCD_DataWrite(WX); - LCD_CmdWrite(0x8B); - LCD_DataWrite(WX>>8); -} -//[8Ch][8Dh]========================================================================= -void Set_Timer1_Compare_Buffer(unsigned short WX) -{ - /* - Timer 0 compare buffer register - Compare buffer register total has 16 bits. - When timer counter equal or less than compare buffer register will cause PWM out - high level if inv_on bit is off. - */ - LCD_CmdWrite(0x8C); - LCD_DataWrite(WX); - LCD_CmdWrite(0x8D); - LCD_DataWrite(WX>>8); -} -//[8Eh][8Fh]========================================================================= -void Set_Timer1_Count_Buffer(unsigned short WX) -{ - /* - Timer 0 count buffer register - Count buffer register total has 16 bits. - When timer counter equal to 0 will cause PWM timer reload Count buffer register if reload_en bit set as enable. - It may read back timer counterˇs real time value when PWM timer start. - */ - LCD_CmdWrite(0x8E); - LCD_DataWrite(WX); - LCD_CmdWrite(0x8F); - LCD_DataWrite(WX>>8); -} - - -//[90h]~[B5h]========================================================================= - -//[90h]========================================================================= -void BTE_Enable(void) -{ - /* - BTE Function Enable - 0 : BTE Function disable. - 1 : BTE Function enable. - */ - unsigned char temp; - LCD_CmdWrite(0x90); - temp = LCD_DataRead(); - temp |= cSetb4 ; - LCD_DataWrite(temp); -} - -//[90h]========================================================================= -void BTE_Disable(void) -{ - /* - BTE Function Enable - 0 : BTE Function disable. - 1 : BTE Function enable. - */ - unsigned char temp; - LCD_CmdWrite(0x90); - temp = LCD_DataRead(); - temp &= cClrb4 ; - LCD_DataWrite(temp); -} - -//[90h]========================================================================= -void Check_BTE_Busy(void) -{ - /* - BTE Function Status - 0 : BTE Function is idle. - 1 : BTE Function is busy. - */ - unsigned char temp; - - do - { - temp=LCD_StatusRead(); - } - while(temp&0x08); -} -//[90h]========================================================================= -void Pattern_Format_8X8(void) -{ - /* - Pattern Format - 0 : 8X8 - 1 : 16X16 - */ - unsigned char temp; - LCD_CmdWrite(0x90); - temp = LCD_DataRead(); - temp &= cClrb0 ; - LCD_DataWrite(temp); -} -//[90h]========================================================================= -void Pattern_Format_16X16(void) -{ - /* - Pattern Format - 0 : 8X8 - 1 : 16X16 - */ - unsigned char temp; - LCD_CmdWrite(0x90); - temp = LCD_DataRead(); - temp |= cSetb0 ; - LCD_DataWrite(temp); -} - -//[91h]========================================================================= -void BTE_ROP_Code(unsigned char setx) -{ - /* - BTE ROP Code[Bit7:4] - - 0000 : 0(Blackness) - 0001 : ~S0.~S1 or ~ ( S0+S1 ) - 0010 : ~S0.S1 - 0011 : ~S0 - 0100 : S0.~S1 - 0101 : ~S1 - 0110 : S0^S1 - 0111 : ~S0+~S1 or ~ ( S0.S1 ) - 1000 : S0.S1 - 1001 : ~ ( S0^S1 ) - 1010 : S1 - 1011 : ~S0+S1 - 1100 : S0 - 1101 : S0+~S1 - 1110 : S0+S1 - 1111 : 1 ( Whiteness ) - */ - unsigned char temp; - LCD_CmdWrite(0x91); - temp = LCD_DataRead(); - temp &= 0x0f ; - temp |= (setx<<4); - LCD_DataWrite(temp); -} - -//[91h]========================================================================= -void BTE_Operation_Code(unsigned char setx) -{ - /* - BTE Operation Code[Bit3:0] - - 0000 : MPU Write BTE with ROP. - 0001 : MPU Read BTE w/o ROP. - 0010 : Memory copy (move) BTE in positive direction with ROP. - 0011 : Memory copy (move) BTE in negative direction with ROP. - 0100 : MPU Transparent Write BTE. (w/o ROP.) - 0101 : Transparent Memory copy (move) BTE in positive direction (w/o ROP.) - 0110 : Pattern Fill with ROP. - 0111 : Pattern Fill with key-chroma - 1000 : Color Expansion - 1001 : Color Expansion with transparency - 1010 : Move BTE in positive direction with Alpha blending - 1011 : MPU Write BTE with Alpha blending - 1100 : Solid Fill - 1101 : Reserved - 1110 : Reserved - 1111 : Reserved - */ - unsigned char temp; - LCD_CmdWrite(0x91); - temp = LCD_DataRead(); - temp &= 0xf0 ; - temp |= setx ; - LCD_DataWrite(temp); -} -//[92h]========================================================================= -void BTE_S0_Color_8bpp(void) -{ - /* - S0 Color Depth - 00 : 256 Color - 01 : 64k Color - 1x : 16M Color - */ - unsigned char temp; - LCD_CmdWrite(0x92); - temp = LCD_DataRead(); - temp &= cClrb6 ; - temp &= cClrb5 ; - LCD_DataWrite(temp); -} -//[92h]========================================================================= -void BTE_S0_Color_16bpp(void) -{ - /* - S0 Color Depth - 00 : 256 Color - 01 : 64k Color - 1x : 16M Color - */ - unsigned char temp; - LCD_CmdWrite(0x92); - temp = LCD_DataRead(); - temp &= cClrb6 ; - temp |= cSetb5 ; - LCD_DataWrite(temp); -} -//[92h]========================================================================= -void BTE_S0_Color_24bpp(void) -{ - /* - S0 Color Depth - 00 : 256 Color - 01 : 64k Color - 1x : 16M Color - */ - unsigned char temp; - LCD_CmdWrite(0x92); - temp = LCD_DataRead(); - temp |= cSetb6 ; - //temp |= cSetb5 ; - LCD_DataWrite(temp); -} -//[92h]========================================================================= -void BTE_S1_Color_8bpp(void) -{ - /* - S1 Color Depth - 000 : 256 Color - 001 : 64k Color - 010 : 16M Color - 011 : Constant Color - 100 : 8 bit pixel alpha blending - 101 : 16 bit pixel alpha blending - */ - unsigned char temp; - LCD_CmdWrite(0x92); - temp = LCD_DataRead(); - temp &= cClrb4 ; - temp &= cClrb3 ; - temp &= cClrb2 ; - LCD_DataWrite(temp); -} -//[92h]========================================================================= -void BTE_S1_Color_16bpp(void) -{ - /* - S1 Color Depth - 000 : 256 Color - 001 : 64k Color - 010 : 16M Color - 011 : Constant Color - 100 : 8 bit pixel alpha blending - 101 : 16 bit pixel alpha blending - */ - unsigned char temp; - LCD_CmdWrite(0x92); - temp = LCD_DataRead(); - temp &= cClrb4 ; - temp &= cClrb3 ; - temp |= cSetb2 ; - LCD_DataWrite(temp); -} -//[92h]========================================================================= -void BTE_S1_Color_24bpp(void) -{ - /* - S1 Color Depth - 000 : 256 Color - 001 : 64k Color - 010 : 16M Color - 011 : Constant Color - 100 : 8 bit pixel alpha blending - 101 : 16 bit pixel alpha blending - */ - unsigned char temp; - LCD_CmdWrite(0x92); - temp = LCD_DataRead(); - temp &= cClrb4 ; - temp |= cSetb3 ; - temp &= cClrb2 ; - LCD_DataWrite(temp); -} - -//[92h]========================================================================= -void BTE_S1_Color_Constant(void) -{ - /* - S1 Color Depth - 000 : 256 Color - 001 : 64k Color - 010 : 16M Color - 011 : Constant Color - 100 : 8 bit pixel alpha blending - 101 : 16 bit pixel alpha blending - */ - unsigned char temp; - LCD_CmdWrite(0x92); - temp = LCD_DataRead(); - temp &= cClrb4 ; - temp |= cSetb3 ; - temp |= cSetb2 ; - LCD_DataWrite(temp); -} - - - -//[92h]========================================================================= -void BTE_S1_Color_8bit_Alpha(void) -{ - /* - S1 Color Depth - 000 : 256 Color - 001 : 64k Color - 010 : 16M Color - 011 : Constant Color - 100 : 8 bit pixel alpha blending - 101 : 16 bit pixel alpha blending - */ - unsigned char temp; - LCD_CmdWrite(0x92); - temp = LCD_DataRead(); - temp |= cSetb4 ; - temp &= cClrb3 ; - temp &= cClrb2 ; - LCD_DataWrite(temp); -} - -//[92h]========================================================================= -void BTE_S1_Color_16bit_Alpha(void) -{ - /* - S1 Color Depth - 000 : 256 Color - 001 : 64k Color - 010 : 16M Color - 011 : Constant Color - 100 : 8 bit pixel alpha blending - 101 : 16 bit pixel alpha blending - */ - unsigned char temp; - LCD_CmdWrite(0x92); - temp = LCD_DataRead(); - temp |= cSetb4 ; - temp &= cClrb3 ; - temp |= cSetb2 ; - LCD_DataWrite(temp); -} - -//[92h]========================================================================= -void BTE_Destination_Color_8bpp(void) -{ - /* - Destination Color Depth - 00 : 256 Color - 01 : 64k Color - 1x : 16M Color - */ - unsigned char temp; - LCD_CmdWrite(0x92); - temp = LCD_DataRead(); - temp &= cClrb1 ; - temp &= cClrb0 ; - LCD_DataWrite(temp); -} -//[92h]========================================================================= -void BTE_Destination_Color_16bpp(void) -{ - /* - Destination Color Depth - 00 : 256 Color - 01 : 64k Color - 1x : 16M Color - */ - unsigned char temp; - LCD_CmdWrite(0x92); - temp = LCD_DataRead(); - temp &= cClrb1 ; - temp |= cSetb0 ; - LCD_DataWrite(temp); -} -//[92h]========================================================================= -void BTE_Destination_Color_24bpp(void) -{ - /* - Destination Color Depth - 00 : 256 Color - 10 : 64k Color - 1x : 16M Color - */ - unsigned char temp; - LCD_CmdWrite(0x92); - temp = LCD_DataRead(); - temp |= cSetb1 ; - //temp |= cSetb0 ; - LCD_DataWrite(temp); -} - - -//[93h][94h][95h][96h]========================================================================= -void BTE_S0_Memory_Start_Address(unsigned long Addr) -{ - /* - [93h] BTE S0 Memory Start Address [7:0] - [94h] BTE S0 Memory Start Address [15:8] - [95h] BTE S0 Memory Start Address [23:16] - [96h] BTE S0 Memory Start Address [31:24] - Bit [1:0] tie to ¨0〃 internally. - */ - LCD_RegisterWrite(0x93,Addr); - LCD_RegisterWrite(0x94,Addr>>8); - LCD_RegisterWrite(0x95,Addr>>16); - LCD_RegisterWrite(0x96,Addr>>24); -} - - -//[97h][98h]========================================================================= -void BTE_S0_Image_Width(unsigned short WX) -{ - /* - [97h] BTE S0 Image Width [7:0] - [98h] BTE S0 Image Width [12:8] - Unit: Pixel. - Bit [1:0] tie to ¨0〃 internally. - */ - LCD_RegisterWrite(0x97,WX); - LCD_RegisterWrite(0x98,WX>>8); -} - - -//[99h][9Ah][9Bh][9Ch]========================================================================= -void BTE_S0_Window_Start_XY(unsigned short WX,unsigned short HY) -{ - /* - [99h] BTE S0 Window Upper-Left corner X-coordination [7:0] - [9Ah] BTE S0 Window Upper-Left corner X-coordination [12:8] - [9Bh] BTE S0 Window Upper-Left corner Y-coordination [7:0] - [9Ch] BTE S0 Window Upper-Left corner Y-coordination [12:8] - */ - LCD_RegisterWrite(0x99,WX); - LCD_RegisterWrite(0x9A,WX>>8); - LCD_RegisterWrite(0x9B,HY); - LCD_RegisterWrite(0x9C,HY>>8); -} - - - - -//[9Dh][9Eh][9Fh][A0h]========================================================================= -void BTE_S1_Memory_Start_Address(unsigned long Addr) -{ - /* - [9Dh] BTE S1 Memory Start Address [7:0] - [9Eh] BTE S1 Memory Start Address [15:8] - [9Fh] BTE S1 Memory Start Address [23:16] - [A0h] BTE S1 Memory Start Address [31:24] - Bit [1:0] tie to ¨0〃 internally. - */ - LCD_RegisterWrite(0x9D,Addr); - LCD_RegisterWrite(0x9E,Addr>>8); - LCD_RegisterWrite(0x9F,Addr>>16); - LCD_RegisterWrite(0xA0,Addr>>24); -} - - -//Input data format:R3G3B2 -void S1_Constant_color_256(unsigned char temp) -{ - LCD_CmdWrite(0x9D); - LCD_DataWrite(temp); - LCD_CmdWrite(0x9E); - LCD_DataWrite(temp<<3); - LCD_CmdWrite(0x9F); - LCD_DataWrite(temp<<6); -} - -//Input data format:R5G6B6 -void S1_Constant_color_65k(unsigned short temp) -{ - LCD_CmdWrite(0x9D); - LCD_DataWrite(temp>>8); - LCD_CmdWrite(0x9E); - LCD_DataWrite(temp>>3); - LCD_CmdWrite(0x9F); - LCD_DataWrite(temp<<3); -} - -//Input data format:R8G8B8 -void S1_Constant_color_16M(unsigned long temp) -{ - LCD_CmdWrite(0x9D); - LCD_DataWrite(temp>>16); - LCD_CmdWrite(0x9E); - LCD_DataWrite(temp>>8); - LCD_CmdWrite(0x9F); - LCD_DataWrite(temp); -} - - - - -//[A1h][A2h]========================================================================= -void BTE_S1_Image_Width(unsigned short WX) -{ - /* - [A1h] BTE S1 Image Width [7:0] - [A2h] BTE S1 Image Width [12:8] - Unit: Pixel. - Bit [1:0] tie to ¨0〃 internally. - */ - LCD_RegisterWrite(0xA1,WX); - LCD_RegisterWrite(0xA2,WX>>8); -} - - -//[A3h][A4h][A5h][A6h]========================================================================= -void BTE_S1_Window_Start_XY(unsigned short WX,unsigned short HY) -{ - /* - [A3h] BTE S1 Window Upper-Left corner X-coordination [7:0] - [A4h] BTE S1 Window Upper-Left corner X-coordination [12:8] - [A5h] BTE S1 Window Upper-Left corner Y-coordination [7:0] - [A6h] BTE S1 Window Upper-Left corner Y-coordination [12:8] - */ - LCD_RegisterWrite(0xA3,WX); - LCD_RegisterWrite(0xA4,WX>>8); - LCD_RegisterWrite(0xA5,HY); - LCD_RegisterWrite(0xA6,HY>>8); -} - - - - -//[A7h][A8h][A9h][AAh]========================================================================= -void BTE_Destination_Memory_Start_Address(unsigned long Addr) -{ - /* - [A7h] BTE Destination Memory Start Address [7:0] - [A8h] BTE Destination Memory Start Address [15:8] - [A9h] BTE Destination Memory Start Address [23:16] - [AAh] BTE Destination Memory Start Address [31:24] - Bit [1:0] tie to ¨0〃 internally. - */ - LCD_RegisterWrite(0xA7,Addr); - LCD_RegisterWrite(0xA8,Addr>>8); - LCD_RegisterWrite(0xA9,Addr>>16); - LCD_RegisterWrite(0xAA,Addr>>24); -} - - -//[ABh][ACh]========================================================================= -void BTE_Destination_Image_Width(unsigned short WX) -{ - /* - [ABh] BTE Destination Image Width [7:0] - [ACh] BTE Destination Image Width [12:8] - Unit: Pixel. - Bit [1:0] tie to ¨0〃 internally. - */ - LCD_RegisterWrite(0xAB,WX); - LCD_RegisterWrite(0xAC,WX>>8); -} - - -//[ADh][AEh][AFh][B0h]========================================================================= -void BTE_Destination_Window_Start_XY(unsigned short WX,unsigned short HY) -{ - /* - [ADh] BTE Destination Window Upper-Left corner X-coordination [7:0] - [AEh] BTE Destination Window Upper-Left corner X-coordination [12:8] - [AFh] BTE Destination Window Upper-Left corner Y-coordination [7:0] - [B0h] BTE Destination Window Upper-Left corner Y-coordination [12:8] - */ - LCD_RegisterWrite(0xAD,WX); - LCD_RegisterWrite(0xAE,WX>>8); - LCD_RegisterWrite(0xAF,HY); - LCD_RegisterWrite(0xB0,HY>>8); -} - - -//[B1h][B2h][B3h][B4h]=============================================================== - -void BTE_Window_Size(unsigned short WX, unsigned short WY) - -{ - /* - [B1h] BTE Window Width [7:0] - [B2h] BTE Window Width [12:8] - - [B3h] BTE Window Height [7:0] - [B4h] BTE Window Height [12:8] - */ - LCD_RegisterWrite(0xB1,WX); - LCD_RegisterWrite(0xB2,WX>>8); - LCD_RegisterWrite(0xB3,WY); - LCD_RegisterWrite(0xB4,WY>>8); -} - -//[B5h]========================================================================= -void BTE_Alpha_Blending_Effect(unsigned char temp) -{ - /* - Window Alpha Blending effect for S0 & S1 - The value of alpha in the color code ranges from 0.0 to 1.0, - where 0.0 represents a fully transparent color, and 1.0 - represents a fully opaque color. - 00h: 0 - 01h: 1/32 - 02h: 2/32 - : - 1Eh: 30/32 - 1Fh: 31/32 - 2Xh: 1 - Output Effect = (S0 image x (1 - alpha setting value)) + (S1 image x alpha setting value) - */ - LCD_CmdWrite(0xB5); - LCD_DataWrite(temp); -} - - -//[B6h]========================================================================= -void Start_SFI_DMA(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB6); - temp = LCD_DataRead(); - temp |= cSetb0; - LCD_DataWrite(temp); -} - -void Check_Busy_SFI_DMA(void) -{ - LCD_CmdWrite(0xB6); - - do - { - } - while((LCD_DataRead()&0x01)==0x01); -} - - -//[B7h]========================================================================= -void Select_SFI_0(void) -{ - /*[bit7] - Serial Flash/ROM I/F # Select - 0: Serial Flash/ROM 0 I/F is selected. - 1: Serial Flash/ROM 1 I/F is selected. - */ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp &= cClrb7; - LCD_DataWrite(temp); -} -void Select_SFI_1(void) -{ - /*[bit7] - Serial Flash/ROM I/F # Select - 0: Serial Flash/ROM 0 I/F is selected. - 1: Serial Flash/ROM 1 I/F is selected. - */ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp |= cSetb7; - LCD_DataWrite(temp); -} -void Select_SFI_Font_Mode(void) -{ - /*[bit6] - Serial Flash /ROM Access Mode - 0: Font mode  for external cgrom - 1: DMA mode  for cgram , pattern , bootstart image or osd - */ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp &= cClrb6; - LCD_DataWrite(temp); -} -void Select_SFI_DMA_Mode(void) -{ - /*[bit6] - Serial Flash /ROM Access Mode - 0: Font mode  for external cgrom - 1: DMA mode  for cgram , pattern , bootstart image or osd - */ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp |= cSetb6; - LCD_DataWrite(temp); -} -void Select_SFI_24bit_Address(void) -{ - /*[bit5] - Serial Flash/ROM Address Mode - 0: 24 bits address mode - 1: 32 bits address mode - */ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp &= cClrb5; - LCD_DataWrite(temp); -} -void Select_SFI_32bit_Address(void) -{ - /*[bit5] - Serial Flash/ROM Address Mode - 0: 24 bits address mode - 1: 32 bits address mode - */ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp |= cSetb5; - LCD_DataWrite(temp); -} -void Select_SFI_Waveform_Mode_0(void) -{ - /*[bit4] - Serial Flash/ROM Waveform Mode - Mode 0. - Mode 3. - */ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp &= cClrb4; - LCD_DataWrite(temp); -} -void Select_SFI_Waveform_Mode_3(void) -{ - /*[bit4] - Serial Flash/ROM Waveform Mode - Mode 0. - Mode 3. - */ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp |= cSetb4; - LCD_DataWrite(temp); -} -void Select_SFI_0_DummyRead(void) -{ - /*[bit3][bit2] - Serial Flash /ROM Read Cycle 0 RW - 00b: no dummy cycle mode - 01b: 1 dummy cycle mode - 10b: 2 dummy cycle mode - 11b: 4 dummy cycle mode - */ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp &= 0xF3; - LCD_DataWrite(temp); -} -void Select_SFI_8_DummyRead(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp &= 0xF3; - temp |= cSetb2; - LCD_DataWrite(temp); -} -void Select_SFI_16_DummyRead(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp &= 0xF3; - temp |= cSetb3; - LCD_DataWrite(temp); -} -void Select_SFI_24_DummyRead(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp |= 0x0c; - LCD_DataWrite(temp); -} -void Select_SFI_Single_Mode(void) -{ - /*[bit1][bit0] - Serial Flash /ROM I/F Data Latch Mode Select - 0Xb: Single Mode - 10b: Dual Mode 0. - 11b: Dual Mode 1. - */ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp &= 0xFC; - LCD_DataWrite(temp); -} -void Select_SFI_Dual_Mode0(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp &= 0xFC; - temp |= cSetb1; - LCD_DataWrite(temp); -} -void Select_SFI_Dual_Mode1(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB7); - temp = LCD_DataRead(); - temp |= 0x03; - LCD_DataWrite(temp); -} - -//REG[B8h] SPI master Tx /Rx FIFO Data Register (SPIDR) -unsigned char SPI_Master_FIFO_Data_Put(unsigned char Data) -{ - unsigned char temp; - LCD_CmdWrite(0xB8); - LCD_DataWrite(Data); - - while(Tx_FIFO_Empty_Flag()==0); - - temp = SPI_Master_FIFO_Data_Get(); - return temp; -} - -unsigned char SPI_Master_FIFO_Data_Get(void) -{ - unsigned char temp; - - while(Rx_FIFO_Empty_Flag()==1); - - LCD_CmdWrite(0xB8); - temp=LCD_DataRead(); - //while(Rx_FIFO_full_flag()); - return temp; -} - -//REG[B9h] SPI master Control Register (SPIMCR2) -void Mask_SPI_Master_Interrupt_Flag(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB9); - temp = LCD_DataRead(); - temp |= cSetb6; - LCD_DataWrite(temp); -} - -void Select_nSS_drive_on_xnsfcs0(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB9); - temp = LCD_DataRead(); - temp &= cClrb5; - LCD_DataWrite(temp); -} - -void Select_nSS_drive_on_xnsfcs1(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB9); - temp = LCD_DataRead(); - temp |= cSetb5; - LCD_DataWrite(temp); -} - -//0: inactive (nSS port will goes high) -void nSS_Inactive(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB9); - temp = LCD_DataRead(); - temp &= cClrb4; - LCD_DataWrite(temp); -} -//1: active (nSS port will goes low) -void nSS_Active(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB9); - temp = LCD_DataRead(); - temp |= cSetb4; - LCD_DataWrite(temp); -} - -//Interrupt enable for FIFO overflow error [OVFIRQEN] -void OVFIRQEN_Enable(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB9); - temp = LCD_DataRead(); - temp |= cSetb3; - LCD_DataWrite(temp); -} -//Interrupt enable for while Tx FIFO empty & SPI engine/FSM idle -void EMTIRQEN_Enable(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB9); - temp = LCD_DataRead(); - temp |= cSetb2; - LCD_DataWrite(temp); -} - - -//At CPOL=0 the base value of the clock is zero -//o For CPHA=0, data are read on the clock's rising edge (low->high transition) and -//data are changed on a falling edge (high->low clock transition). -//o For CPHA=1, data are read on the clock's falling edge and data are changed on a -//rising edge. - -//At CPOL=1 the base value of the clock is one (inversion of CPOL=0) -//o For CPHA=0, data are read on clock's falling edge and data are changed on a -//rising edge. -//o For CPHA=1, data are read on clock's rising edge and data are changed on a -//falling edge. - -void Reset_CPOL(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB9); - temp = LCD_DataRead(); - temp &= cClrb1; - LCD_DataWrite(temp); -} - -void Set_CPOL(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB9); - temp = LCD_DataRead(); - temp |= cSetb1; - LCD_DataWrite(temp); -} - - -void Reset_CPHA(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB9); - temp = LCD_DataRead(); - temp &= cClrb0; - LCD_DataWrite(temp); -} - -void Set_CPHA(void) -{ - unsigned char temp; - LCD_CmdWrite(0xB9); - temp = LCD_DataRead(); - temp |= cSetb0; - LCD_DataWrite(temp); -} - - -//REG[BAh] SPI master Status Register (SPIMSR) -unsigned char Tx_FIFO_Empty_Flag(void) -{ - LCD_CmdWrite(0xBA); - - if((LCD_DataRead()&0x80)==0x80) - { - return 1; - } - else - { - return 0; - } -} - -unsigned char Tx_FIFO_Full_Flag(void) -{ - LCD_CmdWrite(0xBA); - - if((LCD_DataRead()&0x40)==0x40) - { - return 1; - } - else - { - return 0; - } -} - -unsigned char Rx_FIFO_Empty_Flag(void) -{ - LCD_CmdWrite(0xBA); - - if((LCD_DataRead()&0x20)==0x20) - { - return 1; - } - else - { - return 0; - } -} - -unsigned char Rx_FIFO_full_flag(void) -{ - LCD_CmdWrite(0xBA); - - if((LCD_DataRead()&0x10)==0x10) - { - return 1; - } - else - { - return 0; - } -} - -unsigned char OVFI_Flag(void) -{ - LCD_CmdWrite(0xBA); - - if((LCD_DataRead()&0x08)==0x08) - { - return 1; - } - else - { - return 0; - } -} - -void Clear_OVFI_Flag(void) -{ - unsigned char temp; - LCD_CmdWrite(0xBA); - temp = LCD_DataRead(); - temp |= cSetb3; - LCD_DataWrite(temp); -} - -unsigned char EMTI_Flag(void) -{ - LCD_CmdWrite(0xBA); - - if((LCD_DataRead()&0x04)==0x04) - { - return 1; - } - else - { - return 0; - } -} - -void Clear_EMTI_Flag(void) -{ - unsigned char temp; - LCD_CmdWrite(0xBA); - temp = LCD_DataRead(); - temp |= cSetb2; - LCD_DataWrite(temp); -} - - -//REG[BB] SPI Clock period (SPIDIV) -void SPI_Clock_Period(unsigned char temp) -{ - LCD_CmdWrite(0xBB); - LCD_DataWrite(temp); -} - -//[BCh][BDh][BEh][BFh]========================================================================= -void SFI_DMA_Source_Start_Address(unsigned long Addr) -{ - /* - DMA Source START ADDRESS - This bits index serial flash address [7:0][15:8][23:16][31:24] - */ - LCD_CmdWrite(0xBC); - LCD_DataWrite(Addr); - LCD_CmdWrite(0xBD); - LCD_DataWrite(Addr>>8); - LCD_CmdWrite(0xBE); - LCD_DataWrite(Addr>>16); - LCD_CmdWrite(0xBF); - LCD_DataWrite(Addr>>24); -} -//[C0h][C1h][C2h][C3h]========================================================================= -void SFI_DMA_Destination_Start_Address(unsigned long Addr) -{ - /* - DMA Destination START ADDRESS - [1:0]Fix at 0 - This bits index SDRAM address [7:0][15:8][23:16][31:24] - */ - LCD_CmdWrite(0xC0); - LCD_DataWrite(Addr); - LCD_CmdWrite(0xC1); - LCD_DataWrite(Addr>>8); - LCD_CmdWrite(0xC2); - LCD_DataWrite(Addr>>16); - LCD_CmdWrite(0xC3); - LCD_DataWrite(Addr>>24); -} -//[C0h][C1h][C2h][C3h]========================================================================= -void SFI_DMA_Destination_Upper_Left_Corner(unsigned short WX,unsigned short HY) -{ - /* - C0h - This register defines DMA Destination Window Upper-Left corner - X-coordination [7:0] on Canvas area. - When REG DMACR bit 1 = 1 (Block Mode) - This register defines Destination address [7:2] in SDRAM. - C1h - When REG DMACR bit 1 = 0 (Linear Mode) - This register defines DMA Destination Window Upper-Left corner - X-coordination [12:8] on Canvas area. - When REG DMACR bit 1 = 1 (Block Mode) - This register defines Destination address [15:8] in SDRAM. - C2h - When REG DMACR bit 1 = 0 (Linear Mode) - This register defines DMA Destination Window Upper-Left corner - Y-coordination [7:0] on Canvas area. - When REG DMACR bit 1 = 1 (Block Mode) - This register defines Destination address [23:16] in SDRAM. - C3h - When REG DMACR bit 1 = 0 (Linear Mode) - This register defines DMA Destination Window Upper-Left corner - Y-coordination [12:8] on Canvas area. - When REG DMACR bit 1 = 1 (Block Mode) - This register defines Destination address [31:24] in SDRAM. - */ - LCD_CmdWrite(0xC0); - LCD_DataWrite(WX); - LCD_CmdWrite(0xC1); - LCD_DataWrite(WX>>8); - LCD_CmdWrite(0xC2); - LCD_DataWrite(HY); - LCD_CmdWrite(0xC3); - LCD_DataWrite(HY>>8); -} - - - -//[C6h][C7h][C8h][C9h]========================================================================= -void SFI_DMA_Transfer_Number(unsigned long Addr) -{ - /* - Unit : Pixel - When REG DMACR bit 1 = 0 (Linear Mode) - DMA Transfer Number [7:0][15:8][23:16][31:24] - - When REG DMACR bit 1 = 1 (Block Mode) - DMA Block Width [7:0][15:8] - DMA Block HIGH[7:0][15:8] - */ - LCD_CmdWrite(0xC6); - LCD_DataWrite(Addr); - LCD_CmdWrite(0xC7); - LCD_DataWrite(Addr>>8); - LCD_CmdWrite(0xC8); - LCD_DataWrite(Addr>>16); - LCD_CmdWrite(0xC9); - LCD_DataWrite(Addr>>24); -} -void SFI_DMA_Transfer_Width_Height(unsigned short WX,unsigned short HY) -{ - /* - When REG DMACR bit 1 = 0 (Linear Mode) - DMA Transfer Number [7:0][15:8][23:16][31:24] - - When REG DMACR bit 1 = 1 (Block Mode) - DMA Block Width [7:0][15:8] - DMA Block HIGH[7:0][15:8] - */ - LCD_CmdWrite(0xC6); - LCD_DataWrite(WX); - LCD_CmdWrite(0xC7); - LCD_DataWrite(WX>>8); - LCD_CmdWrite(0xC8); - LCD_DataWrite(HY); - LCD_CmdWrite(0xC9); - LCD_DataWrite(HY>>8); -} -//[CAh][CBh]========================================================================= -void SFI_DMA_Source_Width(unsigned short WX) -{ - /* - DMA Source Picture Width [7:0][12:8] - Unit: pixel - */ - LCD_CmdWrite(0xCA); - LCD_DataWrite(WX); - LCD_CmdWrite(0xCB); - LCD_DataWrite(WX>>8); -} - -//[CCh]========================================================================= - -void Font_Select_UserDefine_Mode(void) -{ - /*[bit7-6] - User-defined Font /CGROM Font Selection Bit in Text Mode - 00 : Internal CGROM - 01 : Genitop serial flash - 10 : User-defined Font - */ - unsigned char temp; - LCD_CmdWrite(0xCC); - temp = LCD_DataRead(); - temp |= cSetb7; - temp &= cClrb6; - LCD_DataWrite(temp); -} -void CGROM_Select_Internal_CGROM(void) -{ - /*[bit7-6] - User-defined Font /CGROM Font Selection Bit in Text Mode - 00 : Internal CGROM - 01 : Genitop serial flash - 10 : User-defined Font - */ - unsigned char temp; - LCD_CmdWrite(0xCC); - temp = LCD_DataRead(); - temp &= cClrb7; - temp &= cClrb6; - LCD_DataWrite(temp); -} -void CGROM_Select_Genitop_FontROM(void) -{ - /*[bit7-6] - User-defined Font /CGROM Font Selection Bit in Text Mode - 00 : Internal CGROM - 01 : Genitop serial flash - 10 : User-defined Font - */ - unsigned char temp; - LCD_CmdWrite(0xCC); - temp = LCD_DataRead(); - temp &= cClrb7; - temp |= cSetb6; - LCD_DataWrite(temp); -} -void Font_Select_8x16_16x16(void) -{ - /*[bit5-4] - Font Height Setting - 00b : 8x16 / 16x16. - 01b : 12x24 / 24x24. - 10b : 16x32 / 32x32. - *** User-defined Font width is decided by font code. Genitop - serial flashˇs font width is decided by font code or GT Font ROM - control register. - */ - unsigned char temp; - LCD_CmdWrite(0xCC); - temp = LCD_DataRead(); - temp &= cClrb5; - temp &= cClrb4; - LCD_DataWrite(temp); -} -void Font_Select_12x24_24x24(void) -{ - /*[bit5-4] - Font Height Setting - 00b : 8x16 / 16x16. - 01b : 12x24 / 24x24. - 10b : 16x32 / 32x32. - *** User-defined Font width is decided by font code. Genitop - serial flashˇs font width is decided by font code or GT Font ROM - control register. - */ - unsigned char temp; - LCD_CmdWrite(0xCC); - temp = LCD_DataRead(); - temp &= cClrb5; - temp |= cSetb4; - LCD_DataWrite(temp); -} -void Font_Select_16x32_32x32(void) -{ - /*[bit5-4] - Font Height Setting - 00b : 8x16 / 16x16. - 01b : 12x24 / 24x24. - 10b : 16x32 / 32x32. - *** User-defined Font width is decided by font code. Genitop - serial flashˇs font width is decided by font code or GT Font ROM - control register. - */ - unsigned char temp; - LCD_CmdWrite(0xCC); - temp = LCD_DataRead(); - temp |= cSetb5; - temp &= cClrb4; - LCD_DataWrite(temp); -} -void Internal_CGROM_Select_ISOIEC8859_1(void) -{ - /* - Font Selection for internal CGROM - When FNCR0 B7 = 0 and B5 = 0, Internal CGROM supports the - 8x16 character sets with the standard coding of ISO/IEC 8859-1~4, - which supports English and most of European country languages. - 00b : ISO/IEC 8859-1. - 01b : ISO/IEC 8859-2. - 10b : ISO/IEC 8859-3. - 11b : ISO/IEC 8859-4. - */ - unsigned char temp; - LCD_CmdWrite(0xCC); - temp = LCD_DataRead(); - temp &= cClrb1; - temp &= cClrb0; - LCD_DataWrite(temp); -} -void Internal_CGROM_Select_ISOIEC8859_2(void) -{ - /* - Font Selection for internal CGROM - When FNCR0 B7 = 0 and B5 = 0, Internal CGROM supports the - 8x16 character sets with the standard coding of ISO/IEC 8859-1~4, - which supports English and most of European country languages. - 00b : ISO/IEC 8859-1. - 01b : ISO/IEC 8859-2. - 10b : ISO/IEC 8859-3. - 11b : ISO/IEC 8859-4. - */ - unsigned char temp; - LCD_CmdWrite(0xCC); - temp = LCD_DataRead(); - temp &= cClrb1; - temp |= cSetb0; - LCD_DataWrite(temp); -} -void Internal_CGROM_Select_ISOIEC8859_3(void) -{ - /* - Font Selection for internal CGROM - When FNCR0 B7 = 0 and B5 = 0, Internal CGROM supports the - 8x16 character sets with the standard coding of ISO/IEC 8859-1~4, - which supports English and most of European country languages. - 00b : ISO/IEC 8859-1. - 01b : ISO/IEC 8859-2. - 10b : ISO/IEC 8859-3. - 11b : ISO/IEC 8859-4. - */ - unsigned char temp; - LCD_CmdWrite(0xCC); - temp = LCD_DataRead(); - temp |= cSetb1; - temp &= cClrb0; - LCD_DataWrite(temp); -} -void Internal_CGROM_Select_ISOIEC8859_4(void) -{ - /* - Font Selection for internal CGROM - When FNCR0 B7 = 0 and B5 = 0, Internal CGROM supports the - 8x16 character sets with the standard coding of ISO/IEC 8859-1~4, - which supports English and most of European country languages. - 00b : ISO/IEC 8859-1. - 01b : ISO/IEC 8859-2. - 10b : ISO/IEC 8859-3. - 11b : ISO/IEC 8859-4. - */ - unsigned char temp; - LCD_CmdWrite(0xCC); - temp = LCD_DataRead(); - temp |= cSetb1; - temp |= cSetb0; - LCD_DataWrite(temp); -} -//[CDh]========================================================================= -void Enable_Font_Alignment(void) -{ - /* - Full Alignment Selection Bit - 0 : Full alignment disable. - 1 : Full alignment enable. - */ - unsigned char temp; - LCD_CmdWrite(0xCD); - temp = LCD_DataRead(); - temp |= cSetb7; - LCD_DataWrite(temp); -} -void Disable_Font_Alignment(void) -{ - /* - Full Alignment Selection Bit - 0 : Full alignment disable. - 1 : Full alignment enable. - */ - unsigned char temp; - LCD_CmdWrite(0xCD); - temp = LCD_DataRead(); - temp &= cClrb7; - LCD_DataWrite(temp); -} -void Font_Background_select_Transparency(void) -{ - /* - Font Transparency - 0 : Font with background color. - 1 : Font with background transparency. - */ - unsigned char temp; - LCD_CmdWrite(0xCD); - temp = LCD_DataRead(); - temp |= cSetb6; - LCD_DataWrite(temp); -} -void Font_Background_select_Color(void) -{ - /* - Font Transparency - 0 : Font with background color. - 1 : Font with background transparency. - */ - unsigned char temp; - LCD_CmdWrite(0xCD); - temp = LCD_DataRead(); - temp &= cClrb6; - LCD_DataWrite(temp); -} -void Font_0_degree(void) -{ - /* - Font Rotation - 0 : Normal - Text direction from left to right then from top to bottom - 1 : Counterclockwise 90 degree & horizontal flip - Text direction from top to bottom then from left to right - (it should accommodate with set VDIR as 1) - This attribute can be changed only when previous font write - finished (core_busy = 0) - */ - unsigned char temp; - LCD_CmdWrite(0xCD); - temp = LCD_DataRead(); - temp &= cClrb4; - LCD_DataWrite(temp); -} -void Font_90_degree(void) -{ - /* - Font Rotation - 0 : Normal - Text direction from left to right then from top to bottom - 1 : Counterclockwise 90 degree & horizontal flip - Text direction from top to bottom then from left to right - (it should accommodate with set VDIR as 1) - This attribute can be changed only when previous font write - finished (core_busy = 0) - */ - unsigned char temp; - LCD_CmdWrite(0xCD); - temp = LCD_DataRead(); - temp |= cSetb4; - LCD_DataWrite(temp); -} -void Font_Width_X1(void) -{ - /* - Horizontal Font Enlargement - 00b : X1. - 01b : X2. - 10b : X3. - 11b : X4. - */ - unsigned char temp; - LCD_CmdWrite(0xCD); - temp = LCD_DataRead(); - temp &= cClrb3; - temp &= cClrb2; - LCD_DataWrite(temp); -} -void Font_Width_X2(void) -{ - /* - Horizontal Font Enlargement - 00b : X1. - 01b : X2. - 10b : X3. - 11b : X4. - */ - unsigned char temp; - LCD_CmdWrite(0xCD); - temp = LCD_DataRead(); - temp &= cClrb3; - temp |= cSetb2; - LCD_DataWrite(temp); -} -void Font_Width_X3(void) -{ - /* - Horizontal Font Enlargement - 00b : X1. - 01b : X2. - 10b : X3. - 11b : X4. - */ - unsigned char temp; - LCD_CmdWrite(0xCD); - temp = LCD_DataRead(); - temp |= cSetb3; - temp &= cClrb2; - LCD_DataWrite(temp); -} -void Font_Width_X4(void) -{ - /* - Horizontal Font Enlargement - 00b : X1. - 01b : X2. - 10b : X3. - 11b : X4. - */ - unsigned char temp; - LCD_CmdWrite(0xCD); - temp = LCD_DataRead(); - temp |= cSetb3; - temp |= cSetb2; - LCD_DataWrite(temp); -} -void Font_Height_X1(void) -{ - /* - Vertical Font Enlargement - 00b : X1. - 01b : X2. - 10b : X3. - 11b : X4. - */ - unsigned char temp; - LCD_CmdWrite(0xCD); - temp = LCD_DataRead(); - temp &= cClrb1; - temp &= cClrb0; - LCD_DataWrite(temp); -} -void Font_Height_X2(void) -{ - /* - Vertical Font Enlargement - 00b : X1. - 01b : X2. - 10b : X3. - 11b : X4. - */ - unsigned char temp; - LCD_CmdWrite(0xCD); - temp = LCD_DataRead(); - temp &= cClrb1; - temp |= cSetb0; - LCD_DataWrite(temp); -} -void Font_Height_X3(void) -{ - /* - Vertical Font Enlargement - 00b : X1. - 01b : X2. - 10b : X3. - 11b : X4. - */ - unsigned char temp; - LCD_CmdWrite(0xCD); - temp = LCD_DataRead(); - temp |= cSetb1; - temp &= cClrb0; - LCD_DataWrite(temp); -} -void Font_Height_X4(void) -{ - /* - Vertical Font Enlargement - 00b : X1. - 01b : X2. - 10b : X3. - 11b : X4. - */ - unsigned char temp; - LCD_CmdWrite(0xCD); - temp = LCD_DataRead(); - temp |= cSetb1; - temp |= cSetb0; - LCD_DataWrite(temp); -} - -//[CEh]========================================================================= -void GTFont_Select_GT21L16TW_GT21H16T1W(void) -{ - /* - GT Serial Font ROM Select - 000b: GT21L16TW / GT21H16T1W - 001b: GT23L16U2W - 010b: GT23L24T3Y / GT23H24T3Y - 011b: GT23L24M1Z - 100b: GT23L32S4W / GT23H32S4W - 101b: GT20L24F6Y - 110b: GT21L24S1W - 111b: GT22L16A1Y - */ - unsigned char temp; - LCD_CmdWrite(0xCE); - temp = LCD_DataRead(); - temp &= cClrb7; - temp &= cClrb6; - temp &= cClrb5; - LCD_DataWrite(temp); -} -void GTFont_Select_GT23L16U2W(void) -{ - /* - GT Serial Font ROM Select - 000b: GT21L16TW / GT21H16T1W - 001b: GT23L16U2W - 010b: GT23L24T3Y / GT23H24T3Y - 011b: GT23L24M1Z - 100b: GT23L32S4W / GT23H32S4W - 101b: GT20L24F6Y - 110b: GT21L24S1W - 111b: GT22L16A1Y - */ - unsigned char temp; - LCD_CmdWrite(0xCE); - temp = LCD_DataRead(); - temp &= cClrb7; - temp &= cClrb6; - temp |= cSetb5; - LCD_DataWrite(temp); -} -void GTFont_Select_GT23L24T3Y_GT23H24T3Y(void) -{ - /* - GT Serial Font ROM Select - 000b: GT21L16TW / GT21H16T1W - 001b: GT23L16U2W - 010b: GT23L24T3Y / GT23H24T3Y - 011b: GT23L24M1Z - 100b: GT23L32S4W / GT23H32S4W - 101b: GT20L24F6Y - 110b: GT21L24S1W - 111b: GT22L16A1Y - */ - unsigned char temp; - LCD_CmdWrite(0xCE); - temp = LCD_DataRead(); - temp &= cClrb7; - temp |= cSetb6; - temp &= cClrb5; - LCD_DataWrite(temp); -} -void GTFont_Select_GT23L24M1Z(void) -{ - /* - GT Serial Font ROM Select - 000b: GT21L16TW / GT21H16T1W - 001b: GT23L16U2W - 010b: GT23L24T3Y / GT23H24T3Y - 011b: GT23L24M1Z - 100b: GT23L32S4W / GT23H32S4W - 101b: GT20L24F6Y - 110b: GT21L24S1W - 111b: GT22L16A1Y - */ - unsigned char temp; - LCD_CmdWrite(0xCE); - temp = LCD_DataRead(); - temp &= cClrb7; - temp |= cSetb6; - temp |= cSetb5; - LCD_DataWrite(temp); -} -void GTFont_Select_GT23L32S4W_GT23H32S4W(void) -{ - /* - GT Serial Font ROM Select - 000b: GT21L16TW / GT21H16T1W - 001b: GT23L16U2W - 010b: GT23L24T3Y / GT23H24T3Y - 011b: GT23L24M1Z - 100b: GT23L32S4W / GT23H32S4W - 101b: GT20L24F6Y - 110b: GT21L24S1W - 111b: GT22L16A1Y - */ - unsigned char temp; - LCD_CmdWrite(0xCE); - temp = LCD_DataRead(); - temp |= cSetb7; - temp &= cClrb6; - temp &= cClrb5; - LCD_DataWrite(temp); -} -void GTFont_Select_GT20L24F6Y(void) -{ - /* - GT Serial Font ROM Select - 000b: GT21L16TW / GT21H16T1W - 001b: GT23L16U2W - 010b: GT23L24T3Y / GT23H24T3Y - 011b: GT23L24M1Z - 100b: GT23L32S4W / GT23H32S4W - 101b: GT20L24F6Y - 110b: GT21L24S1W - 111b: GT22L16A1Y - */ - unsigned char temp; - LCD_CmdWrite(0xCE); - temp = LCD_DataRead(); - temp |= cSetb7; - temp &= cClrb6; - temp |= cSetb5; - LCD_DataWrite(temp); -} -void GTFont_Select_GT21L24S1W(void) -{ - /* - GT Serial Font ROM Select - 000b: GT21L16TW / GT21H16T1W - 001b: GT23L16U2W - 010b: GT23L24T3Y / GT23H24T3Y - 011b: GT23L24M1Z - 100b: GT23L32S4W / GT23H32S4W - 101b: GT20L24F6Y - 110b: GT21L24S1W - 111b: GT22L16A1Y - */ - unsigned char temp; - LCD_CmdWrite(0xCE); - temp = LCD_DataRead(); - temp |= cSetb7; - temp |= cSetb6; - temp &= cClrb5; - LCD_DataWrite(temp); -} -void GTFont_Select_GT22L16A1Y(void) -{ - /* - GT Serial Font ROM Select - 000b: GT21L16TW / GT21H16T1W - 001b: GT23L16U2W - 010b: GT23L24T3Y / GT23H24T3Y - 011b: GT23L24M1Z - 100b: GT23L32S4W / GT23H32S4W - 101b: GT20L24F6Y - 110b: GT21L24S1W - 111b: GT22L16A1Y - */ - unsigned char temp; - LCD_CmdWrite(0xCE); - temp = LCD_DataRead(); - temp |= cSetb7; - temp |= cSetb6; - temp |= cSetb5; - LCD_DataWrite(temp); -} - -//[CFh]========================================================================= -void Set_GTFont_Decoder(unsigned char temp) -{ - /* - [bit7-3] - FONT ROM Coding Setting - For specific GT serial Font ROM, the coding method must be set for decoding. - 00000b: GB2312 - 00001b: GB12345/GB18030 - 00010b: BIG5 - 00011b: UNICODE - 00100b: ASCII - 00101b: UNI-Japanese - 00110b: JIS0208 - 00111b: Latin/Greek/ Cyrillic / Arabic/Thai/Hebrew - 01000b: Korea - 10001b: ISO-8859-1 - 10010b: ISO-8859-2 - 10011b: ISO-8859-3 - 10100b: ISO-8859-4 - 10101b: ISO-8859-5 - 10110b: ISO-8859-6 - 10111b: ISO-8859-7 - 11000b: ISO-8859-8 - 11001b: ISO-8859-9 - 11010b: ISO-8859-10 - 11011b: ISO-8859-11 - 11100b: ISO-8859-12 - 11101b: ISO-8859-13 - 11110b: ISO-8859-14 - 11111b: ISO-8859-15 - - [bit1-0] - ASCII / Latin/Greek/ Cyrillic / Arabic - (ASCII) (Latin/Greek/Cyrillic) (Arabic) - 00b Normal Normal NA - 01b Arial Variable Width Presentation Forms-A - 10b Roman NA Presentation Forms-B - 11b Bold NA NA - */ - LCD_CmdWrite(0xCF); - LCD_DataWrite(temp); -} -//[D0h]========================================================================= -void Font_Line_Distance(unsigned char temp) -{ - /*[bit4-0] - Font Line Distance Setting - Setting the font character line distance when setting memory font - write cursor auto move. (Unit: pixel) - */ - LCD_CmdWrite(0xD0); - LCD_DataWrite(temp); -} -//[D1h]========================================================================= -void Set_Font_to_Font_Width(unsigned char temp) -{ - /*[bit5-0] - Font to Font Width Setting (Unit: pixel) - */ - LCD_CmdWrite(0xD1); - LCD_DataWrite(temp); -} -//[D2h]~[D4h]========================================================================= -void Foreground_RGB(unsigned char RED,unsigned char GREEN,unsigned char BLUE) -{ - /* - [D2h] Foreground Color - Red, for draw, text or color expansion - [D3h] Foreground Color - Green, for draw, text or color expansion - [D4h] Foreground Color - Blue, for draw, text or color expansion - */ - LCD_CmdWrite(0xD2); - LCD_DataWrite(RED); - LCD_CmdWrite(0xD3); - LCD_DataWrite(GREEN); - LCD_CmdWrite(0xD4); - LCD_DataWrite(BLUE); -} - -//Input data format:R3G3B2 -void Foreground_color_256(unsigned char temp) -{ - LCD_CmdWrite(0xD2); - LCD_DataWrite(temp); - LCD_CmdWrite(0xD3); - LCD_DataWrite(temp<<3); - LCD_CmdWrite(0xD4); - LCD_DataWrite(temp<<6); -} - -//Input data format:R5G6B5 -void Foreground_color_65k(unsigned short temp) -{ - LCD_CmdWrite(0xD2); - LCD_DataWrite(temp>>8); - LCD_CmdWrite(0xD3); - LCD_DataWrite(temp>>3); - LCD_CmdWrite(0xD4); - LCD_DataWrite(temp<<3); -} - -//Input data format:R8G8B8 -void Foreground_color_16M(unsigned long temp) -{ - LCD_CmdWrite(0xD2); - LCD_DataWrite(temp>>16); - LCD_CmdWrite(0xD3); - LCD_DataWrite(temp>>8); - LCD_CmdWrite(0xD4); - LCD_DataWrite(temp); -} - - - -//[D5h]~[D7h]========================================================================= -/* -[D5h] Background Color - Red, for Text or color expansion -[D6h] Background Color - Green, for Text or color expansion -[D7h] Background Color - Blue, for Text or color expansion -*/ -void Background_RGB(unsigned char RED,unsigned char GREEN,unsigned char BLUE) -{ - LCD_CmdWrite(0xD5); - LCD_DataWrite(RED); - LCD_CmdWrite(0xD6); - LCD_DataWrite(GREEN); - LCD_CmdWrite(0xD7); - LCD_DataWrite(BLUE); -} - -//Input data format:R3G3B2 -void Background_color_256(unsigned char temp) -{ - LCD_CmdWrite(0xD5); - LCD_DataWrite(temp); - LCD_CmdWrite(0xD6); - LCD_DataWrite(temp<<3); - LCD_CmdWrite(0xD7); - LCD_DataWrite(temp<<6); -} - -//Input data format:R5G6B6 -void Background_color_65k(unsigned short temp) -{ - LCD_CmdWrite(0xD5); - LCD_DataWrite(temp>>8); - LCD_CmdWrite(0xD6); - LCD_DataWrite(temp>>3); - LCD_CmdWrite(0xD7); - LCD_DataWrite(temp<<3); -} - -//Input data format:R8G8B8 -void Background_color_16M(unsigned long temp) -{ - LCD_CmdWrite(0xD5); - LCD_DataWrite(temp>>16); - LCD_CmdWrite(0xD6); - LCD_DataWrite(temp>>8); - LCD_CmdWrite(0xD7); - LCD_DataWrite(temp); -} - -//[DBh]~[DEh]========================================================================= -void CGRAM_Start_address(unsigned long Addr) -{ - /* - CGRAM START ADDRESS [31:0] - */ - LCD_CmdWrite(0xDB); - LCD_DataWrite(Addr); - LCD_CmdWrite(0xDC); - LCD_DataWrite(Addr>>8); - LCD_CmdWrite(0xDD); - LCD_DataWrite(Addr>>16); - LCD_CmdWrite(0xDE); - LCD_DataWrite(Addr>>24); -} - -//[DFh]========================================================================= -/* -[bit7] Enter Power saving state -0: Normal state. -1: Enter power saving state. -[bit1][bit0] Power saving Mode definition -00: NA -01: Standby Mode -10: Suspend Mode -11: Sleep Mode -*/ -void Power_Normal_Mode(void) -{ - LCD_CmdWrite(0xDF); - LCD_DataWrite(0x00); -} -void Power_Saving_Standby_Mode(void) -{ - LCD_CmdWrite(0xDF); - LCD_DataWrite(0x01); - LCD_CmdWrite(0xDF); - LCD_DataWrite(0x81); -} -void Power_Saving_Suspend_Mode(void) -{ - LCD_CmdWrite(0xDF); -// LCD_DataWrite(0x02); -// LCD_CmdWrite(0xDF); - LCD_DataWrite(0x82); -} -void Power_Saving_Sleep_Mode(void) -{ - LCD_CmdWrite(0xDF); -// LCD_DataWrite(0x03); -// LCD_CmdWrite(0xDF); - LCD_DataWrite(0x83); -} - - -//[E5h]~[E6h]========================================================================= -void LT768_I2CM_Clock_Prescale(unsigned short WX) -{ - /* - I2C Master Clock Pre-scale [7:0] - I2C Master Clock Pre-scale [15:8] - */ - LCD_CmdWrite(0xE5); - LCD_DataWrite(WX); - LCD_CmdWrite(0xE6); - LCD_DataWrite(WX>>8); -} -//[E7h]========================================================================= -void LT768_I2CM_Transmit_Data(unsigned char temp) -{ - /* - I2C Master Transmit[7:0] - */ - LCD_CmdWrite(0xE7); - LCD_DataWrite(temp); -} -//[E8h]========================================================================= -unsigned char LT768_I2CM_Receiver_Data(void) -{ - /* - I2C Master Receiver [7:0] - */ - unsigned char temp; - LCD_CmdWrite(0xE8); - temp=LCD_DataRead(); - return temp; -} -//[E9h]========================================================================= -/* -[bit7] START -Generate (repeated) start condition and be cleared by hardware automatically -Note : This bit is always read as 0. -[bit6] STOP -Generate stop condition and be cleared by hardware automatically -Note : This bit is always read as 0. -[bit5] -READ(READ and WRITE canˇt be used simultaneously) -Read form slave and be cleared by hardware automatically -Note : This bit is always read as 0. -[bit4] -WRITE(READ and WRITE canˇt be used simultaneously) -Write to slave and be cleared by hardware automatically -Note : This bit is always read as 0. -[bit3] ACKNOWLEDGE -When as a I2C master receiver -0 : Sent ACK. -1 : Sent NACK. -Note : This bit is always read as 0. -[bit0] Noise Filter -0 : Enable. -1 : Disable. -*/ - -#define Disable_I2CM_Noise_Filter - -void LT768_I2CM_Stop(void) -{ - LCD_CmdWrite(0xE9); -#ifdef Disable_I2CM_Noise_Filter - LCD_DataWrite(0x40); -#endif -#ifdef Enable_I2CM_Noise_Filter - LCD_DataWrite(0x41); -#endif -} -void LT768_I2CM_Read_With_Ack(void) -{ - LCD_CmdWrite(0xE9); -#ifdef Disable_I2CM_Noise_Filter - LCD_DataWrite(0x20); -#endif -#ifdef Enable_I2CM_Noise_Filter - LCD_DataWrite(0x21); -#endif -} - -void LT768_I2CM_Read_With_Nack(void) -{ - LCD_CmdWrite(0xE9); -#ifdef Disable_I2CM_Noise_Filter - LCD_DataWrite(0x68); -#endif -#ifdef Enable_I2CM_Noise_Filter - LCD_DataWrite(0x69); -#endif -} - -void LT768_I2CM_Write_With_Start(void) -{ - LCD_CmdWrite(0xE9); -#ifdef Disable_I2CM_Noise_Filter - LCD_DataWrite(0x90); -#endif -#ifdef Enable_I2CM_Noise_Filter - LCD_DataWrite(0x91); -#endif -} - -void LT768_I2CM_Write(void) -{ - LCD_CmdWrite(0xE9); -#ifdef Disable_I2CM_Noise_Filter - LCD_DataWrite(0x10); -#endif -#ifdef Enable_I2CM_Noise_Filter - LCD_DataWrite(0x11); -#endif -} - - - -//[EAh]========================================================================= -/* - 0=Ack - 1=Nack -*/ -unsigned char LT768_I2CM_Check_Slave_ACK(void) -{ - unsigned char temp; - /*[bit7] - Received acknowledge from slave - 0 : Acknowledge received. - 1 : No Acknowledge received. - */ - LCD_CmdWrite(0xEA); - temp=LCD_DataRead(); - - if((temp&0x80)==0x80) - { - return 1; - } - else - { - return 0; - } -} - - -/* - 0=Idle - 1=Busy -*/ -unsigned char LT768_I2CM_Bus_Busy(void) -{ - unsigned char temp; - /*[bit6] - I2C Bus is Busy - 0 : Idle. - 1 : Busy. - */ - LCD_CmdWrite(0xEA); - temp=LCD_DataRead(); - - if((temp&0x40)==0x40) - { - return 1; - } - else - { - return 0; - } -} - -/* - 0=Complete - 1=Transferring -*/ -unsigned char LT768_I2CM_transmit_Progress(void) -{ - unsigned char temp; - /*[bit6] - 0=Complete - 1=Transferring - */ - LCD_CmdWrite(0xEA); - temp=LCD_DataRead(); - - if((temp&0x02)==0x02) - { - return 1; - } - else - { - return 0; - } -} - -/* -0= Arbitration win -1= Arbitration lost -*/ -unsigned char LT768_I2CM_Arbitration(void) -{ - unsigned char temp; - /*[bit6] - I2C Bus is Busy - 0 : Idle. - 1 : Busy. - */ - LCD_CmdWrite(0xEA); - temp=LCD_DataRead(); - temp&=0x01; - return temp; -} - - -//[F0h]========================================================================= -void Set_GPIO_A_In_Out(unsigned char temp) -{ - /* - GPO-A_dir[7:0] : General Purpose I/O direction control. - 0: Output - 1: Input - */ - LCD_CmdWrite(0xF0); - LCD_DataWrite(temp); -} -//[F1h]========================================================================= -void Write_GPIO_A_7_0(unsigned char temp) -{ - /* - GPI-A[7:0] : General Purpose Input, share with DB[15:8] - GPO-A[7:0] : General Purpose Output, share with DB[15:8] - */ - LCD_CmdWrite(0xF1); - LCD_DataWrite(temp); -} -unsigned char Read_GPIO_A_7_0(void) -{ - /* - GPI-A[7:0] : General Purpose Input, share with DB[15:8] - GPO-A[7:0] : General Purpose Output, share with DB[15:8] - */ - unsigned char temp; - LCD_CmdWrite(0xF1); - temp=LCD_DataRead(); - return temp; -} -//[F2h]========================================================================= -void Write_GPIO_B_7_4(unsigned char temp) -{ - /* - GPI-B[7:0] : General Purpose Input ; share with {XKIN[3:0], XA0, XnWR, XnRD, XnCS} - GPO-B[7:4] : General Purpose Output ; share with XKOUT[3:0] ; - */ - LCD_CmdWrite(0xF2); - LCD_DataWrite(temp); -} -unsigned char Read_GPIO_B_7_0(void) -{ - /* - GPI-B[7:0] : General Purpose Input ; share with {XKIN[3:0], XA0, XnWR, XnRD, XnCS} - GPO-B[7:4] : General Purpose Output ; share with XKOUT[3:0] ; - */ - unsigned char temp; - LCD_CmdWrite(0xF2); - temp=LCD_DataRead(); - return temp; -} - -//[F3h]========================================================================= -void Set_GPIO_C_In_Out(unsigned char temp) -{ - /* - GPIO-C_dir[7:0] : General Purpose I/O direction control. - 0: Output - 1: Input - */ - LCD_CmdWrite(0xF3); - LCD_DataWrite(temp); -} -//[F4h]========================================================================= -void Write_GPIO_C_7_0(unsigned char temp) -{ - /* - GPIO-C[7:0] : General Purpose Input / Output - share with {XPWM0, XI2CSDA, XI2CSCL, XnSFCS1, XnSFCS0,XMISO, XMOSI, XSCLK} - */ - LCD_CmdWrite(0xF4); - LCD_DataWrite(temp); -} -unsigned char Read_GPIO_C_7_0(void) -{ - /* - GPIO-C[7:0] : General Purpose Input / Output - share with {XPWM0, XI2CSDA, XI2CSCL, XnSFCS1, XnSFCS0,XMISO, XMOSI, XSCLK} - */ - unsigned char temp; - LCD_CmdWrite(0xF4); - temp=LCD_DataRead(); - return temp; -} -//[F5h]========================================================================= -void Set_GPIO_D_In_Out(unsigned char temp) -{ - /* - GPIO-D_dir[7:0] : General Purpose I/O direction control. - 0: Output - 1: Input - */ - LCD_CmdWrite(0xF5); - LCD_DataWrite(temp); -} -//[F6h]========================================================================= -void Write_GPIO_D_7_0(unsigned char temp) -{ - /* - GPIO-D[7:0] : General Purpose Input/Output - */ - LCD_CmdWrite(0xF6); - LCD_DataWrite(temp); -} -unsigned char Read_GPIO_D_7_0(void) -{ - /* - GPIO-D[7:0] : General Purpose Input/Output - */ - unsigned char temp; - LCD_CmdWrite(0xF6); - temp=LCD_DataRead(); - return temp; -} -//[F7h]========================================================================= -void Set_GPIO_E_In_Out(unsigned char temp) -{ - /* - GPIO-E_dir[7:0] : General Purpose I/O direction control. - 0: Output - 1: Input - */ - LCD_CmdWrite(0xF7); - LCD_DataWrite(temp); -} -//[F8h]========================================================================= -void Write_GPIO_E_7_0(unsigned char temp) -{ - /* - GPIO-E[7:0] : General Purpose Input/Output. - share with {PDAT[23:19], PDAT[15:13]} - */ - LCD_CmdWrite(0xF8); - LCD_DataWrite(temp); -} -unsigned char Read_GPIO_E_7_0(void) -{ - /* - GPIO-E[7:0] : General Purpose Input/Output. - share with {PDAT[23:19], PDAT[15:13]} - */ - unsigned char temp; - LCD_CmdWrite(0xF8); - temp=LCD_DataRead(); - return temp; -} -//[F9h]========================================================================= -void Set_GPIO_F_In_Out(unsigned char temp) -{ - /* - GPIO-F_dir[7:0] : General Purpose I/O direction control. - 0: Output - 1: Input - */ - LCD_CmdWrite(0xF9); - LCD_DataWrite(temp); -} -//[FAh]========================================================================= -void Write_GPIO_F_7_0(unsigned char temp) -{ - /* - GPIO-F[7:0] : General Purpose Input/Output. - share with {XPDAT[12:10], XPDAT[7:3]} - */ - LCD_CmdWrite(0xFA); - LCD_DataWrite(temp); -} -unsigned char Read_GPIO_F_7_0(void) -{ - /* - GPIO-F[7:0] : General Purpose Input/Output. - share with {XPDAT[12:10], XPDAT[7:3]} - */ - unsigned char temp; - LCD_CmdWrite(0xFA); - temp=LCD_DataRead(); - return temp; -} - -//[FBh]========================================================================= - - -void Long_Key_enable(void) -{ - /* - Key-Scan Control Register 1 - [bit6] LongKey Enable Bit - 1 : Enable. Long key period is set by KSCR2 bit4-2. - 0 : Disable. - */ - unsigned char temp; - LCD_CmdWrite(0xFB); - temp=LCD_DataRead(); - temp |= cSetb6; - LCD_DataWrite(temp); -} - - -void Key_Scan_Freg(unsigned char setx) -{ - /*KF2-0: Key-Scan Frequency */ - unsigned char temp; - LCD_CmdWrite(0xFB); - temp = LCD_DataRead(); - temp &= 0xf0; - temp|= (setx&0x07); - LCD_DataWrite(temp); -} - - -//[FCh]========================================================================= - -void Key_Scan_Wakeup_Function_Enable(void) -{ - /* - Key-Scan Controller Register 2 - [bit7] - Key-Scan Wakeup Function Enable Bit - 0: Key-Scan Wakeup function is disabled. - 1: Key-Scan Wakeup function is enabled. - */ - unsigned char temp; - LCD_CmdWrite(0xFC); - temp=LCD_DataRead(); - temp |= cSetb7; - LCD_DataWrite(temp); -} - - -void Long_Key_Timing_Adjustment(unsigned char setx) -{ - /*Long Key Timing Adjustment*/ - unsigned char temp,temp1; - temp = setx & 0x1c; - LCD_CmdWrite(0xFC); - temp1 = LCD_DataRead(); - temp1|=temp; - LCD_DataWrite(temp1); -} - -unsigned char Numbers_of_Key_Hit(void) -{ - unsigned char temp; - LCD_CmdWrite(0xFC); - temp = LCD_DataRead(); //read key touch number - temp = temp & 0x03; // - return temp; -} - -//[FDh][FEh][FFh]========================================================================= -unsigned char Read_Key_Strobe_Data_0(void) -{ - /* - Key Strobe Data 0 - The corresponding key code 0 that is pressed. - */ - unsigned char temp; - LCD_CmdWrite(0xFD); - temp=LCD_DataRead(); - return temp; -} -unsigned char Read_Key_Strobe_Data_1(void) -{ - /* - Key Strobe Data 1 - The corresponding key code 1 that is pressed. - */ - unsigned char temp; - LCD_CmdWrite(0xFE); - temp=LCD_DataRead(); - return temp; -} -unsigned char Read_Key_Strobe_Data_2(void) -{ - /* - Key Strobe Data 2 - The corresponding key code 2 that is pressed. - */ - unsigned char temp; - LCD_CmdWrite(0xFF); - temp=LCD_DataRead(); - return temp; -} - -void Show_String(char *str) -{ - Text_Mode(); //文本模式 - LCD_CmdWrite(0x04); - - while(*str != '\0') - { - LCD_DataWrite(*str); - Check_Mem_WR_FIFO_not_Full(); - ++str; - } - - Check_2D_Busy(); - Graphic_Mode(); //back to graphic mode;图形模式 -} - - -void Show_picture(unsigned long numbers,const unsigned short *datap) -{ - unsigned long i; - LCD_CmdWrite(0x04); - - for(i=0; i +#include "nuttx/arch.h" +#include "nuttx/lcd/lt768.h" + +//============================================================================== + +void LCD_RegisterWrite(uint8_t Cmd, uint8_t Data) +{ + LCD_CmdWrite(Cmd); + LCD_DataWrite(Data); +} + +uint8_t LCD_RegisterRead(uint8_t Cmd) +{ + uint8_t temp; + LCD_CmdWrite(Cmd); + temp = LCD_DataRead(); + return temp; +} + +/******************************************************************************/ +/*Sub program area */ +/******************************************************************************/ +void Check_Mem_WR_FIFO_not_Full(void) +{ + /* 0: Memory Write FIFO is not full. + 1: Memory Write FIFO is full. */ + do + { + } + while(LCD_StatusRead()&0x80); +} +void Check_Mem_WR_FIFO_Empty(void) +{ + /* 0: Memory Write FIFO is not empty. + 1: Memory Write FIFO is empty. */ + do + { + } + while((LCD_StatusRead()&0x40) == 0x00); +} +void Check_Mem_RD_FIFO_not_Full(void) +{ + /* 0: Memory Read FIFO is not full. + 1: Memory Read FIFO is full. */ + do + { + } + while(LCD_StatusRead()&0x20); +} +void Check_Mem_RD_FIFO_not_Empty(void) +{ + /* 0: Memory Read FIFO is not empty. + 1: Memory Read FIFO is empty. + */ + do + { + } + while(LCD_StatusRead()&0x10); +} +void Check_2D_Busy(void) +{ + do + { + } + while(LCD_StatusRead()&0x08); +} +void Check_SDRAM_Ready(void) +{ + /* 0: SDRAM is not ready for access + 1: SDRAM is ready for access */ + uint8_t temp; + + do + { + temp = LCD_StatusRead(); + } + while((temp&0x04) == 0x00); +} + +uint8_t Power_Saving_Status(void) +{ + uint8_t temp; + + if((LCD_StatusRead()&0x02)==0x02) + { + temp = 1; + } + else + { + temp = 0; + } + + return temp; +} + +void Check_Power_is_Normal(void) +{ + /* 0: Normal operation state + 1: Power saving state */ + do + { + } + while(LCD_StatusRead()&0x02); +} +void Check_Power_is_Saving(void) +{ + /* 0: Normal operation state + 1: Power saving state */ + do + { + } + while((LCD_StatusRead()&0x02) == 0x00); +} +void Check_NO_Interrupt(void) +{ + /* 0: without interrupt event + 1: interrupt event occur + */ + do + { + } + while(LCD_StatusRead()&0x01); +} +void Check_Interrupt_Occur(void) +{ + /* 0: without interrupt event + 1: interrupt event occur + */ + do + { + } + while((LCD_StatusRead()&0x01) == 0x00); +} + +void Check_Busy_Draw(void) +{ + uint8_t temp; + + do + { + temp = LCD_StatusRead(); + } + while(temp&0x08); +} + +//[00h]========================================================================= + +void LT768_SW_Reset(void)//IC Reset?? +{ + uint8_t temp; + LCD_CmdWrite(0x00); + temp = LCD_DataRead(); + temp |= 0x01; + LCD_DataWrite(temp); + + do + { + temp = LCD_DataRead(); + } + while(temp&0x01); +} + +//[01h][01h][01h][01h][01h][01h][01h][01h][01h][01h][01h][01h][01h][01h][01h][01h] +void Enable_PLL(void) +{ + /* 0: PLL disable; allow change PLL parameter. + 1: PLL enable; cannot change PLL parameter.*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp |= cSetb7; + LCD_DataWrite(temp); + up_udelay(1);//PLL +} +void LT768_Sleep(void) +{ + /* 0: Normal mode. + 1: Sleep mode.*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp |= cSetb6; + LCD_DataWrite(temp); +} +void LT768_WakeUp(void) +{ + /* 0: Normal mode. + 1: Sleep mode.*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp &= cClrb6; + LCD_DataWrite(temp); +} +void Key_Scan_Enable(void) +{ + /* 0: Disable. + 1: Enable.*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp |= cSetb5; + LCD_DataWrite(temp); +} +void Key_Scan_Disable(void) +{ + /* 0: Disable. + 1: Enable.*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp &= cClrb5; + LCD_DataWrite(temp); +} +void TFT_24bit(void) +{ + /* 00b: 24-bits output. + 01b: 18-bits output, unused pins are set as GPIO. + 10b: 16-bits output, unused pins are set as GPIO. + 11b: LVDS, all 24-bits unused output pins are set as GPIO.*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp &= cClrb4; + temp &= cClrb3; + LCD_DataWrite(temp); +} +void TFT_18bit(void) +{ + /* 00b: 24-bits output. + 01b: 18-bits output, unused pins are set as GPIO. + 10b: 16-bits output, unused pins are set as GPIO. + 11b: LVDS, all 24-bits unused output pins are set as GPIO.*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp &= cClrb4; + temp |= cSetb3; + LCD_DataWrite(temp); +} +void TFT_16bit(void) +{ + /* 00b: 24-bits output. + 01b: 18-bits output, unused pins are set as GPIO. + 10b: 16-bits output, unused pins are set as GPIO. + 11b: LVDS, all 24-bits unused output pins are set as GPIO.*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp |= cSetb4; + temp &= cClrb3; + LCD_DataWrite(temp); +} +void TFT_LVDS(void) +{ + /* 00b: 24-bits output. + 01b: 18-bits output, unused pins are set as GPIO. + 10b: 16-bits output, unused pins are set as GPIO. + 11b: LVDS, all 24-bits unused output pins are set as GPIO.*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp |= cSetb4; + temp |= cSetb3; + LCD_DataWrite(temp); +} + +void LT768_I2CM_Enable(void) +{ + /* I2C master Interface Enable/Disable + 0: Disable + 1: Enable*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp |= cSetb2; + LCD_DataWrite(temp); +} + +void LT768_I2CM_Disable(void) +{ + /* I2C master Interface Enable/Disable + 0: Disable + 1: Enable*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp &= cClrb2; + LCD_DataWrite(temp); +} + +void Enable_SFlash_SPI(void) +{ + /* Serial Flash SPI Interface Enable/Disable + 0: Disable + 1: Enable*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp |= cSetb1; + LCD_DataWrite(temp); +} + +void Disable_SFlash_SPI(void) +{ + /* Serial Flash SPI Interface Enable/Disable + 0: Disable + 1: Enable*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp &= cClrb1; + LCD_DataWrite(temp); +} +void Host_Bus_8bit(void) +{ + /* Parallel Host Data Bus Width Selection + 0: 8-bit Parallel Host Data Bus. + 1: 16-bit Parallel Host Data Bus.*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp &= cClrb0; + LCD_DataWrite(temp); +} +void Host_Bus_16bit(void) +{ + /* Parallel Host Data Bus Width Selection + 0: 8-bit Parallel Host Data Bus. + 1: 16-bit Parallel Host Data Bus.*/ + uint8_t temp; + LCD_CmdWrite(0x01); + temp = LCD_DataRead(); + temp |= cSetb0; + LCD_DataWrite(temp); +} + +//[02h][02h][02h][02h][02h][02h][02h][02h][02h][02h][02h][02h][02h][02h][02h][02h] + +void RGB_8b_8bpp(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp &= cClrb7; + temp &= cClrb6; + LCD_DataWrite(temp); +} +void RGB_8b_16bpp(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp &= cClrb7; + temp |= cSetb6; + LCD_DataWrite(temp); +} +void RGB_8b_24bpp(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp &= cClrb7; + temp &= cClrb6; + LCD_DataWrite(temp); +} + +void RGB_16b_8bpp(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp |= cSetb7; + temp &= cClrb6; + LCD_DataWrite(temp); +} +void RGB_16b_16bpp(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp &= cClrb7; + temp |= cSetb6; + LCD_DataWrite(temp); +} +void RGB_16b_24bpp_mode1(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp &= cClrb7; + temp &= cClrb6; + LCD_DataWrite(temp); +} +void RGB_16b_24bpp_mode2(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp |= cSetb7; + temp |= cSetb6; + LCD_DataWrite(temp); +} + +void MemRead_Left_Right_Top_Down(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp &= cClrb5; + temp &= cClrb4; + LCD_DataWrite(temp); +} +void MemRead_Right_Left_Top_Down(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp &= cClrb5; + temp |= cSetb4; + LCD_DataWrite(temp); +} +void MemRead_Top_Down_Left_Right(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp |= cSetb5; + temp &= cClrb4; + LCD_DataWrite(temp); +} +void MemRead_Down_Top_Left_Right(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp |= cSetb5; + temp |= cSetb4; + LCD_DataWrite(temp); +} +void MemWrite_Left_Right_Top_Down(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp &= cClrb2; + temp &= cClrb1; + LCD_DataWrite(temp); +} +void MemWrite_Right_Left_Top_Down(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp &= cClrb2; + temp |= cSetb1; + LCD_DataWrite(temp); +} +void MemWrite_Top_Down_Left_Right(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp |= cSetb2; + temp &= cClrb1; + LCD_DataWrite(temp); +} +void MemWrite_Down_Top_Left_Right(void) +{ + uint8_t temp; + LCD_CmdWrite(0x02); + temp = LCD_DataRead(); + temp |= cSetb2; + temp |= cSetb1; + LCD_DataWrite(temp); +} +//[03h][03h][03h][03h][03h][03h][03h][03h][03h][03h][03h][03h][03h][03h][03h][03h] +void Interrupt_Active_Low(void) +{ + /* MPU Interrupt active level + 0 : active low. + 1 : active high.*/ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp &= cClrb7; + LCD_DataWrite(temp); +} +void Interrupt_Active_High(void) +{ + /* MPU Interrupt active level + 0 : active low. + 1 : active high.*/ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp |= cSetb7; + LCD_DataWrite(temp); +} +void ExtInterrupt_Debounce(void) +{ + /* External interrupt de-bounce + 0 : without de-bounce + 1 : enable de-bounce (1024 OSC clock)*/ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp |= cSetb6; + LCD_DataWrite(temp); +} +void ExtInterrupt_Nodebounce(void) +{ + /* External interrupt de-bounce + 0 : without de-bounce + 1 : enable de-bounce (1024 OSC clock)*/ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp &= cClrb6; + LCD_DataWrite(temp); +} +void ExtInterrupt_Input_Low_Level_Trigger(void) +{ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp &= cClrb5; + temp &= cClrb4; + LCD_DataWrite(temp); +} +void ExtInterrupt_Input_High_Level_Trigger(void) +{ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp |= cSetb5; + temp &= cClrb4; + LCD_DataWrite(temp); +} +void ExtInterrupt_Input_Falling_Edge_Trigger(void) +{ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp &= cClrb5; + temp |= cSetb4; + LCD_DataWrite(temp); +} +void ExtInterrupt_Input_Rising_Edge_Trigger(void) +{ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp |= cSetb5; + temp |= cSetb4; + LCD_DataWrite(temp); +} +void LVDS_Format1(void) +{ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp &= cClrb3; + LCD_DataWrite(temp); +} +void LVDS_Format2(void) +{ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp |= cSetb3; + LCD_DataWrite(temp); +} +void Graphic_Mode(void) +{ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp &= cClrb2; + LCD_DataWrite(temp); +} +void Text_Mode(void) +{ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp |= cSetb2; + LCD_DataWrite(temp); +} +void Memory_Select_SDRAM(void) +{ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp &= cClrb1; + temp &= cClrb0; // B + LCD_DataWrite(temp); +} +void Memory_Select_Graphic_Cursor_RAM(void) +{ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp |= cSetb1; + temp &= cClrb0; + LCD_DataWrite(temp); +} +void Memory_Select_Color_Palette_RAM(void) +{ + uint8_t temp; + LCD_CmdWrite(0x03); + temp = LCD_DataRead(); + temp |= cSetb1; + temp |= cSetb0; + LCD_DataWrite(temp); +} + +//[05h]========================================================================= +//[06h]========================================================================= +//[07h]========================================================================= +//[08h]========================================================================= +//[09h]========================================================================= +//[0Ah]========================================================================= +//[0Bh]========================================================================= + +void Enable_Resume_Interrupt(void) +{ + /* + Resume Interrupt Enable + 0: Disable. + 1: Enable. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp |= cSetb7; + LCD_DataWrite(temp); +} +void Disable_Resume_Interrupt(void) +{ + /* + Resume Interrupt Enable + 0: Disable. + 1: Enable. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp &= cClrb7; + LCD_DataWrite(temp); +} +void Enable_ExtInterrupt_Input(void) +{ + /* + External Interrupt (PS[0] pin) Enable + 0: Disable. + 1: Enable. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp |= cSetb6; + LCD_DataWrite(temp); +} +void Disable_ExtInterrupt_Input(void) +{ + /* + External Interrupt (PS[0] pin) Enable + 0: Disable. + 1: Enable. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp &= cClrb6; + LCD_DataWrite(temp); +} +void Enable_I2CM_Interrupt(void) +{ + /* + I2C Master Interrupt Enable + 0: Disable. + 1: Enable. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp |= cSetb5; + LCD_DataWrite(temp); +} +void Disable_I2CM_Interrupt(void) +{ + /* + I2C Master Interrupt Enable + 0: Disable. + 1: Enable. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp &= cClrb5; + LCD_DataWrite(temp); +} +void Enable_Vsync_Interrupt(void) +{ + /* + Vsync time base interrupt Enable Bit + 0: Disable Interrupt. + 1: Enable Interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp |= cSetb4; + LCD_DataWrite(temp); +} +void Disable_Vsync_Interrupt(void) +{ + /* + Vsync time base interrupt Enable Bit + 0: Disable Interrupt. + 1: Enable Interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp &= cClrb4; + LCD_DataWrite(temp); +} +void Enable_KeyScan_Interrupt(void) +{ + /* + Key Scan Interrupt Enable Bit + 0: Disable Key scan interrupt. + 1: Enable Key scan interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp |= cSetb3; + LCD_DataWrite(temp); +} +void Disable_KeyScan_Interrupt(void) +{ + /* + Key Scan Interrupt Enable Bit + 0: Disable Key scan interrupt. + 1: Enable Key scan interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp &= cClrb3; + LCD_DataWrite(temp); +} +void Enable_DMA_Draw_BTE_Interrupt(void) +{ + /* + Serial flash DMA Complete | Draw task finished | BTE Process + Complete etc. Interrupt Enable + 0: Disable Interrupt. + 1: Enable Interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp |= cSetb2; + LCD_DataWrite(temp); +} +void Disable_DMA_Draw_BTE_Interrupt(void) +{ + /* + Serial flash DMA Complete | Draw task finished | BTE Process + Complete etc. Interrupt Enable + 0: Disable Interrupt. + 1: Enable Interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp &= cClrb2; + LCD_DataWrite(temp); +} +void Enable_PWM1_Interrupt(void) +{ + /* + PWM timer 1 Interrupt Enable Bit + 0: Disable Interrupt. + 1: Enable Interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp |= cSetb1; + LCD_DataWrite(temp); +} +void Disable_PWM1_Interrupt(void) +{ + /* + PWM timer 1 Interrupt Enable Bit + 0: Disable Interrupt. + 1: Enable Interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp &= cClrb1; + LCD_DataWrite(temp); +} +void Enable_PWM0_Interrupt(void) +{ + /* + PWM timer 0 Interrupt Enable Bit + 0: Disable Interrupt. + 1: Enable Interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp |= cSetb0; + LCD_DataWrite(temp); +} +void Disable_PWM0_Interrupt(void) +{ + /* + PWM timer 0 Interrupt Enable Bit + 0: Disable Interrupt. + 1: Enable Interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0B); + temp = LCD_DataRead(); + temp &= cClrb0; + LCD_DataWrite(temp); +} + +//[0Ch]========================================================================= +uint8_t Read_Interrupt_status(void) +{ + /* + [Bit7]Read Function ..Resume Interrupt Status + 0: No Resume interrupt happens. + 1: Resume interrupt happens. + [Bit6]Read Function .. PS[0] pin Interrupt Status + 0: No PS[0] pin interrupt happens. + 1: PS[0] pin interrupt happens. + [Bit5]Read Function .. I2C master Interrupt Status + 0: No I2C master interrupt happens. + 1: I2C master interrupt happens. + [Bit4]Read Function .. Vsync Interrupt Status + 0: No interrupt happens. + 1: interrupt happens. + [Bit3]Read Function ..Key Scan Interrupt Status + 0: No Key Scan interrupt happens. + 1: Key Scan interrupt happens. + [Bit2]Read Function..Interrupt Status + 0: No interrupt happens. + 1: interrupt happens. + [Bit1]Read Function..Interrupt Status + 0: No interrupt happens. + 1: interrupt happens. + [Bit0]Read Function..Interrupt Status + 0: No interrupt happens. + 1: interrupt happens. + */ + uint8_t temp; + LCD_CmdWrite(0x0C); + temp = LCD_DataRead(); + return temp; +} +void Clear_Resume_Interrupt_Flag(void) +{ + /* + Resume Interrupt flag + Write Function .. Resume Interrupt Clear Bit + 0: No operation. + 1: Clear Resume interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0C); + temp = LCD_DataRead(); + temp |= cSetb7; + LCD_DataWrite(temp); +} +void Clear_ExtInterrupt_Input_Flag(void) +{ + /* + External Interrupt (PS[0] pin) flag + Write Function .. PS[0] pin edge Interrupt Clear Bit + 0: No operation. + 1: Clear the PS[0] pin edge interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0C); + temp = LCD_DataRead(); + temp |= cSetb6; + LCD_DataWrite(temp); +} +void Clear_I2CM_Interrupt_Flag(void) +{ + /* + I2C master Interrupt flag + Write Function.. I2C master Interrupt Clear Bit + 0: No operation. + 1: Clear the I2C master interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0C); + temp = LCD_DataRead(); + temp |= cSetb5; + LCD_DataWrite(temp); +} +void Clear_Vsync_Interrupt_Flag(void) +{ + /* + Vsync Time base interrupt flag + Write Function ..Vsync Interrupt Clear Bit + 0: No operation. + 1: Clear the interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0C); + temp = LCD_DataRead(); + temp |= cSetb4; + LCD_DataWrite(temp); +} +void Clear_KeyScan_Interrupt_Flag(void) +{ + /* + Key Scan Interrupt flag + Write Function..Key Scan Interrupt Clear Bit + 0: No operation. + 1: Clear the Key Scan interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0C); + temp = LCD_DataRead(); + temp |= cSetb3; + LCD_DataWrite(temp); +} +void Clear_DMA_Draw_BTE_Interrupt_Flag(void) +{ + /* + Serial flash DMA Complete | Draw task finished | BTE + Process Complete etc. Interrupt flag + Write Function.. Interrupt Clear Bit + 0: No operation. + 1: Clear interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0C); + temp = LCD_DataRead(); + temp |= cSetb2; + LCD_DataWrite(temp); +} +void Clear_PWM1_Interrupt_Flag(void) +{ + /* + PWM 1 timer Interrupt flag + Write Function..Interrupt Clear Bit + 0: No operation. + 1: Clear interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0C); + temp = LCD_DataRead(); + temp |= cSetb1; + LCD_DataWrite(temp); +} +void Clear_PWM0_Interrupt_Flag(void) +{ + /* + PWM 0 timer Interrupt flag + Write Function..Interrupt Clear Bit + 0: No operation. + 1: Clear interrupt. + */ + uint8_t temp; + LCD_CmdWrite(0x0C); + temp = LCD_DataRead(); + temp |= cSetb0; + LCD_DataWrite(temp); +} +//[0Dh]========================================================================= +void Mask_Resume_Interrupt_Flag(void) +{ + /* + Mask Resume Interrupt Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp |= cSetb7; + LCD_DataWrite(temp); +} +void Mask_ExtInterrupt_Input_Flag(void) +{ + /* + Mask External Interrupt (PS[0] pin) Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp |= cSetb6; + LCD_DataWrite(temp); +} +void Mask_I2CM_Interrupt_Flag(void) +{ + /* + Mask I2C Master Interrupt Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp |= cSetb5; + LCD_DataWrite(temp); +} +void Mask_Vsync_Interrupt_Flag(void) +{ + /* + Mask Vsync time base interrupt Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp |= cSetb4; + LCD_DataWrite(temp); +} +void Mask_KeyScan_Interrupt_Flag(void) +{ + /* + Mask Key Scan Interrupt Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp |= cSetb3; + LCD_DataWrite(temp); +} +void Mask_DMA_Draw_BTE_Interrupt_Flag(void) +{ + /* + Mask Serial flash DMA Complete | Draw task finished | BTE + Process Complete etc. Interrupt Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp |= cSetb2; + LCD_DataWrite(temp); +} +void Mask_PWM1_Interrupt_Flag(void) +{ + /* + Mask PWM timer 1 Interrupt Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp |= cSetb1; + LCD_DataWrite(temp); +} +void Mask_PWM0_Interrupt_Flag(void) +{ + /* + Mask PWM timer 0 Interrupt Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp |= cSetb0; + LCD_DataWrite(temp); +} + +void Enable_Resume_Interrupt_Flag(void) +{ + /* + Mask Resume Interrupt Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp &= cClrb7; + LCD_DataWrite(temp); +} +void Enable_ExtInterrupt_Inpur_Flag(void) +{ + /* + Mask External Interrupt (PS[0] pin) Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp &= cClrb6; + LCD_DataWrite(temp); +} +void Enable_I2CM_Interrupt_Flag(void) +{ + /* + Mask I2C Master Interrupt Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp &= cClrb5; + LCD_DataWrite(temp); +} +void Enable_Vsync_Interrupt_Flag(void) +{ + /* + Mask Vsync time base interrupt Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp &= cClrb4; + LCD_DataWrite(temp); +} +void Enable_KeyScan_Interrupt_Flag(void) +{ + /* + Mask Key Scan Interrupt Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp &= cClrb3; + LCD_DataWrite(temp); +} +void Enable_DMA_Draw_BTE_Interrupt_Flag(void) +{ + /* + Mask Serial flash DMA Complete | Draw task finished | BTE + Process Complete etc. Interrupt Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp &= cClrb2; + LCD_DataWrite(temp); +} +void Enable_PWM1_Interrupt_Flag(void) +{ + /* + Mask PWM timer 1 Interrupt Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp &= cClrb1; + LCD_DataWrite(temp); +} +void Enable_PWM0_Interrupt_Flag(void) +{ + /* + Mask PWM timer 0 Interrupt Flag + 0: Enable. + 1: Mask. + */ + uint8_t temp; + LCD_CmdWrite(0x0D); + temp = LCD_DataRead(); + temp &= cClrb0; + LCD_DataWrite(temp); +} + +//[0Eh]========================================================================= +void Enable_GPIOF_PullUp(void) +{ + /* + GPIO_F[7:0] Pull-Up Enable (XPDAT[23:19, 15:13]) + 0: Pull-Up Disable + 1: Pull-Up Enable + */ + uint8_t temp; + LCD_CmdWrite(0x0E); + temp = LCD_DataRead(); + temp |= cSetb5; + LCD_DataWrite(temp); +} +void Enable_GPIOE_PullUp(void) +{ + /* + GPIO_E[7:0] Pull-Up Enable (XPDAT[12:10, 7:3]) + 0: Pull-Up Disable + 1: Pull-Up Enable + */ + uint8_t temp; + LCD_CmdWrite(0x0E); + temp = LCD_DataRead(); + temp |= cSetb4; + LCD_DataWrite(temp); +} +void Enable_GPIOD_PullUp(void) +{ + /* + GPIO_D[7:0] Pull-Up Enable (XPDAT[18, 2, 17, 16, 9, 8, 1,0]) + 0: Pull-Up Disable + 1: Pull-Up Enable + */ + uint8_t temp; + LCD_CmdWrite(0x0E); + temp = LCD_DataRead(); + temp |= cSetb3; + LCD_DataWrite(temp); +} +void Enable_GPIOC_PullUp(void) +{ + /* + GPIO_C[6:0] Pull-Up Enable (XSDA, XSCL, XnSFCS1, + XnSFCS0, XMISO, XMOSI , XSCK) + 0: Pull-Up Disable + 1: Pull-Up Enable + */ + uint8_t temp; + LCD_CmdWrite(0x0E); + temp = LCD_DataRead(); + temp |= cSetb2; + LCD_DataWrite(temp); +} +void Enable_XDB15_8_PullUp(void) +{ + /* + XDB[15:8] Pull-Up Enable + 0: Pull-Up Disable + 1: Pull-Up Enable + */ + uint8_t temp; + LCD_CmdWrite(0x0E); + temp = LCD_DataRead(); + temp |= cSetb1; + LCD_DataWrite(temp); +} +void Enable_XDB7_0_PullUp(void) +{ + /* + XDB[7:0] Pull-Up Enable + 0: Pull-Up Disable + 1: Pull-Up Enable + */ + uint8_t temp; + LCD_CmdWrite(0x0E); + temp = LCD_DataRead(); + temp |= cSetb0; + LCD_DataWrite(temp); +} +void Disable_GPIOF_PullUp(void) +{ + /* + GPIO_F[7:0] Pull-Up Enable (XPDAT[23:19, 15:13]) + 0: Pull-Up Disable + 1: Pull-Up Enable + */ + uint8_t temp; + LCD_CmdWrite(0x0E); + temp = LCD_DataRead(); + temp &= cClrb5; + LCD_DataWrite(temp); +} +void Disable_GPIOE_PullUp(void) +{ + /* + GPIO_E[7:0] Pull-Up Enable (XPDAT[12:10, 7:3]) + 0: Pull-Up Disable + 1: Pull-Up Enable + */ + uint8_t temp; + LCD_CmdWrite(0x0E); + temp = LCD_DataRead(); + temp &= cClrb4; + LCD_DataWrite(temp); +} +void Disable_GPIOD_PullUp(void) +{ + /* + GPIO_D[7:0] Pull-Up Enable (XPDAT[18, 2, 17, 16, 9, 8, 1,0]) + 0: Pull-Up Disable + 1: Pull-Up Enable + */ + uint8_t temp; + LCD_CmdWrite(0x0E); + temp = LCD_DataRead(); + temp &= cClrb3; + LCD_DataWrite(temp); +} +void Disable_GPIOC_PullUp(void) +{ + /* + GPIO_C[6:0] Pull-Up Enable (XSDA, XSCL, XnSFCS1, + XnSFCS0, XMISO, XMOSI , XSCK) + 0: Pull-Up Disable + 1: Pull-Up Enable + */ + uint8_t temp; + LCD_CmdWrite(0x0E); + temp = LCD_DataRead(); + temp &= cClrb2; + LCD_DataWrite(temp); +} +void Disable_XDB15_8_PullUp(void) +{ + /* + XDB[15:8] Pull-Up Enable + 0: Pull-Up Disable + 1: Pull-Up Enable + */ + uint8_t temp; + LCD_CmdWrite(0x0E); + temp = LCD_DataRead(); + temp &= cClrb1; + LCD_DataWrite(temp); +} +void Disable_XDB7_0_PullUp(void) +{ + /* + XDB[7:0] Pull-Up Enable + 0: Pull-Up Disable + 1: Pull-Up Enable + */ + uint8_t temp; + LCD_CmdWrite(0x0E); + temp = LCD_DataRead(); + temp &= cClrb0; + LCD_DataWrite(temp); +} +//[0Fh]========================================================================= +void XPDAT18_Set_GPIO_D7(void) +{ + /* + XPDAT[18] ? not scan function select + 0: GPIO-D7 + 1: KOUT[4] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp &= cClrb7; + LCD_DataWrite(temp); +} +void XPDAT18_Set_KOUT4(void) +{ + /* + XPDAT[18] ? not scan function select + 0: GPIO-D7 + 1: KOUT[4] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp |= cSetb7; + LCD_DataWrite(temp); +} +void XPDAT17_Set_GPIO_D5(void) +{ + /* + XPDAT[17] ? not scan function select + 0: GPIO-D5 + 1: KOUT[2] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp &= cClrb6; + LCD_DataWrite(temp); +} +void XPDAT17_Set_KOUT2(void) +{ + /* + XPDAT[17] ? not scan function select + 0: GPIO-D5 + 1: KOUT[2] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp |= cSetb6; + LCD_DataWrite(temp); +} +void XPDAT16_Set_GPIO_D4(void) +{ + /* + XPDAT[16] ? not scan function select + 0: GPIO-D4 + 1: KOUT[1] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp &= cClrb5; + LCD_DataWrite(temp); +} +void XPDAT16_Set_KOUT1(void) +{ + /* + XPDAT[16] ? not scan function select + 0: GPIO-D4 + 1: KOUT[1] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp |= cSetb5; + LCD_DataWrite(temp); +} +void XPDAT9_Set_GPIO_D3(void) +{ + /* + XPDAT[9] ? not scan function select + 0: GPIO-D3 + 1: KOUT[3] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp &= cClrb4; + LCD_DataWrite(temp); +} +void XPDAT9_Set_KOUT3(void) +{ + /* + XPDAT[9] ? not scan function select + 0: GPIO-D3 + 1: KOUT[3] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp |= cSetb4; + LCD_DataWrite(temp); +} +void XPDAT8_Set_GPIO_D2(void) +{ + /* + XPDAT[8] ? not scan function select + 0: GPIO-D2 + 1: KIN[3] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp &= cClrb3; + LCD_DataWrite(temp); +} +void XPDAT8_Set_KIN3(void) +{ + /* + XPDAT[8] ? not scan function select + 0: GPIO-D2 + 1: KIN[3] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp |= cSetb3; + LCD_DataWrite(temp); +} +void XPDAT2_Set_GPIO_D6(void) +{ + /* + XPDAT[2] ? not scan function select + 0: GPIO-D6 + 1: KIN[4] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp &= cClrb2; + LCD_DataWrite(temp); +} +void XPDAT2_Set_KIN4(void) +{ + /* + XPDAT[2] ? not scan function select + 0: GPIO-D6 + 1: KIN[4] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp |= cSetb2; + LCD_DataWrite(temp); +} +void XPDAT1_Set_GPIO_D1(void) +{ + /* + XPDAT[1] ? not scan function select + 0: GPIO-D1 + 1: KIN[2] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp &= cClrb1; + LCD_DataWrite(temp); +} +void XPDAT1_Set_KIN2(void) +{ + /* + XPDAT[1] ? not scan function select + 0: GPIO-D1 + 1: KIN[2] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp |= cSetb1; + LCD_DataWrite(temp); +} +void XPDAT0_Set_GPIO_D0(void) +{ + /* + XPDAT[0] ? not scan function select + 0: GPIO-D0 + 1: KIN[1] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp &= cClrb0; + LCD_DataWrite(temp); +} +void XPDAT0_Set_KIN1(void) +{ + /* + XPDAT[0] ? not scan function select + 0: GPIO-D0 + 1: KIN[1] + */ + uint8_t temp; + LCD_CmdWrite(0x0F); + temp = LCD_DataRead(); + temp |= cSetb0; + LCD_DataWrite(temp); +} + +//[10h]========================================================================= +void Enable_PIP1(void) +{ + /* + PIP 1 window Enable/Disable + 0 : PIP 1 window disable. + 1 : PIP 1 window enable + PIP 1 window always on top of PIP 2 window. + */ + uint8_t temp; + LCD_CmdWrite(0x10); + temp = LCD_DataRead(); + temp |= cSetb7; + LCD_DataWrite(temp); +} +void Disable_PIP1(void) +{ + /* + PIP 1 window Enable/Disable + 0 : PIP 1 window disable. + 1 : PIP 1 window enable + PIP 1 window always on top of PIP 2 window. + */ + uint8_t temp; + LCD_CmdWrite(0x10); + temp = LCD_DataRead(); + temp &= cClrb7; + LCD_DataWrite(temp); +} +void Enable_PIP2(void) +{ + /* + PIP 2 window Enable/Disable + 0 : PIP 2 window disable. + 1 : PIP 2 window enable + PIP 1 window always on top of PIP 2 window. + */ + uint8_t temp; + LCD_CmdWrite(0x10); + temp = LCD_DataRead(); + temp |= cSetb6; + LCD_DataWrite(temp); +} +void Disable_PIP2(void) +{ + /* + PIP 2 window Enable/Disable + 0 : PIP 2 window disable. + 1 : PIP 2 window enable + PIP 1 window always on top of PIP 2 window. + */ + uint8_t temp; + LCD_CmdWrite(0x10); + temp = LCD_DataRead(); + temp &= cClrb6; + LCD_DataWrite(temp); +} +void Select_PIP1_Parameter(void) +{ + /* + 0: To configure PIP 1's parameters. + 1: To configure PIP 2's parameters.. + */ + uint8_t temp; + LCD_CmdWrite(0x10); + temp = LCD_DataRead(); + temp &= cClrb4; + LCD_DataWrite(temp); +} +void Select_PIP2_Parameter(void) +{ + /* + 0: To configure PIP 1's parameters. + 1: To configure PIP 2's parameters.. + */ + uint8_t temp; + LCD_CmdWrite(0x10); + temp = LCD_DataRead(); + temp |= cSetb4; + LCD_DataWrite(temp); +} +void Select_Main_Window_8bpp(void) +{ + /* + Main Window Color Depth Setting + 00b: 8-bpp generic TFT, i.e. 256 colors. + 01b: 16-bpp generic TFT, i.e. 65K colors. + 1xb: 24-bpp generic TFT, i.e. 1.67M colors. + */ + uint8_t temp; + LCD_CmdWrite(0x10); + temp = LCD_DataRead(); + temp &= cClrb3; + temp &= cClrb2; + LCD_DataWrite(temp); +} +void Select_Main_Window_16bpp(void) +{ + /* + Main Window Color Depth Setting + 00b: 8-bpp generic TFT, i.e. 256 colors. + 01b: 16-bpp generic TFT, i.e. 65K colors. + 1xb: 24-bpp generic TFT, i.e. 1.67M colors. + */ + uint8_t temp; + LCD_CmdWrite(0x10); + temp = LCD_DataRead(); + temp &= cClrb3; + temp |= cSetb2; + LCD_DataWrite(temp); +} +void Select_Main_Window_24bpp(void) +{ + /* + Main Window Color Depth Setting + 00b: 8-bpp generic TFT, i.e. 256 colors. + 01b: 16-bpp generic TFT, i.e. 65K colors. + 1xb: 24-bpp generic TFT, i.e. 1.67M colors. + */ + uint8_t temp; + LCD_CmdWrite(0x10); + temp = LCD_DataRead(); + temp |= cSetb3; + //temp |= cSetb2; + LCD_DataWrite(temp); +} +//[11h]========================================================================= +void Select_PIP2_Window_8bpp(void) +{ + /* + PIP 1 Window Color Depth Setting + 00b: 8-bpp generic TFT, i.e. 256 colors. + 01b: 16-bpp generic TFT, i.e. 65K colors. + 1xb: 24-bpp generic TFT, i.e. 1.67M colors. + */ + uint8_t temp; + LCD_CmdWrite(0x11); + temp = LCD_DataRead(); + temp &= cClrb1; + temp &= cClrb0; + LCD_DataWrite(temp); +} +void Select_PIP2_Window_16bpp(void) +{ + /* + PIP 1 Window Color Depth Setting + 00b: 8-bpp generic TFT, i.e. 256 colors. + 01b: 16-bpp generic TFT, i.e. 65K colors. + 1xb: 24-bpp generic TFT, i.e. 1.67M colors. + */ + uint8_t temp; + LCD_CmdWrite(0x11); + temp = LCD_DataRead(); + temp &= cClrb1; + temp |= cSetb0; + LCD_DataWrite(temp); +} +void Select_PIP2_Window_24bpp(void) +{ + /* + PIP 1 Window Color Depth Setting + 00b: 8-bpp generic TFT, i.e. 256 colors. + 01b: 16-bpp generic TFT, i.e. 65K colors. + 1xb: 24-bpp generic TFT, i.e. 1.67M colors. + */ + uint8_t temp; + LCD_CmdWrite(0x11); + temp = LCD_DataRead(); + temp |= cSetb1; + temp &= cClrb0; + LCD_DataWrite(temp); +} +void Select_PIP1_Window_8bpp(void) +{ + /* + PIP 2 Window Color Depth Setting + 00b: 8-bpp generic TFT, i.e. 256 colors. + 01b: 16-bpp generic TFT, i.e. 65K colors. + 1xb: 24-bpp generic TFT, i.e. 1.67M colors. + */ + uint8_t temp; + LCD_CmdWrite(0x11); + temp = LCD_DataRead(); + temp &= cClrb3; + temp &= cClrb2; + LCD_DataWrite(temp); +} +void Select_PIP1_Window_16bpp(void) +{ + /* + PIP 2 Window Color Depth Setting + 00b: 8-bpp generic TFT, i.e. 256 colors. + 01b: 16-bpp generic TFT, i.e. 65K colors. + 1xb: 24-bpp generic TFT, i.e. 1.67M colors. + */ + uint8_t temp; + LCD_CmdWrite(0x11); + temp = LCD_DataRead(); + temp &= cClrb3; + temp |= cSetb2; + LCD_DataWrite(temp); +} +void Select_PIP1_Window_24bpp(void) +{ + /* + PIP 2 Window Color Depth Setting + 00b: 8-bpp generic TFT, i.e. 256 colors. + 01b: 16-bpp generic TFT, i.e. 65K colors. + 1xb: 24-bpp generic TFT, i.e. 1.67M colors. + */ + uint8_t temp; + LCD_CmdWrite(0x11); + temp = LCD_DataRead(); + temp |= cSetb3; + temp &= cClrb2; + LCD_DataWrite(temp); +} + +//[12h]========================================================================= +void PCLK_Rising(void) +{ + /* + PCLK Inversion + 0: PDAT, DE, HSYNC etc. Drive(/ change) at PCLK falling edge. + 1: PDAT, DE, HSYNC etc. Drive(/ change) at PCLK rising edge. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp &= cClrb7; + LCD_DataWrite(temp); +} +void PCLK_Falling(void) +{ + /* + PCLK Inversion + 0: PDAT, DE, HSYNC etc. Drive(/ change) at PCLK falling edge. + 1: PDAT, DE, HSYNC etc. Drive(/ change) at PCLK rising edge. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp |= cSetb7; + LCD_DataWrite(temp); +} +void Display_ON(void) +{ + /* + Display ON/OFF + 0b: Display Off. + 1b: Display On. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + syslog(LOG_NOTICE, "Display_ON.pre_read=%02x\n", temp); + temp |= cSetb6; + LCD_DataWrite(temp); + temp = LCD_DataRead(); + syslog(LOG_NOTICE, "Display_ON.write_read=%02x\n", temp); +} + +void Display_OFF(void) +{ + /* + Display ON/OFF + 0b: Display Off. + 1b: Display On. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp &= cClrb6; + LCD_DataWrite(temp); +} +void Color_Bar_ON(void) +{ + /* + Display Test Color Bar + 0b: Disable. + 1b: Enable. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp |= cSetb5; + LCD_DataWrite(temp); +} +void Color_Bar_OFF(void) +{ + /* + Display Test Color Bar + 0b: Disable. + 1b: Enable. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp &= cClrb5; + LCD_DataWrite(temp); +} +void HSCAN_L_to_R(void) +{ + /* + Horizontal Scan Direction + 0 : From Left to Right + 1 : From Right to Left + PIP window will be disabled when HDIR set as 1. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp &= cClrb4; + LCD_DataWrite(temp); +} +void HSCAN_R_to_L(void) +{ + /* + Horizontal Scan Direction + 0 : From Left to Right + 1 : From Right to Left + PIP window will be disabled when HDIR set as 1. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp |= cSetb4; + LCD_DataWrite(temp); +} +void VSCAN_T_to_B(void) +{ + /* + Vertical Scan direction + 0 : From Top to Bottom + 1 : From bottom to Top + PIP window will be disabled when VDIR set as 1. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp &= cClrb3; + LCD_DataWrite(temp); +} +void VSCAN_B_to_T(void) +{ + /* + Vertical Scan direction + 0 : From Top to Bottom + 1 : From bottom to Top + PIP window will be disabled when VDIR set as 1. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp |= cSetb3; + LCD_DataWrite(temp); +} +void PDATA_Set_RGB(void) +{ + /* + parallel PDATA[23:0] Output Sequence + 000b : RGB. + 001b : RBG. + 010b : GRB. + 011b : GBR. + 100b : BRG. + 101b : BGR. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp &=0xf8; + LCD_DataWrite(temp); +} +void PDATA_Set_RBG(void) +{ + /* + parallel PDATA[23:0] Output Sequence + 000b : RGB. + 001b : RBG. + 010b : GRB. + 011b : GBR. + 100b : BRG. + 101b : BGR. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp &=0xf8; + temp |= cSetb0; + LCD_DataWrite(temp); +} +void PDATA_Set_GRB(void) +{ + /* + parallel PDATA[23:0] Output Sequence + 000b : RGB. + 001b : RBG. + 010b : GRB. + 011b : GBR. + 100b : BRG. + 101b : BGR. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp &=0xf8; + temp |= cSetb1; + LCD_DataWrite(temp); +} +void PDATA_Set_GBR(void) +{ + /* + parallel PDATA[23:0] Output Sequence + 000b : RGB. + 001b : RBG. + 010b : GRB. + 011b : GBR. + 100b : BRG. + 101b : BGR. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp &=0xf8; + temp |= cSetb1; + temp |= cSetb0; + LCD_DataWrite(temp); +} +void PDATA_Set_BRG(void) +{ + /* + parallel PDATA[23:0] Output Sequence + 000b : RGB. + 001b : RBG. + 010b : GRB. + 011b : GBR. + 100b : BRG. + 101b : BGR. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp &=0xf8; + temp |= cSetb2; + LCD_DataWrite(temp); +} +void PDATA_Set_BGR(void) +{ + /* + parallel PDATA[23:0] Output Sequence + 000b : RGB. + 001b : RBG. + 010b : GRB. + 011b : GBR. + 100b : BRG. + 101b : BGR. + */ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp &=0xf8; + temp |= cSetb2; + temp |= cSetb0; + LCD_DataWrite(temp); +} + +void PDATA_IDLE_STATE(void) +{ + uint8_t temp; + LCD_CmdWrite(0x12); + temp = LCD_DataRead(); + temp |=0x07; + LCD_DataWrite(temp); +} + + +//[13h]========================================================================= +void HSYNC_Low_Active(void) +{ + /* + HSYNC Polarity + 0 : Low active. + 1 : High active. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp &= cClrb7; + LCD_DataWrite(temp); +} +void HSYNC_High_Active(void) +{ + /* + HSYNC Polarity + 0 : Low active. + 1 : High active. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp |= cSetb7; + LCD_DataWrite(temp); +} +void VSYNC_Low_Active(void) +{ + /* + VSYNC Polarity + 0 : Low active. + 1 : High active. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp &= cClrb6; + LCD_DataWrite(temp); +} +void VSYNC_High_Active(void) +{ + /* + VSYNC Polarity + 0 : Low active. + 1 : High active. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp |= cSetb6; + LCD_DataWrite(temp); +} +void DE_Low_Active(void) +{ + /* + DE Polarity + 0 : High active. + 1 : Low active. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp |= cSetb5; + LCD_DataWrite(temp); +} +void DE_High_Active(void) +{ + /* + DE Polarity + 0 : High active. + 1 : Low active. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp &= cClrb5; + LCD_DataWrite(temp); +} +void Idle_DE_Low(void) +{ + /* + DE IDLE STATE(When STANDBY or DISPLAY OFF ) + 0 : Pin 'DE' output is low. + 1 : Pin 'DE' output is high. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp &= cClrb4; + LCD_DataWrite(temp); +} +void Idle_DE_High(void) +{ + /* + DE IDLE STATE(When STANDBY or DISPLAY OFF ) + 0 : Pin DE output is low. + 1 : Pin DE output is high. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp |= cSetb4; + LCD_DataWrite(temp); +} +void Idle_PCLK_Low(void) +{ + /* + PCLK IDLE STATE(When STANDBY or DISPLAY OFF ) + 0 : Pin 'PCLK' output is low. + 1 : Pin 'PCLK' output is high. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp &= cClrb3; + LCD_DataWrite(temp); +} +void Idle_PCLK_High(void) +{ + /* + PCLK IDLE STATE(When STANDBY or DISPLAY OFF) + 0 : Pin 'PCLK' output is low. + 1 : Pin 'PCLK' output is high. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp |= cSetb3; + LCD_DataWrite(temp); +} +void Idle_PDAT_Low(void) +{ + /* + PDAT IDLE STATE(When STANDBY or DISPLAY OFF ) + 0 : Pins 'PDAT[23:0]' output is low. + 1 : Pins 'PCLK[23:0]' output is high. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp &= cClrb2; + LCD_DataWrite(temp); +} +void Idle_PDAT_High(void) +{ + /* + PDAT IDLE STATE(When STANDBY or DISPLAY OFF ) + 0 : Pins 'PDAT[23:0]' output is low. + 1 : Pins 'PCLK[23:0]' output is high. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp |= cSetb2; + LCD_DataWrite(temp); +} +void Idle_HSYNC_Low(void) +{ + /* + HSYNC IDLE STATE(When STANDBY or DISPLAY OFF ) + 0 : Pin 'HSYNC' output is low. + 1 : Pin 'HSYNC' output is high. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp &= cClrb1; + LCD_DataWrite(temp); +} +void Idle_HSYNC_High(void) +{ + /* + HSYNC IDLE STATE(When STANDBY or DISPLAY OFF ) + 0 : Pin 'HSYNC' output is low. + 1 : Pin 'HSYNC' output is high. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp |= cSetb1; + LCD_DataWrite(temp); +} +void Idle_VSYNC_Low(void) +{ + /* + VSYNC IDLE STATE(When STANDBY or DISPLAY OFF ) + 0 : Pin 'VSYNC' output is low. + 1 : Pin 'VSYNC' output is high. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp &= cClrb0; + LCD_DataWrite(temp); +} +void Idle_VSYNC_High(void) +{ + /* + VSYNC IDLE STATE(When STANDBY or DISPLAY OFF ) + 0 : Pin 'VSYNC' output is low. + 1 : Pin 'VSYNC' output is high. + */ + uint8_t temp; + LCD_CmdWrite(0x13); + temp = LCD_DataRead(); + temp |= cSetb0; + LCD_DataWrite(temp); +} + +//[14h][15h][1Ah][1Bh]========================================================================= + +void LCD_HorizontalWidth_VerticalHeight(unsigned short WX,unsigned short HY) +{ + /* + [14h] Horizontal Display Width Setting Bit[7:0] + [15h] Horizontal Display Width Fine Tuning (HDWFT) [3:0] + The register specifies the LCD panel horizontal display width in + the unit of 8 pixels resolution. + Horizontal display width(pixels) = (HDWR + 1) * 8 + HDWFTR + + [1Ah] Vertical Display Height Bit[7:0] + Vertical Display Height(Line) = VDHR + 1 + [1Bh] Vertical Display Height Bit[10:8] + Vertical Display Height(Line) = VDHR + 1 + */ + uint8_t temp; + + if(WX<8) + { + LCD_CmdWrite(0x14); + LCD_DataWrite(0x00); + LCD_CmdWrite(0x15); + LCD_DataWrite(WX); + temp=HY-1; + LCD_CmdWrite(0x1A); + LCD_DataWrite(temp); + temp=(HY-1) >> 8; + LCD_CmdWrite(0x1B); + LCD_DataWrite(temp); + } + else + { + temp=(WX/8)-1; + LCD_CmdWrite(0x14); + LCD_DataWrite(temp); + temp=WX%8; + LCD_CmdWrite(0x15); + LCD_DataWrite(temp); + temp=HY-1; + LCD_CmdWrite(0x1A); + LCD_DataWrite(temp); + temp=(HY-1) >> 8; + LCD_CmdWrite(0x1B); + LCD_DataWrite(temp); + } +} +//[16h][17h]========================================================================= +void LCD_Horizontal_Non_Display(unsigned short WX) +{ + /* + [16h] Horizontal Non-Display Period(HNDR) Bit[4:0] + This register specifies the horizontal non-display period. Also + called back porch. + Horizontal non-display period(pixels) = (HNDR + 1) * 8 + HNDFTR + + [17h] Horizontal Non-Display Period Fine Tuning(HNDFT) [3:0] + This register specifies the fine tuning for horizontal non-display + period; it is used to support the SYNC mode panel. Each level of + this modulation is 1-pixel. + Horizontal non-display period(pixels) = (HNDR + 1) * 8 + HNDFTR + */ + uint8_t temp; + + if(WX<8) + { + LCD_CmdWrite(0x16); + LCD_DataWrite(0x00); + LCD_CmdWrite(0x17); + LCD_DataWrite(WX); + } + else + { + temp=(WX/8)-1; + LCD_CmdWrite(0x16); + LCD_DataWrite(temp); + temp=WX%8; + LCD_CmdWrite(0x17); + LCD_DataWrite(temp); + } +} +//[18h]========================================================================= +void LCD_HSYNC_Start_Position(unsigned short WX) +{ + /* + [18h] HSYNC Start Position[4:0] + The starting position from the end of display area to the + beginning of HSYNC. Each level of this modulation is 8-pixel. + Also called front porch. + HSYNC Start Position(pixels) = (HSTR + 1)x8 + */ + uint8_t temp; + + if(WX<8) + { + LCD_CmdWrite(0x18); + LCD_DataWrite(0x00); + } + else + { + temp=(WX/8)-1; + LCD_CmdWrite(0x18); + LCD_DataWrite(temp); + } +} +//[19h]========================================================================= +void LCD_HSYNC_Pulse_Width(unsigned short WX) +{ + /* + [19h] HSYNC Pulse Width(HPW) [4:0] + The period width of HSYNC. + HSYNC Pulse Width(pixels) = (HPW + 1)x8 + */ + uint8_t temp; + + if(WX<8) + { + LCD_CmdWrite(0x19); + LCD_DataWrite(0x00); + } + else + { + temp=(WX/8)-1; + LCD_CmdWrite(0x19); + LCD_DataWrite(temp); + } +} +//[1Ch][1Dh]========================================================================= +void LCD_Vertical_Non_Display(unsigned short HY) +{ + /* + [1Ch] Vertical Non-Display Period Bit[7:0] + Vertical Non-Display Period(Line) = (VNDR + 1) + + [1Dh] Vertical Non-Display Period Bit[9:8] + Vertical Non-Display Period(Line) = (VNDR + 1) + */ + uint8_t temp; + temp=HY-1; + LCD_CmdWrite(0x1C); + LCD_DataWrite(temp); + LCD_CmdWrite(0x1D); + LCD_DataWrite(temp >> 8); +} +//[1Eh]========================================================================= +void LCD_VSYNC_Start_Position(unsigned short HY) +{ + /* + [1Eh] VSYNC Start Position[7:0] + The starting position from the end of display area to the beginning of VSYNC. + VSYNC Start Position(Line) = (VSTR + 1) + */ + uint8_t temp; + temp=HY-1; + LCD_CmdWrite(0x1E); + LCD_DataWrite(temp); +} +//[1Fh]========================================================================= +void LCD_VSYNC_Pulse_Width(unsigned short HY) +{ + /* + [1Fh] VSYNC Pulse Width[5:0] + The pulse width of VSYNC in lines. + VSYNC Pulse Width(Line) = (VPWR + 1) + */ + uint8_t temp; + temp=HY-1; + LCD_CmdWrite(0x1F); + LCD_DataWrite(temp); +} +//[20h][21h][22h][23h]========================================================================= +void Main_Image_Start_Address(uint32_t Addr) +{ + /* + [20h] Main Image Start Address[7:2] + [21h] Main Image Start Address[15:8] + [22h] Main Image Start Address [23:16] + [23h] Main Image Start Address [31:24] + */ + LCD_RegisterWrite(0x20,Addr); + LCD_RegisterWrite(0x21,Addr >> 8); + LCD_RegisterWrite(0x22,Addr >> 16); + LCD_RegisterWrite(0x23,Addr >> 24); +} +//[24h][25h]========================================================================= +void Main_Image_Width(unsigned short WX) +{ + /* + [24h] Main Image Width [7:0] + [25h] Main Image Width [12:8] + Unit: Pixel. + It must be divisible by 4. MIW Bit [1:0] tie to '0' internally. + The value is physical pixel number. Maximum value is 8188 pixels + */ + LCD_RegisterWrite(0x24,WX); + LCD_RegisterWrite(0x25,WX >> 8); +} +//[26h][27h][28h][29h]========================================================================= +void Main_Window_Start_XY(unsigned short WX,unsigned short HY) +{ + /* + [26h] Main Window Upper-Left corner X-coordination [7:0] + [27h] Main Window Upper-Left corner X-coordination [12:8] + Reference Main Image coordination. + Unit: Pixel + It must be divisible by 4. MWULX Bit [1:0] tie to '0' internally. + X-axis coordination plus Horizontal display width cannot large than 8188. + + [28h] Main Window Upper-Left corner Y-coordination [7:0] + [29h] Main Window Upper-Left corner Y-coordination [12:8] + Reference Main Image coordination. + Unit: Pixel + Range is between 0 and 8191. + */ + LCD_RegisterWrite(0x26,WX); + LCD_RegisterWrite(0x27,WX >> 8); + LCD_RegisterWrite(0x28,HY); + LCD_RegisterWrite(0x29,HY >> 8); +} +//[2Ah][2Bh][2Ch][2Dh]========================================================================= +void PIP_Display_Start_XY(unsigned short WX,unsigned short HY) +{ + /* + [2Ah] PIP Window Display Upper-Left corner X-coordination [7:0] + [2Bh] PIP Window Display Upper-Left corner X-coordination [12:8] + Reference Main Window coordination. + Unit: Pixel + It must be divisible by 4. PWDULX Bit [1:0] tie to '0' internally. + X-axis coordination should less than horizontal display width. + According to bit of Select Configure PIP 1 or 2 Window's parameters. + Function bit will be configured for relative PIP window. + + [2Ch] PIP Window Display Upper-Left corner Y-coordination [7:0] + [2Dh] PIP Window Display Upper-Left corner Y-coordination [12:8] + Reference Main Window coordination. + Unit: Pixel + Y-axis coordination should less than vertical display height. + According to bit of Select Configure PIP 1 or 2 Window's parameters. + Function bit will be configured for relative PIP window. + */ + LCD_RegisterWrite(0x2A,WX); + LCD_RegisterWrite(0x2B,WX >> 8); + LCD_RegisterWrite(0x2C,HY); + LCD_RegisterWrite(0x2D,HY >> 8); +} +//[2Eh][2Fh][30h][31h]========================================================================= +void PIP_Image_Start_Address(uint32_t Addr) +{ + /* + [2Eh] PIP Image Start Address[7:2] + [2Fh] PIP Image Start Address[15:8] + [30h] PIP Image Start Address [23:16] + [31h] PIP Image Start Address [31:24] + */ + LCD_RegisterWrite(0x2E,Addr); + LCD_RegisterWrite(0x2F,Addr >> 8); + LCD_RegisterWrite(0x30,Addr >> 16); + LCD_RegisterWrite(0x31,Addr >> 24); +} +//[32h][33h]========================================================================= +void PIP_Image_Width(unsigned short WX) +{ + /* + [32h] PIP Image Width [7:0] + [33h] PIP Image Width [12:8] + Unit: Pixel. + It must be divisible by 4. PIW Bit [1:0] tie to '0' internally. + The value is physical pixel number. + This width should less than horizontal display width. + According to bit of Select Configure PIP 1 or 2 Window's parameters. + Function bit will be configured for relative PIP window. + */ + LCD_RegisterWrite(0x32,WX); + LCD_RegisterWrite(0x33,WX >> 8); +} +//[34h][35h][36h][37h]========================================================================= +void PIP_Window_Image_Start_XY(unsigned short WX,unsigned short HY) +{ + /* + [34h] PIP 1 or 2 Window Image Upper-Left corner X-coordination [7:0] + [35h] PIP Window Image Upper-Left corner X-coordination [12:8] + Reference PIP Image coordination. + Unit: Pixel + It must be divisible by 4. PWIULX Bit [1:0] tie to '0' internally. + X-axis coordination plus PIP image width cannot large than 8188. + According to bit of Select Configure PIP 1 or 2 Window's parameters. + Function bit will be configured for relative PIP window. + + [36h] PIP Windows Display Upper-Left corner Y-coordination [7:0] + [37h] PIP Windows Image Upper-Left corner Y-coordination [12:8] + Reference PIP Image coordination. + Unit: Pixel + Y-axis coordination plus PIP window height should less than 8191. + According to bit of Select Configure PIP 1 or 2 Window's parameters. + Function bit will be configured for relative PIP window. + */ + LCD_RegisterWrite(0x34,WX); + LCD_RegisterWrite(0x35,WX >> 8); + LCD_RegisterWrite(0x36,HY); + LCD_RegisterWrite(0x37,HY >> 8); +} +//[38h][39h][3Ah][3Bh]========================================================================= +void PIP_Window_Width_Height(unsigned short WX,unsigned short HY) +{ + /* + [38h] PIP Window Width [7:0] + [39h] PIP Window Width [10:8] + Unit: Pixel. + It must be divisible by 4. The value is physical pixel number. + Maximum value is 8188 pixels. + According to bit of Select Configure PIP 1 or 2 Window's parameters. + Function bit will be configured for relative PIP window. + + [3Ah] PIP Window Height [7:0] + [3Bh] PIP Window Height [10:8] + Unit: Pixel + The value is physical pixel number. Maximum value is 8191 pixels. + According to bit of Select Configure PIP 1 or 2 Window's parameters. + Function bit will be configured for relative PIP window. + */ + LCD_RegisterWrite(0x38,WX); + LCD_RegisterWrite(0x39,WX >> 8); + LCD_RegisterWrite(0x3A,HY); + LCD_RegisterWrite(0x3B,HY >> 8); +} + +//[3Ch]========================================================================= +void Enable_Graphic_Cursor(void) +{ + /* + Graphic Cursor Enable + 0 : Graphic Cursor disable. + 1 : Graphic Cursor enable. + */ + uint8_t temp; + LCD_CmdWrite(0x3C); + temp = LCD_DataRead(); + temp |= cSetb4; + LCD_DataWrite(temp); +} +void Disable_Graphic_Cursor(void) +{ + /* + Graphic Cursor Enable + 0 : Graphic Cursor disable. + 1 : Graphic Cursor enable. + */ + uint8_t temp; + LCD_CmdWrite(0x3C); + temp = LCD_DataRead(); + temp &= cClrb4; + LCD_DataWrite(temp); +} +// +void Select_Graphic_Cursor_1(void) +{ + /* + Graphic Cursor Selection Bit + Select one from four graphic cursor types. (00b to 11b) + 00b : Graphic Cursor Set 1. + 01b : Graphic Cursor Set 2. + 10b : Graphic Cursor Set 3. + 11b : Graphic Cursor Set 4. + */ + uint8_t temp; + LCD_CmdWrite(0x3C); + temp = LCD_DataRead(); + temp &= cClrb3; + temp &= cClrb2; + LCD_DataWrite(temp); +} +void Select_Graphic_Cursor_2(void) +{ + /* + Graphic Cursor Selection Bit + Select one from four graphic cursor types. (00b to 11b) + 00b : Graphic Cursor Set 1. + 01b : Graphic Cursor Set 2. + 10b : Graphic Cursor Set 3. + 11b : Graphic Cursor Set 4. + */ + uint8_t temp; + LCD_CmdWrite(0x3C); + temp = LCD_DataRead(); + temp &= cClrb3; + temp |= cSetb2; + LCD_DataWrite(temp); +} +void Select_Graphic_Cursor_3(void) +{ + /* + Graphic Cursor Selection Bit + Select one from four graphic cursor types. (00b to 11b) + 00b : Graphic Cursor Set 1. + 01b : Graphic Cursor Set 2. + 10b : Graphic Cursor Set 3. + 11b : Graphic Cursor Set 4. + */ + uint8_t temp; + LCD_CmdWrite(0x3C); + temp = LCD_DataRead(); + temp |= cSetb3; + temp &= cClrb2; + LCD_DataWrite(temp); +} +void Select_Graphic_Cursor_4(void) +{ + /* + Graphic Cursor Selection Bit + Select one from four graphic cursor types. (00b to 11b) + 00b : Graphic Cursor Set 1. + 01b : Graphic Cursor Set 2. + 10b : Graphic Cursor Set 3. + 11b : Graphic Cursor Set 4. + */ + uint8_t temp; + LCD_CmdWrite(0x3C); + temp = LCD_DataRead(); + temp |= cSetb3; + temp |= cSetb2; + LCD_DataWrite(temp); +} +// +void Enable_Text_Cursor(void) +{ + /* + Text Cursor Enable + 0 : Disable. + 1 : Enable. + Text cursor & Graphic cursor cannot enable simultaneously. + Graphic cursor has higher priority then Text cursor if enabled simultaneously. + */ + uint8_t temp; + LCD_CmdWrite(0x3C); + temp = LCD_DataRead(); + temp |= cSetb1; + LCD_DataWrite(temp); +} +void Disable_Text_Cursor(void) +{ + /* + Text Cursor Enable + 0 : Disable. + 1 : Enable. + Text cursor & Graphic cursor cannot enable simultaneously. + Graphic cursor has higher priority then Text cursor if enabled simultaneously. + */ + uint8_t temp; + LCD_CmdWrite(0x3C); + temp = LCD_DataRead(); + temp &= cClrb1; + LCD_DataWrite(temp); +} +// +void Enable_Text_Cursor_Blinking(void) +{ + /* + Text Cursor Blinking Enable + 0 : Disable. + 1 : Enable. + */ + uint8_t temp; + LCD_CmdWrite(0x3C); + temp = LCD_DataRead(); + temp |= cSetb0; + LCD_DataWrite(temp); +} +void Disable_Text_Cursor_Blinking(void) +{ + /* + Text Cursor Blinking Enable + 0 : Disable. + 1 : Enable. + */ + uint8_t temp; + LCD_CmdWrite(0x3C); + temp = LCD_DataRead(); + temp &= cClrb0; + LCD_DataWrite(temp); +} +//[3Dh]========================================================================= +void Blinking_Time_Frames(uint8_t temp) +{ + /* + Text Cursor Blink Time Setting (Unit: Frame) + 00h : 1 frame time. + 01h : 2 frames time. + 02h : 3 frames time. + : + FFh : 256 frames time. + */ + LCD_CmdWrite(0x3D); + LCD_DataWrite(temp); +} +//[3Eh]========================================================================= +void Text_Cursor_H_V(unsigned short WX,unsigned short HY) +{ + /* + [3Eh] + Text Cursor Horizontal Size Setting[4:0] + Unit : Pixel + Zero-based number. Value '0' means 1 pixel. + Note : When font is enlarged, the cursor setting will multiply the + same times as the font enlargement. + [3Fh] + Text Cursor Vertical Size Setting[4:0] + Unit : Pixel + Zero-based number. Value '0' means 1 pixel. + Note : When font is enlarged, the cursor setting will multiply the + same times as the font enlargement. + */ + LCD_CmdWrite(0x3E); + LCD_DataWrite(WX); + LCD_CmdWrite(0x3F); + LCD_DataWrite(HY); +} +//[40h][41h][42h][43h]========================================================================= +void Graphic_Cursor_XY(unsigned short WX,unsigned short HY) +{ + /* + [40h] Graphic Cursor Horizontal Location[7:0] + [41h] Graphic Cursor Horizontal Location[12:8] + [42h] Graphic Cursor Vertical Location[7:0] + [43h] Graphic Cursor Vertical Location[12:8] + Reference main Window coordination. + */ + LCD_RegisterWrite(0x40,WX); + LCD_RegisterWrite(0x41,WX >> 8); + LCD_RegisterWrite(0x42,HY); + LCD_RegisterWrite(0x43,HY >> 8); +} +//[44h]========================================================================= +void Set_Graphic_Cursor_Color_1(uint8_t temp) +{ + /* + [44h] Graphic Cursor Color 0 with 256 Colors + RGB Format [7:0] = RRRGGGBB. + */ + LCD_RegisterWrite(0x44,temp); +} +//[45h]========================================================================= +void Set_Graphic_Cursor_Color_2(uint8_t temp) +{ + /* + [45h] Graphic Cursor Color 1 with 256 Colors + RGB Format [7:0] = RRRGGGBB. + */ + LCD_RegisterWrite(0x45,temp); +} +//[50h][51h][52h][53h]========================================================================= +void Canvas_Image_Start_address(uint32_t Addr) +{ + /* + [50h] Start address of Canvas [7:0] + [51h] Start address of Canvas [15:8] + [52h] Start address of Canvas [23:16] + [53h] Start address of Canvas [31:24] + */ + LCD_RegisterWrite(0x50,Addr); + LCD_RegisterWrite(0x51,Addr >> 8); + LCD_RegisterWrite(0x52,Addr >> 16); + LCD_RegisterWrite(0x53,Addr >> 24); +} +//[54h][55h]========================================================================= +void Canvas_image_width(unsigned short WX) +{ + /* + [54h] Canvas image width [7:2] + [55h] Canvas image width [12:8] + */ + LCD_RegisterWrite(0x54,WX); + LCD_RegisterWrite(0x55,WX >> 8); +} +//[56h][57h][58h][59h]========================================================================= +void Active_Window_XY(unsigned short WX,unsigned short HY) +{ + /* + [56h] Active Window Upper-Left corner X-coordination [7:0] + [57h] Active Window Upper-Left corner X-coordination [12:8] + [58h] Active Window Upper-Left corner Y-coordination [7:0] + [59h] Active Window Upper-Left corner Y-coordination [12:8] + */ + LCD_RegisterWrite(0x56,WX); + LCD_RegisterWrite(0x57,WX >> 8); + LCD_RegisterWrite(0x58,HY); + LCD_RegisterWrite(0x59,HY >> 8); +} +//[5Ah][5Bh][5Ch][5Dh]========================================================================= +void Active_Window_WH(unsigned short WX,unsigned short HY) +{ + /* + [5Ah] Width of Active Window [7:0] + [5Bh] Width of Active Window [12:8] + [5Ch] Height of Active Window [7:0] + [5Dh] Height of Active Window [12:8] + */ + LCD_RegisterWrite(0x5A,WX); + LCD_RegisterWrite(0x5B,WX >> 8); + LCD_RegisterWrite(0x5C,HY); + LCD_RegisterWrite(0x5D,HY >> 8); +} +//[5Eh]========================================================================= +void Select_Write_Data_Position(void) +{ + /* + Select to read back Graphic Read/Write position + 0: read back Graphic Write position + 1: read back Graphic Read position + */ + uint8_t temp; + LCD_CmdWrite(0x5E); + temp = LCD_DataRead(); + temp &= cClrb3; + LCD_DataWrite(temp); +} +void Select_Read_Data_Position(void) +{ + /* + Select to read back Graphic Read/Write position + 0: read back Graphic Write position + 1: read back Graphic Read position + */ + uint8_t temp; + LCD_CmdWrite(0x5E); + temp = LCD_DataRead(); + temp |= cSetb3; + LCD_DataWrite(temp); +} +void Memory_XY_Mode(void) +{ + /* + Canvas addressing mode + 0: Block mode (X-Y coordination addressing) + 1: linear mode + */ + uint8_t temp; + LCD_CmdWrite(0x5E); + temp = LCD_DataRead(); + temp &= cClrb2; + LCD_DataWrite(temp); +} +void Memory_Linear_Mode(void) +{ + /* + Canvas addressing mode + 0: Block mode (X-Y coordination addressing) + 1: linear mode + */ + uint8_t temp; + LCD_CmdWrite(0x5E); + temp = LCD_DataRead(); + temp |= cSetb2; + LCD_DataWrite(temp); +} +void Memory_8bpp_Mode(void) +{ + /* + Canvas image's color depth & memory R/W data width + In Block Mode: + 00: 8bpp + 01: 16bpp + 1x: 24bpp + In Linear Mode: + X0: 8-bits memory data read/write. + X1: 16-bits memory data read/write + */ + uint8_t temp; + LCD_CmdWrite(0x5E); + temp = LCD_DataRead(); + temp &= cClrb1; + temp &= cClrb0; + LCD_DataWrite(temp); +} +void Memory_16bpp_Mode(void) +{ + /* + Canvas image's color depth & memory R/W data width + In Block Mode: + 00: 8bpp + 01: 16bpp + 1x: 24bpp + In Linear Mode: + X0: 8-bits memory data read/write. + X1: 16-bits memory data read/write + */ + uint8_t temp; + LCD_CmdWrite(0x5E); + temp = LCD_DataRead(); + temp &= cClrb1; + temp |= cSetb0; + LCD_DataWrite(temp); +} +void Memory_24bpp_Mode(void) +{ + /* + Canvas image's color depth & memory R/W data width + In Block Mode: + 00: 8bpp + 01: 16bpp + 1x: 24bpp + In Linear Mode: + X0: 8-bits memory data read/write. + X1: 16-bits memory data read/write + */ + uint8_t temp; + LCD_CmdWrite(0x5E); + temp = LCD_DataRead(); + temp |= cSetb1; + temp |= cSetb0; + LCD_DataWrite(temp); +} + +//[5Fh][60h][61h][62h]========================================================================= +void Goto_Pixel_XY(unsigned short WX,unsigned short HY) +{ + /* + [Write]: Set Graphic Read/Write position + [Read]: Current Graphic Read/Write position + Read back is Read position or Write position depends on + REG[5Eh] bit3, Select to read back Graphic Read/Write position. + When DPRAM Linear mode:Graphic Read/Write Position [31:24][23:16][15:8][7:0] + When DPRAM Active window mode:Graphic Read/Write + Horizontal Position [12:8][7:0], + Vertical Position [12:8][7:0]. + Reference Canvas image coordination. Unit: Pixel + */ + LCD_RegisterWrite(0x5F,WX); + LCD_RegisterWrite(0x60,WX >> 8); + LCD_RegisterWrite(0x61,HY); + LCD_RegisterWrite(0x62,HY >> 8); +} +void Goto_Linear_Addr(uint32_t Addr) +{ + LCD_RegisterWrite(0x5F,Addr); + LCD_RegisterWrite(0x60,Addr >> 8); + LCD_RegisterWrite(0x61,Addr >> 16); + LCD_RegisterWrite(0x62,Addr >> 24); +} + + +//[63h][64h][65h][66h]========================================================================= +void Goto_Text_XY(unsigned short WX,unsigned short HY) +{ + /* + Write: Set Text Write position + Read: Current Text Write position + Text Write X-coordination [12:8][7:0] + Text Write Y-coordination [12:8][7:0] + Reference Canvas image coordination. + Unit: Pixel + */ + LCD_RegisterWrite(0x63,WX); + LCD_RegisterWrite(0x64,WX >> 8); + LCD_RegisterWrite(0x65,HY); + LCD_RegisterWrite(0x66,HY >> 8); +} +//[67h]========================================================================= +/* +[bit7]Draw Line / Triangle Start Signal +Write Function +0 : Stop the drawing function. +1 : Start the drawing function. +Read Function +0 : Drawing function complete. +1 : Drawing function is processing. +[bit5]Fill function for Triangle Signal +0 : Non fill. +1 : Fill. +[bit1]Draw Triangle or Line Select Signal +0 : Draw Line +1 : Draw Triangle +*/ +void Start_Line(void) +{ + LCD_CmdWrite(0x67); + LCD_DataWrite(0x80); + Check_Busy_Draw(); +} +void Start_Triangle(void) +{ + LCD_CmdWrite(0x67); + LCD_DataWrite(0x82);//B1000_0010 + Check_Busy_Draw(); +} +void Start_Triangle_Fill(void) +{ + LCD_CmdWrite(0x67); + LCD_DataWrite(0xA2);//B1010_0010 + Check_Busy_Draw(); +} +//[68h][69h][6Ah][6Bh]========================================================================= +//line start x, y +void Line_Start_XY(unsigned short WX,unsigned short HY) +{ + /* + [68h] Draw Line/Square/Triangle Start X-coordination [7:0] + [69h] Draw Line/Square/Triangle Start X-coordination [12:8] + [6Ah] Draw Line/Square/Triangle Start Y-coordination [7:0] + [6Bh] Draw Line/Square/Triangle Start Y-coordination [12:8] + */ + LCD_CmdWrite(0x68); + LCD_DataWrite(WX); + LCD_CmdWrite(0x69); + LCD_DataWrite(WX >> 8); + LCD_CmdWrite(0x6A); + LCD_DataWrite(HY); + LCD_CmdWrite(0x6B); + LCD_DataWrite(HY >> 8); +} +//[6Ch][6Dh][6Eh][6Fh]========================================================================= +//line end x, y +void Line_End_XY(unsigned short WX,unsigned short HY) +{ + /* + [6Ch] Draw Line/Square/Triangle End X-coordination [7:0] + [6Dh] Draw Line/Square/Triangle End X-coordination [12:8] + [6Eh] Draw Line/Square/Triangle End Y-coordination [7:0] + [6Fh] Draw Line/Square/Triangle End Y-coordination [12:8] + */ + LCD_CmdWrite(0x6C); + LCD_DataWrite(WX); + LCD_CmdWrite(0x6D); + LCD_DataWrite(WX >> 8); + LCD_CmdWrite(0x6E); + LCD_DataWrite(HY); + LCD_CmdWrite(0x6F); + LCD_DataWrite(HY >> 8); +} +//[68h]~[73h]========================================================================= + +void Triangle_Point1_XY(unsigned short WX,unsigned short HY) +{ + /* + [68h] Draw Line/Square/Triangle Start X-coordination [7:0] + [69h] Draw Line/Square/Triangle Start X-coordination [12:8] + [6Ah] Draw Line/Square/Triangle Start Y-coordination [7:0] + [6Bh] Draw Line/Square/Triangle Start Y-coordination [12:8] + */ + LCD_CmdWrite(0x68); + LCD_DataWrite(WX); + LCD_CmdWrite(0x69); + LCD_DataWrite(WX >> 8); + LCD_CmdWrite(0x6A); + LCD_DataWrite(HY); + LCD_CmdWrite(0x6B); + LCD_DataWrite(HY >> 8); +} + +void Triangle_Point2_XY(unsigned short WX,unsigned short HY) +{ + /* + [6Ch] Draw Line/Square/Triangle End X-coordination [7:0] + [6Dh] Draw Line/Square/Triangle End X-coordination [12:8] + [6Eh] Draw Line/Square/Triangle End Y-coordination [7:0] + [6Fh] Draw Line/Square/Triangle End Y-coordination [12:8] + */ + LCD_CmdWrite(0x6C); + LCD_DataWrite(WX); + LCD_CmdWrite(0x6D); + LCD_DataWrite(WX >> 8); + LCD_CmdWrite(0x6E); + LCD_DataWrite(HY); + LCD_CmdWrite(0x6F); + LCD_DataWrite(HY >> 8); +} + +void Triangle_Point3_XY(unsigned short WX,unsigned short HY) +{ + /* + [70h] Draw Triangle Point 3 X-coordination [7:0] + [71h] Draw Triangle Point 3 X-coordination [12:8] + [72h] Draw Triangle Point 3 Y-coordination [7:0] + [73h] Draw Triangle Point 3 Y-coordination [12:8] + */ + LCD_CmdWrite(0x70); + LCD_DataWrite(WX); + LCD_CmdWrite(0x71); + LCD_DataWrite(WX >> 8); + LCD_CmdWrite(0x72); + LCD_DataWrite(HY); + LCD_CmdWrite(0x73); + LCD_DataWrite(HY >> 8); +} + +void Square_Start_XY(unsigned short WX,unsigned short HY) +{ + /* + [68h] Draw Line/Square/Triangle Start X-coordination [7:0] + [69h] Draw Line/Square/Triangle Start X-coordination [12:8] + [6Ah] Draw Line/Square/Triangle Start Y-coordination [7:0] + [6Bh] Draw Line/Square/Triangle Start Y-coordination [12:8] + */ + LCD_CmdWrite(0x68); + LCD_DataWrite(WX); + LCD_CmdWrite(0x69); + LCD_DataWrite(WX >> 8); + LCD_CmdWrite(0x6A); + LCD_DataWrite(HY); + LCD_CmdWrite(0x6B); + LCD_DataWrite(HY >> 8); +} + +void Square_End_XY(unsigned short WX,unsigned short HY) +{ + /* + [6Ch] Draw Line/Square/Triangle End X-coordination [7:0] + [6Dh] Draw Line/Square/Triangle End X-coordination [12:8] + [6Eh] Draw Line/Square/Triangle End Y-coordination [7:0] + [6Fh] Draw Line/Square/Triangle End Y-coordination [12:8] + */ + LCD_CmdWrite(0x6C); + LCD_DataWrite(WX); + LCD_CmdWrite(0x6D); + LCD_DataWrite(WX >> 8); + LCD_CmdWrite(0x6E); + LCD_DataWrite(HY); + LCD_CmdWrite(0x6F); + LCD_DataWrite(HY >> 8); +} +//[76h]========================================================================= +/* +[bit7] +Draw Circle / Ellipse / Square /Circle Square Start Signal +Write Function +0 : Stop the drawing function. +1 : Start the drawing function. +Read Function +0 : Drawing function complete. +1 : Drawing function is processing. +[bit6] +Fill the Circle / Ellipse / Square / Circle Square Signal +0 : Non fill. +1 : fill. +[bit5 bit4] +Draw Circle / Ellipse / Square / Ellipse Curve / Circle Square Select +00 : Draw Circle / Ellipse +01 : Draw Circle / Ellipse Curve +10 : Draw Square. +11 : Draw Circle Square. +[bit1 bit0] +Draw Circle / Ellipse Curve Part Select +00 : +01 : +10 : +11 : +*/ +void Start_Circle_or_Ellipse(void) +{ + LCD_CmdWrite(0x76); + LCD_DataWrite(0x80);//B1000_XXXX + Check_Busy_Draw(); +} +void Start_Circle_or_Ellipse_Fill(void) +{ + LCD_CmdWrite(0x76); + LCD_DataWrite(0xC0);//B1100_XXXX + Check_Busy_Draw(); +} +// +void Start_Left_Down_Curve(void) +{ + LCD_CmdWrite(0x76); + LCD_DataWrite(0x90);//B1001_XX00 + Check_Busy_Draw(); +} +void Start_Left_Up_Curve(void) +{ + LCD_CmdWrite(0x76); + LCD_DataWrite(0x91);//B1001_XX01 + Check_Busy_Draw(); +} +void Start_Right_Up_Curve(void) +{ + LCD_CmdWrite(0x76); + LCD_DataWrite(0x92);//B1001_XX10 + Check_Busy_Draw(); +} +void Start_Right_Down_Curve(void) +{ + LCD_CmdWrite(0x76); + LCD_DataWrite(0x93);//B1001_XX11 + Check_Busy_Draw(); +} +// +void Start_Left_Down_Curve_Fill(void) +{ + LCD_CmdWrite(0x76); + LCD_DataWrite(0xD0);//B1101_XX00 + Check_Busy_Draw(); +} +void Start_Left_Up_Curve_Fill(void) +{ + LCD_CmdWrite(0x76); + LCD_DataWrite(0xD1);//B1101_XX01 + Check_Busy_Draw(); +} +void Start_Right_Up_Curve_Fill(void) +{ + LCD_CmdWrite(0x76); + LCD_DataWrite(0xD2);//B1101_XX10 + Check_Busy_Draw(); +} +void Start_Right_Down_Curve_Fill(void) +{ + LCD_CmdWrite(0x76); + LCD_DataWrite(0xD3);//B1101_XX11 + Check_Busy_Draw(); +} +// +void Start_Square(void) +{ + LCD_CmdWrite(0x76); + LCD_DataWrite(0xA0);//B1010_XXXX + Check_Busy_Draw(); +} +void Start_Square_Fill(void) +{ + LCD_CmdWrite(0x76); + LCD_DataWrite(0xE0);//B1110_XXXX + Check_Busy_Draw(); +} +void Start_Circle_Square(void) +{ + LCD_CmdWrite(0x76); + LCD_DataWrite(0xB0);//B1011_XXXX + Check_Busy_Draw(); +} +void Start_Circle_Square_Fill(void) +{ + LCD_CmdWrite(0x76); + LCD_DataWrite(0xF0);//B1111_XXXX + Check_Busy_Draw(); +} +//[77h]~[7Eh]========================================================================= +void Circle_Center_XY(unsigned short WX,unsigned short HY) +{ + /* + [7Bh] Draw Circle/Ellipse/Circle Square Center X-coordination [7:0] + [7Ch] Draw Circle/Ellipse/Circle Square Center X-coordination [12:8] + [7Dh] Draw Circle/Ellipse/Circle Square Center Y-coordination [7:0] + [7Eh] Draw Circle/Ellipse/Circle Square Center Y-coordination [12:8] + */ + LCD_CmdWrite(0x7B); + LCD_DataWrite(WX); + LCD_CmdWrite(0x7C); + LCD_DataWrite(WX >> 8); + LCD_CmdWrite(0x7D); + LCD_DataWrite(HY); + LCD_CmdWrite(0x7E); + LCD_DataWrite(HY >> 8); +} + +void Ellipse_Center_XY(unsigned short WX,unsigned short HY) +{ + /* + [7Bh] Draw Circle/Ellipse/Circle Square Center X-coordination [7:0] + [7Ch] Draw Circle/Ellipse/Circle Square Center X-coordination [12:8] + [7Dh] Draw Circle/Ellipse/Circle Square Center Y-coordination [7:0] + [7Eh] Draw Circle/Ellipse/Circle Square Center Y-coordination [12:8] + */ + LCD_CmdWrite(0x7B); + LCD_DataWrite(WX); + LCD_CmdWrite(0x7C); + LCD_DataWrite(WX >> 8); + LCD_CmdWrite(0x7D); + LCD_DataWrite(HY); + LCD_CmdWrite(0x7E); + LCD_DataWrite(HY >> 8); +} + +void Circle_Radius_R(unsigned short WX) +{ + /* + [77h] Draw Circle/Ellipse/Circle Square Major radius [7:0] + [78h] Draw Circle/Ellipse/Circle Square Major radius [12:8] + [79h] Draw Circle/Ellipse/Circle Square Minor radius [7:0] + [7Ah] Draw Circle/Ellipse/Circle Square Minor radius [12:8] + */ + LCD_CmdWrite(0x77); + LCD_DataWrite(WX); + LCD_CmdWrite(0x78); + LCD_DataWrite(WX >> 8); + LCD_CmdWrite(0x79); + LCD_DataWrite(WX); + LCD_CmdWrite(0x7A); + LCD_DataWrite(WX >> 8); +} + +void Ellipse_Radius_RxRy(unsigned short WX,unsigned short HY) +{ + /* + [77h] Draw Circle/Ellipse/Circle Square Major radius [7:0] + [78h] Draw Circle/Ellipse/Circle Square Major radius [12:8] + [79h] Draw Circle/Ellipse/Circle Square Minor radius [7:0] + [7Ah] Draw Circle/Ellipse/Circle Square Minor radius [12:8] + */ + LCD_CmdWrite(0x77); + LCD_DataWrite(WX); + LCD_CmdWrite(0x78); + LCD_DataWrite(WX >> 8); + LCD_CmdWrite(0x79); + LCD_DataWrite(HY); + LCD_CmdWrite(0x7A); + LCD_DataWrite(HY >> 8); +} + +void Circle_Square_Radius_RxRy(unsigned short WX,unsigned short HY) +{ + /* + [77h] Draw Circle/Ellipse/Circle Square Major radius [7:0] + [78h] Draw Circle/Ellipse/Circle Square Major radius [12:8] + [79h] Draw Circle/Ellipse/Circle Square Minor radius [7:0] + [7Ah] Draw Circle/Ellipse/Circle Square Minor radius [12:8] + */ + LCD_CmdWrite(0x77); + LCD_DataWrite(WX); + LCD_CmdWrite(0x78); + LCD_DataWrite(WX >> 8); + LCD_CmdWrite(0x79); + LCD_DataWrite(HY); + LCD_CmdWrite(0x7A); + LCD_DataWrite(HY >> 8); +} + +//[84h]========================================================================= +void Set_PWM_Prescaler_1_to_256(unsigned short WX) +{ + /* + PWM Prescaler Register + These 8 bits determine prescaler value for Timer 0 and 1. + Time base is 'Core_Freq / (Prescaler + 1)' + */ + WX=WX-1; + LCD_CmdWrite(0x84); + LCD_DataWrite(WX); +} +//[85h]========================================================================= +void Select_PWM1_Clock_Divided_By_1(void) +{ + /* + Select MUX input for PWM Timer 1. + 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; + */ + uint8_t temp; + LCD_CmdWrite(0x85); + temp = LCD_DataRead(); + temp &= cClrb7; + temp &= cClrb6; + LCD_DataWrite(temp); +} +void Select_PWM1_Clock_Divided_By_2(void) +{ + /* + Select MUX input for PWM Timer 1. + 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; + */ + uint8_t temp; + LCD_CmdWrite(0x85); + temp = LCD_DataRead(); + temp &= cClrb7; + temp |= cSetb6; + LCD_DataWrite(temp); +} +void Select_PWM1_Clock_Divided_By_4(void) +{ + /* + Select MUX input for PWM Timer 1. + 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; + */ + uint8_t temp; + LCD_CmdWrite(0x85); + temp = LCD_DataRead(); + temp |= cSetb7; + temp &= cClrb6; + LCD_DataWrite(temp); +} +void Select_PWM1_Clock_Divided_By_8(void) +{ + /* + Select MUX input for PWM Timer 1. + 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; + */ + uint8_t temp; + LCD_CmdWrite(0x85); + temp = LCD_DataRead(); + temp |= cSetb7; + temp |= cSetb6; + LCD_DataWrite(temp); +} +void Select_PWM0_Clock_Divided_By_1(void) +{ + /* + Select MUX input for PWM Timer 0. + 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; + */ + uint8_t temp; + LCD_CmdWrite(0x85); + temp = LCD_DataRead(); + temp &= cClrb5; + temp &= cClrb4; + LCD_DataWrite(temp); +} +void Select_PWM0_Clock_Divided_By_2(void) +{ + /* + Select MUX input for PWM Timer 0. + 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; + */ + uint8_t temp; + LCD_CmdWrite(0x85); + temp = LCD_DataRead(); + temp &= cClrb5; + temp |= cSetb4; + LCD_DataWrite(temp); +} +void Select_PWM0_Clock_Divided_By_4(void) +{ + /* + Select MUX input for PWM Timer 0. + 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; + */ + uint8_t temp; + LCD_CmdWrite(0x85); + temp = LCD_DataRead(); + temp |= cSetb5; + temp &= cClrb4; + LCD_DataWrite(temp); +} +void Select_PWM0_Clock_Divided_By_8(void) +{ + /* + Select MUX input for PWM Timer 0. + 00 = 1; 01 = 1/2; 10 = 1/4 ; 11 = 1/8; + */ + uint8_t temp; + LCD_CmdWrite(0x85); + temp = LCD_DataRead(); + temp |= cSetb5; + temp |= cSetb4; + LCD_DataWrite(temp); +} +//[85h].[bit3][bit2]========================================================================= +/* +XPWM[1] pin function control +0X: XPWM[1] output system error flag (REG[00h] bit[1:0], Scan bandwidth insufficient + Memory access out of range) +10: XPWM[1] enabled and controlled by PWM timer 1 +11: XPWM[1] output oscillator clock +//If XTEST[0] set high, then XPWM[1] will become panel scan clock input. +*/ +void Select_PWM1_is_ErrorFlag(void) +{ + uint8_t temp; + LCD_CmdWrite(0x85); + temp = LCD_DataRead(); + temp &= cClrb3; + LCD_DataWrite(temp); +} +void Select_PWM1(void) +{ + uint8_t temp; + LCD_CmdWrite(0x85); + temp = LCD_DataRead(); + temp |= cSetb3; + temp &= cClrb2; + LCD_DataWrite(temp); +} +void Select_PWM1_is_Osc_Clock(void) +{ + uint8_t temp; + LCD_CmdWrite(0x85); + temp = LCD_DataRead(); + temp |= cSetb3; + temp |= cSetb2; + LCD_DataWrite(temp); +} +//[85h].[bit1][bit0]========================================================================= +/* +XPWM[0] pin function control +0X: XPWM[0] becomes GPIO-C[7] +10: XPWM[0] enabled and controlled by PWM timer 0 +11: XPWM[0] output core clock +*/ +void Select_PWM0_is_GPIO_C7(void) +{ + uint8_t temp; + LCD_CmdWrite(0x85); + temp = LCD_DataRead(); + temp &= cClrb1; + LCD_DataWrite(temp); +} +void Select_PWM0(void) +{ + uint8_t temp; + LCD_CmdWrite(0x85); + temp = LCD_DataRead(); + temp |= cSetb1; + temp &= cClrb0; + LCD_DataWrite(temp); +} +void Select_PWM0_is_Core_Clock(void) +{ + uint8_t temp; + LCD_CmdWrite(0x85); + temp = LCD_DataRead(); + temp |= cSetb1; + temp |= cSetb0; + LCD_DataWrite(temp); +} +//[86h]========================================================================= +//[86h]PWM1 +void Enable_PWM1_Inverter(void) +{ + /* + PWM Timer 1 output inverter on/off. + Determine the output inverter on/off for Timer 1. + 0 = Inverter off + 1 = Inverter on for PWM1 + */ + uint8_t temp; + LCD_CmdWrite(0x86); + temp = LCD_DataRead(); + temp |= cSetb6; + LCD_DataWrite(temp); +} +void Disable_PWM1_Inverter(void) +{ + /* + PWM Timer 1 output inverter on/off. + Determine the output inverter on/off for Timer 1. + 0 = Inverter off + 1 = Inverter on for PWM1 + */ + uint8_t temp; + LCD_CmdWrite(0x86); + temp = LCD_DataRead(); + temp &= cClrb6; + LCD_DataWrite(temp); +} +void Auto_Reload_PWM1(void) +{ + /* + PWM Timer 1 auto reload on/off + Determine auto reload on/off for Timer 1. + 0 = One-shot + 1 = Interval mode(auto reload) + */ + uint8_t temp; + LCD_CmdWrite(0x86); + temp = LCD_DataRead(); + temp |= cSetb5; + LCD_DataWrite(temp); +} +void One_Shot_PWM1(void) +{ + /* + PWM Timer 1 auto reload on/off + Determine auto reload on/off for Timer 1. + 0 = One-shot + 1 = Interval mode(auto reload) + */ + uint8_t temp; + LCD_CmdWrite(0x86); + temp = LCD_DataRead(); + temp &= cClrb5; + LCD_DataWrite(temp); +} +void Start_PWM1(void) +{ + /* + PWM Timer 1 start/stop + Determine start/stop for Timer 1. + 0 = Stop + 1 = Start for Timer 1 + */ + uint8_t temp; + LCD_CmdWrite(0x86); + temp = LCD_DataRead(); + temp |= cSetb4; + LCD_DataWrite(temp); +} +void Stop_PWM1(void) +{ + /* + PWM Timer 1 start/stop + Determine start/stop for Timer 1. + 0 = Stop + 1 = Start for Timer 1 + */ + uint8_t temp; + LCD_CmdWrite(0x86); + temp = LCD_DataRead(); + temp &= cClrb4; + LCD_DataWrite(temp); +} +//[86h]PWM0 +void Enable_PWM0_Dead_Zone(void) +{ + /* + PWM Timer 0 Dead zone enable + Determine the dead zone operation. 0 = Disable. 1 = Enable. + */ + uint8_t temp; + LCD_CmdWrite(0x86); + temp = LCD_DataRead(); + temp |= cSetb3; + LCD_DataWrite(temp); +} +void Disable_PWM0_Dead_Zone(void) +{ + /* + PWM Timer 0 Dead zone enable + Determine the dead zone operation. 0 = Disable. 1 = Enable. + */ + uint8_t temp; + LCD_CmdWrite(0x86); + temp = LCD_DataRead(); + temp &= cClrb3; + LCD_DataWrite(temp); +} +void Enable_PWM0_Inverter(void) +{ + /* + PWM Timer 0 output inverter on/off + Determine the output inverter on/off for Timer 0. + 0 = Inverter off + 1 = Inverter on for PWM0 + */ + uint8_t temp; + LCD_CmdWrite(0x86); + temp = LCD_DataRead(); + temp |= cSetb2; + LCD_DataWrite(temp); +} +void Disable_PWM0_Inverter(void) +{ + /* + PWM Timer 0 output inverter on/off + Determine the output inverter on/off for Timer 0. + 0 = Inverter off + 1 = Inverter on for PWM0 + */ + uint8_t temp; + LCD_CmdWrite(0x86); + temp = LCD_DataRead(); + temp &= cClrb2; + LCD_DataWrite(temp); +} +void Auto_Reload_PWM0(void) +{ + /* + PWM Timer 0 auto reload on/off + Determine auto reload on/off for Timer 0. + 0 = One-shot + 1 = Interval mode(auto reload) + */ + uint8_t temp; + LCD_CmdWrite(0x86); + temp = LCD_DataRead(); + temp |= cSetb1; + LCD_DataWrite(temp); +} +void One_Shot_PWM0(void) +{ + /* + PWM Timer 1 auto reload on/off + Determine auto reload on/off for Timer 1. + 0 = One-shot + 1 = Interval mode(auto reload) + */ + uint8_t temp; + LCD_CmdWrite(0x86); + temp = LCD_DataRead(); + temp &= cClrb1; + LCD_DataWrite(temp); +} +void Start_PWM0(void) +{ + /* + PWM Timer 0 start/stop + Determine start/stop for Timer 0. + 0 = Stop + 1 = Start for Timer 0 + */ + uint8_t temp; + LCD_CmdWrite(0x86); + temp = LCD_DataRead(); + temp |= cSetb0; + LCD_DataWrite(temp); +} +void Stop_PWM0(void) +{ + /* + PWM Timer 0 start/stop + Determine start/stop for Timer 0. + 0 = Stop + 1 = Start for Timer 0 + */ + uint8_t temp; + LCD_CmdWrite(0x86); + temp = LCD_DataRead(); + temp &= cClrb0; + LCD_DataWrite(temp); +} +//[87h]========================================================================= +void Set_Timer0_Dead_Zone_Length(uint8_t temp) +{ + /* + Timer 0 Dead zone length register + These 8 bits determine the dead zone length. The 1 unit time of + the dead zone length is equal to that of timer 0. + */ + LCD_CmdWrite(0x87); + LCD_DataWrite(temp); +} +//[88h][89h]========================================================================= +void Set_Timer0_Compare_Buffer(unsigned short WX) +{ + /* + Timer 0 compare buffer register + Compare buffer register total has 16 bits. + When timer counter equal or less than compare buffer register will cause PWM out + high level if inv_on bit is off. + */ + LCD_CmdWrite(0x88); + LCD_DataWrite(WX); + LCD_CmdWrite(0x89); + LCD_DataWrite(WX >> 8); +} +//[8Ah][8Bh]========================================================================= +void Set_Timer0_Count_Buffer(unsigned short WX) +{ + /* + Timer 0 count buffer register + Count buffer register total has 16 bits. + When timer counter equal to 0 will cause PWM timer reload Count buffer register if reload_en bit set as enable. + It may read back timer counter's real time value when PWM timer start. + */ + LCD_CmdWrite(0x8A); + LCD_DataWrite(WX); + LCD_CmdWrite(0x8B); + LCD_DataWrite(WX >> 8); +} +//[8Ch][8Dh]========================================================================= +void Set_Timer1_Compare_Buffer(unsigned short WX) +{ + /* + Timer 0 compare buffer register + Compare buffer register total has 16 bits. + When timer counter equal or less than compare buffer register will cause PWM out + high level if inv_on bit is off. + */ + LCD_CmdWrite(0x8C); + LCD_DataWrite(WX); + LCD_CmdWrite(0x8D); + LCD_DataWrite(WX >> 8); +} +//[8Eh][8Fh]========================================================================= +void Set_Timer1_Count_Buffer(unsigned short WX) +{ + /* + Timer 0 count buffer register + Count buffer register total has 16 bits. + When timer counter equal to 0 will cause PWM timer reload Count buffer register if reload_en bit set as enable. + It may read back timer counter's real time value when PWM timer start. + */ + LCD_CmdWrite(0x8E); + LCD_DataWrite(WX); + LCD_CmdWrite(0x8F); + LCD_DataWrite(WX >> 8); +} + + +//[90h]~[B5h]========================================================================= + +//[90h]========================================================================= +void BTE_Enable(void) +{ + /* + BTE Function Enable + 0 : BTE Function disable. + 1 : BTE Function enable. + */ + uint8_t temp; + LCD_CmdWrite(0x90); + temp = LCD_DataRead(); + temp |= cSetb4 ; + LCD_DataWrite(temp); +} + +//[90h]========================================================================= +void BTE_Disable(void) +{ + /* + BTE Function Enable + 0 : BTE Function disable. + 1 : BTE Function enable. + */ + uint8_t temp; + LCD_CmdWrite(0x90); + temp = LCD_DataRead(); + temp &= cClrb4 ; + LCD_DataWrite(temp); +} + +//[90h]========================================================================= +void Check_BTE_Busy(void) +{ + /* + BTE Function Status + 0 : BTE Function is idle. + 1 : BTE Function is busy. + */ + uint8_t temp; + + do + { + temp = LCD_StatusRead(); + } + while(temp&0x08); +} +//[90h]========================================================================= +void Pattern_Format_8X8(void) +{ + /* + Pattern Format + 0 : 8X8 + 1 : 16X16 + */ + uint8_t temp; + LCD_CmdWrite(0x90); + temp = LCD_DataRead(); + temp &= cClrb0 ; + LCD_DataWrite(temp); +} +//[90h]========================================================================= +void Pattern_Format_16X16(void) +{ + /* + Pattern Format + 0 : 8X8 + 1 : 16X16 + */ + uint8_t temp; + LCD_CmdWrite(0x90); + temp = LCD_DataRead(); + temp |= cSetb0 ; + LCD_DataWrite(temp); +} + +//[91h]========================================================================= +void BTE_ROP_Code(uint8_t setx) +{ + /* + BTE ROP Code[Bit7:4] + + 0000 : 0(Blackness) + 0001 : ~S0.~S1 or ~ ( S0+S1 ) + 0010 : ~S0.S1 + 0011 : ~S0 + 0100 : S0.~S1 + 0101 : ~S1 + 0110 : S0^S1 + 0111 : ~S0+~S1 or ~ ( S0.S1 ) + 1000 : S0.S1 + 1001 : ~ ( S0^S1 ) + 1010 : S1 + 1011 : ~S0+S1 + 1100 : S0 + 1101 : S0+~S1 + 1110 : S0+S1 + 1111 : 1 ( Whiteness ) + */ + uint8_t temp; + LCD_CmdWrite(0x91); + temp = LCD_DataRead(); + temp &= 0x0f ; + temp |= (setx<<4); + LCD_DataWrite(temp); +} + +//[91h]========================================================================= +void BTE_Operation_Code(uint8_t setx) +{ + /* + BTE Operation Code[Bit3:0] + + 0000 : MPU Write BTE with ROP. + 0001 : MPU Read BTE w/o ROP. + 0010 : Memory copy (move) BTE in positive direction with ROP. + 0011 : Memory copy (move) BTE in negative direction with ROP. + 0100 : MPU Transparent Write BTE. (w/o ROP.) + 0101 : Transparent Memory copy (move) BTE in positive direction (w/o ROP.) + 0110 : Pattern Fill with ROP. + 0111 : Pattern Fill with key-chroma + 1000 : Color Expansion + 1001 : Color Expansion with transparency + 1010 : Move BTE in positive direction with Alpha blending + 1011 : MPU Write BTE with Alpha blending + 1100 : Solid Fill + 1101 : Reserved + 1110 : Reserved + 1111 : Reserved + */ + uint8_t temp; + LCD_CmdWrite(0x91); + temp = LCD_DataRead(); + temp &= 0xf0 ; + temp |= setx ; + LCD_DataWrite(temp); +} +//[92h]========================================================================= +void BTE_S0_Color_8bpp(void) +{ + /* + S0 Color Depth + 00 : 256 Color + 01 : 64k Color + 1x : 16M Color + */ + uint8_t temp; + LCD_CmdWrite(0x92); + temp = LCD_DataRead(); + temp &= cClrb6 ; + temp &= cClrb5 ; + LCD_DataWrite(temp); +} +//[92h]========================================================================= +void BTE_S0_Color_16bpp(void) +{ + /* + S0 Color Depth + 00 : 256 Color + 01 : 64k Color + 1x : 16M Color + */ + uint8_t temp; + LCD_CmdWrite(0x92); + temp = LCD_DataRead(); + temp &= cClrb6 ; + temp |= cSetb5 ; + LCD_DataWrite(temp); +} +//[92h]========================================================================= +void BTE_S0_Color_24bpp(void) +{ + /* + S0 Color Depth + 00 : 256 Color + 01 : 64k Color + 1x : 16M Color + */ + uint8_t temp; + LCD_CmdWrite(0x92); + temp = LCD_DataRead(); + temp |= cSetb6 ; + //temp |= cSetb5 ; + LCD_DataWrite(temp); +} +//[92h]========================================================================= +void BTE_S1_Color_8bpp(void) +{ + /* + S1 Color Depth + 000 : 256 Color + 001 : 64k Color + 010 : 16M Color + 011 : Constant Color + 100 : 8 bit pixel alpha blending + 101 : 16 bit pixel alpha blending + */ + uint8_t temp; + LCD_CmdWrite(0x92); + temp = LCD_DataRead(); + temp &= cClrb4 ; + temp &= cClrb3 ; + temp &= cClrb2 ; + LCD_DataWrite(temp); +} +//[92h]========================================================================= +void BTE_S1_Color_16bpp(void) +{ + /* + S1 Color Depth + 000 : 256 Color + 001 : 64k Color + 010 : 16M Color + 011 : Constant Color + 100 : 8 bit pixel alpha blending + 101 : 16 bit pixel alpha blending + */ + uint8_t temp; + LCD_CmdWrite(0x92); + temp = LCD_DataRead(); + temp &= cClrb4 ; + temp &= cClrb3 ; + temp |= cSetb2 ; + LCD_DataWrite(temp); +} +//[92h]========================================================================= +void BTE_S1_Color_24bpp(void) +{ + /* + S1 Color Depth + 000 : 256 Color + 001 : 64k Color + 010 : 16M Color + 011 : Constant Color + 100 : 8 bit pixel alpha blending + 101 : 16 bit pixel alpha blending + */ + uint8_t temp; + LCD_CmdWrite(0x92); + temp = LCD_DataRead(); + temp &= cClrb4 ; + temp |= cSetb3 ; + temp &= cClrb2 ; + LCD_DataWrite(temp); +} + +//[92h]========================================================================= +void BTE_S1_Color_Constant(void) +{ + /* + S1 Color Depth + 000 : 256 Color + 001 : 64k Color + 010 : 16M Color + 011 : Constant Color + 100 : 8 bit pixel alpha blending + 101 : 16 bit pixel alpha blending + */ + uint8_t temp; + LCD_CmdWrite(0x92); + temp = LCD_DataRead(); + temp &= cClrb4 ; + temp |= cSetb3 ; + temp |= cSetb2 ; + LCD_DataWrite(temp); +} + + + +//[92h]========================================================================= +void BTE_S1_Color_8bit_Alpha(void) +{ + /* + S1 Color Depth + 000 : 256 Color + 001 : 64k Color + 010 : 16M Color + 011 : Constant Color + 100 : 8 bit pixel alpha blending + 101 : 16 bit pixel alpha blending + */ + uint8_t temp; + LCD_CmdWrite(0x92); + temp = LCD_DataRead(); + temp |= cSetb4 ; + temp &= cClrb3 ; + temp &= cClrb2 ; + LCD_DataWrite(temp); +} + +//[92h]========================================================================= +void BTE_S1_Color_16bit_Alpha(void) +{ + /* + S1 Color Depth + 000 : 256 Color + 001 : 64k Color + 010 : 16M Color + 011 : Constant Color + 100 : 8 bit pixel alpha blending + 101 : 16 bit pixel alpha blending + */ + uint8_t temp; + LCD_CmdWrite(0x92); + temp = LCD_DataRead(); + temp |= cSetb4 ; + temp &= cClrb3 ; + temp |= cSetb2 ; + LCD_DataWrite(temp); +} + +//[92h]========================================================================= +void BTE_Destination_Color_8bpp(void) +{ + /* + Destination Color Depth + 00 : 256 Color + 01 : 64k Color + 1x : 16M Color + */ + uint8_t temp; + LCD_CmdWrite(0x92); + temp = LCD_DataRead(); + temp &= cClrb1 ; + temp &= cClrb0 ; + LCD_DataWrite(temp); +} +//[92h]========================================================================= +void BTE_Destination_Color_16bpp(void) +{ + /* + Destination Color Depth + 00 : 256 Color + 01 : 64k Color + 1x : 16M Color + */ + uint8_t temp; + LCD_CmdWrite(0x92); + temp = LCD_DataRead(); + temp &= cClrb1 ; + temp |= cSetb0 ; + LCD_DataWrite(temp); +} +//[92h]========================================================================= +void BTE_Destination_Color_24bpp(void) +{ + /* + Destination Color Depth + 00 : 256 Color + 10 : 64k Color + 1x : 16M Color + */ + uint8_t temp; + LCD_CmdWrite(0x92); + temp = LCD_DataRead(); + temp |= cSetb1 ; + //temp |= cSetb0 ; + LCD_DataWrite(temp); +} + + +//[93h][94h][95h][96h]========================================================================= +void BTE_S0_Memory_Start_Address(uint32_t Addr) +{ + /* + [93h] BTE S0 Memory Start Address [7:0] + [94h] BTE S0 Memory Start Address [15:8] + [95h] BTE S0 Memory Start Address [23:16] + [96h] BTE S0 Memory Start Address [31:24] + Bit [1:0] tie to '0' internally. + */ + LCD_RegisterWrite(0x93,Addr); + LCD_RegisterWrite(0x94,Addr >> 8); + LCD_RegisterWrite(0x95,Addr >> 16); + LCD_RegisterWrite(0x96,Addr >> 24); +} + + +//[97h][98h]========================================================================= +void BTE_S0_Image_Width(unsigned short WX) +{ + /* + [97h] BTE S0 Image Width [7:0] + [98h] BTE S0 Image Width [12:8] + Unit: Pixel. + Bit [1:0] tie to '0' internally. + */ + LCD_RegisterWrite(0x97,WX); + LCD_RegisterWrite(0x98,WX >> 8); +} + + +//[99h][9Ah][9Bh][9Ch]========================================================================= +void BTE_S0_Window_Start_XY(unsigned short WX,unsigned short HY) +{ + /* + [99h] BTE S0 Window Upper-Left corner X-coordination [7:0] + [9Ah] BTE S0 Window Upper-Left corner X-coordination [12:8] + [9Bh] BTE S0 Window Upper-Left corner Y-coordination [7:0] + [9Ch] BTE S0 Window Upper-Left corner Y-coordination [12:8] + */ + LCD_RegisterWrite(0x99,WX); + LCD_RegisterWrite(0x9A,WX >> 8); + LCD_RegisterWrite(0x9B,HY); + LCD_RegisterWrite(0x9C,HY >> 8); +} + + + + +//[9Dh][9Eh][9Fh][A0h]========================================================================= +void BTE_S1_Memory_Start_Address(uint32_t Addr) +{ + /* + [9Dh] BTE S1 Memory Start Address [7:0] + [9Eh] BTE S1 Memory Start Address [15:8] + [9Fh] BTE S1 Memory Start Address [23:16] + [A0h] BTE S1 Memory Start Address [31:24] + Bit [1:0] tie to '0' internally. + */ + LCD_RegisterWrite(0x9D,Addr); + LCD_RegisterWrite(0x9E,Addr >> 8); + LCD_RegisterWrite(0x9F,Addr >> 16); + LCD_RegisterWrite(0xA0,Addr >> 24); +} + + +//Input data format:R3G3B2 +void S1_Constant_color_256(uint8_t temp) +{ + LCD_CmdWrite(0x9D); + LCD_DataWrite(temp); + LCD_CmdWrite(0x9E); + LCD_DataWrite(temp<<3); + LCD_CmdWrite(0x9F); + LCD_DataWrite(temp<<6); +} + +//Input data format:R5G6B6 +void S1_Constant_color_65k(unsigned short temp) +{ + LCD_CmdWrite(0x9D); + LCD_DataWrite(temp >> 8); + LCD_CmdWrite(0x9E); + LCD_DataWrite(temp >> 3); + LCD_CmdWrite(0x9F); + LCD_DataWrite(temp<<3); +} + +//Input data format:R8G8B8 +void S1_Constant_color_16M(uint32_t temp) +{ + LCD_CmdWrite(0x9D); + LCD_DataWrite(temp >> 16); + LCD_CmdWrite(0x9E); + LCD_DataWrite(temp >> 8); + LCD_CmdWrite(0x9F); + LCD_DataWrite(temp); +} + + + + +//[A1h][A2h]========================================================================= +void BTE_S1_Image_Width(unsigned short WX) +{ + /* + [A1h] BTE S1 Image Width [7:0] + [A2h] BTE S1 Image Width [12:8] + Unit: Pixel. + Bit [1:0] tie to '0' internally. + */ + LCD_RegisterWrite(0xA1,WX); + LCD_RegisterWrite(0xA2,WX >> 8); +} + + +//[A3h][A4h][A5h][A6h]========================================================================= +void BTE_S1_Window_Start_XY(unsigned short WX,unsigned short HY) +{ + /* + [A3h] BTE S1 Window Upper-Left corner X-coordination [7:0] + [A4h] BTE S1 Window Upper-Left corner X-coordination [12:8] + [A5h] BTE S1 Window Upper-Left corner Y-coordination [7:0] + [A6h] BTE S1 Window Upper-Left corner Y-coordination [12:8] + */ + LCD_RegisterWrite(0xA3,WX); + LCD_RegisterWrite(0xA4,WX >> 8); + LCD_RegisterWrite(0xA5,HY); + LCD_RegisterWrite(0xA6,HY >> 8); +} + + + + +//[A7h][A8h][A9h][AAh]========================================================================= +void BTE_Destination_Memory_Start_Address(uint32_t Addr) +{ + /* + [A7h] BTE Destination Memory Start Address [7:0] + [A8h] BTE Destination Memory Start Address [15:8] + [A9h] BTE Destination Memory Start Address [23:16] + [AAh] BTE Destination Memory Start Address [31:24] + Bit [1:0] tie to '0' internally. + */ + LCD_RegisterWrite(0xA7,Addr); + LCD_RegisterWrite(0xA8,Addr >> 8); + LCD_RegisterWrite(0xA9,Addr >> 16); + LCD_RegisterWrite(0xAA,Addr >> 24); +} + + +//[ABh][ACh]========================================================================= +void BTE_Destination_Image_Width(unsigned short WX) +{ + /* + [ABh] BTE Destination Image Width [7:0] + [ACh] BTE Destination Image Width [12:8] + Unit: Pixel. + Bit [1:0] tie to '0' internally. + */ + LCD_RegisterWrite(0xAB,WX); + LCD_RegisterWrite(0xAC,WX >> 8); +} + + +//[ADh][AEh][AFh][B0h]========================================================================= +void BTE_Destination_Window_Start_XY(unsigned short WX,unsigned short HY) +{ + /* + [ADh] BTE Destination Window Upper-Left corner X-coordination [7:0] + [AEh] BTE Destination Window Upper-Left corner X-coordination [12:8] + [AFh] BTE Destination Window Upper-Left corner Y-coordination [7:0] + [B0h] BTE Destination Window Upper-Left corner Y-coordination [12:8] + */ + LCD_RegisterWrite(0xAD,WX); + LCD_RegisterWrite(0xAE,WX >> 8); + LCD_RegisterWrite(0xAF,HY); + LCD_RegisterWrite(0xB0,HY >> 8); +} + + +//[B1h][B2h][B3h][B4h]=============================================================== + +void BTE_Window_Size(unsigned short WX, unsigned short WY) + +{ + /* + [B1h] BTE Window Width [7:0] + [B2h] BTE Window Width [12:8] + + [B3h] BTE Window Height [7:0] + [B4h] BTE Window Height [12:8] + */ + LCD_RegisterWrite(0xB1,WX); + LCD_RegisterWrite(0xB2,WX >> 8); + LCD_RegisterWrite(0xB3,WY); + LCD_RegisterWrite(0xB4,WY >> 8); +} + +//[B5h]========================================================================= +void BTE_Alpha_Blending_Effect(uint8_t temp) +{ + /* + Window Alpha Blending effect for S0 & S1 + The value of alpha in the color code ranges from 0.0 to 1.0, + where 0.0 represents a fully transparent color, and 1.0 + represents a fully opaque color. + 00h: 0 + 01h: 1/32 + 02h: 2/32 + : + 1Eh: 30/32 + 1Fh: 31/32 + 2Xh: 1 + Output Effect = (S0 image x (1 - alpha setting value)) + (S1 image x alpha setting value) + */ + LCD_CmdWrite(0xB5); + LCD_DataWrite(temp); +} + + +//[B6h]========================================================================= +void Start_SFI_DMA(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB6); + temp = LCD_DataRead(); + temp |= cSetb0; + LCD_DataWrite(temp); +} + +void Check_Busy_SFI_DMA(void) +{ + LCD_CmdWrite(0xB6); + + do + { + } + while((LCD_DataRead()&0x01)==0x01); +} + + +//[B7h]========================================================================= +void Select_SFI_0(void) +{ + /*[bit7] + Serial Flash/ROM I/F # Select + 0: Serial Flash/ROM 0 I/F is selected. + 1: Serial Flash/ROM 1 I/F is selected. + */ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp &= cClrb7; + LCD_DataWrite(temp); +} +void Select_SFI_1(void) +{ + /*[bit7] + Serial Flash/ROM I/F # Select + 0: Serial Flash/ROM 0 I/F is selected. + 1: Serial Flash/ROM 1 I/F is selected. + */ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp |= cSetb7; + LCD_DataWrite(temp); +} +void Select_SFI_Font_Mode(void) +{ + /*[bit6] + Serial Flash /ROM Access Mode + 0: Font mode ? for external cgrom + 1: DMA mode ? for cgram , pattern , bootstart image or osd + */ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp &= cClrb6; + LCD_DataWrite(temp); +} +void Select_SFI_DMA_Mode(void) +{ + /*[bit6] + Serial Flash /ROM Access Mode + 0: Font mode ? for external cgrom + 1: DMA mode ? for cgram , pattern , bootstart image or osd + */ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp |= cSetb6; + LCD_DataWrite(temp); +} +void Select_SFI_24bit_Address(void) +{ + /*[bit5] + Serial Flash/ROM Address Mode + 0: 24 bits address mode + 1: 32 bits address mode + */ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp &= cClrb5; + LCD_DataWrite(temp); +} +void Select_SFI_32bit_Address(void) +{ + /*[bit5] + Serial Flash/ROM Address Mode + 0: 24 bits address mode + 1: 32 bits address mode + */ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp |= cSetb5; + LCD_DataWrite(temp); +} +void Select_SFI_Waveform_Mode_0(void) +{ + /*[bit4] + Serial Flash/ROM Waveform Mode + Mode 0. + Mode 3. + */ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp &= cClrb4; + LCD_DataWrite(temp); +} +void Select_SFI_Waveform_Mode_3(void) +{ + /*[bit4] + Serial Flash/ROM Waveform Mode + Mode 0. + Mode 3. + */ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp |= cSetb4; + LCD_DataWrite(temp); +} +void Select_SFI_0_DummyRead(void) +{ + /*[bit3][bit2] + Serial Flash /ROM Read Cycle 0 RW + 00b: no dummy cycle mode + 01b: 1 dummy cycle mode + 10b: 2 dummy cycle mode + 11b: 4 dummy cycle mode + */ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp &= 0xF3; + LCD_DataWrite(temp); +} +void Select_SFI_8_DummyRead(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp &= 0xF3; + temp |= cSetb2; + LCD_DataWrite(temp); +} +void Select_SFI_16_DummyRead(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp &= 0xF3; + temp |= cSetb3; + LCD_DataWrite(temp); +} +void Select_SFI_24_DummyRead(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp |= 0x0c; + LCD_DataWrite(temp); +} +void Select_SFI_Single_Mode(void) +{ + /*[bit1][bit0] + Serial Flash /ROM I/F Data Latch Mode Select + 0Xb: Single Mode + 10b: Dual Mode 0. + 11b: Dual Mode 1. + */ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp &= 0xFC; + LCD_DataWrite(temp); +} +void Select_SFI_Dual_Mode0(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp &= 0xFC; + temp |= cSetb1; + LCD_DataWrite(temp); +} +void Select_SFI_Dual_Mode1(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB7); + temp = LCD_DataRead(); + temp |= 0x03; + LCD_DataWrite(temp); +} + +//REG[B8h] SPI master Tx /Rx FIFO Data Register (SPIDR) +uint8_t SPI_Master_FIFO_Data_Put(uint8_t Data) +{ + uint8_t temp; + LCD_CmdWrite(0xB8); + LCD_DataWrite(Data); + + while(Tx_FIFO_Empty_Flag()==0); + + temp = SPI_Master_FIFO_Data_Get(); + return temp; +} + +uint8_t SPI_Master_FIFO_Data_Get(void) +{ + uint8_t temp; + + while(Rx_FIFO_Empty_Flag()==1); + + LCD_CmdWrite(0xB8); + temp = LCD_DataRead(); + //while(Rx_FIFO_full_flag()); + return temp; +} + +//REG[B9h] SPI master Control Register (SPIMCR2) +void Mask_SPI_Master_Interrupt_Flag(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB9); + temp = LCD_DataRead(); + temp |= cSetb6; + LCD_DataWrite(temp); +} + +void Select_nSS_drive_on_xnsfcs0(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB9); + temp = LCD_DataRead(); + temp &= cClrb5; + LCD_DataWrite(temp); +} + +void Select_nSS_drive_on_xnsfcs1(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB9); + temp = LCD_DataRead(); + temp |= cSetb5; + LCD_DataWrite(temp); +} + +//0: inactive (nSS port will goes high) +void nSS_Inactive(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB9); + temp = LCD_DataRead(); + temp &= cClrb4; + LCD_DataWrite(temp); +} +//1: active (nSS port will goes low) +void nSS_Active(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB9); + temp = LCD_DataRead(); + temp |= cSetb4; + LCD_DataWrite(temp); +} + +//Interrupt enable for FIFO overflow error [OVFIRQEN] +void OVFIRQEN_Enable(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB9); + temp = LCD_DataRead(); + temp |= cSetb3; + LCD_DataWrite(temp); +} +//Interrupt enable for while Tx FIFO empty & SPI engine/FSM idle +void EMTIRQEN_Enable(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB9); + temp = LCD_DataRead(); + temp |= cSetb2; + LCD_DataWrite(temp); +} + + +//At CPOL=0 the base value of the clock is zero +//o For CPHA=0, data are read on the clock's rising edge (low->high transition) and +//data are changed on a falling edge (high->low clock transition). +//o For CPHA=1, data are read on the clock's falling edge and data are changed on a +//rising edge. + +//At CPOL=1 the base value of the clock is one (inversion of CPOL=0) +//o For CPHA=0, data are read on clock's falling edge and data are changed on a +//rising edge. +//o For CPHA=1, data are read on clock's rising edge and data are changed on a +//falling edge. + +void Reset_CPOL(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB9); + temp = LCD_DataRead(); + temp &= cClrb1; + LCD_DataWrite(temp); +} + +void Set_CPOL(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB9); + temp = LCD_DataRead(); + temp |= cSetb1; + LCD_DataWrite(temp); +} + + +void Reset_CPHA(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB9); + temp = LCD_DataRead(); + temp &= cClrb0; + LCD_DataWrite(temp); +} + +void Set_CPHA(void) +{ + uint8_t temp; + LCD_CmdWrite(0xB9); + temp = LCD_DataRead(); + temp |= cSetb0; + LCD_DataWrite(temp); +} + + +//REG[BAh] SPI master Status Register (SPIMSR) +uint8_t Tx_FIFO_Empty_Flag(void) +{ + LCD_CmdWrite(0xBA); + + if((LCD_DataRead()&0x80)==0x80) + { + return 1; + } + else + { + return 0; + } +} + +uint8_t Tx_FIFO_Full_Flag(void) +{ + LCD_CmdWrite(0xBA); + + if((LCD_DataRead()&0x40)==0x40) + { + return 1; + } + else + { + return 0; + } +} + +uint8_t Rx_FIFO_Empty_Flag(void) +{ + LCD_CmdWrite(0xBA); + + if((LCD_DataRead()&0x20)==0x20) + { + return 1; + } + else + { + return 0; + } +} + +uint8_t Rx_FIFO_full_flag(void) +{ + LCD_CmdWrite(0xBA); + + if((LCD_DataRead()&0x10)==0x10) + { + return 1; + } + else + { + return 0; + } +} + +uint8_t OVFI_Flag(void) +{ + LCD_CmdWrite(0xBA); + + if((LCD_DataRead()&0x08)==0x08) + { + return 1; + } + else + { + return 0; + } +} + +void Clear_OVFI_Flag(void) +{ + uint8_t temp; + LCD_CmdWrite(0xBA); + temp = LCD_DataRead(); + temp |= cSetb3; + LCD_DataWrite(temp); +} + +uint8_t EMTI_Flag(void) +{ + LCD_CmdWrite(0xBA); + + if((LCD_DataRead()&0x04)==0x04) + { + return 1; + } + else + { + return 0; + } +} + +void Clear_EMTI_Flag(void) +{ + uint8_t temp; + LCD_CmdWrite(0xBA); + temp = LCD_DataRead(); + temp |= cSetb2; + LCD_DataWrite(temp); +} + + +//REG[BB] SPI Clock period (SPIDIV) +void SPI_Clock_Period(uint8_t temp) +{ + LCD_CmdWrite(0xBB); + LCD_DataWrite(temp); +} + +//[BCh][BDh][BEh][BFh]========================================================================= +void SFI_DMA_Source_Start_Address(uint32_t Addr) +{ + /* + DMA Source START ADDRESS + This bits index serial flash address [7:0][15:8][23:16][31:24] + */ + LCD_CmdWrite(0xBC); + LCD_DataWrite(Addr); + LCD_CmdWrite(0xBD); + LCD_DataWrite(Addr >> 8); + LCD_CmdWrite(0xBE); + LCD_DataWrite(Addr >> 16); + LCD_CmdWrite(0xBF); + LCD_DataWrite(Addr >> 24); +} +//[C0h][C1h][C2h][C3h]========================================================================= +void SFI_DMA_Destination_Start_Address(uint32_t Addr) +{ + /* + DMA Destination START ADDRESS + [1:0]Fix at 0 + This bits index SDRAM address [7:0][15:8][23:16][31:24] + */ + LCD_CmdWrite(0xC0); + LCD_DataWrite(Addr); + LCD_CmdWrite(0xC1); + LCD_DataWrite(Addr >> 8); + LCD_CmdWrite(0xC2); + LCD_DataWrite(Addr >> 16); + LCD_CmdWrite(0xC3); + LCD_DataWrite(Addr >> 24); +} +//[C0h][C1h][C2h][C3h]========================================================================= +void SFI_DMA_Destination_Upper_Left_Corner(unsigned short WX,unsigned short HY) +{ + /* + C0h + This register defines DMA Destination Window Upper-Left corner + X-coordination [7:0] on Canvas area. + When REG DMACR bit 1 = 1 (Block Mode) + This register defines Destination address [7:2] in SDRAM. + C1h + When REG DMACR bit 1 = 0 (Linear Mode) + This register defines DMA Destination Window Upper-Left corner + X-coordination [12:8] on Canvas area. + When REG DMACR bit 1 = 1 (Block Mode) + This register defines Destination address [15:8] in SDRAM. + C2h + When REG DMACR bit 1 = 0 (Linear Mode) + This register defines DMA Destination Window Upper-Left corner + Y-coordination [7:0] on Canvas area. + When REG DMACR bit 1 = 1 (Block Mode) + This register defines Destination address [23:16] in SDRAM. + C3h + When REG DMACR bit 1 = 0 (Linear Mode) + This register defines DMA Destination Window Upper-Left corner + Y-coordination [12:8] on Canvas area. + When REG DMACR bit 1 = 1 (Block Mode) + This register defines Destination address [31:24] in SDRAM. + */ + LCD_CmdWrite(0xC0); + LCD_DataWrite(WX); + LCD_CmdWrite(0xC1); + LCD_DataWrite(WX >> 8); + LCD_CmdWrite(0xC2); + LCD_DataWrite(HY); + LCD_CmdWrite(0xC3); + LCD_DataWrite(HY >> 8); +} + + + +//[C6h][C7h][C8h][C9h]========================================================================= +void SFI_DMA_Transfer_Number(uint32_t Addr) +{ + /* + Unit : Pixel + When REG DMACR bit 1 = 0 (Linear Mode) + DMA Transfer Number [7:0][15:8][23:16][31:24] + + When REG DMACR bit 1 = 1 (Block Mode) + DMA Block Width [7:0][15:8] + DMA Block HIGH[7:0][15:8] + */ + LCD_CmdWrite(0xC6); + LCD_DataWrite(Addr); + LCD_CmdWrite(0xC7); + LCD_DataWrite(Addr >> 8); + LCD_CmdWrite(0xC8); + LCD_DataWrite(Addr >> 16); + LCD_CmdWrite(0xC9); + LCD_DataWrite(Addr >> 24); +} +void SFI_DMA_Transfer_Width_Height(unsigned short WX,unsigned short HY) +{ + /* + When REG DMACR bit 1 = 0 (Linear Mode) + DMA Transfer Number [7:0][15:8][23:16][31:24] + + When REG DMACR bit 1 = 1 (Block Mode) + DMA Block Width [7:0][15:8] + DMA Block HIGH[7:0][15:8] + */ + LCD_CmdWrite(0xC6); + LCD_DataWrite(WX); + LCD_CmdWrite(0xC7); + LCD_DataWrite(WX >> 8); + LCD_CmdWrite(0xC8); + LCD_DataWrite(HY); + LCD_CmdWrite(0xC9); + LCD_DataWrite(HY >> 8); +} +//[CAh][CBh]========================================================================= +void SFI_DMA_Source_Width(unsigned short WX) +{ + /* + DMA Source Picture Width [7:0][12:8] + Unit: pixel + */ + LCD_CmdWrite(0xCA); + LCD_DataWrite(WX); + LCD_CmdWrite(0xCB); + LCD_DataWrite(WX >> 8); +} + +//[CCh]========================================================================= + +void Font_Select_UserDefine_Mode(void) +{ + /*[bit7-6] + User-defined Font /CGROM Font Selection Bit in Text Mode + 00 : Internal CGROM + 01 : Genitop serial flash + 10 : User-defined Font + */ + uint8_t temp; + LCD_CmdWrite(0xCC); + temp = LCD_DataRead(); + temp |= cSetb7; + temp &= cClrb6; + LCD_DataWrite(temp); +} +void CGROM_Select_Internal_CGROM(void) +{ + /*[bit7-6] + User-defined Font /CGROM Font Selection Bit in Text Mode + 00 : Internal CGROM + 01 : Genitop serial flash + 10 : User-defined Font + */ + uint8_t temp; + LCD_CmdWrite(0xCC); + temp = LCD_DataRead(); + temp &= cClrb7; + temp &= cClrb6; + LCD_DataWrite(temp); +} +void CGROM_Select_Genitop_FontROM(void) +{ + /*[bit7-6] + User-defined Font /CGROM Font Selection Bit in Text Mode + 00 : Internal CGROM + 01 : Genitop serial flash + 10 : User-defined Font + */ + uint8_t temp; + LCD_CmdWrite(0xCC); + temp = LCD_DataRead(); + temp &= cClrb7; + temp |= cSetb6; + LCD_DataWrite(temp); +} +void Font_Select_8x16_16x16(void) +{ + /*[bit5-4] + Font Height Setting + 00b : 8x16 / 16x16. + 01b : 12x24 / 24x24. + 10b : 16x32 / 32x32. + *** User-defined Font width is decided by font code. Genitop + serial flash's font width is decided by font code or GT Font ROM + control register. + */ + uint8_t temp; + LCD_CmdWrite(0xCC); + temp = LCD_DataRead(); + temp &= cClrb5; + temp &= cClrb4; + LCD_DataWrite(temp); +} +void Font_Select_12x24_24x24(void) +{ + /*[bit5-4] + Font Height Setting + 00b : 8x16 / 16x16. + 01b : 12x24 / 24x24. + 10b : 16x32 / 32x32. + *** User-defined Font width is decided by font code. Genitop + serial flash's font width is decided by font code or GT Font ROM + control register. + */ + uint8_t temp; + LCD_CmdWrite(0xCC); + temp = LCD_DataRead(); + temp &= cClrb5; + temp |= cSetb4; + LCD_DataWrite(temp); +} +void Font_Select_16x32_32x32(void) +{ + /*[bit5-4] + Font Height Setting + 00b : 8x16 / 16x16. + 01b : 12x24 / 24x24. + 10b : 16x32 / 32x32. + *** User-defined Font width is decided by font code. Genitop + serial flash's font width is decided by font code or GT Font ROM + control register. + */ + uint8_t temp; + LCD_CmdWrite(0xCC); + temp = LCD_DataRead(); + temp |= cSetb5; + temp &= cClrb4; + LCD_DataWrite(temp); +} +void Internal_CGROM_Select_ISOIEC8859_1(void) +{ + /* + Font Selection for internal CGROM + When FNCR0 B7 = 0 and B5 = 0, Internal CGROM supports the + 8x16 character sets with the standard coding of ISO/IEC 8859-1~4, + which supports English and most of European country languages. + 00b : ISO/IEC 8859-1. + 01b : ISO/IEC 8859-2. + 10b : ISO/IEC 8859-3. + 11b : ISO/IEC 8859-4. + */ + uint8_t temp; + LCD_CmdWrite(0xCC); + temp = LCD_DataRead(); + temp &= cClrb1; + temp &= cClrb0; + LCD_DataWrite(temp); +} +void Internal_CGROM_Select_ISOIEC8859_2(void) +{ + /* + Font Selection for internal CGROM + When FNCR0 B7 = 0 and B5 = 0, Internal CGROM supports the + 8x16 character sets with the standard coding of ISO/IEC 8859-1~4, + which supports English and most of European country languages. + 00b : ISO/IEC 8859-1. + 01b : ISO/IEC 8859-2. + 10b : ISO/IEC 8859-3. + 11b : ISO/IEC 8859-4. + */ + uint8_t temp; + LCD_CmdWrite(0xCC); + temp = LCD_DataRead(); + temp &= cClrb1; + temp |= cSetb0; + LCD_DataWrite(temp); +} +void Internal_CGROM_Select_ISOIEC8859_3(void) +{ + /* + Font Selection for internal CGROM + When FNCR0 B7 = 0 and B5 = 0, Internal CGROM supports the + 8x16 character sets with the standard coding of ISO/IEC 8859-1~4, + which supports English and most of European country languages. + 00b : ISO/IEC 8859-1. + 01b : ISO/IEC 8859-2. + 10b : ISO/IEC 8859-3. + 11b : ISO/IEC 8859-4. + */ + uint8_t temp; + LCD_CmdWrite(0xCC); + temp = LCD_DataRead(); + temp |= cSetb1; + temp &= cClrb0; + LCD_DataWrite(temp); +} +void Internal_CGROM_Select_ISOIEC8859_4(void) +{ + /* + Font Selection for internal CGROM + When FNCR0 B7 = 0 and B5 = 0, Internal CGROM supports the + 8x16 character sets with the standard coding of ISO/IEC 8859-1~4, + which supports English and most of European country languages. + 00b : ISO/IEC 8859-1. + 01b : ISO/IEC 8859-2. + 10b : ISO/IEC 8859-3. + 11b : ISO/IEC 8859-4. + */ + uint8_t temp; + LCD_CmdWrite(0xCC); + temp = LCD_DataRead(); + temp |= cSetb1; + temp |= cSetb0; + LCD_DataWrite(temp); +} +//[CDh]========================================================================= +void Enable_Font_Alignment(void) +{ + /* + Full Alignment Selection Bit + 0 : Full alignment disable. + 1 : Full alignment enable. + */ + uint8_t temp; + LCD_CmdWrite(0xCD); + temp = LCD_DataRead(); + temp |= cSetb7; + LCD_DataWrite(temp); +} +void Disable_Font_Alignment(void) +{ + /* + Full Alignment Selection Bit + 0 : Full alignment disable. + 1 : Full alignment enable. + */ + uint8_t temp; + LCD_CmdWrite(0xCD); + temp = LCD_DataRead(); + temp &= cClrb7; + LCD_DataWrite(temp); +} +void Font_Background_select_Transparency(void) +{ + /* + Font Transparency + 0 : Font with background color. + 1 : Font with background transparency. + */ + uint8_t temp; + LCD_CmdWrite(0xCD); + temp = LCD_DataRead(); + temp |= cSetb6; + LCD_DataWrite(temp); +} +void Font_Background_select_Color(void) +{ + /* + Font Transparency + 0 : Font with background color. + 1 : Font with background transparency. + */ + uint8_t temp; + LCD_CmdWrite(0xCD); + temp = LCD_DataRead(); + temp &= cClrb6; + LCD_DataWrite(temp); +} +void Font_0_degree(void) +{ + /* + Font Rotation + 0 : Normal + Text direction from left to right then from top to bottom + 1 : Counterclockwise 90 degree & horizontal flip + Text direction from top to bottom then from left to right + (it should accommodate with set VDIR as 1) + This attribute can be changed only when previous font write + finished (core_busy = 0) + */ + uint8_t temp; + LCD_CmdWrite(0xCD); + temp = LCD_DataRead(); + temp &= cClrb4; + LCD_DataWrite(temp); +} +void Font_90_degree(void) +{ + /* + Font Rotation + 0 : Normal + Text direction from left to right then from top to bottom + 1 : Counterclockwise 90 degree & horizontal flip + Text direction from top to bottom then from left to right + (it should accommodate with set VDIR as 1) + This attribute can be changed only when previous font write + finished (core_busy = 0) + */ + uint8_t temp; + LCD_CmdWrite(0xCD); + temp = LCD_DataRead(); + temp |= cSetb4; + LCD_DataWrite(temp); +} +void Font_Width_X1(void) +{ + /* + Horizontal Font Enlargement + 00b : X1. + 01b : X2. + 10b : X3. + 11b : X4. + */ + uint8_t temp; + LCD_CmdWrite(0xCD); + temp = LCD_DataRead(); + temp &= cClrb3; + temp &= cClrb2; + LCD_DataWrite(temp); +} +void Font_Width_X2(void) +{ + /* + Horizontal Font Enlargement + 00b : X1. + 01b : X2. + 10b : X3. + 11b : X4. + */ + uint8_t temp; + LCD_CmdWrite(0xCD); + temp = LCD_DataRead(); + temp &= cClrb3; + temp |= cSetb2; + LCD_DataWrite(temp); +} +void Font_Width_X3(void) +{ + /* + Horizontal Font Enlargement + 00b : X1. + 01b : X2. + 10b : X3. + 11b : X4. + */ + uint8_t temp; + LCD_CmdWrite(0xCD); + temp = LCD_DataRead(); + temp |= cSetb3; + temp &= cClrb2; + LCD_DataWrite(temp); +} +void Font_Width_X4(void) +{ + /* + Horizontal Font Enlargement + 00b : X1. + 01b : X2. + 10b : X3. + 11b : X4. + */ + uint8_t temp; + LCD_CmdWrite(0xCD); + temp = LCD_DataRead(); + temp |= cSetb3; + temp |= cSetb2; + LCD_DataWrite(temp); +} +void Font_Height_X1(void) +{ + /* + Vertical Font Enlargement + 00b : X1. + 01b : X2. + 10b : X3. + 11b : X4. + */ + uint8_t temp; + LCD_CmdWrite(0xCD); + temp = LCD_DataRead(); + temp &= cClrb1; + temp &= cClrb0; + LCD_DataWrite(temp); +} +void Font_Height_X2(void) +{ + /* + Vertical Font Enlargement + 00b : X1. + 01b : X2. + 10b : X3. + 11b : X4. + */ + uint8_t temp; + LCD_CmdWrite(0xCD); + temp = LCD_DataRead(); + temp &= cClrb1; + temp |= cSetb0; + LCD_DataWrite(temp); +} +void Font_Height_X3(void) +{ + /* + Vertical Font Enlargement + 00b : X1. + 01b : X2. + 10b : X3. + 11b : X4. + */ + uint8_t temp; + LCD_CmdWrite(0xCD); + temp = LCD_DataRead(); + temp |= cSetb1; + temp &= cClrb0; + LCD_DataWrite(temp); +} +void Font_Height_X4(void) +{ + /* + Vertical Font Enlargement + 00b : X1. + 01b : X2. + 10b : X3. + 11b : X4. + */ + uint8_t temp; + LCD_CmdWrite(0xCD); + temp = LCD_DataRead(); + temp |= cSetb1; + temp |= cSetb0; + LCD_DataWrite(temp); +} + +//[CEh]========================================================================= +void GTFont_Select_GT21L16TW_GT21H16T1W(void) +{ + /* + GT Serial Font ROM Select + 000b: GT21L16TW / GT21H16T1W + 001b: GT23L16U2W + 010b: GT23L24T3Y / GT23H24T3Y + 011b: GT23L24M1Z + 100b: GT23L32S4W / GT23H32S4W + 101b: GT20L24F6Y + 110b: GT21L24S1W + 111b: GT22L16A1Y + */ + uint8_t temp; + LCD_CmdWrite(0xCE); + temp = LCD_DataRead(); + temp &= cClrb7; + temp &= cClrb6; + temp &= cClrb5; + LCD_DataWrite(temp); +} +void GTFont_Select_GT23L16U2W(void) +{ + /* + GT Serial Font ROM Select + 000b: GT21L16TW / GT21H16T1W + 001b: GT23L16U2W + 010b: GT23L24T3Y / GT23H24T3Y + 011b: GT23L24M1Z + 100b: GT23L32S4W / GT23H32S4W + 101b: GT20L24F6Y + 110b: GT21L24S1W + 111b: GT22L16A1Y + */ + uint8_t temp; + LCD_CmdWrite(0xCE); + temp = LCD_DataRead(); + temp &= cClrb7; + temp &= cClrb6; + temp |= cSetb5; + LCD_DataWrite(temp); +} +void GTFont_Select_GT23L24T3Y_GT23H24T3Y(void) +{ + /* + GT Serial Font ROM Select + 000b: GT21L16TW / GT21H16T1W + 001b: GT23L16U2W + 010b: GT23L24T3Y / GT23H24T3Y + 011b: GT23L24M1Z + 100b: GT23L32S4W / GT23H32S4W + 101b: GT20L24F6Y + 110b: GT21L24S1W + 111b: GT22L16A1Y + */ + uint8_t temp; + LCD_CmdWrite(0xCE); + temp = LCD_DataRead(); + temp &= cClrb7; + temp |= cSetb6; + temp &= cClrb5; + LCD_DataWrite(temp); +} +void GTFont_Select_GT23L24M1Z(void) +{ + /* + GT Serial Font ROM Select + 000b: GT21L16TW / GT21H16T1W + 001b: GT23L16U2W + 010b: GT23L24T3Y / GT23H24T3Y + 011b: GT23L24M1Z + 100b: GT23L32S4W / GT23H32S4W + 101b: GT20L24F6Y + 110b: GT21L24S1W + 111b: GT22L16A1Y + */ + uint8_t temp; + LCD_CmdWrite(0xCE); + temp = LCD_DataRead(); + temp &= cClrb7; + temp |= cSetb6; + temp |= cSetb5; + LCD_DataWrite(temp); +} +void GTFont_Select_GT23L32S4W_GT23H32S4W(void) +{ + /* + GT Serial Font ROM Select + 000b: GT21L16TW / GT21H16T1W + 001b: GT23L16U2W + 010b: GT23L24T3Y / GT23H24T3Y + 011b: GT23L24M1Z + 100b: GT23L32S4W / GT23H32S4W + 101b: GT20L24F6Y + 110b: GT21L24S1W + 111b: GT22L16A1Y + */ + uint8_t temp; + LCD_CmdWrite(0xCE); + temp = LCD_DataRead(); + temp |= cSetb7; + temp &= cClrb6; + temp &= cClrb5; + LCD_DataWrite(temp); +} +void GTFont_Select_GT20L24F6Y(void) +{ + /* + GT Serial Font ROM Select + 000b: GT21L16TW / GT21H16T1W + 001b: GT23L16U2W + 010b: GT23L24T3Y / GT23H24T3Y + 011b: GT23L24M1Z + 100b: GT23L32S4W / GT23H32S4W + 101b: GT20L24F6Y + 110b: GT21L24S1W + 111b: GT22L16A1Y + */ + uint8_t temp; + LCD_CmdWrite(0xCE); + temp = LCD_DataRead(); + temp |= cSetb7; + temp &= cClrb6; + temp |= cSetb5; + LCD_DataWrite(temp); +} +void GTFont_Select_GT21L24S1W(void) +{ + /* + GT Serial Font ROM Select + 000b: GT21L16TW / GT21H16T1W + 001b: GT23L16U2W + 010b: GT23L24T3Y / GT23H24T3Y + 011b: GT23L24M1Z + 100b: GT23L32S4W / GT23H32S4W + 101b: GT20L24F6Y + 110b: GT21L24S1W + 111b: GT22L16A1Y + */ + uint8_t temp; + LCD_CmdWrite(0xCE); + temp = LCD_DataRead(); + temp |= cSetb7; + temp |= cSetb6; + temp &= cClrb5; + LCD_DataWrite(temp); +} +void GTFont_Select_GT22L16A1Y(void) +{ + /* + GT Serial Font ROM Select + 000b: GT21L16TW / GT21H16T1W + 001b: GT23L16U2W + 010b: GT23L24T3Y / GT23H24T3Y + 011b: GT23L24M1Z + 100b: GT23L32S4W / GT23H32S4W + 101b: GT20L24F6Y + 110b: GT21L24S1W + 111b: GT22L16A1Y + */ + uint8_t temp; + LCD_CmdWrite(0xCE); + temp = LCD_DataRead(); + temp |= cSetb7; + temp |= cSetb6; + temp |= cSetb5; + LCD_DataWrite(temp); +} + +//[CFh]========================================================================= +void Set_GTFont_Decoder(uint8_t temp) +{ + /* + [bit7-3] + FONT ROM Coding Setting + For specific GT serial Font ROM, the coding method must be set for decoding. + 00000b: GB2312 + 00001b: GB12345/GB18030 + 00010b: BIG5 + 00011b: UNICODE + 00100b: ASCII + 00101b: UNI-Japanese + 00110b: JIS0208 + 00111b: Latin/Greek/ Cyrillic / Arabic/Thai/Hebrew + 01000b: Korea + 10001b: ISO-8859-1 + 10010b: ISO-8859-2 + 10011b: ISO-8859-3 + 10100b: ISO-8859-4 + 10101b: ISO-8859-5 + 10110b: ISO-8859-6 + 10111b: ISO-8859-7 + 11000b: ISO-8859-8 + 11001b: ISO-8859-9 + 11010b: ISO-8859-10 + 11011b: ISO-8859-11 + 11100b: ISO-8859-12 + 11101b: ISO-8859-13 + 11110b: ISO-8859-14 + 11111b: ISO-8859-15 + + [bit1-0] + ASCII / Latin/Greek/ Cyrillic / Arabic + (ASCII) (Latin/Greek/Cyrillic) (Arabic) + 00b Normal Normal NA + 01b Arial Variable Width Presentation Forms-A + 10b Roman NA Presentation Forms-B + 11b Bold NA NA + */ + LCD_CmdWrite(0xCF); + LCD_DataWrite(temp); +} +//[D0h]========================================================================= +void Font_Line_Distance(uint8_t temp) +{ + /*[bit4-0] + Font Line Distance Setting + Setting the font character line distance when setting memory font + write cursor auto move. (Unit: pixel) + */ + LCD_CmdWrite(0xD0); + LCD_DataWrite(temp); +} +//[D1h]========================================================================= +void Set_Font_to_Font_Width(uint8_t temp) +{ + /*[bit5-0] + Font to Font Width Setting (Unit: pixel) + */ + LCD_CmdWrite(0xD1); + LCD_DataWrite(temp); +} +//[D2h]~[D4h]========================================================================= +void Foreground_RGB(uint8_t RED, uint8_t GREEN, uint8_t BLUE) +{ + /* + [D2h] Foreground Color - Red, for draw, text or color expansion + [D3h] Foreground Color - Green, for draw, text or color expansion + [D4h] Foreground Color - Blue, for draw, text or color expansion + */ + LCD_CmdWrite(0xD2); + LCD_DataWrite(RED); + LCD_CmdWrite(0xD3); + LCD_DataWrite(GREEN); + LCD_CmdWrite(0xD4); + LCD_DataWrite(BLUE); +} + +//Input data format:R3G3B2 +void Foreground_color_256(uint8_t temp) +{ + LCD_CmdWrite(0xD2); + LCD_DataWrite(temp); + LCD_CmdWrite(0xD3); + LCD_DataWrite(temp<<3); + LCD_CmdWrite(0xD4); + LCD_DataWrite(temp<<6); +} + +//Input data format:R5G6B5 +void Foreground_color_65k(unsigned short temp) +{ + LCD_CmdWrite(0xD2); + LCD_DataWrite(temp >> 8); + LCD_CmdWrite(0xD3); + LCD_DataWrite(temp >> 3); + LCD_CmdWrite(0xD4); + LCD_DataWrite(temp<<3); +} + +//Input data format:R8G8B8 +void Foreground_color_16M(uint32_t temp) +{ + LCD_CmdWrite(0xD2); + LCD_DataWrite(temp >> 16); + LCD_CmdWrite(0xD3); + LCD_DataWrite(temp >> 8); + LCD_CmdWrite(0xD4); + LCD_DataWrite(temp); +} + + + +//[D5h]~[D7h]========================================================================= +/* +[D5h] Background Color - Red, for Text or color expansion +[D6h] Background Color - Green, for Text or color expansion +[D7h] Background Color - Blue, for Text or color expansion +*/ +void Background_RGB(uint8_t RED, uint8_t GREEN, uint8_t BLUE) +{ + LCD_CmdWrite(0xD5); + LCD_DataWrite(RED); + LCD_CmdWrite(0xD6); + LCD_DataWrite(GREEN); + LCD_CmdWrite(0xD7); + LCD_DataWrite(BLUE); +} + +//Input data format:R3G3B2 +void Background_color_256(uint8_t temp) +{ + LCD_CmdWrite(0xD5); + LCD_DataWrite(temp); + LCD_CmdWrite(0xD6); + LCD_DataWrite(temp<<3); + LCD_CmdWrite(0xD7); + LCD_DataWrite(temp<<6); +} + +//Input data format:R5G6B6 +void Background_color_65k(unsigned short temp) +{ + LCD_CmdWrite(0xD5); + LCD_DataWrite(temp >> 8); + LCD_CmdWrite(0xD6); + LCD_DataWrite(temp >> 3); + LCD_CmdWrite(0xD7); + LCD_DataWrite(temp<<3); +} + +//Input data format:R8G8B8 +void Background_color_16M(uint32_t temp) +{ + LCD_CmdWrite(0xD5); + LCD_DataWrite(temp >> 16); + LCD_CmdWrite(0xD6); + LCD_DataWrite(temp >> 8); + LCD_CmdWrite(0xD7); + LCD_DataWrite(temp); +} + +//[DBh]~[DEh]========================================================================= +void CGRAM_Start_address(uint32_t Addr) +{ + /* + CGRAM START ADDRESS [31:0] + */ + LCD_CmdWrite(0xDB); + LCD_DataWrite(Addr); + LCD_CmdWrite(0xDC); + LCD_DataWrite(Addr >> 8); + LCD_CmdWrite(0xDD); + LCD_DataWrite(Addr >> 16); + LCD_CmdWrite(0xDE); + LCD_DataWrite(Addr >> 24); +} + +//[DFh]========================================================================= +/* +[bit7] Enter Power saving state +0: Normal state. +1: Enter power saving state. +[bit1][bit0] Power saving Mode definition +00: NA +01: Standby Mode +10: Suspend Mode +11: Sleep Mode +*/ +void Power_Normal_Mode(void) +{ + LCD_CmdWrite(0xDF); + LCD_DataWrite(0x00); +} +void Power_Saving_Standby_Mode(void) +{ + LCD_CmdWrite(0xDF); + LCD_DataWrite(0x01); + LCD_CmdWrite(0xDF); + LCD_DataWrite(0x81); +} +void Power_Saving_Suspend_Mode(void) +{ + LCD_CmdWrite(0xDF); +// LCD_DataWrite(0x02); +// LCD_CmdWrite(0xDF); + LCD_DataWrite(0x82); +} +void Power_Saving_Sleep_Mode(void) +{ + LCD_CmdWrite(0xDF); +// LCD_DataWrite(0x03); +// LCD_CmdWrite(0xDF); + LCD_DataWrite(0x83); +} + + +//[E5h]~[E6h]========================================================================= +void LT768_I2CM_Clock_Prescale(unsigned short WX) +{ + /* + I2C Master Clock Pre-scale [7:0] + I2C Master Clock Pre-scale [15:8] + */ + LCD_CmdWrite(0xE5); + LCD_DataWrite(WX); + LCD_CmdWrite(0xE6); + LCD_DataWrite(WX >> 8); +} +//[E7h]========================================================================= +void LT768_I2CM_Transmit_Data(uint8_t temp) +{ + /* + I2C Master Transmit[7:0] + */ + LCD_CmdWrite(0xE7); + LCD_DataWrite(temp); +} +//[E8h]========================================================================= +uint8_t LT768_I2CM_Receiver_Data(void) +{ + /* + I2C Master Receiver [7:0] + */ + uint8_t temp; + LCD_CmdWrite(0xE8); + temp = LCD_DataRead(); + return temp; +} +//[E9h]========================================================================= +/* +[bit7] START +Generate (repeated) start condition and be cleared by hardware automatically +Note : This bit is always read as 0. +[bit6] STOP +Generate stop condition and be cleared by hardware automatically +Note : This bit is always read as 0. +[bit5] +READ(READ and WRITE can't be used simultaneously) +Read form slave and be cleared by hardware automatically +Note : This bit is always read as 0. +[bit4] +WRITE(READ and WRITE can't be used simultaneously) +Write to slave and be cleared by hardware automatically +Note : This bit is always read as 0. +[bit3] ACKNOWLEDGE +When as a I2C master receiver +0 : Sent ACK. +1 : Sent NACK. +Note : This bit is always read as 0. +[bit0] Noise Filter +0 : Enable. +1 : Disable. +*/ + +#define Disable_I2CM_Noise_Filter + +void LT768_I2CM_Stop(void) +{ + LCD_CmdWrite(0xE9); +#ifdef Disable_I2CM_Noise_Filter + LCD_DataWrite(0x40); +#endif +#ifdef Enable_I2CM_Noise_Filter + LCD_DataWrite(0x41); +#endif +} +void LT768_I2CM_Read_With_Ack(void) +{ + LCD_CmdWrite(0xE9); +#ifdef Disable_I2CM_Noise_Filter + LCD_DataWrite(0x20); +#endif +#ifdef Enable_I2CM_Noise_Filter + LCD_DataWrite(0x21); +#endif +} + +void LT768_I2CM_Read_With_Nack(void) +{ + LCD_CmdWrite(0xE9); +#ifdef Disable_I2CM_Noise_Filter + LCD_DataWrite(0x68); +#endif +#ifdef Enable_I2CM_Noise_Filter + LCD_DataWrite(0x69); +#endif +} + +void LT768_I2CM_Write_With_Start(void) +{ + LCD_CmdWrite(0xE9); +#ifdef Disable_I2CM_Noise_Filter + LCD_DataWrite(0x90); +#endif +#ifdef Enable_I2CM_Noise_Filter + LCD_DataWrite(0x91); +#endif +} + +void LT768_I2CM_Write(void) +{ + LCD_CmdWrite(0xE9); +#ifdef Disable_I2CM_Noise_Filter + LCD_DataWrite(0x10); +#endif +#ifdef Enable_I2CM_Noise_Filter + LCD_DataWrite(0x11); +#endif +} + + + +//[EAh]========================================================================= +/* + 0=Ack + 1=Nack +*/ +uint8_t LT768_I2CM_Check_Slave_ACK(void) +{ + uint8_t temp; + /*[bit7] + Received acknowledge from slave + 0 : Acknowledge received. + 1 : No Acknowledge received. + */ + LCD_CmdWrite(0xEA); + temp = LCD_DataRead(); + + if((temp&0x80)==0x80) + { + return 1; + } + else + { + return 0; + } +} + + +/* + 0=Idle + 1=Busy +*/ +uint8_t LT768_I2CM_Bus_Busy(void) +{ + uint8_t temp; + /*[bit6] + I2C Bus is Busy + 0 : Idle. + 1 : Busy. + */ + LCD_CmdWrite(0xEA); + temp = LCD_DataRead(); + + if((temp&0x40)==0x40) + { + return 1; + } + else + { + return 0; + } +} + +/* + 0=Complete + 1=Transferring +*/ +uint8_t LT768_I2CM_transmit_Progress(void) +{ + uint8_t temp; + /*[bit6] + 0=Complete + 1=Transferring + */ + LCD_CmdWrite(0xEA); + temp = LCD_DataRead(); + + if((temp&0x02)==0x02) + { + return 1; + } + else + { + return 0; + } +} + +/* +0= Arbitration win +1= Arbitration lost +*/ +uint8_t LT768_I2CM_Arbitration(void) +{ + uint8_t temp; + /*[bit6] + I2C Bus is Busy + 0 : Idle. + 1 : Busy. + */ + LCD_CmdWrite(0xEA); + temp = LCD_DataRead(); + temp&=0x01; + return temp; +} + + +//[F0h]========================================================================= +void Set_GPIO_A_In_Out(uint8_t temp) +{ + /* + GPO-A_dir[7:0] : General Purpose I/O direction control. + 0: Output + 1: Input + */ + LCD_CmdWrite(0xF0); + LCD_DataWrite(temp); +} +//[F1h]========================================================================= +void Write_GPIO_A_7_0(uint8_t temp) +{ + /* + GPI-A[7:0] : General Purpose Input, share with DB[15:8] + GPO-A[7:0] : General Purpose Output, share with DB[15:8] + */ + LCD_CmdWrite(0xF1); + LCD_DataWrite(temp); +} +uint8_t Read_GPIO_A_7_0(void) +{ + /* + GPI-A[7:0] : General Purpose Input, share with DB[15:8] + GPO-A[7:0] : General Purpose Output, share with DB[15:8] + */ + uint8_t temp; + LCD_CmdWrite(0xF1); + temp = LCD_DataRead(); + return temp; +} +//[F2h]========================================================================= +void Write_GPIO_B_7_4(uint8_t temp) +{ + /* + GPI-B[7:0] : General Purpose Input ; share with {XKIN[3:0], XA0, XnWR, XnRD, XnCS} + GPO-B[7:4] : General Purpose Output ; share with XKOUT[3:0] ; + */ + LCD_CmdWrite(0xF2); + LCD_DataWrite(temp); +} +uint8_t Read_GPIO_B_7_0(void) +{ + /* + GPI-B[7:0] : General Purpose Input ; share with {XKIN[3:0], XA0, XnWR, XnRD, XnCS} + GPO-B[7:4] : General Purpose Output ; share with XKOUT[3:0] ; + */ + uint8_t temp; + LCD_CmdWrite(0xF2); + temp = LCD_DataRead(); + return temp; +} + +//[F3h]========================================================================= +void Set_GPIO_C_In_Out(uint8_t temp) +{ + /* + GPIO-C_dir[7:0] : General Purpose I/O direction control. + 0: Output + 1: Input + */ + LCD_CmdWrite(0xF3); + LCD_DataWrite(temp); +} +//[F4h]========================================================================= +void Write_GPIO_C_7_0(uint8_t temp) +{ + /* + GPIO-C[7:0] : General Purpose Input / Output + share with {XPWM0, XI2CSDA, XI2CSCL, XnSFCS1, XnSFCS0,XMISO, XMOSI, XSCLK} + */ + LCD_CmdWrite(0xF4); + LCD_DataWrite(temp); +} +uint8_t Read_GPIO_C_7_0(void) +{ + /* + GPIO-C[7:0] : General Purpose Input / Output + share with {XPWM0, XI2CSDA, XI2CSCL, XnSFCS1, XnSFCS0,XMISO, XMOSI, XSCLK} + */ + uint8_t temp; + LCD_CmdWrite(0xF4); + temp = LCD_DataRead(); + return temp; +} +//[F5h]========================================================================= +void Set_GPIO_D_In_Out(uint8_t temp) +{ + /* + GPIO-D_dir[7:0] : General Purpose I/O direction control. + 0: Output + 1: Input + */ + LCD_CmdWrite(0xF5); + LCD_DataWrite(temp); +} +//[F6h]========================================================================= +void Write_GPIO_D_7_0(uint8_t temp) +{ + /* + GPIO-D[7:0] : General Purpose Input/Output + */ + LCD_CmdWrite(0xF6); + LCD_DataWrite(temp); +} +uint8_t Read_GPIO_D_7_0(void) +{ + /* + GPIO-D[7:0] : General Purpose Input/Output + */ + uint8_t temp; + LCD_CmdWrite(0xF6); + temp = LCD_DataRead(); + return temp; +} +//[F7h]========================================================================= +void Set_GPIO_E_In_Out(uint8_t temp) +{ + /* + GPIO-E_dir[7:0] : General Purpose I/O direction control. + 0: Output + 1: Input + */ + LCD_CmdWrite(0xF7); + LCD_DataWrite(temp); +} +//[F8h]========================================================================= +void Write_GPIO_E_7_0(uint8_t temp) +{ + /* + GPIO-E[7:0] : General Purpose Input/Output. + share with {PDAT[23:19], PDAT[15:13]} + */ + LCD_CmdWrite(0xF8); + LCD_DataWrite(temp); +} +uint8_t Read_GPIO_E_7_0(void) +{ + /* + GPIO-E[7:0] : General Purpose Input/Output. + share with {PDAT[23:19], PDAT[15:13]} + */ + uint8_t temp; + LCD_CmdWrite(0xF8); + temp = LCD_DataRead(); + return temp; +} +//[F9h]========================================================================= +void Set_GPIO_F_In_Out(uint8_t temp) +{ + /* + GPIO-F_dir[7:0] : General Purpose I/O direction control. + 0: Output + 1: Input + */ + LCD_CmdWrite(0xF9); + LCD_DataWrite(temp); +} +//[FAh]========================================================================= +void Write_GPIO_F_7_0(uint8_t temp) +{ + /* + GPIO-F[7:0] : General Purpose Input/Output. + share with {XPDAT[12:10], XPDAT[7:3]} + */ + LCD_CmdWrite(0xFA); + LCD_DataWrite(temp); +} +uint8_t Read_GPIO_F_7_0(void) +{ + /* + GPIO-F[7:0] : General Purpose Input/Output. + share with {XPDAT[12:10], XPDAT[7:3]} + */ + uint8_t temp; + LCD_CmdWrite(0xFA); + temp = LCD_DataRead(); + return temp; +} + +//[FBh]========================================================================= + + +void Long_Key_enable(void) +{ + /* + Key-Scan Control Register 1 + [bit6] LongKey Enable Bit + 1 : Enable. Long key period is set by KSCR2 bit4-2. + 0 : Disable. + */ + uint8_t temp; + LCD_CmdWrite(0xFB); + temp = LCD_DataRead(); + temp |= cSetb6; + LCD_DataWrite(temp); +} + + +void Key_Scan_Freg(uint8_t setx) +{ + /*KF2-0: Key-Scan Frequency */ + uint8_t temp; + LCD_CmdWrite(0xFB); + temp = LCD_DataRead(); + temp &= 0xf0; + temp|= (setx&0x07); + LCD_DataWrite(temp); +} + + +//[FCh]========================================================================= + +void Key_Scan_Wakeup_Function_Enable(void) +{ + /* + Key-Scan Controller Register 2 + [bit7] + Key-Scan Wakeup Function Enable Bit + 0: Key-Scan Wakeup function is disabled. + 1: Key-Scan Wakeup function is enabled. + */ + uint8_t temp; + LCD_CmdWrite(0xFC); + temp = LCD_DataRead(); + temp |= cSetb7; + LCD_DataWrite(temp); +} + + +void Long_Key_Timing_Adjustment(uint8_t setx) +{ + /*Long Key Timing Adjustment*/ + uint8_t temp,temp1; + temp = setx & 0x1c; + LCD_CmdWrite(0xFC); + temp1 = LCD_DataRead(); + temp1|=temp; + LCD_DataWrite(temp1); +} + +uint8_t Numbers_of_Key_Hit(void) +{ + uint8_t temp; + LCD_CmdWrite(0xFC); + temp = LCD_DataRead(); //read key touch number + temp = temp & 0x03; + return temp; +} + +//[FDh][FEh][FFh]========================================================================= +uint8_t Read_Key_Strobe_Data_0(void) +{ + /* + Key Strobe Data 0 + The corresponding key code 0 that is pressed. + */ + uint8_t temp; + LCD_CmdWrite(0xFD); + temp = LCD_DataRead(); + return temp; +} +uint8_t Read_Key_Strobe_Data_1(void) +{ + /* + Key Strobe Data 1 + The corresponding key code 1 that is pressed. + */ + uint8_t temp; + LCD_CmdWrite(0xFE); + temp = LCD_DataRead(); + return temp; +} +uint8_t Read_Key_Strobe_Data_2(void) +{ + /* + Key Strobe Data 2 + The corresponding key code 2 that is pressed. + */ + uint8_t temp; + LCD_CmdWrite(0xFF); + temp = LCD_DataRead(); + return temp; +} + +void Show_String(char *str) +{ + Text_Mode(); //text mode + LCD_CmdWrite(0x04); + + while(*str != '\0') + { + LCD_DataWrite(*str); + Check_Mem_WR_FIFO_not_Full(); + ++str; + } + + Check_2D_Busy(); + Graphic_Mode(); //back to graphic mode; +} + + +void Show_picture(uint32_t numbers,const unsigned short *datap) +{ + uint32_t i; + LCD_CmdWrite(0x04); + + for(i=0; i5) - { - temp = temp / 1000000 + 1; - } - else - { - temp = temp / 1000000; - } - - lt768_sclk = temp; - temp = temp * 3; - lt768_mclk = temp; - lt768_cclk = temp; - - if(lt768_cclk > 100) - { - lt768_cclk = 100; - } - - if(lt768_mclk > 100) - { - lt768_mclk = 100; - } - - if(lt768_sclk > 65) - { - lt768_sclk = 65; - } - -#if XI_4M - lpllOD_sclk = 3; - lpllOD_cclk = 2; - lpllOD_mclk = 2; - lpllR_sclk = 2; - lpllR_cclk = 2; - lpllR_mclk = 2; - lpllN_mclk = lt768_mclk; - lpllN_cclk = lt768_cclk; - lpllN_sclk = 2*lt768_sclk; -#endif -#if XI_8M - lpllOD_sclk = 3; - lpllOD_cclk = 2; - lpllOD_mclk = 2; - lpllR_sclk = 2; - lpllR_cclk = 4; - lpllR_mclk = 4; - lpllN_mclk = lt768_mclk; - lpllN_cclk = lt768_cclk; - lpllN_sclk = lt768_sclk; -#endif -#if XI_10M - lpllOD_sclk = 3; - lpllOD_cclk = 2; - lpllOD_mclk = 2; - lpllR_sclk = 5; - lpllR_cclk = 5; - lpllR_mclk = 5; - lpllN_mclk = lt768_mclk; - lpllN_cclk = lt768_cclk; - lpllN_sclk = 2*lt768_sclk; -#endif -#if XI_12M - lpllOD_sclk = 3; - lpllOD_cclk = 2; - lpllOD_mclk = 2; - lpllR_sclk = 3; - lpllR_cclk = 6; - lpllR_mclk = 6; - lpllN_mclk = lt768_mclk; - lpllN_cclk = lt768_cclk; - lpllN_sclk = lt768_sclk; -#endif - LCD_CmdWrite(0x05); - LCD_DataWrite((lpllOD_sclk<<6) | (lpllR_sclk<<1) | ((lpllN_sclk>>8)&0x1)); - LCD_CmdWrite(0x07); - LCD_DataWrite((lpllOD_mclk<<6) | (lpllR_mclk<<1) | ((lpllN_mclk>>8)&0x1)); - LCD_CmdWrite(0x09); - LCD_DataWrite((lpllOD_cclk<<6) | (lpllR_cclk<<1) | ((lpllN_cclk>>8)&0x1)); - LCD_CmdWrite(0x06); - LCD_DataWrite(lpllN_sclk); - LCD_CmdWrite(0x08); - LCD_DataWrite(lpllN_mclk); - LCD_CmdWrite(0x0a); - LCD_DataWrite(lpllN_cclk); - LCD_CmdWrite(0x00); - up_udelay(1); - LCD_DataWrite(0x80); - up_mdelay(1); -} - -void lt768_sdram_init(uint8_t mclk) -{ - uint16_t sdram_itv; - LCD_RegisterWrite(0xe0,0x29); - LCD_RegisterWrite(0xe1,0x03); //CAS:2=0x02?CAS:3=0x03 - sdram_itv = (64000000 / 8192) / (1000 / mclk) ; - sdram_itv-=2; - LCD_RegisterWrite(0xe2,sdram_itv); - LCD_RegisterWrite(0xe3,sdram_itv >>8); - LCD_RegisterWrite(0xe4,0x01); -// Check_SDRAM_Ready(); - up_mdelay(1); -} - -void lt768_set_panel(void) -{ - //**[01h]**// - TFT_16bit(); - //TFT_18bit(); - //TFT_24bit(); -#if STM32_FSMC_8 - Host_Bus_8bit(); //主机总线8bit -#else - Host_Bus_16bit(); //主机总线16bit -#endif - //**[02h]**// - RGB_16b_16bpp(); - //RGB_16b_24bpp_mode1(); - MemWrite_Left_Right_Top_Down(); - //MemWrite_Down_Top_Left_Right(); - //**[03h]**// - Graphic_Mode(); - Memory_Select_SDRAM(); -// PCLK_Falling(); //REG[12h]:下降沿 - PCLK_Rising(); - VSCAN_T_to_B(); //REG[12h]:从上到下 - //VSCAN_B_to_T(); //从下到上 - PDATA_Set_RGB(); //REG[12h]:Select RGB output - //PDATA_Set_RBG(); - //PDATA_Set_GRB(); - //PDATA_Set_GBR(); - //PDATA_Set_BRG(); - //PDATA_Set_BGR(); - HSYNC_Low_Active(); //REG[13h]: - //HSYNC_High_Active(); - VSYNC_Low_Active(); //REG[13h]: - //VSYNC_High_Active(); - DE_High_Active(); //REG[13h]: - //DE_Low_Active(); - LCD_HorizontalWidth_VerticalHeight(LCD_XSIZE_TFT,LCD_YSIZE_TFT); - LCD_Horizontal_Non_Display(LCD_HBPD); - LCD_HSYNC_Start_Position(LCD_HFPD); - LCD_HSYNC_Pulse_Width(LCD_HSPW); - LCD_Vertical_Non_Display(LCD_VBPD); - LCD_VSYNC_Start_Position(LCD_VFPD); - LCD_VSYNC_Pulse_Width(LCD_VSPW); - Memory_XY_Mode(); //Block mode (X-Y coordination addressing);块模式 - Memory_16bpp_Mode(); -} - -void lt768_init(void) -{ - lt768_hw_reset(); - //delay for LT768 power on - up_mdelay(100); - - // check reset ok? - lt768_sys_check(); - - //Initial_Display_test and set SW2 pin2 = 1 - while(LCD_StatusRead() & 0x02); - - lt768_pll_init(); - lt768_sdram_init(lt768_mclk); - lt768_set_panel(); -} - -/*----------------------------------------------------------------------------*/ - -void MPU8_8bpp_Memory_Write -( - uint16_t x // x坐标 - ,uint16_t y // y坐标 - ,uint16_t w // 宽度 - ,uint16_t h // 高度 - ,const uint8_t *data // 数据首地址 -) -{ - uint16_t i,j; - Graphic_Mode(); - Active_Window_XY(x,y); - Active_Window_WH(w,h); - Goto_Pixel_XY(x,y); - LCD_CmdWrite(0x04); - - for(i=0; i< h; i++) - { - for(j=0; j< w; j++) - { - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite(*data); - data++; - } - } - - Check_Mem_WR_FIFO_Empty(); -} - - -void MPU8_16bpp_Memory_Write -( - uint16_t x // x坐标 - ,uint16_t y // y坐标 - ,uint16_t w // 宽度 - ,uint16_t h // 高度 - ,const uint8_t *data // 数据首地址 -) -{ - uint16_t i,j; - Graphic_Mode(); - Active_Window_XY(x,y); - Active_Window_WH(w,h); - Goto_Pixel_XY(x,y); - LCD_CmdWrite(0x04); - - for(i=0; i< h; i++) - { - for(j=0; j< w; j++) - { - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite(*data); - data++; - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite(*data); - data++; - } - } - - Check_Mem_WR_FIFO_Empty(); -} - - -void MPU8_24bpp_Memory_Write -( - uint16_t x // x坐标 - ,uint16_t y // y坐标 - ,uint16_t w // 宽度 - ,uint16_t h // 高度 - ,const uint8_t *data // 数据首地址 -) -{ - uint16_t i,j; - Graphic_Mode(); - Active_Window_XY(x,y); - Active_Window_WH(w,h); - Goto_Pixel_XY(x,y); - LCD_CmdWrite(0x04); - - for(i=0; i< h; i++) - { - for(j=0; j< w; j++) - { - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite(*data); - data++; - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite(*data); - data++; - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite(*data); - data++; - } - } - - Check_Mem_WR_FIFO_Empty(); -} - - - -void MPuint16_t_16bpp_Memory_Write -( - uint16_t x // x坐标 - ,uint16_t y // y坐标 - ,uint16_t w // 宽度 - ,uint16_t h // 高度 - ,const uint16_t *data // 数据首地址 -) -{ - uint16_t i,j; - Graphic_Mode(); - Active_Window_XY(x,y); - Active_Window_WH(w,h); - Goto_Pixel_XY(x,y); - LCD_CmdWrite(0x04); - - for(i=0; i< h; i++) - { - for(j=0; j< w; j++) - { - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite_Pixel(*data); - data++; - } - } - - Check_Mem_WR_FIFO_Empty(); -} - -void MPuint16_t_24bpp_Mode1_Memory_Write -( - uint16_t x // x坐标 - ,uint16_t y // y坐标 - ,uint16_t w // 宽度 - ,uint16_t h // 高度 - ,const uint16_t *data // 数据首地址 -) -{ - uint16_t i,j; - Graphic_Mode(); - Active_Window_XY(x,y); - Active_Window_WH(w,h); - Goto_Pixel_XY(x,y); - LCD_CmdWrite(0x04); - - for(i=0; i< h; i++) - { - for(j=0; j< w/2; j++) - { - LCD_DataWrite_Pixel(*data); - Check_Mem_WR_FIFO_not_Full(); - data++; - LCD_DataWrite_Pixel(*data); - Check_Mem_WR_FIFO_not_Full(); - data++; - LCD_DataWrite_Pixel(*data); - Check_Mem_WR_FIFO_not_Full(); - data++; - } - } - - Check_Mem_WR_FIFO_Empty(); -} - - -void MPuint16_t_24bpp_Mode2_Memory_Write -( - uint16_t x // x坐标 - ,uint16_t y // y坐标 - ,uint16_t w // 宽度 - ,uint16_t h // 高度 - ,const uint16_t *data // 数据首地址 -) -{ - uint16_t i,j; - Graphic_Mode(); - Active_Window_XY(x,y); - Active_Window_WH(w,h); - Goto_Pixel_XY(x,y); - LCD_CmdWrite(0x04); - - for(i=0; i< h; i++) - { - for(j=0; j< w; j++) - { - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite_Pixel(*data); - data++; - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite_Pixel(*data); - data++; - } - } - - Check_Mem_WR_FIFO_Empty(); -} -/*----------------------------------------------------------------------------*/ - -//------------------------------------- 线段 ----------------------------------------- -void LT768_DrawLine -( - uint16_t X1 // X1坐标 - ,uint16_t Y1 // Y1坐标 - ,uint16_t X2 // X2坐标 - ,uint16_t Y2 // Y2坐标 - ,unsigned long LineColor // 线段颜色 -) -{ - Foreground_color_65k(LineColor); - Line_Start_XY(X1,Y1); - Line_End_XY(X2,Y2); - Start_Line(); - Check_2D_Busy(); -} - -void LT768_DrawLine_Width -( - uint16_t X1 // X1坐标 - ,uint16_t Y1 // Y1坐标 - ,uint16_t X2 // X2坐标 - ,uint16_t Y2 // Y2坐标 - ,unsigned long LineColor // 线段颜色 - ,uint16_t Width // 线段宽度 -) -{ - uint16_t i = 0; - signed short x = 0, y = 0; - double temp = 0; - x = X2 - X1; - y = Y2 - Y1; - - if(x == 0) - { - temp = 2; - } - else - { - temp = -((double)y/(double)x); - } - - if(temp>=-1&&temp<=1) - { - while(Width--) - { - LT768_DrawLine(X1,Y1+i,X2,Y2+i,LineColor); - i++; - } - } - else - { - while(Width--) - { - LT768_DrawLine(X1+i,Y1,X2+i,Y2,LineColor); - i++; - } - } -} - -//------------------------------------- 圆 ----------------------------------------- -void LT768_DrawCircle -( - uint16_t XCenter // 圆心X位置 - ,uint16_t YCenter // 圆心Y位置 - ,uint16_t R // 半径 - ,unsigned long CircleColor // 画线颜色 -) -{ - Foreground_color_65k(CircleColor); - Circle_Center_XY(XCenter,YCenter); - Circle_Radius_R(R); - Start_Circle_or_Ellipse(); - Check_2D_Busy(); -} - -void LT768_DrawCircle_Fill -( - uint16_t XCenter // 圆心X位置 - ,uint16_t YCenter // 圆心Y位置 - ,uint16_t R // 半径 - ,unsigned long ForegroundColor // 背景颜色 -) -{ - Foreground_color_65k(ForegroundColor); - Circle_Center_XY(XCenter,YCenter); - Circle_Radius_R(R); - Start_Circle_or_Ellipse_Fill(); - Check_2D_Busy(); -} - -void LT768_DrawCircle_Width -( - uint16_t XCenter // 圆心X位置 - ,uint16_t YCenter // 圆心Y位置 - ,uint16_t R // 半径 - ,unsigned long CircleColor // 画线颜色 - ,unsigned long ForegroundColor // 背景颜色 - ,uint16_t Width // 线宽 -) -{ - LT768_DrawCircle_Fill(XCenter,YCenter,R+Width,CircleColor); - LT768_DrawCircle_Fill(XCenter,YCenter,R,ForegroundColor); -} - -//------------------------------------- 椭圆 ----------------------------------------- -void LT768_DrawEllipse -( - uint16_t XCenter // 椭圆心X位置 - ,uint16_t YCenter // 椭圆心Y位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long EllipseColor // 画线颜色 -) -{ - Foreground_color_65k(EllipseColor); - Ellipse_Center_XY(XCenter,YCenter); - Ellipse_Radius_RxRy(X_R,Y_R); - Start_Circle_or_Ellipse(); - Check_2D_Busy(); -} - -void LT768_DrawEllipse_Fill -( - uint16_t XCenter // 椭圆心X位置 - ,uint16_t YCenter // 椭圆心Y位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long ForegroundColor // 背景颜色 -) -{ - Foreground_color_65k(ForegroundColor); - Ellipse_Center_XY(XCenter,YCenter); - Ellipse_Radius_RxRy(X_R,Y_R); - Start_Circle_or_Ellipse_Fill(); - Check_2D_Busy(); -} - -void LT768_DrawEllipse_Width -( - uint16_t XCenter // 椭圆心X位置 - ,uint16_t YCenter // 椭圆心Y位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long EllipseColor // 画线颜色 - ,unsigned long ForegroundColor // 背景颜色 - ,uint16_t Width // 线宽 -) -{ - LT768_DrawEllipse_Fill(XCenter,YCenter,X_R+Width,Y_R+Width,EllipseColor); - LT768_DrawEllipse_Fill(XCenter,YCenter,X_R,Y_R,ForegroundColor); -} - -//------------------------------------- 矩形 ----------------------------------------- -void LT768_DrawSquare -( - uint16_t X1 // X1位置 - ,uint16_t Y1 // Y1位置 - ,uint16_t X2 // X2位置 - ,uint16_t Y2 // Y2位置 - ,unsigned long SquareColor // 画线颜色 -) -{ - Foreground_color_65k(SquareColor); - Square_Start_XY(X1,Y1); - Square_End_XY(X2,Y2); - Start_Square(); - Check_2D_Busy(); -} - -void LT768_DrawSquare_Fill -( - uint16_t X1 // X1位置 - ,uint16_t Y1 // Y1位置 - ,uint16_t X2 // X2位置 - ,uint16_t Y2 // Y2位置 - ,unsigned long ForegroundColor // 背景颜色 -) -{ - Foreground_color_65k(ForegroundColor); - Square_Start_XY(X1,Y1); - Square_End_XY(X2,Y2); - Start_Square_Fill(); - Check_2D_Busy(); -} - -void LT768_DrawSquare_Width -( - uint16_t X1 // X1位置 - ,uint16_t Y1 // Y1位置 - ,uint16_t X2 // X2位置 - ,uint16_t Y2 // Y2位置 - ,unsigned long SquareColor // 画线颜色 - ,unsigned long ForegroundColor // 背景颜色 - ,uint16_t Width // 线宽 -) -{ - LT768_DrawSquare_Fill(X1-Width,Y1-Width,X2+Width,Y2+Width,SquareColor); - LT768_DrawSquare_Fill(X1,Y1,X2,Y2,ForegroundColor); -} - -//------------------------------------- 圆角矩形 ----------------------------------------- -void LT768_DrawCircleSquare -( - uint16_t X1 // X1位置 - ,uint16_t Y1 // Y1位置 - ,uint16_t X2 // X2位置 - ,uint16_t Y2 // Y2位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long CircleSquareColor // 画线颜色 -) -{ - Foreground_color_65k(CircleSquareColor); - Square_Start_XY(X1,Y1); - Square_End_XY(X2,Y2); - Circle_Square_Radius_RxRy(X_R,Y_R); - Start_Circle_Square(); - Check_2D_Busy(); -} - -void LT768_DrawCircleSquare_Fill -( - uint16_t X1 // X1位置 - ,uint16_t Y1 // Y1位置 - ,uint16_t X2 // X2位置 - ,uint16_t Y2 // Y2位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long ForegroundColor // 画线颜色 -) -{ - Foreground_color_65k(ForegroundColor); - Square_Start_XY(X1,Y1); - Square_End_XY(X2,Y2); - Circle_Square_Radius_RxRy(X_R,Y_R); - Start_Circle_Square_Fill(); - Check_2D_Busy(); -} - -void LT768_DrawCircleSquare_Width -( - uint16_t X1 // X1位置 - ,uint16_t Y1 // Y1位置 - ,uint16_t X2 // X2位置 - ,uint16_t Y2 // Y2位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long CircleSquareColor // 画线颜色 - ,unsigned long ForegroundColor // 画线颜色 - ,uint16_t Width // 宽度 -) -{ - LT768_DrawCircleSquare_Fill(X1-Width,Y1-Width,X2+Width,Y2+Width,X_R,Y_R,CircleSquareColor); - LT768_DrawCircleSquare_Fill(X1,Y1,X2,Y2,X_R,Y_R,ForegroundColor); -} - -//------------------------------------- 三角形 ----------------------------------------- -void LT768_DrawTriangle -( - uint16_t X1 // X1位置 - ,uint16_t Y1 // Y1位置 - ,uint16_t X2 // X2位置 - ,uint16_t Y2 // Y2位置 - ,uint16_t X3 // X3位置 - ,uint16_t Y3 // Y3位置 - ,unsigned long TriangleColor // 画线颜色 -) -{ - Foreground_color_65k(TriangleColor); - Triangle_Point1_XY(X1,Y1); - Triangle_Point2_XY(X2,Y2); - Triangle_Point3_XY(X3,Y3); - Start_Triangle(); - Check_2D_Busy(); -} - - - -void LT768_DrawTriangle_Fill -( - uint16_t X1 // X1位置 - ,uint16_t Y1 // Y1位置 - ,uint16_t X2 // X2位置 - ,uint16_t Y2 // Y2位置 - ,uint16_t X3 // X3位置 - ,uint16_t Y3 // Y3位置 - ,unsigned long ForegroundColor // 画线颜色 -) -{ - Foreground_color_65k(ForegroundColor); - Triangle_Point1_XY(X1,Y1); - Triangle_Point2_XY(X2,Y2); - Triangle_Point3_XY(X3,Y3); - Start_Triangle_Fill(); - Check_2D_Busy(); -} - -void LT768_DrawTriangle_Frame -( - uint16_t X1 // X1位置 - ,uint16_t Y1 // Y1位置 - ,uint16_t X2 // X2位置 - ,uint16_t Y2 // Y2位置 - ,uint16_t X3 // X3位置 - ,uint16_t Y3 // Y3位置 - ,unsigned long TriangleColor // 画线颜色 - ,unsigned long ForegroundColor // 背景颜色 -) -{ - LT768_DrawTriangle_Fill(X1,Y1,X2,Y2,X3,Y3,ForegroundColor); - LT768_DrawTriangle(X1,Y1,X2,Y2,X3,Y3,TriangleColor); -} - - - -//------------------------------------- 曲线 ----------------------------------------- -void LT768_DrawLeftUpCurve -( - uint16_t XCenter // 曲心X位置 - ,uint16_t YCenter // 曲心Y位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long CurveColor // 画线颜色 -) -{ - Foreground_color_65k(CurveColor); - Ellipse_Center_XY(XCenter,YCenter); - Ellipse_Radius_RxRy(X_R,Y_R); - Start_Left_Up_Curve(); - Check_2D_Busy(); -} - - -void LT768_DrawLeftDownCurve -( - uint16_t XCenter // 曲心X位置 - ,uint16_t YCenter // 曲心Y位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long CurveColor // 画线颜色 -) -{ - Foreground_color_65k(CurveColor); - Ellipse_Center_XY(XCenter,YCenter); - Ellipse_Radius_RxRy(X_R,Y_R); - Start_Left_Down_Curve(); - Check_2D_Busy(); -} - - -void LT768_DrawRightUpCurve -( - uint16_t XCenter // 曲心X位置 - ,uint16_t YCenter // 曲心Y位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long CurveColor // 画线颜色 -) -{ - Foreground_color_65k(CurveColor); - Ellipse_Center_XY(XCenter,YCenter); - Ellipse_Radius_RxRy(X_R,Y_R); - Start_Right_Up_Curve(); - Check_2D_Busy(); -} - - -void LT768_DrawRightDownCurve -( - uint16_t XCenter // 曲心X位置 - ,uint16_t YCenter // 曲心Y位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long CurveColor // 画线颜色 -) -{ - Foreground_color_65k(CurveColor); - Ellipse_Center_XY(XCenter,YCenter); - Ellipse_Radius_RxRy(X_R,Y_R); - Start_Right_Down_Curve(); - Check_2D_Busy(); -} - - -void LT768_SelectDrawCurve -( - uint16_t XCenter // 曲心X位置 - ,uint16_t YCenter // 曲心Y位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long CurveColor // 画线颜色 - ,uint16_t Dir // 方向 -) -{ - switch(Dir) - { - case 0: - LT768_DrawLeftDownCurve(XCenter,YCenter,X_R,Y_R,CurveColor); - break; - - case 1: - LT768_DrawLeftUpCurve(XCenter,YCenter,X_R,Y_R,CurveColor); - break; - - case 2: - LT768_DrawRightUpCurve(XCenter,YCenter,X_R,Y_R,CurveColor); - break; - - case 3: - LT768_DrawRightDownCurve(XCenter,YCenter,X_R,Y_R,CurveColor); - break; - - default: - break; - } -} - - -//------------------------------------- 1/4实心椭圆 ----------------------------------------- -void LT768_DrawLeftUpCurve_Fill -( - uint16_t XCenter // 曲心X位置 - ,uint16_t YCenter // 曲心Y位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long ForegroundColor // 背景颜色 -) -{ - Foreground_color_65k(ForegroundColor); - Ellipse_Center_XY(XCenter,YCenter); - Ellipse_Radius_RxRy(X_R,Y_R); - Start_Left_Up_Curve_Fill(); - Check_2D_Busy(); -} - - -void LT768_DrawLeftDownCurve_Fill -( - uint16_t XCenter // 曲心X位置 - ,uint16_t YCenter // 曲心Y位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long ForegroundColor // 背景颜色 -) -{ - Foreground_color_65k(ForegroundColor); - Ellipse_Center_XY(XCenter,YCenter); - Ellipse_Radius_RxRy(X_R,Y_R); - Start_Left_Down_Curve_Fill(); - Check_2D_Busy(); -} - - -void LT768_DrawRightUpCurve_Fill -( - uint16_t XCenter // 曲心X位置 - ,uint16_t YCenter // 曲心Y位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long ForegroundColor // 背景颜色 -) -{ - Foreground_color_65k(ForegroundColor); - Ellipse_Center_XY(XCenter,YCenter); - Ellipse_Radius_RxRy(X_R,Y_R); - Start_Right_Up_Curve_Fill(); - Check_2D_Busy(); -} - - -void LT768_DrawRightDownCurve_Fill -( - uint16_t XCenter // 曲心X位置 - ,uint16_t YCenter // 曲心Y位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long ForegroundColor // 背景颜色 -) -{ - Foreground_color_65k(ForegroundColor); - Ellipse_Center_XY(XCenter,YCenter); - Ellipse_Radius_RxRy(X_R,Y_R); - Start_Right_Down_Curve_Fill(); - Check_2D_Busy(); -} - - -void LT768_SelectDrawCurve_Fill -( - uint16_t XCenter // 曲心X位置 - ,uint16_t YCenter // 曲心Y位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,unsigned long CurveColor // 画线颜色 - ,uint16_t Dir // 方向 -) -{ - switch(Dir) - { - case 0: - LT768_DrawLeftDownCurve_Fill(XCenter,YCenter,X_R,Y_R,CurveColor); - break; - - case 1: - LT768_DrawLeftUpCurve_Fill(XCenter,YCenter,X_R,Y_R,CurveColor); - break; - - case 2: - LT768_DrawRightUpCurve_Fill(XCenter,YCenter,X_R,Y_R,CurveColor); - break; - - case 3: - LT768_DrawRightDownCurve_Fill(XCenter,YCenter,X_R,Y_R,CurveColor); - break; - - default: - break; - } -} - - - -//------------------------------------- 四边形 ----------------------------------------- - -void LT768_DrawQuadrilateral -( - uint16_t X1 // X1位置 - ,uint16_t Y1 // Y1位置 - ,uint16_t X2 // X2位置 - ,uint16_t Y2 // Y2位置 - ,uint16_t X3 // X3位置 - ,uint16_t Y3 // Y3位置 - ,uint16_t X4 // X4位置 - ,uint16_t Y4 // Y4位置 - ,unsigned long ForegroundColor // 画线颜色 -) -{ - Foreground_color_65k(ForegroundColor); - Triangle_Point1_XY(X1,Y1); - Triangle_Point2_XY(X2,Y2); - Triangle_Point3_XY(X3,Y3); - Ellipse_Radius_RxRy(X4,Y4); - LCD_CmdWrite(0x67); - LCD_DataWrite(0x8d); - Check_Busy_Draw(); - Check_2D_Busy(); -} - - -void LT768_DrawQuadrilateral_Fill -( - uint16_t X1 // X1位置 - ,uint16_t Y1 // Y1位置 - ,uint16_t X2 // X2位置 - ,uint16_t Y2 // Y2位置 - ,uint16_t X3 // X3位置 - ,uint16_t Y3 // Y3位置 - ,uint16_t X4 // X4位置 - ,uint16_t Y4 // Y4位置 - ,unsigned long ForegroundColor // 画线颜色 -) -{ - Foreground_color_65k(ForegroundColor); - Triangle_Point1_XY(X1,Y1); - Triangle_Point2_XY(X2,Y2); - Triangle_Point3_XY(X3,Y3); - Ellipse_Radius_RxRy(X4,Y4); - LCD_CmdWrite(0x67); - LCD_DataWrite(0xa7); - Check_Busy_Draw(); - Check_2D_Busy(); -} - - - -//------------------------------------- 五边形 ----------------------------------------- - -void LT768_DrawPentagon -( - uint16_t X1 // X1位置 - ,uint16_t Y1 // Y1位置 - ,uint16_t X2 // X2位置 - ,uint16_t Y2 // Y2位置 - ,uint16_t X3 // X3位置 - ,uint16_t Y3 // Y3位置 - ,uint16_t X4 // X4位置 - ,uint16_t Y4 // Y4位置 - ,uint16_t X5 // X5位置 - ,uint16_t Y5 // Y5位置 - ,unsigned long ForegroundColor // 画线颜色 -) -{ - Foreground_color_65k(ForegroundColor); - Triangle_Point1_XY(X1,Y1); - Triangle_Point2_XY(X2,Y2); - Triangle_Point3_XY(X3,Y3); - Ellipse_Radius_RxRy(X4,Y4); - Ellipse_Center_XY(X5,Y5); - LCD_CmdWrite(0x67); - LCD_DataWrite(0x8F); - Check_Busy_Draw(); - Check_2D_Busy(); -} - - -void LT768_DrawPentagon_Fill -( - uint16_t X1 // X1位置 - ,uint16_t Y1 // Y1位置 - ,uint16_t X2 // X2位置 - ,uint16_t Y2 // Y2位置 - ,uint16_t X3 // X3位置 - ,uint16_t Y3 // Y3位置 - ,uint16_t X4 // X4位置 - ,uint16_t Y4 // Y4位置 - ,uint16_t X5 // X5位置 - ,uint16_t Y5 // Y5位置 - ,unsigned long ForegroundColor // 画线颜色 -) -{ - Foreground_color_65k(ForegroundColor); - Triangle_Point1_XY(X1,Y1); - Triangle_Point2_XY(X2,Y2); - Triangle_Point3_XY(X3,Y3); - Ellipse_Radius_RxRy(X4,Y4); - Ellipse_Center_XY(X5,Y5); - LCD_CmdWrite(0x67); - LCD_DataWrite(0xa9); - Check_Busy_Draw(); - Check_2D_Busy(); -} - - -//------------------------------------- 圆柱 ----------------------------------------- -uint8_t LT768_DrawCylinder -( - uint16_t XCenter // 椭圆心X位置 - ,uint16_t YCenter // 椭圆心Y位置 - ,uint16_t X_R // 宽半径 - ,uint16_t Y_R // 长半径 - ,uint16_t H // 高度 - ,unsigned long CylinderColor // 画线颜色 - ,unsigned long ForegroundColor // 背景颜色 -) -{ - if(YCenter < H) - { - return 1; - } - - //底面椭圆 - LT768_DrawEllipse_Fill(XCenter,YCenter,X_R,Y_R,ForegroundColor); - LT768_DrawEllipse(XCenter,YCenter,X_R,Y_R,CylinderColor); - //中间矩形 - LT768_DrawSquare_Fill(XCenter-X_R,YCenter-H,XCenter+X_R,YCenter,ForegroundColor); - //顶面椭圆 - LT768_DrawEllipse_Fill(XCenter,YCenter-H,X_R,Y_R,ForegroundColor); - LT768_DrawEllipse(XCenter,YCenter-H,X_R,Y_R,CylinderColor); - LT768_DrawLine(XCenter-X_R,YCenter,XCenter-X_R,YCenter-H,CylinderColor); - LT768_DrawLine(XCenter+X_R,YCenter,XCenter+X_R,YCenter-H,CylinderColor); - return 0; -} - - -//------------------------------------- 四棱柱 ----------------------------------------- -void LT768_DrawQuadrangular -( - uint16_t X1 - ,uint16_t Y1 - ,uint16_t X2 - ,uint16_t Y2 - ,uint16_t X3 - ,uint16_t Y3 - ,uint16_t X4 - ,uint16_t Y4 - ,uint16_t X5 - ,uint16_t Y5 - ,uint16_t X6 - ,uint16_t Y6 - ,unsigned long QuadrangularColor // 画线颜色 - ,unsigned long ForegroundColor // 背景颜色 -) -{ - LT768_DrawSquare_Fill(X1,Y1,X5,Y5,ForegroundColor); - LT768_DrawSquare(X1,Y1,X5,Y5,QuadrangularColor); - LT768_DrawQuadrilateral_Fill(X1,Y1,X2,Y2,X3,Y3,X4,Y4,ForegroundColor); - LT768_DrawQuadrilateral(X1,Y1,X2,Y2,X3,Y3,X4,Y4,QuadrangularColor); - LT768_DrawQuadrilateral_Fill(X3,Y3,X4,Y4,X5,Y5,X6,Y6,ForegroundColor); - LT768_DrawQuadrilateral(X3,Y3,X4,Y4,X5,Y5,X6,Y6,QuadrangularColor); -} - - -//--------------------------------------表格------------------------------------ -void LT768_MakeTable -( - uint16_t X1, // 起始位置X1 - uint16_t Y1, // 起始位置X2 - uint16_t W, // 宽度 - uint16_t H, // 高度 - uint16_t Line, // 行数 - uint16_t Row, // 列数 - unsigned long TableColor, // 线框颜色C1 - unsigned long ItemColor, // 项目拦背景色C2 - unsigned long ForegroundColor, // 内部窗口背景色C3 - uint16_t width1, // 内框宽度 - uint16_t width2, // 外框宽度 - uint8_t mode // 0:项目栏纵向 1:项目栏横向 -) -{ - uint16_t i = 0; - uint16_t x2,y2; - x2 = X1 + W * Row; - y2 = Y1 + H * Line; - LT768_DrawSquare_Width(X1,Y1,x2,y2,TableColor,ForegroundColor,width2); - - if(mode == 0) - { - LT768_DrawSquare_Fill(X1,Y1,X1+W,y2,ItemColor); - } - else if(mode == 1) - { - LT768_DrawSquare_Fill(X1,Y1,x2,Y1+H,ItemColor); - } - - for(i = 0 ; i < Line ; i++) - { - LT768_DrawLine_Width(X1,Y1+i*H,x2,Y1+i*H,TableColor,width1); - } - - for(i = 0 ; i < Row ; i++) - { - LT768_DrawLine_Width(X1+i*W,Y1,X1+i*W,y2,TableColor,width1); - } -} - -/*----------------------------------------------------------------------------*/ - -void LT768_Color_Bar_ON(void) -{ - Color_Bar_ON(); -} - -void LT768_Color_Bar_OFF(void) -{ - Color_Bar_OFF(); -} - -/*----------------------------------------------------------------------------*/ - -/*--Flash-->DMA-->SDRAM--*/ -/*address:24bit or 32bit*/ - -void LT768_DMA_24bit_Linear -( - uint8_t SCS // 选择外挂的SPI : SCS:0 SCS:1 - ,uint8_t Clk // SPI时钟分频参数 : SPI Clock = System Clock /{(Clk+1)*2} - ,unsigned long flash_addr // 要从flash读取数据的起始地址 - ,unsigned long memory_addr // 数据要传输到SDRAM的起始地址 - ,unsigned long data_num // 传输的数据量 -) -{ - Enable_SFlash_SPI(); // 使能SPI功能 - - if(SCS == 0) - { - Select_SFI_0(); // 选择外挂的SPI0 - } - - if(SCS == 1) - { - Select_SFI_1(); // 选择外挂的SPI1 - } - - Memory_Linear_Mode(); - Select_SFI_DMA_Mode(); // 设置SPI的DMA模式 - SPI_Clock_Period(Clk); // SPI速率 - SFI_DMA_Destination_Start_Address(memory_addr); // 指定的内存的开始地址 - SFI_DMA_Transfer_Number(data_num); // DMA传输的数量 - SFI_DMA_Source_Start_Address(flash_addr); // flash地址 - Check_Busy_SFI_DMA(); - Start_SFI_DMA(); - Check_Busy_SFI_DMA(); - Memory_XY_Mode(); -} - -void LT768_DMA_32bit_Linear -( - uint8_t SCS // 选择外挂的SPI : SCS:0 SCS:1 - ,uint8_t Clk // SPI时钟分频参数 : SPI Clock = System Clock /{(Clk+1)*2} - ,unsigned long flash_addr // 要从flash读取数据的起始地址 - ,unsigned long memory_addr // 数据要传输到SDRAM的起始地址 - ,unsigned long data_num // 传输的数据量 -) -{ - Enable_SFlash_SPI(); // 使能SPI功能 - - if(SCS == 0) - { - Select_SFI_0(); // 选择外挂的SPI0 - } - - if(SCS == 1) - { - Select_SFI_1(); // 选择外挂的SPI1 - } - - Memory_Linear_Mode(); - Select_SFI_DMA_Mode(); // 设置SPI的DMA模式 - Select_SFI_32bit_Address(); - SPI_Clock_Period(Clk); // SPI速率 - SFI_DMA_Destination_Start_Address(memory_addr); // 指定的内存的开始地址 - SFI_DMA_Transfer_Number(data_num); // DMA传输的数量 - SFI_DMA_Source_Start_Address(flash_addr); // flash地址 - Check_Busy_SFI_DMA(); - Start_SFI_DMA(); - Check_Busy_SFI_DMA(); - Memory_XY_Mode(); -} - -void LT768_DMA_24bit_Block -( - uint8_t SCS // 选择外挂的SPI : SCS:0 SCS:1 - ,uint8_t Clk // SPI时钟分频参数 : SPI Clock = System Clock /{(Clk+1)*2} - ,uint16_t X1 // 传输到内存X1的位置 - ,uint16_t Y1 // 传输到内存Y1的位置 - ,uint16_t X_W // DMA传输数据的宽度 - ,uint16_t Y_H // DMA传输数据的高度 - ,uint16_t P_W // 图片的宽度 - ,unsigned long Addr // Flash的地址 -) -{ - Enable_SFlash_SPI(); // 使能SPI功能 - - if(SCS == 0) - { - Select_SFI_0(); // 选择外挂的SPI0 - } - - if(SCS == 1) - { - Select_SFI_1(); // 选择外挂的SPI1 - } - - Select_SFI_DMA_Mode(); // 设置SPI的DMA模式 - SPI_Clock_Period(Clk); // 设置SPI的分频系数 - Goto_Pixel_XY(X1,Y1); // 在图形模式中设置内存的位置 - SFI_DMA_Destination_Upper_Left_Corner(X1,Y1); // DMA传输的目的地(内存的位置) - SFI_DMA_Transfer_Width_Height(X_W,Y_H); // 设置块数据的宽度和高度 - SFI_DMA_Source_Width(P_W); // 设置源数据的宽度 - SFI_DMA_Source_Start_Address(Addr); // 设置源数据在Flash的地址 - Start_SFI_DMA(); // 开始DMA传输 - Check_Busy_SFI_DMA(); // 检测DMA是否传输完成 -} - - - -void LT768_DMA_32bit_Block -( - uint8_t SCS // 选择外挂的SPI : SCS:0 SCS:1 - ,uint8_t Clk // SPI时钟分频参数 : SPI Clock = System Clock /{(Clk+1)*2} - ,uint16_t X1 // 内存X1的位置 - ,uint16_t Y1 // 内存Y1的位置 - ,uint16_t X_W // DMA传输数据的宽度 - ,uint16_t Y_H // DMA传输数据的高度 - ,uint16_t P_W // 图片的宽度 - ,unsigned long Addr // Flash的地址 -) -{ - Enable_SFlash_SPI(); - - if(SCS == 0) - { - Select_SFI_0(); - } - - if(SCS == 1) - { - Select_SFI_1(); - } - - Select_SFI_DMA_Mode(); - SPI_Clock_Period(Clk); - Select_SFI_32bit_Address(); - Goto_Pixel_XY(X1,Y1); - SFI_DMA_Destination_Upper_Left_Corner(X1,Y1); - SFI_DMA_Transfer_Width_Height(X_W,Y_H); - SFI_DMA_Source_Width(P_W); - SFI_DMA_Source_Start_Address(Addr); - Start_SFI_DMA(); - Check_Busy_SFI_DMA(); - Select_SFI_24bit_Address(); -} - -/*----------------------------------------------------------------------------*/ -/* 选择内部集成字库初始化 */ -void LT768_Select_Internal_Font_Init -( - uint8_t Size // 设置字体大小 16:16*16 24:24*24 32:32*32 - ,uint8_t XxN // 字体的宽度放大倍数:1~4 - ,uint8_t YxN // 字体的高度放大倍数:1~4 - ,uint8_t ChromaKey // 0:字体背景色透明 1:可以设置字体的背景色 - ,uint8_t Alignment // 0:不字体不对齐 1:字体对齐 -) -{ - if(Size==16) - { - Font_Select_8x16_16x16(); - } - - if(Size==24) - { - Font_Select_12x24_24x24(); - } - - if(Size==32) - { - Font_Select_16x32_32x32(); - } - - //(*) - if(XxN==1) - { - Font_Width_X1(); - } - - if(XxN==2) - { - Font_Width_X2(); - } - - if(XxN==3) - { - Font_Width_X3(); - } - - if(XxN==4) - { - Font_Width_X4(); - } - - //(*) - if(YxN==1) - { - Font_Height_X1(); - } - - if(YxN==2) - { - Font_Height_X2(); - } - - if(YxN==3) - { - Font_Height_X3(); - } - - if(YxN==4) - { - Font_Height_X4(); - } - - //(*) - if(ChromaKey==0) - { - Font_Background_select_Color(); - } - - if(ChromaKey==1) - { - Font_Background_select_Transparency(); - } - - //(*) - if(Alignment==0) - { - Disable_Font_Alignment(); - } - - if(Alignment==1) - { - Enable_Font_Alignment(); - } -} - - -/* 显示内部集成字体 */ -void LT768_Print_Internal_Font_String -( - uint16_t x // 字体开始显示的x位置 - ,uint16_t y // 字体开始显示的y位置 - ,unsigned long FontColor // 字体的颜色 - ,unsigned long BackGroundColor // 字体的背景色(注意:当字体背景初始化成透明时,设置该值无效) - ,char *c // 数据缓冲的首地址 -) -{ - Text_Mode(); - CGROM_Select_Internal_CGROM(); - Foreground_color_65k(FontColor); - Background_color_65k(BackGroundColor); - Goto_Text_XY(x,y); - Show_String(c); -} - - -/* 选择外部集成字库初始化 */ -void LT768_Select_Outside_Font_Init -( - uint8_t SCS // 选择外挂的SPI : SCS:0 SCS:1 - ,uint8_t Clk // SPI时钟分频参数 : SPI Clock = System Clock /{(Clk+1)*2} - ,unsigned long FlashAddr // 源地址(Flash) - ,unsigned long MemoryAddr // 目的地址(SDRAM) - ,unsigned long Num // 字库的数据量大小 - ,uint8_t Size // 设置字体大小 16:16*16 24:24*24 32:32*32 - ,uint8_t XxN // 字体的宽度放大倍数:1~4 - ,uint8_t YxN // 字体的高度放大倍数:1~4 - ,uint8_t ChromaKey // 0:字体背景色透明 1:可以设置字体的背景色 - ,uint8_t Alignment // 0:不字体不对齐 1:字体对齐 -) -{ - if(Size==16) - { - Font_Select_8x16_16x16(); - } - - if(Size==24) - { - Font_Select_12x24_24x24(); - } - - if(Size==32) - { - Font_Select_16x32_32x32(); - } - - //(*) - if(XxN==1) - { - Font_Width_X1(); - } - - if(XxN==2) - { - Font_Width_X2(); - } - - if(XxN==3) - { - Font_Width_X3(); - } - - if(XxN==4) - { - Font_Width_X4(); - } - - //(*) - if(YxN==1) - { - Font_Height_X1(); - } - - if(YxN==2) - { - Font_Height_X2(); - } - - if(YxN==3) - { - Font_Height_X3(); - } - - if(YxN==4) - { - Font_Height_X4(); - } - - //(*) - if(ChromaKey==0) - { - Font_Background_select_Color(); - } - - if(ChromaKey==1) - { - Font_Background_select_Transparency(); - } - - //(*) - if(Alignment==0) - { - Disable_Font_Alignment(); - } - - if(Alignment==1) - { - Enable_Font_Alignment(); - } - - LT768_DMA_24bit_Linear(SCS,Clk,FlashAddr,MemoryAddr,Num); - CGRAM_Start_address(MemoryAddr); -} - -/* 显示外部及内部集成字体 */ -void LT768_Print_Outside_Font_String -( - uint16_t x // 字体开始显示的x位置 - ,uint16_t y // 字体开始显示的y位置 - ,unsigned long FontColor // 字体的颜色 - ,unsigned long BackGroundColor // 字体的背景色(注意:当字体背景初始化成透明时,设置该值无效) - ,uint8_t *c // 数据缓冲的首地址 -) -{ - uint16_t temp_H = 0; - uint16_t temp_L = 0; - uint16_t temp = 0; - unsigned long i = 0; - Text_Mode(); - Font_Select_UserDefine_Mode(); - Foreground_color_65k(FontColor); - Background_color_65k(BackGroundColor); - Goto_Text_XY(x,y); - - while(c[i] != '\0') - { - if(c[i] < 0xa1) - { - CGROM_Select_Internal_CGROM(); // 内部CGROM为字符来源 - LCD_CmdWrite(0x04); - LCD_DataWrite(c[i]); - Check_Mem_WR_FIFO_not_Full(); - i += 1; - } - else - { - Font_Select_UserDefine_Mode(); // 自定义字库 - LCD_CmdWrite(0x04); - temp_H = ((c[i] - 0xa1) & 0x00ff) * 94; - temp_L = c[i+1] - 0xa1; - temp = temp_H + temp_L + 0x8000; - LCD_DataWrite((temp>>8)&0xff); - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite(temp&0xff); - Check_Mem_WR_FIFO_not_Full(); - i += 2; - } - } - - Check_2D_Busy(); - Graphic_Mode(); //back to graphic mode;图形模式 -} - -/* 显示外部GBK及内部集成字体 */ -void LT768_Print_Outside_Font_GBK_String -( - uint16_t x // 字体开始显示的x位置 - ,uint16_t y // 字体开始显示的y位置 - ,unsigned long FontColor // 字体的颜色 - ,unsigned long BackGroundColor // 字体的背景色(注意:当字体背景初始化成透明时,设置该值无效) - ,uint8_t *c // 数据缓冲的首地址 -) -{ - uint16_t temp_H = 0; - uint16_t temp_L = 0; - uint16_t temp = 0; - unsigned long i = 0; - Text_Mode(); - Font_Select_UserDefine_Mode(); - Foreground_color_65k(FontColor); - Background_color_65k(BackGroundColor); - Goto_Text_XY(x,y); - - while(c[i] != '\0') - { - if(c[i] < 0x81) - { - CGROM_Select_Internal_CGROM(); // 内部CGROM为字符来源 - LCD_CmdWrite(0x04); - LCD_DataWrite(c[i]); - Check_Mem_WR_FIFO_not_Full(); - i += 1; - } - else - { - Font_Select_UserDefine_Mode(); // 自定义字库 - LCD_CmdWrite(0x04); - temp_H = ((c[i] - 0x81) & 0x00ff) * 191; - temp_L = c[i+1] - 0x40; - temp = temp_H + temp_L + 0x8000; - LCD_DataWrite((temp>>8)&0xff); - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite(temp&0xff); - Check_Mem_WR_FIFO_not_Full(); - i += 2; - } - } - - Check_2D_Busy(); - Graphic_Mode(); //back to graphic mode;图形模式 -} - -/*显示48*48、72*72字库*/ -void LT768_BTE_Memory_Copy_ColorExpansion_8 -( - unsigned long S0_Addr // SO图像的内存起始地址 - ,uint16_t YS0 // S0图像的左上方Y坐标 - ,unsigned long Des_Addr // 目的图像的内存起始地址 - ,uint16_t Des_W // 目的图像的宽度 - ,uint16_t XDes // 目的图像的左上方X坐标(显示窗口的起始x坐标) - ,uint16_t YDes // 目的图像的左上方Y坐标(显示窗口的起始y坐标) - ,uint16_t X_W // 显示窗口的宽度 - ,uint16_t Y_H // 显示窗口的长度 - ,unsigned long Foreground_color - ,unsigned long Background_color -) -{ - Foreground_color_256(Foreground_color); - Background_color_256(Background_color); - BTE_ROP_Code(7); - BTE_S0_Color_8bpp(); - BTE_S0_Memory_Start_Address(S0_Addr); - BTE_S0_Image_Width(Des_W); - BTE_S0_Window_Start_XY(YS0,0); - BTE_Destination_Color_16bpp(); - BTE_Destination_Memory_Start_Address(Des_Addr); - BTE_Destination_Image_Width(Des_W); - BTE_Destination_Window_Start_XY(XDes,YDes); - BTE_Operation_Code(0x0e); //BTE Operation: Memory copy (move) with chroma keying (w/o ROP) - BTE_Window_Size(X_W,Y_H); - BTE_Enable(); - Check_BTE_Busy(); -} - -void LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8 -( - unsigned long S0_Addr // SO图像的内存起始地址 - ,uint16_t YS0 // S0图像的左上方Y坐标 - ,unsigned long Des_Addr // 目的图像的内存起始地址 - ,uint16_t Des_W // 目的图像的宽度 - ,uint16_t XDes // 目的图像的左上方X坐标(显示窗口的起始x坐标) - ,uint16_t YDes // 目的图像的左上方Y坐标(显示窗口的起始y坐标) - ,uint16_t X_W // 显示窗口的宽度 - ,uint16_t Y_H // 显示窗口的长度 - ,unsigned long Foreground_color -) -{ - Foreground_color_256(Foreground_color); - BTE_ROP_Code(7); - BTE_S0_Color_8bpp(); - BTE_S0_Memory_Start_Address(S0_Addr); - BTE_S0_Image_Width(Des_W); - BTE_S0_Window_Start_XY(YS0,0); - BTE_Destination_Color_16bpp(); - BTE_Destination_Memory_Start_Address(Des_Addr); - BTE_Destination_Image_Width(Des_W); - BTE_Destination_Window_Start_XY(XDes,YDes); - BTE_Operation_Code(0x0f); //BTE Operation: Memory copy (move) with chroma keying (w/o ROP) - BTE_Window_Size(X_W,Y_H); - BTE_Enable(); - Check_BTE_Busy(); -} - -void LT768_Print_Outside_Font_GB2312_48_72 -( - uint8_t SCS // 选择外挂的SPI : SCS:0 SCS:1 - ,uint8_t Clk // SPI时钟分频参数 : SPI Clock = System Clock /{(Clk+1)*2} - ,unsigned long FlashAddr // 字库源地址(Flash) - ,unsigned long MemoryAddr // 目的地址(SDRAM) - ,unsigned long ShowAddr // 显示层的地址 - ,uint16_t width // 显示层的宽度 - ,uint8_t Size // 设置字体大小 48:48*48 72:72*72 - ,uint8_t ChromaKey // 0:字体背景色透明 1:可以设置字体的背景色 - ,uint16_t x // 字体开始显示的x位置 - ,uint16_t y // 字体开始显示的y位置 - ,unsigned long FontColor // 字体的颜色 - ,unsigned long BackGroundColor // 字体的背景色(注意:当字体背景初始化成透明时,设置该值无效) - ,uint16_t w // 字体粗细:0:不加粗 1:加粗1级 2:加粗2级 - ,uint16_t s // 行距 - ,uint8_t *c // 数据缓冲的首地址 -) -{ - uint16_t temp_H = 0; - uint16_t temp_L = 0; - uint16_t temp = 0; - unsigned long i = 0; - uint16_t j = 0; - uint16_t k = 0; - uint16_t h = 0; - uint16_t n = 0; - uint16_t m = 0; - uint16_t g = 0; - uint16_t f = 0; - h = x; - k = y; - Memory_8bpp_Mode();//使用8位色深来存储图片 - Canvas_Image_Start_address(MemoryAddr); - Canvas_image_width(width); - - while(c[i] != '\0') - { - temp_H = (c[i] - 0xa1) * 94; - temp_L = c[i+1] - 0xa1; - temp = temp_H + temp_L; - LT768_DMA_24bit_Block(SCS,Clk,Size*j/8,0,Size/8,Size,Size/8,FlashAddr+temp*((Size*Size)/8)); - i+=2; - j++; - } - - Memory_16bpp_Mode(); - Canvas_Image_Start_address(ShowAddr); - Canvas_image_width(width); - j = 0; - i = 0; - - if(w>2) - { - w = 2; - } - - for(g=0; g(width*(n+1)))) - { - m++; - n++; - y=y+Size-1+s; - x = x+((width*n)-(x+Size*j))+g; - f=n; - } - - if(ChromaKey==1) - { - LT768_BTE_Memory_Copy_ColorExpansion_8(MemoryAddr,Size*j/8, - ShowAddr,width,x+Size*j,y, - Size,Size,FontColor,BackGroundColor - ); - } - - if(ChromaKey==0) - { - LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8(MemoryAddr,Size*j/8, - ShowAddr,width,x+Size*j,y, - Size,Size,FontColor - ); - } - - i+=2; - j++; - } - - ChromaKey=0; - i=0; - j=0; - m=0; - n=0; - f=0; - x=h+g+1; - y=k+g+1; - } -} - - -void LT768_Print_Outside_Font_BIG5_48_72 -( - uint8_t SCS // 选择外挂的SPI : SCS:0 SCS:1 - ,uint8_t Clk // SPI时钟分频参数 : SPI Clock = System Clock /{(Clk+1)*2} - ,unsigned long FlashAddr // 字库源地址(Flash) - ,unsigned long MemoryAddr // 目的地址(SDRAM) - ,unsigned long ShowAddr // 显示层的地址 - ,uint16_t width // 显示层的宽度 - ,uint8_t Size // 设置字体大小 48:48*48 72:72*72 - ,uint8_t ChromaKey // 0:字体背景色透明 1:可以设置字体的背景色 - ,uint16_t x // 字体开始显示的x位置 - ,uint16_t y // 字体开始显示的y位置 - ,unsigned long FontColor // 字体的颜色 - ,unsigned long BackGroundColor // 字体的背景色(注意:当字体背景初始化成透明时,设置该值无效) - ,uint16_t w // 字体粗细:0:不加粗 1:加粗1级 2:加粗2级 - ,uint16_t s // 行距 - ,uint8_t *c // 数据缓冲的首地址 -) -{ - uint16_t temp_H = 0; - uint16_t temp_L = 0; - uint16_t temp = 0; - unsigned long i = 0; - uint16_t j = 0; - uint16_t k = 0; - uint16_t h = 0; - uint16_t n = 0; - uint16_t m = 0; - uint16_t g = 0; - uint16_t f = 0; - h = x; - k = y; - Memory_8bpp_Mode();//使用8位色深来存储图片 - Canvas_Image_Start_address(MemoryAddr); - Canvas_image_width(width); - - while(c[i] != '\0') - { - temp_H = (c[i] - 0xa1) * 160; - - if(c[i+1]<0x7f) - { - temp_L = c[i+1] - 0x40; - } - else - { - temp_L = c[i+1] - 0xa0 + 0x40; - } - - temp = temp_H + temp_L; - LT768_DMA_24bit_Block(SCS,Clk,Size*j/8,0,Size/8,Size,Size/8,FlashAddr+temp*((Size*Size)/8)); - i+=2; - j++; - } - - Memory_16bpp_Mode(); // 因为显示是16位的色深,所以需要转为16位色深 - Canvas_Image_Start_address(ShowAddr); - Canvas_image_width(width); - j = 0; - i = 0; - - for(g=0; g(1024*(n+1)))) - { - m++; - n++; - y=y+Size-1+s; - x = x+((1024*n)-(x+Size*j))+g; - f=n; - } - - if(ChromaKey==1) - { - LT768_BTE_Memory_Copy_ColorExpansion_8(MemoryAddr,Size*j/8, - ShowAddr,LCD_XSIZE_TFT,x+Size*j,y, - Size,Size,FontColor,BackGroundColor - ); - } - - if(ChromaKey==0) - { - LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8(MemoryAddr,Size*j/8, - ShowAddr,LCD_XSIZE_TFT,x+Size*j,y, - Size,Size,FontColor - ); - } - - i+=2; - j++; - } - - ChromaKey=0; - i=0; - j=0; - m=0; - n=0; - f=0; - x=h+g+1; - y=k+g+1; - } -} - -void LT768_Print_Outside_Font_GBK_48_72 -( - uint8_t SCS // 选择外挂的SPI : SCS:0 SCS:1 - ,uint8_t Clk // SPI时钟分频参数 : SPI Clock = System Clock /{(Clk+1)*2} - ,unsigned long FlashAddr // 字库源地址(Flash) - ,unsigned long MemoryAddr // 目的地址(SDRAM) - ,unsigned long ShowAddr // 显示层的地址 - ,uint16_t width // 显示层的宽度 - ,uint8_t Size // 设置字体大小 48:48*48 72:72*72 - ,uint8_t ChromaKey // 0:字体背景色透明 1:可以设置字体的背景色 - ,uint16_t x // 字体开始显示的x位置 - ,uint16_t y // 字体开始显示的y位置 - ,unsigned long FontColor // 字体的颜色 - ,unsigned long BackGroundColor // 字体的背景色(注意:当字体背景初始化成透明时,设置该值无效) - ,uint16_t w // 字体粗细:0:不加粗 1:加粗1级 2:加粗2级 - ,uint16_t s // 行距 - ,uint8_t *c // 数据缓冲的首地址 -) -{ - uint16_t temp_H = 0; - uint16_t temp_L = 0; - uint16_t temp = 0; - unsigned long i = 0; - uint16_t j = 0; - uint16_t k = 0; - uint16_t h = 0; - uint16_t n = 0; - uint16_t m = 0; - uint16_t g = 0; - uint16_t f = 0; - h = x; - k = y; - Memory_8bpp_Mode();//使用8位色深来存储图片 - Canvas_Image_Start_address(MemoryAddr); - Canvas_image_width(width); - - while(c[i] != '\0') - { - temp_H = (c[i] - 0x81) * 191; - temp_L = c[i+1] - 0x40; - temp = temp_H + temp_L; - LT768_DMA_24bit_Block(SCS,Clk,Size*j/8,0,Size/8,Size,Size/8,FlashAddr+temp*((Size*Size)/8)); - i+=2; - j++; - } - - Memory_16bpp_Mode(); - Canvas_Image_Start_address(ShowAddr); - Canvas_image_width(width); - j = 0; - i = 0; - - if(w>2) - { - w = 2; - } - - for(g=0; g(width*(n+1)))) - { - m++; - n++; - y=y+Size-1+s; - x = x+((width*n)-(x+Size*j))+g; - f=n; - } - - if(ChromaKey==1) - { - LT768_BTE_Memory_Copy_ColorExpansion_8(MemoryAddr,Size*j/8, - ShowAddr,width,x+Size*j,y, - Size,Size,FontColor,BackGroundColor - ); - } - - if(ChromaKey==0) - { - LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8(MemoryAddr,Size*j/8, - ShowAddr,width,x+Size*j,y, - Size,Size,FontColor - ); - } - - i+=2; - j++; - } - - ChromaKey=0; - i=0; - j=0; - m=0; - n=0; - f=0; - x=h+g+1; - y=k+g+1; - } -} - -/*自定义字库*/ -//只能输入中文字 -#define Font_size 200//定义字库大小,200:最多200个字 -#define Font_BYTE Font_size*2 -uint8_t Font_1[Font_BYTE]; - -void clear_Font_1(void) -{ - uint16_t i; - - for(i = 0; i < Font_BYTE; i++) - { - Font_1[i] = 0; - } -} - -int Get_User_Font_P(char chH,char chL) -{ - int i; - - for(i=0; i<(sizeof(Font_1)/2); i++) - { - if((chH == Font_1[i*2])&&(chL == Font_1[i*2+1])) - { - return i; - } - } - - return -1; -} - -void LT768_Print_Outside_UserDefineFont_GB2312 -( - uint8_t SCS // 选择外挂的SPI : SCS:0 SCS:1 - ,uint8_t Clk // SPI时钟分频参数 : SPI Clock = System Clock /{(Clk+1)*2} - ,unsigned long FlashAddr // 字库源地址(Flash) - ,unsigned long MemoryAddr // 目的地址(SDRAM) - ,unsigned long ShowAddr // 显示层的地址 - ,uint16_t width // 显示层的宽度 - ,uint8_t Size // 设置字体大小 48:48*48 72:72*72 - ,uint8_t ChromaKey // 0:字体背景色透明 1:可以设置字体的背景色 - ,uint16_t x // 字体开始显示的x位置 - ,uint16_t y // 字体开始显示的y位置 - ,unsigned long FontColor // 字体的颜色 - ,unsigned long BackGroundColor // 字体的背景色(注意:当字体背景初始化成透明时,设置该值无效) - ,uint16_t w // 字体粗细:0:不加粗 1:加粗1级 2:加粗2级 - ,uint16_t s // 行距 - ,uint8_t *c // 数据缓冲的首地址 -) -{ - short temp = 0; - unsigned long i = 0; - uint16_t j = 0; - uint16_t k = 0; - uint16_t h = 0; - uint16_t n = 0; - uint16_t m = 0; - uint16_t g = 0; - uint16_t f = 0; - uint8_t temp1[2] = {0}; - uint32_t fontNum = 0; - clear_Font_1(); - LT768_SPI_Init(SCS,1); - LT_W25QXX_Read(temp1,FlashAddr+8,2); - fontNum = (temp1[0]<<8)+temp1[1]; - LT_W25QXX_Read(Font_1,FlashAddr + 0xc,fontNum * 2); - h = x; - k = y; - Memory_8bpp_Mode();//使用8位色深来存储图片 - Canvas_Image_Start_address(MemoryAddr); - Canvas_image_width(width); - - while(c[i] != '\0') - { - temp = Get_User_Font_P(c[i],c[i+1]); - - if(temp>-1) - { - LT768_DMA_24bit_Block(SCS,Clk,Size*j/8,0,Size/8,Size,Size/8,FlashAddr+temp*((Size*Size)/8)+0x0c+fontNum*2); - } - - i+=2; - j++; - } - - Memory_16bpp_Mode(); - Canvas_Image_Start_address(ShowAddr); - Canvas_image_width(width); - j = 0; - i = 0; - - if(w>2) - { - w = 2; - } - - for(g=0; g(width*(n+1)))) - { - m++; - n++; - y=y+Size-1+s; - x = x+((width*n)-(x+Size*j))+g; - f=n; - } - - if(ChromaKey==1) - { - LT768_BTE_Memory_Copy_ColorExpansion_8(MemoryAddr,Size*j/8, - ShowAddr,width,x+Size*j,y, - Size,Size,FontColor,BackGroundColor - ); - } - - if(ChromaKey==0) - { - LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8(MemoryAddr,Size*j/8, - ShowAddr,width,x+Size*j,y, - Size,Size,FontColor - ); - } - - i+=2; - j++; - } - - ChromaKey=0; - i=0; - j=0; - m=0; - n=0; - f=0; - x=h+g+1; - y=k+g+1; - } -} - -/*----------------------------------------------------------------------------*/ - -void LT768_Text_cursor_Init -( - uint8_t On_Off_Blinking // 0:禁止光标闪烁 1:使能光标闪烁 - ,uint16_t Blinking_Time // 设置文字光标闪烁时间 - ,uint16_t X_W // 文字光标水平大小 - ,uint16_t Y_W // 文字光标垂直大小 -) -{ - if(On_Off_Blinking == 0) - { - Disable_Text_Cursor_Blinking(); - } - - if(On_Off_Blinking == 1) - { - Enable_Text_Cursor_Blinking(); - } - - Blinking_Time_Frames(Blinking_Time); - //[3E][3Fh] - Text_Cursor_H_V(X_W,Y_W); - Enable_Text_Cursor(); -} - - -void LT768_Enable_Text_Cursor(void) -{ - Enable_Text_Cursor(); -} - - -void LT768_Disable_Text_Cursor(void) -{ - Disable_Text_Cursor(); -} - - -void LT768_Graphic_cursor_Init -( - uint8_t Cursor_N // 选择光标 1:光标1 2:光标2 3:光标3 4:光标4 - ,uint8_t Color1 // 颜色1 - ,uint8_t Color2 // 颜色2 - ,uint16_t X_Pos // 显示坐标X - ,uint16_t Y_Pos // 显示坐标Y - ,uint8_t *Cursor_Buf // 光标数据的缓冲首地址 -) -{ - uint32_t i ; - Memory_Select_Graphic_Cursor_RAM(); - Graphic_Mode(); - - switch(Cursor_N) - { - case 1: - Select_Graphic_Cursor_1(); - break; - - case 2: - Select_Graphic_Cursor_2(); - break; - - case 3: - Select_Graphic_Cursor_3(); - break; - - case 4: - Select_Graphic_Cursor_4(); - break; - - default: - break; - } - - LCD_CmdWrite(0x04); - - for(i=0; i<256; i++) - { - LCD_DataWrite(Cursor_Buf[i]); - } - - Memory_Select_SDRAM();//写完后切回SDRAM - Set_Graphic_Cursor_Color_1(Color1); - Set_Graphic_Cursor_Color_2(Color2); - Graphic_Cursor_XY(X_Pos,Y_Pos); - Enable_Graphic_Cursor(); -} - - -void LT768_Set_Graphic_cursor_Pos -( - uint8_t Cursor_N // 选择光标 1:光标1 2:光标2 3:光标3 4:光标4 - ,uint16_t X_Pos // 显示坐标X - ,uint16_t Y_Pos // 显示坐标Y -) -{ - Graphic_Cursor_XY(X_Pos,Y_Pos); - - switch(Cursor_N) - { - case 1: - Select_Graphic_Cursor_1(); - break; - - case 2: - Select_Graphic_Cursor_2(); - break; - - case 3: - Select_Graphic_Cursor_3(); - break; - - case 4: - Select_Graphic_Cursor_4(); - break; - - default: - break; - } -} - - -void LT768_Enable_Graphic_Cursor(void) -{ - Enable_Graphic_Cursor(); -} - - -void LT768_Disable_Graphic_Cursor(void) -{ - Disable_Graphic_Cursor(); -} - -/*----------------------------------------------------------------------------*/ - -void LT768_PIP_Init -( - uint8_t On_Off // 0 : 禁止 PIP 1 : 使能 PIP 2 : 保持原来的状态 - ,uint8_t Select_PIP // 1 : 使用 PIP1 2 : 使用 PIP2 - ,unsigned long PAddr // PIP的开始地址 - ,uint16_t XP // PIP窗口的X坐标,必须被4整除 - ,uint16_t YP // PIP窗口的Y坐标,必须被4整除 - ,unsigned long ImageWidth // 底图的宽度 - ,uint16_t X_Dis // 显示窗口的X坐标 - ,uint16_t Y_Dis // 显示窗口的Y坐标 - ,uint16_t X_W // 显示窗口的宽度,必须被4整除 - ,uint16_t Y_H // 显示窗口的长度,必须被4整除 -) -{ - if(Select_PIP == 1) - { - Select_PIP1_Window_16bpp(); - Select_PIP1_Parameter(); - } - - if(Select_PIP == 2) - { - Select_PIP2_Window_16bpp(); - Select_PIP2_Parameter(); - } - - PIP_Display_Start_XY(X_Dis,Y_Dis); - PIP_Image_Start_Address(PAddr); - PIP_Image_Width(ImageWidth); - PIP_Window_Image_Start_XY(XP,YP); - PIP_Window_Width_Height(X_W,Y_H); - - if(On_Off == 0) - { - if(Select_PIP == 1) - { - Disable_PIP1(); - } - - if(Select_PIP == 2) - { - Disable_PIP2(); - } - } - - if(On_Off == 1) - { - if(Select_PIP == 1) - { - Enable_PIP1(); - } - - if(Select_PIP == 2) - { - Enable_PIP2(); - } - } -} - - -void LT768_Set_DisWindowPos -( - uint8_t On_Off // 0 : 禁止 PIP, 1 : 使能 PIP, 2 : 保持原来的状态 - ,uint8_t Select_PIP // 1 : 使用 PIP1 , 2 : 使用 PIP2 - ,uint16_t X_Dis // 显示窗口的X坐标 - ,uint16_t Y_Dis // 显示窗口的Y坐标 -) -{ - if(Select_PIP == 1) - { - Select_PIP1_Parameter(); - } - - if(Select_PIP == 2) - { - Select_PIP2_Parameter(); - } - - if(On_Off == 0) - { - if(Select_PIP == 1) - { - Disable_PIP1(); - } - - if(Select_PIP == 2) - { - Disable_PIP2(); - } - } - - if(On_Off == 1) - { - if(Select_PIP == 1) - { - Enable_PIP1(); - } - - if(Select_PIP == 2) - { - Enable_PIP2(); - } - } - - PIP_Display_Start_XY(X_Dis,Y_Dis); -} - -/*----------------------------------------------------------------------------*/ - -void BTE_Solid_Fill -( - unsigned long Des_Addr // 填充的目的地址 - ,uint16_t Des_W // 目的地址图片宽度 - ,uint16_t XDes // x坐标 - ,uint16_t YDes // y坐标 - ,uint16_t color // 填充的颜色 - ,uint16_t X_W // 填充的长度 - ,uint16_t Y_H // 填充的宽度 -) -{ - BTE_Destination_Color_16bpp(); - BTE_Destination_Memory_Start_Address(Des_Addr); - BTE_Destination_Image_Width(Des_W); - BTE_Destination_Window_Start_XY(XDes,YDes); - BTE_Window_Size(X_W,Y_H); - Foreground_color_65k(color); - BTE_Operation_Code(0x0c); - BTE_Enable(); - Check_BTE_Busy(); -} - -/* 结合光栅操作的BTE内存复制 */ -void LT768_BTE_Memory_Copy -( - unsigned long S0_Addr // SO图像的内存起始地址 - ,uint16_t S0_W // S0图像的宽度 - ,uint16_t XS0 // S0图像的左上方X坐标 - ,uint16_t YS0 // S0图像的左上方Y坐标 - ,unsigned long S1_Addr // S1图像的内存起始地址 - ,uint16_t S1_W // S1图像的宽度 - ,uint16_t XS1 // S1图像的左上方X坐标 - ,uint16_t YS1 // S1图像的左上方Y坐标 - ,unsigned long Des_Addr // 目的图像的内存起始地址 - ,uint16_t Des_W // 目的图像的宽度 - ,uint16_t XDes // 目的图像的左上方X坐标 - ,uint16_t YDes // 目的图像的左上方Y坐标 - ,uint32_t ROP_Code // 光栅操作模式 - /*ROP_Code : - 0000b 0(Blackness) - 0001b ~S0!E~S1 or ~(S0+S1) - 0010b ~S0!ES1 - 0011b ~S0 - 0100b S0!E~S1 - 0101b ~S1 - 0110b S0^S1 - 0111b ~S0 + ~S1 or ~(S0 + S1) - 1000b S0!ES1 - 1001b ~(S0^S1) - 1010b S1 - 1011b ~S0+S1 - 1100b S0 - 1101b S0+~S1 - 1110b S0+S1 - 1111b 1(whiteness)*/ - ,uint16_t X_W // 活动窗口的宽度 - ,uint16_t Y_H // 活动窗口的长度 -) -{ - BTE_S0_Color_16bpp(); - BTE_S0_Memory_Start_Address(S0_Addr); - BTE_S0_Image_Width(S0_W); - BTE_S0_Window_Start_XY(XS0,YS0); - BTE_S1_Color_16bpp(); - BTE_S1_Memory_Start_Address(S1_Addr); - BTE_S1_Image_Width(S1_W); - BTE_S1_Window_Start_XY(XS1,YS1); - BTE_Destination_Color_16bpp(); - BTE_Destination_Memory_Start_Address(Des_Addr); - BTE_Destination_Image_Width(Des_W); - BTE_Destination_Window_Start_XY(XDes,YDes); - BTE_ROP_Code(ROP_Code); - BTE_Operation_Code(0x02); //BTE Operation: Memory copy (move) with ROP. - BTE_Window_Size(X_W,Y_H); - BTE_Enable(); - Check_BTE_Busy(); -} - - -/* 结合 Chroma Key 的内存复制(不含 ROP) */ -void LT768_BTE_Memory_Copy_Chroma_key -( - unsigned long S0_Addr // SO图像的内存起始地址 - ,uint16_t S0_W // S0图像的宽度 - ,uint16_t XS0 // S0图像的左上方X坐标 - ,uint16_t YS0 // S0图像的左上方Y坐标 - ,unsigned long Des_Addr // 目的图像的内存起始地址 - ,uint16_t Des_W // 目的图像的宽度 - ,uint16_t XDes // 目的图像的左上方X坐标 - ,uint16_t YDes // 目的图像的左上方X坐标 - ,unsigned long Background_color // 透明色 - ,uint16_t X_W // 活动窗口的宽度 - ,uint16_t Y_H // 活动窗口的长度 -) -{ - Background_color_65k(Background_color); - BTE_S0_Color_16bpp(); - BTE_S0_Memory_Start_Address(S0_Addr); - BTE_S0_Image_Width(S0_W); - BTE_S0_Window_Start_XY(XS0,YS0); - BTE_Destination_Color_16bpp(); - BTE_Destination_Memory_Start_Address(Des_Addr); - BTE_Destination_Image_Width(Des_W); - BTE_Destination_Window_Start_XY(XDes,YDes); - BTE_Operation_Code(0x05); //BTE Operation: Memory copy (move) with chroma keying (w/o ROP) - BTE_Window_Size(X_W,Y_H); - BTE_Enable(); - Check_BTE_Busy(); -} - - -void LT768_BTE_Pattern_Fill -( - uint8_t P_8x8_or_16x16 // 0 : use 8x8 Icon , 1 : use 16x16 Icon. - ,unsigned long S0_Addr // SO图像的内存起始地址 - ,uint16_t S0_W // S0图像的宽度 - ,uint16_t XS0 // S0图像的左上方X坐标 - ,uint16_t YS0 // S0图像的左上方Y坐标 - ,unsigned long Des_Addr // 目的图像的内存起始地址 - ,uint16_t Des_W // 目的图像的宽度 - , uint16_t XDes // 目的图像的左上方X坐标 - ,uint16_t YDes // 目的图像的左上方X坐标 - ,uint32_t ROP_Code // 光栅操作模式 - /*ROP_Code : - 0000b 0(Blackness) - 0001b ~S0!E~S1 or ~(S0+S1) - 0010b ~S0!ES1 - 0011b ~S0 - 0100b S0!E~S1 - 0101b ~S1 - 0110b S0^S1 - 0111b ~S0 + ~S1 or ~(S0 + S1) - 1000b S0!ES1 - 1001b ~(S0^S1) - 1010b S1 - 1011b ~S0+S1 - 1100b S0 - 1101b S0+~S1 - 1110b S0+S1 - 1111b 1(whiteness)*/ - ,uint16_t X_W // 活动窗口的宽度 - ,uint16_t Y_H // 活动窗口的长度 -) -{ - if(P_8x8_or_16x16 == 0) - { - Pattern_Format_8X8(); - } - - if(P_8x8_or_16x16 == 1) - { - Pattern_Format_16X16(); - } - - BTE_S0_Color_16bpp(); - BTE_S0_Memory_Start_Address(S0_Addr); - BTE_S0_Image_Width(S0_W); - BTE_S0_Window_Start_XY(XS0,YS0); - BTE_Destination_Color_16bpp(); - BTE_Destination_Memory_Start_Address(Des_Addr); - BTE_Destination_Image_Width(Des_W); - BTE_Destination_Window_Start_XY(XDes,YDes); - BTE_ROP_Code(ROP_Code); - BTE_Operation_Code(0x06); //BTE Operation: Pattern Fill with ROP. - BTE_Window_Size(X_W,Y_H); - BTE_Enable(); - Check_BTE_Busy(); -} - - - -void LT768_BTE_Pattern_Fill_With_Chroma_key -( - uint8_t P_8x8_or_16x16 // 0 : use 8x8 Icon , 1 : use 16x16 Icon. - ,unsigned long S0_Addr // SO图像的内存起始地址 - ,uint16_t S0_W // S0图像的宽度 - ,uint16_t XS0 // S0图像的左上方X坐标 - ,uint16_t YS0 // S0图像的左上方Y坐标 - ,unsigned long Des_Addr // 目的图像的内存起始地址 - ,uint16_t Des_W // 目的图像的宽度 - ,uint16_t XDes // 目的图像的左上方X坐标 - ,uint16_t YDes // 目的图像的左上方Y坐标 - ,uint32_t ROP_Code // 光栅操作模式 - /*ROP_Code : - 0000b 0(Blackness) - 0001b ~S0!E~S1 or ~(S0+S1) - 0010b ~S0!ES1 - 0011b ~S0 - 0100b S0!E~S1 - 0101b ~S1 - 0110b S0^S1 - 0111b ~S0 + ~S1 or ~(S0 + S1) - 1000b S0!ES1 - 1001b ~(S0^S1) - 1010b S1 - 1011b ~S0+S1 - 1100b S0 - 1101b S0+~S1 - 1110b S0+S1 - 1111b 1(whiteness)*/ - ,unsigned long Background_color // 透明色 - ,uint16_t X_W // 活动窗口的宽度 - ,uint16_t Y_H // 活动窗口的长度 -) -{ - Background_color_65k(Background_color); - - if(P_8x8_or_16x16 == 0) - { - Pattern_Format_8X8(); - } - - if(P_8x8_or_16x16 == 1) - { - Pattern_Format_16X16(); - } - - BTE_S0_Color_16bpp(); - BTE_S0_Memory_Start_Address(S0_Addr); - BTE_S0_Image_Width(S0_W); - BTE_S0_Window_Start_XY(XS0,YS0); - BTE_Destination_Color_16bpp(); - BTE_Destination_Memory_Start_Address(Des_Addr); - BTE_Destination_Image_Width(Des_W); - BTE_Destination_Window_Start_XY(XDes,YDes); - BTE_ROP_Code(ROP_Code); - BTE_Operation_Code(0x07); //BTE Operation: Pattern Fill with Chroma key. - BTE_Window_Size(X_W,Y_H); - BTE_Enable(); - Check_BTE_Busy(); -} - - - -void LT768_BTE_MCU_Write_MCU_16bit -( - unsigned long S1_Addr // S1图像的内存起始地址 - ,uint16_t S1_W // S1图像的宽度 - ,uint16_t XS1 // S1图像的左上方X坐标 - ,uint16_t YS1 // S1图像的左上方Y坐标 - ,unsigned long Des_Addr // 目的图像的内存起始地址 - ,uint16_t Des_W // 目的图像的宽度 - ,uint16_t XDes // 目的图像的左上方X坐标 - ,uint16_t YDes // 目的图像的左上方Y坐标 - ,uint32_t ROP_Code // 光栅操作模式 - /*ROP_Code : - 0000b 0(Blackness) - 0001b ~S0!E~S1 or ~(S0+S1) - 0010b ~S0!ES1 - 0011b ~S0 - 0100b S0!E~S1 - 0101b ~S1 - 0110b S0^S1 - 0111b ~S0 + ~S1 or ~(S0 + S1) - 1000b S0!ES1 - 1001b ~(S0^S1) - 1010b S1 - 1011b ~S0+S1 - 1100b S0 - 1101b S0+~S1 - 1110b S0+S1 - 1111b 1(whiteness)*/ - ,uint16_t X_W // 活动窗口的宽度 - ,uint16_t Y_H // 活动窗口的长度 - ,const uint16_t *data // S0的数据首地址 -) -{ - uint16_t i,j; - BTE_S1_Color_16bpp(); - BTE_S1_Memory_Start_Address(S1_Addr); - BTE_S1_Image_Width(S1_W); - BTE_S1_Window_Start_XY(XS1,YS1); - BTE_Destination_Color_16bpp(); - BTE_Destination_Memory_Start_Address(Des_Addr); - BTE_Destination_Image_Width(Des_W); - BTE_Destination_Window_Start_XY(XDes,YDes); - BTE_Window_Size(X_W,Y_H); - BTE_ROP_Code(ROP_Code); - BTE_Operation_Code(0x00); //BTE Operation: MPU Write with ROP. - BTE_Enable(); - BTE_S0_Color_16bpp(); - LCD_CmdWrite(0x04); //Memory Data Read/Write Port - - //MCU_16bit_ColorDepth_16bpp - for(i=0; i< Y_H; i++) - { - for(j=0; j< (X_W); j++) - { - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite_Pixel((*data)); - data++; - } - } - - Check_Mem_WR_FIFO_Empty(); - Check_BTE_Busy(); -} - - - -void LT768_BTE_MCU_Write_Chroma_key_MCU_16bit -( - unsigned long Des_Addr // 目的图像的内存起始地址 - ,uint16_t Des_W // 目的图像的宽度 - ,uint16_t XDes // 目的图像的左上方X坐标 - ,uint16_t YDes // 目的图像的左上方Y坐标 - ,unsigned long Background_color // 透明色 - ,uint16_t X_W // 活动窗口的宽度 - ,uint16_t Y_H // 活动窗口的长度 - ,const uint16_t *data // S0的数据收地址 -) -{ - uint32_t i,j; - Background_color_65k(Background_color); - BTE_Destination_Color_16bpp(); - BTE_Destination_Memory_Start_Address(Des_Addr); - BTE_Destination_Image_Width(Des_W); - BTE_Destination_Window_Start_XY(XDes,YDes); - BTE_Window_Size(X_W,Y_H); - BTE_Operation_Code(0x04); //BTE Operation: MPU Write with chroma keying (w/o ROP) - BTE_Enable(); - BTE_S0_Color_16bpp(); - LCD_CmdWrite(0x04); //Memory Data Read/Write Port - - //MCU_16bit_ColorDepth_16bpp - for(i=0; i< Y_H; i++) - { - for(j=0; j< (X_W); j++) - { - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite_Pixel((*data)); - data++; - } - } - - Check_Mem_WR_FIFO_Empty(); - Check_BTE_Busy(); -} - - -/* 结合扩展色彩的 MPU 寫入 */ -void LT768_BTE_MCU_Write_ColorExpansion_MCU_16bit -( - unsigned long Des_Addr // 目的图像的内存起始地址 - ,uint16_t Des_W // 目的图像的宽度 - ,uint16_t XDes // 目的图像的左上方X坐标 - ,uint16_t YDes // 目的图像的左上方Y坐标 - ,uint16_t X_W // 活动窗口的宽度 - ,uint16_t Y_H // 活动窗口的长度 - ,unsigned long Foreground_color // 前景色 - /*Foreground_color : The source (1bit map picture) map data 1 translate to Foreground color by color expansion*/ - ,unsigned long Background_color // 背景色 - /*Background_color : The source (1bit map picture) map data 0 translate to Background color by color expansion*/ - ,const uint16_t *data // 数据缓存首地址 -) -{ - uint16_t i,j; - RGB_16b_16bpp(); - Foreground_color_65k(Foreground_color); - Background_color_65k(Background_color); - BTE_ROP_Code(15); - BTE_Destination_Color_16bpp(); - BTE_Destination_Memory_Start_Address(Des_Addr); - BTE_Destination_Image_Width(Des_W); - BTE_Destination_Window_Start_XY(XDes,YDes); - BTE_Window_Size(X_W,Y_H); - BTE_Operation_Code(0x8); //BTE Operation: MPU Write with Color Expansion (w/o ROP) - BTE_Enable(); - LCD_CmdWrite(0x04); //Memory Data Read/Write Port - - for(i=0; i< Y_H; i++) - { - for(j=0; j< X_W/16; j++) - { - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite_Pixel(*data); - data++; - } - } - - Check_Mem_WR_FIFO_Empty(); - Check_BTE_Busy(); -} - -/* 结合扩展色彩与 Chroma key 的 MPU 寫入 */ -void LT768_BTE_MCU_Write_ColorExpansion_Chroma_key_MCU_16bit -( - unsigned long Des_Addr // 目的图像的内存起始地址 - ,uint16_t Des_W // 目的图像的宽度 - ,uint16_t XDes // 目的图像的左上方X坐标 - ,uint16_t YDes // 目的图像的左上方Y坐标 - ,uint16_t X_W // 活动窗口的宽度 - ,uint16_t Y_H // 活动窗口的长度 - ,unsigned long Foreground_color // 前景色 - /*Foreground_color : The source (1bit map picture) map data 1 translate to Foreground color by color expansion*/ - ,const uint16_t *data // 数据缓存首地址 -) -{ - uint16_t i,j; - RGB_16b_16bpp(); - Foreground_color_65k(Foreground_color); - BTE_ROP_Code(15); - BTE_Destination_Color_16bpp(); - BTE_Destination_Memory_Start_Address(Des_Addr); - BTE_Destination_Image_Width(Des_W); - BTE_Destination_Window_Start_XY(XDes,YDes); - BTE_Window_Size(X_W,Y_H); - BTE_Operation_Code(0x9); //BTE Operation: MPU Write with Color Expansion and chroma keying (w/o ROP) - BTE_Enable(); - LCD_CmdWrite(0x04); //Memory Data Read/Write Port - - for(i=0; i< Y_H; i++) - { - for(j=0; j< X_W/16; j++) - { - Check_Mem_WR_FIFO_not_Full(); - LCD_DataWrite_Pixel(*data); - data++; - } - } - - Check_Mem_WR_FIFO_Empty(); - Check_BTE_Busy(); -} - -/* 结合透明度的内存复制 */ -void BTE_Alpha_Blending -( - unsigned long S0_Addr // SO图像的内存起始地址 - ,uint16_t S0_W // S0图像的宽度 - ,uint16_t XS0 // S0图像的左上方X坐标 - ,uint16_t YS0 // S0图像的左上方Y坐标 - ,unsigned long S1_Addr // S1图像的内存起始地址 - ,uint16_t S1_W // S1图像的宽度 - ,uint16_t XS1 // S1图像的左上方X坐标 - ,uint16_t YS1 // S1图像的左上方Y坐标 - ,unsigned long Des_Addr // 目的图像的内存起始地址 - ,uint16_t Des_W // 目的图像的宽度 - ,uint16_t XDes // 目的图像的左上方X坐标 - ,uint16_t YDes // 目的图像的左上方X坐标 - ,uint16_t X_W // 活动窗口的宽度 - ,uint16_t Y_H // 活动窗口的长度 - ,uint8_t alpha // 透明度等级(32等级) -) -{ - BTE_S0_Color_16bpp(); - BTE_S0_Memory_Start_Address(S0_Addr); - BTE_S0_Image_Width(S0_W); - BTE_S0_Window_Start_XY(XS0,YS0); - BTE_S1_Color_16bpp(); - BTE_S1_Memory_Start_Address(S1_Addr); - BTE_S1_Image_Width(S1_W); - BTE_S1_Window_Start_XY(XS1,YS1); - BTE_Destination_Color_16bpp(); - BTE_Destination_Memory_Start_Address(Des_Addr); - BTE_Destination_Image_Width(Des_W); - BTE_Destination_Window_Start_XY(XDes,YDes); - BTE_Window_Size(X_W,Y_H); - BTE_Operation_Code(0x0A); //BTE Operation: Memory write with opacity (w/o ROP) - BTE_Alpha_Blending_Effect(alpha); - BTE_Enable(); - Check_BTE_Busy(); -} - -void BTE_Pixel_8bpp_Alpha_Blending -( - unsigned long S0_Addr // SO图像的内存起始地址 - ,uint16_t S0_W // S0图像的宽度 - ,uint16_t XS0 // S0图像的左上方X坐标 - ,uint16_t YS0 // S0图像的左上方Y坐标 - ,unsigned long S1_Addr // S1图像的内存起始地址 - ,uint16_t S1_W // S1图像的宽度 - ,uint16_t XS1 // S1图像的左上方X坐标 - ,uint16_t YS1 // S1图像的左上方Y坐标 - ,unsigned long Des_Addr // 目的图像的内存起始地址 - ,uint16_t Des_W // 目的图像的宽度 - ,uint16_t XDes // 目的图像的左上方X坐标 - ,uint16_t YDes // 目的图像的左上方X坐标 - ,uint16_t X_W // 活动窗口的宽度 - ,uint16_t Y_H // 活动窗口的长度 -) -{ - BTE_S0_Color_8bpp(); - BTE_S0_Memory_Start_Address(S0_Addr); - BTE_S0_Image_Width(S0_W); - BTE_S0_Window_Start_XY(XS0,YS0); - BTE_S1_Color_8bit_Alpha(); - BTE_S1_Memory_Start_Address(S1_Addr); - BTE_S1_Image_Width(S1_W); - BTE_S1_Window_Start_XY(XS1,YS1); - BTE_Destination_Color_8bpp(); - BTE_Destination_Memory_Start_Address(Des_Addr); - BTE_Destination_Image_Width(Des_W); - BTE_Destination_Window_Start_XY(XDes,YDes); - BTE_Window_Size(X_W,Y_H); - BTE_Operation_Code(0x0A); //BTE Operation: Memory write with opacity (w/o ROP) - BTE_Enable(); - Check_BTE_Busy(); -} - -void BTE_Pixel_16bpp_Alpha_Blending -( - unsigned long S0_Addr // SO图像的内存起始地址 - ,uint16_t S0_W // S0图像的宽度 - ,uint16_t XS0 // S0图像的左上方X坐标 - ,uint16_t YS0 // S0图像的左上方Y坐标 - ,unsigned long S1_Addr // S1图像的内存起始地址 - ,uint16_t S1_W // S1图像的宽度 - ,uint16_t XS1 // S1图像的左上方X坐标 - ,uint16_t YS1 // S1图像的左上方Y坐标 - ,unsigned long Des_Addr // 目的图像的内存起始地址 - ,uint16_t Des_W // 目的图像的宽度 - ,uint16_t XDes // 目的图像的左上方X坐标 - ,uint16_t YDes // 目的图像的左上方X坐标 - ,uint16_t X_W // 活动窗口的宽度 - ,uint16_t Y_H // 活动窗口的长度 -) -{ - BTE_S0_Color_16bpp(); - BTE_S0_Memory_Start_Address(S0_Addr); - BTE_S0_Image_Width(S0_W); - BTE_S0_Window_Start_XY(XS0,YS0); - BTE_S1_Color_16bit_Alpha(); - BTE_S1_Memory_Start_Address(S1_Addr); - BTE_S1_Image_Width(S1_W); - BTE_S1_Window_Start_XY(XS1,YS1); - BTE_Destination_Color_16bpp(); - BTE_Destination_Memory_Start_Address(Des_Addr); - BTE_Destination_Image_Width(Des_W); - BTE_Destination_Window_Start_XY(XDes,YDes); - BTE_Window_Size(X_W,Y_H); - BTE_Operation_Code(0x0A); //BTE Operation: Memory write with opacity (w/o ROP) - BTE_Enable(); - Check_BTE_Busy(); -} - -/*----------------------------------------------------------------------------*/ - -void LT768_PWM0_Init -( - uint8_t on_off // 0:禁止PWM0 1:使能PWM0 - ,uint8_t Clock_Divided // PWM时钟分频 取值范围 0~3(1,1/2,1/4,1/8) - ,uint8_t Prescalar // 时钟分频 取值范围 1~256 - ,uint16_t Count_Buffer // 设置PWM的输出周期 - ,uint16_t Compare_Buffer // 设置占空比 -) -{ - Select_PWM0(); - Set_PWM_Prescaler_1_to_256(Prescalar); - - if(Clock_Divided ==0) - { - Select_PWM0_Clock_Divided_By_1(); - } - - if(Clock_Divided ==1) - { - Select_PWM0_Clock_Divided_By_2(); - } - - if(Clock_Divided ==2) - { - Select_PWM0_Clock_Divided_By_4(); - } - - if(Clock_Divided ==3) - { - Select_PWM0_Clock_Divided_By_8(); - } - - Set_Timer0_Count_Buffer(Count_Buffer); - Set_Timer0_Compare_Buffer(Compare_Buffer); - - if(on_off == 1) - { - Start_PWM0(); - } - - if(on_off == 0) - { - Stop_PWM0(); - } -} - - -void LT768_PWM0_Duty(uint16_t Compare_Buffer) -{ - Set_Timer0_Compare_Buffer(Compare_Buffer); -} - -void LT768_PWM1_Init -( - uint8_t on_off // 0:禁止PWM0 1:使能PWM0 - ,uint8_t Clock_Divided // PWM时钟分频 取值范围 0~3(1,1/2,1/4,1/8) - ,uint8_t Prescalar // 时钟分频 取值范围 1~256 - ,uint16_t Count_Buffer // 设置PWM的输出周期 - ,uint16_t Compare_Buffer // 设置占空比 -) -{ - Select_PWM1(); - Set_PWM_Prescaler_1_to_256(Prescalar); - - if(Clock_Divided ==0) - { - Select_PWM1_Clock_Divided_By_1(); - } - - if(Clock_Divided ==1) - { - Select_PWM1_Clock_Divided_By_2(); - } - - if(Clock_Divided ==2) - { - Select_PWM1_Clock_Divided_By_4(); - } - - if(Clock_Divided ==3) - { - Select_PWM1_Clock_Divided_By_8(); - } - - Set_Timer1_Count_Buffer(Count_Buffer); - Set_Timer1_Compare_Buffer(Compare_Buffer); - - if(on_off == 1) - { - Start_PWM1(); - } - - if(on_off == 0) - { - Stop_PWM1(); - } -} - - -void LT768_PWM1_Duty(uint16_t Compare_Buffer) -{ - Set_Timer1_Compare_Buffer(Compare_Buffer); -} - -/*----------------------------------------------------------------------------*/ - -// LT768进入待命模式 -void LT768_Standby(void) -{ - Power_Saving_Standby_Mode(); - Check_Power_is_Saving(); -} -// 从待命模式中唤醒 -void LT768_Wkup_Standby(void) -{ - Power_Normal_Mode(); - Check_Power_is_Normal(); -} - - -// LT768进入暂停模式 -void LT768_Suspend(void) -{ - lt768_sdram_init(10); - Power_Saving_Suspend_Mode(); - Check_Power_is_Saving(); -} -// 从暂停模式中唤醒 -void LT768_Wkup_Suspend(void) -{ - Power_Normal_Mode(); - Check_Power_is_Normal(); - lt768_sdram_init(lt768_mclk); -} - - -// LT768进入休眠模式 -void LT768_SleepMode(void) -{ - Power_Saving_Sleep_Mode(); - Check_Power_is_Saving(); -} -// 从休眠模式中唤醒 -void LT768_Wkup_Sleep(void) -{ - Power_Normal_Mode(); - Check_Power_is_Normal(); -} - -/*----------------------------------------------------------------------------*/ - -void LT768_SPI_Init(uint8_t cs,uint8_t div) -{ - if(cs == 0) - { - Select_SFI_0(); - Select_nSS_drive_on_xnsfcs0(); - } - else - { - Select_SFI_1(); - Select_nSS_drive_on_xnsfcs1(); - } - - SPI_Clock_Period(div); - Enable_SFlash_SPI(); -} - -void W25QXX_Enter_4Byte_AddressMode(void)//val:选择外挂的SPI: SCS:0 SCS:1 -{ - nSS_Active(); - SPI_Master_FIFO_Data_Put(0xB7); - nSS_Inactive(); -} - -void LT_W25QXX_Read(uint8_t *pBuffer,uint32_t ReadAddr,uint16_t NumByteToRead) -{ - uint16_t i; - nSS_Active(); - SPI_Master_FIFO_Data_Put(0x03); - SPI_Master_FIFO_Data_Put((uint8_t)((ReadAddr)>>16)); - SPI_Master_FIFO_Data_Put((uint8_t)((ReadAddr)>>8)); - SPI_Master_FIFO_Data_Put((uint8_t)ReadAddr); - - for(i=0; i>8)); - SPI_Master_FIFO_Data_Put((uint8_t)page); - nSS_Inactive(); - W25N01GV_Wait_Busy(); -} - -void W25N01GV_ReadPageAddr_Data(uint8_t *pBuffer,uint32_t PageNum,uint32_t PageAddr,uint16_t NumByteToRead) -{ - uint16_t i; - //------从flash读数据到BUFF----- - nSS_Active(); //使能器件 - SPI_Master_FIFO_Data_Put(0x13); - SPI_Master_FIFO_Data_Put(0x00); - SPI_Master_FIFO_Data_Put((uint8_t)((PageNum)>>8)); //发送16bit地址 - SPI_Master_FIFO_Data_Put((uint8_t)(PageNum)); - nSS_Inactive(); - W25N01GV_Wait_Busy(); - W25N01GV_Write_SR(0xb0,W25N01GV_ReadSR(0xb0) | 0x08); //设定从BUFF的哪个位置开始读 - //------再从BUFF读数据到单片机内----- - nSS_Active(); - SPI_Master_FIFO_Data_Put(0x03); - SPI_Master_FIFO_Data_Put((PageAddr)>>8); - SPI_Master_FIFO_Data_Put(PageAddr); - SPI_Master_FIFO_Data_Put(0x00); - - for(i=0; iLCD_XSIZE_TFT) - { - x1 = x1-LCD_XSIZE_TFT; - y1++; - } - } -} - -void LT768_Print_Outside_Font_GB2312_48_72_Nand -( - uint8_t SCS // 选择外挂的SPI : SCS:0 SCS:1 - ,uint8_t Clk // SPI时钟分频参数 : SPI Clock = System Clock /{(Clk+1)*2} - ,unsigned long FlashAddr // 字库源地址(Flash) - ,unsigned long MemoryAddr1 // 缓冲层1的地址(SDRAM) - ,unsigned long MemoryAddr2 // 缓冲层1的地址(SDRAM) - ,unsigned long ShowAddr // 显示层的地址 - ,uint16_t width // 显示层的宽度 - ,uint8_t Size // 设置字体大小 48:48*48 72:72*72 - ,uint8_t ChromaKey // 0:字体背景色透明 1:可以设置字体的背景色 - ,uint16_t x // 字体开始显示的x位置 - ,uint16_t y // 字体开始显示的y位置 - ,unsigned long FontColor // 字体的颜色 - ,unsigned long BackGroundColor // 字体的背景色(注意:当字体背景初始化成透明时,设置该值无效) - ,uint16_t w // 字体粗细:0:不加粗 1:加粗1级 2:加粗2级 - ,uint16_t s // 行距 - ,uint8_t *c // 数据缓冲的首地址 -) -{ - uint16_t temp_H = 0; - uint16_t temp_L = 0; - uint16_t temp = 0; - unsigned long i = 0; - uint16_t j = 0; - uint16_t k = 0; - uint16_t h = 0; - uint16_t n = 0; - uint16_t m = 0; - uint16_t g = 0; - uint16_t f = 0; - h = x; - k = y; - Memory_8bpp_Mode(); //使用8位色深来存储图片 - Canvas_Image_Start_address(MemoryAddr1); - Canvas_image_width(width); - - while((c[i] != '\0')&&(c[i]>=0xa0)) // 遇见不是汉字编码的自动退出 - { - temp_H = (c[i] - 0xa1) * 94; - temp_L = c[i+1] - 0xa1; - temp = temp_H + temp_L; - LT768_Nand_8bpp_font(1,0,Size*j/8,0,Size/8,Size,FlashAddr+temp*((Size*Size)/8),MemoryAddr1,MemoryAddr2); //2019 - i+=2; - j++; - } - - Memory_16bpp_Mode(); - Canvas_Image_Start_address(ShowAddr); - Canvas_image_width(width); - j = 0; - i = 0; - - if(w>2) - { - w = 2; - } - - for(g=0; g=0xa0)) // 遇见不是汉字编码的自动退出 - { - if((f == m)&&((x+Size*j+Size)>(width*(n+1)))) - { - m++; - n++; - y=y+Size-1+s; - x = x+((width*n)-(x+Size*j))+g; - f=n; - } - - if(ChromaKey==0) - { - LT768_BTE_Memory_Copy_ColorExpansion_8(MemoryAddr2,Size*j/8, - ShowAddr,width,x+Size*j,y, - Size,Size,FontColor,BackGroundColor - ); - } - - if(ChromaKey==1) - { - LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8(MemoryAddr2,Size*j/8, - ShowAddr,width,x+Size*j,y, - Size,Size,FontColor); - } - - i+=2; - j++; - } - - i=0; - j=0; - m=0; - n=0; - f=0; - x=h+g+1; - y=k+g+1; - } -} - -void LT768_Print_Outside_Font_GBK_48_72_Nand -( - uint8_t SCS // 选择外挂的SPI : SCS:0 SCS:1 - ,uint8_t Clk // SPI时钟分频参数 : SPI Clock = System Clock /{(Clk+1)*2} - ,unsigned long FlashAddr // 字库源地址(Flash) - ,unsigned long MemoryAddr1 // 缓冲层1的地址(SDRAM) - ,unsigned long MemoryAddr2 // 缓冲层1的地址(SDRAM) - ,unsigned long ShowAddr // 显示层的地址 - ,uint16_t width // 显示层的宽度 - ,uint8_t Size // 设置字体大小 48:48*48 72:72*72 - ,uint8_t ChromaKey // 0:字体背景色透明 1:可以设置字体的背景色 - ,uint16_t x // 字体开始显示的x位置 - ,uint16_t y // 字体开始显示的y位置 - ,unsigned long FontColor // 字体的颜色 - ,unsigned long BackGroundColor // 字体的背景色(注意:当字体背景初始化成透明时,设置该值无效) - ,uint16_t w // 字体粗细:0:不加粗 1:加粗1级 2:加粗2级 - ,uint16_t s // 行距 - ,uint8_t *c // 数据缓冲的首地址 -) -{ - uint16_t temp_H = 0; - uint16_t temp_L = 0; - uint16_t temp = 0; - unsigned long i = 0; - uint16_t j = 0; - uint16_t k = 0; - uint16_t h = 0; - uint16_t n = 0; - uint16_t m = 0; - uint16_t g = 0; - uint16_t f = 0; - h = x; - k = y; - Memory_8bpp_Mode(); //使用8位色深来存储图片 - Canvas_Image_Start_address(MemoryAddr1); - Canvas_image_width(width); - - while((c[i] != '\0')&&(c[i]>=0xa0)) // 遇见不是汉字编码的自动退出 - { - temp_H = (c[i] - 0x81) * 191; - temp_L = c[i+1] - 0x40; - temp = temp_H + temp_L; - LT768_Nand_8bpp_font(1,0,Size*j/8,0,Size/8,Size,FlashAddr+temp*((Size*Size)/8),MemoryAddr1,MemoryAddr2); //2019 - i+=2; - j++; - } - - Memory_16bpp_Mode(); - Canvas_Image_Start_address(ShowAddr); - Canvas_image_width(width); - j = 0; - i = 0; - - if(w>2) - { - w = 2; - } - - for(g=0; g=0xa0)) // 遇见不是汉字编码的自动退出 - { - if((f == m)&&((x+Size*j+Size)>(width*(n+1)))) - { - m++; - n++; - y=y+Size-1+s; - x = x+((width*n)-(x+Size*j))+g; - f=n; - } - - if(ChromaKey==0) - { - LT768_BTE_Memory_Copy_ColorExpansion_8(MemoryAddr2,Size*j/8, - ShowAddr,width,x+Size*j,y, - Size,Size,FontColor,BackGroundColor - ); - } - - if(ChromaKey==1) - { - LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8(MemoryAddr2,Size*j/8, - ShowAddr,width,x+Size*j,y, - Size,Size,FontColor); - } - - i+=2; - j++; - } - - i=0; - j=0; - m=0; - n=0; - f=0; - x=h+g+1; - y=k+g+1; - } -} - -void LT768_Print_Outside_UserDefineFont_GB2312_Nand -( - uint8_t SCS // 选择外挂的SPI : SCS:0 SCS:1 - ,uint8_t Clk // SPI时钟分频参数 : SPI Clock = System Clock /{(Clk+1)*2} - ,unsigned long FlashAddr // 字库源地址(Flash) - ,unsigned long MemoryAddr1 // 缓冲层1的地址(SDRAM) - ,unsigned long MemoryAddr2 // 缓冲层1的地址(SDRAM) - ,unsigned long ShowAddr // 显示层的地址 - ,uint16_t width // 显示层的宽度 - ,uint8_t Size // 设置字体大小 48:48*48 72:72*72 - ,uint8_t ChromaKey // 0:字体背景色透明 1:可以设置字体的背景色 - ,uint16_t x // 字体开始显示的x位置 - ,uint16_t y // 字体开始显示的y位置 - ,unsigned long FontColor // 字体的颜色 - ,unsigned long BackGroundColor // 字体的背景色(注意:当字体背景初始化成透明时,设置该值无效) - ,uint16_t w // 字体粗细:0:不加粗 1:加粗1级 2:加粗2级 - ,uint16_t s // 行距 - ,uint8_t *c // 数据缓冲的首地址 -) -{ - short temp = 0; - unsigned long i = 0; - uint16_t j = 0; - uint16_t k = 0; - uint16_t h = 0; - uint16_t n = 0; - uint16_t m = 0; - uint16_t g = 0; - uint16_t f = 0; - uint8_t temp1[2] = {0}; - uint32_t fontNum = 0; - clear_Font_1(); - LT768_SPI_Init(SCS,1); - LT_W25N01GV_Read(temp1,FlashAddr+8,2); - fontNum = (temp1[0]<<8)+temp1[1]; - LT_W25N01GV_Read(Font_1,FlashAddr + 0xc,fontNum * 2); - h = x; - k = y; - Memory_8bpp_Mode();//使用8位色深来存储图片 - Canvas_Image_Start_address(MemoryAddr1); - Canvas_image_width(width); - - while(c[i + 1] != '\0') - { - temp = Get_User_Font_P(c[i],c[i+1]); - - if(temp != -1) - { - LT768_Nand_8bpp_font(SCS,Clk,Size*j/8,0,Size/8,Size,FlashAddr+temp*((Size*Size)/8)+0x0c+fontNum*2,MemoryAddr1,MemoryAddr2); //2019 - } - else - { - break; - } - - i+=2; - j++; - } - - Memory_16bpp_Mode(); - Canvas_Image_Start_address(ShowAddr); - Canvas_image_width(width); - j = 0; - i = 0; - - if(w>2) - { - w = 2; - } - - for(g=0; g(width*(n+1)))) - { - m++; - n++; - y=y+Size-1+s; - x = x+((width*n)-(x+Size*j))+g; - f=n; - } - - if(ChromaKey==1) - { - LT768_BTE_Memory_Copy_ColorExpansion_8(MemoryAddr2,Size*j/8, - ShowAddr,width,x+Size*j,y, - Size,Size,FontColor,BackGroundColor - ); - } - - if(ChromaKey==0) - { - LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8(MemoryAddr2,Size*j/8, - ShowAddr,width,x+Size*j,y, - Size,Size,FontColor - ); - } - - i+=2; - j++; - } - - ChromaKey=0; - i=0; - j=0; - m=0; - n=0; - f=0; - x=h+g+1; - y=k+g+1; - } -} - +/* +* Copyright (c) 2022 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file lt768_lib.c + * @brief lt768 register relative driver, inherit from Levetop Electronics + * @version 1.0 + * @author AIIT XUOS Lab + * @date 2022.9.19 + */ + +#include "nuttx/arch.h" +#include "nuttx/lcd/lt768_lib.h" + +/*----------------------------------------------------------------------------*/ + +uint8_t lt768_cclk; // LT768 clock frequnce +uint8_t lt768_mclk; // SDRAM clock frequnce +uint8_t lt768_sclk; // LCD scan clock frequence + +/*----------------------------------------------------------------------------*/ + +void lt768_pll_init(void) +{ + uint32_t temp = 0; + uint32_t temp1; + uint16_t lpllOD_sclk, lpllOD_cclk, lpllOD_mclk; + uint16_t lpllR_sclk, lpllR_cclk, lpllR_mclk; + uint16_t lpllN_sclk, lpllN_cclk, lpllN_mclk; + temp = (LCD_HBPD + LCD_HFPD + LCD_HSPW + LCD_XSIZE_TFT) * + (LCD_VBPD + LCD_VFPD + LCD_VSPW + LCD_YSIZE_TFT) * 60; + temp1 = (temp % 1000000) / 100000; + + if(temp1 > 5) + { + temp = temp / 1000000 + 1; + } + else + { + temp = temp / 1000000; + } + + lt768_sclk = temp; + temp = temp * 3; + lt768_mclk = temp; + lt768_cclk = temp; + + if(lt768_cclk > 100) + { + lt768_cclk = 100; + } + + if(lt768_mclk > 100) + { + lt768_mclk = 100; + } + + if(lt768_sclk > 65) + { + lt768_sclk = 65; + } + +#if XI_4M + lpllOD_sclk = 3; + lpllOD_cclk = 2; + lpllOD_mclk = 2; + lpllR_sclk = 2; + lpllR_cclk = 2; + lpllR_mclk = 2; + lpllN_mclk = lt768_mclk; + lpllN_cclk = lt768_cclk; + lpllN_sclk = 2*lt768_sclk; +#endif +#if XI_8M + lpllOD_sclk = 3; + lpllOD_cclk = 2; + lpllOD_mclk = 2; + lpllR_sclk = 2; + lpllR_cclk = 4; + lpllR_mclk = 4; + lpllN_mclk = lt768_mclk; + lpllN_cclk = lt768_cclk; + lpllN_sclk = lt768_sclk; +#endif +#if XI_10M + lpllOD_sclk = 3; + lpllOD_cclk = 2; + lpllOD_mclk = 2; + lpllR_sclk = 5; + lpllR_cclk = 5; + lpllR_mclk = 5; + lpllN_mclk = lt768_mclk; + lpllN_cclk = lt768_cclk; + lpllN_sclk = 2*lt768_sclk; +#endif +#if XI_12M + lpllOD_sclk = 3; + lpllOD_cclk = 2; + lpllOD_mclk = 2; + lpllR_sclk = 3; + lpllR_cclk = 6; + lpllR_mclk = 6; + lpllN_mclk = lt768_mclk; + lpllN_cclk = lt768_cclk; + lpllN_sclk = lt768_sclk; +#endif + LCD_CmdWrite(0x05); + LCD_DataWrite((lpllOD_sclk << 6) | (lpllR_sclk << 1) | ((lpllN_sclk >> 8) & 0x1)); + LCD_CmdWrite(0x07); + LCD_DataWrite((lpllOD_mclk << 6) | (lpllR_mclk << 1) | ((lpllN_mclk >> 8) & 0x1)); + LCD_CmdWrite(0x09); + LCD_DataWrite((lpllOD_cclk << 6) | (lpllR_cclk << 1) | ((lpllN_cclk >> 8) & 0x1)); + LCD_CmdWrite(0x06); + LCD_DataWrite(lpllN_sclk); + LCD_CmdWrite(0x08); + LCD_DataWrite(lpllN_mclk); + LCD_CmdWrite(0x0a); + LCD_DataWrite(lpllN_cclk); + LCD_CmdWrite(0x00); + up_udelay(1); + LCD_DataWrite(0x80); + up_mdelay(1); +} + +void lt768_sdram_init(uint8_t mclk) +{ + uint16_t sdram_itv; + LCD_RegisterWrite(0xe0, 0x29); + LCD_RegisterWrite(0xe1, 0x03); //CAS:2=0x02?CAS:3=0x03 + sdram_itv = (64000000 / 8192) / (1000 / mclk) ; + sdram_itv -= 2; + LCD_RegisterWrite(0xe2, sdram_itv); + LCD_RegisterWrite(0xe3, sdram_itv >> 8); + LCD_RegisterWrite(0xe4, 0x01); +// Check_SDRAM_Ready(); + up_mdelay(1); +} + +void lt768_set_panel(void) +{ +//**[01h]**// + TFT_16bit(); +//TFT_18bit(); +//TFT_24bit(); +#if STM32_FSMC_8 + Host_Bus_8bit(); //host bus 8bit +#else + Host_Bus_16bit(); //host bus 16bit +#endif +//**[02h]**// + RGB_16b_16bpp(); +//RGB_16b_24bpp_mode1(); + MemWrite_Left_Right_Top_Down(); +//MemWrite_Down_Top_Left_Right(); +//**[03h]**// + Graphic_Mode(); + Memory_Select_SDRAM(); +// PCLK_Falling(); //REG[12h]:falling + PCLK_Rising(); + VSCAN_T_to_B(); //REG[12h]:from top to bottom +//VSCAN_B_to_T(); //from bottom to top + PDATA_Set_RGB(); //REG[12h]:Select RGB output +//PDATA_Set_RBG(); +//PDATA_Set_GRB(); +//PDATA_Set_GBR(); +//PDATA_Set_BRG(); +//PDATA_Set_BGR(); + HSYNC_Low_Active(); //REG[13h]: +//HSYNC_High_Active(); + VSYNC_Low_Active(); //REG[13h]: +//VSYNC_High_Active(); + DE_High_Active(); //REG[13h]: +//DE_Low_Active(); + LCD_HorizontalWidth_VerticalHeight(LCD_XSIZE_TFT, LCD_YSIZE_TFT); + LCD_Horizontal_Non_Display(LCD_HBPD); + LCD_HSYNC_Start_Position(LCD_HFPD); + LCD_HSYNC_Pulse_Width(LCD_HSPW); + LCD_Vertical_Non_Display(LCD_VBPD); + LCD_VSYNC_Start_Position(LCD_VFPD); + LCD_VSYNC_Pulse_Width(LCD_VSPW); + Memory_XY_Mode(); //Block mode (X-Y coordination addressing); + Memory_16bpp_Mode(); +} + +void lt768_init(void) +{ +//Initial_Display_test and set SW2 pin2 = 1 + while(LCD_StatusRead() & 0x02); + + lt768_pll_init(); + lt768_sdram_init(lt768_mclk); + lt768_set_panel(); +} + +/*----------------------------------------------------------------------------*/ + +void MPU8_8bpp_Memory_Write +( + uint16_t x + , uint16_t y + , uint16_t w + , uint16_t h + , const uint8_t *data +) +{ + uint16_t i, j; + Graphic_Mode(); + Active_Window_XY(x, y); + Active_Window_WH(w, h); + Goto_Pixel_XY(x, y); + LCD_CmdWrite(0x04); + + for(i = 0; i < h; i ++) + { + for(j = 0; j < w; j ++) + { + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite(*data); + data ++; + } + } + + Check_Mem_WR_FIFO_Empty(); +} + + +void MPU8_16bpp_Memory_Write +( + uint16_t x + , uint16_t y + , uint16_t w + , uint16_t h + , const uint8_t *data +) +{ + uint16_t i, j; + Graphic_Mode(); + Active_Window_XY(x, y); + Active_Window_WH(w, h); + Goto_Pixel_XY(x, y); + LCD_CmdWrite(0x04); + + for(i = 0; i < h; i ++) + { + for(j = 0; j < w; j ++) + { + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite(*data); + data ++; + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite(*data); + data ++; + } + } + + Check_Mem_WR_FIFO_Empty(); +} + + +void MPU8_24bpp_Memory_Write +( + uint16_t x + , uint16_t y + , uint16_t w + , uint16_t h + , const uint8_t *data +) +{ + uint16_t i, j; + Graphic_Mode(); + Active_Window_XY(x, y); + Active_Window_WH(w, h); + Goto_Pixel_XY(x, y); + LCD_CmdWrite(0x04); + + for(i = 0; i < h; i ++) + { + for(j = 0; j < w; j ++) + { + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite(*data); + data ++; + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite(*data); + data ++; + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite(*data); + data ++; + } + } + + Check_Mem_WR_FIFO_Empty(); +} + + + +void MPuint16_t_16bpp_Memory_Write +( + uint16_t x + , uint16_t y + , uint16_t w + , uint16_t h + , const uint16_t *data +) +{ + uint16_t i, j; + Graphic_Mode(); + Active_Window_XY(x, y); + Active_Window_WH(w, h); + Goto_Pixel_XY(x, y); + LCD_CmdWrite(0x04); + + for(i = 0; i < h; i ++) + { + for(j = 0; j < w; j ++) + { + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite_Pixel(*data); + data ++; + } + } + + Check_Mem_WR_FIFO_Empty(); +} + +void MPuint16_t_24bpp_Mode1_Memory_Write +( + uint16_t x + , uint16_t y + , uint16_t w + , uint16_t h + , const uint16_t *data +) +{ + uint16_t i, j; + Graphic_Mode(); + Active_Window_XY(x, y); + Active_Window_WH(w, h); + Goto_Pixel_XY(x, y); + LCD_CmdWrite(0x04); + + for(i = 0; i < h; i ++) + { + for(j = 0; j < w/2; j ++) + { + LCD_DataWrite_Pixel(*data); + Check_Mem_WR_FIFO_not_Full(); + data ++; + LCD_DataWrite_Pixel(*data); + Check_Mem_WR_FIFO_not_Full(); + data ++; + LCD_DataWrite_Pixel(*data); + Check_Mem_WR_FIFO_not_Full(); + data ++; + } + } + + Check_Mem_WR_FIFO_Empty(); +} + + +void MPuint16_t_24bpp_Mode2_Memory_Write +( + uint16_t x + , uint16_t y + , uint16_t w + , uint16_t h + , const uint16_t *data +) +{ + uint16_t i, j; + Graphic_Mode(); + Active_Window_XY(x, y); + Active_Window_WH(w, h); + Goto_Pixel_XY(x, y); + LCD_CmdWrite(0x04); + + for(i = 0; i < h; i ++) + { + for(j = 0; j < w; j ++) + { + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite_Pixel(*data); + data ++; + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite_Pixel(*data); + data ++; + } + } + + Check_Mem_WR_FIFO_Empty(); +} +/*----------------------------------------------------------------------------*/ + +//------------------------------------- line ----------------------------------------- +void LT768_DrawLine +( + uint16_t X1 // X1 coordination + , uint16_t Y1 // Y1 coordination + , uint16_t X2 // X2 coordination + , uint16_t Y2 // Y2 coordination + , uint32_t LineColor // line color +) +{ + Foreground_color_65k(LineColor); + Line_Start_XY(X1, Y1); + Line_End_XY(X2, Y2); + Start_Line(); + Check_2D_Busy(); +} + +void LT768_DrawLine_Width +( + uint16_t X1 // X1 coordination + , uint16_t Y1 // Y1 coordination + , uint16_t X2 // X2 coordination + , uint16_t Y2 // Y2 coordination + , uint32_t LineColor // line color + , uint16_t Width // line width +) +{ + uint16_t i = 0; + signed short x = 0, y = 0; + double temp = 0; + x = X2 - X1; + y = Y2 - Y1; + + if(x == 0) + { + temp = 2; + } + else + { + temp = -((double)y/(double)x); + } + + if(temp >= -1 && temp <= 1) + { + while(Width--) + { + LT768_DrawLine(X1, Y1 + i, X2, Y2 + i, LineColor); + i ++; + } + } + else + { + while(Width--) + { + LT768_DrawLine(X1 + i, Y1, X2 + i, Y2, LineColor); + i ++; + } + } +} + +//------------------------------------- circle ----------------------------------------- +void LT768_DrawCircle +( + uint16_t XCenter // center x + , uint16_t YCenter // center y + , uint16_t R // radius + , uint32_t CircleColor // line color +) +{ + Foreground_color_65k(CircleColor); + Circle_Center_XY(XCenter, YCenter); + Circle_Radius_R(R); + Start_Circle_or_Ellipse(); + Check_2D_Busy(); +} + +void LT768_DrawCircle_Fill +( + uint16_t XCenter // center x + , uint16_t YCenter // center y + , uint16_t R // radius + , uint32_t ForegroundColor // foreground color +) +{ + Foreground_color_65k(ForegroundColor); + Circle_Center_XY(XCenter, YCenter); + Circle_Radius_R(R); + Start_Circle_or_Ellipse_Fill(); + Check_2D_Busy(); +} + +void LT768_DrawCircle_Width +( + uint16_t XCenter // center x + , uint16_t YCenter // center y + , uint16_t R // radius + , uint32_t CircleColor // line color + , uint32_t ForegroundColor // background color + , uint16_t Width // line width +) +{ + LT768_DrawCircle_Fill(XCenter, YCenter, R + Width, CircleColor); + LT768_DrawCircle_Fill(XCenter, YCenter, R, ForegroundColor); +} + +//------------------------------------- ellipse ----------------------------------------- +void LT768_DrawEllipse +( + uint16_t XCenter // ellipse center x + , uint16_t YCenter // ellipse center y + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t EllipseColor // line color +) +{ + Foreground_color_65k(EllipseColor); + Ellipse_Center_XY(XCenter, YCenter); + Ellipse_Radius_RxRy(X_R, Y_R); + Start_Circle_or_Ellipse(); + Check_2D_Busy(); +} + +void LT768_DrawEllipse_Fill +( + uint16_t XCenter // ellipse center x + , uint16_t YCenter // ellipse center y + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t ForegroundColor // background color +) +{ + Foreground_color_65k(ForegroundColor); + Ellipse_Center_XY(XCenter, YCenter); + Ellipse_Radius_RxRy(X_R, Y_R); + Start_Circle_or_Ellipse_Fill(); + Check_2D_Busy(); +} + +void LT768_DrawEllipse_Width +( + uint16_t XCenter // ellipse center x + , uint16_t YCenter // ellipse center y + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t EllipseColor // line color + , uint32_t ForegroundColor // background color + , uint16_t Width // line width +) +{ + LT768_DrawEllipse_Fill(XCenter, YCenter, X_R + Width, Y_R + Width, EllipseColor); + LT768_DrawEllipse_Fill(XCenter, YCenter, X_R, Y_R, ForegroundColor); +} + +//------------------------------------- rectangle ----------------------------------------- +void LT768_DrawSquare +( + uint16_t X1 // X1 position + , uint16_t Y1 // Y1 position + , uint16_t X2 // X2 position + , uint16_t Y2 // Y2 position + , uint32_t SquareColor // line color +) +{ + Foreground_color_65k(SquareColor); + Square_Start_XY(X1, Y1); + Square_End_XY(X2, Y2); + Start_Square(); + Check_2D_Busy(); +} + +void LT768_DrawSquare_Fill +( + uint16_t X1 // X1 position + , uint16_t Y1 // Y1 position + , uint16_t X2 // X2 position + , uint16_t Y2 // Y2 position + , uint32_t ForegroundColor // background color +) +{ + Foreground_color_65k(ForegroundColor); + Square_Start_XY(X1, Y1); + Square_End_XY(X2, Y2); + Start_Square_Fill(); + Check_2D_Busy(); +} + +void LT768_DrawSquare_Width +( + uint16_t X1 // X1 position + , uint16_t Y1 // Y1 position + , uint16_t X2 // X2 position + , uint16_t Y2 // Y2 position + , uint32_t SquareColor // line color + , uint32_t ForegroundColor // background color + , uint16_t Width // line width +) +{ + LT768_DrawSquare_Fill(X1-Width, Y1-Width, X2 + Width, Y2 + Width, SquareColor); + LT768_DrawSquare_Fill(X1, Y1, X2, Y2, ForegroundColor); +} + +//------------------------------------- round corner rectangle ----------------------------------------- +void LT768_DrawCircleSquare +( + uint16_t X1 // X1 position + , uint16_t Y1 // Y1 position + , uint16_t X2 // X2 position + , uint16_t Y2 // Y2 position + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t CircleSquareColor // line color +) +{ + Foreground_color_65k(CircleSquareColor); + Square_Start_XY(X1, Y1); + Square_End_XY(X2, Y2); + Circle_Square_Radius_RxRy(X_R, Y_R); + Start_Circle_Square(); + Check_2D_Busy(); +} + +void LT768_DrawCircleSquare_Fill +( + uint16_t X1 // X1 position + , uint16_t Y1 // Y1 position + , uint16_t X2 // X2 position + , uint16_t Y2 // Y2 position + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t ForegroundColor // line color +) +{ + Foreground_color_65k(ForegroundColor); + Square_Start_XY(X1, Y1); + Square_End_XY(X2, Y2); + Circle_Square_Radius_RxRy(X_R, Y_R); + Start_Circle_Square_Fill(); + Check_2D_Busy(); +} + +void LT768_DrawCircleSquare_Width +( + uint16_t X1 // X1 position + , uint16_t Y1 // Y1 position + , uint16_t X2 // X2 position + , uint16_t Y2 // Y2 position + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t CircleSquareColor // line color + , uint32_t ForegroundColor // line color + , uint16_t Width +) +{ + LT768_DrawCircleSquare_Fill(X1-Width, Y1-Width, X2 + Width, Y2 + Width, X_R, Y_R, CircleSquareColor); + LT768_DrawCircleSquare_Fill(X1, Y1, X2, Y2, X_R, Y_R, ForegroundColor); +} + +//------------------------------------- triangle ----------------------------------------- +void LT768_DrawTriangle +( + uint16_t X1 // X1 position + , uint16_t Y1 // Y1 position + , uint16_t X2 // X2 position + , uint16_t Y2 // Y2 position + , uint16_t X3 // X3 position + , uint16_t Y3 // Y3 position + , uint32_t TriangleColor // line color +) +{ + Foreground_color_65k(TriangleColor); + Triangle_Point1_XY(X1, Y1); + Triangle_Point2_XY(X2, Y2); + Triangle_Point3_XY(X3, Y3); + Start_Triangle(); + Check_2D_Busy(); +} + +void LT768_DrawTriangle_Fill +( + uint16_t X1 // X1 position + , uint16_t Y1 // Y1 position + , uint16_t X2 // X2 position + , uint16_t Y2 // Y2 position + , uint16_t X3 // X3 position + , uint16_t Y3 // Y3 position + , uint32_t ForegroundColor // line color +) +{ + Foreground_color_65k(ForegroundColor); + Triangle_Point1_XY(X1, Y1); + Triangle_Point2_XY(X2, Y2); + Triangle_Point3_XY(X3, Y3); + Start_Triangle_Fill(); + Check_2D_Busy(); +} + +void LT768_DrawTriangle_Frame +( + uint16_t X1 // X1 position + , uint16_t Y1 // Y1 position + , uint16_t X2 // X2 position + , uint16_t Y2 // Y2 position + , uint16_t X3 // X3 position + , uint16_t Y3 // Y3 position + , uint32_t TriangleColor // line color + , uint32_t ForegroundColor // background color +) +{ + LT768_DrawTriangle_Fill(X1, Y1, X2, Y2, X3, Y3, ForegroundColor); + LT768_DrawTriangle(X1, Y1, X2, Y2, X3, Y3, TriangleColor); +} + +//------------------------------------- curve ----------------------------------------- +void LT768_DrawLeftUpCurve +( + uint16_t XCenter // center X position + , uint16_t YCenter // center Y position + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t CurveColor // line color +) +{ + Foreground_color_65k(CurveColor); + Ellipse_Center_XY(XCenter, YCenter); + Ellipse_Radius_RxRy(X_R, Y_R); + Start_Left_Up_Curve(); + Check_2D_Busy(); +} + + +void LT768_DrawLeftDownCurve +( + uint16_t XCenter // center X position + , uint16_t YCenter // center Y position + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t CurveColor // line color +) +{ + Foreground_color_65k(CurveColor); + Ellipse_Center_XY(XCenter, YCenter); + Ellipse_Radius_RxRy(X_R, Y_R); + Start_Left_Down_Curve(); + Check_2D_Busy(); +} + + +void LT768_DrawRightUpCurve +( + uint16_t XCenter // center X position + , uint16_t YCenter // center Y position + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t CurveColor // line color +) +{ + Foreground_color_65k(CurveColor); + Ellipse_Center_XY(XCenter, YCenter); + Ellipse_Radius_RxRy(X_R, Y_R); + Start_Right_Up_Curve(); + Check_2D_Busy(); +} + + +void LT768_DrawRightDownCurve +( + uint16_t XCenter // center X position + , uint16_t YCenter // center Y position + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t CurveColor // line color +) +{ + Foreground_color_65k(CurveColor); + Ellipse_Center_XY(XCenter, YCenter); + Ellipse_Radius_RxRy(X_R, Y_R); + Start_Right_Down_Curve(); + Check_2D_Busy(); +} + + +void LT768_SelectDrawCurve +( + uint16_t XCenter // center X position + , uint16_t YCenter // center Y position + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t CurveColor // line color + , uint16_t Dir // direction +) +{ + switch(Dir) + { + case 0: + LT768_DrawLeftDownCurve(XCenter, YCenter, X_R, Y_R, CurveColor); + break; + + case 1: + LT768_DrawLeftUpCurve(XCenter, YCenter, X_R, Y_R, CurveColor); + break; + + case 2: + LT768_DrawRightUpCurve(XCenter, YCenter, X_R, Y_R, CurveColor); + break; + + case 3: + LT768_DrawRightDownCurve(XCenter, YCenter, X_R, Y_R, CurveColor); + break; + + default: + break; + } +} + + +//------------------------------------- 1/4 filled ellipse ----------------------------------------- +void LT768_DrawLeftUpCurve_Fill +( + uint16_t XCenter // center X position + , uint16_t YCenter // center Y position + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t ForegroundColor // background color +) +{ + Foreground_color_65k(ForegroundColor); + Ellipse_Center_XY(XCenter, YCenter); + Ellipse_Radius_RxRy(X_R, Y_R); + Start_Left_Up_Curve_Fill(); + Check_2D_Busy(); +} + + +void LT768_DrawLeftDownCurve_Fill +( + uint16_t XCenter // center X position + , uint16_t YCenter // center Y position + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t ForegroundColor // background color +) +{ + Foreground_color_65k(ForegroundColor); + Ellipse_Center_XY(XCenter, YCenter); + Ellipse_Radius_RxRy(X_R, Y_R); + Start_Left_Down_Curve_Fill(); + Check_2D_Busy(); +} + + +void LT768_DrawRightUpCurve_Fill +( + uint16_t XCenter // center X position + , uint16_t YCenter // center Y position + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t ForegroundColor // background color +) +{ + Foreground_color_65k(ForegroundColor); + Ellipse_Center_XY(XCenter, YCenter); + Ellipse_Radius_RxRy(X_R, Y_R); + Start_Right_Up_Curve_Fill(); + Check_2D_Busy(); +} + + +void LT768_DrawRightDownCurve_Fill +( + uint16_t XCenter // center X position + , uint16_t YCenter // center Y position + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t ForegroundColor // background color +) +{ + Foreground_color_65k(ForegroundColor); + Ellipse_Center_XY(XCenter, YCenter); + Ellipse_Radius_RxRy(X_R, Y_R); + Start_Right_Down_Curve_Fill(); + Check_2D_Busy(); +} + + +void LT768_SelectDrawCurve_Fill +( + uint16_t XCenter // center X position + , uint16_t YCenter // center Y position + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint32_t CurveColor // line color + , uint16_t Dir // direction +) +{ + switch(Dir) + { + case 0: + LT768_DrawLeftDownCurve_Fill(XCenter, YCenter, X_R, Y_R, CurveColor); + break; + + case 1: + LT768_DrawLeftUpCurve_Fill(XCenter, YCenter, X_R, Y_R, CurveColor); + break; + + case 2: + LT768_DrawRightUpCurve_Fill(XCenter, YCenter, X_R, Y_R, CurveColor); + break; + + case 3: + LT768_DrawRightDownCurve_Fill(XCenter, YCenter, X_R, Y_R, CurveColor); + break; + + default: + break; + } +} + + + +//------------------------------------- quadrilateral ----------------------------------------- + +void LT768_DrawQuadrilateral +( + uint16_t X1 // X1 position + , uint16_t Y1 // Y1 position + , uint16_t X2 // X2 position + , uint16_t Y2 // Y2 position + , uint16_t X3 // X3 position + , uint16_t Y3 // Y3 position + , uint16_t X4 // X4 position + , uint16_t Y4 // Y4 position + , uint32_t ForegroundColor // line color +) +{ + Foreground_color_65k(ForegroundColor); + Triangle_Point1_XY(X1, Y1); + Triangle_Point2_XY(X2, Y2); + Triangle_Point3_XY(X3, Y3); + Ellipse_Radius_RxRy(X4, Y4); + LCD_CmdWrite(0x67); + LCD_DataWrite(0x8d); + Check_Busy_Draw(); + Check_2D_Busy(); +} + + +void LT768_DrawQuadrilateral_Fill +( + uint16_t X1 // X1 position + , uint16_t Y1 // Y1 position + , uint16_t X2 // X2 position + , uint16_t Y2 // Y2 position + , uint16_t X3 // X3 position + , uint16_t Y3 // Y3 position + , uint16_t X4 // X4 position + , uint16_t Y4 // Y4 position + , uint32_t ForegroundColor // line color +) +{ + Foreground_color_65k(ForegroundColor); + Triangle_Point1_XY(X1, Y1); + Triangle_Point2_XY(X2, Y2); + Triangle_Point3_XY(X3, Y3); + Ellipse_Radius_RxRy(X4, Y4); + LCD_CmdWrite(0x67); + LCD_DataWrite(0xa7); + Check_Busy_Draw(); + Check_2D_Busy(); +} + + +//------------------------------------- pentagon ----------------------------------------- + +void LT768_DrawPentagon +( + uint16_t X1 // X1 position + , uint16_t Y1 // Y1 position + , uint16_t X2 // X2 position + , uint16_t Y2 // Y2 position + , uint16_t X3 // X3 position + , uint16_t Y3 // Y3 position + , uint16_t X4 // X4 position + , uint16_t Y4 // Y4 position + , uint16_t X5 // X5 position + , uint16_t Y5 // Y5 position + , uint32_t ForegroundColor // line color +) +{ + Foreground_color_65k(ForegroundColor); + Triangle_Point1_XY(X1, Y1); + Triangle_Point2_XY(X2, Y2); + Triangle_Point3_XY(X3, Y3); + Ellipse_Radius_RxRy(X4, Y4); + Ellipse_Center_XY(X5, Y5); + LCD_CmdWrite(0x67); + LCD_DataWrite(0x8F); + Check_Busy_Draw(); + Check_2D_Busy(); +} + + +void LT768_DrawPentagon_Fill +( + uint16_t X1 // X1 position + , uint16_t Y1 // Y1 position + , uint16_t X2 // X2 position + , uint16_t Y2 // Y2 position + , uint16_t X3 // X3 position + , uint16_t Y3 // Y3 position + , uint16_t X4 // X4 position + , uint16_t Y4 // Y4 position + , uint16_t X5 // X5 position + , uint16_t Y5 // Y5 position + , uint32_t ForegroundColor // line color +) +{ + Foreground_color_65k(ForegroundColor); + Triangle_Point1_XY(X1, Y1); + Triangle_Point2_XY(X2, Y2); + Triangle_Point3_XY(X3, Y3); + Ellipse_Radius_RxRy(X4, Y4); + Ellipse_Center_XY(X5, Y5); + LCD_CmdWrite(0x67); + LCD_DataWrite(0xa9); + Check_Busy_Draw(); + Check_2D_Busy(); +} + + +//------------------------------------- cylinder ----------------------------------------- +uint8_t LT768_DrawCylinder +( + uint16_t XCenter // ellipse center x + , uint16_t YCenter // ellipse center y + , uint16_t X_R // radius width + , uint16_t Y_R // radius length + , uint16_t H + , uint32_t CylinderColor // line color + , uint32_t ForegroundColor // background color +) +{ + if(YCenter < H) + { + return 1; + } + +//bottom ellipse + LT768_DrawEllipse_Fill(XCenter, YCenter, X_R, Y_R, ForegroundColor); + LT768_DrawEllipse(XCenter, YCenter, X_R, Y_R, CylinderColor); +//middle rectangle + LT768_DrawSquare_Fill(XCenter-X_R, YCenter-H, XCenter + X_R, YCenter, ForegroundColor); +//top ellipse + LT768_DrawEllipse_Fill(XCenter, YCenter-H, X_R, Y_R, ForegroundColor); + LT768_DrawEllipse(XCenter, YCenter-H, X_R, Y_R, CylinderColor); + LT768_DrawLine(XCenter-X_R, YCenter, XCenter-X_R, YCenter-H, CylinderColor); + LT768_DrawLine(XCenter + X_R, YCenter, XCenter + X_R, YCenter-H, CylinderColor); + return 0; +} + + +//------------------------------------- quadrangular ----------------------------------------- +void LT768_DrawQuadrangular +( + uint16_t X1 + , uint16_t Y1 + , uint16_t X2 + , uint16_t Y2 + , uint16_t X3 + , uint16_t Y3 + , uint16_t X4 + , uint16_t Y4 + , uint16_t X5 + , uint16_t Y5 + , uint16_t X6 + , uint16_t Y6 + , uint32_t QuadrangularColor // line color + , uint32_t ForegroundColor // background color +) +{ + LT768_DrawSquare_Fill(X1, Y1, X5, Y5, ForegroundColor); + LT768_DrawSquare(X1, Y1, X5, Y5, QuadrangularColor); + LT768_DrawQuadrilateral_Fill(X1, Y1, X2, Y2, X3, Y3, X4, Y4, ForegroundColor); + LT768_DrawQuadrilateral(X1, Y1, X2, Y2, X3, Y3, X4, Y4, QuadrangularColor); + LT768_DrawQuadrilateral_Fill(X3, Y3, X4, Y4, X5, Y5, X6, Y6, ForegroundColor); + LT768_DrawQuadrilateral(X3, Y3, X4, Y4, X5, Y5, X6, Y6, QuadrangularColor); +} + + +//-------------------------------------- table ------------------------------------ +void LT768_MakeTable +( + uint16_t X1, // start position X1 + uint16_t Y1, // start position X2 + uint16_t W, + uint16_t H, + uint16_t Line, // line number + uint16_t Row, // row number + uint32_t TableColor, // table color C1 + uint32_t ItemColor, // item background color C2 + uint32_t ForegroundColor, // foreground color C3 + uint16_t width1, // internal width + uint16_t width2, // out-side width + uint8_t mode // 0: vertical 1: cross +) +{ + uint16_t i = 0; + uint16_t x2, y2; + x2 = X1 + W * Row; + y2 = Y1 + H * Line; + LT768_DrawSquare_Width(X1, Y1, x2, y2, TableColor, ForegroundColor, width2); + + if(mode == 0) + { + LT768_DrawSquare_Fill(X1, Y1, X1 + W, y2, ItemColor); + } + else if(mode == 1) + { + LT768_DrawSquare_Fill(X1, Y1, x2, Y1 + H, ItemColor); + } + + for(i = 0 ; i < Line ; i ++) + { + LT768_DrawLine_Width(X1, Y1 + i*H, x2, Y1 + i*H, TableColor, width1); + } + + for(i = 0 ; i < Row ; i ++) + { + LT768_DrawLine_Width(X1 + i*W, Y1, X1 + i*W, y2, TableColor, width1); + } +} + +/*----------------------------------------------------------------------------*/ + +void LT768_Color_Bar_ON(void) +{ + Color_Bar_ON(); +} + +void LT768_Color_Bar_OFF(void) +{ + Color_Bar_OFF(); +} + +/*----------------------------------------------------------------------------*/ + +/*--Flash-->DMA-->SDRAM--*/ +/*address:24bit or 32bit*/ + +void LT768_DMA_24bit_Linear +( + uint8_t SCS // select SPI: 0 1 + , uint8_t Clk // SPI clock frequence divison : SPI Clock = System Clock /{(Clk + 1)*2} + , uint32_t flash_addr // flash start address + , uint32_t memory_addr // memory start address + , uint32_t data_num // data number +) +{ + Enable_SFlash_SPI(); // enable SPI + + if(SCS == 0) + { + Select_SFI_0(); // select extern SPI0 + } + + if(SCS == 1) + { + Select_SFI_1(); // select extern SPI1 + } + + Memory_Linear_Mode(); + Select_SFI_DMA_Mode(); // set SPI DMA mode + SPI_Clock_Period(Clk); // SPI speed + SFI_DMA_Destination_Start_Address(memory_addr); // destination start address + SFI_DMA_Transfer_Number(data_num); // DMA transport number + SFI_DMA_Source_Start_Address(flash_addr); // flash address + Check_Busy_SFI_DMA(); + Start_SFI_DMA(); + Check_Busy_SFI_DMA(); + Memory_XY_Mode(); +} + +void LT768_DMA_32bit_Linear +( + uint8_t SCS // select SPI: 0 1 + , uint8_t Clk // SPI clock frequence divison : SPI Clock = System Clock /{(Clk + 1)*2} + , uint32_t flash_addr // flash start address + , uint32_t memory_addr // memory start address + , uint32_t data_num // data number +) +{ + Enable_SFlash_SPI(); // enable SPI + + if(SCS == 0) + { + Select_SFI_0(); // select extern SPI0 + } + + if(SCS == 1) + { + Select_SFI_1(); // select extern SPI1 + } + + Memory_Linear_Mode(); + Select_SFI_DMA_Mode(); // set SPI DMA mode + Select_SFI_32bit_Address(); + SPI_Clock_Period(Clk); // SPI speed + SFI_DMA_Destination_Start_Address(memory_addr); // destination start address + SFI_DMA_Transfer_Number(data_num); // DMA transport number + SFI_DMA_Source_Start_Address(flash_addr); // flash address + Check_Busy_SFI_DMA(); + Start_SFI_DMA(); + Check_Busy_SFI_DMA(); + Memory_XY_Mode(); +} + +void LT768_DMA_24bit_Block +( + uint8_t SCS // select SPI: 0 1 + , uint8_t Clk // SPI clock frequence divison : SPI Clock = System Clock /{(Clk + 1)*2} + , uint16_t X1 // transport X1 address + , uint16_t Y1 // transport Y1 address + , uint16_t X_W // DMA transport width + , uint16_t Y_H // DMA transport length + , uint16_t P_W // picture width + , uint32_t Addr // flash address +) +{ + Enable_SFlash_SPI(); // enable SPI + + if(SCS == 0) + { + Select_SFI_0(); // select extern SPI0 + } + + if(SCS == 1) + { + Select_SFI_1(); // select extern SPI1 + } + + Select_SFI_DMA_Mode(); // set SPI DMA mode + SPI_Clock_Period(Clk); // set SPI clock frequence divsion factor + Goto_Pixel_XY(X1, Y1); // set memory address + SFI_DMA_Destination_Upper_Left_Corner(X1, Y1); // DMA destination address + SFI_DMA_Transfer_Width_Height(X_W, Y_H); // set block width and length + SFI_DMA_Source_Width(P_W); // set source data width + SFI_DMA_Source_Start_Address(Addr); // set source data in flash address + Start_SFI_DMA(); // start DMA transport + Check_Busy_SFI_DMA(); // check DMA transport finish +} + + +void LT768_DMA_32bit_Block +( + uint8_t SCS // select SPI: 0 1 + , uint8_t Clk // SPI clock frequence divison : SPI Clock = System Clock /{(Clk + 1)*2} + , uint16_t X1 // X1 address + , uint16_t Y1 // Y1 address + , uint16_t X_W // DMA transport width + , uint16_t Y_H // DMA transport length + , uint16_t P_W // picture width + , uint32_t Addr // flash address +) +{ + Enable_SFlash_SPI(); + + if(SCS == 0) + { + Select_SFI_0(); + } + + if(SCS == 1) + { + Select_SFI_1(); + } + + Select_SFI_DMA_Mode(); + SPI_Clock_Period(Clk); + Select_SFI_32bit_Address(); + Goto_Pixel_XY(X1, Y1); + SFI_DMA_Destination_Upper_Left_Corner(X1, Y1); + SFI_DMA_Transfer_Width_Height(X_W, Y_H); + SFI_DMA_Source_Width(P_W); + SFI_DMA_Source_Start_Address(Addr); + Start_SFI_DMA(); + Check_Busy_SFI_DMA(); + Select_SFI_24bit_Address(); +} + +/*----------------------------------------------------------------------------*/ +/* select integrated font initialization */ +void LT768_Select_Internal_Font_Init +( + uint8_t Size // set word size 16:16*16 24:24*24 32:32*32 + , uint8_t XxN // word width enlargement factor: 1~4 + , uint8_t YxN // word length enlargement factor: 1~4 + , uint8_t ChromaKey // 0:font background color transparent 1:set font background color + , uint8_t Alignment // 0:no font no align 1:font align +) +{ + if(Size == 16) + { + Font_Select_8x16_16x16(); + } + + if(Size == 24) + { + Font_Select_12x24_24x24(); + } + + if(Size == 32) + { + Font_Select_16x32_32x32(); + } + +//(*) + if(XxN == 1) + { + Font_Width_X1(); + } + + if(XxN == 2) + { + Font_Width_X2(); + } + + if(XxN == 3) + { + Font_Width_X3(); + } + + if(XxN == 4) + { + Font_Width_X4(); + } + +//(*) + if(YxN == 1) + { + Font_Height_X1(); + } + + if(YxN == 2) + { + Font_Height_X2(); + } + + if(YxN == 3) + { + Font_Height_X3(); + } + + if(YxN == 4) + { + Font_Height_X4(); + } + +//(*) + if(ChromaKey == 0) + { + Font_Background_select_Color(); + } + + if(ChromaKey == 1) + { + Font_Background_select_Transparency(); + } + +//(*) + if(Alignment == 0) + { + Disable_Font_Alignment(); + } + + if(Alignment == 1) + { + Enable_Font_Alignment(); + } +} + + +/* print integrated font*/ +void LT768_Print_Internal_Font_String +( + uint16_t x // font start x + , uint16_t y // font start y + , uint32_t FontColor // font color + , uint32_t BackGroundColor // font background color(when font background is transparent, it is invalid) + , char *c // data start address +) +{ + Text_Mode(); + CGROM_Select_Internal_CGROM(); + Foreground_color_65k(FontColor); + Background_color_65k(BackGroundColor); + Goto_Text_XY(x, y); + Show_String(c); +} + + +/* select integrated font initialization */ +void LT768_Select_Outside_Font_Init +( + uint8_t SCS // select SPI: 0 1 + , uint8_t Clk // SPI clock frequence divison : SPI Clock = System Clock /{(Clk + 1)*2} + , uint32_t FlashAddr // source address(Flash) + , uint32_t MemoryAddr // destination address(SDRAM) + , uint32_t Num // word lib size + , uint8_t Size // set word size 16:16*16 24:24*24 32:32*32 + , uint8_t XxN // word width enlargement factor: 1~4 + , uint8_t YxN // word length enlargement factor: 1~4 + , uint8_t ChromaKey // 0:font background color transparent 1:set font background color + , uint8_t Alignment // 0:no font no align 1:font align +) +{ + if(Size == 16) + { + Font_Select_8x16_16x16(); + } + + if(Size == 24) + { + Font_Select_12x24_24x24(); + } + + if(Size == 32) + { + Font_Select_16x32_32x32(); + } + +//(*) + if(XxN == 1) + { + Font_Width_X1(); + } + + if(XxN == 2) + { + Font_Width_X2(); + } + + if(XxN == 3) + { + Font_Width_X3(); + } + + if(XxN == 4) + { + Font_Width_X4(); + } + +//(*) + if(YxN == 1) + { + Font_Height_X1(); + } + + if(YxN == 2) + { + Font_Height_X2(); + } + + if(YxN == 3) + { + Font_Height_X3(); + } + + if(YxN == 4) + { + Font_Height_X4(); + } + +//(*) + if(ChromaKey == 0) + { + Font_Background_select_Color(); + } + + if(ChromaKey == 1) + { + Font_Background_select_Transparency(); + } + +//(*) + if(Alignment == 0) + { + Disable_Font_Alignment(); + } + + if(Alignment == 1) + { + Enable_Font_Alignment(); + } + + LT768_DMA_24bit_Linear(SCS, Clk, FlashAddr, MemoryAddr, Num); + CGRAM_Start_address(MemoryAddr); +} + +/* print outsize and integrated font */ +void LT768_Print_Outside_Font_String +( + uint16_t x // font start x + , uint16_t y // font start y + , uint32_t FontColor // font color + , uint32_t BackGroundColor // font background color((when font background is transparent, it is invalid)) + , uint8_t *c // data start address +) +{ + uint16_t temp_H = 0; + uint16_t temp_L = 0; + uint16_t temp = 0; + uint32_t i = 0; + Text_Mode(); + Font_Select_UserDefine_Mode(); + Foreground_color_65k(FontColor); + Background_color_65k(BackGroundColor); + Goto_Text_XY(x, y); + + while(c[i] != '\0') + { + if(c[i] < 0xa1) + { + CGROM_Select_Internal_CGROM(); // fond source use inside CGROM + LCD_CmdWrite(0x04); + LCD_DataWrite(c[i]); + Check_Mem_WR_FIFO_not_Full(); + i += 1; + } + else + { + Font_Select_UserDefine_Mode(); // user define font + LCD_CmdWrite(0x04); + temp_H = ((c[i] - 0xa1) & 0x00ff) * 94; + temp_L = c[i + 1] - 0xa1; + temp = temp_H + temp_L + 0x8000; + LCD_DataWrite((temp>>8)&0xff); + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite(temp&0xff); + Check_Mem_WR_FIFO_not_Full(); + i += 2; + } + } + + Check_2D_Busy(); + Graphic_Mode(); //back to graphic mode; +} + +/* print external GBK and integrated font */ +void LT768_Print_Outside_Font_GBK_String +( + uint16_t x // font start x + , uint16_t y // font start y + , uint32_t FontColor // font color + , uint32_t BackGroundColor // font background color((when font background is transparent, it is invalid)) + , uint8_t *c // data start address +) +{ + uint16_t temp_H = 0; + uint16_t temp_L = 0; + uint16_t temp = 0; + uint32_t i = 0; + Text_Mode(); + Font_Select_UserDefine_Mode(); + Foreground_color_65k(FontColor); + Background_color_65k(BackGroundColor); + Goto_Text_XY(x, y); + + while(c[i] != '\0') + { + if(c[i] < 0x81) + { + CGROM_Select_Internal_CGROM(); // fond source use inside CGROM + LCD_CmdWrite(0x04); + LCD_DataWrite(c[i]); + Check_Mem_WR_FIFO_not_Full(); + i += 1; + } + else + { + Font_Select_UserDefine_Mode(); // user define font + LCD_CmdWrite(0x04); + temp_H = ((c[i] - 0x81) & 0x00ff) * 191; + temp_L = c[i + 1] - 0x40; + temp = temp_H + temp_L + 0x8000; + LCD_DataWrite((temp>>8)&0xff); + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite(temp&0xff); + Check_Mem_WR_FIFO_not_Full(); + i += 2; + } + } + + Check_2D_Busy(); + Graphic_Mode(); //back to graphic mode; +} + +/*print 48*48,72*72 font */ +void LT768_BTE_Memory_Copy_ColorExpansion_8 +( + uint32_t S0_Addr // SO memory start address + , uint16_t YS0 // SO top-left Y coordinate + , uint32_t Des_Addr // destination memory start address + , uint16_t Des_W // destination memory width + , uint16_t XDes // destination top-left X(show window start X) + , uint16_t YDes // destination top-left Y(show window start y) + , uint16_t X_W // show window width + , uint16_t Y_H // show window length + , uint32_t Foreground_color + , uint32_t Background_color +) +{ + Foreground_color_256(Foreground_color); + Background_color_256(Background_color); + BTE_ROP_Code(7); + BTE_S0_Color_8bpp(); + BTE_S0_Memory_Start_Address(S0_Addr); + BTE_S0_Image_Width(Des_W); + BTE_S0_Window_Start_XY(YS0, 0); + BTE_Destination_Color_16bpp(); + BTE_Destination_Memory_Start_Address(Des_Addr); + BTE_Destination_Image_Width(Des_W); + BTE_Destination_Window_Start_XY(XDes, YDes); + BTE_Operation_Code(0x0e); //BTE Operation: Memory copy (move) with chroma keying (w/o ROP) + BTE_Window_Size(X_W, Y_H); + BTE_Enable(); + Check_BTE_Busy(); +} + +void LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8 +( + uint32_t S0_Addr // SO memory start address + , uint16_t YS0 // SO top-left Y coordinate + , uint32_t Des_Addr // destination memory start address + , uint16_t Des_W // destination memory width + , uint16_t XDes // destination top-left X(show window start X) + , uint16_t YDes // destination top-left Y(show window start y) + , uint16_t X_W // show window width + , uint16_t Y_H // show window length + , uint32_t Foreground_color +) +{ + Foreground_color_256(Foreground_color); + BTE_ROP_Code(7); + BTE_S0_Color_8bpp(); + BTE_S0_Memory_Start_Address(S0_Addr); + BTE_S0_Image_Width(Des_W); + BTE_S0_Window_Start_XY(YS0, 0); + BTE_Destination_Color_16bpp(); + BTE_Destination_Memory_Start_Address(Des_Addr); + BTE_Destination_Image_Width(Des_W); + BTE_Destination_Window_Start_XY(XDes, YDes); + BTE_Operation_Code(0x0f); //BTE Operation: Memory copy (move) with chroma keying (w/o ROP) + BTE_Window_Size(X_W, Y_H); + BTE_Enable(); + Check_BTE_Busy(); +} + +void LT768_Print_Outside_Font_GB2312_48_72 +( + uint8_t SCS // select SPI: 0 1 + , uint8_t Clk // SPI clock frequence divison : SPI Clock = System Clock /{(Clk + 1)*2} + , uint32_t FlashAddr // font source address(Flash) + , uint32_t MemoryAddr // destination address(SDRAM) + , uint32_t ShowAddr // show layer address + , uint16_t width // show layer width + , uint8_t Size // set word size 48:48*48 72:72*72 + , uint8_t ChromaKey // 0:font background color transparent 1:set font background color + , uint16_t x // font start x + , uint16_t y // font start y + , uint32_t FontColor // font color + , uint32_t BackGroundColor // font background color((when font background is transparent, it is invalid)) + , uint16_t w // font thinkness: 0: not overstriking 1: 1 overstriking 2: 2 overstriking + , uint16_t s // linewidth + , uint8_t *c // data start address +) +{ + uint16_t temp_H = 0; + uint16_t temp_L = 0; + uint16_t temp = 0; + uint32_t i = 0; + uint16_t j = 0; + uint16_t k = 0; + uint16_t h = 0; + uint16_t n = 0; + uint16_t m = 0; + uint16_t g = 0; + uint16_t f = 0; + h = x; + k = y; + Memory_8bpp_Mode();//save picture with 8bit color depth + Canvas_Image_Start_address(MemoryAddr); + Canvas_image_width(width); + + while(c[i] != '\0') + { + temp_H = (c[i] - 0xa1) * 94; + temp_L = c[i + 1] - 0xa1; + temp = temp_H + temp_L; + LT768_DMA_24bit_Block(SCS, Clk, Size * j / 8, 0, Size / 8, Size, Size / 8, + FlashAddr + temp * ((Size * Size) / 8)); + i += 2; + j ++; + } + + Memory_16bpp_Mode(); + Canvas_Image_Start_address(ShowAddr); + Canvas_image_width(width); + j = 0; + i = 0; + + if(w > 2) + { + w = 2; + } + + for(g=0; g(width*(n + 1)))) + { + m ++; + n ++; + y=y + Size-1 + s; + x = x + ((width*n)-(x + Size*j)) + g; + f=n; + } + + if(ChromaKey == 1) + { + LT768_BTE_Memory_Copy_ColorExpansion_8( + MemoryAddr, Size * j / 8, + ShowAddr, width, x + Size * j, y, + Size, Size, FontColor, BackGroundColor + ); + } + + if(ChromaKey == 0) + { + LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8( + MemoryAddr, Size * j / 8, + ShowAddr, width, x + Size * j, y, + Size, Size, FontColor + ); + } + + i += 2; + j ++; + } + + ChromaKey=0; + i = 0; + j = 0; + m = 0; + n = 0; + f = 0; + x = h + g + 1; + y = k + g + 1; + } +} + + +void LT768_Print_Outside_Font_BIG5_48_72 +( + uint8_t SCS // select SPI: 0 1 + , uint8_t Clk // SPI clock frequence divison : SPI Clock = System Clock /{(Clk + 1)*2} + , uint32_t FlashAddr // font source address(Flash) + , uint32_t MemoryAddr // destination address(SDRAM) + , uint32_t ShowAddr // show layer address + , uint16_t width // show layer width + , uint8_t Size // set word size 48:48*48 72:72*72 + , uint8_t ChromaKey // 0:font background color transparent 1:set font background color + , uint16_t x // font start x + , uint16_t y // font start y + , uint32_t FontColor // font color + , uint32_t BackGroundColor // font background color((when font background is transparent, it is invalid)) + , uint16_t w // font thinkness: 0: not overstriking 1: 1 overstriking 2: 2 overstriking + , uint16_t s // linewidth + , uint8_t *c // data start address +) +{ + uint16_t temp_H = 0; + uint16_t temp_L = 0; + uint16_t temp = 0; + uint32_t i = 0; + uint16_t j = 0; + uint16_t k = 0; + uint16_t h = 0; + uint16_t n = 0; + uint16_t m = 0; + uint16_t g = 0; + uint16_t f = 0; + h = x; + k = y; + Memory_8bpp_Mode();//save picture with 8bit color depth + Canvas_Image_Start_address(MemoryAddr); + Canvas_image_width(width); + + while(c[i] != '\0') + { + temp_H = (c[i] - 0xa1) * 160; + + if(c[i + 1]<0x7f) + { + temp_L = c[i + 1] - 0x40; + } + else + { + temp_L = c[i + 1] - 0xa0 + 0x40; + } + + temp = temp_H + temp_L; + LT768_DMA_24bit_Block(SCS, Clk, Size * j / 8, 0, Size / 8, Size, Size / 8, + FlashAddr + temp * ((Size * Size) / 8)); + i += 2; + j ++; + } + + Memory_16bpp_Mode(); // print 16bits color depth + Canvas_Image_Start_address(ShowAddr); + Canvas_image_width(width); + j = 0; + i = 0; + + for(g=0; g(1024*(n + 1)))) + { + m ++; + n ++; + y=y + Size-1 + s; + x = x + ((1024*n)-(x + Size*j)) + g; + f=n; + } + + if(ChromaKey == 1) + { + LT768_BTE_Memory_Copy_ColorExpansion_8( + MemoryAddr, Size * j / 8, + ShowAddr, LCD_XSIZE_TFT, x + Size * j, y, + Size, Size, FontColor, BackGroundColor + ); + } + + if(ChromaKey == 0) + { + LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8( + MemoryAddr, Size * j / 8, + ShowAddr, LCD_XSIZE_TFT, x + Size * j, y, + Size, Size, FontColor + ); + } + + i += 2; + j ++; + } + + ChromaKey=0; + i = 0; + j = 0; + m = 0; + n = 0; + f = 0; + x = h + g + 1; + y = k + g + 1; + } +} + +void LT768_Print_Outside_Font_GBK_48_72 +( + uint8_t SCS // select SPI: 0 1 + , uint8_t Clk // SPI clock frequence divison : SPI Clock = System Clock /{(Clk + 1)*2} + , uint32_t FlashAddr // font source address(Flash) + , uint32_t MemoryAddr // destination address(SDRAM) + , uint32_t ShowAddr // show layer address + , uint16_t width // show layer width + , uint8_t Size // set word size 48:48*48 72:72*72 + , uint8_t ChromaKey // 0:font background color transparent 1:set font background color + , uint16_t x // font start x + , uint16_t y // font start y + , uint32_t FontColor // font color + , uint32_t BackGroundColor // font background color((when font background is transparent, it is invalid)) + , uint16_t w // font thinkness: 0: not overstriking 1: 1 overstriking 2: 2 overstriking + , uint16_t s // linewidth + , uint8_t *c // data start address +) +{ + uint16_t temp_H = 0; + uint16_t temp_L = 0; + uint16_t temp = 0; + uint32_t i = 0; + uint16_t j = 0; + uint16_t k = 0; + uint16_t h = 0; + uint16_t n = 0; + uint16_t m = 0; + uint16_t g = 0; + uint16_t f = 0; + h = x; + k = y; + Memory_8bpp_Mode();//save picture with 8bit color depth + Canvas_Image_Start_address(MemoryAddr); + Canvas_image_width(width); + + while(c[i] != '\0') + { + temp_H = (c[i] - 0x81) * 191; + temp_L = c[i + 1] - 0x40; + temp = temp_H + temp_L; + LT768_DMA_24bit_Block(SCS, Clk, Size * j / 8, 0, Size / 8, Size, Size / 8, + FlashAddr + temp * ((Size * Size) / 8)); + i += 2; + j ++; + } + + Memory_16bpp_Mode(); + Canvas_Image_Start_address(ShowAddr); + Canvas_image_width(width); + j = 0; + i = 0; + + if(w > 2) + { + w = 2; + } + + for(g=0; g(width*(n + 1)))) + { + m ++; + n ++; + y=y + Size-1 + s; + x = x + ((width*n)-(x + Size*j)) + g; + f=n; + } + + if(ChromaKey == 1) + { + LT768_BTE_Memory_Copy_ColorExpansion_8( + MemoryAddr, Size * j / 8, + ShowAddr, width, x + Size * j, y, + Size, Size, FontColor, BackGroundColor + ); + } + + if(ChromaKey == 0) + { + LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8( + MemoryAddr, Size * j / 8, + ShowAddr, width, x + Size * j, y, + Size, Size, FontColor + ); + } + + i += 2; + j ++; + } + + ChromaKey = 0; + i = 0; + j = 0; + m = 0; + n = 0; + f = 0; + x = h + g + 1; + y = k + g + 1; + } +} + +/*user-defined font*/ +//only input chinese font +#define Font_size 200 //define font size +#define Font_BYTE Font_size * 2 +uint8_t Font_1[Font_BYTE]; + +void clear_Font_1(void) +{ + uint16_t i; + + for(i = 0; i < Font_BYTE; i ++) + { + Font_1[i] = 0; + } +} + +int Get_User_Font_P(char chH, char chL) +{ + int i; + + for(i = 0; i <(sizeof(Font_1)/2); i ++) + { + if((chH == Font_1[i * 2]) && (chL == Font_1[i * 2 + 1])) + { + return i; + } + } + + return -1; +} + +void LT768_Print_Outside_UserDefineFont_GB2312 +( + uint8_t SCS // select SPI: 0 1 + , uint8_t Clk // SPI clock frequence divison : SPI Clock = System Clock /{(Clk + 1)*2} + , uint32_t FlashAddr // font source address(Flash) + , uint32_t MemoryAddr // destination address(SDRAM) + , uint32_t ShowAddr // show layer address + , uint16_t width // show layer width + , uint8_t Size // set word size 48:48*48 72:72*72 + , uint8_t ChromaKey // 0:font background color transparent 1:set font background color + , uint16_t x // font start x + , uint16_t y // font start y + , uint32_t FontColor // font color + , uint32_t BackGroundColor // font background color((when font background is transparent, it is invalid)) + , uint16_t w // font thinkness: 0: not overstriking 1: 1 overstriking 2: 2 overstriking + , uint16_t s // linewidth + , uint8_t *c // data start address +) +{ + short temp = 0; + uint32_t i = 0; + uint16_t j = 0; + uint16_t k = 0; + uint16_t h = 0; + uint16_t n = 0; + uint16_t m = 0; + uint16_t g = 0; + uint16_t f = 0; + uint8_t temp1[2] = {0}; + uint32_t fontNum = 0; + clear_Font_1(); + LT768_SPI_Init(SCS, 1); + LT_W25QXX_Read(temp1, FlashAddr + 8, 2); + fontNum = (temp1[0] << 8) + temp1[1]; + LT_W25QXX_Read(Font_1, FlashAddr + 0xc, fontNum * 2); + h = x; + k = y; + Memory_8bpp_Mode();//save picture with 8bit color depth + Canvas_Image_Start_address(MemoryAddr); + Canvas_image_width(width); + + while(c[i] != '\0') + { + temp = Get_User_Font_P(c[i], c[i + 1]); + + if(temp>-1) + { + LT768_DMA_24bit_Block(SCS, Clk, Size * j / 8, 0, Size / 8, Size, Size / 8, + FlashAddr + temp*((Size*Size)/8) + 0x0c + fontNum*2); + } + + i += 2; + j ++; + } + + Memory_16bpp_Mode(); + Canvas_Image_Start_address(ShowAddr); + Canvas_image_width(width); + j = 0; + i = 0; + + if(w > 2) + { + w = 2; + } + + for(g=0; g(width*(n + 1)))) + { + m ++; + n ++; + y=y + Size-1 + s; + x = x + ((width*n)-(x + Size*j)) + g; + f=n; + } + + if(ChromaKey == 1) + { + LT768_BTE_Memory_Copy_ColorExpansion_8( + MemoryAddr, Size * j / 8, + ShowAddr, width, x + Size * j, y, + Size, Size, FontColor, BackGroundColor + ); + } + + if(ChromaKey == 0) + { + LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8( + MemoryAddr, Size * j / 8, + ShowAddr, width, x + Size * j, y, + Size, Size, FontColor + ); + } + + i += 2; + j ++; + } + + ChromaKey = 0; + i = 0; + j = 0; + m = 0; + n = 0; + f = 0; + x = h + g + 1; + y = k + g + 1; + } +} + +/*----------------------------------------------------------------------------*/ + +void LT768_Text_cursor_Init +( + uint8_t On_Off_Blinking // 0: disable 1: enable blink + , uint16_t Blinking_Time // set time of blink + , uint16_t X_W // font cursor width + , uint16_t Y_W // font cursor length +) +{ + if(On_Off_Blinking == 0) + { + Disable_Text_Cursor_Blinking(); + } + + if(On_Off_Blinking == 1) + { + Enable_Text_Cursor_Blinking(); + } + + Blinking_Time_Frames(Blinking_Time); +//[3E][3Fh] + Text_Cursor_H_V(X_W, Y_W); + Enable_Text_Cursor(); +} + + +void LT768_Enable_Text_Cursor(void) +{ + Enable_Text_Cursor(); +} + + +void LT768_Disable_Text_Cursor(void) +{ + Disable_Text_Cursor(); +} + + +void LT768_Graphic_cursor_Init +( + uint8_t Cursor_N // select cursor 1 2 3 4 + , uint8_t Color1 // color1 + , uint8_t Color2 // color2 + , uint16_t X_Pos // print coordinationX + , uint16_t Y_Pos // print coordinationY + , uint8_t *Cursor_Buf // cursor buffer start address +) +{ + uint32_t i ; + Memory_Select_Graphic_Cursor_RAM(); + Graphic_Mode(); + + switch(Cursor_N) + { + case 1: + Select_Graphic_Cursor_1(); + break; + + case 2: + Select_Graphic_Cursor_2(); + break; + + case 3: + Select_Graphic_Cursor_3(); + break; + + case 4: + Select_Graphic_Cursor_4(); + break; + + default: + break; + } + + LCD_CmdWrite(0x04); + + for(i = 0; i < 256; i ++) + { + LCD_DataWrite(Cursor_Buf[i]); + } + + Memory_Select_SDRAM();//go back to SDRAM after write finish + Set_Graphic_Cursor_Color_1(Color1); + Set_Graphic_Cursor_Color_2(Color2); + Graphic_Cursor_XY(X_Pos, Y_Pos); + Enable_Graphic_Cursor(); +} + + +void LT768_Set_Graphic_cursor_Pos +( + uint8_t Cursor_N // select cursor 1 2 3 4 + , uint16_t X_Pos // print coordinationX + , uint16_t Y_Pos // print coordinationY +) +{ + Graphic_Cursor_XY(X_Pos, Y_Pos); + + switch(Cursor_N) + { + case 1: + Select_Graphic_Cursor_1(); + break; + + case 2: + Select_Graphic_Cursor_2(); + break; + + case 3: + Select_Graphic_Cursor_3(); + break; + + case 4: + Select_Graphic_Cursor_4(); + break; + + default: + break; + } +} + + +void LT768_Enable_Graphic_Cursor(void) +{ + Enable_Graphic_Cursor(); +} + + +void LT768_Disable_Graphic_Cursor(void) +{ + Disable_Graphic_Cursor(); +} + +/*----------------------------------------------------------------------------*/ + +void LT768_PIP_Init +( + uint8_t On_Off // 0 : disable PIP 1 : enable PIP 2 : keep + , uint8_t Select_PIP // 1 : use PIP1 2 : use PIP2 + , uint32_t PAddr // PIP start address + , uint16_t XP // PIP window X coordiation must divisible by 4 + , uint16_t YP // // PIP window Y coordiation must divisible by 4 + , uint32_t ImageWidth // image width + , uint16_t X_Dis // print windows X coordination + , uint16_t Y_Dis // print windows Y coordination + , uint16_t X_W // show window width, must be divisible by 4 + , uint16_t Y_H // show window length, must be divisible by 4 +) +{ + if(Select_PIP == 1) + { + Select_PIP1_Window_16bpp(); + Select_PIP1_Parameter(); + } + + if(Select_PIP == 2) + { + Select_PIP2_Window_16bpp(); + Select_PIP2_Parameter(); + } + + PIP_Display_Start_XY(X_Dis, Y_Dis); + PIP_Image_Start_Address(PAddr); + PIP_Image_Width(ImageWidth); + PIP_Window_Image_Start_XY(XP, YP); + PIP_Window_Width_Height(X_W, Y_H); + + if(On_Off == 0) + { + if(Select_PIP == 1) + { + Disable_PIP1(); + } + + if(Select_PIP == 2) + { + Disable_PIP2(); + } + } + + if(On_Off == 1) + { + if(Select_PIP == 1) + { + Enable_PIP1(); + } + + if(Select_PIP == 2) + { + Enable_PIP2(); + } + } +} + + +void LT768_Set_DisWindowPos +( + uint8_t On_Off // 0: disable PIP, 1: enable PIP, 2: keep + , uint8_t Select_PIP // 1: use PIP1, 2: use PIP2 + , uint16_t X_Dis // print windows X coordination + , uint16_t Y_Dis // print windows Y coordination +) +{ + if(Select_PIP == 1) + { + Select_PIP1_Parameter(); + } + + if(Select_PIP == 2) + { + Select_PIP2_Parameter(); + } + + if(On_Off == 0) + { + if(Select_PIP == 1) + { + Disable_PIP1(); + } + + if(Select_PIP == 2) + { + Disable_PIP2(); + } + } + + if(On_Off == 1) + { + if(Select_PIP == 1) + { + Enable_PIP1(); + } + + if(Select_PIP == 2) + { + Enable_PIP2(); + } + } + + PIP_Display_Start_XY(X_Dis, Y_Dis); +} + +/*----------------------------------------------------------------------------*/ + +void BTE_Solid_Fill +( + uint32_t Des_Addr // fill destination address + , uint16_t Des_W // destination picture width + , uint16_t XDes + , uint16_t YDes + , uint16_t color // fill color + , uint16_t X_W // fill length + , uint16_t Y_H // fill width +) +{ + BTE_Destination_Color_16bpp(); + BTE_Destination_Memory_Start_Address(Des_Addr); + BTE_Destination_Image_Width(Des_W); + BTE_Destination_Window_Start_XY(XDes, YDes); + BTE_Window_Size(X_W, Y_H); + Foreground_color_65k(color); + BTE_Operation_Code(0x0c); + BTE_Enable(); + Check_BTE_Busy(); +} + +/* BTE memory copy with raster operation*/ +void LT768_BTE_Memory_Copy +( + uint32_t S0_Addr // SO memory start address + , uint16_t S0_W // SO memory width + , uint16_t XS0 // SO top-left X coordinate + , uint16_t YS0 // SO top-left Y coordinate + , uint32_t S1_Addr // S1 memory start address + , uint16_t S1_W // S1 width + , uint16_t XS1 // S1 top-left X + , uint16_t YS1 // S1 top-left Y + , uint32_t Des_Addr // destination memory start address + , uint16_t Des_W // destination memory width + , uint16_t XDes // destination top-left X + , uint16_t YDes // destination top-left Y + , uint32_t ROP_Code // raster operation mode + /*ROP_Code : + 0000b 0(Blackness) + 0001b ~S0!E~S1 or ~(S0 + S1) + 0010b ~S0!ES1 + 0011b ~S0 + 0100b S0!E~S1 + 0101b ~S1 + 0110b S0^S1 + 0111b ~S0 + ~S1 or ~(S0 + S1) + 1000b S0!ES1 + 1001b ~(S0^S1) + 1010b S1 + 1011b ~S0 + S1 + 1100b S0 + 1101b S0 + ~S1 + 1110b S0 + S1 + 1111b 1(whiteness)*/ + , uint16_t X_W // active windows width + , uint16_t Y_H // active windows length +) +{ + BTE_S0_Color_16bpp(); + BTE_S0_Memory_Start_Address(S0_Addr); + BTE_S0_Image_Width(S0_W); + BTE_S0_Window_Start_XY(XS0, YS0); + BTE_S1_Color_16bpp(); + BTE_S1_Memory_Start_Address(S1_Addr); + BTE_S1_Image_Width(S1_W); + BTE_S1_Window_Start_XY(XS1, YS1); + BTE_Destination_Color_16bpp(); + BTE_Destination_Memory_Start_Address(Des_Addr); + BTE_Destination_Image_Width(Des_W); + BTE_Destination_Window_Start_XY(XDes, YDes); + BTE_ROP_Code(ROP_Code); + BTE_Operation_Code(0x02); //BTE Operation: Memory copy (move) with ROP. + BTE_Window_Size(X_W, Y_H); + BTE_Enable(); + Check_BTE_Busy(); +} + + +/* memory copy with Chroma Key (not include ROP) */ +void LT768_BTE_Memory_Copy_Chroma_key +( + uint32_t S0_Addr // SO memory start address + , uint16_t S0_W // SO memory width + , uint16_t XS0 // SO top-left X coordinate + , uint16_t YS0 // SO top-left Y coordinate + , uint32_t Des_Addr // destination memory start address + , uint16_t Des_W // destination memory width + , uint16_t XDes // destination top-left X + , uint16_t YDes // destination top-left X + , uint32_t Background_color // transparent color + , uint16_t X_W // active windows width + , uint16_t Y_H // active windows length +) +{ + Background_color_65k(Background_color); + BTE_S0_Color_16bpp(); + BTE_S0_Memory_Start_Address(S0_Addr); + BTE_S0_Image_Width(S0_W); + BTE_S0_Window_Start_XY(XS0, YS0); + BTE_Destination_Color_16bpp(); + BTE_Destination_Memory_Start_Address(Des_Addr); + BTE_Destination_Image_Width(Des_W); + BTE_Destination_Window_Start_XY(XDes, YDes); + BTE_Operation_Code(0x05); //BTE Operation: Memory copy (move) with chroma keying (w/o ROP) + BTE_Window_Size(X_W, Y_H); + BTE_Enable(); + Check_BTE_Busy(); +} + + +void LT768_BTE_Pattern_Fill +( + uint8_t P_8x8_or_16x16 // 0 : use 8x8 Icon , 1 : use 16x16 Icon. + , uint32_t S0_Addr // SO memory start address + , uint16_t S0_W // SO memory width + , uint16_t XS0 // SO top-left X coordinate + , uint16_t YS0 // SO top-left Y coordinate + , uint32_t Des_Addr // destination memory start address + , uint16_t Des_W // destination memory width + , uint16_t XDes // destination top-left X + , uint16_t YDes // destination top-left X + , uint32_t ROP_Code // raster operation mode + /*ROP_Code : + 0000b 0(Blackness) + 0001b ~S0!E~S1 or ~(S0 + S1) + 0010b ~S0!ES1 + 0011b ~S0 + 0100b S0!E~S1 + 0101b ~S1 + 0110b S0^S1 + 0111b ~S0 + ~S1 or ~(S0 + S1) + 1000b S0!ES1 + 1001b ~(S0^S1) + 1010b S1 + 1011b ~S0 + S1 + 1100b S0 + 1101b S0 + ~S1 + 1110b S0 + S1 + 1111b 1(whiteness)*/ + , uint16_t X_W // active windows width + , uint16_t Y_H // active windows length +) +{ + if(P_8x8_or_16x16 == 0) + { + Pattern_Format_8X8(); + } + + if(P_8x8_or_16x16 == 1) + { + Pattern_Format_16X16(); + } + + BTE_S0_Color_16bpp(); + BTE_S0_Memory_Start_Address(S0_Addr); + BTE_S0_Image_Width(S0_W); + BTE_S0_Window_Start_XY(XS0, YS0); + BTE_Destination_Color_16bpp(); + BTE_Destination_Memory_Start_Address(Des_Addr); + BTE_Destination_Image_Width(Des_W); + BTE_Destination_Window_Start_XY(XDes, YDes); + BTE_ROP_Code(ROP_Code); + BTE_Operation_Code(0x06); //BTE Operation: Pattern Fill with ROP. + BTE_Window_Size(X_W, Y_H); + BTE_Enable(); + Check_BTE_Busy(); +} + + +void LT768_BTE_Pattern_Fill_With_Chroma_key +( + uint8_t P_8x8_or_16x16 // 0 : use 8x8 Icon , 1 : use 16x16 Icon. + , uint32_t S0_Addr // SO memory start address + , uint16_t S0_W // SO memory width + , uint16_t XS0 // SO top-left X coordinate + , uint16_t YS0 // SO top-left Y coordinate + , uint32_t Des_Addr // destination memory start address + , uint16_t Des_W // destination memory width + , uint16_t XDes // destination top-left X + , uint16_t YDes // destination top-left Y + , uint32_t ROP_Code // raster operation mode + /*ROP_Code : + 0000b 0(Blackness) + 0001b ~S0!E~S1 or ~(S0 + S1) + 0010b ~S0!ES1 + 0011b ~S0 + 0100b S0!E~S1 + 0101b ~S1 + 0110b S0^S1 + 0111b ~S0 + ~S1 or ~(S0 + S1) + 1000b S0!ES1 + 1001b ~(S0^S1) + 1010b S1 + 1011b ~S0 + S1 + 1100b S0 + 1101b S0 + ~S1 + 1110b S0 + S1 + 1111b 1(whiteness)*/ + , uint32_t Background_color // transparent color + , uint16_t X_W // active windows width + , uint16_t Y_H // active windows length +) +{ + Background_color_65k(Background_color); + + if(P_8x8_or_16x16 == 0) + { + Pattern_Format_8X8(); + } + + if(P_8x8_or_16x16 == 1) + { + Pattern_Format_16X16(); + } + + BTE_S0_Color_16bpp(); + BTE_S0_Memory_Start_Address(S0_Addr); + BTE_S0_Image_Width(S0_W); + BTE_S0_Window_Start_XY(XS0, YS0); + BTE_Destination_Color_16bpp(); + BTE_Destination_Memory_Start_Address(Des_Addr); + BTE_Destination_Image_Width(Des_W); + BTE_Destination_Window_Start_XY(XDes, YDes); + BTE_ROP_Code(ROP_Code); + BTE_Operation_Code(0x07); //BTE Operation: Pattern Fill with Chroma key. + BTE_Window_Size(X_W, Y_H); + BTE_Enable(); + Check_BTE_Busy(); +} + +void LT768_BTE_MCU_Write_MCU_16bit +( + uint32_t S1_Addr // S1 memory start address + , uint16_t S1_W // S1 width + , uint16_t XS1 // S1 top-left X + , uint16_t YS1 // S1 top-left Y + , uint32_t Des_Addr // destination memory start address + , uint16_t Des_W // destination memory width + , uint16_t XDes // destination top-left X + , uint16_t YDes // destination top-left Y + , uint32_t ROP_Code // raster operation mode + /*ROP_Code : + 0000b 0(Blackness) + 0001b ~S0!E~S1 or ~(S0 + S1) + 0010b ~S0!ES1 + 0011b ~S0 + 0100b S0!E~S1 + 0101b ~S1 + 0110b S0^S1 + 0111b ~S0 + ~S1 or ~(S0 + S1) + 1000b S0!ES1 + 1001b ~(S0^S1) + 1010b S1 + 1011b ~S0 + S1 + 1100b S0 + 1101b S0 + ~S1 + 1110b S0 + S1 + 1111b 1(whiteness)*/ + , uint16_t X_W // active windows width + , uint16_t Y_H // active windows length + , const uint16_t *data // S0 start address +) +{ + uint16_t i, j; + BTE_S1_Color_16bpp(); + BTE_S1_Memory_Start_Address(S1_Addr); + BTE_S1_Image_Width(S1_W); + BTE_S1_Window_Start_XY(XS1, YS1); + BTE_Destination_Color_16bpp(); + BTE_Destination_Memory_Start_Address(Des_Addr); + BTE_Destination_Image_Width(Des_W); + BTE_Destination_Window_Start_XY(XDes, YDes); + BTE_Window_Size(X_W, Y_H); + BTE_ROP_Code(ROP_Code); + BTE_Operation_Code(0x00); //BTE Operation: MPU Write with ROP. + BTE_Enable(); + BTE_S0_Color_16bpp(); + LCD_CmdWrite(0x04); //Memory Data Read/Write Port + +//MCU_16bit_ColorDepth_16bpp + for(i = 0; i < Y_H; i ++) + { + for(j = 0; j < (X_W); j ++) + { + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite_Pixel((*data)); + data ++; + } + } + + Check_Mem_WR_FIFO_Empty(); + Check_BTE_Busy(); +} + + +void LT768_BTE_MCU_Write_Chroma_key_MCU_16bit +( + uint32_t Des_Addr // destination memory start address + , uint16_t Des_W // destination memory width + , uint16_t XDes // destination top-left X + , uint16_t YDes // destination top-left Y + , uint32_t Background_color // transparent color + , uint16_t X_W // active windows width + , uint16_t Y_H // active windows length + , const uint16_t *data // S0 receive address +) +{ + uint32_t i, j; + Background_color_65k(Background_color); + BTE_Destination_Color_16bpp(); + BTE_Destination_Memory_Start_Address(Des_Addr); + BTE_Destination_Image_Width(Des_W); + BTE_Destination_Window_Start_XY(XDes, YDes); + BTE_Window_Size(X_W, Y_H); + BTE_Operation_Code(0x04); //BTE Operation: MPU Write with chroma keying (w/o ROP) + BTE_Enable(); + BTE_S0_Color_16bpp(); + LCD_CmdWrite(0x04); //Memory Data Read/Write Port + +//MCU_16bit_ColorDepth_16bpp + for(i = 0; i < Y_H; i ++) + { + for(j = 0; j < (X_W); j ++) + { + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite_Pixel((*data)); + data ++; + } + } + + Check_Mem_WR_FIFO_Empty(); + Check_BTE_Busy(); +} + + +/* MPU write with expansion color */ +void LT768_BTE_MCU_Write_ColorExpansion_MCU_16bit +( + uint32_t Des_Addr // destination memory start address + , uint16_t Des_W // destination memory width + , uint16_t XDes // destination top-left X + , uint16_t YDes // destination top-left Y + , uint16_t X_W // active windows width + , uint16_t Y_H // active windows length + , uint32_t Foreground_color // foreground color + /*Foreground_color : The source (1bit map picture) map data 1 translate to Foreground color by color expansion*/ + , uint32_t Background_color // background color + /*Background_color : The source (1bit map picture) map data 0 translate to Background color by color expansion*/ + , const uint16_t *data // buffer start address +) +{ + uint16_t i, j; + RGB_16b_16bpp(); + Foreground_color_65k(Foreground_color); + Background_color_65k(Background_color); + BTE_ROP_Code(15); + BTE_Destination_Color_16bpp(); + BTE_Destination_Memory_Start_Address(Des_Addr); + BTE_Destination_Image_Width(Des_W); + BTE_Destination_Window_Start_XY(XDes, YDes); + BTE_Window_Size(X_W, Y_H); + BTE_Operation_Code(0x8); //BTE Operation: MPU Write with Color Expansion (w/o ROP) + BTE_Enable(); + LCD_CmdWrite(0x04); //Memory Data Read/Write Port + + for(i = 0; i < Y_H; i ++) + { + for(j = 0; j < X_W/16; j ++) + { + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite_Pixel(*data); + data ++; + } + } + + Check_Mem_WR_FIFO_Empty(); + Check_BTE_Busy(); +} + +/* MPU write with expansion color and chroma key */ +void LT768_BTE_MCU_Write_ColorExpansion_Chroma_key_MCU_16bit +( + uint32_t Des_Addr // destination memory start address + , uint16_t Des_W // destination memory width + , uint16_t XDes // destination top-left X + , uint16_t YDes // destination top-left Y + , uint16_t X_W // active windows width + , uint16_t Y_H // active windows length + , uint32_t Foreground_color // foreground color + /*Foreground_color : The source (1bit map picture) map data 1 translate to Foreground color by color expansion*/ + , const uint16_t *data // buffer start address +) +{ + uint16_t i, j; + RGB_16b_16bpp(); + Foreground_color_65k(Foreground_color); + BTE_ROP_Code(15); + BTE_Destination_Color_16bpp(); + BTE_Destination_Memory_Start_Address(Des_Addr); + BTE_Destination_Image_Width(Des_W); + BTE_Destination_Window_Start_XY(XDes, YDes); + BTE_Window_Size(X_W, Y_H); + BTE_Operation_Code(0x9); //BTE Operation: MPU Write with Color Expansion and chroma keying (w/o ROP) + BTE_Enable(); + LCD_CmdWrite(0x04); //Memory Data Read/Write Port + + for(i = 0; i < Y_H; i ++) + { + for(j = 0; j < X_W/16; j ++) + { + Check_Mem_WR_FIFO_not_Full(); + LCD_DataWrite_Pixel(*data); + data ++; + } + } + + Check_Mem_WR_FIFO_Empty(); + Check_BTE_Busy(); +} + +/* memory copy with transparent */ +void BTE_Alpha_Blending +( + uint32_t S0_Addr // SO memory start address + , uint16_t S0_W // SO memory width + , uint16_t XS0 // SO top-left X coordinate + , uint16_t YS0 // SO top-left Y coordinate + , uint32_t S1_Addr // S1 memory start address + , uint16_t S1_W // S1 width + , uint16_t XS1 // S1 top-left X + , uint16_t YS1 // S1 top-left Y + , uint32_t Des_Addr // destination memory start address + , uint16_t Des_W // destination memory width + , uint16_t XDes // destination top-left X + , uint16_t YDes // destination top-left X + , uint16_t X_W // active windows width + , uint16_t Y_H // active windows length + , uint8_t alpha // transparent grade (32) +) +{ + BTE_S0_Color_16bpp(); + BTE_S0_Memory_Start_Address(S0_Addr); + BTE_S0_Image_Width(S0_W); + BTE_S0_Window_Start_XY(XS0, YS0); + BTE_S1_Color_16bpp(); + BTE_S1_Memory_Start_Address(S1_Addr); + BTE_S1_Image_Width(S1_W); + BTE_S1_Window_Start_XY(XS1, YS1); + BTE_Destination_Color_16bpp(); + BTE_Destination_Memory_Start_Address(Des_Addr); + BTE_Destination_Image_Width(Des_W); + BTE_Destination_Window_Start_XY(XDes, YDes); + BTE_Window_Size(X_W, Y_H); + BTE_Operation_Code(0x0A); //BTE Operation: Memory write with opacity (w/o ROP) + BTE_Alpha_Blending_Effect(alpha); + BTE_Enable(); + Check_BTE_Busy(); +} + +void BTE_Pixel_8bpp_Alpha_Blending +( + uint32_t S0_Addr // SO memory start address + , uint16_t S0_W // SO memory width + , uint16_t XS0 // SO top-left X coordinate + , uint16_t YS0 // SO top-left Y coordinate + , uint32_t S1_Addr // S1 memory start address + , uint16_t S1_W // S1 width + , uint16_t XS1 // S1 top-left X + , uint16_t YS1 // S1 top-left Y + , uint32_t Des_Addr // destination memory start address + , uint16_t Des_W // destination memory width + , uint16_t XDes // destination top-left X + , uint16_t YDes // destination top-left X + , uint16_t X_W // active windows width + , uint16_t Y_H // active windows length +) +{ + BTE_S0_Color_8bpp(); + BTE_S0_Memory_Start_Address(S0_Addr); + BTE_S0_Image_Width(S0_W); + BTE_S0_Window_Start_XY(XS0, YS0); + BTE_S1_Color_8bit_Alpha(); + BTE_S1_Memory_Start_Address(S1_Addr); + BTE_S1_Image_Width(S1_W); + BTE_S1_Window_Start_XY(XS1, YS1); + BTE_Destination_Color_8bpp(); + BTE_Destination_Memory_Start_Address(Des_Addr); + BTE_Destination_Image_Width(Des_W); + BTE_Destination_Window_Start_XY(XDes, YDes); + BTE_Window_Size(X_W, Y_H); + BTE_Operation_Code(0x0A); //BTE Operation: Memory write with opacity (w/o ROP) + BTE_Enable(); + Check_BTE_Busy(); +} + +void BTE_Pixel_16bpp_Alpha_Blending +( + uint32_t S0_Addr // SO memory start address + , uint16_t S0_W // SO memory width + , uint16_t XS0 // SO top-left X coordinate + , uint16_t YS0 // SO top-left Y coordinate + , uint32_t S1_Addr // S1 memory start address + , uint16_t S1_W // S1 width + , uint16_t XS1 // S1 top-left X + , uint16_t YS1 // S1 top-left Y + , uint32_t Des_Addr // destination memory start address + , uint16_t Des_W // destination memory width + , uint16_t XDes // destination top-left X + , uint16_t YDes // destination top-left X + , uint16_t X_W // active windows width + , uint16_t Y_H // active windows length +) +{ + BTE_S0_Color_16bpp(); + BTE_S0_Memory_Start_Address(S0_Addr); + BTE_S0_Image_Width(S0_W); + BTE_S0_Window_Start_XY(XS0, YS0); + BTE_S1_Color_16bit_Alpha(); + BTE_S1_Memory_Start_Address(S1_Addr); + BTE_S1_Image_Width(S1_W); + BTE_S1_Window_Start_XY(XS1, YS1); + BTE_Destination_Color_16bpp(); + BTE_Destination_Memory_Start_Address(Des_Addr); + BTE_Destination_Image_Width(Des_W); + BTE_Destination_Window_Start_XY(XDes, YDes); + BTE_Window_Size(X_W, Y_H); + BTE_Operation_Code(0x0A); //BTE Operation: Memory write with opacity (w/o ROP) + BTE_Enable(); + Check_BTE_Busy(); +} + +/*----------------------------------------------------------------------------*/ + +void LT768_PWM0_Init +( + uint8_t on_off // 0: enable PWM0 1: enable PWM0 + , uint8_t Clock_Divided // PWM clock frequency division range 0~3(1, 1/2, 1/4, 1/8) + , uint8_t Prescalar // clock frequency range 1~256 + , uint16_t Count_Buffer // PWM output period + , uint16_t Compare_Buffer // set duty ratio +) +{ + Select_PWM0(); + Set_PWM_Prescaler_1_to_256(Prescalar); + + if(Clock_Divided == 0) + { + Select_PWM0_Clock_Divided_By_1(); + } + + if(Clock_Divided == 1) + { + Select_PWM0_Clock_Divided_By_2(); + } + + if(Clock_Divided == 2) + { + Select_PWM0_Clock_Divided_By_4(); + } + + if(Clock_Divided == 3) + { + Select_PWM0_Clock_Divided_By_8(); + } + + Set_Timer0_Count_Buffer(Count_Buffer); + Set_Timer0_Compare_Buffer(Compare_Buffer); + + if(on_off == 1) + { + Start_PWM0(); + } + + if(on_off == 0) + { + Stop_PWM0(); + } +} + + +void LT768_PWM0_Duty(uint16_t Compare_Buffer) +{ + Set_Timer0_Compare_Buffer(Compare_Buffer); +} + +void LT768_PWM1_Init +( + uint8_t on_off // 0: enable PWM0 1: enable PWM0 + , uint8_t Clock_Divided // PWM clock frequency division range 0~3(1, 1/2, 1/4, 1/8) + , uint8_t Prescalar // clock frequency range 1~256 + , uint16_t Count_Buffer // PWM output period + , uint16_t Compare_Buffer // set duty ratio +) +{ + Select_PWM1(); + Set_PWM_Prescaler_1_to_256(Prescalar); + + if(Clock_Divided == 0) + { + Select_PWM1_Clock_Divided_By_1(); + } + + if(Clock_Divided == 1) + { + Select_PWM1_Clock_Divided_By_2(); + } + + if(Clock_Divided == 2) + { + Select_PWM1_Clock_Divided_By_4(); + } + + if(Clock_Divided == 3) + { + Select_PWM1_Clock_Divided_By_8(); + } + + Set_Timer1_Count_Buffer(Count_Buffer); + Set_Timer1_Compare_Buffer(Compare_Buffer); + + if(on_off == 1) + { + Start_PWM1(); + } + + if(on_off == 0) + { + Stop_PWM1(); + } +} + + +void LT768_PWM1_Duty(uint16_t Compare_Buffer) +{ + Set_Timer1_Compare_Buffer(Compare_Buffer); +} + +/*----------------------------------------------------------------------------*/ + +// LT768 enter standby mode +void LT768_Standby(void) +{ + Power_Saving_Standby_Mode(); + Check_Power_is_Saving(); +} + +// wakeup from standby mode +void LT768_Wkup_Standby(void) +{ + Power_Normal_Mode(); + Check_Power_is_Normal(); +} + +// LT768 enter suspend mode +void LT768_Suspend(void) +{ + lt768_sdram_init(10); + Power_Saving_Suspend_Mode(); + Check_Power_is_Saving(); +} + +//wakeup from suspend mode +void LT768_Wkup_Suspend(void) +{ + Power_Normal_Mode(); + Check_Power_is_Normal(); + lt768_sdram_init(lt768_mclk); +} + +// LT768 enter sleep mode +void LT768_SleepMode(void) +{ + Power_Saving_Sleep_Mode(); + Check_Power_is_Saving(); +} + +// wakeup from sleep mode +void LT768_Wkup_Sleep(void) +{ + Power_Normal_Mode(); + Check_Power_is_Normal(); +} + +/*----------------------------------------------------------------------------*/ + +void LT768_SPI_Init(uint8_t cs, uint8_t div) +{ + if(cs == 0) + { + Select_SFI_0(); + Select_nSS_drive_on_xnsfcs0(); + } + else + { + Select_SFI_1(); + Select_nSS_drive_on_xnsfcs1(); + } + + SPI_Clock_Period(div); + Enable_SFlash_SPI(); +} + +void W25QXX_Enter_4Byte_AddressMode(void)//val:select external SPI: SCS:0 SCS:1 +{ + nSS_Active(); + SPI_Master_FIFO_Data_Put(0xB7); + nSS_Inactive(); +} + +void LT_W25QXX_Read(uint8_t *pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead) +{ + uint16_t i; + nSS_Active(); + SPI_Master_FIFO_Data_Put(0x03); + SPI_Master_FIFO_Data_Put((uint8_t)((ReadAddr)>>16)); + SPI_Master_FIFO_Data_Put((uint8_t)((ReadAddr)>>8)); + SPI_Master_FIFO_Data_Put((uint8_t)ReadAddr); + + for(i = 0; i > 8)); + SPI_Master_FIFO_Data_Put((uint8_t)page); + nSS_Inactive(); + W25N01GV_Wait_Busy(); +} + +void W25N01GV_ReadPageAddr_Data(uint8_t *pBuffer, uint32_t PageNum, uint32_t PageAddr, uint16_t NumByteToRead) +{ + uint16_t i; +//------read data from flash to buffer----- + nSS_Active(); //enable + SPI_Master_FIFO_Data_Put(0x13); + SPI_Master_FIFO_Data_Put(0x00); + SPI_Master_FIFO_Data_Put((uint8_t)((PageNum) >> 8)); //send 16bit address + SPI_Master_FIFO_Data_Put((uint8_t)(PageNum)); + nSS_Inactive(); + W25N01GV_Wait_Busy(); + W25N01GV_Write_SR(0xb0, W25N01GV_ReadSR(0xb0) | 0x08); //set read position of buffer +//------read data from buffer to MCU----- + nSS_Active(); + SPI_Master_FIFO_Data_Put(0x03); + SPI_Master_FIFO_Data_Put((PageAddr)>>8); + SPI_Master_FIFO_Data_Put(PageAddr); + SPI_Master_FIFO_Data_Put(0x00); + + for(i = 0; i LCD_XSIZE_TFT) + { + x1 = x1-LCD_XSIZE_TFT; + y1 ++; + } + } +} + +void LT768_Print_Outside_Font_GB2312_48_72_Nand +( + uint8_t SCS // select SPI: 0 1 + , uint8_t Clk // SPI clock frequence divison : SPI Clock = System Clock /{(Clk + 1)*2} + , uint32_t FlashAddr // font source address(Flash) + , uint32_t MemoryAddr1 // cache layer address(sdram) + , uint32_t MemoryAddr2 // cache layer address(sdram) + , uint32_t ShowAddr // show layer address + , uint16_t width // show layer width + , uint8_t Size // set word size 48:48*48 72:72*72 + , uint8_t ChromaKey // 0:font background color transparent 1:set font background color + , uint16_t x // font start x + , uint16_t y // font start y + , uint32_t FontColor // font color + , uint32_t BackGroundColor // font background color((when font background is transparent, it is invalid)) + , uint16_t w // font thinkness: 0: not overstriking 1: 1 overstriking 2: 2 overstriking + , uint16_t s // linewidth + , uint8_t *c // data start address +) +{ + uint16_t temp_H = 0; + uint16_t temp_L = 0; + uint16_t temp = 0; + uint32_t i = 0; + uint16_t j = 0; + uint16_t k = 0; + uint16_t h = 0; + uint16_t n = 0; + uint16_t m = 0; + uint16_t g = 0; + uint16_t f = 0; + h = x; + k = y; + Memory_8bpp_Mode(); //save picture with 8bit color depth + Canvas_Image_Start_address(MemoryAddr1); + Canvas_image_width(width); + + while((c[i] != '\0') && (c[i] >= 0xa0)) // if not chinese code, exit + { + temp_H = (c[i] - 0xa1) * 94; + temp_L = c[i + 1] - 0xa1; + temp = temp_H + temp_L; + LT768_Nand_8bpp_font(1, 0, Size * j / 8, 0, Size / 8, Size, + FlashAddr + temp * ((Size * Size) / 8), MemoryAddr1, MemoryAddr2); + i += 2; + j ++; + } + + Memory_16bpp_Mode(); + Canvas_Image_Start_address(ShowAddr); + Canvas_image_width(width); + j = 0; + i = 0; + + if(w > 2) + { + w = 2; + } + + for(g=0; g= 0xa0)) // if not chinese code, exit + { + if((f == m) && ((x + Size*j + Size)>(width*(n + 1)))) + { + m ++; + n ++; + y=y + Size-1 + s; + x = x + ((width*n)-(x + Size*j)) + g; + f=n; + } + + if(ChromaKey == 0) + { + LT768_BTE_Memory_Copy_ColorExpansion_8( + MemoryAddr2, Size * j / 8, + ShowAddr, width, x + Size * j, y, + Size, Size, FontColor, BackGroundColor + ); + } + + if(ChromaKey == 1) + { + LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8( + MemoryAddr2, Size * j / 8, + ShowAddr, width, x + Size * j, y, + Size, Size, FontColor + ); + } + + i += 2; + j ++; + } + + i = 0; + j = 0; + m = 0; + n = 0; + f = 0; + x = h + g + 1; + y = k + g + 1; + } +} + +void LT768_Print_Outside_Font_GBK_48_72_Nand +( + uint8_t SCS // select SPI: 0 1 + , uint8_t Clk // SPI clock frequence divison : SPI Clock = System Clock /{(Clk + 1)*2} + , uint32_t FlashAddr // font source address(Flash) + , uint32_t MemoryAddr1 // cache layer address(sdram) + , uint32_t MemoryAddr2 // cache layer address(sdram) + , uint32_t ShowAddr // show layer address + , uint16_t width // show layer width + , uint8_t Size // set word size 48:48*48 72:72*72 + , uint8_t ChromaKey // 0:font background color transparent 1:set font background color + , uint16_t x // font start x + , uint16_t y // font start y + , uint32_t FontColor // font color + , uint32_t BackGroundColor // font background color((when font background is transparent, it is invalid)) + , uint16_t w // font thinkness: 0: not overstriking 1: 1 overstriking 2: 2 overstriking + , uint16_t s // linewidth + , uint8_t *c // data start address +) +{ + uint16_t temp_H = 0; + uint16_t temp_L = 0; + uint16_t temp = 0; + uint32_t i = 0; + uint16_t j = 0; + uint16_t k = 0; + uint16_t h = 0; + uint16_t n = 0; + uint16_t m = 0; + uint16_t g = 0; + uint16_t f = 0; + h = x; + k = y; + Memory_8bpp_Mode(); //save picture with 8bit color depth + Canvas_Image_Start_address(MemoryAddr1); + Canvas_image_width(width); + + while((c[i] != '\0') && (c[i] >= 0xa0)) // if not chinese code, exit + { + temp_H = (c[i] - 0x81) * 191; + temp_L = c[i + 1] - 0x40; + temp = temp_H + temp_L; + LT768_Nand_8bpp_font(1, 0, Size * j / 8, 0, Size / 8, Size, + FlashAddr + temp * ((Size * Size)/8), + MemoryAddr1, MemoryAddr2); + i += 2; + j ++; + } + + Memory_16bpp_Mode(); + Canvas_Image_Start_address(ShowAddr); + Canvas_image_width(width); + j = 0; + i = 0; + + if(w > 2) + { + w = 2; + } + + for(g = 0; g < w + 1; g ++) + { + while((c[i] != '\0') && (c[i] >= 0xa0)) // if not chinese code, exit + { + if((f == m) && ((x + Size * j + Size) > (width * (n + 1)))) + { + m ++; + n ++; + y = y + Size - 1 + s; + x = x + ((width * n) - (x + Size * j)) + g; + f = n; + } + + if(ChromaKey == 0) + { + LT768_BTE_Memory_Copy_ColorExpansion_8( + MemoryAddr2, Size * j / 8, + ShowAddr, width, x + Size * j, y, + Size, Size, FontColor, BackGroundColor + ); + } + + if(ChromaKey == 1) + { + LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8( + MemoryAddr2, Size * j / 8, + ShowAddr, width, x + Size * j, y, + Size, Size, FontColor); + } + + i += 2; + j ++; + } + + i = 0; + j = 0; + m = 0; + n = 0; + f = 0; + x = h + g + 1; + y = k + g + 1; + } +} + +void LT768_Print_Outside_UserDefineFont_GB2312_Nand +( + uint8_t SCS // select SPI: 0 1 + , uint8_t Clk // SPI clock frequence divison : SPI Clock = System Clock /{(Clk + 1)*2} + , uint32_t FlashAddr // font source address(Flash) + , uint32_t MemoryAddr1 // cache layer address(sdram) + , uint32_t MemoryAddr2 // cache layer address(sdram) + , uint32_t ShowAddr // show layer address + , uint16_t width // show layer width + , uint8_t Size // set word size 48:48*48 72:72*72 + , uint8_t ChromaKey // 0:font background color transparent 1:set font background color + , uint16_t x // font start x + , uint16_t y // font start y + , uint32_t FontColor // font color + , uint32_t BackGroundColor // font background color((when font background is transparent, it is invalid)) + , uint16_t w // font thinkness: 0: not overstriking 1: 1 overstriking 2: 2 overstriking + , uint16_t s // linewidth + , uint8_t *c // data start address +) +{ + short temp = 0; + uint32_t i = 0; + uint16_t j = 0; + uint16_t k = 0; + uint16_t h = 0; + uint16_t n = 0; + uint16_t m = 0; + uint16_t g = 0; + uint16_t f = 0; + uint8_t temp1[2] = {0}; + uint32_t fontNum = 0; + clear_Font_1(); + LT768_SPI_Init(SCS, 1); + LT_W25N01GV_Read(temp1, FlashAddr + 8, 2); + fontNum = (temp1[0] << 8) + temp1[1]; + LT_W25N01GV_Read(Font_1, FlashAddr + 0xc, fontNum * 2); + h = x; + k = y; + Memory_8bpp_Mode();//save picture with 8bit color depth + Canvas_Image_Start_address(MemoryAddr1); + Canvas_image_width(width); + + while(c[i + 1] != '\0') + { + temp = Get_User_Font_P(c[i], c[i + 1]); + + if(temp != -1) + { + LT768_Nand_8bpp_font(SCS, Clk, Size * j / 8, 0, Size / 8, Size, + FlashAddr + temp * ((Size * Size) / 8) + 0x0c + fontNum * 2, + MemoryAddr1, MemoryAddr2); + } + else + { + break; + } + + i += 2; + j ++; + } + + Memory_16bpp_Mode(); + Canvas_Image_Start_address(ShowAddr); + Canvas_image_width(width); + j = 0; + i = 0; + + if(w > 2) + { + w = 2; + } + + for(g = 0; g < w + 1; g ++) + { + while(c[i + 1] != '\0') + { + temp = Get_User_Font_P(c[i], c[i + 1]); + + if(temp == -1) + { + break; + } + + if((f == m) && ((x + Size * j + Size) > (width * (n + 1)))) + { + m ++; + n ++; + y = y + Size - 1 + s; + x = x + ((width * n) - (x + Size * j)) + g; + f = n; + } + + if(ChromaKey == 1) + { + LT768_BTE_Memory_Copy_ColorExpansion_8( + MemoryAddr2, Size * j / 8, + ShowAddr, width, x + Size * j, y, + Size, Size, FontColor, BackGroundColor + ); + } + + if(ChromaKey == 0) + { + LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8( + MemoryAddr2, Size * j / 8, + ShowAddr, width, x + Size*j, y, + Size, Size, FontColor + ); + } + + i += 2; + j ++; + } + + ChromaKey = 0; + i = 0; + j = 0; + m = 0; + n = 0; + f = 0; + x = h + g + 1; + y = k + g + 1; + } +} + diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/include/nuttx/lcd/lt768.h b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/include/nuttx/lcd/lt768.h index 9dd5817ec..f60fdf799 100755 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/include/nuttx/lcd/lt768.h +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/include/nuttx/lcd/lt768.h @@ -1,685 +1,704 @@ -/******************** COPYRIGHT ******************** -* File Name : LT768.h -* Author : Levetop Electronics -* Version : V1.0 -* Date : 2017-8-25 -* Description : 操作LT768的寄存器函数 -****************************************************/ - -#ifndef _LT768_h -#define _LT768_h - -#define cSetb0 0x01 -#define cSetb1 0x02 -#define cSetb2 0x04 -#define cSetb3 0x08 -#define cSetb4 0x10 -#define cSetb5 0x20 -#define cSetb6 0x40 -#define cSetb7 0x80 - -#define cClrb0 0xfe -#define cClrb1 0xfd -#define cClrb2 0xfb -#define cClrb3 0xf7 -#define cClrb4 0xef -#define cClrb5 0xdf -#define cClrb6 0xbf -#define cClrb7 0x7f - - -void LCD_RegisterWrite(unsigned char Cmd,unsigned char Data); -unsigned char LCD_RegisterRead(unsigned char Cmd); - -//**Staus**// -void Check_Mem_WR_FIFO_not_Full(void); -void Check_Mem_WR_FIFO_Empty(void); -void Check_Mem_RD_FIFO_not_Full(void); -void Check_Mem_RD_FIFO_not_Empty(void); -void Check_2D_Busy(void); -void Check_SDRAM_Ready(void); -unsigned char Power_Saving_Status(void); -void Check_Power_is_Normal(void); -void Check_Power_is_Saving(void); -void Check_NO_Interrupt(void); -void Check_Interrupt_Occur(void); - -void Check_Busy_Draw(void); -void Check_Busy_SFI_DMA(void); - -//**[00h]**// -void LT768_SW_Reset(void); -//**[01h]**// -void Enable_PLL(void); -void LT768_Sleep(void); -void LT768_WakeUp(void); -void TFT_24bit(void); -void TFT_18bit(void); -void TFT_16bit(void); -void TFT_LVDS(void); -void Key_Scan_Enable(void); -void Key_Scan_Disable(void); -void LT768_I2CM_Enable(void); -void LT768_I2CM_Disable(void); -void Enable_SFlash_SPI(void); -void Disable_SFlash_SPI(void); -void Host_Bus_8bit(void); -void Host_Bus_16bit(void); -//**[02h]**// - -void RGB_8b_8bpp(void); -void RGB_8b_16bpp(void); -void RGB_8b_24bpp(void); - -void RGB_16b_8bpp(void); -void RGB_16b_16bpp(void); -void RGB_16b_24bpp_mode1(void); -void RGB_16b_24bpp_mode2(void); - -void MemRead_Left_Right_Top_Down(void); -void MemRead_Right_Left_Top_Down(void); -void MemRead_Top_Down_Left_Right(void); -void MemRead_Down_Top_Left_Right(void); - -void MemWrite_Left_Right_Top_Down(void); -void MemWrite_Right_Left_Top_Down(void); -void MemWrite_Top_Down_Left_Right(void); -void MemWrite_Down_Top_Left_Right(void); -//**[03h]**// -void Interrupt_Active_Low(void); -void Interrupt_Active_High(void); -void ExtInterrupt_Debounce(void); -void ExtInterrupt_Nodebounce(void); -void ExtInterrupt_Input_Low_Level_Trigger(void); -void ExtInterrupt_Input_High_Level_Trigger(void); -void ExtInterrupt_Input_Falling_Edge_Trigger(void); -void ExtInterrupt_Input_Rising_Edge_Trigger(void); -void LVDS_Format1(void); -void LVDS_Format2(void); -void Graphic_Mode(void); -void Text_Mode(void); -void Memory_Select_SDRAM(void); -void Memory_Select_Graphic_Cursor_RAM(void); -void Memory_Select_Color_Palette_RAM(void); -//**[05h]**// -//**[06h]**// -//**[07h]**// -//**[09h]**// -//**[0Ah]**// -//**[0Bh]**// -void Enable_Resume_Interrupt(void); -void Disable_Resume_Interrupt(void); -void Enable_ExtInterrupt_Input(void); -void Disable_ExtInterrupt_Input(void); -void Enable_I2CM_Interrupt(void); -void Disable_I2CM_Interrupt(void); -void Enable_Vsync_Interrupt(void); -void Disable_Vsync_Interrupt(void); -void Enable_KeyScan_Interrupt(void); -void Disable_KeyScan_Interrupt(void); -void Enable_DMA_Draw_BTE_Interrupt(void); -void Disable_DMA_Draw_BTE_Interrupt(void); -void Enable_PWM1_Interrupt(void); -void Disable_PWM1_Interrupt(void); -void Enable_PWM0_Interrupt(void); -void Disable_PWM0_Interrupt(void); -//**[0Ch]**// -unsigned char Read_Interrupt_status(void); -void Clear_Resume_Interrupt_Flag(void); -void Clear_ExtInterrupt_Input_Flag(void); -void Clear_I2CM_Interrupt_Flag(void); -void Clear_Vsync_Interrupt_Flag(void); -void Clear_KeyScan_Interrupt_Flag(void); -void Clear_DMA_Draw_BTE_Interrupt_Flag(void); -void Clear_PWM1_Interrupt_Flag(void); -void Clear_PWM0_Interrupt_Flag(void); -//**[0Dh]**// -void Mask_Resume_Interrupt_Flag(void); -void Mask_ExtInterrupt_Input_Flag(void); -void Mask_I2CM_Interrupt_Flag(void); -void Mask_Vsync_Interrupt_Flag(void); -void Mask_KeyScan_Interrupt_Flag(void); -void Mask_DMA_Draw_BTE_Interrupt_Flag(void); -void Mask_PWM1_Interrupt_Flag(void); -void Mask_PWM0_Interrupt_Flag(void); -// -void Enable_Resume_Interrupt_Flag(void); -void Enable_ExtInterrupt_Input_Flag(void); -void Enable_I2CM_Interrupt_Flag(void); -void Enable_Vsync_Interrupt_Flag(void); -void Enable_KeyScan_Interrupt_Flag(void); -void Enable_DMA_Draw_BTE_Interrupt_Flag(void); -void Enable_PWM1_Interrupt_Flag(void); -void Enable_PWM0_Interrupt_Flag(void); -//**[0Eh]**// -void Enable_GPIOF_PullUp(void); -void Enable_GPIOE_PullUp(void); -void Enable_GPIOD_PullUp(void); -void Enable_GPIOC_PullUp(void); -void Enable_XDB15_8_PullUp(void); -void Enable_XDB7_0_PullUp(void); -void Disable_GPIOF_PullUp(void); -void Disable_GPIOE_PullUp(void); -void Disable_GPIOD_PullUp(void); -void Disable_GPIOC_PullUp(void); -void Disable_XDB15_8_PullUp(void); -void Disable_XDB7_0_PullUp(void); - -//**[0Fh]**// -void XPDAT18_Set_GPIO_D7(void); -void XPDAT18_Set_KOUT4(void); -void XPDAT17_Set_GPIO_D5(void); -void XPDAT17_Set_KOUT2(void); -void XPDAT16_Set_GPIO_D4(void); -void XPDAT16_Set_KOUT1(void); -void XPDAT9_Set_GPIO_D3(void); -void XPDAT9_Set_KOUT3(void); -void XPDAT8_Set_GPIO_D2(void); -void XPDAT8_Set_KIN3(void); -void XPDAT2_Set_GPIO_D6(void); -void XPDAT2_Set_KIN4(void); -void XPDAT1_Set_GPIO_D1(void); -void XPDAT1_Set_KIN2(void); -void XPDAT0_Set_GPIO_D0(void); -void XPDAT0_Set_KIN1(void); - -//**[10h]**// -void Enable_PIP1(void); -void Disable_PIP1(void); -void Enable_PIP2(void); -void Disable_PIP2(void); -void Select_PIP1_Parameter(void); -void Select_PIP2_Parameter(void); -void Select_Main_Window_8bpp(void); -void Select_Main_Window_16bpp(void); -void Select_Main_Window_24bpp(void); -//**[11h]**// -void Select_PIP1_Window_8bpp(void); -void Select_PIP1_Window_16bpp(void); -void Select_PIP1_Window_24bpp(void); -void Select_PIP2_Window_8bpp(void); -void Select_PIP2_Window_16bpp(void); -void Select_PIP2_Window_24bpp(void); -//**[12h]**// -void PCLK_Rising(void); -void PCLK_Falling(void); -void Display_ON(void); -void Display_OFF(void); -void Color_Bar_ON(void); -void Color_Bar_OFF(void); -void HSCAN_L_to_R(void); -void HSCAN_R_to_L(void); -void VSCAN_T_to_B(void); -void VSCAN_B_to_T(void); -void PDATA_Set_RGB(void); -void PDATA_Set_RBG(void); -void PDATA_Set_GRB(void); -void PDATA_Set_GBR(void); -void PDATA_Set_BRG(void); -void PDATA_Set_BGR(void); -void PDATA_IDLE_STATE(void); - -//**[13h]**// -void HSYNC_Low_Active(void); -void HSYNC_High_Active(void); -void VSYNC_Low_Active(void); -void VSYNC_High_Active(void); -void DE_Low_Active(void); -void DE_High_Active(void); -void Idle_DE_Low(void); -void Idle_DE_High(void); -void Idle_PCLK_Low(void); -void Idle_PCLK_High(void); -void Idle_PDAT_Low(void); -void Idle_PDAT_High(void); -void Idle_HSYNC_Low(void); -void Idle_HSYNC_High(void); -void Idle_VSYNC_Low(void); -void Idle_VSYNC_High(void); -//**[14h][15h][1Ah][1Bh]**// -void LCD_HorizontalWidth_VerticalHeight(unsigned short WX,unsigned short HY); -//**[16h][17h]**// -void LCD_Horizontal_Non_Display(unsigned short WX); -//**[18h]**// -void LCD_HSYNC_Start_Position(unsigned short WX); -//**[19h]**// -void LCD_HSYNC_Pulse_Width(unsigned short WX); -//**[1Ch][1Dh]**// -void LCD_Vertical_Non_Display(unsigned short HY); -//**[1Eh]**// -void LCD_VSYNC_Start_Position(unsigned short HY); -//**[1Fh]**// -void LCD_VSYNC_Pulse_Width(unsigned short HY); -//**[20h][21h][22h][23h]**// -void Main_Image_Start_Address(unsigned long Addr); -//**[24h][25h]**// -void Main_Image_Width(unsigned short WX); -//**[26h][27h][28h][29h]**// -void Main_Window_Start_XY(unsigned short WX,unsigned short HY); -//**[2Ah][2Bh][2Ch][2Dh]**// -void PIP_Display_Start_XY(unsigned short WX,unsigned short HY); -//**[2Eh][2Fh][30h][31h]**// -void PIP_Image_Start_Address(unsigned long Addr); -//**[32h][33h]**// -void PIP_Image_Width(unsigned short WX); -//**[34h][35h][36h][37h]**// -void PIP_Window_Image_Start_XY(unsigned short WX,unsigned short HY); -//**[38h][39h][3Ah][3Bh]**// -void PIP_Window_Width_Height(unsigned short WX,unsigned short HY); -//**[3C]**// -void Enable_Graphic_Cursor(void); -void Disable_Graphic_Cursor(void); -void Select_Graphic_Cursor_1(void); -void Select_Graphic_Cursor_2(void); -void Select_Graphic_Cursor_3(void); -void Select_Graphic_Cursor_4(void); -void Enable_Text_Cursor(void); -void Disable_Text_Cursor(void); -void Enable_Text_Cursor_Blinking(void); -void Disable_Text_Cursor_Blinking(void); -//**[3D]**// -void Blinking_Time_Frames(unsigned char temp); -//**[3E][3Fh]**// -void Text_Cursor_H_V(unsigned short WX,unsigned short HY); -//**[40h][41h][42h][43h]**// -void Graphic_Cursor_XY(unsigned short WX,unsigned short HY); -//**[44]**// -void Set_Graphic_Cursor_Color_1(unsigned char temp); -//**[45]**// -void Set_Graphic_Cursor_Color_2(unsigned char temp); -//**[50h][51h][52h][53h]**// -void Canvas_Image_Start_address(unsigned long Addr); -//**[54h][55h]**// -void Canvas_image_width(unsigned short WX); -//**[56h][57h][58h][59h]**// -void Active_Window_XY(unsigned short WX,unsigned short HY); -//**[5Ah][5Bh][5Ch][5Dh]**// -void Active_Window_WH(unsigned short WX,unsigned short HY); -//**[5E]**// -void Select_Write_Data_Position(void); -void Select_Read_Data_Position(void); -void Memory_XY_Mode(void); -void Memory_Linear_Mode(void); -void Memory_8bpp_Mode(void); -void Memory_16bpp_Mode(void); -void Memory_24bpp_Mode(void); -//**[5Fh][60h][61h][62h]**// -void Goto_Pixel_XY(unsigned short WX,unsigned short HY); -void Goto_Linear_Addr(unsigned long Addr); -//**[63h][64h][65h][66h]**// -void Goto_Text_XY(unsigned short WX,unsigned short HY); - -//////////////////////////////////////////////////////////////////////// -////**** [ Function : Draw ] ****//// -//**[67h]**// -void Start_Line(void); -void Start_Triangle(void); -void Start_Triangle_Fill(void); -//**[68h]~[73h]**// -void Line_Start_XY(unsigned short WX,unsigned short HY); -void Line_End_XY(unsigned short WX,unsigned short HY); -void Triangle_Point1_XY(unsigned short WX,unsigned short HY); -void Triangle_Point2_XY(unsigned short WX,unsigned short HY); -void Triangle_Point3_XY (unsigned short WX,unsigned short HY); -void Square_Start_XY(unsigned short WX,unsigned short HY); -void Square_End_XY(unsigned short WX,unsigned short HY); -//**[76h]**// -void Start_Circle_or_Ellipse(void); -void Start_Circle_or_Ellipse_Fill(void); -void Start_Left_Down_Curve(void); -void Start_Left_Up_Curve(void); -void Start_Right_Up_Curve(void); -void Start_Right_Down_Curve(void); -void Start_Left_Down_Curve_Fill(void); -void Start_Left_Up_Curve_Fill(void); -void Start_Right_Up_Curve_Fill(void); -void Start_Right_Down_Curve_Fill(void); -void Start_Square(void); -void Start_Square_Fill(void); -void Start_Circle_Square(void); -void Start_Circle_Square_Fill(void); -//**[77h]~[7Eh]**// -void Circle_Center_XY(unsigned short WX,unsigned short HY); -void Ellipse_Center_XY(unsigned short WX,unsigned short HY); -void Circle_Radius_R(unsigned short WX); -void Ellipse_Radius_RxRy(unsigned short WX,unsigned short HY); -void Circle_Square_Radius_RxRy(unsigned short WX,unsigned short HY); - -//////////////////////////////////////////////////////////////////////// -////**** [ Function : PWM ] ****//// -//**[84h]**// -void Set_PWM_Prescaler_1_to_256(unsigned short WX); -//**[85h]**// -void Select_PWM1_Clock_Divided_By_1(void); -void Select_PWM1_Clock_Divided_By_2(void); -void Select_PWM1_Clock_Divided_By_4(void); -void Select_PWM1_Clock_Divided_By_8(void); -void Select_PWM0_Clock_Divided_By_1(void); -void Select_PWM0_Clock_Divided_By_2(void); -void Select_PWM0_Clock_Divided_By_4(void); -void Select_PWM0_Clock_Divided_By_8(void); -//[85h].[bit3][bit2] -void Select_PWM1_is_ErrorFlag(void); -void Select_PWM1(void); -void Select_PWM1_is_Osc_Clock(void); -//[85h].[bit1][bit0] -void Select_PWM0_is_GPIO_C7(void); -void Select_PWM0(void); -void Select_PWM0_is_Core_Clock(void); -//**[86h]**// -//[86h]PWM1 -void Enable_PWM1_Inverter(void); -void Disable_PWM1_Inverter(void); -void Auto_Reload_PWM1(void); -void One_Shot_PWM1(void); -void Start_PWM1(void); -void Stop_PWM1(void); -//[86h]PWM0 -void Enable_PWM0_Dead_Zone(void); -void Disable_PWM0_Dead_Zone(void); -void Enable_PWM0_Inverter(void); -void Disable_PWM0_Inverter(void); -void Auto_Reload_PWM0(void); -void One_Shot_PWM0(void); -void Start_PWM0(void); -void Stop_PWM0(void); -//**[87h]**// -void Set_Timer0_Dead_Zone_Length(unsigned char temp); -//**[88h][89h]**// -void Set_Timer0_Compare_Buffer(unsigned short WX); -//**[8Ah][8Bh]**// -void Set_Timer0_Count_Buffer(unsigned short WX); -//**[8Ch][8Dh]**// -void Set_Timer1_Compare_Buffer(unsigned short WX); -//**[8Eh][8Fh]**// -void Set_Timer1_Count_Buffer(unsigned short WX); - -//////////////////////////////////////////////////////////////////////// -////**** [ Function : BTE ] ****//// -//**[90h]**// - -//[90h]========================================================================= -void BTE_Enable(void); -void BTE_Disable(void); - -void Check_BTE_Busy(void); - -void Pattern_Format_8X8(void); -void Pattern_Format_16X16(void); - -//[91h]========================================================================= -void BTE_ROP_Code(unsigned char setx); -void BTE_Operation_Code(unsigned char setx); - -//[92h]========================================================================= -void BTE_S0_Color_8bpp(void); -void BTE_S0_Color_16bpp(void); -void BTE_S0_Color_24bpp(void); - -void BTE_S1_Color_8bpp(void); -void BTE_S1_Color_16bpp(void); -void BTE_S1_Color_24bpp(void); -void BTE_S1_Color_Constant(void); -void BTE_S1_Color_8bit_Alpha(void); -void BTE_S1_Color_16bit_Alpha(void); - -void BTE_Destination_Color_8bpp(void); -void BTE_Destination_Color_16bpp(void); -void BTE_Destination_Color_24bpp(void); - -//[93h][94h][95h][96h]========================================================================= -void BTE_S0_Memory_Start_Address(unsigned long Addr); - -//[97h][98h]========================================================================= -void BTE_S0_Image_Width(unsigned short WX); - -//[99h][9Ah][9Bh][9Ch]========================================================================= -void BTE_S0_Window_Start_XY(unsigned short WX,unsigned short HY); - -//[9Dh][9Eh][9Fh][A0h]========================================================================= -void BTE_S1_Memory_Start_Address(unsigned long Addr); -void S1_Constant_color_256(unsigned char temp); -void S1_Constant_color_65k(unsigned short temp); -void S1_Constant_color_16M(unsigned long temp); - -//[A1h][A2h]========================================================================= -void BTE_S1_Image_Width(unsigned short WX); - -//[A3h][A4h][A5h][A6h]========================================================================= -void BTE_S1_Window_Start_XY(unsigned short WX,unsigned short HY); - -//[A7h][A8h][A9h][AAh]========================================================================= -void BTE_Destination_Memory_Start_Address(unsigned long Addr); - -//[ABh][ACh]========================================================================= -void BTE_Destination_Image_Width(unsigned short WX); - -//[ADh][AEh][AFh][B0h]========================================================================= -void BTE_Destination_Window_Start_XY(unsigned short WX,unsigned short HY); - -//[B1h][B2h][B3h][B4h]========================================================================= -void BTE_Window_Size(unsigned short WX, unsigned short WY); - -//[B5h]========================================================================= -void BTE_Alpha_Blending_Effect(unsigned char temp); - - -//**[B5h]**// - -//////////////////////////////////////////////////////////////////////// -////**** [ Function : Serial Flash ] ****//// - - -//REG[B6h] Serial flash DMA Controller REG (DMA_CTRL) -void Start_SFI_DMA(void); -void Check_Busy_SFI_DMA(void); - -//REG[B7h] Serial Flash/ROM Controller Register (SFL_CTRL) -void Select_SFI_0(void); -void Select_SFI_1(void); -void Select_SFI_Font_Mode(void); -void Select_SFI_DMA_Mode(void); -void Select_SFI_24bit_Address(void); -void Select_SFI_32bit_Address(void); -void Select_SFI_Waveform_Mode_0(void); -void Select_SFI_Waveform_Mode_3(void); -void Select_SFI_0_DummyRead(void); -void Select_SFI_8_DummyRead(void); -void Select_SFI_16_DummyRead(void); -void Select_SFI_24_DummyRead(void); -void Select_SFI_Single_Mode(void); -void Select_SFI_Dual_Mode0(void); -void Select_SFI_Dual_Mode1(void); - -//REG[B8h] SPI master Tx /Rx FIFO Data Register (SPIDR) -unsigned char SPI_Master_FIFO_Data_Put(unsigned char Data); -unsigned char SPI_Master_FIFO_Data_Get(void); - -//REG[B9h] SPI master Control Register (SPIMCR2) -void Mask_SPI_Master_Interrupt_Flag(void); -void Select_nSS_drive_on_xnsfcs0(void); -void Select_nSS_drive_on_xnsfcs1(void); -void nSS_Inactive(void); -void nSS_Active(void); -void OVFIRQEN_Enable(void); -void EMTIRQEN_Enable(void); -void Reset_CPOL(void); -void Set_CPOL(void); -void Reset_CPHA(void); -void Set_CPHA(void); - -//REG[BAh] SPI master Status Register (SPIMSR) -unsigned char Tx_FIFO_Empty_Flag(void); -unsigned char Tx_FIFO_Full_Flag(void); -unsigned char Rx_FIFO_Empty_Flag(void); -unsigned char Rx_FIFO_full_flag(void); -unsigned char OVFI_Flag(void); -void Clear_OVFI_Flag(void); -unsigned char EMTI_Flag(void); -void Clear_EMTI_Flag(void); - -//REG[BB] SPI Clock period (SPIDIV) -void SPI_Clock_Period(unsigned char temp); - - -//**[BCh][BDh][BEh][BFh]**// -void SFI_DMA_Source_Start_Address(unsigned long Addr); -//**[C0h][C1h][C2h][C3h]**// -void SFI_DMA_Destination_Start_Address(unsigned long Addr); -void SFI_DMA_Destination_Upper_Left_Corner(unsigned short WX,unsigned short HY); -//**[C4h][C5h]**// -void SFI_DMA_Destination_Width(unsigned short WX); -//**[C6h][C7h][C8h][C9h]**// -void SFI_DMA_Transfer_Number(unsigned long Addr); -void SFI_DMA_Transfer_Width_Height(unsigned short WX,unsigned short HY); -//**[CAh][CBh]**// -void SFI_DMA_Source_Width(unsigned short WX); - -//////////////////////////////////////////////////////////////////////// -////**** [ Function : Font ] ****//// -//**[CCh]**// - -void Font_Select_UserDefine_Mode(void); -void CGROM_Select_Internal_CGROM(void); -void CGROM_Select_Genitop_FontROM(void); -void Font_Select_8x16_16x16(void); -void Font_Select_12x24_24x24(void); -void Font_Select_16x32_32x32(void); -void Internal_CGROM_Select_ISOIEC8859_1(void); -void Internal_CGROM_Select_ISOIEC8859_2(void); -void Internal_CGROM_Select_ISOIEC8859_3(void); -void Internal_CGROM_Select_ISOIEC8859_4(void); -//**[CDh]**// -void Enable_Font_Alignment(void); -void Disable_Font_Alignment(void); -void Font_Background_select_Transparency(void); -void Font_Background_select_Color(void); -void Font_0_degree(void); -void Font_90_degree(void); -void Font_Width_X1(void); -void Font_Width_X2(void); -void Font_Width_X3(void); -void Font_Width_X4(void); -void Font_Height_X1(void); -void Font_Height_X2(void); -void Font_Height_X3(void); -void Font_Height_X4(void); -//**[CEh]**// -void GTFont_Select_GT21L16TW_GT21H16T1W(void); -void GTFont_Select_GT23L16U2W(void); -void GTFont_Select_GT23L24T3Y_GT23H24T3Y(void); -void GTFont_Select_GT23L24M1Z(void); -void GTFont_Select_GT23L32S4W_GT23H32S4W(void); -void GTFont_Select_GT20L24F6Y(void); -void GTFont_Select_GT21L24S1W(void); -void GTFont_Select_GT22L16A1Y(void); -//**[CFh]**// -void Set_GTFont_Decoder(unsigned char temp); -//**[D0h]**// -void Font_Line_Distance(unsigned char temp); -//**[D1h]**// -void Set_Font_to_Font_Width(unsigned char temp); -//**[D2h]~[D4h]**// -void Foreground_RGB(unsigned char RED,unsigned char GREEN,unsigned char BLUE); -void Foreground_color_256(unsigned char temp); -void Foreground_color_65k(unsigned short temp); -void Foreground_color_16M(unsigned long temp); -//**[D5h]~[D7h]**// -void Background_RGB(unsigned char RED,unsigned char GREEN,unsigned char BLUE); -void Background_color_256(unsigned char temp); -void Background_color_65k(unsigned short temp); -void Background_color_16M(unsigned long temp); -//**[DBh]~[DEh]**// -void CGRAM_Start_address(unsigned long Addr); -//**[DFh]**// -void Power_Normal_Mode(void); -void Power_Saving_Standby_Mode(void); -void Power_Saving_Suspend_Mode(void); -void Power_Saving_Sleep_Mode(void); - -//////////////////////////////////////////////////////////////////////// -////**** [ Function : SDRAM ] ****//// -//**[E0h]~[E4h]**// -// LT768_Select_SDRAM(); - - -//////////////////////////////////////////////////////////////////////// -////**** [ Function : I2C ] ****//// -//**[E5h]~[EAh]**// -void LT768_I2CM_Clock_Prescale(unsigned short WX); -//**[E7h]**// -void LT768_I2CM_Transmit_Data(unsigned char temp); -//**[E8h]**// -unsigned char LT768_I2CM_Receiver_Data(void); -//**[E9h]**// - -void LT768_I2CM_Read_With_Ack(void); -void LT768_I2CM_Read_With_Nack(void); -void LT768_I2CM_Write_With_Start(void); -void LT768_I2CM_Write(void); -void LT768_I2CM_Stop(void); - - -//**[EAh]**// -unsigned char LT768_I2CM_Check_Slave_ACK(void); -unsigned char LT768_I2CM_Bus_Busy(void); -unsigned char LT768_I2CM_transmit_Progress(void); -unsigned char LT768_I2CM_Arbitration(void); - - - -//////////////////////////////////////////////////////////////////////// -////**** [ Function : GPIO ] ****//// -//[F0h][F1h] -void Set_GPIO_A_In_Out(unsigned char temp); -void Write_GPIO_A_7_0(unsigned char temp); -unsigned char Read_GPIO_A_7_0(void); -//[F2h] -void Write_GPIO_B_7_4(unsigned char temp); -unsigned char Read_GPIO_B_7_0(void); -//[F3h][F4h] -void Set_GPIO_C_In_Out(unsigned char temp); -void Write_GPIO_C_7_0(unsigned char temp); -unsigned char Read_GPIO_C_7_0(void); -//[F5h][F6h] -void Set_GPIO_D_In_Out(unsigned char temp); -void Write_GPIO_D_7_0(unsigned char temp); -unsigned char Read_GPIO_D_7_0(void); -//[F7h][F8h] -void Set_GPIO_E_In_Out(unsigned char temp); -void Write_GPIO_E_7_0(unsigned char temp); -unsigned char Read_GPIO_E_7_0(void); -//[F9h][FAh] -void Set_GPIO_F_In_Out(unsigned char temp); -void Write_GPIO_F_7_0(unsigned char temp); -unsigned char Read_GPIO_F_7_0(void); - - -//////////////////////////////////////////////////////////////////////// -////**** [ Function : Key ] ****//// -//**[FBh]~[FFh]**// -//[FBh] -void Long_Key_enable(void); -void Key_Scan_Freg(unsigned char temp); //set bit2~0 - -//[FCh] -void Key_Scan_Wakeup_Function_Enable(void); -void Long_Key_Timing_Adjustment(unsigned char setx);//set bit5~3 -unsigned char Numbers_of_Key_Hit(void); - -//[FDh][FEh][FFh] -unsigned char Read_Key_Strobe_Data_0(void); -unsigned char Read_Key_Strobe_Data_1(void); -unsigned char Read_Key_Strobe_Data_2(void); - -void Show_String(char *str); -void Show_picture(unsigned long numbers,const unsigned short *data); - -void PWM0_ON(void); //开PWM0 - -void lt768_hw_reset(void); -void System_Check_Temp(void); -void Enable_SPI_Flash_DMA(unsigned char val); - -#endif - +/* +* Copyright (c) 2022 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file lt768.h + * @brief lt768 register relative driver, inherit from Levetop Electronics + * @version 1.0 + * @author AIIT XUOS Lab + * @date 2022.9.19 + */ + +#ifndef __LT768_H_ +#define __LT768_H_ + +#define cSetb0 0x01 +#define cSetb1 0x02 +#define cSetb2 0x04 +#define cSetb3 0x08 +#define cSetb4 0x10 +#define cSetb5 0x20 +#define cSetb6 0x40 +#define cSetb7 0x80 + +#define cClrb0 0xfe +#define cClrb1 0xfd +#define cClrb2 0xfb +#define cClrb3 0xf7 +#define cClrb4 0xef +#define cClrb5 0xdf +#define cClrb6 0xbf +#define cClrb7 0x7f + + +#define STM32_FSMC_8 0 //16bits bus + +void LCD_CmdWrite(uint8_t cmd); +void LCD_DataWrite(uint8_t data); +uint8_t LCD_StatusRead(void); +uint8_t LCD_DataRead(void); +void LCD_DataWrite_Pixel(uint8_t data); + +void LCD_RegisterWrite(uint8_t Cmd, uint8_t Data); +uint8_t LCD_RegisterRead(uint8_t Cmd); + +void Check_Mem_WR_FIFO_not_Full(void); +void Check_Mem_WR_FIFO_Empty(void); +void Check_Mem_RD_FIFO_not_Full(void); +void Check_Mem_RD_FIFO_not_Empty(void); +void Check_2D_Busy(void); +void Check_SDRAM_Ready(void); +uint8_t Power_Saving_Status(void); +void Check_Power_is_Normal(void); +void Check_Power_is_Saving(void); +void Check_NO_Interrupt(void); +void Check_Interrupt_Occur(void); + +void Check_Busy_Draw(void); +void Check_Busy_SFI_DMA(void); + +//**[00h]**// +void LT768_SW_Reset(void); +//**[01h]**// +void Enable_PLL(void); +void LT768_Sleep(void); +void LT768_WakeUp(void); +void TFT_24bit(void); +void TFT_18bit(void); +void TFT_16bit(void); +void TFT_LVDS(void); +void Key_Scan_Enable(void); +void Key_Scan_Disable(void); +void LT768_I2CM_Enable(void); +void LT768_I2CM_Disable(void); +void Enable_SFlash_SPI(void); +void Disable_SFlash_SPI(void); +void Host_Bus_8bit(void); +void Host_Bus_16bit(void); +//**[02h]**// + +void RGB_8b_8bpp(void); +void RGB_8b_16bpp(void); +void RGB_8b_24bpp(void); + +void RGB_16b_8bpp(void); +void RGB_16b_16bpp(void); +void RGB_16b_24bpp_mode1(void); +void RGB_16b_24bpp_mode2(void); + +void MemRead_Left_Right_Top_Down(void); +void MemRead_Right_Left_Top_Down(void); +void MemRead_Top_Down_Left_Right(void); +void MemRead_Down_Top_Left_Right(void); + +void MemWrite_Left_Right_Top_Down(void); +void MemWrite_Right_Left_Top_Down(void); +void MemWrite_Top_Down_Left_Right(void); +void MemWrite_Down_Top_Left_Right(void); +//**[03h]**// +void Interrupt_Active_Low(void); +void Interrupt_Active_High(void); +void ExtInterrupt_Debounce(void); +void ExtInterrupt_Nodebounce(void); +void ExtInterrupt_Input_Low_Level_Trigger(void); +void ExtInterrupt_Input_High_Level_Trigger(void); +void ExtInterrupt_Input_Falling_Edge_Trigger(void); +void ExtInterrupt_Input_Rising_Edge_Trigger(void); +void LVDS_Format1(void); +void LVDS_Format2(void); +void Graphic_Mode(void); +void Text_Mode(void); +void Memory_Select_SDRAM(void); +void Memory_Select_Graphic_Cursor_RAM(void); +void Memory_Select_Color_Palette_RAM(void); +//**[05h]**// +//**[06h]**// +//**[07h]**// +//**[09h]**// +//**[0Ah]**// +//**[0Bh]**// +void Enable_Resume_Interrupt(void); +void Disable_Resume_Interrupt(void); +void Enable_ExtInterrupt_Input(void); +void Disable_ExtInterrupt_Input(void); +void Enable_I2CM_Interrupt(void); +void Disable_I2CM_Interrupt(void); +void Enable_Vsync_Interrupt(void); +void Disable_Vsync_Interrupt(void); +void Enable_KeyScan_Interrupt(void); +void Disable_KeyScan_Interrupt(void); +void Enable_DMA_Draw_BTE_Interrupt(void); +void Disable_DMA_Draw_BTE_Interrupt(void); +void Enable_PWM1_Interrupt(void); +void Disable_PWM1_Interrupt(void); +void Enable_PWM0_Interrupt(void); +void Disable_PWM0_Interrupt(void); +//**[0Ch]**// +uint8_t Read_Interrupt_status(void); +void Clear_Resume_Interrupt_Flag(void); +void Clear_ExtInterrupt_Input_Flag(void); +void Clear_I2CM_Interrupt_Flag(void); +void Clear_Vsync_Interrupt_Flag(void); +void Clear_KeyScan_Interrupt_Flag(void); +void Clear_DMA_Draw_BTE_Interrupt_Flag(void); +void Clear_PWM1_Interrupt_Flag(void); +void Clear_PWM0_Interrupt_Flag(void); +//**[0Dh]**// +void Mask_Resume_Interrupt_Flag(void); +void Mask_ExtInterrupt_Input_Flag(void); +void Mask_I2CM_Interrupt_Flag(void); +void Mask_Vsync_Interrupt_Flag(void); +void Mask_KeyScan_Interrupt_Flag(void); +void Mask_DMA_Draw_BTE_Interrupt_Flag(void); +void Mask_PWM1_Interrupt_Flag(void); +void Mask_PWM0_Interrupt_Flag(void); +// +void Enable_Resume_Interrupt_Flag(void); +void Enable_ExtInterrupt_Input_Flag(void); +void Enable_I2CM_Interrupt_Flag(void); +void Enable_Vsync_Interrupt_Flag(void); +void Enable_KeyScan_Interrupt_Flag(void); +void Enable_DMA_Draw_BTE_Interrupt_Flag(void); +void Enable_PWM1_Interrupt_Flag(void); +void Enable_PWM0_Interrupt_Flag(void); +//**[0Eh]**// +void Enable_GPIOF_PullUp(void); +void Enable_GPIOE_PullUp(void); +void Enable_GPIOD_PullUp(void); +void Enable_GPIOC_PullUp(void); +void Enable_XDB15_8_PullUp(void); +void Enable_XDB7_0_PullUp(void); +void Disable_GPIOF_PullUp(void); +void Disable_GPIOE_PullUp(void); +void Disable_GPIOD_PullUp(void); +void Disable_GPIOC_PullUp(void); +void Disable_XDB15_8_PullUp(void); +void Disable_XDB7_0_PullUp(void); + +//**[0Fh]**// +void XPDAT18_Set_GPIO_D7(void); +void XPDAT18_Set_KOUT4(void); +void XPDAT17_Set_GPIO_D5(void); +void XPDAT17_Set_KOUT2(void); +void XPDAT16_Set_GPIO_D4(void); +void XPDAT16_Set_KOUT1(void); +void XPDAT9_Set_GPIO_D3(void); +void XPDAT9_Set_KOUT3(void); +void XPDAT8_Set_GPIO_D2(void); +void XPDAT8_Set_KIN3(void); +void XPDAT2_Set_GPIO_D6(void); +void XPDAT2_Set_KIN4(void); +void XPDAT1_Set_GPIO_D1(void); +void XPDAT1_Set_KIN2(void); +void XPDAT0_Set_GPIO_D0(void); +void XPDAT0_Set_KIN1(void); + +//**[10h]**// +void Enable_PIP1(void); +void Disable_PIP1(void); +void Enable_PIP2(void); +void Disable_PIP2(void); +void Select_PIP1_Parameter(void); +void Select_PIP2_Parameter(void); +void Select_Main_Window_8bpp(void); +void Select_Main_Window_16bpp(void); +void Select_Main_Window_24bpp(void); +//**[11h]**// +void Select_PIP1_Window_8bpp(void); +void Select_PIP1_Window_16bpp(void); +void Select_PIP1_Window_24bpp(void); +void Select_PIP2_Window_8bpp(void); +void Select_PIP2_Window_16bpp(void); +void Select_PIP2_Window_24bpp(void); +//**[12h]**// +void PCLK_Rising(void); +void PCLK_Falling(void); +void Display_ON(void); +void Display_OFF(void); +void Color_Bar_ON(void); +void Color_Bar_OFF(void); +void HSCAN_L_to_R(void); +void HSCAN_R_to_L(void); +void VSCAN_T_to_B(void); +void VSCAN_B_to_T(void); +void PDATA_Set_RGB(void); +void PDATA_Set_RBG(void); +void PDATA_Set_GRB(void); +void PDATA_Set_GBR(void); +void PDATA_Set_BRG(void); +void PDATA_Set_BGR(void); +void PDATA_IDLE_STATE(void); + +//**[13h]**// +void HSYNC_Low_Active(void); +void HSYNC_High_Active(void); +void VSYNC_Low_Active(void); +void VSYNC_High_Active(void); +void DE_Low_Active(void); +void DE_High_Active(void); +void Idle_DE_Low(void); +void Idle_DE_High(void); +void Idle_PCLK_Low(void); +void Idle_PCLK_High(void); +void Idle_PDAT_Low(void); +void Idle_PDAT_High(void); +void Idle_HSYNC_Low(void); +void Idle_HSYNC_High(void); +void Idle_VSYNC_Low(void); +void Idle_VSYNC_High(void); +//**[14h][15h][1Ah][1Bh]**// +void LCD_HorizontalWidth_VerticalHeight(uint16_t WX, uint16_t HY); +//**[16h][17h]**// +void LCD_Horizontal_Non_Display(uint16_t WX); +//**[18h]**// +void LCD_HSYNC_Start_Position(uint16_t WX); +//**[19h]**// +void LCD_HSYNC_Pulse_Width(uint16_t WX); +//**[1Ch][1Dh]**// +void LCD_Vertical_Non_Display(uint16_t HY); +//**[1Eh]**// +void LCD_VSYNC_Start_Position(uint16_t HY); +//**[1Fh]**// +void LCD_VSYNC_Pulse_Width(uint16_t HY); +//**[20h][21h][22h][23h]**// +void Main_Image_Start_Address(uint32_t Addr); +//**[24h][25h]**// +void Main_Image_Width(uint16_t WX); +//**[26h][27h][28h][29h]**// +void Main_Window_Start_XY(uint16_t WX, uint16_t HY); +//**[2Ah][2Bh][2Ch][2Dh]**// +void PIP_Display_Start_XY(uint16_t WX, uint16_t HY); +//**[2Eh][2Fh][30h][31h]**// +void PIP_Image_Start_Address(uint32_t Addr); +//**[32h][33h]**// +void PIP_Image_Width(uint16_t WX); +//**[34h][35h][36h][37h]**// +void PIP_Window_Image_Start_XY(uint16_t WX, uint16_t HY); +//**[38h][39h][3Ah][3Bh]**// +void PIP_Window_Width_Height(uint16_t WX, uint16_t HY); +//**[3C]**// +void Enable_Graphic_Cursor(void); +void Disable_Graphic_Cursor(void); +void Select_Graphic_Cursor_1(void); +void Select_Graphic_Cursor_2(void); +void Select_Graphic_Cursor_3(void); +void Select_Graphic_Cursor_4(void); +void Enable_Text_Cursor(void); +void Disable_Text_Cursor(void); +void Enable_Text_Cursor_Blinking(void); +void Disable_Text_Cursor_Blinking(void); +//**[3D]**// +void Blinking_Time_Frames(uint8_t temp); +//**[3E][3Fh]**// +void Text_Cursor_H_V(uint16_t WX, uint16_t HY); +//**[40h][41h][42h][43h]**// +void Graphic_Cursor_XY(uint16_t WX, uint16_t HY); +//**[44]**// +void Set_Graphic_Cursor_Color_1(uint8_t temp); +//**[45]**// +void Set_Graphic_Cursor_Color_2(uint8_t temp); +//**[50h][51h][52h][53h]**// +void Canvas_Image_Start_address(uint32_t Addr); +//**[54h][55h]**// +void Canvas_image_width(uint16_t WX); +//**[56h][57h][58h][59h]**// +void Active_Window_XY(uint16_t WX, uint16_t HY); +//**[5Ah][5Bh][5Ch][5Dh]**// +void Active_Window_WH(uint16_t WX, uint16_t HY); +//**[5E]**// +void Select_Write_Data_Position(void); +void Select_Read_Data_Position(void); +void Memory_XY_Mode(void); +void Memory_Linear_Mode(void); +void Memory_8bpp_Mode(void); +void Memory_16bpp_Mode(void); +void Memory_24bpp_Mode(void); +//**[5Fh][60h][61h][62h]**// +void Goto_Pixel_XY(uint16_t WX, uint16_t HY); +void Goto_Linear_Addr(uint32_t Addr); +//**[63h][64h][65h][66h]**// +void Goto_Text_XY(uint16_t WX, uint16_t HY); + +//////////////////////////////////////////////////////////////////////// +////**** [ Function : Draw ] ****//// +//**[67h]**// +void Start_Line(void); +void Start_Triangle(void); +void Start_Triangle_Fill(void); +//**[68h]~[73h]**// +void Line_Start_XY(uint16_t WX, uint16_t HY); +void Line_End_XY(uint16_t WX, uint16_t HY); +void Triangle_Point1_XY(uint16_t WX, uint16_t HY); +void Triangle_Point2_XY(uint16_t WX, uint16_t HY); +void Triangle_Point3_XY (uint16_t WX, uint16_t HY); +void Square_Start_XY(uint16_t WX, uint16_t HY); +void Square_End_XY(uint16_t WX, uint16_t HY); +//**[76h]**// +void Start_Circle_or_Ellipse(void); +void Start_Circle_or_Ellipse_Fill(void); +void Start_Left_Down_Curve(void); +void Start_Left_Up_Curve(void); +void Start_Right_Up_Curve(void); +void Start_Right_Down_Curve(void); +void Start_Left_Down_Curve_Fill(void); +void Start_Left_Up_Curve_Fill(void); +void Start_Right_Up_Curve_Fill(void); +void Start_Right_Down_Curve_Fill(void); +void Start_Square(void); +void Start_Square_Fill(void); +void Start_Circle_Square(void); +void Start_Circle_Square_Fill(void); +//**[77h]~[7Eh]**// +void Circle_Center_XY(uint16_t WX, uint16_t HY); +void Ellipse_Center_XY(uint16_t WX, uint16_t HY); +void Circle_Radius_R(uint16_t WX); +void Ellipse_Radius_RxRy(uint16_t WX, uint16_t HY); +void Circle_Square_Radius_RxRy(uint16_t WX, uint16_t HY); + +//////////////////////////////////////////////////////////////////////// +////**** [ Function : PWM ] ****//// +//**[84h]**// +void Set_PWM_Prescaler_1_to_256(uint16_t WX); +//**[85h]**// +void Select_PWM1_Clock_Divided_By_1(void); +void Select_PWM1_Clock_Divided_By_2(void); +void Select_PWM1_Clock_Divided_By_4(void); +void Select_PWM1_Clock_Divided_By_8(void); +void Select_PWM0_Clock_Divided_By_1(void); +void Select_PWM0_Clock_Divided_By_2(void); +void Select_PWM0_Clock_Divided_By_4(void); +void Select_PWM0_Clock_Divided_By_8(void); +//[85h].[bit3][bit2] +void Select_PWM1_is_ErrorFlag(void); +void Select_PWM1(void); +void Select_PWM1_is_Osc_Clock(void); +//[85h].[bit1][bit0] +void Select_PWM0_is_GPIO_C7(void); +void Select_PWM0(void); +void Select_PWM0_is_Core_Clock(void); +//**[86h]**// +//[86h]PWM1 +void Enable_PWM1_Inverter(void); +void Disable_PWM1_Inverter(void); +void Auto_Reload_PWM1(void); +void One_Shot_PWM1(void); +void Start_PWM1(void); +void Stop_PWM1(void); +//[86h]PWM0 +void Enable_PWM0_Dead_Zone(void); +void Disable_PWM0_Dead_Zone(void); +void Enable_PWM0_Inverter(void); +void Disable_PWM0_Inverter(void); +void Auto_Reload_PWM0(void); +void One_Shot_PWM0(void); +void Start_PWM0(void); +void Stop_PWM0(void); +//**[87h]**// +void Set_Timer0_Dead_Zone_Length(uint8_t temp); +//**[88h][89h]**// +void Set_Timer0_Compare_Buffer(uint16_t WX); +//**[8Ah][8Bh]**// +void Set_Timer0_Count_Buffer(uint16_t WX); +//**[8Ch][8Dh]**// +void Set_Timer1_Compare_Buffer(uint16_t WX); +//**[8Eh][8Fh]**// +void Set_Timer1_Count_Buffer(uint16_t WX); + +//////////////////////////////////////////////////////////////////////// +////**** [ Function : BTE ] ****//// +//**[90h]**// + +//[90h]========================================================================= +void BTE_Enable(void); +void BTE_Disable(void); + +void Check_BTE_Busy(void); + +void Pattern_Format_8X8(void); +void Pattern_Format_16X16(void); + +//[91h]========================================================================= +void BTE_ROP_Code(uint8_t setx); +void BTE_Operation_Code(uint8_t setx); + +//[92h]========================================================================= +void BTE_S0_Color_8bpp(void); +void BTE_S0_Color_16bpp(void); +void BTE_S0_Color_24bpp(void); + +void BTE_S1_Color_8bpp(void); +void BTE_S1_Color_16bpp(void); +void BTE_S1_Color_24bpp(void); +void BTE_S1_Color_Constant(void); +void BTE_S1_Color_8bit_Alpha(void); +void BTE_S1_Color_16bit_Alpha(void); + +void BTE_Destination_Color_8bpp(void); +void BTE_Destination_Color_16bpp(void); +void BTE_Destination_Color_24bpp(void); + +//[93h][94h][95h][96h]========================================================================= +void BTE_S0_Memory_Start_Address(uint32_t Addr); + +//[97h][98h]========================================================================= +void BTE_S0_Image_Width(uint16_t WX); + +//[99h][9Ah][9Bh][9Ch]========================================================================= +void BTE_S0_Window_Start_XY(uint16_t WX, uint16_t HY); + +//[9Dh][9Eh][9Fh][A0h]========================================================================= +void BTE_S1_Memory_Start_Address(uint32_t Addr); +void S1_Constant_color_256(uint8_t temp); +void S1_Constant_color_65k(uint16_t temp); +void S1_Constant_color_16M(uint32_t temp); + +//[A1h][A2h]========================================================================= +void BTE_S1_Image_Width(uint16_t WX); + +//[A3h][A4h][A5h][A6h]========================================================================= +void BTE_S1_Window_Start_XY(uint16_t WX, uint16_t HY); + +//[A7h][A8h][A9h][AAh]========================================================================= +void BTE_Destination_Memory_Start_Address(uint32_t Addr); + +//[ABh][ACh]========================================================================= +void BTE_Destination_Image_Width(uint16_t WX); + +//[ADh][AEh][AFh][B0h]========================================================================= +void BTE_Destination_Window_Start_XY(uint16_t WX, uint16_t HY); + +//[B1h][B2h][B3h][B4h]========================================================================= +void BTE_Window_Size(uint16_t WX, uint16_t WY); + +//[B5h]========================================================================= +void BTE_Alpha_Blending_Effect(uint8_t temp); + + +//**[B5h]**// + +//////////////////////////////////////////////////////////////////////// +////**** [ Function : Serial Flash ] ****//// + + +//REG[B6h] Serial flash DMA Controller REG (DMA_CTRL) +void Start_SFI_DMA(void); +void Check_Busy_SFI_DMA(void); + +//REG[B7h] Serial Flash/ROM Controller Register (SFL_CTRL) +void Select_SFI_0(void); +void Select_SFI_1(void); +void Select_SFI_Font_Mode(void); +void Select_SFI_DMA_Mode(void); +void Select_SFI_24bit_Address(void); +void Select_SFI_32bit_Address(void); +void Select_SFI_Waveform_Mode_0(void); +void Select_SFI_Waveform_Mode_3(void); +void Select_SFI_0_DummyRead(void); +void Select_SFI_8_DummyRead(void); +void Select_SFI_16_DummyRead(void); +void Select_SFI_24_DummyRead(void); +void Select_SFI_Single_Mode(void); +void Select_SFI_Dual_Mode0(void); +void Select_SFI_Dual_Mode1(void); + +//REG[B8h] SPI master Tx /Rx FIFO Data Register (SPIDR) +uint8_t SPI_Master_FIFO_Data_Put(uint8_t Data); +uint8_t SPI_Master_FIFO_Data_Get(void); + +//REG[B9h] SPI master Control Register (SPIMCR2) +void Mask_SPI_Master_Interrupt_Flag(void); +void Select_nSS_drive_on_xnsfcs0(void); +void Select_nSS_drive_on_xnsfcs1(void); +void nSS_Inactive(void); +void nSS_Active(void); +void OVFIRQEN_Enable(void); +void EMTIRQEN_Enable(void); +void Reset_CPOL(void); +void Set_CPOL(void); +void Reset_CPHA(void); +void Set_CPHA(void); + +//REG[BAh] SPI master Status Register (SPIMSR) +uint8_t Tx_FIFO_Empty_Flag(void); +uint8_t Tx_FIFO_Full_Flag(void); +uint8_t Rx_FIFO_Empty_Flag(void); +uint8_t Rx_FIFO_full_flag(void); +uint8_t OVFI_Flag(void); +void Clear_OVFI_Flag(void); +uint8_t EMTI_Flag(void); +void Clear_EMTI_Flag(void); + +//REG[BB] SPI Clock period (SPIDIV) +void SPI_Clock_Period(uint8_t temp); + + +//**[BCh][BDh][BEh][BFh]**// +void SFI_DMA_Source_Start_Address(uint32_t Addr); +//**[C0h][C1h][C2h][C3h]**// +void SFI_DMA_Destination_Start_Address(uint32_t Addr); +void SFI_DMA_Destination_Upper_Left_Corner(uint16_t WX, uint16_t HY); +//**[C4h][C5h]**// +void SFI_DMA_Destination_Width(uint16_t WX); +//**[C6h][C7h][C8h][C9h]**// +void SFI_DMA_Transfer_Number(uint32_t Addr); +void SFI_DMA_Transfer_Width_Height(uint16_t WX, uint16_t HY); +//**[CAh][CBh]**// +void SFI_DMA_Source_Width(uint16_t WX); + +//////////////////////////////////////////////////////////////////////// +////**** [ Function : Font ] ****//// +//**[CCh]**// + +void Font_Select_UserDefine_Mode(void); +void CGROM_Select_Internal_CGROM(void); +void CGROM_Select_Genitop_FontROM(void); +void Font_Select_8x16_16x16(void); +void Font_Select_12x24_24x24(void); +void Font_Select_16x32_32x32(void); +void Internal_CGROM_Select_ISOIEC8859_1(void); +void Internal_CGROM_Select_ISOIEC8859_2(void); +void Internal_CGROM_Select_ISOIEC8859_3(void); +void Internal_CGROM_Select_ISOIEC8859_4(void); +//**[CDh]**// +void Enable_Font_Alignment(void); +void Disable_Font_Alignment(void); +void Font_Background_select_Transparency(void); +void Font_Background_select_Color(void); +void Font_0_degree(void); +void Font_90_degree(void); +void Font_Width_X1(void); +void Font_Width_X2(void); +void Font_Width_X3(void); +void Font_Width_X4(void); +void Font_Height_X1(void); +void Font_Height_X2(void); +void Font_Height_X3(void); +void Font_Height_X4(void); +//**[CEh]**// +void GTFont_Select_GT21L16TW_GT21H16T1W(void); +void GTFont_Select_GT23L16U2W(void); +void GTFont_Select_GT23L24T3Y_GT23H24T3Y(void); +void GTFont_Select_GT23L24M1Z(void); +void GTFont_Select_GT23L32S4W_GT23H32S4W(void); +void GTFont_Select_GT20L24F6Y(void); +void GTFont_Select_GT21L24S1W(void); +void GTFont_Select_GT22L16A1Y(void); +//**[CFh]**// +void Set_GTFont_Decoder(uint8_t temp); +//**[D0h]**// +void Font_Line_Distance(uint8_t temp); +//**[D1h]**// +void Set_Font_to_Font_Width(uint8_t temp); +//**[D2h]~[D4h]**// +void Foreground_RGB(uint8_t RED, uint8_t GREEN, uint8_t BLUE); +void Foreground_color_256(uint8_t temp); +void Foreground_color_65k(uint16_t temp); +void Foreground_color_16M(uint32_t temp); +//**[D5h]~[D7h]**// +void Background_RGB(uint8_t RED, uint8_t GREEN, uint8_t BLUE); +void Background_color_256(uint8_t temp); +void Background_color_65k(uint16_t temp); +void Background_color_16M(uint32_t temp); +//**[DBh]~[DEh]**// +void CGRAM_Start_address(uint32_t Addr); +//**[DFh]**// +void Power_Normal_Mode(void); +void Power_Saving_Standby_Mode(void); +void Power_Saving_Suspend_Mode(void); +void Power_Saving_Sleep_Mode(void); + +//////////////////////////////////////////////////////////////////////// +////**** [ Function : SDRAM ] ****//// +//**[E0h]~[E4h]**// +// LT768_Select_SDRAM(); + + +//////////////////////////////////////////////////////////////////////// +////**** [ Function : I2C ] ****//// +//**[E5h]~[EAh]**// +void LT768_I2CM_Clock_Prescale(uint16_t WX); +//**[E7h]**// +void LT768_I2CM_Transmit_Data(uint8_t temp); +//**[E8h]**// +uint8_t LT768_I2CM_Receiver_Data(void); +//**[E9h]**// + +void LT768_I2CM_Read_With_Ack(void); +void LT768_I2CM_Read_With_Nack(void); +void LT768_I2CM_Write_With_Start(void); +void LT768_I2CM_Write(void); +void LT768_I2CM_Stop(void); + + +//**[EAh]**// +uint8_t LT768_I2CM_Check_Slave_ACK(void); +uint8_t LT768_I2CM_Bus_Busy(void); +uint8_t LT768_I2CM_transmit_Progress(void); +uint8_t LT768_I2CM_Arbitration(void); + + + +//////////////////////////////////////////////////////////////////////// +////**** [ Function : GPIO ] ****//// +//[F0h][F1h] +void Set_GPIO_A_In_Out(uint8_t temp); +void Write_GPIO_A_7_0(uint8_t temp); +uint8_t Read_GPIO_A_7_0(void); +//[F2h] +void Write_GPIO_B_7_4(uint8_t temp); +uint8_t Read_GPIO_B_7_0(void); +//[F3h][F4h] +void Set_GPIO_C_In_Out(uint8_t temp); +void Write_GPIO_C_7_0(uint8_t temp); +uint8_t Read_GPIO_C_7_0(void); +//[F5h][F6h] +void Set_GPIO_D_In_Out(uint8_t temp); +void Write_GPIO_D_7_0(uint8_t temp); +uint8_t Read_GPIO_D_7_0(void); +//[F7h][F8h] +void Set_GPIO_E_In_Out(uint8_t temp); +void Write_GPIO_E_7_0(uint8_t temp); +uint8_t Read_GPIO_E_7_0(void); +//[F9h][FAh] +void Set_GPIO_F_In_Out(uint8_t temp); +void Write_GPIO_F_7_0(uint8_t temp); +uint8_t Read_GPIO_F_7_0(void); + + +//////////////////////////////////////////////////////////////////////// +////**** [ Function : Key ] ****//// +//**[FBh]~[FFh]**// +//[FBh] +void Long_Key_enable(void); +void Key_Scan_Freg(uint8_t temp); //set bit2~0 + +//[FCh] +void Key_Scan_Wakeup_Function_Enable(void); +void Long_Key_Timing_Adjustment(uint8_t setx);//set bit5~3 +uint8_t Numbers_of_Key_Hit(void); + +//[FDh][FEh][FFh] +uint8_t Read_Key_Strobe_Data_0(void); +uint8_t Read_Key_Strobe_Data_1(void); +uint8_t Read_Key_Strobe_Data_2(void); + +void Show_String(char *str); +void Show_picture(uint32_t numbers, const uint16_t *data); + +void PWM0_ON(void); //PWM0 + +void lt768_hw_reset(void); +void System_Check_Temp(void); +void Enable_SPI_Flash_DMA(uint8_t val); + +#endif + diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/include/nuttx/lcd/lt768_lib.h b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/include/nuttx/lcd/lt768_lib.h index 6c6adaf1f..345eb2e58 100755 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/include/nuttx/lcd/lt768_lib.h +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/include/nuttx/lcd/lt768_lib.h @@ -1,306 +1,913 @@ -/********************* COPYRIGHT ********************** -* File Name : lt768_lib.h -* Author : Levetop Electronics -* Version : V1.3 -* Date : 2019-5-14 -* Description : LT768x所有功能函数 -********************************************************/ - -#ifndef _LT768_Lib_H -#define _LT768_Lib_H -#include "lt768.h" - -//外部晶振 -#define XI_4M 0 -#define XI_8M 1 -#define XI_10M 0 -#define XI_12M 0 - -//分辨率 -#define LCD_XSIZE_TFT 480 -#define LCD_YSIZE_TFT 272 - -//参数 -#define LCD_VBPD 20 -#define LCD_VFPD 12 -#define LCD_VSPW 3 -#define LCD_HBPD 140 -#define LCD_HFPD 160 -#define LCD_HSPW 20 - -#define color256_black 0x00 -#define color256_white 0xff -#define color256_red 0xe0 -#define color256_green 0x1c -#define color256_blue 0x03 -#define color256_yellow color256_red|color256_green -#define color256_cyan color256_green|color256_blue -#define color256_purple color256_red|color256_blue - -#define color65k_black 0x0000 -#define color65k_white 0xffff -#define color65k_red 0xf800 -#define color65k_green 0x07e0 -#define color65k_blue 0x001f -#define color65k_yellow color65k_red|color65k_green -#define color65k_cyan color65k_green|color65k_blue -#define color65k_purple color65k_red|color65k_blue - -#define color65k_grayscale1 2113 -#define color65k_grayscale2 2113*2 -#define color65k_grayscale3 2113*3 -#define color65k_grayscale4 2113*4 -#define color65k_grayscale5 2113*5 -#define color65k_grayscale6 2113*6 -#define color65k_grayscale7 2113*7 -#define color65k_grayscale8 2113*8 -#define color65k_grayscale9 2113*9 -#define color65k_grayscale10 2113*10 -#define color65k_grayscale11 2113*11 -#define color65k_grayscale12 2113*12 -#define color65k_grayscale13 2113*13 -#define color65k_grayscale14 2113*14 -#define color65k_grayscale15 2113*15 -#define color65k_grayscale16 2113*16 -#define color65k_grayscale17 2113*17 -#define color65k_grayscale18 2113*18 -#define color65k_grayscale19 2113*19 -#define color65k_grayscale20 2113*20 -#define color65k_grayscale21 2113*21 -#define color65k_grayscale22 2113*22 -#define color65k_grayscale23 2113*23 -#define color65k_grayscale24 2113*24 -#define color65k_grayscale25 2113*25 -#define color65k_grayscale26 2113*26 -#define color65k_grayscale27 2113*27 -#define color65k_grayscale28 2113*28 -#define color65k_grayscale29 2113*29 -#define color65k_grayscale30 2113*30 - -#define color16M_black 0x00000000 -#define color16M_white 0x00ffffff -#define color16M_red 0x00ff0000 -#define color16M_green 0x0000ff00 -#define color16M_blue 0x000000ff -#define color16M_yellow color16M_red|color16M_green -#define color16M_cyan color16M_green|color16M_blue -#define color16M_purple color16M_red|color16M_blue - -/* LCD color */ -#define White 0xFFFF -#define Black 0x0000 -#define Grey 0xF7DE -#define Blue 0x001F -#define Blue2 0x051F -#define Red 0xF800 -#define Magenta 0xF81F -#define Green 0x07E0 -#define Cyan 0x7FFF -#define Yellow 0xFFE0 - -#define Line0 0 -#define Line1 24 -#define Line2 48 -#define Line3 72 -#define Line4 96 -#define Line5 120 -#define Line6 144 -#define Line7 168 -#define Line8 192 -#define Line9 216 -#define Line10 240 -#define Line11 264 -#define Line12 288 -#define Line13 312 -#define Line14 336 -#define Line15 360 -#define Line16 384 -#define Line17 408 -#define Line18 432 -#define Line19 456 -#define Line20 480 -#define Line21 504 -#define Line22 528 -#define Line23 552 -#define Line24 576 -#define Line25 600 - -void lt768_init(void); - -/* 写数据到内存 */ -void MPuint8_t_8bpp_Memory_Write(unsigned short x,unsigned short y,unsigned short w,unsigned short h,const unsigned char *data); -void MPuint8_t_16bpp_Memory_Write(unsigned short x,unsigned short y,unsigned short w,unsigned short h,const unsigned char *data); -void MPuint8_t_24bpp_Memory_Write(unsigned short x,unsigned short y,unsigned short w,unsigned short h,const unsigned char *data); -void MPuint16_t_16bpp_Memory_Write(unsigned short x,unsigned short y,unsigned short w,unsigned short h,const unsigned short *data); -void MPuint16_t_24bpp_Mode1_Memory_Write(unsigned short x,unsigned short y,unsigned short w,unsigned short h,const unsigned short *data); -void MPuint16_t_24bpp_Mode2_Memory_Write(unsigned short x,unsigned short y,unsigned short w,unsigned short h,const unsigned short *data); - -/* 硬件画线段 */ -void LT768_DrawLine(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned long LineColor); -void LT768_DrawLine_Width(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned long LineColor,unsigned short Width); - -/* 硬件画圆 */ -void LT768_DrawCircle(unsigned short XCenter,unsigned short YCenter,unsigned short R,unsigned long CircleColor); -void LT768_DrawCircle_Fill(unsigned short XCenter,unsigned short YCenter,unsigned short R,unsigned long ForegroundColor); -void LT768_DrawCircle_Width(unsigned short XCenter,unsigned short YCenter,unsigned short R,unsigned long CircleColor,unsigned long ForegroundColor,unsigned short Width); - -/* 硬件画椭圆 */ -void LT768_DrawEllipse(unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R,unsigned long EllipseColor); -void LT768_DrawEllipse_Fill(unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R,unsigned long ForegroundColor); -void LT768_DrawEllipse_Width(unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R,unsigned long EllipseColor,unsigned long ForegroundColor,unsigned short Width); - -/* 硬件画矩形 */ -void LT768_DrawSquare(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned long SquareColor); -void LT768_DrawSquare_Fill(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned long ForegroundColor); -void LT768_DrawSquare_Width(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned long SquareColor,unsigned long ForegroundColor,unsigned short Width); - -/* 硬件画圆角矩形 */ -void LT768_DrawCircleSquare(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short X_R,unsigned short Y_R,unsigned long CircleSquareColor); -void LT768_DrawCircleSquare_Fill(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short X_R,unsigned short Y_R,unsigned long ForegroundColor); -void LT768_DrawCircleSquare_Width(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short X_R,unsigned short Y_R,unsigned long CircleSquareColor,unsigned long ForegroundColor,unsigned short Width); - -/* 硬件画三角形 */ -void LT768_DrawTriangle(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short X3,unsigned short Y3,unsigned long TriangleColor); -void LT768_DrawTriangle_Fill(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short X3,unsigned short Y3,unsigned long ForegroundColor); -void LT768_DrawTriangle_Frame(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short X3,unsigned short Y3,unsigned long TriangleColor,unsigned long ForegroundColor); - -/* 硬件画四边形 */ -void LT768_DrawQuadrilateral(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short X3,unsigned short Y3,unsigned short X4,unsigned short Y4,unsigned long ForegroundColor); -void LT768_DrawQuadrilateral_Fill(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short X3,unsigned short Y3,unsigned short X4,unsigned short Y4,unsigned long ForegroundColor); -void LT768_DrawTriangle_Frame(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short X3,unsigned short Y3,unsigned long TriangleColor ,unsigned long ForegroundColor); - -/* 硬件画五边形 */ -void LT768_DrawPentagon(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short X3,unsigned short Y3,unsigned short X4,unsigned short Y4,unsigned short X5,unsigned short Y5,unsigned long ForegroundColor); -void LT768_DrawPentagon_Fill(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short X3,unsigned short Y3,unsigned short X4,unsigned short Y4,unsigned short X5,unsigned short Y5,unsigned long ForegroundColor); - -/* 硬件画曲线 */ -void LT768_DrawLeftUpCurve(unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R,unsigned long CurveColor); -void LT768_DrawLeftDownCurve(unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R,unsigned long CurveColor); -void LT768_DrawRightUpCurve(unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R,unsigned long CurveColor); -void LT768_DrawRightDownCurve(unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R,unsigned long CurveColor); -void LT768_SelectDrawCurve(unsigned short XCenter ,unsigned short YCenter,unsigned short X_R,unsigned short Y_R,unsigned long CurveColor,unsigned short Dir); - -/* 硬件画1/4椭圆 */ -void LT768_DrawLeftUpCurve_Fill(unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R,unsigned long ForegroundColor); -void LT768_DrawLeftDownCurve_Fill(unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R,unsigned long ForegroundColor); -void LT768_DrawRightUpCurve_Fill(unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R,unsigned long ForegroundColor); -void LT768_DrawRightDownCurve_Fill(unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R,unsigned long ForegroundColor); -void LT768_SelectDrawCurve_Fill(unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R,unsigned long CurveColor,unsigned short Dir); - -/* 硬件画圆柱 */ -unsigned char LT768_DrawCylinder(unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R,unsigned short H,unsigned long CylinderColor,unsigned long ForegroundColor); - -/* 硬件画四棱柱 */ -void LT768_DrawQuadrangular(unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short X3,unsigned short Y3,unsigned short X4,unsigned short Y4,unsigned short X5,unsigned short Y5,unsigned short X6,unsigned short Y6,unsigned long QuadrangularColor,unsigned long ForegroundColor); - -/* 表格 */ -void LT768_MakeTable(unsigned short X1,unsigned short Y1,unsigned short W,unsigned short H,unsigned short Line,unsigned short Row,unsigned long TableColor,unsigned long ItemColor,unsigned long ForegroundColor,unsigned short width1,unsigned short width2,unsigned char mode); - -/* 线性模式下DMA传输数据到SDRAM中 */ -void LT768_DMA_24bit_Linear(unsigned char SCS,unsigned char Clk,unsigned long flash_addr,unsigned long memory_ad,unsigned long data_num); -void LT768_DMA_32bit_Linear(unsigned char SCS,unsigned char Clk,unsigned long flash_addr,unsigned long memory_ad,unsigned long data_num); - -/* 区块模式下DMA传输数据到SDRAM中 */ -void LT768_DMA_24bit_Block(unsigned char SCS,unsigned char Clk,unsigned short X1,unsigned short Y1 ,unsigned short X_W,unsigned short Y_H,unsigned short P_W,unsigned long Addr); -void LT768_DMA_32bit_Block(unsigned char SCS,unsigned char Clk,unsigned short X1,unsigned short Y1 ,unsigned short X_W,unsigned short Y_H,unsigned short P_W,unsigned long Addr); - -/* 使用内建字库 */ -void LT768_Select_Internal_Font_Init(unsigned char Size,unsigned char XxN,unsigned char YxN,unsigned char ChromaKey,unsigned char Alignment); -void LT768_Print_Internal_Font_String(unsigned short x,unsigned short y,unsigned long FontColor,unsigned long BackGroundColor ,char *c); - -/* nor flash使用外建字库 */ -/* 16*16 24*24 32*32 */ -void LT768_Select_Outside_Font_Init(unsigned char SCS,unsigned char Clk,unsigned long FlashAddr,unsigned long MemoryAddr,unsigned long Num,unsigned char Size,unsigned char XxN,unsigned char YxN,unsigned char ChromaKey,unsigned char Alignment); -void LT768_Print_Outside_Font_String(unsigned short x,unsigned short y,unsigned long FontColor,unsigned long BackGroundColor,unsigned char *c); -void LT768_Print_Outside_Font_GBK_String(unsigned short x,unsigned short y,unsigned long FontColor,unsigned long BackGroundColor,unsigned char *c); -/* 48*48 72*72全角 */ -void LT768_BTE_Memory_Copy_ColorExpansion_8(unsigned long S0_Addr,unsigned short YS0,unsigned long Des_Addr,unsigned short Des_W,unsigned short XDes,unsigned short YDes,unsigned short X_W,unsigned short Y_H,unsigned long Foreground_color,unsigned long Background_color); -void LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8(unsigned long S0_Addr,unsigned short YS0,unsigned long Des_Addr,unsigned short Des_W,unsigned short XDes,unsigned short YDes,unsigned short X_W,unsigned short Y_H,unsigned long Foreground_color); -void LT768_Print_Outside_Font_GB2312_48_72(unsigned char SCS,unsigned char Clk,unsigned long FlashAddr,unsigned long MemoryAddr,unsigned long ShowAddr,unsigned short width,unsigned char Size,unsigned char ChromaKey,unsigned short x,unsigned short y,unsigned long FontColor,unsigned long BackGroundColor,unsigned short w,unsigned short s,unsigned char *c); -void LT768_Print_Outside_Font_BIG5_48_72(unsigned char SCS,unsigned char Clk,unsigned long FlashAddr,unsigned long MemoryAddr,unsigned long ShowAddr,unsigned short width,unsigned char Size,unsigned char ChromaKey,unsigned short x,unsigned short y,unsigned long FontColor,unsigned long BackGroundColor,unsigned short w,unsigned short s,unsigned char *c); -void LT768_Print_Outside_Font_GBK_48_72(unsigned char SCS,unsigned char Clk,unsigned long FlashAddr,unsigned long MemoryAddr,unsigned long ShowAddr,unsigned short width,unsigned char Size,unsigned char ChromaKey,unsigned short x,unsigned short y,unsigned long FontColor,unsigned long BackGroundColor,unsigned short w,unsigned short s,unsigned char *c); - -/* nor flash使用自定义字库 */ -/* 16*16 24*24 32*32 48*48 72*72全角 */ -int Get_User_Font_P(char chH,char chL); -void LT768_Print_Outside_UserDefineFont_GB2312(unsigned char SCS,unsigned char Clk,unsigned long FlashAddr,unsigned long MemoryAddr,unsigned long ShowAddr,unsigned short width,unsigned char Size,unsigned char ChromaKey,unsigned short x,unsigned short y,unsigned long FontColor,unsigned long BackGroundColor,unsigned short w,unsigned short s,unsigned char *c); - -/* 文字光标 */ -void LT768_Text_cursor_Init(unsigned char On_Off_Blinking,unsigned short Blinking_Time,unsigned short X_W,unsigned short Y_W); -void LT768_Enable_Text_Cursor(void); -void LT768_Disable_Text_Cursor(void); - -/* 图像光标 */ -void LT768_Graphic_cursor_Init(unsigned char Cursor_N,unsigned char Color1,unsigned char Color2,unsigned short X_Pos,unsigned short Y_Pos,unsigned char *Cursor_Buf); -void LT768_Set_Graphic_cursor_Pos(unsigned char Cursor_N,unsigned short X_Pos,unsigned short Y_Pos); -void LT768_Enable_Graphic_Cursor(void); -void LT768_Disable_Graphic_Cursor(void); - -/* 区块传输引擎(BitBLT) */ -void BTE_Solid_Fill(unsigned long Des_Addr,unsigned short Des_W,unsigned short XDes,unsigned short YDes,unsigned short color,unsigned short X_W,unsigned short Y_H); -void LT768_BTE_Memory_Copy(unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long S1_Addr,unsigned short S1_W,unsigned short XS1,unsigned short YS1,unsigned long Des_Addr,unsigned short Des_W,unsigned short XDes,unsigned short YDes,unsigned int ROP_Code,unsigned short X_W,unsigned short Y_H); -void LT768_BTE_Memory_Copy_Chroma_key(unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long Des_Addr,unsigned short Des_W,unsigned short XDes,unsigned short YDes,unsigned long Background_color,unsigned short X_W,unsigned short Y_H); -void LT768_BTE_Pattern_Fill(unsigned char P_8x8_or_16x16,unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned int ROP_Code ,unsigned short X_W,unsigned short Y_H); -void LT768_BTE_Pattern_Fill_With_Chroma_key(unsigned char P_8x8_or_16x16,unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long Des_Addr,unsigned short Des_W,unsigned short XDes,unsigned short YDes,unsigned int ROP_Code,unsigned long Background_color,unsigned short X_W,unsigned short Y_H); -void LT768_BTE_MCU_Write_MCU_16bit(unsigned long S1_Addr,unsigned short S1_W,unsigned short XS,unsigned short YS1,unsigned long Des_Addr,unsigned short Des_W,unsigned short XDes,unsigned short YDes,unsigned int ROP_Code,unsigned short X_W,unsigned short Y_H ,const unsigned short *data); -void LT768_BTE_MCU_Write_Chroma_key_MCU_16bit(unsigned long Des_Addr,unsigned short Des_W,unsigned short XDes,unsigned short YDes,unsigned long Background_color,unsigned short X_W,unsigned short Y_H,const unsigned short *data); -void LT768_BTE_MCU_Write_ColorExpansion_MCU_16bit(unsigned long Des_Addr,unsigned short Des_W,unsigned short XDes,unsigned short YDes,unsigned short X_W,unsigned short Y_H,unsigned long Foreground_color ,unsigned long Background_color ,const unsigned short *data); -void LT768_BTE_MCU_Write_ColorExpansion_Chroma_key_MCU_16bit(unsigned long Des_Addr,unsigned short Des_W,unsigned short XDes,unsigned short YDes,unsigned short X_W,unsigned short Y_H,unsigned long Foreground_color,const unsigned short *data); -void BTE_Alpha_Blending(unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long S1_Addr,unsigned short S1_W,unsigned short XS1,unsigned short YS1,unsigned long Des_Addr,unsigned short Des_W,unsigned short XDes,unsigned short YDes,unsigned short X_W,unsigned short Y_H,unsigned char alpha); -void BTE_Pixel_8bpp_Alpha_Blending(unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long S1_Addr,unsigned short S1_W,unsigned short XS1,unsigned short YS1,unsigned long Des_Addr,unsigned short Des_W,unsigned short XDes,unsigned short YDes,unsigned short X_W,unsigned short Y_H); -void BTE_Pixel_16bpp_Alpha_Blending(unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long S1_Addr,unsigned short S1_W,unsigned short XS1,unsigned short YS1,unsigned long Des_Addr,unsigned short Des_W,unsigned short XDes,unsigned short YDes,unsigned short X_W,unsigned short Y_H); - -/* PIP */ -void LT768_PIP_Init(unsigned char On_Off,unsigned char Select_PIP,unsigned long PAddr,unsigned short XP,unsigned short YP,unsigned long ImageWidth,unsigned short X_Dis,unsigned short Y_Dis,unsigned short X_W,unsigned short Y_H); -void LT768_Set_DisWindowPos(unsigned char On_Off,unsigned char Select_PIP,unsigned short X_Dis,unsigned short Y_Dis); - -/* PWM */ -void LT768_PWM0_Init(unsigned char on_off,unsigned char Clock_Divided,unsigned char Prescalar,unsigned short Count_Buffer,unsigned short Compare_Buffer); -void LT768_PWM1_Init(unsigned char on_off,unsigned char Clock_Divided,unsigned char Prescalar,unsigned short Count_Buffer,unsigned short Compare_Buffer); -void LT768_PWM0_Duty(unsigned short Compare_Buffer); -void LT768_PWM1_Duty(unsigned short Compare_Buffer); - -/* Standby Mode */ -void LT768_Standby(void); -void LT768_Wkup_Standby(void); - -/* Suspend Mode */ -void LT768_Suspend(void); -void LT768_Wkup_Suspend(void); - -/* Sleep Mode */ -void LT768_SleepMode(void); -void LT768_Wkup_Sleep(void); - -/* W25QXX */ -void LT768_SPI_Init(uint8_t cs,uint8_t div); -void W25QXX_Enter_4Byte_AddressMode(void); -void LT_W25QXX_Read(uint8_t* pBuffer,uint32_t ReadAddr,uint16_t NumByteToRead); - -/* nand flash W25N01GV */ -uint8_t W25N01GV_ReadSR(uint8_t reg); -void W25N01GV_Write_SR(uint8_t reg,uint8_t val); -void W25N01GV_Wait_Busy(void); -void W25N01GV_ContinuousRead_Mode(void); -void W25N01GV_Write_Page(uint16_t page); -void W25N01GV_ReadPageAddr_Data(uint8_t* pBuffer,uint32_t PageNum,uint32_t PageAddr,uint16_t NumByteToRead); -void LT_W25N01GV_Read(uint8_t* pBuffer,uint32_t ReadAddr,uint16_t NumByteToRead); - -/* nand flash显示图片 */ -void LT768_Nand_Pic(unsigned char SCS,unsigned short X1,unsigned short Y1,unsigned short X_W,unsigned short Y_H,unsigned long Addr,unsigned long lay0,unsigned long lay1); - -/* nand flash使用外建字库初始化 */ -/* 16*16 24*24 32*32 */ -void NandFlash_Select_Outside_Font_Init(unsigned char SCS,unsigned char Clk,unsigned long FlashAddr,unsigned long MemoryAddr,unsigned long Num,unsigned char Size,unsigned char XxN,unsigned char YxN,unsigned char ChromaKey,unsigned char Alignment); - -/* nand flash使用外建字库 */ -/* 48*48 72*72全角 */ -void LT768_BTE_Memory_Copy_8(unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long S1_Addr,unsigned short S1_W,unsigned short XS1,unsigned short YS1,unsigned long Des_Addr,unsigned short Des_W,unsigned short XDes,unsigned short YDes,unsigned int ROP_Code,unsigned short X_W,unsigned short Y_H); -void LT768_Nand_8bpp_font(unsigned char SCS,unsigned char Clk,unsigned short X1,unsigned short Y1,unsigned short X_W,unsigned short Y_H,unsigned long Addr,unsigned long lay1,unsigned long lay2); -void LT768_Print_Outside_Font_GB2312_48_72_Nand(unsigned char SCS,unsigned char Clk,unsigned long FlashAddr,unsigned long MemoryAddr1,unsigned long MemoryAddr2,unsigned long ShowAddr,unsigned short width,unsigned char Size,unsigned char ChromaKey,unsigned short x,unsigned short y,unsigned long FontColor,unsigned long BackGroundColor,unsigned short w,unsigned short s,unsigned char *c); -void LT768_Print_Outside_Font_GBK_48_72_Nand(unsigned char SCS,unsigned char Clk,unsigned long FlashAddr,unsigned long MemoryAddr1,unsigned long MemoryAddr2,unsigned long ShowAddr,unsigned short width,unsigned char Size,unsigned char ChromaKey,unsigned short x,unsigned short y,unsigned long FontColor,unsigned long BackGroundColor,unsigned short w,unsigned short s,unsigned char *c); - -/* nand flash使用自定义字库 */ -/* 16*16 24*24 32*32 48*48 72*72全角 */ -void LT768_Print_Outside_UserDefineFont_GB2312_Nand(unsigned char SCS,unsigned char Clk,unsigned long FlashAddr,unsigned long MemoryAddr1,unsigned long MemoryAddr2,unsigned long ShowAddr,unsigned short width,unsigned char Size,unsigned char ChromaKey,unsigned short x,unsigned short y,unsigned long FontColor,unsigned long BackGroundColor,unsigned short w,unsigned short s,unsigned char *c); -#endif +/* +* Copyright (c) 2022 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file lt768_lib.h + * @brief lt768 register relative driver, inherit from Levetop Electronics + * @version 1.0 + * @author AIIT XUOS Lab + * @date 2022.9.19 + */ + +#ifndef __LT768_LIB_H_ +#define __LT768_LIB_H_ +#include "lt768.h" + +//external OSC +#define XI_4M 0 +#define XI_8M 1 +#define XI_10M 0 +#define XI_12M 0 + +//resolution +#define LCD_XSIZE_TFT 480 +#define LCD_YSIZE_TFT 272 + +//parameter +#define LCD_VBPD 20 +#define LCD_VFPD 12 +#define LCD_VSPW 3 +#define LCD_HBPD 140 +#define LCD_HFPD 160 +#define LCD_HSPW 20 + +#define color256_black 0x00 +#define color256_white 0xff +#define color256_red 0xe0 +#define color256_green 0x1c +#define color256_blue 0x03 +#define color256_yellow color256_red|color256_green +#define color256_cyan color256_green|color256_blue +#define color256_purple color256_red|color256_blue + +#define color65k_black 0x0000 +#define color65k_white 0xffff +#define color65k_red 0xf800 +#define color65k_green 0x07e0 +#define color65k_blue 0x001f +#define color65k_yellow color65k_red|color65k_green +#define color65k_cyan color65k_green|color65k_blue +#define color65k_purple color65k_red|color65k_blue + +#define color65k_grayscale1 2113 +#define color65k_grayscale2 2113*2 +#define color65k_grayscale3 2113*3 +#define color65k_grayscale4 2113*4 +#define color65k_grayscale5 2113*5 +#define color65k_grayscale6 2113*6 +#define color65k_grayscale7 2113*7 +#define color65k_grayscale8 2113*8 +#define color65k_grayscale9 2113*9 +#define color65k_grayscale10 2113*10 +#define color65k_grayscale11 2113*11 +#define color65k_grayscale12 2113*12 +#define color65k_grayscale13 2113*13 +#define color65k_grayscale14 2113*14 +#define color65k_grayscale15 2113*15 +#define color65k_grayscale16 2113*16 +#define color65k_grayscale17 2113*17 +#define color65k_grayscale18 2113*18 +#define color65k_grayscale19 2113*19 +#define color65k_grayscale20 2113*20 +#define color65k_grayscale21 2113*21 +#define color65k_grayscale22 2113*22 +#define color65k_grayscale23 2113*23 +#define color65k_grayscale24 2113*24 +#define color65k_grayscale25 2113*25 +#define color65k_grayscale26 2113*26 +#define color65k_grayscale27 2113*27 +#define color65k_grayscale28 2113*28 +#define color65k_grayscale29 2113*29 +#define color65k_grayscale30 2113*30 + +#define color16M_black 0x00000000 +#define color16M_white 0x00ffffff +#define color16M_red 0x00ff0000 +#define color16M_green 0x0000ff00 +#define color16M_blue 0x000000ff +#define color16M_yellow color16M_red|color16M_green +#define color16M_cyan color16M_green|color16M_blue +#define color16M_purple color16M_red|color16M_blue + +/* LCD color */ +#define White 0xFFFF +#define Black 0x0000 +#define Grey 0xF7DE +#define Blue 0x001F +#define Blue2 0x051F +#define Red 0xF800 +#define Magenta 0xF81F +#define Green 0x07E0 +#define Cyan 0x7FFF +#define Yellow 0xFFE0 + +#define Line0 0 +#define Line1 24 +#define Line2 48 +#define Line3 72 +#define Line4 96 +#define Line5 120 +#define Line6 144 +#define Line7 168 +#define Line8 192 +#define Line9 216 +#define Line10 240 +#define Line11 264 +#define Line12 288 +#define Line13 312 +#define Line14 336 +#define Line15 360 +#define Line16 384 +#define Line17 408 +#define Line18 432 +#define Line19 456 +#define Line20 480 +#define Line21 504 +#define Line22 528 +#define Line23 552 +#define Line24 576 +#define Line25 600 + +void lt768_init(void); + +/* write to memory */ +void MPuint8_t_8bpp_Memory_Write(uint16_t x, + uint16_t y, + uint16_t w, + uint16_t h, + const uint8_t *data); +void MPuint8_t_16bpp_Memory_Write(uint16_t x, + uint16_t y, + uint16_t w, + uint16_t h, + const uint8_t *data); +void MPuint8_t_24bpp_Memory_Write(uint16_t x, + uint16_t y, + uint16_t w, + uint16_t h, + const uint8_t *data); +void MPuint16_t_16bpp_Memory_Write(uint16_t x, + uint16_t y, + uint16_t w, + uint16_t h, + const uint16_t *data); +void MPuint16_t_24bpp_Mode1_Memory_Write(uint16_t x, + uint16_t y, + uint16_t w, + uint16_t h, + const uint16_t *data); +void MPuint16_t_24bpp_Mode2_Memory_Write(uint16_t x, + uint16_t y, + uint16_t w, + uint16_t h, + const uint16_t *data); + +/* draw line */ +void LT768_DrawLine(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint32_t LineColor); +void LT768_DrawLine_Width(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint32_t LineColor, + uint16_t Width); + +/* draw circle */ +void LT768_DrawCircle(uint16_t XCenter, + uint16_t YCenter, + uint16_t R, + uint32_t CircleColor); +void LT768_DrawCircle_Fill(uint16_t XCenter, + uint16_t YCenter, + uint16_t R, + uint32_t ForegroundColor); +void LT768_DrawCircle_Width(uint16_t XCenter, + uint16_t YCenter, + uint16_t R, + uint32_t CircleColor, + uint32_t ForegroundColor, + uint16_t Width); + +/* draw elipse */ +void LT768_DrawEllipse(uint16_t XCenter, + uint16_t YCenter, + uint16_t X_R, + uint16_t Y_R, + uint32_t EllipseColor); +void LT768_DrawEllipse_Fill(uint16_t XCenter, + uint16_t YCenter, + uint16_t X_R, + uint16_t Y_R, + uint32_t ForegroundColor); +void LT768_DrawEllipse_Width(uint16_t XCenter, + uint16_t YCenter, + uint16_t X_R, + uint16_t Y_R, + uint32_t EllipseColor, + uint32_t ForegroundColor, + uint16_t Width); + +/* draw square */ +void LT768_DrawSquare(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint32_t SquareColor); +void LT768_DrawSquare_Fill(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint32_t ForegroundColor); +void LT768_DrawSquare_Width(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint32_t SquareColor, + uint32_t ForegroundColor, + uint16_t Width); + +/* draw circle square */ +void LT768_DrawCircleSquare(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint16_t X_R, + uint16_t Y_R, + uint32_t CircleSquareColor); +void LT768_DrawCircleSquare_Fill(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint16_t X_R, + uint16_t Y_R, + uint32_t ForegroundColor); +void LT768_DrawCircleSquare_Width(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint16_t X_R, + uint16_t Y_R, + uint32_t CircleSquareColor, + uint32_t ForegroundColor, + uint16_t Width); + +/* draw triangle */ +void LT768_DrawTriangle(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint16_t X3, + uint16_t Y3, + uint32_t TriangleColor); +void LT768_DrawTriangle_Fill(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint16_t X3, + uint16_t Y3, + uint32_t ForegroundColor); +void LT768_DrawTriangle_Frame(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint16_t X3, + uint16_t Y3, + uint32_t TriangleColor, + uint32_t ForegroundColor); + +/* draw quadrilateral */ +void LT768_DrawQuadrilateral(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint16_t X3, + uint16_t Y3, + uint16_t X4, + uint16_t Y4, + uint32_t ForegroundColor); +void LT768_DrawQuadrilateral_Fill(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint16_t X3, + uint16_t Y3, + uint16_t X4, + uint16_t Y4, + uint32_t ForegroundColor); +void LT768_DrawTriangle_Frame(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint16_t X3, + uint16_t Y3, + uint32_t TriangleColor, + uint32_t ForegroundColor); + +/* draw pentagon */ +void LT768_DrawPentagon(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint16_t X3, + uint16_t Y3, + uint16_t X4, + uint16_t Y4, + uint16_t X5, + uint16_t Y5, + uint32_t ForegroundColor); +void LT768_DrawPentagon_Fill(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint16_t X3, + uint16_t Y3, + uint16_t X4, + uint16_t Y4, + uint16_t X5, + uint16_t Y5, + uint32_t ForegroundColor); + +/* draw curve */ +void LT768_DrawLeftUpCurve(uint16_t XCenter, + uint16_t YCenter, + uint16_t X_R, + uint16_t Y_R, + uint32_t CurveColor); +void LT768_DrawLeftDownCurve(uint16_t XCenter, + uint16_t YCenter, + uint16_t X_R, + uint16_t Y_R, + uint32_t CurveColor); +void LT768_DrawRightUpCurve(uint16_t XCenter, + uint16_t YCenter, + uint16_t X_R, + uint16_t Y_R, + uint32_t CurveColor); +void LT768_DrawRightDownCurve(uint16_t XCenter, + uint16_t YCenter, + uint16_t X_R, + uint16_t Y_R, + uint32_t CurveColor); +void LT768_SelectDrawCurve(uint16_t XCenter, + uint16_t YCenter, + uint16_t X_R, + uint16_t Y_R, + uint32_t CurveColor, + uint16_t Dir); + +/* draw 1/4 filled curve */ +void LT768_DrawLeftUpCurve_Fill(uint16_t XCenter, + uint16_t YCenter, + uint16_t X_R, + uint16_t Y_R, + uint32_t ForegroundColor); +void LT768_DrawLeftDownCurve_Fill(uint16_t XCenter, + uint16_t YCenter, + uint16_t X_R, + uint16_t Y_R, + uint32_t ForegroundColor); +void LT768_DrawRightUpCurve_Fill(uint16_t XCenter, + uint16_t YCenter, + uint16_t X_R, + uint16_t Y_R, + uint32_t ForegroundColor); +void LT768_DrawRightDownCurve_Fill(uint16_t XCenter, + uint16_t YCenter, + uint16_t X_R, + uint16_t Y_R, + uint32_t ForegroundColor); +void LT768_SelectDrawCurve_Fill(uint16_t XCenter, + uint16_t YCenter, + uint16_t X_R, + uint16_t Y_R, + uint32_t CurveColor, + uint16_t Dir); + +/* draw cylinders */ +uint8_t LT768_DrawCylinder(uint16_t XCenter, + uint16_t YCenter, + uint16_t X_R, + uint16_t Y_R, + uint16_t H, + uint32_t CylinderColor, + uint32_t ForegroundColor); + +/* draw quadrangular */ +void LT768_DrawQuadrangular(uint16_t X1, + uint16_t Y1, + uint16_t X2, + uint16_t Y2, + uint16_t X3, + uint16_t Y3, + uint16_t X4, + uint16_t Y4, + uint16_t X5, + uint16_t Y5, + uint16_t X6, + uint16_t Y6, + uint32_t QuadrangularColor, + uint32_t ForegroundColor); + +/* table */ +void LT768_MakeTable(uint16_t X1, + uint16_t Y1, + uint16_t W, + uint16_t H, + uint16_t Line, + uint16_t Row, + uint32_t TableColor, + uint32_t ItemColor, + uint32_t ForegroundColor, + uint16_t width1, + uint16_t width2, + uint8_t mode); + +/* linear DMA transport to SDRAM */ +void LT768_DMA_24bit_Linear(uint8_t SCS, + uint8_t Clk, + uint32_t flash_addr, + uint32_t memory_ad, + uint32_t data_num); +void LT768_DMA_32bit_Linear(uint8_t SCS, + uint8_t Clk, + uint32_t flash_addr, + uint32_t memory_ad, + uint32_t data_num); + +/* DMA transport to SDRAM */ +void LT768_DMA_24bit_Block(uint8_t SCS, + uint8_t Clk, + uint16_t X1, + uint16_t Y1, + uint16_t X_W, + uint16_t Y_H, + uint16_t P_W, + uint32_t Addr); +void LT768_DMA_32bit_Block(uint8_t SCS, + uint8_t Clk, + uint16_t X1, + uint16_t Y1, + uint16_t X_W, + uint16_t Y_H, + uint16_t P_W, + uint32_t Addr); + +/* use internal font */ +void LT768_Select_Internal_Font_Init(uint8_t Size, + uint8_t XxN, + uint8_t YxN, + uint8_t ChromaKey, + uint8_t Alignment); +void LT768_Print_Internal_Font_String(uint16_t x, + uint16_t y, + uint32_t FontColor, + uint32_t BackGroundColor, + char *c); + +/* nor flash use outside font */ +/* 16*16 24*24 32*32 */ +void LT768_Select_Outside_Font_Init(uint8_t SCS, + uint8_t Clk, + uint32_t FlashAddr, + uint32_t MemoryAddr, + uint32_t Num, + uint8_t Size, + uint8_t XxN, + uint8_t YxN, + uint8_t ChromaKey, + uint8_t Alignment); +void LT768_Print_Outside_Font_String(uint16_t x, + uint16_t y, + uint32_t FontColor, + uint32_t BackGroundColor, + uint8_t *c); +void LT768_Print_Outside_Font_GBK_String(uint16_t x, + uint16_t y, + uint32_t FontColor, + uint32_t BackGroundColor, + uint8_t *c); +/* 48*48 72*72 SBC case */ +void LT768_BTE_Memory_Copy_ColorExpansion_8(uint32_t S0_Addr, + uint16_t YS0, + uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + uint16_t X_W, + uint16_t Y_H, + uint32_t Foreground_color, + uint32_t Background_color); +void LT768_BTE_Memory_Copy_ColorExpansion_Chroma_key_8(uint32_t S0_Addr, + uint16_t YS0, + uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + uint16_t X_W, + uint16_t Y_H, + uint32_t Foreground_color); +void LT768_Print_Outside_Font_GB2312_48_72(uint8_t SCS, + uint8_t Clk, + uint32_t FlashAddr, + uint32_t MemoryAddr, + uint32_t ShowAddr, + uint16_t width, + uint8_t Size, + uint8_t ChromaKey, + uint16_t x, + uint16_t y, + uint32_t FontColor, + uint32_t BackGroundColor, + uint16_t w, + uint16_t s, + uint8_t *c); +void LT768_Print_Outside_Font_BIG5_48_72(uint8_t SCS, + uint8_t Clk, + uint32_t FlashAddr, + uint32_t MemoryAddr, + uint32_t ShowAddr, + uint16_t width, + uint8_t Size, + uint8_t ChromaKey, + uint16_t x, + uint16_t y, + uint32_t FontColor, + uint32_t BackGroundColor, + uint16_t w, + uint16_t s, + uint8_t *c); +void LT768_Print_Outside_Font_GBK_48_72(uint8_t SCS, + uint8_t Clk, + uint32_t FlashAddr, + uint32_t MemoryAddr, + uint32_t ShowAddr, + uint16_t width, + uint8_t Size, + uint8_t ChromaKey, + uint16_t x, + uint16_t y, + uint32_t FontColor, + uint32_t BackGroundColor, + uint16_t w, + uint16_t s, + uint8_t *c); + +/* nor flash used define font */ +/* 16*16 24*24 32*32 48*48 72*72 SBC case */ +int Get_User_Font_P(char chH, + char chL); +void LT768_Print_Outside_UserDefineFont_GB2312(uint8_t SCS, + uint8_t Clk, + uint32_t FlashAddr, + uint32_t MemoryAddr, + uint32_t ShowAddr, + uint16_t width, + uint8_t Size, + uint8_t ChromaKey, + uint16_t x, + uint16_t y, + uint32_t FontColor, + uint32_t BackGroundColor, + uint16_t w, + uint16_t s, + uint8_t *c); + +/* text cursor */ +void LT768_Text_cursor_Init(uint8_t On_Off_Blinking, + uint16_t Blinking_Time, + uint16_t X_W, + uint16_t Y_W); +void LT768_Enable_Text_Cursor(void); +void LT768_Disable_Text_Cursor(void); + +/* graphic cursor */ +void LT768_Graphic_cursor_Init(uint8_t Cursor_N, + uint8_t Color1, + uint8_t Color2, + uint16_t X_Pos, + uint16_t Y_Pos, + uint8_t *Cursor_Buf); +void LT768_Set_Graphic_cursor_Pos(uint8_t Cursor_N, + uint16_t X_Pos, + uint16_t Y_Pos); +void LT768_Enable_Graphic_Cursor(void); +void LT768_Disable_Graphic_Cursor(void); + +/* block transport enginer (BitBLT) */ +void BTE_Solid_Fill(uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + uint16_t color, + uint16_t X_W, + uint16_t Y_H); +void LT768_BTE_Memory_Copy(uint32_t S0_Addr, + uint16_t S0_W, + uint16_t XS0, + uint16_t YS0, + uint32_t S1_Addr, + uint16_t S1_W, + uint16_t XS1, + uint16_t YS1, + uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + unsigned int ROP_Code, + uint16_t X_W, + uint16_t Y_H); +void LT768_BTE_Memory_Copy_Chroma_key(uint32_t S0_Addr, + uint16_t S0_W, + uint16_t XS0, + uint16_t YS0, + uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + uint32_t Background_color, + uint16_t X_W, + uint16_t Y_H); +void LT768_BTE_Pattern_Fill(uint8_t P_8x8_or_16x16, + uint32_t S0_Addr, + uint16_t S0_W, + uint16_t XS0, + uint16_t YS0, + uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + unsigned int ROP_Code, + uint16_t X_W, + uint16_t Y_H); +void LT768_BTE_Pattern_Fill_With_Chroma_key(uint8_t P_8x8_or_16x16, + uint32_t S0_Addr, + uint16_t S0_W, + uint16_t XS0, + uint16_t YS0, + uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + unsigned int ROP_Code, + uint32_t Background_color, + uint16_t X_W, + uint16_t Y_H); +void LT768_BTE_MCU_Write_MCU_16bit(uint32_t S1_Addr, + uint16_t S1_W, + uint16_t XS, + uint16_t YS1, + uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + unsigned int ROP_Code, + uint16_t X_W, + uint16_t Y_H, + const uint16_t *data); +void LT768_BTE_MCU_Write_Chroma_key_MCU_16bit(uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + uint32_t Background_color, + uint16_t X_W, + uint16_t Y_H, + const uint16_t *data); +void LT768_BTE_MCU_Write_ColorExpansion_MCU_16bit(uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + uint16_t X_W, + uint16_t Y_H, + uint32_t Foreground_color, + uint32_t Background_color, + const uint16_t *data); +void LT768_BTE_MCU_Write_ColorExpansion_Chroma_key_MCU_16bit(uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + uint16_t X_W, + uint16_t Y_H, + uint32_t Foreground_color, + const uint16_t *data); +void BTE_Alpha_Blending(uint32_t S0_Addr, + uint16_t S0_W, + uint16_t XS0, + uint16_t YS0, + uint32_t S1_Addr, + uint16_t S1_W, + uint16_t XS1, + uint16_t YS1, + uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + uint16_t X_W, + uint16_t Y_H, + uint8_t alpha); +void BTE_Pixel_8bpp_Alpha_Blending(uint32_t S0_Addr, + uint16_t S0_W, + uint16_t XS0, + uint16_t YS0, + uint32_t S1_Addr, + uint16_t S1_W, + uint16_t XS1, + uint16_t YS1, + uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + uint16_t X_W, + uint16_t Y_H); +void BTE_Pixel_16bpp_Alpha_Blending(uint32_t S0_Addr, + uint16_t S0_W, + uint16_t XS0, + uint16_t YS0, + uint32_t S1_Addr, + uint16_t S1_W, + uint16_t XS1, + uint16_t YS1, + uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + uint16_t X_W, + uint16_t Y_H); + +/* PIP */ +void LT768_PIP_Init(uint8_t On_Off, + uint8_t Select_PIP, + uint32_t PAddr, + uint16_t XP, + uint16_t YP, + uint32_t ImageWidth, + uint16_t X_Dis, + uint16_t Y_Dis, + uint16_t X_W, + uint16_t Y_H); +void LT768_Set_DisWindowPos(uint8_t On_Off, + uint8_t Select_PIP, + uint16_t X_Dis, + uint16_t Y_Dis); + +/* PWM */ +void LT768_PWM0_Init(uint8_t on_off, + uint8_t Clock_Divided, + uint8_t Prescalar, + uint16_t Count_Buffer, + uint16_t Compare_Buffer); +void LT768_PWM1_Init(uint8_t on_off, + uint8_t Clock_Divided, + uint8_t Prescalar, + uint16_t Count_Buffer, + uint16_t Compare_Buffer); +void LT768_PWM0_Duty(uint16_t Compare_Buffer); +void LT768_PWM1_Duty(uint16_t Compare_Buffer); + +/* Standby Mode */ +void LT768_Standby(void); +void LT768_Wkup_Standby(void); + +/* Suspend Mode */ +void LT768_Suspend(void); +void LT768_Wkup_Suspend(void); + +/* Sleep Mode */ +void LT768_SleepMode(void); +void LT768_Wkup_Sleep(void); + +/* W25QXX */ +void LT768_SPI_Init(uint8_t cs, + uint8_t div); +void W25QXX_Enter_4Byte_AddressMode(void); +void LT_W25QXX_Read(uint8_t *pBuffer, + uint32_t ReadAddr, + uint16_t NumByteToRead); + +/* nand flash W25N01GV */ +uint8_t W25N01GV_ReadSR(uint8_t reg); +void W25N01GV_Write_SR(uint8_t reg, + uint8_t val); +void W25N01GV_Wait_Busy(void); +void W25N01GV_ContinuousRead_Mode(void); +void W25N01GV_Write_Page(uint16_t page); +void W25N01GV_ReadPageAddr_Data(uint8_t *pBuffer, + uint32_t PageNum, + uint32_t PageAddr, + uint16_t NumByteToRead); +void LT_W25N01GV_Read(uint8_t *pBuffer, + uint32_t ReadAddr, + uint16_t NumByteToRead); + +/* nand flash draw picture */ +void LT768_Nand_Pic(uint8_t SCS, + uint16_t X1, + uint16_t Y1, + uint16_t X_W, + uint16_t Y_H, + uint32_t Addr, + uint32_t lay0, + uint32_t lay1); + +/* nand flash use outside font */ +/* 16*16 24*24 32*32 */ +void NandFlash_Select_Outside_Font_Init(uint8_t SCS, + uint8_t Clk, + uint32_t FlashAddr, + uint32_t MemoryAddr, + uint32_t Num, + uint8_t Size, + uint8_t XxN, + uint8_t YxN, + uint8_t ChromaKey, + uint8_t Alignment); + +/* nand flash use outside font */ +/* 48*48 72*72 SBC case */ +void LT768_BTE_Memory_Copy_8(uint32_t S0_Addr, + uint16_t S0_W, + uint16_t XS0, + uint16_t YS0, + uint32_t S1_Addr, + uint16_t S1_W, + uint16_t XS1, + uint16_t YS1, + uint32_t Des_Addr, + uint16_t Des_W, + uint16_t XDes, + uint16_t YDes, + unsigned int ROP_Code, + uint16_t X_W, + uint16_t Y_H); +void LT768_Nand_8bpp_font(uint8_t SCS, + uint8_t Clk, + uint16_t X1, + uint16_t Y1, + uint16_t X_W, + uint16_t Y_H, + uint32_t Addr, + uint32_t lay1, + uint32_t lay2); +void LT768_Print_Outside_Font_GB2312_48_72_Nand(uint8_t SCS, + uint8_t Clk, + uint32_t FlashAddr, + uint32_t MemoryAddr1, + uint32_t MemoryAddr2, + uint32_t ShowAddr, + uint16_t width, + uint8_t Size, + uint8_t ChromaKey, + uint16_t x, + uint16_t y, + uint32_t FontColor, + uint32_t BackGroundColor, + uint16_t w, + uint16_t s, + uint8_t *c); +void LT768_Print_Outside_Font_GBK_48_72_Nand(uint8_t SCS, + uint8_t Clk, + uint32_t FlashAddr, + uint32_t MemoryAddr1, + uint32_t MemoryAddr2, + uint32_t ShowAddr, + uint16_t width, + uint8_t Size, + uint8_t ChromaKey, + uint16_t x, + uint16_t y, + uint32_t FontColor, + uint32_t BackGroundColor, + uint16_t w, + uint16_t s, + uint8_t *c); + +/* nand flash user defined font */ +/* 16*16 24*24 32*32 48*48 72*72 SBC case */ +void LT768_Print_Outside_UserDefineFont_GB2312_Nand(uint8_t SCS, + uint8_t Clk, + uint32_t FlashAddr, + uint32_t MemoryAddr1, + uint32_t MemoryAddr2, + uint32_t ShowAddr, + uint16_t width, + uint8_t Size, + uint8_t ChromaKey, + uint16_t x, + uint16_t y, + uint32_t FontColor, + uint32_t BackGroundColor, + uint16_t w, + uint16_t s, + uint8_t *c); +#endif