TL-LED

  • 2025-01-16
  • 发表了主题帖: 【极海APM32M3514电机通用评估板】 驱动电机测试

    驱动电机测试,开环方式测试。   测试电机是一个24V带减速器的无刷电机,由于电机其他参数不是很清楚,按照官网的手册进行测试。 根据官方文档《APM32M3514x8 MOTOR EVAL V1.0》对电机的参数进行设置 调试参数在parameter.h中设置   一、转速4000转测试   1.1、设置最高转速为4000转   1.2、 设置开环加速度和极对数   1.3、运行视频 [localvideo]086437c6c2ff4cfa9b99fb8c0980875b[/localvideo]   二、转速9000测试   2.1、设置转速参数   2.2、运行视频 [localvideo]d2785f196464282dde55df0302629e6a[/localvideo]    

  • 2025-01-08
  • 发表了主题帖: 【FRDM-MCXN947】移植lwip及ping测试

    测试开发板以太网,移植lwip并ping测试,参考SDK包里的例程进行移植。   一、硬件部分   开发板以太网接口部分电路图   二、配置接口   配置以太网对应的引脚   三、下载源码   下载lwip2.1.3版本 下载地址:http://download.savannah.nongnu.org/releases/lwip/   四、添加源码到工程   复制SDK工程中的部分源码和LWIP源码到工程目录下middleware文件中,并添加文件到工程。   五、程序部分   5.1、net_ping.c #include "main.h" /* IP address configuration. */ #ifndef configIP_ADDR0 #define configIP_ADDR0 192 #endif #ifndef configIP_ADDR1 #define configIP_ADDR1 168 #endif #ifndef configIP_ADDR2 #define configIP_ADDR2 1 #endif #ifndef configIP_ADDR3 #define configIP_ADDR3 102 #endif /* Netmask configuration. */ #ifndef configNET_MASK0 #define configNET_MASK0 255 #endif #ifndef configNET_MASK1 #define configNET_MASK1 255 #endif #ifndef configNET_MASK2 #define configNET_MASK2 255 #endif #ifndef configNET_MASK3 #define configNET_MASK3 0 #endif /* Gateway address configuration. */ #ifndef configGW_ADDR0 #define configGW_ADDR0 192 #endif #ifndef configGW_ADDR1 #define configGW_ADDR1 168 #endif #ifndef configGW_ADDR2 #define configGW_ADDR2 1 #endif #ifndef configGW_ADDR3 #define configGW_ADDR3 1 #endif /* Ethernet configuration. */ extern phy_lan8741_resource_t g_phy_resource; #define EXAMPLE_ENET_BASE ENET0 #define EXAMPLE_PHY_ADDRESS BOARD_ENET0_PHY_ADDRESS #define EXAMPLE_PHY_OPS &phylan8741_ops #define EXAMPLE_PHY_RESOURCE &g_phy_resource #define EXAMPLE_CLOCK_FREQ (50000000U) /* Must be after include of app.h */ #ifndef configMAC_ADDR #include "fsl_silicon_id.h" #endif #ifndef EXAMPLE_NETIF_INIT_FN /*! [url=home.php?mod=space&uid=159083]@brief[/url] Network interface initialization function. */ #define EXAMPLE_NETIF_INIT_FN ethernetif0_init #endif /* EXAMPLE_NETIF_INIT_FN */ /******************************************************************************* * Prototypes ******************************************************************************/ /******************************************************************************* * Variables ******************************************************************************/ phy_lan8741_resource_t g_phy_resource; static phy_handle_t phyHandle; /******************************************************************************* * Code ******************************************************************************/ static void MDIO_Init(void) { (void)CLOCK_EnableClock(s_enetClock[ENET_GetInstance(EXAMPLE_ENET_BASE)]); ENET_SetSMI(EXAMPLE_ENET_BASE, CLOCK_GetCoreSysClkFreq()); } static status_t MDIO_Write(uint8_t phyAddr, uint8_t regAddr, uint16_t data) { return ENET_MDIOWrite(EXAMPLE_ENET_BASE, phyAddr, regAddr, data); } static status_t MDIO_Read(uint8_t phyAddr, uint8_t regAddr, uint16_t *pData) { return ENET_MDIORead(EXAMPLE_ENET_BASE, phyAddr, regAddr, pData); } void init_net(void) { struct netif netif; ip4_addr_t netif_ipaddr, netif_netmask, netif_gw; ethernetif_config_t enet_config = { .phyHandle = &phyHandle, .phyAddr = EXAMPLE_PHY_ADDRESS, .phyOps = EXAMPLE_PHY_OPS, .phyResource = EXAMPLE_PHY_RESOURCE, #ifdef configMAC_ADDR .macAddress = configMAC_ADDR #endif }; CLOCK_AttachClk(MUX_A(CM_ENETRMIICLKSEL, 0)); CLOCK_EnableClock(kCLOCK_Enet); SYSCON0->PRESETCTRL2 = SYSCON_PRESETCTRL2_ENET_RST_MASK; SYSCON0->PRESETCTRL2 &= ~SYSCON_PRESETCTRL2_ENET_RST_MASK; MDIO_Init(); g_phy_resource.read = MDIO_Read; g_phy_resource.write = MDIO_Write; time_init(); /* Set MAC address. */ #ifndef configMAC_ADDR (void)SILICONID_ConvertToMacAddr(&enet_config.macAddress); #endif /* Get clock after hardware init. */ enet_config.srcClockHz = EXAMPLE_CLOCK_FREQ; IP4_ADDR(&netif_ipaddr, configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3); IP4_ADDR(&netif_netmask, configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3); IP4_ADDR(&netif_gw, configGW_ADDR0, configGW_ADDR1, configGW_ADDR2, configGW_ADDR3); lwip_init(); netif_add(&netif, &netif_ipaddr, &netif_netmask, &netif_gw, &enet_config, EXAMPLE_NETIF_INIT_FN, ethernet_input); netif_set_default(&netif); netif_set_up(&netif); while (ethernetif_wait_linkup(&netif, 5000) != ERR_OK) { PRINTF("PHY Auto-negotiation failed. Please check the cable connection and link partner setting.\r\n"); } ping_init(&netif_gw); PRINTF("\r\n************************************************\r\n"); PRINTF(" PING example\r\n"); PRINTF("************************************************\r\n"); PRINTF(" IPv4 Address : %u.%u.%u.%u\r\n", ((u8_t *)&netif_ipaddr)[0], ((u8_t *)&netif_ipaddr)[1], ((u8_t *)&netif_ipaddr)[2], ((u8_t *)&netif_ipaddr)[3]); PRINTF(" IPv4 Subnet mask : %u.%u.%u.%u\r\n", ((u8_t *)&netif_netmask)[0], ((u8_t *)&netif_netmask)[1], ((u8_t *)&netif_netmask)[2], ((u8_t *)&netif_netmask)[3]); PRINTF(" IPv4 Gateway : %u.%u.%u.%u\r\n", ((u8_t *)&netif_gw)[0], ((u8_t *)&netif_gw)[1], ((u8_t *)&netif_gw)[2], ((u8_t *)&netif_gw)[3]); PRINTF("************************************************\r\n"); while (1) { /* Poll the driver, get any outstanding frames */ ethernetif_input(&netif); sys_check_timeouts(); /* Handle all system timeouts for all core protocols */ } }   5.2、net_ping.h #ifndef __NET_PING_H #define __NET_PING_H void init_net(void); #endif 5.3、main.c #include "main.h" int main(void) { BOARD_InitDEBUG_UARTPins(); BOARD_PowerMode_OD(); BOARD_InitBootPins(); BOARD_InitBootClocks(); BOARD_InitDebugConsole(); SysTick_Init(); init_led(); init_key(); init_net(); while (1) { } }   六、运行结果   6.1、下载程序后,复位开发板,连接网线,运行后串口输出     6.2、ping网络   七、附件   程序源码:

  • 发表了主题帖: 【FRDM-MCXN947】CAN0收发测试

    测试开发板上的CAN0通信,实现数据收发。   一、硬件部分   开发板上的CAN通信部分电路图   二、配置端口和时钟   2.1、CAN0端口配置   2.2、配置CAN0时钟   三、程序部分   3.1、can.c #include "main.h" #if (defined(USE_CANFD) && USE_CANFD) /* * DWORD_IN_MB DLC BYTES_IN_MB Maximum MBs * 2 8 kFLEXCAN_8BperMB 64 * 4 10 kFLEXCAN_16BperMB 42 * 8 13 kFLEXCAN_32BperMB 25 * 16 15 kFLEXCAN_64BperMB 14 * * Dword in each message buffer, Length of data in bytes, Payload size must align, * and the Message Buffers are limited corresponding to each payload configuration: */ #define DLC (15) #define BYTES_IN_MB kFLEXCAN_64BperMB #else #define DLC (8) #endif flexcan_handle_t flexcanHandle; volatile bool txComplete = false; volatile bool rxComplete = false; volatile bool wakenUp = false; flexcan_mb_transfer_t txXfer, rxXfer; #if (defined(USE_CANFD) && USE_CANFD) flexcan_fd_frame_t frame; #else flexcan_frame_t frame; #endif uint32_t txIdentifier; uint32_t rxIdentifier; static void FLEXCAN_PHY_Config(void) { #if (defined(USE_PHY_TJA1152) && USE_PHY_TJA1152) /* Initialize TJA1152. */ /* STB=H, configuration CAN messages are expected from the local host via TXD pin. */ RGPIO_PortSet(EXAMPLE_STB_RGPIO, 1u << EXAMPLE_STB_RGPIO_PIN); /* Classical CAN messages with standard identifier 0x555 must be transmitted * by the local host controller until acknowledged by the TJA1152 for * automatic bit rate detection. Do not set frame.brs = 1U to keep nominal * bit rate in CANFD frame data phase. */ frame.id = FLEXCAN_ID_STD(0x555); frame.format = (uint8_t)kFLEXCAN_FrameFormatStandard; frame.type = (uint8_t)kFLEXCAN_FrameTypeData; frame.length = 0U; txXfer.mbIdx = (uint8_t)TX_MESSAGE_BUFFER_NUM; #if (defined(USE_CANFD) && USE_CANFD) txXfer.framefd = &frame; (void)FLEXCAN_TransferFDSendNonBlocking(EXAMPLE_CAN, &flexcanHandle, &txXfer); #else txXfer.frame = &frame; (void)FLEXCAN_TransferSendNonBlocking(EXAMPLE_CAN, &flexcanHandle, &txXfer); #endif while (!txComplete) { }; txComplete = false; /* Configuration of spoofing protection. */ /* Add 0x321 and 0x123 to Transmission Whitelist. */ frame.id = FLEXCAN_ID_EXT(0x18DA00F1); frame.format = (uint8_t)kFLEXCAN_FrameFormatExtend; frame.type = (uint8_t)kFLEXCAN_FrameTypeData; frame.length = 6U; #if (defined(USE_CANFD) && USE_CANFD) frame.dataWord[0] = CAN_WORD_DATA_BYTE_0(0x10) | CAN_WORD_DATA_BYTE_1(0x00) | CAN_WORD_DATA_BYTE_2(0x33) | CAN_WORD_DATA_BYTE_3(0x21); frame.dataWord[1] = CAN_WORD_DATA_BYTE_4(0x11) | CAN_WORD_DATA_BYTE_5(0x23); (void)FLEXCAN_TransferFDSendNonBlocking(EXAMPLE_CAN, &flexcanHandle, &txXfer); #else frame.dataWord0 = CAN_WORD0_DATA_BYTE_0(0x10) | CAN_WORD0_DATA_BYTE_1(0x00) | CAN_WORD0_DATA_BYTE_2(0x33) | CAN_WORD0_DATA_BYTE_3(0x21); frame.dataWord1 = CAN_WORD1_DATA_BYTE_4(0x11) | CAN_WORD1_DATA_BYTE_5(0x23); (void)FLEXCAN_TransferSendNonBlocking(EXAMPLE_CAN, &flexcanHandle, &txXfer); #endif while (!txComplete) { }; txComplete = false; /* Configuration of command message ID. */ /* Reconfiguration is only accepted locally. Keep CONFIG_ID as default value 0x18DA00F1. */ frame.length = 5U; #if (defined(USE_CANFD) && USE_CANFD) frame.dataWord[0] = CAN_WORD_DATA_BYTE_0(0x60) | CAN_WORD_DATA_BYTE_1(0x98) | CAN_WORD_DATA_BYTE_2(0xDA) | CAN_WORD_DATA_BYTE_3(0x00); frame.dataWord[1] = CAN_WORD_DATA_BYTE_4(0xF1); (void)FLEXCAN_TransferFDSendNonBlocking(EXAMPLE_CAN, &flexcanHandle, &txXfer); #else frame.dataWord0 = CAN_WORD0_DATA_BYTE_0(0x60) | CAN_WORD0_DATA_BYTE_1(0x98) | CAN_WORD0_DATA_BYTE_2(0xDA) | CAN_WORD0_DATA_BYTE_3(0x00); frame.dataWord1 = CAN_WORD1_DATA_BYTE_4(0xF1); (void)FLEXCAN_TransferSendNonBlocking(EXAMPLE_CAN, &flexcanHandle, &txXfer); #endif while (!txComplete) { }; txComplete = false; /* Leaving configuration mode. */ /* Configuration into volatile memory only. */ frame.length = 8U; #if (defined(USE_CANFD) && USE_CANFD) frame.dataWord[0] = CAN_WORD_DATA_BYTE_0(0x71) | CAN_WORD_DATA_BYTE_1(0x02) | CAN_WORD_DATA_BYTE_2(0x03) | CAN_WORD_DATA_BYTE_3(0x04); frame.dataWord[1] = CAN_WORD_DATA_BYTE_4(0x05) | CAN_WORD_DATA_BYTE_5(0x06) | CAN_WORD_DATA_BYTE_6(0x07) | CAN_WORD_DATA_BYTE_7(0x08); (void)FLEXCAN_TransferFDSendNonBlocking(EXAMPLE_CAN, &flexcanHandle, &txXfer); #else frame.dataWord0 = CAN_WORD0_DATA_BYTE_0(0x71) | CAN_WORD0_DATA_BYTE_1(0x02) | CAN_WORD0_DATA_BYTE_2(0x03) | CAN_WORD0_DATA_BYTE_3(0x04); frame.dataWord1 = CAN_WORD1_DATA_BYTE_4(0x05) | CAN_WORD1_DATA_BYTE_5(0x06) | CAN_WORD1_DATA_BYTE_6(0x07) | CAN_WORD1_DATA_BYTE_7(0x08); (void)FLEXCAN_TransferSendNonBlocking(EXAMPLE_CAN, &flexcanHandle, &txXfer); #endif while (!txComplete) { }; txComplete = false; LOG_INFO("Initialize TJA1152 successfully!\r\n\r\n"); /* STB=L, TJA1152 switch from secure standby mode to normal mode. */ RGPIO_PortClear(EXAMPLE_STB_RGPIO, 1u << EXAMPLE_STB_RGPIO_PIN); /* Initialize TJA1152 end. */ #endif } /*! * [url=home.php?mod=space&uid=159083]@brief[/url] FlexCAN Call Back function */ static FLEXCAN_CALLBACK(flexcan_callback) { switch (status) { case kStatus_FLEXCAN_RxIdle: if (RX_MESSAGE_BUFFER_NUM == result) { rxComplete = true; } break; case kStatus_FLEXCAN_TxIdle: if (TX_MESSAGE_BUFFER_NUM == result) { txComplete = true; } break; case kStatus_FLEXCAN_WakeUp: wakenUp = true; break; default: break; } } uint8_t can_rx_hdl(uint8_t *rxbuf) { uint8_t can_tx_buf[8]; /* Start receive data through Rx Message Buffer. */ rxXfer.mbIdx = (uint8_t)RX_MESSAGE_BUFFER_NUM; #if (defined(USE_CANFD) && USE_CANFD) rxXfer.framefd = &frame; (void)FLEXCAN_TransferFDReceiveNonBlocking(EXAMPLE_CAN, &flexcanHandle, &rxXfer); #else rxXfer.frame = &frame; (void)FLEXCAN_TransferReceiveNonBlocking(EXAMPLE_CAN, &flexcanHandle, &rxXfer); #endif if(rxComplete==true) { rxComplete=false; LOG_INFO(" Rx MB ID: 0x%3x, Rx MB data: %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x \r\n", frame.id >> CAN_ID_STD_SHIFT,frame.dataByte0,frame.dataByte1,frame.dataByte2,frame.dataByte3, frame.dataByte4,frame.dataByte5,frame.dataByte6,frame.dataByte7); rxbuf[0] = frame.dataByte0; rxbuf[1] = frame.dataByte1; rxbuf[2] = frame.dataByte2; rxbuf[3] = frame.dataByte3; rxbuf[4] = frame.dataByte4; rxbuf[5] = frame.dataByte5; rxbuf[6] = frame.dataByte6; rxbuf[7] = frame.dataByte7; return 1; } return 0; } void can_std_tx(uint32_t id, uint8_t *txbuf) { frame.id = FLEXCAN_ID_STD(id); frame.format = (uint8_t)kFLEXCAN_FrameFormatStandard; frame.type = (uint8_t)kFLEXCAN_FrameTypeData; frame.length = (uint8_t)DLC; #if (defined(USE_CANFD) && USE_CANFD) frame.brs = 1U; frame.edl = 1U; #endif txXfer.mbIdx = (uint8_t)TX_MESSAGE_BUFFER_NUM; #if (defined(USE_CANFD) && USE_CANFD) txXfer.framefd = &frame; (void)FLEXCAN_TransferFDSendNonBlocking(EXAMPLE_CAN, &flexcanHandle, &txXfer); #else txXfer.frame = &frame; frame.dataByte0 = txbuf[0]; frame.dataByte1 = txbuf[1]; frame.dataByte2 = txbuf[2]; frame.dataByte3 = txbuf[3]; frame.dataByte4 = txbuf[4]; frame.dataByte5 = txbuf[5]; frame.dataByte6 = txbuf[6]; frame.dataByte7 = txbuf[7]; (void)FLEXCAN_TransferSendNonBlocking(EXAMPLE_CAN, &flexcanHandle, &txXfer); #endif while (!txComplete) { }; txComplete = false; } void init_can(void) { flexcan_config_t flexcanConfig; flexcan_rx_mb_config_t mbConfig; uint8_t node_type; rxIdentifier = 0x506; FLEXCAN_GetDefaultConfig(&flexcanConfig); flexcanConfig.bitRate = 500000U; #if defined(EXAMPLE_CAN_CLK_SOURCE) flexcanConfig.clkSrc = EXAMPLE_CAN_CLK_SOURCE; #endif #if defined(EXAMPLE_CAN_BIT_RATE) flexcanConfig.bitRate = EXAMPLE_CAN_BIT_RATE; #endif /* If special quantum setting is needed, set the timing parameters. */ #if (defined(SET_CAN_QUANTUM) && SET_CAN_QUANTUM) flexcanConfig.timingConfig.phaseSeg1 = PSEG1; flexcanConfig.timingConfig.phaseSeg2 = PSEG2; flexcanConfig.timingConfig.propSeg = PROPSEG; #if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) flexcanConfig.timingConfig.fphaseSeg1 = FPSEG1; flexcanConfig.timingConfig.fphaseSeg2 = FPSEG2; flexcanConfig.timingConfig.fpropSeg = FPROPSEG; #endif #endif #if (defined(USE_IMPROVED_TIMING_CONFIG) && USE_IMPROVED_TIMING_CONFIG) flexcan_timing_config_t timing_config; memset(&timing_config, 0, sizeof(flexcan_timing_config_t)); #if (defined(USE_CANFD) && USE_CANFD) if (FLEXCAN_FDCalculateImprovedTimingValues(EXAMPLE_CAN, flexcanConfig.bitRate, flexcanConfig.bitRateFD, EXAMPLE_CAN_CLK_FREQ, &timing_config)) { /* Update the improved timing configuration*/ memcpy(&(flexcanConfig.timingConfig), &timing_config, sizeof(flexcan_timing_config_t)); } else { LOG_INFO("No found Improved Timing Configuration. Just used default configuration\r\n\r\n"); } #else if (FLEXCAN_CalculateImprovedTimingValues(EXAMPLE_CAN, flexcanConfig.bitRate, EXAMPLE_CAN_CLK_FREQ, &timing_config)) { /* Update the improved timing configuration*/ memcpy(&(flexcanConfig.timingConfig), &timing_config, sizeof(flexcan_timing_config_t)); } else { LOG_INFO("No found Improved Timing Configuration. Just used default configuration\r\n\r\n"); } #endif #endif #if (defined(USE_CANFD) && USE_CANFD) FLEXCAN_FDInit(EXAMPLE_CAN, &flexcanConfig, EXAMPLE_CAN_CLK_FREQ, BYTES_IN_MB, true); #else FLEXCAN_Init(EXAMPLE_CAN, &flexcanConfig, EXAMPLE_CAN_CLK_FREQ); #endif /* Create FlexCAN handle structure and set call back function. */ FLEXCAN_TransferCreateHandle(EXAMPLE_CAN, &flexcanHandle, flexcan_callback, NULL); /* Set Rx Masking mechanism. */ FLEXCAN_SetRxMbGlobalMask(EXAMPLE_CAN, FLEXCAN_RX_MB_STD_MASK(rxIdentifier, 0, 0)); /* Setup Rx Message Buffer. */ mbConfig.format = kFLEXCAN_FrameFormatStandard; mbConfig.type = kFLEXCAN_FrameTypeData; mbConfig.id = FLEXCAN_ID_STD(rxIdentifier); #if (defined(USE_CANFD) && USE_CANFD) FLEXCAN_SetFDRxMbConfig(EXAMPLE_CAN, RX_MESSAGE_BUFFER_NUM, &mbConfig, true); #else FLEXCAN_SetRxMbConfig(EXAMPLE_CAN, RX_MESSAGE_BUFFER_NUM, &mbConfig, true); #endif /* Setup Tx Message Buffer. */ #if (defined(USE_CANFD) && USE_CANFD) FLEXCAN_SetFDTxMbConfig(EXAMPLE_CAN, TX_MESSAGE_BUFFER_NUM, true); #else FLEXCAN_SetTxMbConfig(EXAMPLE_CAN, TX_MESSAGE_BUFFER_NUM, true); #endif /* Configure CAN transceiver */ FLEXCAN_PHY_Config(); }   3.2、can.h #ifndef __CAN_H #define __CAN_H #define USE_CANFD (0) #define EXAMPLE_CAN CAN0 #define RX_MESSAGE_BUFFER_NUM (0) #define TX_MESSAGE_BUFFER_NUM (1) #define EXAMPLE_CAN_CLK_FREQ CLOCK_GetFlexcanClkFreq(0U) #define USE_IMPROVED_TIMING_CONFIG (1) #define LOG_INFO (void)PRINTF void init_can(void); void can_std_tx(uint32_t id, uint8_t *txbuf); uint8_t can_rx_hdl(uint8_t *rxbuf); #endif   3.3、main.c #include "main.h" int main(void) { uint8_t can_tx_buf[8]; uint8_t can_rx_buf[8]; uint8_t i; CLOCK_EnableClock(kCLOCK_Gpio0); BOARD_InitDEBUG_UARTPins(); BOARD_PowerMode_OD(); BOARD_InitBootPins(); BOARD_InitBootClocks(); BOARD_InitDebugConsole(); SysTick_Init(); init_led(); init_can(); while (1) { if(can_rx_hdl(can_rx_buf)) { can_std_tx((uint32_t)0x510,can_rx_buf); } } }   四、运行结果   4.1、CAN0收发数据   4.2、串口打印接收的数据   五、附件   测试源代码:      

  • 回复了主题帖: 【兆易GD32H759I-EVAL】ADC测试

    zz19940910 发表于 2025-1-8 10:10 我在pc2上给了一个1.2v电压 为什么采集不到数据呢 ADC端口配置正常?

  • 2024-12-27
  • 回复了主题帖: 【FRDM-MCXN947】TFT-LCD显示屏测试

    秦天qintian0303 发表于 2024-12-27 11:03 你这是做了转接板吗,看着好像直接连上去的 做的转接板,驱动一个老旧屏幕

  • 回复了主题帖: 【FRDM-MCXN947】TFT-LCD显示屏测试

    秦天qintian0303 发表于 2024-12-25 22:53 这个要是有那个官方的模块效果会不会更好,省的配置了 嗯,想通过MCLCD接口的配置的学习来了解这个接口方面的应用。

  • 2024-12-24
  • 发表了主题帖: 【FRDM-MCXN947】移植LVGL

    本帖最后由 TL-LED 于 2024-12-24 00:48 编辑 移植LVGL到开发板,在FreeRTOS系统基础上进行移植。   一、下载LVGL源码   下载V8.3版本 下载地址:https://github.com/lvgl/lvgl/tree/release/v8.3   二、添加文件到工程   将下载的LVGL源码文件复制到工程目录middleware\lvgl下,添加文件到工程中   三、源码部分   显示屏驱动程序参考例程FRDM-MCXN947\SDK_2_16_100_FRDM-MCXN947\boards\frdmmcxn947\lvgl_examples中的代码   3.1、lvgl_support.c /* * Copyright 2023 NXP * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include "lvgl_support.h" #include "lvgl.h" #if defined(SDK_OS_FREE_RTOS) #include "FreeRTOS.h" #include "semphr.h" #endif #include "board.h" #include "fsl_gpio.h" #if BOARD_USE_FLEXIO_SMARTDMA #include "fsl_dbi_flexio_smartdma.h" #else #include "fsl_dbi_flexio_edma.h" #endif #include "fsl_flexio_mculcd.h" #include "fsl_lpi2c.h" #include "fsl_port.h" #if BOARD_LCD_S035 #include "fsl_st7796s.h" #include "fsl_gt911.h" #else #include "fsl_ssd1963.h" #include "fsl_ft5406_rt.h" #endif #include "fsl_debug_console.h" /******************************************************************************* * Definitions ******************************************************************************/ /* Port Me. Start */ #if BOARD_LCD_S035 #else #define BOARD_SSD1963_XTAL_FREQ 10000000U #define BOARD_SSD1963_PCLK_FREQ 25000000U//30000000U #define BOARD_SSD1963_HSW 1U//48U #define BOARD_SSD1963_HFP 116//40U #define BOARD_SSD1963_HBP 44//0U #define BOARD_SSD1963_VSW 1U//3U #define BOARD_SSD1963_VFP 10U/13U #define BOARD_SSD1963_VBP 34U//18U #define BOARD_SSD1963_POLARITY_FLAG 0U #endif /* Macros for FlexIO interfacing the LCD */ #define BOARD_FLEXIO FLEXIO0 #define BOARD_FLEXIO_CLOCK_FREQ CLOCK_GetFlexioClkFreq() #define BOARD_FLEXIO_BAUDRATE_BPS 160000000U /* Macros for FlexIO shifter, timer, and pins. */ #define BOARD_FLEXIO_WR_PIN 1 #define BOARD_FLEXIO_RD_PIN 0 #define BOARD_FLEXIO_DATA_PIN_START 16 #define BOARD_FLEXIO_TX_START_SHIFTER 0 #define BOARD_FLEXIO_RX_START_SHIFTER 0 #define BOARD_FLEXIO_TX_END_SHIFTER 7 #define BOARD_FLEXIO_RX_END_SHIFTER 7 #define BOARD_FLEXIO_TIMER 0 /* Macros for the touch touch controller. */ #define BOARD_TOUCH_I2C LPI2C2 #define BOARD_TOUCH_I2C_CLOCK_FREQ CLOCK_GetLPFlexCommClkFreq(2u) #define BOARD_TOUCH_I2C_BAUDRATE 100000U /* Port Me. End */ #define DEMO_MS_TO_TICK(ms) ((ms * configTICK_RATE_HZ / 1000) + 1) /******************************************************************************* * Prototypes ******************************************************************************/ static void DEMO_InitLcd(void); static void DEMO_InitLcdClock(void); static status_t DEMO_InitLcdController(void); static void DEMO_FlushDisplay(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p); static void DEMO_InitTouch(void); static void DEMO_ReadTouch(lv_indev_drv_t *drv, lv_indev_data_t *data); static void DEMO_SetCSPin(bool set); static void DEMO_SetRSPin(bool set); /******************************************************************************* * Variables ******************************************************************************/ #if BOARD_LCD_S035 static gt911_handle_t touchHandle; #else static ft5406_rt_handle_t touchHandle; #endif #if defined(SDK_OS_FREE_RTOS) static SemaphoreHandle_t s_memWriteDone; #else static volatile bool s_memWriteDone; #endif #if BOARD_LCD_S035 /* ST7796S LCD controller handle. */ st7796s_handle_t lcdHandle; #else /* SSD1963 LCD controller handle. */ ssd1963_handle_t lcdHandle; #endif /* DBI XFER handle. */ #if BOARD_USE_FLEXIO_SMARTDMA dbi_flexio_smartdma_xfer_handle_t g_dbiFlexioXferHandle; #else dbi_flexio_edma_xfer_handle_t g_dbiFlexioXferHandle; #endif /* The FlexIO MCU LCD device. */ FLEXIO_MCULCD_Type flexioLcdDev = { .flexioBase = BOARD_FLEXIO, .busType = kFLEXIO_MCULCD_8080, .dataPinStartIndex = BOARD_FLEXIO_DATA_PIN_START, .ENWRPinIndex = BOARD_FLEXIO_WR_PIN, .RDPinIndex = BOARD_FLEXIO_RD_PIN, .txShifterStartIndex = BOARD_FLEXIO_TX_START_SHIFTER, .txShifterEndIndex = BOARD_FLEXIO_TX_END_SHIFTER, .rxShifterStartIndex = BOARD_FLEXIO_RX_START_SHIFTER, .rxShifterEndIndex = BOARD_FLEXIO_RX_END_SHIFTER, .timerIndex = BOARD_FLEXIO_TIMER, .setCSPin = DEMO_SetCSPin, .setRSPin = DEMO_SetRSPin, .setRDWRPin = NULL /* Not used in 8080 mode. */ }; SDK_ALIGN(static uint8_t s_frameBuffer[2][LCD_VIRTUAL_BUF_SIZE * LCD_FB_BYTE_PER_PIXEL], 4); /******************************************************************************* * Code ******************************************************************************/ static void DEMO_SetCSPin(bool set) { GPIO_PinWrite(BOARD_LCD_CS_GPIO, BOARD_LCD_CS_PIN, (uint8_t)set); } static void DEMO_SetRSPin(bool set) { GPIO_PinWrite(BOARD_LCD_RS_GPIO, BOARD_LCD_RS_PIN, (uint8_t)set); } static void DEMO_DbiMemoryDoneCallback(status_t status, void *userData) { #if defined(SDK_OS_FREE_RTOS) BaseType_t taskAwake = pdFALSE; xSemaphoreGiveFromISR(s_memWriteDone, &taskAwake); portYIELD_FROM_ISR(taskAwake); #else s_memWriteDone = true; #endif } #if BOARD_LCD_S035 void DEMO_LCD_I2C_Init(void) { BOARD_LPI2C_Init(BOARD_TOUCH_I2C, BOARD_TOUCH_I2C_CLOCK_FREQ); } status_t DEMO_LCD_I2C_Send( uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, const uint8_t *txBuff, uint8_t txBuffSize) { return BOARD_LPI2C_Send(BOARD_TOUCH_I2C, deviceAddress, subAddress, subaddressSize, (uint8_t *)txBuff, txBuffSize); } status_t DEMO_LCD_I2C_Receive( uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize) { return BOARD_LPI2C_Receive(BOARD_TOUCH_I2C, deviceAddress, subAddress, subaddressSize, rxBuff, rxBuffSize); } void DEMO_TouchDelayMs(uint32_t delayMs) { #if defined(SDK_OS_FREE_RTOS) vTaskDelay(pdMS_TO_TICKS(delayMs)); #else SDK_DelayAtLeastUs(delayMs * 1000, CLOCK_GetCoreSysClkFreq()); #endif } void DEMO_TouchConfigIntPin(gt911_int_pin_mode_t mode) { port_pin_config_t int_config = {/* Internal pull-up/down resistor is disabled */ kPORT_PullDown, /* Low internal pull resistor value is selected. */ kPORT_LowPullResistor, /* Fast slew rate is configured */ kPORT_FastSlewRate, /* Passive input filter is disabled */ kPORT_PassiveFilterDisable, /* Open drain output is disabled */ kPORT_OpenDrainDisable, /* Low drive strength is configured */ kPORT_LowDriveStrength, /* Pin is configured as GPIO */ kPORT_MuxAlt0, /* Digital input enabled */ kPORT_InputBufferEnable, /* Digital input is not inverted */ kPORT_InputNormal, /* Pin Control Register fields [15:0] are not locked */ kPORT_UnlockRegister}; switch (mode) { case kGT911_IntPinPullUp: int_config.pullSelect = kPORT_PullUp; break; case kGT911_IntPinPullDown: int_config.pullSelect = kPORT_PullDown; break; case kGT911_IntPinInput: int_config.pullSelect = kPORT_PullDisable; break; default: break; }; PORT_SetPinConfig(BOARD_LCD_INT_PORT, BOARD_LCD_INT_PIN, &int_config); } void DEMO_TouchConfigResetPin(bool pullUp) { /* * As touch controller and display controller shares the same reset pin, * we do not do actual reset / address configuration here. Please check below for * the relationship between RST pin and INT pin. * */ } #endif /* Clear the LCD controller video memory content. */ static void DEMO_ClearLcd(void) { int32_t leftLinesToClear = LCD_HEIGHT; int32_t curLinesToClear; int32_t startLine = 0; while (leftLinesToClear > 0) { curLinesToClear = (leftLinesToClear > (2 * LCD_VIRTUAL_BUF_HEIGHT)) ? (2 * LCD_VIRTUAL_BUF_HEIGHT) : leftLinesToClear; #if BOARD_LCD_S035 ST7796S_SelectArea(&lcdHandle, 0, startLine, LCD_WIDTH - 1, startLine + curLinesToClear - 1); #else SSD1963_SelectArea(&lcdHandle, 0, startLine, LCD_WIDTH - 1, startLine + curLinesToClear - 1); #endif #if !defined(SDK_OS_FREE_RTOS) s_memWriteDone = false; #endif #if BOARD_LCD_S035 ST7796S_WritePixels(&lcdHandle, (uint16_t *)s_frameBuffer, curLinesToClear * LCD_WIDTH); #else SSD1963_WriteMemory(&lcdHandle, (const uint8_t *)s_frameBuffer, curLinesToClear * LCD_WIDTH * LCD_FB_BYTE_PER_PIXEL); #endif #if defined(SDK_OS_FREE_RTOS) if (xSemaphoreTake(s_memWriteDone, portMAX_DELAY) != pdTRUE) { PRINTF("Wait semaphore error: s_memWriteDone\r\n"); assert(0); } #else while (false == s_memWriteDone) { } #endif startLine += curLinesToClear; leftLinesToClear -= curLinesToClear; } } status_t DEMO_InitLcdController(void) { status_t status; flexio_mculcd_config_t flexioMcuLcdConfig; #if BOARD_LCD_S035 const st7796s_config_t st7796sConfig = {.driverPreset = kST7796S_DriverPresetLCDPARS035, .pixelFormat = kST7796S_PixelFormatRGB565, .orientationMode = kST7796S_Orientation270, .teConfig = kST7796S_TEDisabled, .invertDisplay = true, .flipDisplay = true, .bgrFilter = true}; #else const ssd1963_config_t ssd1963Config = {.pclkFreq_Hz = BOARD_SSD1963_PCLK_FREQ, .pixelInterface = kSSD1963_RGB565, .panelDataWidth = kSSD1963_PanelData18Bit, .polarityFlags = BOARD_SSD1963_POLARITY_FLAG, .panelWidth = LCD_WIDTH, .panelHeight = LCD_HEIGHT, .hsw = BOARD_SSD1963_HSW, .hfp = BOARD_SSD1963_HFP, .hbp = BOARD_SSD1963_HBP, .vsw = BOARD_SSD1963_VSW, .vfp = BOARD_SSD1963_VFP, .vbp = BOARD_SSD1963_VBP}; #endif const gpio_pin_config_t pinConfig = { .pinDirection = kGPIO_DigitalOutput, .outputLogic = 1, }; #if BOARD_USE_FLEXIO_SMARTDMA flexio_mculcd_smartdma_config_t flexioEzhConfig = { .inputPixelFormat = kFLEXIO_MCULCD_RGB565, .outputPixelFormat = kFLEXIO_MCULCD_RGB565, }; #endif /* Set SSD1963 CS, RS, and reset pin to output. */ GPIO_PinInit(BOARD_LCD_RST_GPIO, BOARD_LCD_RST_PIN, &pinConfig); GPIO_PinInit(BOARD_LCD_CS_GPIO, BOARD_LCD_CS_PIN, &pinConfig); GPIO_PinInit(BOARD_LCD_RS_GPIO, BOARD_LCD_RS_PIN, &pinConfig); /* Initialize the flexio MCU LCD. */ /* * flexioMcuLcdConfig.enable = true; * flexioMcuLcdConfig.enableInDoze = false; * flexioMcuLcdConfig.enableInDebug = true; * flexioMcuLcdConfig.enableFastAccess = true; * flexioMcuLcdConfig.baudRate_Bps = 96000000U; */ FLEXIO_MCULCD_GetDefaultConfig(&flexioMcuLcdConfig); flexioMcuLcdConfig.baudRate_Bps = BOARD_FLEXIO_BAUDRATE_BPS; status = FLEXIO_MCULCD_Init(&flexioLcdDev, &flexioMcuLcdConfig, BOARD_FLEXIO_CLOCK_FREQ); if (kStatus_Success != status) { return status; } #if BOARD_USE_FLEXIO_SMARTDMA /* Create the DBI XFER handle. */ status = DBI_FLEXIO_SMARTDMA_CreateXferHandle(&g_dbiFlexioXferHandle, &flexioLcdDev, &flexioEzhConfig); #else /* Create the DBI XFER handle. Because DMA transfer is not used, so don't * need to create DMA handle. */ status = DBI_FLEXIO_EDMA_CreateXferHandle(&g_dbiFlexioXferHandle, &flexioLcdDev, NULL, NULL); #endif if (kStatus_Success != status) { return status; } /* Reset the SSD1963 LCD controller. */ GPIO_PinWrite(BOARD_LCD_RST_GPIO, BOARD_LCD_RST_PIN, 0); #if BOARD_LCD_S035 /* Required for GT911 I2C address mode 0 */ DEMO_TouchConfigIntPin(kGT911_IntPinPullDown); #endif #if defined(SDK_OS_FREE_RTOS) vTaskDelay(DEMO_MS_TO_TICK(1)); /* Delay at least 10ns. */ #else SDK_DelayAtLeastUs(1000U, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY); #endif GPIO_PinWrite(BOARD_LCD_RST_GPIO, BOARD_LCD_RST_PIN, 1); #if BOARD_LCD_S035 DEMO_TouchConfigIntPin(kGT911_IntPinInput); #endif #if defined(SDK_OS_FREE_RTOS) vTaskDelay(DEMO_MS_TO_TICK(5)); /* Delay at 5ms. */ #else SDK_DelayAtLeastUs(5000U, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY); #endif #if BOARD_USE_FLEXIO_SMARTDMA #if BOARD_LCD_S035 status = ST7796S_Init(&lcdHandle, &st7796sConfig, &g_dbiFlexioSmartdmaXferOps, &g_dbiFlexioXferHandle); #else status = SSD1963_Init(&lcdHandle, &ssd1963Config, &g_dbiFlexioSmartdmaXferOps, &g_dbiFlexioXferHandle, BOARD_SSD1963_XTAL_FREQ); #endif #else #if BOARD_LCD_S035 status = ST7796S_Init(&lcdHandle, &st7796sConfig, &g_dbiFlexioEdmaXferOps, &g_dbiFlexioXferHandle); #else status = SSD1963_Init(&lcdHandle, &ssd1963Config, &g_dbiFlexioEdmaXferOps, &g_dbiFlexioXferHandle, BOARD_SSD1963_XTAL_FREQ); #endif #endif if (status == kStatus_Success) { #if BOARD_LCD_S035 ST7796S_SetMemoryDoneCallback(&lcdHandle, DEMO_DbiMemoryDoneCallback, NULL); #else SSD1963_SetMemoryDoneCallback(&lcdHandle, DEMO_DbiMemoryDoneCallback, NULL); #endif /* Clear the SSD1963 video ram. */ DEMO_ClearLcd(); #if BOARD_LCD_S035 ST7796S_EnableDisplay(&lcdHandle, true); #else SSD1963_StartDisplay(&lcdHandle); SSD1963_SetBackLight(&lcdHandle, 128); #endif } else { PRINTF("LCD controller initialization failed.\r\n"); } return status; } static void DEMO_InitLcdClock(void) { } static void DEMO_InitLcd(void) { #if defined(SDK_OS_FREE_RTOS) s_memWriteDone = xSemaphoreCreateBinary(); if (NULL == s_memWriteDone) { PRINTF("Frame semaphore create failed\r\n"); assert(0); } #else s_memWriteDone = false; #endif DEMO_InitLcdClock(); DEMO_InitLcdController(); } /* Flush the content of the internal buffer the specific area on the display * You can use DMA or any hardware acceleration to do this operation in the background but * 'lv_flush_ready()' has to be called when finished * This function is required only when LV_VDB_SIZE != 0 in lv_conf.h*/ static void DEMO_FlushDisplay(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) { lv_coord_t x1 = area->x1; lv_coord_t y1 = area->y1; lv_coord_t x2 = area->x2; lv_coord_t y2 = area->y2; int32_t length = (x2 - x1 + 1) * (y2 - y1 + 1) * LCD_FB_BYTE_PER_PIXEL; #if BOARD_LCD_S035 ST7796S_SelectArea(&lcdHandle, x1, y1, x2, y2); #else SSD1963_SelectArea(&lcdHandle, x1, y1, x2, y2); #endif #if !defined(SDK_OS_FREE_RTOS) s_memWriteDone = false; #endif #if BOARD_LCD_S035 ST7796S_WritePixels(&lcdHandle, (uint16_t *)color_p, length / LCD_FB_BYTE_PER_PIXEL); #else SSD1963_WriteMemory(&lcdHandle, (const uint8_t *)color_p, length); #endif #if defined(SDK_OS_FREE_RTOS) if (xSemaphoreTake(s_memWriteDone, portMAX_DELAY) != pdTRUE) { PRINTF("Wait semaphore error: s_memWriteDone\r\n"); assert(0); } #else while (!s_memWriteDone) { } #endif /* IMPORTANT!!! * Inform the graphics library that you are ready with the flushing*/ lv_disp_flush_ready(disp_drv); } void lv_port_pre_init(void) { } void lv_port_disp_init(void) { static lv_disp_draw_buf_t disp_buf; memset(s_frameBuffer, 0, sizeof(s_frameBuffer)); lv_disp_draw_buf_init(&disp_buf, (void *)s_frameBuffer[0], (void *)s_frameBuffer[1], LCD_VIRTUAL_BUF_SIZE); /*------------------------- * Initialize your display * -----------------------*/ DEMO_InitLcd(); /*----------------------------------- * Register the display in LittlevGL *----------------------------------*/ static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ lv_disp_drv_init(&disp_drv); /*Basic initialization*/ /*Set up the functions to access to your display*/ /*Set the resolution of the display*/ disp_drv.hor_res = LCD_WIDTH; disp_drv.ver_res = LCD_HEIGHT; /*Used to copy the buffer's content to the display*/ disp_drv.flush_cb = DEMO_FlushDisplay; /*Set a display buffer*/ disp_drv.draw_buf = &disp_buf; /*Finally register the driver*/ lv_disp_drv_register(&disp_drv); } void lv_port_indev_init(void) { static lv_indev_drv_t indev_drv; /*------------------ * Touchpad * -----------------*/ /*Initialize your touchpad */ DEMO_InitTouch(); /*Register a touchpad input device*/ lv_indev_drv_init(&indev_drv); indev_drv.type = LV_INDEV_TYPE_POINTER; indev_drv.read_cb = DEMO_ReadTouch; lv_indev_drv_register(&indev_drv); } /*Initialize your touchpad*/ static void DEMO_InitTouch(void) { #if BOARD_LCD_S035 DEMO_LCD_I2C_Init(); gt911_config_t touchConfig = {.I2C_SendFunc = DEMO_LCD_I2C_Send, .I2C_ReceiveFunc = DEMO_LCD_I2C_Receive, .timeDelayMsFunc = DEMO_TouchDelayMs, .intPinFunc = DEMO_TouchConfigIntPin, .pullResetPinFunc = DEMO_TouchConfigResetPin, .touchPointNum = 5, .i2cAddrMode = kGT911_I2cAddrMode0, .intTrigMode = kGT911_IntFallingEdge}; GT911_Init(&touchHandle, &touchConfig); #else lpi2c_master_config_t masterConfig; /* * masterConfig.enableMaster = true; * masterConfig.baudRate_Bps = 100000U; * masterConfig.enableTimeout = false; */ LPI2C_MasterGetDefaultConfig(&masterConfig); /* Change the default baudrate configuration */ masterConfig.baudRate_Hz = BOARD_TOUCH_I2C_BAUDRATE; /* Initialize the I2C master peripheral */ LPI2C_MasterInit(BOARD_TOUCH_I2C, &masterConfig, BOARD_TOUCH_I2C_CLOCK_FREQ); /* Initialize the touch handle. */ FT5406_RT_Init(&touchHandle, BOARD_TOUCH_I2C); #endif } /* Will be called by the library to read the touchpad */ static void DEMO_ReadTouch(lv_indev_drv_t *drv, lv_indev_data_t *data) { #if BOARD_LCD_S035 touch_point_t tp[5]; uint8_t tp_count = 5; GT911_GetMultiTouch(&touchHandle, &tp_count, tp); /** * GT911 supports 5 points tracking, we only tracks ID #0. * */ bool found_track = false; for (uint8_t i = 0; i < tp_count; i++) { /* Found track ID #0 */ if (tp[i].touchID == 0) { data->state = LV_INDEV_STATE_PRESSED; switch (lcdHandle.orientationMode) { case kST7796S_Orientation0: data->point.x = (int16_t)tp[i].x; data->point.y = (int16_t)tp[i].y; break; case kST7796S_Orientation90: data->point.x = (int16_t)(touchHandle.resolutionY - tp[i].y); data->point.y = (int16_t)tp[i].x; break; case kST7796S_Orientation180: data->point.x = (int16_t)(touchHandle.resolutionX - tp[i].x); data->point.y = (int16_t)(touchHandle.resolutionY - tp[i].y); break; case kST7796S_Orientation270: data->point.x = (int16_t)tp[i].y; data->point.y = (int16_t)(touchHandle.resolutionX - tp[i].x); break; default: break; } found_track = true; break; } } /* No track #0 found... */ if (!found_track) { data->state = LV_INDEV_STATE_RELEASED; } #else touch_event_t touch_event; static int touch_x = 0; static int touch_y = 0; data->state = LV_INDEV_STATE_REL; if (kStatus_Success == FT5406_RT_GetSingleTouch(&touchHandle, &touch_event, &touch_x, &touch_y)) { if ((touch_event == kTouch_Down) || (touch_event == kTouch_Contact)) { data->state = LV_INDEV_STATE_PR; } } /*Set the last pressed coordinates*/ data->point.y = touch_y; data->point.x = touch_x; #endif }   3.2、fun_task.c #include "main.h" static volatile bool s_lvgl_initialized = false; #define START_TASK_PRO tskIDLE_PRIORITY + 1 #define START_STK_SIZE 256 TaskHandle_t StartTask_Handler; #define TASK1_PRIO tskIDLE_PRIORITY + 2 #define TASK1_STK_SIZE 256 static TaskHandle_t Task1Task_Handler = NULL; #define TASK2_PRIO tskIDLE_PRIORITY + 3 #define TASK2_STK_SIZE 256 static TaskHandle_t Task2Task_Handler = NULL; #define TASK3_PRIO tskIDLE_PRIORITY + 4 #define TASK3_STK_SIZE configMINIMAL_STACK_SIZE + 800 static TaskHandle_t Task3Task_Handler = NULL; void start_task(void *pvParameters); void task1(void *pvParameters); void task2(void *pvParameters); void task3(void *pvParameters); void task_create(void) { //start_task xTaskCreate((TaskFunction_t )start_task, (const char* )"start_task", (uint16_t )START_STK_SIZE, (void* )NULL, (UBaseType_t )START_TASK_PRO, (TaskHandle_t* )&StartTask_Handler); vTaskStartScheduler(); } void start_task(void *pvParameters) { taskENTER_CRITICAL(); //task1 xTaskCreate((TaskFunction_t )task1, (const char* )"task1", (uint16_t )TASK1_STK_SIZE, (void* )NULL, (UBaseType_t )TASK1_PRIO, (TaskHandle_t* )&Task1Task_Handler); //task2 xTaskCreate((TaskFunction_t )task2, (const char* )"task2", (uint16_t )TASK2_STK_SIZE, (void* )NULL, (UBaseType_t )TASK2_PRIO, (TaskHandle_t* )&Task2Task_Handler); //task3-lvlg xTaskCreate((TaskFunction_t )task3, (const char* )"task3", (uint16_t )TASK3_STK_SIZE, (void* )NULL, (UBaseType_t )TASK3_PRIO, (TaskHandle_t* )&Task2Task_Handler); taskEXIT_CRITICAL(); vTaskDelete(StartTask_Handler); } //task1 void task1(void *pvParameters) { __IO uint32_t index = 0; __IO uint32_t flash_id_index = 0; // tx_data_fill(); // spiflash_init(); // flash_id_index = spiflash_read_id(); // if(flash_id_index !=0x5114) // { // PRINTF("flash id check error!\r\n"); // } // else // { // PRINTF("flash id check success! id: %x\r\n", flash_id_index); // } // // spiflash_sector_erase(FLASH_TEST_ADDR / SPIF_SECTOR_SIZE); // spiflash_write(tx_buffer, FLASH_TEST_ADDR, SPI_BUF_SIZE); // spiflash_read(rx_buffer, FLASH_TEST_ADDR, SPI_BUF_SIZE); // PRINTF("Read Data: "); // for(index = 0; index < SPI_BUF_SIZE; index++) // { // PRINTF("%x ", rx_buffer[index]); // } while (1) { PRINTF("task1 run ...\r\n"); vTaskDelay(200); } } //task2 void task2(void *pvParameters) { while (1) { PRINTF("task2 run ...\r\n"); vTaskDelay(100); } } //task3 void task3(void *pvParameters) { lv_port_pre_init(); lv_init();S lv_port_disp_init(); //lv_port_indev_init(); s_lvgl_initialized = true; lv_demo_benchmark(); while (1) { lv_task_handler(); led_red_tog(); vTaskDelay(5); } } /*! * [url=home.php?mod=space&uid=159083]@brief[/url] FreeRTOS tick hook. */ void vApplicationTickHook(void) { if (s_lvgl_initialized) { lv_tick_inc(1); } } /*! * @brief Malloc failed hook. */ void vApplicationMallocFailedHook(void) { PRINTF("Malloc failed. Increase the heap size."); for (;;) ; } /*! * @brief Stack overflow hook. */ void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName) { (void)pcTaskName; (void)xTask; for (;;) ; }   3.3、main.c #include "main.h" static void BOARD_InitSmartDMA(void); int main(void) { uint8_t i; CLOCK_EnableClock(kCLOCK_Gpio0); BOARD_InitDEBUG_UARTPins(); BOARD_PowerMode_OD(); BOARD_InitBootPins(); BOARD_InitBootClocks(); BOARD_InitDebugConsole(); BOARD_InitSmartDMA(); init_led(); init_key(); task_create(); while (1) { } } static void BOARD_InitSmartDMA(void) { RESET_ClearPeripheralReset(kMUX_RST_SHIFT_RSTn); INPUTMUX_Init(INPUTMUX0); INPUTMUX_AttachSignal(INPUTMUX0, 0, kINPUTMUX_FlexioToSmartDma); /* Turnoff clock to inputmux to save power. Clock is only needed to make changes */ INPUTMUX_Deinit(INPUTMUX0); SMARTDMA_InitWithoutFirmware(); NVIC_EnableIRQ(SMARTDMA_IRQn); NVIC_SetPriority(SMARTDMA_IRQn, 3); }   四、程序运行   下载程序到开发板后,显示屏显示如下: [localvideo]43de8b1f1ac9d1df8dff2fab4ea63801[/localvideo]    

  • 2024-12-23
  • 回复了主题帖: 【FRDM-MCXN947】TFT-LCD显示屏测试

    bigbat 发表于 2024-12-23 09:40 感觉楼主的速度有点慢,是不是楼主程序有延时。 小窗口循环显示有延时

  • 2024-12-22
  • 发表了主题帖: 【FRDM-MCXN947】TFT-LCD显示屏测试

    本帖最后由 TL-LED 于 2024-12-22 22:50 编辑 使用FLEXIO接口测试TFT-LCD显示屏,驱动芯片使用SSD1963。   一、硬件接口部分   1.1、使用板子上的LCD接口   1.2、SSD1963接口框图 1.3、SSD1963数据格式 SSD1963与显示屏之间数据接口的连接定义   1.4、显示屏接口 我的显示屏是18位总线,在配置SSD1963时,选择18位数据。   二、引脚配置   2.1、配置显示屏接口   2.2、配置外设   三、程序部分   3.1、mculcd.c #include "main.h" /******************************************************************************* * Prototypes ******************************************************************************/ void BOARD_InitSmartDMA(void); static void DEMO_InitFlexioMcuLcd(void); static void DEMO_InitPanel(void); static void DEMO_StartPanel(void); static status_t DEMO_LcdWriteCommand(void *dbiXferHandle, uint32_t command); static status_t DEMO_LcdWriteData(void *dbiXferHandle, void *data, uint32_t len_byte); static status_t DEMO_LcdWriteMemory(void *dbiXferHandle, uint32_t command, const void *data, uint32_t len_byte); /******************************************************************************* * Variables ******************************************************************************/ /* The functions used to drive the panel. */ static dbi_xfer_ops_t s_flexioDbiOps = { .writeCommand = DEMO_LcdWriteCommand, .writeData = DEMO_LcdWriteData, .writeMemory = DEMO_LcdWriteMemory, .readMemory = NULL, /* Don't need read in this project. */ .setMemoryDoneCallback = NULL, /* This used for upper layer to register callback. If the writeMemory is a non-blocking(or async) function, when write finished, the registered callback function will be called. In this project, to be simple, DEMO_LcdWriteMemory blocks to wait the write done, it is not async implementation, so don't need to set callback. */ }; static ssd1963_handle_t lcdHandle; static flexio_mculcd_smartdma_handle_t s_flexioLcdHandle; static demo_pixel_t s_lcdBuffer[DEMO_BUFFER_HEIGHT][DEMO_BUFFER_WIDTH]; static volatile bool s_transferDone = false; void FLEXIO_TransferCallback(FLEXIO_MCULCD_Type *,flexio_mculcd_smartdma_handle_t *,status_t ,void *) { s_transferDone = true; } void BOARD_SetResetPin(bool set) { GPIO_PinWrite(DEMO_SSD1963_RST_GPIO, DEMO_SSD1963_RST_PIN, (uint8_t)set); } void BOARD_InitSmartDMA(void) { RESET_ClearPeripheralReset(kMUX_RST_SHIFT_RSTn); INPUTMUX_Init(INPUTMUX0); INPUTMUX_AttachSignal(INPUTMUX0, 0, kINPUTMUX_FlexioToSmartDma); /* Turnoff clock to inputmux to save power. Clock is only needed to make changes */ INPUTMUX_Deinit(INPUTMUX0); SMARTDMA_InitWithoutFirmware(); NVIC_EnableIRQ(SMARTDMA_IRQn); NVIC_SetPriority(SMARTDMA_IRQn, 3); } static status_t DEMO_LcdWriteCommand(void *dbiXferHandle, uint32_t command) { /* dbiXferHandle is actually s_flexioLcdHandle, set by SSD1963_Init 4th parameter. */ flexio_mculcd_smartdma_handle_t *flexioLcdHandle = (flexio_mculcd_smartdma_handle_t *)dbiXferHandle; /* Here use blocking way to send command, because command is short. */ FLEXIO_MCULCD_Type *flexioLCD = flexioLcdHandle->base; /* flexioLcdDev */ FLEXIO_MCULCD_StartTransfer(flexioLCD); FLEXIO_MCULCD_WriteCommandBlocking(flexioLCD, command); FLEXIO_MCULCD_StopTransfer(flexioLCD); return kStatus_Success; } static status_t DEMO_LcdWriteData(void *dbiXferHandle, void *data, uint32_t len_byte) { /* dbiXferHandle is actually s_flexioLcdHandle, set by SSD1963_Init 4th parameter. */ flexio_mculcd_smartdma_handle_t *flexioLcdHandle = (flexio_mculcd_smartdma_handle_t *)dbiXferHandle; /* * Here use blocking way to write data, this function is generally * used to send command parameter, the data length is short. */ FLEXIO_MCULCD_Type *flexioLCD = flexioLcdHandle->base; /* flexioLcdDev */ FLEXIO_MCULCD_StartTransfer(flexioLCD); FLEXIO_MCULCD_WriteDataArrayBlocking(flexioLCD, data, len_byte); FLEXIO_MCULCD_StopTransfer(flexioLCD); return kStatus_Success; } static status_t DEMO_LcdWriteMemory(void *dbiXferHandle, uint32_t command, const void *data, uint32_t len_byte) { status_t status; /* dbiXferHandle is actually s_flexioLcdHandle, set by SSD1963_Init 4th parameter. */ flexio_mculcd_smartdma_handle_t *flexioLcdHandle = (flexio_mculcd_smartdma_handle_t *)dbiXferHandle; FLEXIO_MCULCD_Type *flexioLCD = flexioLcdHandle->base; /* flexioLcdDev */ flexio_mculcd_transfer_t xfer = { .command = command, .mode = kFLEXIO_MCULCD_WriteArray, .dataAddrOrSameValue = (uint32_t)data, .dataSize = len_byte, }; s_transferDone = false; status = FLEXIO_MCULCD_TransferSMARTDMA(flexioLCD, flexioLcdHandle, &xfer); if (kStatus_Success != status) { PRINTF("Write Memory Failed\r\n"); while (1) { } } else { /* Wait for transfer done. */ while (!s_transferDone) { } } return status; } static void DEMO_InitFlexioMcuLcd(void) { status_t status; flexio_mculcd_config_t flexioMcuLcdConfig; flexio_mculcd_smartdma_config_t flexioEzhConfig = { .inputPixelFormat = kFLEXIO_MCULCD_RGB565, .outputPixelFormat = kFLEXIO_MCULCD_RGB565, }; /* Initialize the flexio MCU LCD. */ /* * flexioMcuLcdConfig.enable = true; * flexioMcuLcdConfig.enableInDoze = false; * flexioMcuLcdConfig.enableInDebug = true; * flexioMcuLcdConfig.enableFastAccess = true; * flexioMcuLcdConfig.baudRate_Bps = 96000000U; */ // FLEXIO_MCULCD_GetDefaultConfig(&flexioMcuLcdConfig); // flexioMcuLcdConfig.baudRate_Bps = DEMO_FLEXIO_BAUDRATE_BPS; // status = FLEXIO_MCULCD_Init(&flexioLcdDev, &flexioMcuLcdConfig, DEMO_FLEXIO_CLOCK_FREQ); // if (kStatus_Success != status) // { // PRINTF("FlexIO MCULCD init failed\r\n"); // while (1) // ; // } /* Init SMARTDMA. */ // BOARD_InitSmartDMA(); // /* Create FLEXIO_MCULCD SMARTDMA handle. */ // status = FLEXIO_MCULCD_TransferCreateHandleSMARTDMA(&flexioLcdDev, &s_flexioLcdHandle, &flexioEzhConfig, // DEMO_FLEXIO_TransferCallback, NULL); // status = FLEXIO_MCULCD_TransferCreateHandleSMARTDMA(&FLEXIO0_peripheralConfig, &ss_flexioLcdHandle, &FLEXIO0_smartdma_config, // FLEXIO_TransferCallback, NULL); // if (kStatus_Success != status) // { // PRINTF("FlexIO MCULCD handle creation failed\r\n"); // while (1) // ; // } } static void DEMO_InitPanel(void) { status_t status; const ssd1963_config_t ssd1963Config = { .pclkFreq_Hz = DEMO_SSD1963_PCLK_FREQ, #if SSD1963_DATA_WITDH == 16 .pixelInterface = kSSD1963_PixelInterface16Bit565, #else .pixelInterface = kSSD1963_PixelInterface8BitBGR888, #endif .panelDataWidth = kSSD1963_PanelData18Bit, .polarityFlags = DEMO_SSD1963_POLARITY_FLAG, .panelWidth = DEMO_PANEL_WIDTH, .panelHeight = DEMO_PANEL_HEIGHT, .hsw = DEMO_SSD1963_HSW, .hfp = DEMO_SSD1963_HFP, .hbp = DEMO_SSD1963_HBP, .vsw = DEMO_SSD1963_VSW, .vfp = DEMO_SSD1963_VFP, .vbp = DEMO_SSD1963_VBP }; /* Reset the SSD1963 LCD controller. */ BOARD_SetResetPin(false); SDK_DelayAtLeastUs(1, SystemCoreClock); /* Delay 10ns. */ BOARD_SetResetPin(true); SDK_DelayAtLeastUs(5000, SystemCoreClock); /* Delay 5ms. */ status = SSD1963_Init(&lcdHandle, &ssd1963Config, &s_flexioDbiOps, &ss_flexioLcdHandle, DEMO_SSD1963_XTAL_FREQ); if (kStatus_Success != status) { PRINTF("Panel initialization failed\r\n"); while (1) { } } } void DEMO_StartPanel(void) { SSD1963_StartDisplay(&lcdHandle); SSD1963_SetBackLight(&lcdHandle, 255); } /* * Draw one window with pixel array, and delay some time after draw done. */ void DEMO_DrawWindow(uint16_t startX, uint16_t startY, uint16_t endX, uint16_t endY, const uint8_t *data, uint32_t dataLen, uint32_t delayMsAfterDraw) { SSD1963_SelectArea(&lcdHandle, startX, startY, endX, endY); SSD1963_WriteMemory(&lcdHandle, data, dataLen); if (delayMsAfterDraw > 0) { SDK_DelayAtLeastUs(delayMsAfterDraw * 1000, SystemCoreClock); } } /* * Draw multiple windows with specified color, can delay some time each window draw finished. * In this example, the whole screen is devided in to 4 windows, this function fills the * windows one by one. */ void DEMO_DrawMultiWindows(demo_pixel_t color, uint32_t intervalMs) { /* Fill buffer with pixel. */ for (uint32_t y = 0; y < DEMO_BUFFER_HEIGHT; y++) { for (uint32_t x = 0; x < DEMO_BUFFER_WIDTH; x++) { s_lcdBuffer[y][x] = color; } } /* Region 0. */ DEMO_DrawWindow(0, 0, DEMO_BUFFER_WIDTH - 1, DEMO_BUFFER_HEIGHT - 1, (const uint8_t *)s_lcdBuffer, sizeof(s_lcdBuffer), intervalMs); /* Region 1. */ DEMO_DrawWindow(DEMO_BUFFER_WIDTH, 0, 2 * DEMO_BUFFER_WIDTH - 1, DEMO_BUFFER_HEIGHT - 1, (const uint8_t *)s_lcdBuffer, sizeof(s_lcdBuffer), intervalMs); /* Region 2. */ DEMO_DrawWindow(0, DEMO_BUFFER_HEIGHT, DEMO_BUFFER_WIDTH - 1, 2 * DEMO_BUFFER_HEIGHT - 1, (const uint8_t *)s_lcdBuffer, sizeof(s_lcdBuffer), intervalMs); /* Region 3. */ DEMO_DrawWindow(DEMO_BUFFER_WIDTH, DEMO_BUFFER_HEIGHT, 2 * DEMO_BUFFER_WIDTH - 1, 2 * DEMO_BUFFER_HEIGHT - 1, (const uint8_t *)s_lcdBuffer, sizeof(s_lcdBuffer), intervalMs); } void init_mculcd(void) { BOARD_InitBootPeripherals(); BOARD_InitSmartDMA(); DEMO_InitPanel(); DEMO_DrawMultiWindows(DEMO_COLOR_BLACK, 0); DEMO_StartPanel(); }   3.2、mculcd.h #ifndef __MCULCD_H #define __MCULCD_H #define DEMO_PANEL_WIDTH 640U #define DEMO_PANEL_HEIGHT 480U /* Macros for the LCD controller. */ #define DEMO_SSD1963_XTAL_FREQ 10000000U #define DEMO_SSD1963_PCLK_FREQ 25000000U #define DEMO_SSD1963_HSW 1U #define DEMO_SSD1963_HFP 116U #define DEMO_SSD1963_HBP 44U #define DEMO_SSD1963_VSW 1U #define DEMO_SSD1963_VFP 10U #define DEMO_SSD1963_VBP 34U #define DEMO_SSD1963_POLARITY_FLAG 0U #define DEMO_SSD1963_RST_GPIO GPIO4 #define DEMO_SSD1963_RST_PIN 7 #define DEMO_SSD1963_CS_GPIO GPIO0 #define DEMO_SSD1963_CS_PIN 12 #define DEMO_SSD1963_RS_GPIO GPIO0 #define DEMO_SSD1963_RS_PIN 7 #define DEMO_FLEXIO FLEXIO0 #define DEMO_FLEXIO_CLOCK_FREQ CLOCK_GetFlexioClkFreq() #define DEMO_FLEXIO_BAUDRATE_BPS 160000000U /* 16-bit data bus, baud rate on each pin is 1MHz. */ /* Macros for FlexIO shifter, timer, and pins. */ #define DEMO_FLEXIO_WR_PIN 1 #define DEMO_FLEXIO_RD_PIN 0 #define DEMO_FLEXIO_DATA_PIN_START 16 #define DEMO_FLEXIO_TX_START_SHIFTER 0 #define DEMO_FLEXIO_RX_START_SHIFTER 0 #define DEMO_FLEXIO_TX_END_SHIFTER 7 #define DEMO_FLEXIO_RX_END_SHIFTER 7 #define DEMO_FLEXIO_TIMER 0 /* Macros for DMA */ #define DEMO_EDMA DMA0 #define DEMO_FLEXIO_TX_DMA_CHANNEL 0 #define DEMO_FLEXIO_TX_DMA_REQUEST kDma0RequestMuxFlexIO0ShiftRegister0Request /* Buffer of the LCD send data. */ #define DEMO_BUFFER_WIDTH (DEMO_PANEL_WIDTH / 2U) #define DEMO_BUFFER_HEIGHT (DEMO_PANEL_HEIGHT / 2U) /* Color for RGB565 */ typedef uint16_t demo_pixel_t; #define DEMO_COLOR_RED 0xF800U #define DEMO_COLOR_GREEN 0x07E0U #define DEMO_COLOR_BLUE 0x001FU #define DEMO_COLOR_WHITE 0xFFFFU #define DEMO_COLOR_BLACK 0x0000U void init_mculcd(void); void DEMO_DrawWindow(uint16_t startX, uint16_t startY, uint16_t endX, uint16_t endY, const uint8_t *data, uint32_t dataLen, uint32_t delayMsAfterDraw); void DEMO_DrawMultiWindows(demo_pixel_t color, uint32_t intervalMs); #endif   3.3、main.c #include "main.h" int main(void) { uint8_t i; uint8_t colorIdx = 0; const demo_pixel_t colorTable[] = { DEMO_COLOR_RED, DEMO_COLOR_GREEN, DEMO_COLOR_BLUE, DEMO_COLOR_WHITE, }; CLOCK_EnableClock(kCLOCK_Gpio0); BOARD_InitDEBUG_UARTPins(); BOARD_PowerMode_OD(); BOARD_InitBootPins(); BOARD_InitBootClocks(); BOARD_InitDebugConsole(); SysTick_Init(); init_led(); init_key(); init_mculcd(); while (1) { DEMO_DrawMultiWindows(colorTable[colorIdx], 500); colorIdx++; if (colorIdx >= ARRAY_SIZE(colorTable)) { colorIdx = 0U; } led_red_tog(); } }   3.4、 源代码   四、运行结果   下载程序到开发板,显示屏显示如下 [localvideo]a77d775d9e1c35768f1e854c5d121424[/localvideo]      

  • 回复了主题帖: 【FRDM-MCXN947】LCD160160显示屏测试

    电子烂人 发表于 2024-12-22 17:09 屏幕是自己焊接的吗 是的,自己做的板子。

  • 发表了主题帖: 【FRDM-MCXN947】LCD160160显示屏测试

    本帖最后由 TL-LED 于 2024-12-22 14:36 编辑 测试并口方式驱动LCD160160显示屏。   一、电路图部分 使用FlexIO LCD接口的引脚,模拟并口方式。   二、配置端口   配置显示屏有关的引脚   三、显示屏接口时序图     四、程序部分   4.1、UC1698Driver.c /** * @File UC1698Driver.c * @author guoweilkd * @version V1.1.0 * @date 2018/05/09 * @brief Lcd驱动 * 本文件Lcd为UC1698 */ #include "main.h" const uint8_t DataToBit2[] = {0x00,0x0f,0xf0,0xff}; void lcd_delay(uint16_t dl) { uint16_t dd; for(dd=0;dd<dl;dd++) { __NOP(); } } /** *@brief 引脚初始化 *@param None *@retval None */ static void LcdGpioConfig(void) { init_tm160160_pins(); //LCD_BLA_ON(); LCD_CS_HIGH(); } /** *@brief 写命令 *@param cmd 命令 *@retval None */ void WriteLcdCommand(uint8_t cmd) { LCD_RS_LOW(); LCD_RD_HIGH(); LCD_DATABUS(cmd); lcd_delay(10); LCD_WR_LOW(); lcd_delay(1); LCD_WR_HIGH(); } /** *@brief 写数据 *@param data 数据 *@retval None */ void WriteLcdData(uint8_t data) { LCD_RS_HIGH(); LCD_RD_HIGH(); LCD_DATATOBIT((data&0x03)); lcd_delay(10); LCD_WR_LOW(); lcd_delay(5); LCD_WR_HIGH(); } /** *@brief 设置起始行 *@param row 行 *@retval None */ void SetLcdRow(uint8_t row) { WriteLcdCommand(CMD_ROWADDRH | ((row & 0xF0) >> 4)); WriteLcdCommand(CMD_ROWADDRL | (row & 0x0F)); } /** *@brief 设置起始列 *@param col 列地址 *@retval None */ void SetLcdCol(uint8_t col) { WriteLcdCommand(CMD_COLADDRH | ((col & 0x70) >> 4)); WriteLcdCommand(CMD_COLADDRL | (col & 0x0F)); } /** *@brief 开显示 *@param None *@retval None */ void Uc1698OpenLcdDisplay(void) { LCD_CS_LOW(); WriteLcdCommand(OPEN_LCDDISPLAY); LCD_CS_HIGH(); //LCD_BLA_ON(); } /** *@brief UC1698U横向写8个点的子函数 *@param Data:要显示的数据 *@retval None */ void Write8DotsUC1698U(uint8_t Data) { LCD_DATATOBIT((Data >> 6)); lcd_delay(10); LCD_WR_LOW(); lcd_delay(5); LCD_WR_HIGH(); LCD_DATATOBIT(((Data >> 4)&0x03)); lcd_delay(10); LCD_WR_LOW(); lcd_delay(5); LCD_WR_HIGH(); LCD_DATATOBIT(((Data >> 2)&0x03)); lcd_delay(10); LCD_WR_LOW(); lcd_delay(5); LCD_WR_HIGH(); LCD_DATATOBIT((Data & 0x03)); lcd_delay(10); LCD_WR_LOW(); lcd_delay(5); LCD_WR_HIGH(); } /** *@brief 关显示 *@param None *@retval None */ void Uc1698CloseLcdDisplay(void) { LCD_CS_LOW(); WriteLcdCommand(CLOSE_LCDDISPLAY); LCD_CS_HIGH(); } /** *@brief LCD初始化 *@param None *@retval None */ void LcdInit(void) { LcdGpioConfig(); LCD_CS_LOW(); LCD_RES_LOW(); SysTick_Delay_ms(100); LCD_RES_HIGH(); SysTick_Delay_ms(100); WriteLcdCommand(0xE8|(BR&0X03));//设置偏压比1/10 WriteLcdCommand(0x28|(PC1&0X03));//内部电源DC/DC WriteLcdCommand(0x24|(TC&0x03));//温度补偿 WriteLcdCommand(0x81);//设置电位命令 WriteLcdCommand(PM ); //值 WriteLcdCommand(0xc0|(LC_210&0X07) ); WriteLcdCommand(0xa0|(LC_43 &0X03) ); WriteLcdCommand(0xd0|(LC_5 &0X01) ); WriteLcdCommand(0xd4|(LC_76 &0X03) ); WriteLcdCommand(0x84|(LC_8 &0X01) ); WriteLcdCommand(0xc8); //设置N-line WriteLcdCommand( NIV); WriteLcdCommand(0xd8|(CSF&0X07) ); WriteLcdCommand(0xf4); WriteLcdCommand(WPC0); WriteLcdCommand(0xf6); WriteLcdCommand(WPC1); WriteLcdCommand(0xf5); WriteLcdCommand(WPP0); WriteLcdCommand(0xf7); WriteLcdCommand(WPP1); WriteLcdCommand(0xf8|((AC>>3)&0x01)); WriteLcdCommand(0x88| (0x07&AC)); WriteLcdCommand(0xf1); WriteLcdCommand(CEN); WriteLcdCommand(OPEN_LCDDISPLAY);/* 开显示 */ SysTick_Delay_ms(20); LCD_CS_HIGH(); } /* END */   4.2、main.c #include "main.h" extern void defaultFontInit(void); int main(void) { uint8_t i; lkdColour color; CLOCK_EnableClock(kCLOCK_Gpio0); BOARD_InitDEBUG_UARTPins(); BOARD_PowerMode_OD(); BOARD_InitBootClocks(); BOARD_InitDebugConsole(); SysTick_Init(); init_led(); init_key(); LcdInit(); defaultFontInit(); GuiUpdateDisplayAll(); color = GuiGetForecolor(); GuiRowText(0, 2,160, FONT_MID,"AI FRDM-MCXN947 Board"); GuiHPointLine(0, 15, 160, 2, color); GuiRowText(0, 60,160, FONT_MID,"https://bbs.eeworld.com.cn"); GuiRowText(0, 80,160, FONT_MID,"https://www.nxp.com.cn"); GuiRowText(0, 100,160, FONT_MID,"ID:TLLED"); GuiUpdateDisplayAll(); while (1) { SysTick_Delay_ms(500); led_red_tog(); GuiRowText(0, 2,160, FONT_MID,"TTTTTTTTTTTTTTTTTTTTT"); GuiHPointLine(0, 15, 160, 2, color); GuiRowText(0, 60,160, FONT_MID,"https://bbs.eeworld.com.cn"); GuiRowText(0, 80,160, FONT_MID,"https://www.nxp.com.cn"); GuiRowText(0, 100,160, FONT_MID,"ID:TLLED"); GuiUpdateDisplayAll(); SysTick_Delay_ms(500); GuiRowText(0, 2,160, FONT_MID,"AI FRDM-MCXN947 Board"); GuiHPointLine(0, 15, 160, 2, color); GuiRowText(0, 60,160, FONT_MID,"https://bbs.eeworld.com.cn"); GuiRowText(0, 80,160, FONT_MID,"https://www.nxp.com.cn"); GuiRowText(0, 100,160, FONT_MID,"ID:TLLED"); GuiUpdateDisplayAll(); } }   4.3、程序源码   五、程序运行   下载程序后,显示屏显示如下 [localvideo]2f00763ff0cd199f46cbe8f30c22f7c2[/localvideo]      

  • 2024-12-18
  • 发表了主题帖: 【FRDM-MCXN947】spi flash存储器读写测试

    本帖最后由 TL-LED 于 2024-12-18 16:36 编辑 spi flash存储器读写测试。   一、硬件连接   1.1、使用开发板的SPI相关的引脚     1.2、外部FLASH存储器电路图部分   二、配置SPI端口   2.1、配置FC1_SPI端口   2.2、SS端口配置 SS端口和LED_GREEN端口共用引脚   三、程序部分   3.1、spi_flash.c /** ************************************************************************** * [url=home.php?mod=space&uid=1307177]@File[/url] spi_flash.c * [url=home.php?mod=space&uid=159083]@brief[/url] spi_flash source code ************************************************************************** * Copyright notice & Disclaimer * * The software Board Support Package (BSP) that is made available to * download from Artery official website is the copyrighted work of Artery. * Artery authorizes customers to use, copy, and distribute the BSP * software and its related documentation for the purpose of design and * development in conjunction with Artery microcontrollers. Use of the * software is governed by this copyright notice and the following disclaimer. * * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES, * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS, * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS, * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. * ************************************************************************** */ #include "spiflash/spi_flash.h" uint8_t spiflash_sector_buf[SPIF_SECTOR_SIZE]; void init_spi(void) { uint32_t srcClock_Hz; lpspi_master_config_t masterConfig; edma_config_t userConfig = {0}; /* attach FRO 12M to FLEXCOMM1 */ CLOCK_SetClkDiv(kCLOCK_DivFlexcom1Clk, 1u); CLOCK_AttachClk(kFRO12M_to_FLEXCOMM1); init_spi1_pins(); /*Master config*/ LPSPI_MasterGetDefaultConfig(&masterConfig); masterConfig.baudRate = TRANSFER_BAUDRATE; masterConfig.whichPcs = EXAMPLE_LPSPI_MASTER_PCS_FOR_INIT; masterConfig.pcsToSckDelayInNanoSec = 1000000000U / (masterConfig.baudRate * 2U); masterConfig.lastSckToPcsDelayInNanoSec = 1000000000U / (masterConfig.baudRate * 2U); masterConfig.betweenTransferDelayInNanoSec = 1000000000U / (masterConfig.baudRate * 2U); srcClock_Hz = LPSPI_MASTER_CLK_FREQ; LPSPI_MasterInit(EXAMPLE_LPSPI_MASTER_BASEADDR, &masterConfig, srcClock_Hz); } uint8_t spi1_writedat(uint8_t dat) { uint8_t srcBuff[2]; uint8_t destBuff[2]; srcBuff[0]=dat; lpspi_transfer_t masterXfer; masterXfer.txData = srcBuff; masterXfer.rxData = destBuff; masterXfer.dataSize = 1; masterXfer.configFlags = EXAMPLE_LPSPI_MASTER_PCS_FOR_TRANSFER | kLPSPI_MasterPcsContinuous | kLPSPI_MasterByteSwap; LPSPI_MasterTransferBlocking(EXAMPLE_LPSPI_MASTER_BASEADDR, &masterXfer); return destBuff[0]; } /** * @brief spi configuration. * @param none * @retval none */ void spiflash_init(void) { init_spi(); } /** * @brief write data to flash * @param pbuffer: the pointer for data buffer * @param write_addr: the address where the data is written * @param length: buffer length * @retval none */ void spiflash_write(uint8_t *pbuffer, uint32_t write_addr, uint32_t length) { uint32_t sector_pos; uint16_t sector_offset; uint16_t sector_remain; uint16_t index; uint8_t *spiflash_buf; spiflash_buf = spiflash_sector_buf; /* sector address */ sector_pos = write_addr / SPIF_SECTOR_SIZE; /* address offset in a sector */ sector_offset = write_addr % SPIF_SECTOR_SIZE; /* the remain in a sector */ sector_remain = SPIF_SECTOR_SIZE - sector_offset; if(length <= sector_remain) { /* smaller than a sector size */ sector_remain = length; } while(1) { /* read a sector */ spiflash_read(spiflash_buf, sector_pos * SPIF_SECTOR_SIZE, SPIF_SECTOR_SIZE); /* validate the read erea */ for(index = 0; index < sector_remain; index++) { if(spiflash_buf[sector_offset + index] != 0xFF) { /* there are some data not equal 0xff, so this secotr needs erased */ break; } } if(index < sector_remain) { /* erase the sector */ spiflash_sector_erase(sector_pos); /* copy the write data */ for(index = 0; index < sector_remain; index++) { spiflash_buf[index + sector_offset] = pbuffer[index]; } spiflash_write_nocheck(spiflash_buf, sector_pos * SPIF_SECTOR_SIZE, SPIF_SECTOR_SIZE); /* program the sector */ } else { /* write directly in the erased area */ spiflash_write_nocheck(pbuffer, write_addr, sector_remain); } if(length == sector_remain) { /* write end */ break; } else { /* go on writing */ sector_pos++; sector_offset = 0; pbuffer += sector_remain; write_addr += sector_remain; length -= sector_remain; if(length > SPIF_SECTOR_SIZE) { /* could not write the remain data in the next sector */ sector_remain = SPIF_SECTOR_SIZE; } else { /* could write the remain data in the next sector */ sector_remain = length; } } } } /** * @brief read data from flash * @param pbuffer: the pointer for data buffer * @param read_addr: the address where the data is read * @param length: buffer length * @retval none */ void spiflash_read(uint8_t *pbuffer, uint32_t read_addr, uint32_t length) { FLASH_CS_LOW(); spi_byte_write(SPIF_READDATA); /* send instruction */ spi_byte_write((uint8_t)((read_addr) >> 16)); /* send 24-bit address */ spi_byte_write((uint8_t)((read_addr) >> 8)); spi_byte_write((uint8_t)read_addr); spi_bytes_read(pbuffer, length); FLASH_CS_HIGH(); } /** * @brief erase a sector data * @param erase_addr: sector address to erase * @retval none */ void spiflash_sector_erase(uint32_t erase_addr) { erase_addr *= SPIF_SECTOR_SIZE; /* translate sector address to byte address */ spiflash_write_enable(); spiflash_wait_busy(); FLASH_CS_LOW(); spi_byte_write(SPIF_SECTORERASE); spi_byte_write((uint8_t)((erase_addr) >> 16)); spi_byte_write((uint8_t)((erase_addr) >> 8)); spi_byte_write((uint8_t)erase_addr); FLASH_CS_HIGH(); spiflash_wait_busy(); } /** * @brief write data without check * @param pbuffer: the pointer for data buffer * @param write_addr: the address where the data is written * @param length: buffer length * @retval none */ void spiflash_write_nocheck(uint8_t *pbuffer, uint32_t write_addr, uint32_t length) { uint16_t page_remain; /* remain bytes in a page */ page_remain = SPIF_PAGE_SIZE - write_addr % SPIF_PAGE_SIZE; if(length <= page_remain) { /* smaller than a page size */ page_remain = length; } while(1) { spiflash_page_write(pbuffer, write_addr, page_remain); if(length == page_remain) { /* all data are programmed */ break; } else { /* length > page_remain */ pbuffer += page_remain; write_addr += page_remain; /* the remain bytes to be prorammed */ length -= page_remain; if(length > SPIF_PAGE_SIZE) { /* can be progrmmed a page at a time */ page_remain = SPIF_PAGE_SIZE; } else { /* smaller than a page size */ page_remain = length; } } } } /** * @brief write a page data * @param pbuffer: the pointer for data buffer * @param write_addr: the address where the data is written * @param length: buffer length * @retval none */ void spiflash_page_write(uint8_t *pbuffer, uint32_t write_addr, uint32_t length) { if((0 < length) && (length <= SPIF_PAGE_SIZE)) { /* set write enable */ spiflash_write_enable(); FLASH_CS_LOW(); /* send instruction */ spi_byte_write(SPIF_PAGEPROGRAM); /* send 24-bit address */ spi_byte_write((uint8_t)((write_addr) >> 16)); spi_byte_write((uint8_t)((write_addr) >> 8)); spi_byte_write((uint8_t)write_addr); spi_bytes_write(pbuffer,length); FLASH_CS_HIGH(); /* wait for program end */ spiflash_wait_busy(); } } /** * @brief write data continuously * @param pbuffer: the pointer for data buffer * @param length: buffer length * @retval none */ void spi_bytes_write(uint8_t *pbuffer, uint32_t length) { volatile uint8_t dummy_data; #if defined(SPI_TRANS_DMA) dma_init_type dma_init_struct; dma_reset(DMA1_CHANNEL2); dma_reset(DMA1_CHANNEL3); dma_flexible_config(DMA1, FLEX_CHANNEL2, DMA_FLEXIBLE_SPI2_RX); dma_flexible_config(DMA1, FLEX_CHANNEL3, DMA_FLEXIBLE_SPI2_TX); dma_default_para_init(&dma_init_struct); dma_init_struct.buffer_size = length; dma_init_struct.direction = DMA_DIR_PERIPHERAL_TO_MEMORY; dma_init_struct.memory_base_addr = (uint32_t)&dummy_data; dma_init_struct.memory_data_width = DMA_MEMORY_DATA_WIDTH_BYTE; dma_init_struct.memory_inc_enable = FALSE; dma_init_struct.peripheral_base_addr = (uint32_t)(&SPI2->dt); dma_init_struct.peripheral_data_width = DMA_PERIPHERAL_DATA_WIDTH_BYTE; dma_init_struct.peripheral_inc_enable = FALSE; dma_init_struct.priority = DMA_PRIORITY_VERY_HIGH; dma_init_struct.loop_mode_enable = FALSE; dma_init(DMA1_CHANNEL2, &dma_init_struct); dma_init_struct.buffer_size = length; dma_init_struct.direction = DMA_DIR_MEMORY_TO_PERIPHERAL; dma_init_struct.memory_base_addr = (uint32_t)pbuffer; dma_init_struct.memory_data_width = DMA_MEMORY_DATA_WIDTH_BYTE; dma_init_struct.memory_inc_enable = TRUE; dma_init_struct.peripheral_base_addr = (uint32_t)(&SPI2->dt); dma_init_struct.peripheral_data_width = DMA_PERIPHERAL_DATA_WIDTH_BYTE; dma_init_struct.peripheral_inc_enable = FALSE; dma_init_struct.priority = DMA_PRIORITY_VERY_HIGH; dma_init_struct.loop_mode_enable = FALSE; dma_init(DMA1_CHANNEL3, &dma_init_struct); spi_i2s_dma_transmitter_enable(SPI2, TRUE); spi_i2s_dma_receiver_enable(SPI2, TRUE); dma_channel_enable(DMA1_CHANNEL2, TRUE); dma_channel_enable(DMA1_CHANNEL3, TRUE); while(dma_flag_get(DMA1_FDT2_FLAG) == RESET); dma_flag_clear(DMA1_FDT2_FLAG); dma_channel_enable(DMA1_CHANNEL2, FALSE); dma_channel_enable(DMA1_CHANNEL3, FALSE); spi_i2s_dma_transmitter_enable(SPI2, FALSE); spi_i2s_dma_receiver_enable(SPI2, FALSE); #else while(length--) { dummy_data = spi1_writedat(*pbuffer); pbuffer++; } #endif } /** * @brief read data continuously * @param pbuffer: buffer to save data * @param length: buffer length * @retval none */ void spi_bytes_read(uint8_t *pbuffer, uint32_t length) { uint8_t write_value = FLASH_SPI_DUMMY_BYTE; #if defined(SPI_TRANS_DMA) dma_init_type dma_init_struct; dma_reset(DMA1_CHANNEL2); dma_reset(DMA1_CHANNEL3); dma_flexible_config(DMA1, FLEX_CHANNEL2, DMA_FLEXIBLE_SPI2_RX); dma_flexible_config(DMA1, FLEX_CHANNEL3, DMA_FLEXIBLE_SPI2_TX); dma_default_para_init(&dma_init_struct); dma_init_struct.buffer_size = length; dma_init_struct.direction = DMA_DIR_MEMORY_TO_PERIPHERAL; dma_init_struct.memory_base_addr = (uint32_t)&write_value; dma_init_struct.memory_data_width = DMA_MEMORY_DATA_WIDTH_BYTE; dma_init_struct.memory_inc_enable = FALSE; dma_init_struct.peripheral_base_addr = (uint32_t)(&SPI2->dt); dma_init_struct.peripheral_data_width = DMA_PERIPHERAL_DATA_WIDTH_BYTE; dma_init_struct.peripheral_inc_enable = FALSE; dma_init_struct.priority = DMA_PRIORITY_VERY_HIGH; dma_init_struct.loop_mode_enable = FALSE; dma_init(DMA1_CHANNEL3, &dma_init_struct); dma_init_struct.buffer_size = length; dma_init_struct.direction = DMA_DIR_PERIPHERAL_TO_MEMORY; dma_init_struct.memory_base_addr = (uint32_t)pbuffer; dma_init_struct.memory_data_width = DMA_MEMORY_DATA_WIDTH_BYTE; dma_init_struct.memory_inc_enable = TRUE; dma_init_struct.peripheral_base_addr = (uint32_t)(&SPI2->dt); dma_init_struct.peripheral_data_width = DMA_PERIPHERAL_DATA_WIDTH_BYTE; dma_init_struct.peripheral_inc_enable = FALSE; dma_init_struct.priority = DMA_PRIORITY_VERY_HIGH; dma_init_struct.loop_mode_enable = FALSE; dma_init(DMA1_CHANNEL2, &dma_init_struct); spi_i2s_dma_transmitter_enable(SPI2, TRUE); spi_i2s_dma_receiver_enable(SPI2, TRUE); dma_channel_enable(DMA1_CHANNEL2, TRUE); dma_channel_enable(DMA1_CHANNEL3, TRUE); while(dma_flag_get(DMA1_FDT2_FLAG) == RESET); dma_flag_clear(DMA1_FDT2_FLAG); dma_channel_enable(DMA1_CHANNEL2, FALSE); dma_channel_enable(DMA1_CHANNEL3, FALSE); spi_i2s_dma_transmitter_enable(SPI2, FALSE); spi_i2s_dma_receiver_enable(SPI2, FALSE); #else while(length--) { *pbuffer = spi1_writedat(write_value); pbuffer++; } #endif } /** * @brief wait program done * @param none * @retval none */ void spiflash_wait_busy(void) { while((spiflash_read_sr1() & 0x01) == 0x01); } /** * @brief read sr1 register * @param none * @retval none */ uint8_t spiflash_read_sr1(void) { uint8_t breadbyte = 0; FLASH_CS_LOW(); spi_byte_write(SPIF_READSTATUSREG1); breadbyte = (uint8_t)spi_byte_read(); FLASH_CS_HIGH(); return (breadbyte); } /** * @brief enable write operation * @param none * @retval none */ void spiflash_write_enable(void) { FLASH_CS_LOW(); spi_byte_write(SPIF_WRITEENABLE); FLASH_CS_HIGH(); } /** * @brief read device id * @param none * @retval device id */ uint16_t spiflash_read_id(void) { uint16_t wreceivedata = 0; FLASH_CS_LOW(); spi_byte_write(SPIF_MANUFACTDEVICEID); spi_byte_write(0x00); spi_byte_write(0x00); spi_byte_write(0x00); wreceivedata |= spi_byte_read() << 8; wreceivedata |= spi_byte_read(); FLASH_CS_HIGH(); return wreceivedata; } /** * @brief write a byte to flash * @param data: data to write * @retval flash return data */ uint8_t spi_byte_write(uint8_t data) { uint8_t brxbuff; brxbuff = spi1_writedat(data); return brxbuff; } /** * @brief read a byte to flash * @param none * @retval flash return data */ uint8_t spi_byte_read(void) { return (spi_byte_write(FLASH_SPI_DUMMY_BYTE)); } /** * @} */ /** * @} */   3.2、spi_flash.h /** ************************************************************************** * @file spi_flash.h * @brief header file of spi_flash ************************************************************************** * Copyright notice & Disclaimer * * The software Board Support Package (BSP) that is made available to * download from Artery official website is the copyrighted work of Artery. * Artery authorizes customers to use, copy, and distribute the BSP * software and its related documentation for the purpose of design and * development in conjunction with Artery microcontrollers. Use of the * software is governed by this copyright notice and the following disclaimer. * * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES, * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS, * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS, * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. * ************************************************************************** */ #ifndef __SPI_FLASH_H #define __SPI_FLASH_H #include "main.h" /** @addtogroup AT32L021_periph_examples * @{ */ /** @addtogroup 021_SPI_w25q_flash * @{ */ /* use dma transfer spi data */ //#define SPI_TRANS_DMA /** @defgroup SPI_flash_cs_pin_definition * @{ */ #define FLASH_CS_HIGH() GPIO_PortSet(LED_GREEN_GPIO, 1u << LED_GREEN_GPIO_PIN) #define FLASH_CS_LOW() GPIO_PortClear(LED_GREEN_GPIO, 1u << LED_GREEN_GPIO_PIN) /** * @} */ /** @defgroup SPI_flash_id_definition * @{ */ /* * flash define */ #define W25Q80 0xEF13 #define W25Q16 0xEF14 #define W25Q32 0xEF15 #define W25Q64 0xEF16 /* 16mb, the range of address:0~0xFFFFFF */ #define W25Q128 0xEF17 /** * @} */ /** @defgroup SPI_flash_operation_definition * @{ */ #define SPIF_CHIP_SIZE 0x1000000 #define SPIF_SECTOR_SIZE 4096 #define SPIF_PAGE_SIZE 256 #define SPIF_WRITEENABLE 0x06 #define SPIF_WRITEDISABLE 0x04 /* s7-s0 */ #define SPIF_READSTATUSREG1 0x05 #define SPIF_WRITESTATUSREG1 0x01 /* s15-s8 */ #define SPIF_READSTATUSREG2 0x35 #define SPIF_WRITESTATUSREG2 0x31 /* s23-s16 */ #define SPIF_READSTATUSREG3 0x15 #define SPIF_WRITESTATUSREG3 0x11 #define SPIF_READDATA 0x03 #define SPIF_FASTREADDATA 0x0B #define SPIF_FASTREADDUAL 0x3B #define SPIF_PAGEPROGRAM 0x02 /* block size:64kb */ #define SPIF_BLOCKERASE 0xD8 #define SPIF_SECTORERASE 0x20 #define SPIF_CHIPERASE 0xC7 #define SPIF_POWERDOWN 0xB9 #define SPIF_RELEASEPOWERDOWN 0xAB #define SPIF_DEVICEID 0xAB #define SPIF_MANUFACTDEVICEID 0x90 #define SPIF_JEDECDEVICEID 0x9F #define FLASH_SPI_DUMMY_BYTE 0xA5 /** * @} */ /** @defgroup SPI_flash_exported_functions * @{ */ void spiflash_init(void); void spiflash_write(uint8_t *pbuffer, uint32_t write_addr, uint32_t length); void spiflash_read(uint8_t *pbuffer, uint32_t read_addr, uint32_t length); void spiflash_sector_erase(uint32_t erase_addr); void spiflash_write_nocheck(uint8_t *pbuffer, uint32_t write_addr, uint32_t length); void spiflash_page_write(uint8_t *pbuffer, uint32_t write_addr, uint32_t length); void spi_bytes_write(uint8_t *pbuffer, uint32_t length); void spi_bytes_read(uint8_t *pbuffer, uint32_t length); void spiflash_wait_busy(void); uint8_t spiflash_read_sr1(void); void spiflash_write_enable(void); uint16_t spiflash_read_id(void); uint8_t spi_byte_write(uint8_t data); uint8_t spi_byte_read(void); /** * @} */ /** * @} */ /** * @} */ #endif   3.3、fun_task.c #include "main.h" #define FLASH_TEST_ADDR 0x1000 #define SPI_BUF_SIZE 256 uint8_t tx_buffer[SPI_BUF_SIZE]; uint8_t rx_buffer[SPI_BUF_SIZE]; #define START_TASK_PRO 1 #define START_STK_SIZE 128 TaskHandle_t StartTask_Handler; #define TASK1_PRIO 4 #define TASK1_STK_SIZE 128 static TaskHandle_t Task1Task_Handler = NULL; #define TASK2_PRIO 3 #define TASK2_STK_SIZE 128 static TaskHandle_t Task2Task_Handler = NULL; void start_task(void *pvParameters); void gui_task(void *pvParameters); void task1(void *pvParameters); void task2(void *pvParameters); void tx_data_fill(void) { uint32_t data_index = 0; for(data_index = 0; data_index < SPI_BUF_SIZE; data_index++) { tx_buffer[data_index] = 255-data_index; } } void task_create(void) { //start_task xTaskCreate((TaskFunction_t )start_task, (const char* )"start_task", (uint16_t )START_STK_SIZE, (void* )NULL, (UBaseType_t )START_TASK_PRO, (TaskHandle_t* )&StartTask_Handler); vTaskStartScheduler(); } void start_task(void *pvParameters) { taskENTER_CRITICAL(); //task1 xTaskCreate((TaskFunction_t )task1, (const char* )"task1", (uint16_t )TASK1_STK_SIZE, (void* )NULL, (UBaseType_t )TASK1_PRIO, (TaskHandle_t* )&Task1Task_Handler); //task2 xTaskCreate((TaskFunction_t )task2, (const char* )"task2", (uint16_t )TASK2_STK_SIZE, (void* )NULL, (UBaseType_t )TASK2_PRIO, (TaskHandle_t* )&Task2Task_Handler); taskEXIT_CRITICAL(); vTaskDelete(StartTask_Handler); } //task1 void task1(void *pvParameters) { __IO uint32_t index = 0; __IO uint32_t flash_id_index = 0; tx_data_fill(); spiflash_init(); flash_id_index = spiflash_read_id(); if(flash_id_index !=0x5114) { PRINTF("flash id check error!\r\n"); } else { PRINTF("flash id check success! id: %x\r\n", flash_id_index); } spiflash_sector_erase(FLASH_TEST_ADDR / SPIF_SECTOR_SIZE); spiflash_write(tx_buffer, FLASH_TEST_ADDR, SPI_BUF_SIZE); spiflash_read(rx_buffer, FLASH_TEST_ADDR, SPI_BUF_SIZE); PRINTF("Read Data: "); for(index = 0; index < SPI_BUF_SIZE; index++) { PRINTF("%x ", rx_buffer[index]); } while (1) { //PRINTF("task1 run ...\r\n"); vTaskDelay(200); } } //task2 void task2(void *pvParameters) { while (1) { //PRINTF("task2 run ...\r\n"); vTaskDelay(100); } }   四、运行结果   下载程序后,串口打印输出内容  

  • 2024-12-15
  • 回复了主题帖: 【FRDM-MCXN947】硬件SPI方式驱动LCD12864

    秦天qintian0303 发表于 2024-12-15 00:01 这是定制款的屏幕还还是通用接口的屏幕? 买的LCD屏幕设计的底板和转接板

  • 2024-12-14
  • 发表了主题帖: 【FRDM-MCXN947】硬件SPI方式驱动LCD12864

    测试使用硬件方式驱动LCD12864。 在上篇帖子https://bbs.eeworld.com.cn/thread-1301831-1-1.html的基础上,将SPI方式有模拟方式改为硬件SPI方式   一、配置接口   显示屏只有写,没有读接口,用到了SPI的MOSI和SCK引脚。下图是配置为硬件SPI   配置FC6_FLEXCOMM时钟 SPI配置为12MHz   二、程序部分   spi初始化。 void lcd_init_spi(void) { uint32_t srcClock_Hz; lpspi_master_config_t masterConfig; lpspi_transfer_t masterXfer; init_lcd_jlx12864g_pins(); /* attach FRO 12M to FLEXCOMM6 */ // CLOCK_SetClkDiv(kCLOCK_DivFlexcom6Clk, 1u); // CLOCK_AttachClk(kFRO12M_to_FLEXCOMM6); // /*Master config*/ LPSPI_MasterGetDefaultConfig(&masterConfig); masterConfig.baudRate = TRANSFER_BAUDRATE; masterConfig.whichPcs = EXAMPLE_LPSPI_MASTER_PCS_FOR_INIT; masterConfig.pcsToSckDelayInNanoSec = 1000000000U / (masterConfig.baudRate * 2U); masterConfig.lastSckToPcsDelayInNanoSec = 1000000000U / (masterConfig.baudRate * 2U); masterConfig.betweenTransferDelayInNanoSec = 1000000000U / (masterConfig.baudRate * 2U); srcClock_Hz = LPSPI_MASTER_CLK_FREQ; LPSPI_MasterInit(EXAMPLE_LPSPI_MASTER_BASEADDR, &masterConfig, srcClock_Hz); } void fc6_spi_writebyte(uint8_t byte) { uint8_t srcBuff[2]; uint8_t destBuff[2]; srcBuff[0]=byte; lpspi_transfer_t masterXfer; /*Start master transfer*/ masterXfer.txData = srcBuff; masterXfer.rxData = destBuff; masterXfer.dataSize = 1; masterXfer.configFlags = EXAMPLE_LPSPI_MASTER_PCS_FOR_TRANSFER | kLPSPI_MasterPcsContinuous | kLPSPI_MasterByteSwap; LPSPI_MasterTransferBlocking(EXAMPLE_LPSPI_MASTER_BASEADDR, &masterXfer); } void lcd_jlx12864g_write_cmd(uint8_t cmd) { uint8_t i=0; lcd_jlx12864g_cs_l(); lcd_jlx12864g_rs_l(); fc6_spi_writebyte(cmd); } void lcd_jlx12864g_write_dat(uint8_t dat) { uint8_t i=0; lcd_jlx12864g_cs_l(); lcd_jlx12864g_rs_h(); fc6_spi_writebyte(dat); }   main.c #include "main.h" int main(void) { uint8_t i; CLOCK_EnableClock(kCLOCK_Gpio0); BOARD_InitDEBUG_UARTPins(); BOARD_PowerMode_OD(); BOARD_InitBootClocks(); BOARD_InitDebugConsole(); init_utick(); SysTick_Init(); //init_p3t1755(); init_led(); init_key(); //p3t1755_test(); init_lcd_jlx12864g(); lcd_showString(0,0, (uint8_t*)"MCXN947_BOARD_TEST",6,12); lcd_showString(0,13,(uint8_t*)"JLX12864G-SPI",6,12); lcd_showString(0,26,(uint8_t*)"2024/12/14",6,12); lcd_refreshGram(); while (1) { SysTick_Delay_ms(500); led_red_tog(); //lcd_clear(); lcd_showString(0,39,(uint8_t*)"MCXN947_BOARD [OK]",6,12); lcd_refreshGram(); SysTick_Delay_ms(500); //lcd_clear(); lcd_showString(0,39,(uint8_t*)"TTTTTTTTTTTTT [OK]",6,12); lcd_refreshGram(); } }   三、运行结果   [localvideo]629ce48f9d627ffdb73f046b97fbe02b[/localvideo]          

  • 发表了主题帖: 【FRDM-MCXN947】 模拟SPI方式驱动LCD12864

    使用模式方式测试是LCD12864模块。   一、硬件部分   1.1、测试端口使用MikroBus总线接口   1.2、测试模块使用的JLX12864G     二、端口配置   配置显示显示屏使用的MikroBus总线部分接口     三、程序部分   3.1、jlx12864g.c #include "main.h" #include "lcd/jlx12864g_font.h" volatile static uint8_t lcdGram[128][8]; void lcd_jlx12864g_write_cmd(uint8_t cmd) { uint8_t i=0; lcd_jlx12864g_cs_l(); lcd_jlx12864g_rs_l(); for(i=0;i<8;i++) { lcd_jlx12864g_clk_l(); if(cmd&0x80) { lcd_jlx12864g_sda_h(); } else { lcd_jlx12864g_sda_l(); } lcd_jlx12864g_clk_h(); cmd = cmd<<1; } } void lcd_jlx12864g_write_dat(uint8_t dat) { uint8_t i=0; lcd_jlx12864g_cs_l(); lcd_jlx12864g_rs_h(); for(i=0;i<8;i++) { lcd_jlx12864g_clk_l(); if(dat&0x80) { lcd_jlx12864g_sda_h(); } else { lcd_jlx12864g_sda_l(); } lcd_jlx12864g_clk_h(); dat = dat<<1; } } void lcd_refreshGram(void) { uint8_t i,n; for(i=0;i<8;i++) { lcd_jlx12864g_write_cmd (0xb0+i); //write page lcd_jlx12864g_write_cmd (0x00); lcd_jlx12864g_write_cmd (0x10); for(n=0;n<128;n++) lcd_jlx12864g_write_dat(lcdGram[n][i]); } } void lcd_clear(void) { uint8_t i,n; for(i=0;i<8;i++) for(n=0;n<128;n++) lcdGram[n][i]=0X00; lcd_refreshGram(); } void lcd_drawPoint(uint8_t x,uint8_t y,uint8_t t) { uint8_t pos,bx,temp=0; if(x>127||y>63)return; pos=7-y/8; bx=y%8; temp=1<<(7-bx); if(t)lcdGram[x][pos]|=temp; else lcdGram[x][pos]&=~temp; } uint8_t lcd_readPoint(uint8_t x,uint8_t y) { uint8_t pos,bx,temp=0x00; //x = 127-x; y = 63-y; pos=y/8; bx=y%8; temp=1<<bx; if(temp&lcdGram[x][pos]) return 1; return 0; } void lcd_fill(uint8_t x1,uint8_t y1,uint8_t x2,uint8_t y2,uint8_t dot) { uint8_t x,y; for(x=x1;x<=x2;x++) for(y=y1;y<=y2;y++) lcd_drawPoint(x,y,dot); } void lcd_showChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t f_w,uint8_t f_h,uint8_t mode) { uint8_t temp,t,t1; uint8_t y0=y; uint8_t csize=(f_h/8+((f_h%8)?1:0))*f_w; chr=chr-' '; for(t=0;t<csize;t++) { if(f_w==6&&f_h==8)temp=asc2_0608[chr][t]; else if(f_w==6&&f_h==12)temp=asc2_0612[chr][t]; else if(f_w==12&&f_h==24)temp=asc2_1224[chr][t]; else return; for(t1=0;t1<8;t1++) { if(temp&0x80)lcd_drawPoint(x,y,mode); else lcd_drawPoint(x,y,!mode); temp<<=1; y++; if((y-y0)==f_h) { y=y0; x++; break; } } } } uint32_t mypow(uint8_t m,uint8_t n) { uint32_t result=1; while(n--)result*=m; return result; } void lcd_showNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t f_w,uint8_t f_h) { uint8_t t,temp; uint8_t enshow=0; for(t=0;t<len;t++) { temp=(num/mypow(10,len-t-1))%10; if(enshow==0&&t<(len-1)) { if(temp==0) { lcd_showChar(x+(f_w)*t,y,' ',f_w,f_h,1); continue; } else enshow=1; } lcd_showChar(x+(f_w)*t,y,temp+'0',f_w,f_h,1); } } void lcd_showString(uint8_t x,uint8_t y,const uint8_t *p,uint8_t f_w,uint8_t f_h) { while((*p<='~')&&(*p>=' ')) { if(x>(128-(f_w))){x=0;y+=f_h;} if(y>(64-f_h)){y=x=0;lcd_clear();} lcd_showChar(x,y,*p,f_w,f_h,1); x+=f_w; p++; } } void lcd_showPicture(uint8_t x,uint8_t y,const uint8_t *p,uint8_t p_w,uint8_t p_h) { uint8_t temp,i,col,row; uint8_t y0=y; uint8_t width=p_w; if(x+p_w>128)width=128-p_w; uint8_t high=p_h; if(y+p_h>64)high=64-p_h; uint8_t exp_col_bytes=(p_h/8+((p_h%8)?1:0)); uint8_t act_col_bytes=(high/8+((high%8)?1:0)); for(row=0;row<width;row++) { for(col=0;col<act_col_bytes;col++) { temp = p[col+row*exp_col_bytes]; for(i=0;i<8;i++) { if(temp&0x80)lcd_drawPoint(x,y,1); else lcd_drawPoint(x,y,0); temp<<=1; y++; if((y-y0)==high) { y=y0; x++; break; } } } } } void init_lcd_jlx12864g(void) { init_lcd_jlx12864g_pins(); lcd_jlx12864g_cs_l(); lcd_jlx12864g_rst_l(); SysTick_Delay_ms(20); lcd_jlx12864g_rst_h(); SysTick_Delay_ms(20); lcd_jlx12864g_write_cmd(0xe2); lcd_jlx12864g_write_cmd(0x2c); lcd_jlx12864g_write_cmd(0x2e); lcd_jlx12864g_write_cmd(0x2f); lcd_jlx12864g_write_cmd(0x23); lcd_jlx12864g_write_cmd(0x81); lcd_jlx12864g_write_cmd(0x28); lcd_jlx12864g_write_cmd(0xa2); lcd_jlx12864g_write_cmd(0xc0); lcd_jlx12864g_write_cmd(0xa0); lcd_jlx12864g_write_cmd(0x40); lcd_jlx12864g_write_cmd(0xaf); lcd_jlx12864g_cs_h(); lcd_clear(); lcd_jlx12864g_bk_on(); }   3.2、jlx12864g.h #ifndef __12864G_H #define __12864G_H #define LCD_JLX12864G_CS_GPIO INIT_LCD_JLX12864G_PINS_FC6_SPI_CS_GPIO #define LCD_JLX12864G_CS_PIN INIT_LCD_JLX12864G_PINS_FC6_SPI_CS_GPIO_PIN #define LCD_JLX12864G_RST_GPIO INIT_LCD_JLX12864G_PINS_FC6_SPI_MISO_GPIO #define LCD_JLX12864G_RST_PIN INIT_LCD_JLX12864G_PINS_FC6_SPI_MISO_GPIO_PIN #define LCD_JLX12864G_RS_GPIO INIT_LCD_JLX12864G_PINS_ME_RESET_GPIO #define LCD_JLX12864G_RS_PIN INIT_LCD_JLX12864G_PINS_ME_RESET_GPIO_PIN #define LCD_JLX12864G_CLK_GPIO INIT_LCD_JLX12864G_PINS_FC6_SPI_CLK_GPIO #define LCD_JLX12864G_CLK_PIN INIT_LCD_JLX12864G_PINS_FC6_SPI_CLK_GPIO_PIN #define LCD_JLX12864G_MOSI_GPIO INIT_LCD_JLX12864G_PINS_FC6_SPI_MOSI_GPIO #define LCD_JLX12864G_MOSI_PIN INIT_LCD_JLX12864G_PINS_FC6_SPI_MOSI_GPIO_PIN #define LCD_JLX12864G_BK_GPIO INIT_LCD_JLX12864G_PINS_ME_INT_GPIO #define LCD_JLX12864G_BK_PIN INIT_LCD_JLX12864G_PINS_ME_INT_GPIO_PIN #define lcd_jlx12864g_cs_l() GPIO_PortClear(LCD_JLX12864G_CS_GPIO, 1u << LCD_JLX12864G_CS_PIN) #define lcd_jlx12864g_cs_h() GPIO_PortSet(LCD_JLX12864G_CS_GPIO, 1u << LCD_JLX12864G_CS_PIN) #define lcd_jlx12864g_rs_l() GPIO_PortClear(LCD_JLX12864G_RS_GPIO, 1u << LCD_JLX12864G_RS_PIN) #define lcd_jlx12864g_rs_h() GPIO_PortSet(LCD_JLX12864G_RS_GPIO, 1u << LCD_JLX12864G_RS_PIN) #define lcd_jlx12864g_rst_l() GPIO_PortClear(LCD_JLX12864G_RST_GPIO, 1u << LCD_JLX12864G_RST_PIN) #define lcd_jlx12864g_rst_h() GPIO_PortSet(LCD_JLX12864G_RST_GPIO, 1u << LCD_JLX12864G_RST_PIN) #define lcd_jlx12864g_clk_l() GPIO_PortClear(LCD_JLX12864G_CLK_GPIO, 1u << LCD_JLX12864G_CLK_PIN) #define lcd_jlx12864g_clk_h() GPIO_PortSet(LCD_JLX12864G_CLK_GPIO, 1u << LCD_JLX12864G_CLK_PIN) #define lcd_jlx12864g_sda_l() GPIO_PortClear(LCD_JLX12864G_MOSI_GPIO, 1u << LCD_JLX12864G_MOSI_PIN) #define lcd_jlx12864g_sda_h() GPIO_PortSet(LCD_JLX12864G_MOSI_GPIO, 1u << LCD_JLX12864G_MOSI_PIN) #define lcd_jlx12864g_bk_off() GPIO_PortClear(LCD_JLX12864G_BK_GPIO, 1u << LCD_JLX12864G_BK_PIN) #define lcd_jlx12864g_bk_on() GPIO_PortSet(LCD_JLX12864G_BK_GPIO, 1u << LCD_JLX12864G_BK_PIN) void lcd_refreshGram(void); void lcd_clear(void) ; void lcd_drawPoint(uint8_t x,uint8_t y,uint8_t t); uint8_t lcd_readPoint(uint8_t x,uint8_t y); void lcd_fill(uint8_t x1,uint8_t y1,uint8_t x2,uint8_t y2,uint8_t dot); void lcd_showChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t f_w,uint8_t f_h,uint8_t mode); uint32_t mypow(uint8_t m,uint8_t n); void lcd_showNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t f_w,uint8_t f_h); void lcd_showString(uint8_t x,uint8_t y,const uint8_t *p,uint8_t f_w,uint8_t f_h); void lcd_showPicture(uint8_t x,uint8_t y,const uint8_t *p,uint8_t p_w,uint8_t p_h); void init_lcd_jlx12864g(void); #endif   3.3、jlx12864g_font.h const uint8_t ascii_table_8x16[95][16]={ 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, //- -(????ASCII ?:0X20 0x00,0x00,0x38,0xFC, 0xFC,0x38,0x00,0x00, 0x00,0x00,0x00,0x0D, 0x0D,0x00,0x00,0x00, //-!- ASCII ?:0X21 0x00,0x0E,0x1E,0x00, 0x00,0x1E,0x0E,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, //-"- 0x20,0xF8,0xF8,0x20, 0xF8,0xF8,0x20,0x00, 0x02,0x0F,0x0F,0x02, 0x0F,0x0F,0x02,0x00, //-#- 0x38,0x7C,0x44,0x47, 0x47,0xCC,0x98,0x00, 0x06,0x0C,0x08,0x38, 0x38,0x0F,0x07,0x00, //-$- 0x30,0x30,0x00,0x80, 0xC0,0x60,0x30,0x00, 0x0C,0x06,0x03,0x01, 0x00,0x0C,0x0C,0x00, //-%- 0x80,0xD8,0x7C,0xE4, 0xBC,0xD8,0x40,0x00, 0x07,0x0F,0x08,0x08, 0x07,0x0F,0x08,0x00, //-&- 0x00,0x10,0x1E,0x0E, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, //-'- 0x00,0x00,0xF0,0xF8, 0x0C,0x04,0x00,0x00, 0x00,0x00,0x03,0x07, 0x0C,0x08,0x00,0x00, //-(- 0x00,0x00,0x04,0x0C, 0xF8,0xF0,0x00,0x00, 0x00,0x00,0x08,0x0C, 0x07,0x03,0x00,0x00, //-)- 0x80,0xA0,0xE0,0xC0, 0xC0,0xE0,0xA0,0x80, 0x00,0x02,0x03,0x01, 0x01,0x03,0x02,0x00, //-*- ASCII ?:0X2A 0x00,0x80,0x80,0xE0, 0xE0,0x80,0x80,0x00, 0x00,0x00,0x00,0x03, 0x03,0x00,0x00,0x00, //-+- 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x10,0x1E, 0x0E,0x00,0x00,0x00, //-,- 0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, //--- 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x0C, 0x0C,0x00,0x00,0x00, //-.- 0x00,0x00,0x00,0x80, 0xC0,0x60,0x30,0x00, 0x0C,0x06,0x03,0x01, 0x00,0x00,0x00,0x00, //-/- 0xF8,0xF8,0x0C,0xC4, 0x0C,0xF8,0xF0,0x00, 0x03,0x07,0x0C,0x08, 0x0C,0x07,0x03,0x00, //-0- ASCII ?:0X30 0x00,0x10,0x18,0xFC, 0xFC,0x00,0x00,0x00, 0x00,0x08,0x08,0x0F, 0x0F,0x08,0x08,0x00, //-1- 0x08,0x0C,0x84,0xC4, 0x64,0x3C,0x18,0x00, 0x0E,0x0F,0x09,0x08, 0x08,0x0C,0x0C,0x00, //-2- 0x08,0x0C,0x44,0x44, 0x44,0xFC,0xB8,0x00, 0x04,0x0C,0x08,0x08, 0x08,0x0F,0x07,0x00, //-3- 0xC0,0xE0,0xB0,0x98, 0xFC,0xFC,0x80,0x00, 0x00,0x00,0x00,0x08, 0x0F,0x0F,0x08,0x00, //-4- ASCII ?:0X34 0x7C,0x7C,0x44,0x44, 0x44,0xC4,0x84,0x00, 0x04,0x0C,0x08,0x08, 0x08,0x0F,0x07,0x00, //-5- 0xF0,0xF8,0x4C,0x44, 0x44,0xC0,0x80,0x00, 0x07,0x0F,0x08,0x08, 0x08,0x0F,0x07,0x00, //-6- 0x0C,0x0C,0x04,0x84, 0xC4,0x7C,0x3C,0x00, 0x00,0x00,0x0F,0x0F, 0x00,0x00,0x00,0x00, //-7- 0xB8,0xFC,0x44,0x44, 0x44,0xFC,0xB8,0x00, 0x07,0x0F,0x08,0x08, 0x08,0x0F,0x07,0x00, //-8- 0x38,0x7C,0x44,0x44, 0x44,0xFC,0xF8,0x00, 0x00,0x08,0x08,0x08, 0x0C,0x07,0x03,0x00, //-9- 0x00,0x00,0x00,0x30, 0x30,0x00,0x00,0x00, 0x00,0x00,0x00,0x06, 0x06,0x00,0x00,0x00, //-:- 0x00,0x00,0x00,0x30, 0x30,0x00,0x00,0x00, 0x00,0x00,0x08,0x0E, 0x06,0x00,0x00,0x00, //-;- 0x00,0x80,0xC0,0x60, 0x30,0x18,0x08,0x00, 0x00,0x00,0x01,0x03, 0x06,0x0C,0x08,0x00, //-<- 0x00,0x20,0x20,0x20, 0x20,0x20,0x20,0x00, 0x00,0x01,0x01,0x01, 0x01,0x01,0x01,0x00, //-=- 0x00,0x08,0x18,0x30, 0x60,0xC0,0x80,0x00, 0x00,0x08,0x0C,0x06, 0x03,0x01,0x00,0x00, //->- ASCII ?:0X3E 0x18,0x1C,0x04,0xC4, 0xE4,0x3C,0x18,0x00, 0x00,0x00,0x00,0x0D, 0x0D,0x00,0x00,0x00, //-?- 0xF0,0xF0,0x08,0xC8, 0xC8,0xF8,0xF0,0x00, 0x07,0x0F,0x08,0x0B, 0x0B,0x0B,0x01,0x00, //-@- 0xE0,0xF0,0x98,0x8C, 0x98,0xF0,0xE0,0x00, 0x0F,0x0F,0x00,0x00, 0x00,0x0F,0x0F,0x00, //-A- ASCII ?:0X41 0x04,0xFC,0xFC,0x44, 0x44,0xFC,0xB8,0x00, 0x08,0x0F,0x0F,0x08, 0x08,0x0F,0x07,0x00, //-B- 0xF0,0xF8,0x0C,0x04, 0x04,0x0C,0x18,0x00, 0x03,0x07,0x0C,0x08, 0x08,0x0C,0x06,0x00, //-C- 0x04,0xFC,0xFC,0x04, 0x0C,0xF8,0xF0,0x00, 0x08,0x0F,0x0F,0x08, 0x0C,0x07,0x03,0x00, //-D- 0x04,0xFC,0xFC,0x44, 0xE4,0x0C,0x1C,0x00, 0x08,0x0F,0x0F,0x08, 0x08,0x0C,0x0E,0x00, //-E- 0x04,0xFC,0xFC,0x44, 0xE4,0x0C,0x1C,0x00, 0x08,0x0F,0x0F,0x08, 0x00,0x00,0x00,0x00, //-F- 0xF0,0xF8,0x0C,0x84, 0x84,0x8C,0x98,0x00, 0x03,0x07,0x0C,0x08, 0x08,0x07,0x0F,0x00, //-G- 0xFC,0xFC,0x40,0x40, 0x40,0xFC,0xFC,0x00, 0x0F,0x0F,0x00,0x00, 0x00,0x0F,0x0F,0x00, //-H- ASCII ?:0X48 0x00,0x00,0x04,0xFC, 0xFC,0x04,0x00,0x00, 0x00,0x00,0x08,0x0F, 0x0F,0x08,0x00,0x00, //-I- 0x00,0x00,0x00,0x04, 0xFC,0xFC,0x04,0x00, 0x07,0x0F,0x08,0x08, 0x0F,0x07,0x00,0x00, //-J- 0x04,0xFC,0xFC,0xC0, 0xE0,0x3C,0x1C,0x00, 0x08,0x0F,0x0F,0x00, 0x01,0x0F,0x0E,0x00, //-K- 0x04,0xFC,0xFC,0x04, 0x00,0x00,0x00,0x00, 0x08,0x0F,0x0F,0x08, 0x08,0x0C,0x0E,0x00, //-L- 0xFC,0xFC,0x38,0x70, 0x38,0xFC,0xFC,0x00, 0x0F,0x0F,0x00,0x00, 0x00,0x0F,0x0F,0x00, //-M- 0xFC,0xFC,0x38,0x70, 0xE0,0xFC,0xFC,0x00, 0x0F,0x0F,0x00,0x00, 0x00,0x0F,0x0F,0x00, //-N- 0xF8,0xFC,0x04,0x04, 0x04,0xFC,0xF8,0x00, 0x07,0x0F,0x08,0x08, 0x08,0x0F,0x07,0x00, //-O- 0x04,0xFC,0xFC,0x44, 0x44,0x7C,0x38,0x00, 0x08,0x0F,0x0F,0x08, 0x00,0x00,0x00,0x00, //-P- 0xF8,0xFC,0x04,0x04, 0x04,0xFC,0xF8,0x00, 0x07,0x0F,0x08,0x0E, 0x3C,0x3F,0x27,0x00, //-Q- 0x04,0xFC,0xFC,0x44, 0xC4,0xFC,0x38,0x00, 0x08,0x0F,0x0F,0x00, 0x00,0x0F,0x0F,0x00, //-R- 0x18,0x3C,0x64,0x44, 0xC4,0x9C,0x18,0x00, 0x06,0x0E,0x08,0x08, 0x08,0x0F,0x07,0x00, //-S- 0x00,0x1C,0x0C,0xFC, 0xFC,0x0C,0x1C,0x00, 0x00,0x00,0x08,0x0F, 0x0F,0x08,0x00,0x00, //-T- 0xFC,0xFC,0x00,0x00, 0x00,0xFC,0xFC,0x00, 0x07,0x0F,0x08,0x08, 0x08,0x0F,0x07,0x00, //-U- 0xFC,0xFC,0x00,0x00, 0x00,0xFC,0xFC,0x00, 0x01,0x03,0x06,0x0C, 0x06,0x03,0x01,0x00, //-V- 0xFC,0xFC,0x00,0x00, 0x00,0xFC,0xFC,0x00, 0x07,0x0F,0x0E,0x03, 0x0E,0x0F,0x07,0x00, //-W- 0x0C,0x3C,0xF0,0xE0, 0xF0,0x3C,0x0C,0x00, 0x0C,0x0F,0x03,0x01, 0x03,0x0F,0x0C,0x00, //-X- 0x00,0x0C,0x7C,0xC0, 0xC0,0x7C,0x3C,0x00, 0x00,0x00,0x08,0x0F, 0x0F,0x08,0x00,0x00, //-Y- 0x1C,0x0C,0x84,0xC4, 0x64,0x3C,0x1C,0x00, 0x0E,0x0F,0x09,0x08, 0x08,0x0C,0x0E,0x00, //-Z- 0x00,0x00,0xFC,0xFC, 0x04,0x04,0x00,0x00, 0x00,0x00,0x0F,0x0F, 0x08,0x08,0x00,0x00, //-[- 0x38,0x70,0xE0,0xC0, 0x80,0x00,0x00,0x00, 0x00,0x00,0x00,0x01, 0x03,0x07,0x0E,0x00, //-\- 0x00,0x00,0x04,0x04, 0xFC,0xFC,0x00,0x00, 0x00,0x00,0x08,0x08, 0x0F,0x0F,0x00,0x00, //-]- 0x08,0x0C,0x06,0x03, 0x06,0x0C,0x08,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, //-^- 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20, //-_- 0x00,0x00,0x03,0x07, 0x04,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, //-`- 0x00,0xA0,0xA0,0xA0, 0xE0,0xC0,0x00,0x00, 0x07,0x0F,0x08,0x08, 0x07,0x0F,0x08,0x00, //-a- ASCII ?:0X61 0x04,0xFC,0xFC,0x20, 0x60,0xC0,0x80,0x00, 0x00,0x0F,0x0F,0x08, 0x08,0x0F,0x07,0x00, //-b- 0xC0,0xE0,0x20,0x20, 0x20,0x60,0x40,0x00, 0x07,0x0F,0x08,0x08, 0x08,0x0C,0x04,0x00, //-c- 0x80,0xC0,0x60,0x24, 0xFC,0xFC,0x00,0x00, 0x07,0x0F,0x08,0x08, 0x07,0x0F,0x08,0x00, //-d- 0xC0,0xE0,0xA0,0xA0, 0xA0,0xE0,0xC0,0x00, 0x07,0x0F,0x08,0x08, 0x08,0x0C,0x04,0x00, //-e- 0x40,0xF8,0xFC,0x44, 0x0C,0x18,0x00,0x00, 0x08,0x0F,0x0F,0x08, 0x00,0x00,0x00,0x00, //-f- 0xC0,0xE0,0x20,0x20, 0xC0,0xE0,0x20,0x00, 0x27,0x6F,0x48,0x48, 0x7F,0x3F,0x00,0x00, //-g- 0x04,0xFC,0xFC,0x40, 0x20,0xE0,0xC0,0x00, 0x08,0x0F,0x0F,0x00, 0x00,0x0F,0x0F,0x00, //-h- 0x00,0x00,0x20,0xEC, 0xEC,0x00,0x00,0x00, 0x00,0x00,0x08,0x0F, 0x0F,0x08,0x00,0x00, //-i- 0x00,0x00,0x00,0x00, 0x20,0xEC,0xEC,0x00, 0x00,0x30,0x70,0x40, 0x40,0x7F,0x3F,0x00, //-j- 0x04,0xFC,0xFC,0x80, 0xC0,0x60,0x20,0x00, 0x08,0x0F,0x0F,0x01, 0x03,0x0E,0x0C,0x00, //-k- 0x00,0x00,0x04,0xFC, 0xFC,0x00,0x00,0x00, 0x00,0x00,0x08,0x0F, 0x0F,0x08,0x00,0x00, //-l- 0xE0,0xE0,0x60,0xC0, 0x60,0xE0,0xC0,0x00, 0x0F,0x0F,0x00,0x07, 0x00,0x0F,0x0F,0x00, //-m- 0x20,0xE0,0xC0,0x20, 0x20,0xE0,0xC0,0x00, 0x00,0x0F,0x0F,0x00, 0x00,0x0F,0x0F,0x00, //-n- 0xC0,0xE0,0x20,0x20, 0x20,0xE0,0xC0,0x00, 0x07,0x0F,0x08,0x08, 0x08,0x0F,0x07,0x00, //-o- 0x20,0xE0,0xC0,0x20, 0x20,0xE0,0xC0,0x00, 0x40,0x7F,0x7F,0x48, 0x08,0x0F,0x07,0x00, //-p- 0xC0,0xE0,0x20,0x20, 0xC0,0xE0,0x20,0x00, 0x07,0x0F,0x08,0x48, 0x7F,0x7F,0x40,0x00, //-q- 0x20,0xE0,0xC0,0x60, 0x20,0xE0,0xC0,0x00, 0x08,0x0F,0x0F,0x08, 0x00,0x00,0x00,0x00, //-r- 0x40,0xE0,0xA0,0x20, 0x20,0x60,0x40,0x00, 0x04,0x0C,0x09,0x09, 0x0B,0x0E,0x04,0x00, //-s- 0x20,0x20,0xF8,0xFC, 0x20,0x20,0x00,0x00, 0x00,0x00,0x07,0x0F, 0x08,0x0C,0x04,0x00, //-t- 0xE0,0xE0,0x00,0x00, 0xE0,0xE0,0x00,0x00, 0x07,0x0F,0x08,0x08, 0x07,0x0F,0x08,0x00, //-u- 0x00,0xE0,0xE0,0x00, 0x00,0xE0,0xE0,0x00, 0x00,0x03,0x07,0x0C, 0x0C,0x07,0x03,0x00, //-v- 0xE0,0xE0,0x00,0x80, 0x00,0xE0,0xE0,0x00, 0x07,0x0F,0x0C,0x07, 0x0C,0x0F,0x07,0x00, //-w- 0x20,0x60,0xC0,0x80, 0xC0,0x60,0x20,0x00, 0x08,0x0C,0x07,0x03, 0x07,0x0C,0x08,0x00, //-x- 0xE0,0xE0,0x00,0x00, 0x00,0xE0,0xE0,0x00, 0x47,0x4F,0x48,0x48, 0x68,0x3F,0x1F,0x00, //-y- 0x60,0x60,0x20,0xA0, 0xE0,0x60,0x20,0x00, 0x0C,0x0E,0x0B,0x09, 0x08,0x0C,0x0C,0x00, //-z- // 0x00,0x40,0x40,0xF8, 0xBC,0x04,0x04,0x00, 0x00,0x00,0x00,0x07, 0x0F,0x08,0x08,0x00, //-{- 0x00,0x00,0x00,0xBC, 0xBC,0x00,0x00,0x00, 0x00,0x00,0x00,0x0F, 0x0F,0x00,0x00,0x00, //-|- 0x00,0x04,0x04,0xBC, 0xF8,0x40,0x40,0x00, 0x00,0x08,0x08,0x0F, 0x07,0x00,0x00,0x00, //-}- 0x08,0x0C,0x04,0x0C, 0x08,0x0C,0x04,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, //-~- ASCII ?:0X7E }; /************************************************************************************************************** //常用ASCII表 //偏移量32 //ASCII字符集: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ //PC2LCD2002取模方式设置:阴码+逐列式+顺向+C51格式 //每个字符所占用的字节数为:(size/8+((size%8)?1:0))*(size/2),其中size:是字库生成时的点阵大小(12/16/24...) ****************************************************************************************************************/ //06*08==宽*高 ASCII字符集点阵 (Terminal Greek8字体) const unsigned char asc2_0608[95][6]={ {0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/ {0x00,0x00,0x60,0xFA,0x60,0x00},/*"!",1*/ {0x00,0xE0,0xC0,0x00,0xE0,0xC0},/*""",2*/ {0x00,0x24,0x7E,0x24,0x7E,0x24},/*"#",3*/ {0x00,0x24,0xD4,0x56,0x48,0x00},/*"$",4*/ {0x00,0xC6,0xC8,0x10,0x26,0xC6},/*"%",5*/ {0x00,0x6C,0x92,0x6A,0x04,0x0A},/*"&",6*/ {0x00,0x00,0xE0,0xC0,0x00,0x00},/*"'",7*/ {0x00,0x00,0x7C,0x82,0x00,0x00},/*"(",8*/ {0x00,0x00,0x82,0x7C,0x00,0x00},/*")",9*/ {0x00,0x10,0x7C,0x38,0x7C,0x10},/*"*",10*/ {0x00,0x10,0x10,0x7C,0x10,0x10},/*"+",11*/ {0x00,0x00,0x07,0x06,0x00,0x00},/*",",12*/ {0x00,0x10,0x10,0x10,0x10,0x10},/*"-",13*/ {0x00,0x00,0x06,0x06,0x00,0x00},/*".",14*/ {0x00,0x04,0x08,0x10,0x20,0x40},/*"/",15*/ {0x00,0x7C,0x8A,0x92,0xA2,0x7C},/*"0",16*/ {0x00,0x00,0x42,0xFE,0x02,0x00},/*"1",17*/ {0x00,0x46,0x8A,0x92,0x92,0x62},/*"2",18*/ {0x00,0x44,0x92,0x92,0x92,0x6C},/*"3",19*/ {0x00,0x18,0x28,0x48,0xFE,0x08},/*"4",20*/ {0x00,0xF4,0x92,0x92,0x92,0x8C},/*"5",21*/ {0x00,0x3C,0x52,0x92,0x92,0x0C},/*"6",22*/ {0x00,0x80,0x8E,0x90,0xA0,0xC0},/*"7",23*/ {0x00,0x6C,0x92,0x92,0x92,0x6C},/*"8",24*/ {0x00,0x60,0x92,0x92,0x94,0x78},/*"9",25*/ {0x00,0x00,0x36,0x36,0x00,0x00},/*":",26*/ {0x00,0x00,0x37,0x36,0x00,0x00},/*";",27*/ {0x00,0x10,0x28,0x44,0x82,0x00},/*"<",28*/ {0x00,0x24,0x24,0x24,0x24,0x24},/*"=",29*/ {0x00,0x00,0x82,0x44,0x28,0x10},/*">",30*/ {0x00,0x40,0x80,0x9A,0x90,0x60},/*"?",31*/ {0x00,0x7C,0x82,0xBA,0xAA,0x78},/*"@",32*/ {0x00,0x7E,0x88,0x88,0x88,0x7E},/*"A",33*/ {0x00,0xFE,0x92,0x92,0x92,0x6C},/*"B",34*/ {0x00,0x7C,0x82,0x82,0x82,0x44},/*"C",35*/ {0x00,0xFE,0x82,0x82,0x82,0x7C},/*"D",36*/ {0x00,0xFE,0x92,0x92,0x92,0x82},/*"E",37*/ {0x00,0xFE,0x90,0x90,0x90,0x80},/*"F",38*/ {0x00,0x7C,0x82,0x92,0x92,0x5E},/*"G",39*/ {0x00,0xFE,0x10,0x10,0x10,0xFE},/*"H",40*/ {0x00,0x00,0x82,0xFE,0x82,0x00},/*"I",41*/ {0x00,0x0C,0x02,0x02,0x02,0xFC},/*"J",42*/ {0x00,0xFE,0x10,0x28,0x44,0x82},/*"K",43*/ {0x00,0xFE,0x02,0x02,0x02,0x02},/*"L",44*/ {0x00,0xFE,0x40,0x20,0x40,0xFE},/*"M",45*/ {0x00,0xFE,0x40,0x20,0x10,0xFE},/*"N",46*/ {0x00,0x7C,0x82,0x82,0x82,0x7C},/*"O",47*/ {0x00,0xFE,0x90,0x90,0x90,0x60},/*"P",48*/ {0x00,0x7C,0x82,0x8A,0x84,0x7A},/*"Q",49*/ {0x00,0xFE,0x90,0x90,0x98,0x66},/*"R",50*/ {0x00,0x64,0x92,0x92,0x92,0x4C},/*"S",51*/ {0x00,0x80,0x80,0xFE,0x80,0x80},/*"T",52*/ {0x00,0xFC,0x02,0x02,0x02,0xFC},/*"U",53*/ {0x00,0xF8,0x04,0x02,0x04,0xF8},/*"V",54*/ {0x00,0xFC,0x02,0x3C,0x02,0xFC},/*"W",55*/ {0x00,0xC6,0x28,0x10,0x28,0xC6},/*"X",56*/ {0x00,0xE0,0x10,0x0E,0x10,0xE0},/*"Y",57*/ {0x00,0x8E,0x92,0xA2,0xC2,0x00},/*"Z",58*/ {0x00,0x00,0xFE,0x82,0x82,0x00},/*"[",59*/ {0x00,0x40,0x20,0x10,0x08,0x04},/*"\",60*/ {0x00,0x00,0x82,0x82,0xFE,0x00},/*"]",61*/ {0x00,0x20,0x40,0x80,0x40,0x20},/*"^",62*/ {0x01,0x01,0x01,0x01,0x01,0x01},/*"_",63*/ {0x00,0x00,0xC0,0xE0,0x00,0x00},/*"`",64*/ {0x00,0x04,0x2A,0x2A,0x2A,0x1E},/*"a",65*/ {0x00,0xFE,0x22,0x22,0x22,0x1C},/*"b",66*/ {0x00,0x1C,0x22,0x22,0x22,0x14},/*"c",67*/ {0x00,0x1C,0x22,0x22,0x22,0xFE},/*"d",68*/ {0x00,0x1C,0x2A,0x2A,0x2A,0x10},/*"e",69*/ {0x00,0x10,0x7E,0x90,0x90,0x00},/*"f",70*/ {0x00,0x18,0x25,0x25,0x25,0x3E},/*"g",71*/ {0x00,0xFE,0x20,0x20,0x1E,0x00},/*"h",72*/ {0x00,0x00,0x00,0xBE,0x02,0x00},/*"i",73*/ {0x00,0x02,0x01,0x21,0xBE,0x00},/*"j",74*/ {0x00,0xFE,0x08,0x14,0x22,0x00},/*"k",75*/ {0x00,0x00,0x00,0xFE,0x02,0x00},/*"l",76*/ {0x00,0x3E,0x20,0x18,0x20,0x1E},/*"m",77*/ {0x00,0x3E,0x20,0x20,0x1E,0x00},/*"n",78*/ {0x00,0x1C,0x22,0x22,0x22,0x1C},/*"o",79*/ {0x00,0x3F,0x22,0x22,0x22,0x1C},/*"p",80*/ {0x00,0x1C,0x22,0x22,0x22,0x3F},/*"q",81*/ {0x00,0x22,0x1E,0x22,0x20,0x10},/*"r",82*/ {0x00,0x10,0x2A,0x2A,0x2A,0x04},/*"s",83*/ {0x00,0x20,0x7C,0x22,0x24,0x00},/*"t",84*/ {0x00,0x3C,0x02,0x04,0x3E,0x00},/*"u",85*/ {0x00,0x38,0x04,0x02,0x04,0x38},/*"v",86*/ {0x00,0x3C,0x06,0x0C,0x06,0x3C},/*"w",87*/ {0x00,0x36,0x08,0x08,0x36,0x00},/*"x",88*/ {0x00,0x39,0x05,0x06,0x3C,0x00},/*"y",89*/ {0x00,0x26,0x2A,0x2A,0x32,0x00},/*"z",90*/ {0x00,0x10,0x7C,0x82,0x82,0x00},/*"{",91*/ {0x00,0x00,0x00,0xEE,0x00,0x00},/*"|",92*/ {0x00,0x00,0x82,0x82,0x7C,0x10},/*"}",93*/ {0x00,0x40,0x80,0x40,0x80,0x00},/*"~",94*/ }; //06*12==宽*高 ASCII字符集点阵 (宋体) const unsigned char asc2_0612[95][12]={ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/ {0x00,0x00,0x00,0x00,0x3F,0x40,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/ {0x00,0x00,0x30,0x00,0x40,0x00,0x30,0x00,0x40,0x00,0x00,0x00},/*""",2*/ {0x09,0x00,0x0B,0xC0,0x3D,0x00,0x0B,0xC0,0x3D,0x00,0x09,0x00},/*"#",3*/ {0x18,0xC0,0x24,0x40,0x7F,0xE0,0x22,0x40,0x31,0x80,0x00,0x00},/*"$",4*/ {0x18,0x00,0x24,0xC0,0x1B,0x00,0x0D,0x80,0x32,0x40,0x01,0x80},/*"%",5*/ {0x03,0x80,0x1C,0x40,0x27,0x40,0x1C,0x80,0x07,0x40,0x00,0x40},/*"&",6*/ {0x10,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/ {0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x20,0x40,0x40,0x20},/*"(",8*/ {0x00,0x00,0x40,0x20,0x20,0x40,0x1F,0x80,0x00,0x00,0x00,0x00},/*")",9*/ {0x09,0x00,0x06,0x00,0x1F,0x80,0x06,0x00,0x09,0x00,0x00,0x00},/*"*",10*/ {0x04,0x00,0x04,0x00,0x3F,0x80,0x04,0x00,0x04,0x00,0x00,0x00},/*"+",11*/ {0x00,0x10,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*",",12*/ {0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00},/*"-",13*/ {0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*".",14*/ {0x00,0x20,0x01,0xC0,0x06,0x00,0x38,0x00,0x40,0x00,0x00,0x00},/*"/",15*/ {0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"0",16*/ {0x00,0x00,0x10,0x40,0x3F,0xC0,0x00,0x40,0x00,0x00,0x00,0x00},/*"1",17*/ {0x18,0xC0,0x21,0x40,0x22,0x40,0x24,0x40,0x18,0x40,0x00,0x00},/*"2",18*/ {0x10,0x80,0x20,0x40,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"3",19*/ {0x02,0x00,0x0D,0x00,0x11,0x00,0x3F,0xC0,0x01,0x40,0x00,0x00},/*"4",20*/ {0x3C,0x80,0x24,0x40,0x24,0x40,0x24,0x40,0x23,0x80,0x00,0x00},/*"5",21*/ {0x1F,0x80,0x24,0x40,0x24,0x40,0x34,0x40,0x03,0x80,0x00,0x00},/*"6",22*/ {0x30,0x00,0x20,0x00,0x27,0xC0,0x38,0x00,0x20,0x00,0x00,0x00},/*"7",23*/ {0x1B,0x80,0x24,0x40,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"8",24*/ {0x1C,0x00,0x22,0xC0,0x22,0x40,0x22,0x40,0x1F,0x80,0x00,0x00},/*"9",25*/ {0x00,0x00,0x00,0x00,0x08,0x40,0x00,0x00,0x00,0x00,0x00,0x00},/*":",26*/ {0x00,0x00,0x00,0x00,0x04,0x60,0x00,0x00,0x00,0x00,0x00,0x00},/*";",27*/ {0x00,0x00,0x04,0x00,0x0A,0x00,0x11,0x00,0x20,0x80,0x40,0x40},/*"<",28*/ {0x09,0x00,0x09,0x00,0x09,0x00,0x09,0x00,0x09,0x00,0x00,0x00},/*"=",29*/ {0x00,0x00,0x40,0x40,0x20,0x80,0x11,0x00,0x0A,0x00,0x04,0x00},/*">",30*/ {0x18,0x00,0x20,0x00,0x23,0x40,0x24,0x00,0x18,0x00,0x00,0x00},/*"?",31*/ {0x1F,0x80,0x20,0x40,0x27,0x40,0x29,0x40,0x1F,0x40,0x00,0x00},/*"@",32*/ {0x00,0x40,0x07,0xC0,0x39,0x00,0x0F,0x00,0x01,0xC0,0x00,0x40},/*"A",33*/ {0x20,0x40,0x3F,0xC0,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"B",34*/ {0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x30,0x80,0x00,0x00},/*"C",35*/ {0x20,0x40,0x3F,0xC0,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"D",36*/ {0x20,0x40,0x3F,0xC0,0x24,0x40,0x2E,0x40,0x30,0xC0,0x00,0x00},/*"E",37*/ {0x20,0x40,0x3F,0xC0,0x24,0x40,0x2E,0x00,0x30,0x00,0x00,0x00},/*"F",38*/ {0x0F,0x00,0x10,0x80,0x20,0x40,0x22,0x40,0x33,0x80,0x02,0x00},/*"G",39*/ {0x20,0x40,0x3F,0xC0,0x04,0x00,0x04,0x00,0x3F,0xC0,0x20,0x40},/*"H",40*/ {0x20,0x40,0x20,0x40,0x3F,0xC0,0x20,0x40,0x20,0x40,0x00,0x00},/*"I",41*/ {0x00,0x60,0x20,0x20,0x20,0x20,0x3F,0xC0,0x20,0x00,0x20,0x00},/*"J",42*/ {0x20,0x40,0x3F,0xC0,0x24,0x40,0x0B,0x00,0x30,0xC0,0x20,0x40},/*"K",43*/ {0x20,0x40,0x3F,0xC0,0x20,0x40,0x00,0x40,0x00,0x40,0x00,0xC0},/*"L",44*/ {0x3F,0xC0,0x3C,0x00,0x03,0xC0,0x3C,0x00,0x3F,0xC0,0x00,0x00},/*"M",45*/ {0x20,0x40,0x3F,0xC0,0x0C,0x40,0x23,0x00,0x3F,0xC0,0x20,0x00},/*"N",46*/ {0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"O",47*/ {0x20,0x40,0x3F,0xC0,0x24,0x40,0x24,0x00,0x18,0x00,0x00,0x00},/*"P",48*/ {0x1F,0x80,0x21,0x40,0x21,0x40,0x20,0xE0,0x1F,0xA0,0x00,0x00},/*"Q",49*/ {0x20,0x40,0x3F,0xC0,0x24,0x40,0x26,0x00,0x19,0xC0,0x00,0x40},/*"R",50*/ {0x18,0xC0,0x24,0x40,0x24,0x40,0x22,0x40,0x31,0x80,0x00,0x00},/*"S",51*/ {0x30,0x00,0x20,0x40,0x3F,0xC0,0x20,0x40,0x30,0x00,0x00,0x00},/*"T",52*/ {0x20,0x00,0x3F,0x80,0x00,0x40,0x00,0x40,0x3F,0x80,0x20,0x00},/*"U",53*/ {0x20,0x00,0x3E,0x00,0x01,0xC0,0x07,0x00,0x38,0x00,0x20,0x00},/*"V",54*/ {0x38,0x00,0x07,0xC0,0x3C,0x00,0x07,0xC0,0x38,0x00,0x00,0x00},/*"W",55*/ {0x20,0x40,0x39,0xC0,0x06,0x00,0x39,0xC0,0x20,0x40,0x00,0x00},/*"X",56*/ {0x20,0x00,0x38,0x40,0x07,0xC0,0x38,0x40,0x20,0x00,0x00,0x00},/*"Y",57*/ {0x30,0x40,0x21,0xC0,0x26,0x40,0x38,0x40,0x20,0xC0,0x00,0x00},/*"Z",58*/ {0x00,0x00,0x00,0x00,0x7F,0xE0,0x40,0x20,0x40,0x20,0x00,0x00},/*"[",59*/ {0x00,0x00,0x70,0x00,0x0C,0x00,0x03,0x80,0x00,0x40,0x00,0x00},/*"\",60*/ {0x00,0x00,0x40,0x20,0x40,0x20,0x7F,0xE0,0x00,0x00,0x00,0x00},/*"]",61*/ {0x00,0x00,0x20,0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x00},/*"^",62*/ {0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10},/*"_",63*/ {0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/ {0x00,0x00,0x02,0x80,0x05,0x40,0x05,0x40,0x03,0xC0,0x00,0x40},/*"a",65*/ {0x20,0x00,0x3F,0xC0,0x04,0x40,0x04,0x40,0x03,0x80,0x00,0x00},/*"b",66*/ {0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x40,0x06,0x40,0x00,0x00},/*"c",67*/ {0x00,0x00,0x03,0x80,0x04,0x40,0x24,0x40,0x3F,0xC0,0x00,0x40},/*"d",68*/ {0x00,0x00,0x03,0x80,0x05,0x40,0x05,0x40,0x03,0x40,0x00,0x00},/*"e",69*/ {0x00,0x00,0x04,0x40,0x1F,0xC0,0x24,0x40,0x24,0x40,0x20,0x00},/*"f",70*/ {0x00,0x00,0x02,0xE0,0x05,0x50,0x05,0x50,0x06,0x50,0x04,0x20},/*"g",71*/ {0x20,0x40,0x3F,0xC0,0x04,0x40,0x04,0x00,0x03,0xC0,0x00,0x40},/*"h",72*/ {0x00,0x00,0x04,0x40,0x27,0xC0,0x00,0x40,0x00,0x00,0x00,0x00},/*"i",73*/ {0x00,0x10,0x00,0x10,0x04,0x10,0x27,0xE0,0x00,0x00,0x00,0x00},/*"j",74*/ {0x20,0x40,0x3F,0xC0,0x01,0x40,0x07,0x00,0x04,0xC0,0x04,0x40},/*"k",75*/ {0x20,0x40,0x20,0x40,0x3F,0xC0,0x00,0x40,0x00,0x40,0x00,0x00},/*"l",76*/ {0x07,0xC0,0x04,0x00,0x07,0xC0,0x04,0x00,0x03,0xC0,0x00,0x00},/*"m",77*/ {0x04,0x40,0x07,0xC0,0x04,0x40,0x04,0x00,0x03,0xC0,0x00,0x40},/*"n",78*/ {0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x40,0x03,0x80,0x00,0x00},/*"o",79*/ {0x04,0x10,0x07,0xF0,0x04,0x50,0x04,0x40,0x03,0x80,0x00,0x00},/*"p",80*/ {0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x50,0x07,0xF0,0x00,0x10},/*"q",81*/ {0x04,0x40,0x07,0xC0,0x02,0x40,0x04,0x00,0x04,0x00,0x00,0x00},/*"r",82*/ {0x00,0x00,0x06,0x40,0x05,0x40,0x05,0x40,0x04,0xC0,0x00,0x00},/*"s",83*/ {0x00,0x00,0x04,0x00,0x1F,0x80,0x04,0x40,0x00,0x40,0x00,0x00},/*"t",84*/ {0x04,0x00,0x07,0x80,0x00,0x40,0x04,0x40,0x07,0xC0,0x00,0x40},/*"u",85*/ {0x04,0x00,0x07,0x00,0x04,0xC0,0x01,0x80,0x06,0x00,0x04,0x00},/*"v",86*/ {0x06,0x00,0x01,0xC0,0x07,0x00,0x01,0xC0,0x06,0x00,0x00,0x00},/*"w",87*/ {0x04,0x40,0x06,0xC0,0x01,0x00,0x06,0xC0,0x04,0x40,0x00,0x00},/*"x",88*/ {0x04,0x10,0x07,0x10,0x04,0xE0,0x01,0x80,0x06,0x00,0x04,0x00},/*"y",89*/ {0x00,0x00,0x04,0x40,0x05,0xC0,0x06,0x40,0x04,0x40,0x00,0x00},/*"z",90*/ {0x00,0x00,0x00,0x00,0x04,0x00,0x7B,0xE0,0x40,0x20,0x00,0x00},/*"{",91*/ {0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xF0,0x00,0x00,0x00,0x00},/*"|",92*/ {0x00,0x00,0x40,0x20,0x7B,0xE0,0x04,0x00,0x00,0x00,0x00,0x00},/*"}",93*/ {0x40,0x00,0x80,0x00,0x40,0x00,0x20,0x00,0x20,0x00,0x40,0x00},/*"~",94*/ }; //12*24==宽*高 ASCII字符集点阵 (宋体) const unsigned char asc2_1224[95][36]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",0*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x38, 0x0F,0xFE,0x38,0x0F,0x80,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"!",1*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x06,0x00,0x00,0x0C,0x00,0x00,0x38,0x00,0x00, 0x31,0x00,0x00,0x06,0x00,0x00,0x0C,0x00,0x00,0x38,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,/*""",2*/ 0x00,0x00,0x00,0x00,0x61,0x80,0x00,0x67,0xF8,0x07,0xF9,0x80,0x00,0x61,0x80,0x00,0x61,0x80, 0x00,0x61,0x80,0x00,0x61,0x80,0x00,0x67,0xF8,0x07,0xF9,0x80,0x00,0x61,0x80,0x00,0x00,0x00,/*"#",3*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0xE0,0x03,0xE0,0xF0,0x06,0x30,0x08,0x04,0x18,0x08, 0x1F,0xFF,0xFE,0x04,0x0E,0x08,0x07,0x87,0xF0,0x03,0x81,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,/*"$",4*/ 0x01,0xF0,0x00,0x06,0x0C,0x00,0x04,0x04,0x08,0x06,0x0C,0x70,0x01,0xF9,0xC0,0x00,0x0E,0x00, 0x00,0x3B,0xE0,0x00,0xEC,0x18,0x07,0x08,0x08,0x04,0x0C,0x18,0x00,0x03,0xE0,0x00,0x00,0x00,/*"%",5*/ 0x00,0x01,0xE0,0x00,0x07,0xF0,0x03,0xF8,0x18,0x04,0x1C,0x08,0x04,0x17,0x08,0x07,0xE1,0xD0, 0x03,0xC0,0xE0,0x00,0x23,0xB0,0x00,0x3C,0x08,0x00,0x20,0x08,0x00,0x00,0x10,0x00,0x00,0x00,/*"&",6*/ 0x00,0x00,0x00,0x01,0x00,0x00,0x31,0x00,0x00,0x32,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"'",7*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00, 0x01,0xFF,0xC0,0x07,0x80,0xF0,0x0C,0x00,0x18,0x10,0x00,0x04,0x20,0x00,0x02,0x00,0x00,0x00,/*"(",8*/ 0x00,0x00,0x00,0x20,0x00,0x02,0x10,0x00,0x04,0x0C,0x00,0x18,0x07,0x80,0xF0,0x01,0xFF,0xC0, 0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*")",9*/ 0x00,0x00,0x00,0x00,0x42,0x00,0x00,0x66,0x00,0x00,0x66,0x00,0x00,0x3C,0x00,0x00,0x18,0x00, 0x03,0xFF,0xC0,0x00,0x18,0x00,0x00,0x3C,0x00,0x00,0x66,0x00,0x00,0x66,0x00,0x00,0x42,0x00,/*"*",10*/ 0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00, 0x01,0xFF,0xC0,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,/*"+",11*/ 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x31,0x00,0x00,0x32,0x00,0x00,0x1C,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*",",12*/ 0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00, 0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x00,0x00,/*"-",13*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*".",14*/ 0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x1C,0x00,0x00,0x70,0x00,0x01,0x80,0x00,0x0E,0x00, 0x00,0x38,0x00,0x00,0xC0,0x00,0x07,0x00,0x00,0x1C,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,/*"/",15*/ 0x00,0x00,0x00,0x00,0x7F,0x80,0x01,0xFF,0xE0,0x03,0x80,0x70,0x06,0x00,0x18,0x04,0x00,0x08, 0x04,0x00,0x08,0x06,0x00,0x18,0x03,0x80,0x70,0x01,0xFF,0xE0,0x00,0x7F,0x80,0x00,0x00,0x00,/*"0",16*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x08,0x01,0x00,0x08,0x01,0x00,0x08,0x03,0xFF,0xF8, 0x07,0xFF,0xF8,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,/*"1",17*/ 0x00,0x00,0x00,0x01,0xC0,0x38,0x02,0xC0,0x58,0x04,0x00,0x98,0x04,0x01,0x18,0x04,0x02,0x18, 0x04,0x04,0x18,0x06,0x1C,0x18,0x03,0xF8,0x18,0x01,0xE0,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,/*"2",18*/ 0x00,0x00,0x00,0x01,0xC0,0xE0,0x03,0xC0,0xF0,0x04,0x00,0x08,0x04,0x08,0x08,0x04,0x08,0x08, 0x06,0x18,0x08,0x03,0xF4,0x18,0x01,0xE7,0xF0,0x00,0x01,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,/*"3",19*/ 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x0D,0x00,0x00,0x11,0x00,0x00,0x61,0x00,0x00,0x81,0x08, 0x03,0x01,0x08,0x07,0xFF,0xF8,0x0F,0xFF,0xF8,0x00,0x01,0x08,0x00,0x01,0x08,0x00,0x00,0x00,/*"4",20*/ 0x00,0x00,0x00,0x00,0x00,0xE0,0x07,0xFC,0xD0,0x06,0x08,0x08,0x06,0x10,0x08,0x06,0x10,0x08, 0x06,0x10,0x08,0x06,0x18,0x38,0x06,0x0F,0xF0,0x06,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,/*"5",21*/ 0x00,0x00,0x00,0x00,0x3F,0x80,0x01,0xFF,0xE0,0x03,0x84,0x30,0x02,0x08,0x18,0x04,0x10,0x08, 0x04,0x10,0x08,0x04,0x10,0x08,0x07,0x18,0x10,0x03,0x0F,0xF0,0x00,0x07,0xC0,0x00,0x00,0x00,/*"6",22*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x07,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0xF8, 0x06,0x07,0xF8,0x06,0x18,0x00,0x06,0xE0,0x00,0x07,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,/*"7",23*/ 0x00,0x00,0x00,0x01,0xE1,0xE0,0x03,0xF7,0xF0,0x06,0x34,0x10,0x04,0x18,0x08,0x04,0x18,0x08, 0x04,0x0C,0x08,0x04,0x0C,0x08,0x06,0x16,0x18,0x03,0xF3,0xF0,0x01,0xC1,0xE0,0x00,0x00,0x00,/*"8",24*/ 0x00,0x00,0x00,0x00,0xF8,0x00,0x03,0xFC,0x30,0x03,0x06,0x38,0x04,0x02,0x08,0x04,0x02,0x08, 0x04,0x02,0x08,0x04,0x04,0x10,0x03,0x08,0xF0,0x01,0xFF,0xC0,0x00,0x7F,0x00,0x00,0x00,0x00,/*"9",25*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x38, 0x00,0x70,0x38,0x00,0x70,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*":",26*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x1A, 0x00,0x30,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*";",27*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x14,0x00,0x00,0x22,0x00,0x00,0x41,0x00, 0x00,0x80,0x80,0x01,0x00,0x40,0x02,0x00,0x20,0x04,0x00,0x10,0x08,0x00,0x08,0x00,0x00,0x00,/*"<",28*/ 0x00,0x00,0x00,0x00,0x21,0x00,0x00,0x21,0x00,0x00,0x21,0x00,0x00,0x21,0x00,0x00,0x21,0x00, 0x00,0x21,0x00,0x00,0x21,0x00,0x00,0x21,0x00,0x00,0x21,0x00,0x00,0x21,0x00,0x00,0x00,0x00,/*"=",29*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x04,0x00,0x10,0x02,0x00,0x20,0x01,0x00,0x40, 0x00,0x80,0x80,0x00,0x41,0x00,0x00,0x22,0x00,0x00,0x14,0x00,0x00,0x08,0x00,0x00,0x00,0x00,/*">",30*/ 0x00,0x00,0x00,0x03,0xC0,0x00,0x04,0xC0,0x00,0x04,0x00,0x00,0x08,0x00,0x38,0x08,0x0F,0x38, 0x08,0x08,0x38,0x08,0x10,0x00,0x0C,0x30,0x00,0x07,0xE0,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,/*"?",31*/ 0x00,0x00,0x00,0x00,0x3F,0x80,0x00,0xFF,0xE0,0x03,0x80,0x70,0x02,0x0F,0x10,0x06,0x70,0x88, 0x04,0xC0,0x88,0x04,0x83,0x08,0x04,0x7F,0x88,0x02,0xC0,0x90,0x03,0x01,0x20,0x00,0xFE,0x40,/*"@",32*/ 0x00,0x00,0x08,0x00,0x00,0x18,0x00,0x01,0xF8,0x00,0x3E,0x08,0x01,0xC2,0x00,0x07,0x02,0x00, 0x07,0xE2,0x00,0x00,0xFE,0x00,0x00,0x1F,0xC8,0x00,0x01,0xF8,0x00,0x00,0x38,0x00,0x00,0x08,/*"A",33*/ 0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x08,0x08,0x04,0x08,0x08,0x04,0x08,0x08, 0x04,0x08,0x08,0x06,0x18,0x08,0x03,0xF4,0x18,0x01,0xE7,0xF0,0x00,0x01,0xE0,0x00,0x00,0x00,/*"B",34*/ 0x00,0x00,0x00,0x00,0x3F,0x80,0x01,0xFF,0xE0,0x03,0x80,0x70,0x02,0x00,0x18,0x04,0x00,0x08, 0x04,0x00,0x08,0x04,0x00,0x08,0x04,0x00,0x10,0x06,0x00,0x20,0x07,0x80,0xC0,0x00,0x00,0x00,/*"C",35*/ 0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x00,0x08,0x04,0x00,0x08,0x04,0x00,0x08, 0x04,0x00,0x18,0x02,0x00,0x10,0x03,0x80,0x70,0x01,0xFF,0xE0,0x00,0x7F,0x80,0x00,0x00,0x00,/*"D",36*/ 0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x08,0x08,0x04,0x08,0x08,0x04,0x08,0x08, 0x04,0x08,0x08,0x04,0x3E,0x08,0x04,0x00,0x08,0x06,0x00,0x18,0x01,0x00,0x60,0x00,0x00,0x00,/*"E",37*/ 0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x08,0x08,0x04,0x08,0x00,0x04,0x08,0x00, 0x04,0x08,0x00,0x04,0x3E,0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,/*"F",38*/ 0x00,0x00,0x00,0x00,0x3F,0x80,0x01,0xFF,0xE0,0x03,0x80,0x70,0x06,0x00,0x18,0x04,0x00,0x08, 0x04,0x02,0x08,0x04,0x02,0x08,0x02,0x03,0xF0,0x07,0x83,0xF0,0x00,0x02,0x00,0x00,0x02,0x00,/*"G",39*/ 0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x08,0x08,0x00,0x08,0x00,0x00,0x08,0x00, 0x00,0x08,0x00,0x00,0x08,0x00,0x04,0x08,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x00,0x08,/*"H",40*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x08,0x04,0x00,0x08,0x04,0x00,0x08,0x07,0xFF,0xF8, 0x07,0xFF,0xF8,0x04,0x00,0x08,0x04,0x00,0x08,0x04,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,/*"I",41*/ 0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x07,0x00,0x00,0x01,0x04,0x00,0x01,0x04,0x00,0x01, 0x04,0x00,0x03,0x07,0xFF,0xFE,0x07,0xFF,0xFC,0x04,0x00,0x00,0x04,0x00,0x00,0x04,0x00,0x00,/*"J",42*/ 0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x0C,0x08,0x00,0x18,0x00,0x00,0x3E,0x00, 0x04,0xC7,0x80,0x05,0x03,0xC8,0x06,0x00,0xF8,0x04,0x00,0x38,0x04,0x00,0x18,0x00,0x00,0x08,/*"K",43*/ 0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08, 0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x18,0x00,0x00,0x60,0x00,0x00,0x00,/*"L",44*/ 0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0x80,0x08,0x07,0xFC,0x00,0x00,0x7F,0xC0,0x00,0x03,0xF8, 0x00,0x07,0xC0,0x00,0x78,0x00,0x07,0x80,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x00,0x08,/*"M",45*/ 0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0x00,0x08,0x03,0xC0,0x00,0x00,0xE0,0x00,0x00,0x38,0x00, 0x00,0x1E,0x00,0x00,0x07,0x00,0x00,0x01,0xC0,0x04,0x00,0xF0,0x07,0xFF,0xF8,0x04,0x00,0x00,/*"N",46*/ 0x00,0x00,0x00,0x00,0x7F,0x80,0x01,0xFF,0xE0,0x03,0x80,0x70,0x06,0x00,0x18,0x04,0x00,0x08, 0x04,0x00,0x08,0x06,0x00,0x18,0x03,0x00,0x30,0x01,0xFF,0xE0,0x00,0x7F,0x80,0x00,0x00,0x00,/*"O",47*/ 0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x04,0x08,0x04,0x04,0x00,0x04,0x04,0x00, 0x04,0x04,0x00,0x04,0x04,0x00,0x06,0x0C,0x00,0x03,0xF8,0x00,0x01,0xF0,0x00,0x00,0x00,0x00,/*"P",48*/ 0x00,0x00,0x00,0x00,0x7F,0x80,0x01,0xFF,0xE0,0x03,0x80,0x70,0x06,0x00,0x88,0x04,0x00,0x88, 0x04,0x00,0xC8,0x06,0x00,0x3C,0x03,0x00,0x3E,0x01,0xFF,0xE6,0x00,0x7F,0x84,0x00,0x00,0x00,/*"Q",49*/ 0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x08,0x08,0x04,0x08,0x00,0x04,0x0C,0x00, 0x04,0x0F,0x00,0x04,0x0B,0xC0,0x06,0x10,0xF0,0x03,0xF0,0x38,0x01,0xE0,0x08,0x00,0x00,0x08,/*"R",50*/ 0x00,0x00,0x00,0x01,0xE0,0xF8,0x03,0xF0,0x30,0x06,0x30,0x10,0x04,0x18,0x08,0x04,0x18,0x08, 0x04,0x0C,0x08,0x04,0x0C,0x08,0x02,0x06,0x18,0x02,0x07,0xF0,0x07,0x81,0xE0,0x00,0x00,0x00,/*"S",51*/ 0x01,0x80,0x00,0x06,0x00,0x00,0x04,0x00,0x00,0x04,0x00,0x00,0x04,0x00,0x08,0x07,0xFF,0xF8, 0x07,0xFF,0xF8,0x04,0x00,0x08,0x04,0x00,0x00,0x04,0x00,0x00,0x06,0x00,0x00,0x01,0x80,0x00,/*"T",52*/ 0x04,0x00,0x00,0x07,0xFF,0xE0,0x07,0xFF,0xF0,0x04,0x00,0x18,0x00,0x00,0x08,0x00,0x00,0x08, 0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x04,0x00,0x10,0x07,0xFF,0xE0,0x04,0x00,0x00,/*"U",53*/ 0x04,0x00,0x00,0x06,0x00,0x00,0x07,0xE0,0x00,0x07,0xFE,0x00,0x04,0x1F,0xE0,0x00,0x01,0xF8, 0x00,0x00,0x38,0x00,0x01,0xE0,0x04,0x3E,0x00,0x07,0xC0,0x00,0x06,0x00,0x00,0x04,0x00,0x00,/*"V",54*/ 0x04,0x00,0x00,0x07,0xE0,0x00,0x07,0xFF,0xC0,0x04,0x1F,0xF8,0x00,0x07,0xC0,0x07,0xF8,0x00, 0x07,0xFF,0x80,0x04,0x3F,0xF8,0x00,0x07,0xC0,0x04,0xF8,0x00,0x07,0x00,0x00,0x04,0x00,0x00,/*"W",55*/ 0x00,0x00,0x00,0x04,0x00,0x08,0x06,0x00,0x18,0x07,0xC0,0x78,0x05,0xF1,0xC8,0x00,0x3E,0x00, 0x00,0x1F,0x80,0x04,0x63,0xE8,0x07,0x80,0xF8,0x06,0x00,0x18,0x04,0x00,0x08,0x00,0x00,0x00,/*"X",56*/ 0x04,0x00,0x00,0x06,0x00,0x00,0x07,0x80,0x00,0x07,0xE0,0x08,0x04,0x7C,0x08,0x00,0x1F,0xF8, 0x00,0x07,0xF8,0x00,0x18,0x08,0x04,0xE0,0x08,0x07,0x00,0x00,0x06,0x00,0x00,0x04,0x00,0x00,/*"Y",57*/ 0x00,0x00,0x00,0x01,0x00,0x08,0x06,0x00,0x38,0x04,0x00,0xF8,0x04,0x03,0xE8,0x04,0x0F,0x08, 0x04,0x7C,0x08,0x05,0xF0,0x08,0x07,0xC0,0x08,0x07,0x00,0x18,0x04,0x00,0x60,0x00,0x00,0x00,/*"Z",58*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFE, 0x20,0x00,0x02,0x20,0x00,0x02,0x20,0x00,0x02,0x20,0x00,0x02,0x20,0x00,0x02,0x00,0x00,0x00,/*"[",59*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x07,0x00,0x00,0x00,0xC0,0x00,0x00,0x38,0x00, 0x00,0x06,0x00,0x00,0x01,0xC0,0x00,0x00,0x30,0x00,0x00,0x0E,0x00,0x00,0x01,0x00,0x00,0x00,/*"\",60*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x02,0x20,0x00,0x02,0x20,0x00,0x02,0x20,0x00,0x02, 0x20,0x00,0x02,0x3F,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"]",61*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x10,0x00,0x00,0x30,0x00,0x00, 0x20,0x00,0x00,0x30,0x00,0x00,0x10,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"^",62*/ 0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01, 0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,/*"_",63*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x20,0x00,0x00,0x10,0x00,0x00, 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"`",64*/ 0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x19,0xF8,0x00,0x1B,0x18,0x00,0x22,0x08,0x00,0x26,0x08, 0x00,0x24,0x08,0x00,0x24,0x10,0x00,0x3F,0xF8,0x00,0x1F,0xF8,0x00,0x00,0x08,0x00,0x00,0x18,/*"a",65*/ 0x00,0x00,0x00,0x04,0x00,0x00,0x07,0xFF,0xF8,0x0F,0xFF,0xF0,0x00,0x18,0x18,0x00,0x10,0x08, 0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x30,0x18,0x00,0x1F,0xF0,0x00,0x0F,0xC0,0x00,0x00,0x00,/*"b",66*/ 0x00,0x00,0x00,0x00,0x07,0xC0,0x00,0x1F,0xF0,0x00,0x18,0x30,0x00,0x20,0x08,0x00,0x20,0x08, 0x00,0x20,0x08,0x00,0x3C,0x08,0x00,0x1C,0x10,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,/*"c",67*/ 0x00,0x00,0x00,0x00,0x07,0xC0,0x00,0x1F,0xF0,0x00,0x38,0x18,0x00,0x20,0x08,0x00,0x20,0x08, 0x00,0x20,0x08,0x04,0x10,0x10,0x07,0xFF,0xF8,0x0F,0xFF,0xF0,0x00,0x00,0x10,0x00,0x00,0x00,/*"d",68*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xC0,0x00,0x1F,0xF0,0x00,0x12,0x30,0x00,0x22,0x18, 0x00,0x22,0x08,0x00,0x22,0x08,0x00,0x32,0x08,0x00,0x1E,0x10,0x00,0x0E,0x20,0x00,0x00,0x00,/*"e",69*/ 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x20,0x08,0x00,0x20,0x08,0x01,0xFF,0xF8,0x03,0xFF,0xF8, 0x06,0x20,0x08,0x04,0x20,0x08,0x04,0x20,0x08,0x07,0x20,0x00,0x03,0x00,0x00,0x00,0x00,0x00,/*"f",70*/ 0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x0E,0x6E,0x00,0x1F,0xF3,0x00,0x31,0xB1,0x00,0x20,0xB1, 0x00,0x20,0xB1,0x00,0x31,0x91,0x00,0x1F,0x13,0x00,0x2E,0x1E,0x00,0x20,0x0E,0x00,0x30,0x00,/*"g",71*/ 0x00,0x00,0x00,0x04,0x00,0x08,0x07,0xFF,0xF8,0x0F,0xFF,0xF8,0x00,0x10,0x08,0x00,0x20,0x00, 0x00,0x20,0x00,0x00,0x20,0x08,0x00,0x3F,0xF8,0x00,0x1F,0xF8,0x00,0x00,0x08,0x00,0x00,0x00,/*"h",72*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x20,0x08,0x06,0x3F,0xF8, 0x06,0x3F,0xF8,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,/*"i",73*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x20,0x01,0x00,0x20,0x01, 0x00,0x20,0x03,0x06,0x3F,0xFE,0x06,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"j",74*/ 0x00,0x00,0x00,0x04,0x00,0x08,0x07,0xFF,0xF8,0x0F,0xFF,0xF8,0x00,0x01,0x88,0x00,0x03,0x00, 0x00,0x2F,0xC0,0x00,0x38,0xF8,0x00,0x20,0x38,0x00,0x20,0x08,0x00,0x00,0x08,0x00,0x00,0x00,/*"k",75*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x08,0x04,0x00,0x08,0x04,0x00,0x08,0x07,0xFF,0xF8, 0x0F,0xFF,0xF8,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,/*"l",76*/ 0x00,0x20,0x08,0x00,0x3F,0xF8,0x00,0x3F,0xF8,0x00,0x10,0x08,0x00,0x20,0x00,0x00,0x3F,0xF8, 0x00,0x3F,0xF8,0x00,0x10,0x08,0x00,0x20,0x00,0x00,0x3F,0xF8,0x00,0x3F,0xF8,0x00,0x00,0x08,/*"m",77*/ 0x00,0x00,0x00,0x00,0x20,0x08,0x00,0x3F,0xF8,0x00,0x3F,0xF8,0x00,0x10,0x08,0x00,0x10,0x00, 0x00,0x20,0x00,0x00,0x20,0x08,0x00,0x3F,0xF8,0x00,0x1F,0xF8,0x00,0x00,0x08,0x00,0x00,0x00,/*"n",78*/ 0x00,0x00,0x00,0x00,0x07,0xC0,0x00,0x0F,0xF0,0x00,0x18,0x30,0x00,0x30,0x08,0x00,0x20,0x08, 0x00,0x20,0x08,0x00,0x30,0x08,0x00,0x18,0x30,0x00,0x0F,0xF0,0x00,0x07,0xC0,0x00,0x00,0x00,/*"o",79*/ 0x00,0x00,0x00,0x00,0x20,0x01,0x00,0x3F,0xFF,0x00,0x3F,0xFF,0x00,0x10,0x11,0x00,0x20,0x09, 0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x30,0x38,0x00,0x1F,0xF0,0x00,0x0F,0xC0,0x00,0x00,0x00,/*"p",80*/ 0x00,0x00,0x00,0x00,0x07,0xC0,0x00,0x1F,0xF0,0x00,0x38,0x18,0x00,0x20,0x08,0x00,0x20,0x08, 0x00,0x20,0x09,0x00,0x10,0x11,0x00,0x1F,0xFF,0x00,0x3F,0xFF,0x00,0x00,0x01,0x00,0x00,0x00,/*"q",81*/ 0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x3F,0xF8,0x00,0x3F,0xF8,0x00,0x08,0x08, 0x00,0x10,0x08,0x00,0x20,0x08,0x00,0x20,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x00,0x00,/*"r",82*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x78,0x00,0x1E,0x18,0x00,0x33,0x08,0x00,0x23,0x08, 0x00,0x21,0x08,0x00,0x21,0x88,0x00,0x21,0x98,0x00,0x30,0xF0,0x00,0x38,0x60,0x00,0x00,0x00,/*"s",83*/ 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x20,0x00,0x00,0x20,0x00,0x00,0xFF,0xF0,0x03,0xFF,0xF8, 0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,/*"t",84*/ 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x3F,0xF0,0x00,0x7F,0xF8,0x00,0x00,0x18,0x00,0x00,0x08, 0x00,0x00,0x08,0x00,0x20,0x10,0x00,0x3F,0xF8,0x00,0x7F,0xF0,0x00,0x00,0x10,0x00,0x00,0x00,/*"u",85*/ 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x30,0x00,0x00,0x3C,0x00,0x00,0x3F,0x80,0x00,0x23,0xF0, 0x00,0x00,0x78,0x00,0x00,0x70,0x00,0x23,0x80,0x00,0x3C,0x00,0x00,0x30,0x00,0x00,0x20,0x00,/*"v",86*/ 0x00,0x20,0x00,0x00,0x3C,0x00,0x00,0x3F,0xE0,0x00,0x23,0xF8,0x00,0x00,0xE0,0x00,0x27,0x00, 0x00,0x3E,0x00,0x00,0x3F,0xE0,0x00,0x21,0xF8,0x00,0x01,0xE0,0x00,0x3E,0x00,0x00,0x20,0x00,/*"w",87*/ 0x00,0x00,0x00,0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x38,0x38,0x00,0x3E,0x68,0x00,0x27,0x80, 0x00,0x03,0xC8,0x00,0x2C,0xF8,0x00,0x38,0x38,0x00,0x20,0x18,0x00,0x20,0x08,0x00,0x00,0x00,/*"x",88*/ 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x30,0x03,0x00,0x3C,0x01,0x00,0x3F,0x83,0x00,0x23,0xEC, 0x00,0x00,0x70,0x00,0x23,0x80,0x00,0x3C,0x00,0x00,0x20,0x00,0x00,0x20,0x00,0x00,0x00,0x00,/*"y",89*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x08,0x00,0x20,0x38,0x00,0x20,0xF8,0x00,0x23,0xE8, 0x00,0x2F,0x88,0x00,0x3E,0x08,0x00,0x38,0x08,0x00,0x20,0x18,0x00,0x00,0x70,0x00,0x00,0x00,/*"z",90*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00, 0x00,0x14,0x00,0x1F,0xF7,0xFC,0x30,0x00,0x06,0x20,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,/*"{",91*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"|",92*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x02,0x30,0x00,0x06,0x1F,0xF7,0xFC,0x00,0x14,0x00, 0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"}",93*/ 0x00,0x00,0x00,0x18,0x00,0x00,0x60,0x00,0x00,0x40,0x00,0x00,0x40,0x00,0x00,0x20,0x00,0x00, 0x10,0x00,0x00,0x08,0x00,0x00,0x04,0x00,0x00,0x04,0x00,0x00,0x0C,0x00,0x00,0x10,0x00,0x00,/*"~",94*/ };   3.4、main.c #include "main.h" int main(void) { uint8_t i; CLOCK_EnableClock(kCLOCK_Gpio0); BOARD_InitDEBUG_UARTPins(); BOARD_PowerMode_OD(); BOARD_InitBootClocks(); BOARD_InitDebugConsole(); init_utick(); SysTick_Init(); init_led(); init_key(); init_lcd_jlx12864g(); lcd_showString(0,0, (uint8_t*)"MCXN947_BOARD_TEST",6,12); lcd_showString(0,13,(uint8_t*)"JLX12864G-SPI",6,12); lcd_showString(0,26,(uint8_t*)"2024/12/14",6,12); lcd_refreshGram(); while (1) { SysTick_Delay_ms(500); led_red_tog(); //lcd_clear(); lcd_showString(0,39,(uint8_t*)"MCXN947_BOARD [OK]",6,12); lcd_refreshGram(); SysTick_Delay_ms(500); //lcd_clear(); lcd_showString(0,39,(uint8_t*)"TTTTTTTTTTTTT [OK]",6,12); lcd_refreshGram(); } }   3.5、main.h #ifndef _MAIN_H_ #define _MAIN_H_ #include "pin_mux.h" #include "clock_config.h" #include "board.h" #include "fsl_debug_console.h" #include "fsl_gpio.h" #include "fsl_port.h" #include "fsl_lpi2c.h" #include "fsl_common.h" #include "fsl_lpspi.h" #include "fsl_lpspi_edma.h" #include "fsl_utick.h" #include "led/led.h" #include "systick/systick.h" #include "key/key.h" #include "fsl_p3t1755.h" #include "fsl_i3c.h" #include "utick/utick.h" #include "lcd/jlx12864g.h" #endif   四、运行结果   下载程序后,显示屏显示 [localvideo]ec5f286ce86c0e88e7d9465d74c14699[/localvideo]    

  • 2024-12-12
  • 回复了主题帖: 【英飞凌PSOC™ 4100S Max】⑤SPI点亮TFT LCD屏幕

    模拟SPI刷新速度有点慢,硬件SPI方式会好些。

  • 发表了主题帖: 【FRDM-MCXN947】 移植FreeRTOS

    本帖最后由 TL-LED 于 2024-12-12 21:54 编辑 移植FreeRTOS到开发板   一、FreeRTOS源码下载   源码下载地址:https://github.com/FreeRTOS/FreeRTOS     二、添加源码到工程   2.1、将下载的源码复制到项目工程的middleware目录下   2.2、添加文件到工程       2.3、添加头文件路径   三、程序代码   3.1、FreeRTOSConfig.h /* * FreeRTOS V202212.01 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * https://www.FreeRTOS.org * https://github.com/FreeRTOS * */ #ifndef FREERTOS_CONFIG_H #define FREERTOS_CONFIG_H /*----------------------------------------------------------- * Application specific definitions. * * These definitions should be adjusted for your particular hardware and * application requirements. * * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. * * See http://www.freertos.org/a00110.html. *----------------------------------------------------------*/ /* Ensure definitions are only used by the compiler, and not by the assembler. */ #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) #include <stdint.h> extern uint32_t SystemCoreClock; #endif #ifndef configENABLE_FPU #define configENABLE_FPU 1 #endif #ifndef configENABLE_MPU #define configENABLE_MPU 0 #endif #ifndef configENABLE_TRUSTZONE #define configENABLE_TRUSTZONE 0 #endif #ifndef configRUN_FREERTOS_SECURE_ONLY #define configRUN_FREERTOS_SECURE_ONLY 1 #endif #define configUSE_PREEMPTION 1 #define configSUPPORT_STATIC_ALLOCATION 0//1 #define configSUPPORT_DYNAMIC_ALLOCATION 1 #define configUSE_IDLE_HOOK 0 #define configUSE_TICK_HOOK 0 #define configCPU_CLOCK_HZ ( SystemCoreClock ) #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) #define configMAX_PRIORITIES ( 56 ) #define configMINIMAL_STACK_SIZE ( ( uint16_t ) 512 ) #define configTOTAL_HEAP_SIZE ( ( size_t ) 15 * 1024 ) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_TRACE_FACILITY 1 #define configUSE_16_BIT_TICKS 0 #define configUSE_MUTEXES 1 #define configQUEUE_REGISTRY_SIZE 8 #define configUSE_RECURSIVE_MUTEXES 1 #define configUSE_COUNTING_SEMAPHORES 1 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 #define configUSE_MALLOC_FAILED_HOOK 0//1 #define configCHECK_FOR_STACK_OVERFLOW 0//2 /* Defaults to size_t for backward compatibility, but can be changed * if lengths will always be less than the number of bytes in a size_t. */ #define configMESSAGE_BUFFER_LENGTH_TYPE size_t /* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ /* Software timer definitions. */ #define configUSE_TIMERS 1 #define configTIMER_TASK_PRIORITY ( 2 ) #define configTIMER_QUEUE_LENGTH 10 #define configTIMER_TASK_STACK_DEPTH 256 /* Set the following definitions to 1 to include the API function, or zero * to exclude the API function. */ #define INCLUDE_vTaskPrioritySet 1 #define INCLUDE_uxTaskPriorityGet 1 #define INCLUDE_vTaskDelete 1 #define INCLUDE_vTaskCleanUpResources 0 #define INCLUDE_vTaskSuspend 1 #define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelay 1 #define INCLUDE_xTaskGetSchedulerState 1 #define INCLUDE_xTimerPendFunctionCall 1 #define INCLUDE_xQueueGetMutexHolder 1 #define INCLUDE_uxTaskGetStackHighWaterMark 1 #define INCLUDE_eTaskGetState 1 /* Cortex-M specific definitions. */ #ifdef __NVIC_PRIO_BITS /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ #define configPRIO_BITS __NVIC_PRIO_BITS #else #define configPRIO_BITS 4 #endif /* The lowest interrupt priority that can be used in a call to a "set priority" * function. */ #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 /* The highest interrupt priority that can be used by any interrupt service * routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT * CALL INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A * HIGHER PRIORITY THAN THIS! (higher priorities are lower numeric values. */ #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 /* Interrupt priorities used by the kernel port layer itself. These are generic * to all Cortex-M ports, and do not rely on any particular library functions. */ #define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << ( 8 - configPRIO_BITS ) ) /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ #define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << ( 8 - configPRIO_BITS ) ) /* Normal assert() semantics without relying on the provision of an assert.h * header file. */ #define configASSERT( x ) if ( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); } /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS * standard names. */ #define vPortSVCHandler SVC_Handler #define xPortPendSVHandler PendSV_Handler #define xPortSysTickHandler SysTick_Handler /* Allow system call from within FreeRTOS kernel only. */ #define configENFORCE_SYSTEM_CALLS_FROM_KERNEL_ONLY 1 /* STM32H743 has 16 MPU regions and therefore it is necessary to configure * configTOTAL_MPU_REGIONS correctly. */ #define configTOTAL_MPU_REGIONS 16 /* The default TEX,S,C,B setting marks the SRAM as shareable and as a result, * disables cache. Do not mark the SRAM as shareable because caching is being * used. TEX=0, S=0, C=1, B=1. */ #define configTEX_S_C_B_SRAM ( 0x03UL ) #endif /* FREERTOS_CONFIG_H */   3.2、fun_task.c #include "main.h" #define START_TASK_PRO 1 #define START_STK_SIZE 128 TaskHandle_t StartTask_Handler; #define TASK1_PRIO 4 #define TASK1_STK_SIZE 128 static TaskHandle_t Task1Task_Handler = NULL; #define TASK2_PRIO 3 #define TASK2_STK_SIZE 128 static TaskHandle_t Task2Task_Handler = NULL; void start_task(void *pvParameters); void gui_task(void *pvParameters); void task1(void *pvParameters); void task2(void *pvParameters); void task_create(void) { //start_task xTaskCreate((TaskFunction_t )start_task, (const char* )"start_task", (uint16_t )START_STK_SIZE, (void* )NULL, (UBaseType_t )START_TASK_PRO, (TaskHandle_t* )&StartTask_Handler); vTaskStartScheduler(); } void start_task(void *pvParameters) { taskENTER_CRITICAL(); //task1 xTaskCreate((TaskFunction_t )task1, (const char* )"task1", (uint16_t )TASK1_STK_SIZE, (void* )NULL, (UBaseType_t )TASK1_PRIO, (TaskHandle_t* )&Task1Task_Handler); //task2 xTaskCreate((TaskFunction_t )task2, (const char* )"task2", (uint16_t )TASK2_STK_SIZE, (void* )NULL, (UBaseType_t )TASK2_PRIO, (TaskHandle_t* )&Task2Task_Handler); taskEXIT_CRITICAL(); vTaskDelete(StartTask_Handler); } //task1 void task1(void *pvParameters) { while (1) { PRINTF("task1 run ...\r\n"); vTaskDelay(200); } } //task2 void task2(void *pvParameters) { while (1) { PRINTF("task2 run ...\r\n"); vTaskDelay(100); } }   3.3、fun_task.h #ifndef __FUN_TASK_H #define __FUN_TASK_H void task_create(void); #endif   3.4、main.c #include "main.h" int main(void) { uint8_t i; CLOCK_EnableClock(kCLOCK_Gpio0); BOARD_InitDEBUG_UARTPins(); BOARD_PowerMode_OD(); BOARD_InitBootClocks(); BOARD_InitDebugConsole(); init_led(); init_key(); task_create(); while (1) { } }   3.5、main.h #ifndef _MAIN_H_ #define _MAIN_H_ #include "pin_mux.h" #include "clock_config.h" #include "board.h" #include "fsl_debug_console.h" #include "fsl_gpio.h" #include "fsl_port.h" #include "fsl_lpi2c.h" #include "fsl_common.h" #include "fsl_lpspi.h" #include "fsl_lpspi_edma.h" #include "fsl_utick.h" #include "led/led.h" #include "systick/systick.h" #include "key/key.h" #include "fsl_p3t1755.h" #include "fsl_i3c.h" #include "p3t1755/p3t1755.h" #include "utick/utick.h" #include "FreeRTOS.h" #include "task.h" #include "fun_task.h" #endif   四、运行结果   下载程序后,串口输出          

  • 发表了主题帖: 【FRDM-MCXN947】 P3T1755温度传感器测试

    读取P3T1755温度传感器的值,通过串口打印输出。   一、硬件部分   P3T1755电路图部分   二、接口和时钟配置   2.1、配置I3C接口   2.2、配置I3C时钟   也可以在程序中配置,配置代码 /* Attach PLL0 clock to I3C, 150MHz / 6 = 25MHz. */ CLOCK_SetClkDiv(kCLOCK_DivI3c1FClk, 6U); CLOCK_AttachClk(kPLL0_to_I3C1FCLK);   三、程序部分   3.1、fsl_p3t1755.c /* * Copyright 2022, 2024 NXP * * SPDX-License-Identifier: BSD-3-Clause */ #include "fsl_p3t1755.h" /******************************************************************************* * Definitions ******************************************************************************/ /******************************************************************************* * Prototypes ******************************************************************************/ /******************************************************************************* * Variables ******************************************************************************/ /******************************************************************************* * Code ******************************************************************************/ status_t P3T1755_WriteReg(p3t1755_handle_t *handle, uint32_t regAddress, uint8_t *regData, size_t dataSize) { status_t result; result = handle->writeTransfer(handle->sensorAddress, regAddress, regData, dataSize); return (result == kStatus_Success) ? result : kStatus_Fail; } status_t P3T1755_ReadReg(p3t1755_handle_t *handle, uint32_t regAddress, uint8_t *regData, size_t dataSize) { status_t result; result = handle->readTransfer(handle->sensorAddress, regAddress, regData, dataSize); return (result == kStatus_Success) ? result : kStatus_Fail; } status_t P3T1755_Init(p3t1755_handle_t *handle, p3t1755_config_t *config) { assert(handle != NULL); assert(config != NULL); assert(config->writeTransfer != NULL); assert(config->readTransfer != NULL); handle->writeTransfer = config->writeTransfer; handle->readTransfer = config->readTransfer; handle->sensorAddress = config->sensorAddress; return kStatus_Success; } status_t P3T1755_ReadTemperature(p3t1755_handle_t *handle, double *temperature) { status_t result = kStatus_Success; uint8_t data[2]; uint16_t temp; result = P3T1755_ReadReg(handle, P3T1755_TEMPERATURE_REG, &data[0], 2); if (result == kStatus_Success) { temp = (((uint16_t)data[0] << 8U) | (uint16_t)data[1]) >> 4U; *temperature = (double)temp * 0.0625; } return result; }   3.2、fsl_p3t1755.h /* * Copyright 2022 NXP * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef _FSL_P3T1755_H_ #define _FSL_P3T1755_H_ #include "fsl_common.h" /* Registers. */ #define P3T1755_TEMPERATURE_REG (0x00U) #define P3T1755_CONFIG_REG (0x01U) /*! [url=home.php?mod=space&uid=159083]@brief[/url] Define sensor access function. */ typedef status_t (*sensor_write_transfer_func_t)(uint8_t deviceAddress, uint32_t regAddress, uint8_t *regData, size_t dataSize); typedef status_t (*sensor_read_transfer_func_t)(uint8_t deviceAddress, uint32_t regAddress, uint8_t *regData, size_t dataSize); typedef struct _p3t1755_handle { sensor_write_transfer_func_t writeTransfer; sensor_read_transfer_func_t readTransfer; uint8_t sensorAddress; } p3t1755_handle_t; typedef struct _p3t1755_config { sensor_write_transfer_func_t writeTransfer; sensor_read_transfer_func_t readTransfer; uint8_t sensorAddress; } p3t1755_config_t; #if defined(__cplusplus) extern "C" { #endif /*! * @brief Create handle for P3T1755, reset the sensor per user configuration. * * @param p3t1755_handle The pointer to #p3t1755_handle_t. * * [url=home.php?mod=space&uid=784970]@return[/url] kStatus_Success if success or kStatus_Fail if error. */ status_t P3T1755_Init(p3t1755_handle_t *handle, p3t1755_config_t *config); /*! * @brief Write Register with register data buffer. * * @param handle The pointer to #p3t1755_handle_t. * @param regAddress register address to write. * @param regData The pointer to data buffer to be write to the reg. * @param dataSize Size of the regData. * * @return kStatus_Success if success or kStatus_Fail if error. */ status_t P3T1755_WriteReg(p3t1755_handle_t *handle, uint32_t regAddress, uint8_t *regData, size_t dataSize); /*! * @brief Read Register to speficied data buffer. * * @param handle The pointer to #p3t1755_handle_t. * @param regAddress register address to read. * @param regData The pointer to data buffer to store the read out data. * @param dataSize Size of the regData to be read. * * @return kStatus_Success if success or kStatus_Fail if error. */ status_t P3T1755_ReadReg(p3t1755_handle_t *handle, uint32_t regAddress, uint8_t *regData, size_t dataSize); /*! * @brief Read temperature data. * * @param handle The pointer to #p3t1755_handle_t. * @param temperature The pointer to temperature data. * * @return kStatus_Success if success or kStatus_Fail if error. */ status_t P3T1755_ReadTemperature(p3t1755_handle_t *handle, double *temperature); #if defined(__cplusplus) } #endif /* __cplusplus */ #endif /* _FSL_P3T1755_H_ */   3.3、p3t1755.c #include "main.h" /******************************************************************************* * Prototypes ******************************************************************************/ static void i3c_master_callback(I3C_Type *base, i3c_master_handle_t *handle, status_t status, void *userData); /******************************************************************************* * Variables ******************************************************************************/ volatile status_t g_completionStatus; volatile bool g_masterCompletionFlag; i3c_master_handle_t g_i3c_m_handle; p3t1755_handle_t p3t1755Handle; const i3c_master_transfer_callback_t masterCallback = { .slave2Master = NULL, .ibiCallback = NULL, .transferComplete = i3c_master_callback}; /******************************************************************************* * Code ******************************************************************************/ static void i3c_master_callback(I3C_Type *base, i3c_master_handle_t *handle, status_t status, void *userData) { if (status == kStatus_Success) { g_masterCompletionFlag = true; } g_completionStatus = status; } status_t I3C_WriteSensor(uint8_t deviceAddress, uint32_t regAddress, uint8_t *regData, size_t dataSize) { status_t result = kStatus_Success; i3c_master_transfer_t masterXfer = {0}; uint32_t timeout = 0U; masterXfer.slaveAddress = deviceAddress; masterXfer.direction = kI3C_Write; masterXfer.busType = kI3C_TypeI3CSdr; masterXfer.subaddress = regAddress; masterXfer.subaddressSize = 1; masterXfer.data = regData; masterXfer.dataSize = dataSize; masterXfer.flags = kI3C_TransferDefaultFlag; g_masterCompletionFlag = false; g_completionStatus = kStatus_Success; result = I3C_MasterTransferNonBlocking(EXAMPLE_MASTER, &g_i3c_m_handle, &masterXfer); if (kStatus_Success != result) { return result; } while (!g_masterCompletionFlag) { timeout++; if ((g_completionStatus != kStatus_Success) || (timeout > I3C_TIME_OUT_INDEX)) { break; } } if (timeout == I3C_TIME_OUT_INDEX) { result = kStatus_Timeout; } result = g_completionStatus; return result; } status_t I3C_ReadSensor(uint8_t deviceAddress, uint32_t regAddress, uint8_t *regData, size_t dataSize) { status_t result = kStatus_Success; i3c_master_transfer_t masterXfer = {0}; uint32_t timeout = 0U; masterXfer.slaveAddress = deviceAddress; masterXfer.direction = kI3C_Read; masterXfer.busType = kI3C_TypeI3CSdr; masterXfer.subaddress = regAddress; masterXfer.subaddressSize = 1; masterXfer.data = regData; masterXfer.dataSize = dataSize; masterXfer.flags = kI3C_TransferDefaultFlag; g_masterCompletionFlag = false; g_completionStatus = kStatus_Success; result = I3C_MasterTransferNonBlocking(EXAMPLE_MASTER, &g_i3c_m_handle, &masterXfer); if (kStatus_Success != result) { return result; } while (!g_masterCompletionFlag) { timeout++; if ((g_completionStatus != kStatus_Success) || (timeout > I3C_TIME_OUT_INDEX)) { break; } } if (timeout == I3C_TIME_OUT_INDEX) { result = kStatus_Timeout; } result = g_completionStatus; return result; } status_t p3t1755_set_dynamic_address(void) { status_t result = kStatus_Success; i3c_master_transfer_t masterXfer = {0}; uint8_t g_master_txBuff[1]; /* Reset dynamic address. */ g_master_txBuff[0] = CCC_RSTDAA; masterXfer.slaveAddress = 0x7E; masterXfer.data = g_master_txBuff; masterXfer.dataSize = 1; masterXfer.direction = kI3C_Write; masterXfer.busType = kI3C_TypeI3CSdr; masterXfer.flags = kI3C_TransferDefaultFlag; result = I3C_MasterTransferBlocking(EXAMPLE_MASTER, &masterXfer); if (result != kStatus_Success) { return result; } /* Assign dynmic address. */ memset(&masterXfer, 0, sizeof(masterXfer)); g_master_txBuff[0] = CCC_SETDASA; masterXfer.slaveAddress = 0x7E; masterXfer.data = g_master_txBuff; masterXfer.dataSize = 1; masterXfer.direction = kI3C_Write; masterXfer.busType = kI3C_TypeI3CSdr; masterXfer.flags = kI3C_TransferNoStopFlag; result = I3C_MasterTransferBlocking(EXAMPLE_MASTER, &masterXfer); if (result != kStatus_Success) { return result; } memset(&masterXfer, 0, sizeof(masterXfer)); g_master_txBuff[0] = SENSOR_ADDR << 1; masterXfer.slaveAddress = SENSOR_SLAVE_ADDR; masterXfer.data = g_master_txBuff; masterXfer.dataSize = 1; masterXfer.direction = kI3C_Write; masterXfer.busType = kI3C_TypeI3CSdr; masterXfer.flags = kI3C_TransferDefaultFlag; return I3C_MasterTransferBlocking(EXAMPLE_MASTER, &masterXfer); } void init_p3t1755(void) { status_t result = kStatus_Success; i3c_master_config_t masterConfig; p3t1755_config_t p3t1755Config; // /* Attach PLL0 clock to I3C, 150MHz / 6 = 25MHz. */ // CLOCK_SetClkDiv(kCLOCK_DivI3c1FClk, 6U); // CLOCK_AttachClk(kPLL0_to_I3C1FCLK); init_p3t1755_pins(); PRINTF("\r\nI3C master read sensor data example.\r\n"); I3C_MasterGetDefaultConfig(&masterConfig); masterConfig.baudRate_Hz.i2cBaud = EXAMPLE_I2C_BAUDRATE; masterConfig.baudRate_Hz.i3cPushPullBaud = EXAMPLE_I3C_PP_BAUDRATE; masterConfig.baudRate_Hz.i3cOpenDrainBaud = EXAMPLE_I3C_OD_BAUDRATE; masterConfig.enableOpenDrainStop = false; masterConfig.disableTimeout = true; I3C_MasterInit(EXAMPLE_MASTER, &masterConfig, I3C_MASTER_CLOCK_FREQUENCY); /* Create I3C handle. */ I3C_MasterTransferCreateHandle(EXAMPLE_MASTER, &g_i3c_m_handle, &masterCallback, NULL); result = p3t1755_set_dynamic_address(); if (result != kStatus_Success) { PRINTF("\r\nP3T1755 set dynamic address failed.\r\n"); } p3t1755Config.writeTransfer = I3C_WriteSensor; p3t1755Config.readTransfer = I3C_ReadSensor; p3t1755Config.sensorAddress = SENSOR_ADDR; P3T1755_Init(&p3t1755Handle, &p3t1755Config); } void p3t1755_test(void) { status_t result = kStatus_Success; double temperature; while(1) { result = P3T1755_ReadTemperature(&p3t1755Handle, &temperature); if (result != kStatus_Success) { PRINTF("\r\nP3T1755 read temperature failed.\r\n"); } else { PRINTF("Temperature:%0.1f \r\n", temperature); } SysTick_Delay_ms(500); } }   3.4、p3t1755.h #ifndef __P3T1755_H #define __P3T1755_H #define EXAMPLE_MASTER I3C1 #define I3C_MASTER_CLOCK_FREQUENCY CLOCK_GetI3cClkFreq(1) #define SENSOR_SLAVE_ADDR 0x48U #define I3C_TIME_OUT_INDEX 100000000U #define SENSOR_ADDR 0x08U #define CCC_RSTDAA 0x06U #define CCC_SETDASA 0x87 #ifndef EXAMPLE_I2C_BAUDRATE #define EXAMPLE_I2C_BAUDRATE 400000 #endif #ifndef EXAMPLE_I3C_OD_BAUDRATE #define EXAMPLE_I3C_OD_BAUDRATE 1500000 #endif #ifndef EXAMPLE_I3C_PP_BAUDRATE #define EXAMPLE_I3C_PP_BAUDRATE 4000000 #endif void init_p3t1755(void); void p3t1755_test(void); #endif   3.5、main.c #include "main.h" int main(void) { uint8_t i; CLOCK_EnableClock(kCLOCK_Gpio0); BOARD_InitDEBUG_UARTPins(); BOARD_PowerMode_OD(); BOARD_InitBootClocks(); BOARD_InitDebugConsole(); init_utick(); SysTick_Init(); init_p3t1755(); init_led(); init_key(); p3t1755_test(); while (1) { SysTick_Delay_ms(500); led_red_tog(); } }   3.6、main.h #ifndef _MAIN_H_ #define _MAIN_H_ #include "pin_mux.h" #include "clock_config.h" #include "board.h" #include "fsl_debug_console.h" #include "fsl_gpio.h" #include "fsl_port.h" #include "fsl_lpi2c.h" #include "fsl_common.h" #include "fsl_lpspi.h" #include "fsl_lpspi_edma.h" #include "fsl_utick.h" #include "led/led.h" #include "systick/systick.h" #include "key/key.h" #include "fsl_p3t1755.h" #include "fsl_i3c.h" #include "p3t1755/p3t1755.h" #include "utick/utick.h" #endif   四、运行结果   程序下载后,串口输出温度值  

  • 发表了主题帖: 【FRDM-MCXN947】UTICK定时器

    测试N947内部的UTICK定时器,定时1MS中断。   一、UTICK内部框图     二、程序部分   2.1、utick.c #include "main.h" static void UTickCallback(void) { led_red_tog(); } void init_utick(void) { SYSCON->CLOCK_CTRL |= SYSCON_CLOCK_CTRL_FRO1MHZ_ENA_MASK; UTICK_Init(EXAMPLE_UTICK); UTICK_SetTick(EXAMPLE_UTICK, kUTICK_Repeat, UTICK_TIME_1MS - 1, UTickCallback); }   2.2、utick.h #ifndef __UTICK_H #define __UTICK_H #define EXAMPLE_UTICK UTICK0 #define UTICK_TIME_1MS (1000L) #define UTICK_TIME_1S (1000000UL) void init_utick(void); #endif   三、程序运行结果   下载程序后,测试红色LED引脚电平,查看输出波形    

  • 2024-12-10
  • 回复了主题帖: FRDM-MCXN947 下载问题linkserver

    打开个MDK工程,看能不能找到仿真器  

统计信息

已有1111人来访过

  • 芯积分:1646
  • 好友:3
  • 主题:243
  • 回复:198

留言

你需要登录后才可以留言 登录 | 注册


现在还没有留言