From 89a48816379d2c3ee0aba39ec9593fde8eeb3a47 Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Tue, 12 Nov 2024 16:50:38 +1100 Subject: [PATCH] Strip driver out of board folder, will be in own repo. --- ports/mimxrt/boards/MIMXRT1170_EVK/board.c | 668 ------------------ ports/mimxrt/boards/MIMXRT1170_EVK/board.h | 282 -------- .../boards/MIMXRT1170_EVK/display_support.c | 533 -------------- .../boards/MIMXRT1170_EVK/display_support.h | 110 --- .../mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb.h | 80 --- .../boards/MIMXRT1170_EVK/fsl_dc_fb_elcdif.c | 263 ------- .../boards/MIMXRT1170_EVK/fsl_dc_fb_elcdif.h | 101 --- .../boards/MIMXRT1170_EVK/fsl_dc_fb_lcdifv2.c | 289 -------- .../boards/MIMXRT1170_EVK/fsl_dc_fb_lcdifv2.h | 109 --- .../boards/MIMXRT1170_EVK/fsl_display.h | 140 ---- .../mimxrt/boards/MIMXRT1170_EVK/fsl_gt911.c | 317 --------- .../mimxrt/boards/MIMXRT1170_EVK/fsl_gt911.h | 198 ------ .../mimxrt/boards/MIMXRT1170_EVK/fsl_hx8394.c | 187 ----- .../mimxrt/boards/MIMXRT1170_EVK/fsl_hx8394.h | 57 -- .../boards/MIMXRT1170_EVK/fsl_mipi_dsi_cmd.c | 338 --------- .../boards/MIMXRT1170_EVK/fsl_mipi_dsi_cmd.h | 313 -------- .../boards/MIMXRT1170_EVK/fsl_rm68191.c | 251 ------- .../boards/MIMXRT1170_EVK/fsl_rm68191.h | 62 -- .../boards/MIMXRT1170_EVK/fsl_rm68200.c | 409 ----------- .../boards/MIMXRT1170_EVK/fsl_rm68200.h | 67 -- .../boards/MIMXRT1170_EVK/fsl_video_common.c | 259 ------- .../boards/MIMXRT1170_EVK/fsl_video_common.h | 291 -------- .../boards/MIMXRT1170_EVK/lvgl_support.c | 581 --------------- .../boards/MIMXRT1170_EVK/lvgl_support.h | 50 -- ports/mimxrt/boards/MIMXRT1170_EVK/pin_mux.c | 364 ---------- ports/mimxrt/boards/MIMXRT1170_EVK/pin_mux.h | 199 ------ 26 files changed, 6518 deletions(-) delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/board.c delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/board.h delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/display_support.c delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/display_support.h delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb.h delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_elcdif.c delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_elcdif.h delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_lcdifv2.c delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_lcdifv2.h delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_display.h delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_gt911.c delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_gt911.h delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_hx8394.c delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_hx8394.h delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_mipi_dsi_cmd.c delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_mipi_dsi_cmd.h delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68191.c delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68191.h delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68200.c delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68200.h delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_video_common.c delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/fsl_video_common.h delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/lvgl_support.c delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/lvgl_support.h delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/pin_mux.c delete mode 100644 ports/mimxrt/boards/MIMXRT1170_EVK/pin_mux.h diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/board.c b/ports/mimxrt/boards/MIMXRT1170_EVK/board.c deleted file mode 100644 index eb8a073e6303..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/board.c +++ /dev/null @@ -1,668 +0,0 @@ -/* - * Copyright 2018-2022 NXP - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "fsl_common.h" -// #include "fsl_debug_console.h" -#include "board.h" -#if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED -#include "fsl_lpi2c.h" -#endif /* SDK_I2C_BASED_COMPONENT_USED */ -#include "fsl_iomuxc.h" - -/******************************************************************************* - * Variables - ******************************************************************************/ -/******************************************************************************* - * Code - ******************************************************************************/ - -/* Get debug console frequency. */ -uint32_t BOARD_DebugConsoleSrcFreq(void) -{ -#if DEBUG_CONSOLE_UART_INDEX == 1 - return CLOCK_GetRootClockFreq(kCLOCK_Root_Lpuart1); -#elif DEBUG_CONSOLE_UART_INDEX == 12 - return CLOCK_GetRootClockFreq(kCLOCK_Root_Lpuart12); -#else - return CLOCK_GetRootClockFreq(kCLOCK_Root_Lpuart2); -#endif -} - -/* Initialize debug console. */ -void BOARD_InitDebugConsole(void) -{ - // uint32_t uartClkSrcFreq = BOARD_DebugConsoleSrcFreq(); - // DbgConsole_Init(BOARD_DEBUG_UART_INSTANCE, BOARD_DEBUG_UART_BAUDRATE, BOARD_DEBUG_UART_TYPE, uartClkSrcFreq); -} - -#if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED -void BOARD_LPI2C_Init(LPI2C_Type *base, uint32_t clkSrc_Hz) -{ - lpi2c_master_config_t lpi2cConfig = {0}; - - /* - * lpi2cConfig.debugEnable = false; - * lpi2cConfig.ignoreAck = false; - * lpi2cConfig.pinConfig = kLPI2C_2PinOpenDrain; - * lpi2cConfig.baudRate_Hz = 100000U; - * lpi2cConfig.busIdleTimeout_ns = 0; - * lpi2cConfig.pinLowTimeout_ns = 0; - * lpi2cConfig.sdaGlitchFilterWidth_ns = 0; - * lpi2cConfig.sclGlitchFilterWidth_ns = 0; - */ - LPI2C_MasterGetDefaultConfig(&lpi2cConfig); - LPI2C_MasterInit(base, &lpi2cConfig, clkSrc_Hz); -} - -status_t BOARD_LPI2C_Send(LPI2C_Type *base, - uint8_t deviceAddress, - uint32_t subAddress, - uint8_t subAddressSize, - uint8_t *txBuff, - uint8_t txBuffSize) -{ - lpi2c_master_transfer_t xfer; - - xfer.flags = kLPI2C_TransferDefaultFlag; - xfer.slaveAddress = deviceAddress; - xfer.direction = kLPI2C_Write; - xfer.subaddress = subAddress; - xfer.subaddressSize = subAddressSize; - xfer.data = txBuff; - xfer.dataSize = txBuffSize; - - return LPI2C_MasterTransferBlocking(base, &xfer); -} - -status_t BOARD_LPI2C_Receive(LPI2C_Type *base, - uint8_t deviceAddress, - uint32_t subAddress, - uint8_t subAddressSize, - uint8_t *rxBuff, - uint8_t rxBuffSize) -{ - lpi2c_master_transfer_t xfer; - - xfer.flags = kLPI2C_TransferDefaultFlag; - xfer.slaveAddress = deviceAddress; - xfer.direction = kLPI2C_Read; - xfer.subaddress = subAddress; - xfer.subaddressSize = subAddressSize; - xfer.data = rxBuff; - xfer.dataSize = rxBuffSize; - - return LPI2C_MasterTransferBlocking(base, &xfer); -} - -status_t BOARD_LPI2C_SendSCCB(LPI2C_Type *base, - uint8_t deviceAddress, - uint32_t subAddress, - uint8_t subAddressSize, - uint8_t *txBuff, - uint8_t txBuffSize) -{ - lpi2c_master_transfer_t xfer; - - xfer.flags = kLPI2C_TransferDefaultFlag; - xfer.slaveAddress = deviceAddress; - xfer.direction = kLPI2C_Write; - xfer.subaddress = subAddress; - xfer.subaddressSize = subAddressSize; - xfer.data = txBuff; - xfer.dataSize = txBuffSize; - - return LPI2C_MasterTransferBlocking(base, &xfer); -} - -status_t BOARD_LPI2C_ReceiveSCCB(LPI2C_Type *base, - uint8_t deviceAddress, - uint32_t subAddress, - uint8_t subAddressSize, - uint8_t *rxBuff, - uint8_t rxBuffSize) -{ - status_t status; - lpi2c_master_transfer_t xfer; - - xfer.flags = kLPI2C_TransferDefaultFlag; - xfer.slaveAddress = deviceAddress; - xfer.direction = kLPI2C_Write; - xfer.subaddress = subAddress; - xfer.subaddressSize = subAddressSize; - xfer.data = NULL; - xfer.dataSize = 0; - - status = LPI2C_MasterTransferBlocking(base, &xfer); - - if (kStatus_Success == status) - { - xfer.subaddressSize = 0; - xfer.direction = kLPI2C_Read; - xfer.data = rxBuff; - xfer.dataSize = rxBuffSize; - - status = LPI2C_MasterTransferBlocking(base, &xfer); - } - - return status; -} - -void BOARD_Accel_I2C_Init(void) -{ - BOARD_LPI2C_Init(BOARD_ACCEL_I2C_BASEADDR, BOARD_ACCEL_I2C_CLOCK_FREQ); -} - -status_t BOARD_Accel_I2C_Send(uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint32_t txBuff) -{ - uint8_t data = (uint8_t)txBuff; - - return BOARD_LPI2C_Send(BOARD_ACCEL_I2C_BASEADDR, deviceAddress, subAddress, subaddressSize, &data, 1); -} - -status_t BOARD_Accel_I2C_Receive( - uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize) -{ - return BOARD_LPI2C_Receive(BOARD_ACCEL_I2C_BASEADDR, deviceAddress, subAddress, subaddressSize, rxBuff, rxBuffSize); -} - -void BOARD_Codec_I2C_Init(void) -{ - BOARD_LPI2C_Init(BOARD_CODEC_I2C_BASEADDR, BOARD_CODEC_I2C_CLOCK_FREQ); -} - -status_t BOARD_Codec_I2C_Send( - uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize) -{ - return BOARD_LPI2C_Send(BOARD_CODEC_I2C_BASEADDR, deviceAddress, subAddress, subAddressSize, (uint8_t *)txBuff, - txBuffSize); -} - -status_t BOARD_Codec_I2C_Receive( - uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize) -{ - return BOARD_LPI2C_Receive(BOARD_CODEC_I2C_BASEADDR, deviceAddress, subAddress, subAddressSize, rxBuff, rxBuffSize); -} - -void BOARD_Camera_I2C_Init(void) -{ - const clock_root_config_t lpi2cClockConfig = { - .clockOff = false, - .mux = BOARD_CAMERA_I2C_CLOCK_SOURCE, - .div = BOARD_CAMERA_I2C_CLOCK_DIVIDER, - }; - - CLOCK_SetRootClock(BOARD_CAMERA_I2C_CLOCK_ROOT, &lpi2cClockConfig); - - BOARD_LPI2C_Init(BOARD_CAMERA_I2C_BASEADDR, CLOCK_GetRootClockFreq(BOARD_CAMERA_I2C_CLOCK_ROOT)); -} - -status_t BOARD_Camera_I2C_Send( - uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize) -{ - return BOARD_LPI2C_Send(BOARD_CAMERA_I2C_BASEADDR, deviceAddress, subAddress, subAddressSize, (uint8_t *)txBuff, - txBuffSize); -} - -status_t BOARD_Camera_I2C_Receive( - uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize) -{ - return BOARD_LPI2C_Receive(BOARD_CAMERA_I2C_BASEADDR, deviceAddress, subAddress, subAddressSize, rxBuff, - rxBuffSize); -} - -status_t BOARD_Camera_I2C_SendSCCB( - uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize) -{ - return BOARD_LPI2C_SendSCCB(BOARD_CAMERA_I2C_BASEADDR, deviceAddress, subAddress, subAddressSize, (uint8_t *)txBuff, - txBuffSize); -} - -status_t BOARD_Camera_I2C_ReceiveSCCB( - uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize) -{ - return BOARD_LPI2C_ReceiveSCCB(BOARD_CAMERA_I2C_BASEADDR, deviceAddress, subAddress, subAddressSize, rxBuff, - rxBuffSize); -} - -void BOARD_MIPIPanelTouch_I2C_Init(void) -{ - const clock_root_config_t lpi2cClockConfig = { - .clockOff = false, - .mux = BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_SOURCE, - .div = BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_DIVIDER, - }; - - CLOCK_SetRootClock(BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_ROOT, &lpi2cClockConfig); - - BOARD_LPI2C_Init(BOARD_MIPI_PANEL_TOUCH_I2C_BASEADDR, - CLOCK_GetRootClockFreq(BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_ROOT)); -} - -status_t BOARD_MIPIPanelTouch_I2C_Send( - uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize) -{ - return BOARD_LPI2C_Send(BOARD_MIPI_PANEL_TOUCH_I2C_BASEADDR, deviceAddress, subAddress, subAddressSize, - (uint8_t *)txBuff, txBuffSize); -} - -status_t BOARD_MIPIPanelTouch_I2C_Receive( - uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize) -{ - return BOARD_LPI2C_Receive(BOARD_MIPI_PANEL_TOUCH_I2C_BASEADDR, deviceAddress, subAddress, subAddressSize, rxBuff, - rxBuffSize); -} -#endif /* SDK_I2C_BASED_COMPONENT_USED */ - -/* MPU configuration. */ -#if __CORTEX_M == 7 -void BOARD_ConfigMPU(void) -{ -#if defined(__CC_ARM) || defined(__ARMCC_VERSION) - extern uint32_t Image$$RW_m_ncache$$Base[]; - /* RW_m_ncache_unused is a auxiliary region which is used to get the whole size of noncache section */ - extern uint32_t Image$$RW_m_ncache_unused$$Base[]; - extern uint32_t Image$$RW_m_ncache_unused$$ZI$$Limit[]; - uint32_t nonCacheStart = (uint32_t)Image$$RW_m_ncache$$Base; - uint32_t size = ((uint32_t)Image$$RW_m_ncache_unused$$Base == nonCacheStart) ? - 0 : - ((uint32_t)Image$$RW_m_ncache_unused$$ZI$$Limit - nonCacheStart); -#elif defined(__MCUXPRESSO) -#if defined(__USE_SHMEM) - extern uint32_t __base_rpmsg_sh_mem; - extern uint32_t __top_rpmsg_sh_mem; - uint32_t nonCacheStart = (uint32_t)(&__base_rpmsg_sh_mem); - uint32_t size = (uint32_t)(&__top_rpmsg_sh_mem) - nonCacheStart; -#else - extern uint32_t __base_NCACHE_REGION; - extern uint32_t __top_NCACHE_REGION; - uint32_t nonCacheStart = (uint32_t)(&__base_NCACHE_REGION); - uint32_t size = (uint32_t)(&__top_NCACHE_REGION) - nonCacheStart; -#endif -#elif defined(__ICCARM__) || defined(__GNUC__) - extern uint32_t __NCACHE_REGION_START[]; - extern uint32_t __NCACHE_REGION_SIZE[]; - uint32_t nonCacheStart = (uint32_t)__NCACHE_REGION_START; - uint32_t size = (uint32_t)__NCACHE_REGION_SIZE; -#endif - volatile uint32_t i = 0; - -#if defined(__ICACHE_PRESENT) && __ICACHE_PRESENT - /* Disable I cache and D cache */ - if (SCB_CCR_IC_Msk == (SCB_CCR_IC_Msk & SCB->CCR)) - { - SCB_DisableICache(); - } -#endif -#if defined(__DCACHE_PRESENT) && __DCACHE_PRESENT - if (SCB_CCR_DC_Msk == (SCB_CCR_DC_Msk & SCB->CCR)) - { - SCB_DisableDCache(); - } -#endif - - /* Disable MPU */ - ARM_MPU_Disable(); - - /* MPU configure: - * Use ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, - * SubRegionDisable, Size) - * API in mpu_armv7.h. - * param DisableExec Instruction access (XN) disable bit,0=instruction fetches enabled, 1=instruction fetches - * disabled. - * param AccessPermission Data access permissions, allows you to configure read/write access for User and - * Privileged mode. - * Use MACROS defined in mpu_armv7.h: - * ARM_MPU_AP_NONE/ARM_MPU_AP_PRIV/ARM_MPU_AP_URO/ARM_MPU_AP_FULL/ARM_MPU_AP_PRO/ARM_MPU_AP_RO - * Combine TypeExtField/IsShareable/IsCacheable/IsBufferable to configure MPU memory access attributes. - * TypeExtField IsShareable IsCacheable IsBufferable Memory Attribute Shareability Cache - * 0 x 0 0 Strongly Ordered shareable - * 0 x 0 1 Device shareable - * 0 0 1 0 Normal not shareable Outer and inner write - * through no write allocate - * 0 0 1 1 Normal not shareable Outer and inner write - * back no write allocate - * 0 1 1 0 Normal shareable Outer and inner write - * through no write allocate - * 0 1 1 1 Normal shareable Outer and inner write - * back no write allocate - * 1 0 0 0 Normal not shareable outer and inner - * noncache - * 1 1 0 0 Normal shareable outer and inner - * noncache - * 1 0 1 1 Normal not shareable outer and inner write - * back write/read acllocate - * 1 1 1 1 Normal shareable outer and inner write - * back write/read acllocate - * 2 x 0 0 Device not shareable - * Above are normal use settings, if your want to see more details or want to config different inner/outter cache - * policy. - * please refer to Table 4-55 /4-56 in arm cortex-M7 generic user guide - * param SubRegionDisable Sub-region disable field. 0=sub-region is enabled, 1=sub-region is disabled. - * param Size Region size of the region to be configured. use ARM_MPU_REGION_SIZE_xxx MACRO in - * mpu_armv7.h. - */ - - /* - * Add default region to deny access to whole address space to workaround speculative prefetch. - * Refer to Arm errata 1013783-B for more details. - * - */ - /* Region 0 setting: Instruction access disabled, No data access permission. */ - MPU->RBAR = ARM_MPU_RBAR(0, 0x00000000U); - MPU->RASR = ARM_MPU_RASR(1, ARM_MPU_AP_NONE, 0, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_4GB); - - /* Region 1 setting: Memory with Device type, not shareable, non-cacheable. */ - MPU->RBAR = ARM_MPU_RBAR(1, 0x80000000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_512MB); - - /* Region 2 setting: Memory with Device type, not shareable, non-cacheable. */ - MPU->RBAR = ARM_MPU_RBAR(2, 0x60000000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_512MB); - - /* Region 3 setting: Memory with Device type, not shareable, non-cacheable. */ - MPU->RBAR = ARM_MPU_RBAR(3, 0x00000000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_1GB); - - /* Region 4 setting: Memory with Normal type, not shareable, outer/inner write back */ - MPU->RBAR = ARM_MPU_RBAR(4, 0x00000000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_256KB); - - /* Region 5 setting: Memory with Normal type, not shareable, outer/inner write back */ - MPU->RBAR = ARM_MPU_RBAR(5, 0x20000000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_256KB); - -#if defined(CACHE_MODE_WRITE_THROUGH) && CACHE_MODE_WRITE_THROUGH - /* Region 6 setting: Memory with Normal type, not shareable, write through */ - MPU->RBAR = ARM_MPU_RBAR(6, 0x20200000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 0, 0, ARM_MPU_REGION_SIZE_1MB); - - /* Region 7 setting: Memory with Normal type, not shareable, write trough */ - MPU->RBAR = ARM_MPU_RBAR(7, 0x20300000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 0, 0, ARM_MPU_REGION_SIZE_512KB); -#else - /* Region 6 setting: Memory with Normal type, not shareable, outer/inner write back */ - MPU->RBAR = ARM_MPU_RBAR(6, 0x20200000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_1MB); - - /* Region 7 setting: Memory with Normal type, not shareable, outer/inner write back */ - MPU->RBAR = ARM_MPU_RBAR(7, 0x20300000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_512KB); -#endif - -#if defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1) - /* Region 8 setting: Memory with Normal type, not shareable, outer/inner write back. */ - MPU->RBAR = ARM_MPU_RBAR(8, 0x30000000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_RO, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_16MB); -#endif - -#ifdef USE_SDRAM -#if defined(CACHE_MODE_WRITE_THROUGH) && CACHE_MODE_WRITE_THROUGH - /* Region 9 setting: Memory with Normal type, not shareable, write trough */ - MPU->RBAR = ARM_MPU_RBAR(9, 0x80000000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 0, 0, ARM_MPU_REGION_SIZE_64MB); -#else - /* Region 9 setting: Memory with Normal type, not shareable, outer/inner write back */ - MPU->RBAR = ARM_MPU_RBAR(9, 0x80000000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_64MB); -#endif -#endif - - while ((size >> i) > 0x1U) - { - i++; - } - - if (i != 0) - { - /* The MPU region size should be 2^N, 5<=N<=32, region base should be multiples of size. */ - assert(!(nonCacheStart % size)); - assert(size == (uint32_t)(1 << i)); - assert(i >= 5); - - /* Region 10 setting: Memory with Normal type, not shareable, non-cacheable */ - MPU->RBAR = ARM_MPU_RBAR(10, nonCacheStart); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 1, 0, 0, 0, 0, i - 1); - } - - /* Region 11 setting: Memory with Device type, not shareable, non-cacheable */ - MPU->RBAR = ARM_MPU_RBAR(11, 0x40000000); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_16MB); - - /* Region 12 setting: Memory with Device type, not shareable, non-cacheable */ - MPU->RBAR = ARM_MPU_RBAR(12, 0x41000000); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_2MB); - - /* Region 13 setting: Memory with Device type, not shareable, non-cacheable */ - MPU->RBAR = ARM_MPU_RBAR(13, 0x41400000); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_1MB); - - /* Region 14 setting: Memory with Device type, not shareable, non-cacheable */ - MPU->RBAR = ARM_MPU_RBAR(14, 0x41800000); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_2MB); - - /* Region 15 setting: Memory with Device type, not shareable, non-cacheable */ - MPU->RBAR = ARM_MPU_RBAR(15, 0x42000000); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_1MB); - - /* Enable MPU */ - ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk); - - /* Enable I cache and D cache */ -#if defined(__DCACHE_PRESENT) && __DCACHE_PRESENT - SCB_EnableDCache(); -#endif -#if defined(__ICACHE_PRESENT) && __ICACHE_PRESENT - SCB_EnableICache(); -#endif -} -#elif __CORTEX_M == 4 -void BOARD_ConfigMPU(void) -{ -#if defined(__CC_ARM) || defined(__ARMCC_VERSION) - extern uint32_t Image$$RW_m_ncache$$Base[]; - /* RW_m_ncache_unused is a auxiliary region which is used to get the whole size of noncache section */ - extern uint32_t Image$$RW_m_ncache_unused$$Base[]; - extern uint32_t Image$$RW_m_ncache_unused$$ZI$$Limit[]; - uint32_t nonCacheStart = (uint32_t)Image$$RW_m_ncache$$Base; - uint32_t nonCacheSize = ((uint32_t)Image$$RW_m_ncache_unused$$Base == nonCacheStart) ? - 0 : - ((uint32_t)Image$$RW_m_ncache_unused$$ZI$$Limit - nonCacheStart); -#elif defined(__MCUXPRESSO) - extern uint32_t __base_NCACHE_REGION; - extern uint32_t __top_NCACHE_REGION; - uint32_t nonCacheStart = (uint32_t)(&__base_NCACHE_REGION); - uint32_t nonCacheSize = (uint32_t)(&__top_NCACHE_REGION) - nonCacheStart; -#elif defined(__ICCARM__) || defined(__GNUC__) - extern uint32_t __NCACHE_REGION_START[]; - extern uint32_t __NCACHE_REGION_SIZE[]; - uint32_t nonCacheStart = (uint32_t)__NCACHE_REGION_START; - uint32_t nonCacheSize = (uint32_t)__NCACHE_REGION_SIZE; -#endif -#if defined(__USE_SHMEM) -#if defined(__CC_ARM) || defined(__ARMCC_VERSION) - extern uint32_t Image$$RPMSG_SH_MEM$$Base[]; - /* RPMSG_SH_MEM_unused is a auxiliary region which is used to get the whole size of RPMSG_SH_MEM section */ - extern uint32_t Image$$RPMSG_SH_MEM_unused$$Base[]; - extern uint32_t Image$$RPMSG_SH_MEM_unused$$ZI$$Limit[]; - uint32_t rpmsgShmemStart = (uint32_t)Image$$RPMSG_SH_MEM$$Base; - uint32_t rpmsgShmemSize = (uint32_t)Image$$RPMSG_SH_MEM_unused$$ZI$$Limit - rpmsgShmemStart; -#elif defined(__MCUXPRESSO) - extern uint32_t __base_rpmsg_sh_mem; - extern uint32_t __top_rpmsg_sh_mem; - uint32_t rpmsgShmemStart = (uint32_t)(&__base_rpmsg_sh_mem); - uint32_t rpmsgShmemSize = (uint32_t)(&__top_rpmsg_sh_mem) - rpmsgShmemStart; -#elif defined(__ICCARM__) || defined(__GNUC__) - extern uint32_t __RPMSG_SH_MEM_START[]; - extern uint32_t __RPMSG_SH_MEM_SIZE[]; - uint32_t rpmsgShmemStart = (uint32_t)__RPMSG_SH_MEM_START; - uint32_t rpmsgShmemSize = (uint32_t)__RPMSG_SH_MEM_SIZE; -#endif -#endif - uint32_t i = 0; - - /* Only config non-cacheable region on system bus */ - assert(nonCacheStart >= 0x20000000); - - /* Disable code bus cache */ - if (LMEM_PCCCR_ENCACHE_MASK == (LMEM_PCCCR_ENCACHE_MASK & LMEM->PCCCR)) - { - /* Enable the processor code bus to push all modified lines. */ - LMEM->PCCCR |= LMEM_PCCCR_PUSHW0_MASK | LMEM_PCCCR_PUSHW1_MASK | LMEM_PCCCR_GO_MASK; - /* Wait until the cache command completes. */ - while ((LMEM->PCCCR & LMEM_PCCCR_GO_MASK) != 0U) - { - } - /* As a precaution clear the bits to avoid inadvertently re-running this command. */ - LMEM->PCCCR &= ~(LMEM_PCCCR_PUSHW0_MASK | LMEM_PCCCR_PUSHW1_MASK); - /* Now disable the cache. */ - LMEM->PCCCR &= ~LMEM_PCCCR_ENCACHE_MASK; - } - - /* Disable system bus cache */ - if (LMEM_PSCCR_ENCACHE_MASK == (LMEM_PSCCR_ENCACHE_MASK & LMEM->PSCCR)) - { - /* Enable the processor system bus to push all modified lines. */ - LMEM->PSCCR |= LMEM_PSCCR_PUSHW0_MASK | LMEM_PSCCR_PUSHW1_MASK | LMEM_PSCCR_GO_MASK; - /* Wait until the cache command completes. */ - while ((LMEM->PSCCR & LMEM_PSCCR_GO_MASK) != 0U) - { - } - /* As a precaution clear the bits to avoid inadvertently re-running this command. */ - LMEM->PSCCR &= ~(LMEM_PSCCR_PUSHW0_MASK | LMEM_PSCCR_PUSHW1_MASK); - /* Now disable the cache. */ - LMEM->PSCCR &= ~LMEM_PSCCR_ENCACHE_MASK; - } - - /* Disable MPU */ - ARM_MPU_Disable(); - -#if defined(CACHE_MODE_WRITE_THROUGH) && CACHE_MODE_WRITE_THROUGH - /* Region 0 setting: Memory with Normal type, not shareable, write trough */ - MPU->RBAR = ARM_MPU_RBAR(0, 0x20200000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 0, 0, ARM_MPU_REGION_SIZE_1MB); - - /* Region 1 setting: Memory with Normal type, not shareable, write through */ - MPU->RBAR = ARM_MPU_RBAR(1, 0x20300000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 0, 0, ARM_MPU_REGION_SIZE_512KB); - - /* Region 2 setting: Memory with Normal type, not shareable, write through */ - MPU->RBAR = ARM_MPU_RBAR(2, 0x80000000U); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 0, 0, ARM_MPU_REGION_SIZE_64MB); - - while ((nonCacheSize >> i) > 0x1U) - { - i++; - } - - if (i != 0) - { - /* The MPU region size should be 2^N, 5<=N<=32, region base should be multiples of size. */ - assert(!(nonCacheStart % nonCacheSize)); - assert(nonCacheSize == (uint32_t)(1 << i)); - assert(i >= 5); - - /* Region 3 setting: Memory with device type, not shareable, non-cacheable */ - MPU->RBAR = ARM_MPU_RBAR(3, nonCacheStart); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, i - 1); - } - -#if defined(__USE_SHMEM) - i = 0; - - while ((rpmsgShmemSize >> i) > 0x1U) - { - i++; - } - - if (i != 0) - { - /* The MPU region size should be 2^N, 5<=N<=32, region base should be multiples of size. */ - assert(!(rpmsgShmemStart % rpmsgShmemSize)); - assert(rpmsgShmemSize == (uint32_t)(1 << i)); - assert(i >= 5); - - /* Region 4 setting: Memory with device type, not shareable, non-cacheable */ - MPU->RBAR = ARM_MPU_RBAR(4, rpmsgShmemStart); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, i - 1); - } -#endif -#else - while ((nonCacheSize >> i) > 0x1U) - { - i++; - } - - if (i != 0) - { - /* The MPU region size should be 2^N, 5<=N<=32, region base should be multiples of size. */ - assert(!(nonCacheStart % nonCacheSize)); - assert(nonCacheSize == (uint32_t)(1 << i)); - assert(i >= 5); - - /* Region 0 setting: Memory with device type, not shareable, non-cacheable */ - MPU->RBAR = ARM_MPU_RBAR(0, nonCacheStart); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, i - 1); - } - -#if defined(__USE_SHMEM) - i = 0; - - while ((rpmsgShmemSize >> i) > 0x1U) - { - i++; - } - - if (i != 0) - { - /* The MPU region size should be 2^N, 5<=N<=32, region base should be multiples of size. */ - assert(!(rpmsgShmemStart % rpmsgShmemSize)); - assert(rpmsgShmemSize == (uint32_t)(1 << i)); - assert(i >= 5); - - /* Region 1 setting: Memory with device type, not shareable, non-cacheable */ - MPU->RBAR = ARM_MPU_RBAR(1, rpmsgShmemStart); - MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, i - 1); - } -#endif -#endif - - /* Enable MPU */ - ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk); - - /* Enables the processor system bus to invalidate all lines in both ways. - and Initiate the processor system bus cache command. */ - LMEM->PSCCR |= LMEM_PSCCR_INVW0_MASK | LMEM_PSCCR_INVW1_MASK | LMEM_PSCCR_GO_MASK; - /* Wait until the cache command completes */ - while ((LMEM->PSCCR & LMEM_PSCCR_GO_MASK) != 0U) - { - } - /* As a precaution clear the bits to avoid inadvertently re-running this command. */ - LMEM->PSCCR &= ~(LMEM_PSCCR_INVW0_MASK | LMEM_PSCCR_INVW1_MASK); - /* Now enable the system bus cache. */ - LMEM->PSCCR |= LMEM_PSCCR_ENCACHE_MASK; - - /* Enables the processor code bus to invalidate all lines in both ways. - and Initiate the processor code bus code cache command. */ - LMEM->PCCCR |= LMEM_PCCCR_INVW0_MASK | LMEM_PCCCR_INVW1_MASK | LMEM_PCCCR_GO_MASK; - /* Wait until the cache command completes. */ - while ((LMEM->PCCCR & LMEM_PCCCR_GO_MASK) != 0U) - { - } - /* As a precaution clear the bits to avoid inadvertently re-running this command. */ - LMEM->PCCCR &= ~(LMEM_PCCCR_INVW0_MASK | LMEM_PCCCR_INVW1_MASK); - /* Now enable the code bus cache. */ - LMEM->PCCCR |= LMEM_PCCCR_ENCACHE_MASK; -} -#endif - -void BOARD_SD_Pin_Config(uint32_t speed, uint32_t strength) -{ -} - -void BOARD_MMC_Pin_Config(uint32_t speed, uint32_t strength) -{ -} diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/board.h b/ports/mimxrt/boards/MIMXRT1170_EVK/board.h deleted file mode 100644 index c5d56e1cd193..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/board.h +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright 2020 NXP - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _BOARD_H_ -#define _BOARD_H_ - -// #include "clock_config.h" -#include "fsl_common.h" -#include "fsl_gpio.h" -#include "fsl_clock.h" -#include "pin_mux.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief The board name */ -#define BOARD_NAME "MIMXRT1170-EVK" -#ifndef DEBUG_CONSOLE_UART_INDEX -#define DEBUG_CONSOLE_UART_INDEX 1 -#endif - -/* The UART to use for debug messages. */ -// #define BOARD_DEBUG_UART_TYPE kSerialPort_Uart -// #define BOARD_DEBUG_UART_CLK_FREQ 24000000 - -/* Used when setting clock frequency for usb apps like MSC dev in bootloader */ -#define BOARD_USB_CLOCK_FREQ (24000000) - -#if DEBUG_CONSOLE_UART_INDEX == 1 -#define BOARD_DEBUG_UART_BASEADDR (uint32_t) LPUART1 -#define BOARD_DEBUG_UART_INSTANCE 1U -#define BOARD_UART_IRQ LPUART1_IRQn -#define BOARD_UART_IRQ_HANDLER LPUART1_IRQHandler -#elif DEBUG_CONSOLE_UART_INDEX == 2 -#define BOARD_DEBUG_UART_BASEADDR (uint32_t) LPUART2 -#define BOARD_DEBUG_UART_INSTANCE 2U -#define BOARD_UART_IRQ LPUART2_IRQn -#define BOARD_UART_IRQ_HANDLER LPUART2_IRQHandler -#elif DEBUG_CONSOLE_UART_INDEX == 12 -#define BOARD_DEBUG_UART_BASEADDR (uint32_t) LPUART12 -#define BOARD_DEBUG_UART_INSTANCE 12U -#define BOARD_UART_IRQ LPUART12_IRQn -#define BOARD_UART_IRQ_HANDLER LPUART12_IRQHandler -#else -#error "Unsupported UART" -#endif - -#ifndef BOARD_DEBUG_UART_BAUDRATE -#define BOARD_DEBUG_UART_BAUDRATE (115200U) -#endif /* BOARD_DEBUG_UART_BAUDRATE */ - -/* Definitions for eRPC MU transport layer */ -#if defined(FSL_FEATURE_MU_SIDE_A) -#define MU_BASE MUA -#define MU_IRQ MUA_IRQn -#define MU_IRQ_HANDLER MUA_IRQHandler -#endif -#if defined(FSL_FEATURE_MU_SIDE_B) -#define MU_BASE MUB -#define MU_IRQ MUB_IRQn -#define MU_IRQ_HANDLER MUB_IRQHandler -#endif -#define MU_IRQ_PRIORITY (2) - -/*! @brief The USER_LED used for board */ -#define LOGIC_LED_ON (0U) -#define LOGIC_LED_OFF (1U) -#ifndef BOARD_USER_LED_GPIO -#define BOARD_USER_LED_GPIO GPIO9 -#endif -#ifndef BOARD_USER_LED_GPIO_PIN -#define BOARD_USER_LED_GPIO_PIN (25U) -#endif - -#define USER_LED_INIT(output) \ - GPIO_PinWrite(BOARD_USER_LED_GPIO, BOARD_USER_LED_GPIO_PIN, output); \ - BOARD_USER_LED_GPIO->GDIR |= (1U << BOARD_USER_LED_GPIO_PIN) /*!< Enable target USER_LED */ -#define USER_LED_OFF() \ - GPIO_PortClear(BOARD_USER_LED_GPIO, 1U << BOARD_USER_LED_GPIO_PIN) /*!< Turn off target USER_LED */ -#define USER_LED_ON() GPIO_PortSet(BOARD_USER_LED_GPIO, 1U << BOARD_USER_LED_GPIO_PIN) /*!VID_MUX_CTRL.SET = VIDEO_MUX_VID_MUX_CTRL_MIPI_DSI_SEL_MASK; - #else - /* ELCDIF output to MIPI DSI. */ - VIDEO_MUX->VID_MUX_CTRL.CLR = VIDEO_MUX_VID_MUX_CTRL_MIPI_DSI_SEL_MASK; - #endif - - /* 1. Power on and isolation off. */ - PGMC_BPC4->BPC_POWER_CTRL |= (PGMC_BPC_BPC_POWER_CTRL_PSW_ON_SOFT_MASK | PGMC_BPC_BPC_POWER_CTRL_ISO_OFF_SOFT_MASK); - - /* 2. Assert MIPI reset. */ - IOMUXC_GPR->GPR62 &= - ~(IOMUXC_GPR_GPR62_MIPI_DSI_PCLK_SOFT_RESET_N_MASK | IOMUXC_GPR_GPR62_MIPI_DSI_ESC_SOFT_RESET_N_MASK | - IOMUXC_GPR_GPR62_MIPI_DSI_BYTE_SOFT_RESET_N_MASK | IOMUXC_GPR_GPR62_MIPI_DSI_DPI_SOFT_RESET_N_MASK); - - /* 3. Setup clock. */ - BOARD_InitMipiDsiClock(); - - /* 4. Deassert PCLK and ESC reset. */ - IOMUXC_GPR->GPR62 |= - (IOMUXC_GPR_GPR62_MIPI_DSI_PCLK_SOFT_RESET_N_MASK | IOMUXC_GPR_GPR62_MIPI_DSI_ESC_SOFT_RESET_N_MASK); - - /* 5. Configures peripheral. */ - BOARD_SetMipiDsiConfig(); - - /* 6. Deassert BYTE and DBI reset. */ - IOMUXC_GPR->GPR62 |= - (IOMUXC_GPR_GPR62_MIPI_DSI_BYTE_SOFT_RESET_N_MASK | IOMUXC_GPR_GPR62_MIPI_DSI_DPI_SOFT_RESET_N_MASK); - - /* 7. Configure the panel. */ - return BOARD_InitLcdPanel(); -} - -#if (DEMO_DISPLAY_CONTROLLER == DEMO_DISPLAY_CONTROLLER_LCDIFV2) -void LCDIFv2_IRQHandler(void) { - DC_FB_LCDIFV2_IRQHandler(&g_dc); -} -#else -void eLCDIF_IRQHandler(void) { - DC_FB_ELCDIF_IRQHandler(&g_dc); -} -#endif - -status_t BOARD_VerifyDisplayClockSource(void) { - status_t status; - uint32_t srcClkFreq; - - /* - * In this implementation, the SYSPLL2 (528M) clock is used as the source - * of LCDIFV2 pixel clock and MIPI DSI ESC clock. The OSC24M clock is used - * as the MIPI DSI DPHY PLL reference clock. This function checks the clock - * source are valid. OSC24M is always valid, so only verify the SYSPLL2. - */ - srcClkFreq = CLOCK_GetPllFreq(kCLOCK_PllSys2); - if (528 != (srcClkFreq / 1000000)) { - status = kStatus_Fail; - } else { - status = kStatus_Success; - } - - return status; -} - -status_t BOARD_PrepareDisplayController(void) { - status_t status; - - status = BOARD_VerifyDisplayClockSource(); - - if (status != kStatus_Success) { - PRINTF("Error: Invalid display clock source.\r\n"); - return status; - } - - BOARD_InitLcdifClock(); - - status = BOARD_InitDisplayInterface(); - - if (kStatus_Success == status) { - #if (DEMO_DISPLAY_CONTROLLER == DEMO_DISPLAY_CONTROLLER_LCDIFV2) - NVIC_ClearPendingIRQ(LCDIFv2_IRQn); - NVIC_SetPriority(LCDIFv2_IRQn, 3); - EnableIRQ(LCDIFv2_IRQn); - #else - NVIC_ClearPendingIRQ(eLCDIF_IRQn); - NVIC_SetPriority(eLCDIF_IRQn, 3); - EnableIRQ(eLCDIF_IRQn); - #endif - } - - return kStatus_Success; -} diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/display_support.h b/ports/mimxrt/boards/MIMXRT1170_EVK/display_support.h deleted file mode 100644 index a0573cb77842..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/display_support.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2019-2021 NXP - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _DISPLAY_SUPPORT_H_ -#define _DISPLAY_SUPPORT_H_ - -#include "fsl_dc_fb.h" - -#include "py/mphal.h" -#include "py/mpconfig.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -#define PRINTF(...) mp_printf(&mp_plat_print, "lvgl: " __VA_ARGS__) - -/* @TEST_ANCHOR */ - -#define DEMO_PANEL_RK055AHD091 0 /* 720 * 1280 */ -#define DEMO_PANEL_RK055IQH091 1 /* 540 * 960 */ -#define DEMO_PANEL_RK055MHD091 2 /* 720 * 1280 */ - -#define DEMO_DISPLAY_CONTROLLER_ELCDIF 0 -#define DEMO_DISPLAY_CONTROLLER_LCDIFV2 1 - -#ifndef DEMO_PANEL -#define DEMO_PANEL DEMO_PANEL_RK055MHD091 -#endif - -#ifndef DEMO_DISPLAY_CONTROLLER -/* Use LCDIFV2 by default, could use ELCDIF by changing this macro. */ -#define DEMO_DISPLAY_CONTROLLER DEMO_DISPLAY_CONTROLLER_LCDIFV2 -// #define DEMO_DISPLAY_CONTROLLER DEMO_DISPLAY_CONTROLLER_ELCDIF -#endif - -#define DEMO_BUFFER_FIXED_ADDRESS 0 - -#if DEMO_BUFFER_FIXED_ADDRESS -#define DEMO_BUFFER0_ADDR 0x80000000 -#define DEMO_BUFFER1_ADDR 0x80200000 -#endif - -/* - * Use the MIPI dumb panel - */ - -/* Definitions for the frame buffer. */ -#define DEMO_BUFFER_COUNT 2 /* 2 is enough for DPI interface display. */ - -#ifndef DEMO_USE_XRGB8888 -#define DEMO_USE_XRGB8888 0 -#endif - -#if DEMO_USE_XRGB8888 -#define DEMO_BUFFER_PIXEL_FORMAT kVIDEO_PixelFormatXRGB8888 -#define DEMO_BUFFER_BYTE_PER_PIXEL 4 -#else -#define DEMO_BUFFER_PIXEL_FORMAT kVIDEO_PixelFormatRGB565 -#define DEMO_BUFFER_BYTE_PER_PIXEL 2 -#endif - -#if ((DEMO_PANEL_RK055AHD091 == DEMO_PANEL) || (DEMO_PANEL_RK055MHD091 == DEMO_PANEL)) - -#define DEMO_PANEL_WIDTH (720) -#define DEMO_PANEL_HEIGHT (1280) - -#elif (DEMO_PANEL_RK055IQH091 == DEMO_PANEL) - -#define DEMO_PANEL_WIDTH (540) -#define DEMO_PANEL_HEIGHT (960) - -#endif - -#define DEMO_BUFFER_WIDTH DEMO_PANEL_WIDTH -// #define DEMO_BUFFER_HEIGHT (DEMO_PANEL_HEIGHT / 10) -#define DEMO_BUFFER_HEIGHT (DEMO_PANEL_HEIGHT) - -/* Where the frame buffer is shown in the screen. */ -#define DEMO_BUFFER_START_X 0U -#define DEMO_BUFFER_START_Y 0U - -#define DEMO_BUFFER_STRIDE_BYTE (DEMO_BUFFER_WIDTH * DEMO_BUFFER_BYTE_PER_PIXEL) -/* There is not frame buffer aligned requirement, consider the 64-bit AXI data - * bus width and 32-byte cache line size, the frame buffer alignment is set to - * 32 byte. - */ -#define FRAME_BUFFER_ALIGN 32 - -extern const dc_fb_t g_dc; - -/******************************************************************************* - * API - ******************************************************************************/ -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus */ - -status_t BOARD_PrepareDisplayController(void); -status_t BOARD_DeinitLcdPanel(void); - -#if defined(__cplusplus) -} -#endif /* __cplusplus */ - -#endif /* _DISPLAY_SUPPORT_H_ */ diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb.h b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb.h deleted file mode 100644 index a81b15b93311..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2019 NXP - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _FSL_DC_FB_H_ -#define _FSL_DC_FB_H_ - -#include "fsl_video_common.h" - -/*! - * @addtogroup dc_fb - * @{ - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief frame buffer information. */ -typedef struct _dc_fb_info -{ - uint16_t startX; /*!< The start position in the panel. */ - uint16_t startY; /*!< The start position in the panel. */ - uint16_t width; /*!< How many pixels in one line of the frame buffer.*/ - uint16_t height; /*!< How many lines in one frame buffer. */ - uint16_t strideBytes; /*!< Stride of the frame buffer */ - video_pixel_format_t pixelFormat; /*!< Pixel format of the frame buffer */ -} dc_fb_info_t; - -/*! @brief Display controller frame callback. */ -typedef void (*dc_fb_callback_t)(void *param, void *inactiveBuffer); - -/*! @brief Display controller. */ -typedef struct _dc_fb dc_fb_t; - -/*! @brief Display controller operations. */ -typedef struct _dc_fb_ops -{ - status_t (*init)(const dc_fb_t *dc); - status_t (*deinit)(const dc_fb_t *dc); - status_t (*enableLayer)(const dc_fb_t *dc, uint8_t layer); - status_t (*disableLayer)(const dc_fb_t *dc, uint8_t layer); - status_t (*setLayerConfig)(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo); - status_t (*getLayerDefaultConfig)(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo); - status_t (*setFrameBuffer)(const dc_fb_t *dc, uint8_t layer, void *frameBuffer); - uint32_t (*getProperty)(const dc_fb_t *dc); - void (*setCallback)(const dc_fb_t *dc, uint8_t layer, dc_fb_callback_t callback, void *param); -} dc_fb_ops_t; - -/*! @brief Display controller property. */ -enum _dc_fb_property -{ - kDC_FB_ReserveFrameBuffer = (1 << 0), /*< One frame buffer is always used as the DC active buffer. */ -}; - -/*! @brief Display controller driver handle. */ -struct _dc_fb -{ - const dc_fb_ops_t *ops; /* Display controller operations. */ - void *prvData; /* Private data for the display controller. */ - const void *config; /* Configuration for the display controller. */ -}; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif - -#if defined(__cplusplus) -} -#endif - -/*! @} */ - -#endif /* _FSL_DC_FB_H_ */ diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_elcdif.c b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_elcdif.c deleted file mode 100644 index 5411b18e3c9b..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_elcdif.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright 2019-2020 NXP - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "fsl_dc_fb_elcdif.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -const dc_fb_ops_t g_dcFbOpsElcdif = { - .init = DC_FB_ELCDIF_Init, - .deinit = DC_FB_ELCDIF_Deinit, - .enableLayer = DC_FB_ELCDIF_EnableLayer, - .disableLayer = DC_FB_ELCDIF_DisableLayer, - .setLayerConfig = DC_FB_ELCDIF_SetLayerConfig, - .getLayerDefaultConfig = DC_FB_ELCDIF_GetLayerDefaultConfig, - .setFrameBuffer = DC_FB_ELCDIF_SetFrameBuffer, - .getProperty = DC_FB_ELCDIF_GetProperty, - .setCallback = DC_FB_ELCDIF_SetCallback, -}; - -typedef struct -{ - video_pixel_format_t videoFormat; - elcdif_pixel_format_t elcdifFormat; -} dc_fb_elcdif_pixel_foramt_map_t; - -/******************************************************************************* - * Prototypes - ******************************************************************************/ -static status_t DC_FB_ELCDIF_GetPixelFormat(video_pixel_format_t input, elcdif_pixel_format_t *output); - -/******************************************************************************* - * Variables - ******************************************************************************/ -static const dc_fb_elcdif_pixel_foramt_map_t s_elcdifPixelFormatMap[] = { - {kVIDEO_PixelFormatRGB565, kELCDIF_PixelFormatRGB565}, - { - kVIDEO_PixelFormatXRGB8888, - kELCDIF_PixelFormatXRGB8888, - }, - { - kVIDEO_PixelFormatRGB888, - kELCDIF_PixelFormatRGB888, - }}; - -/******************************************************************************* - * Code - ******************************************************************************/ -static status_t DC_FB_ELCDIF_GetPixelFormat(video_pixel_format_t input, elcdif_pixel_format_t *output) -{ - uint8_t i; - - for (i = 0; i < ARRAY_SIZE(s_elcdifPixelFormatMap); i++) - { - if (s_elcdifPixelFormatMap[i].videoFormat == input) - { - *output = s_elcdifPixelFormatMap[i].elcdifFormat; - return kStatus_Success; - } - } - - return kStatus_InvalidArgument; -} - -status_t DC_FB_ELCDIF_Init(const dc_fb_t *dc) -{ - const dc_fb_elcdif_config_t *dcConfig; - elcdif_rgb_mode_config_t elcdifConfig = {0}; - - dc_fb_elcdif_handle_t *dcHandle = dc->prvData; - - if (0U == dcHandle->initTimes++) - { - dcConfig = (const dc_fb_elcdif_config_t *)(dc->config); - - elcdifConfig.panelWidth = dcConfig->width; - elcdifConfig.panelHeight = dcConfig->height; - elcdifConfig.hsw = (uint8_t)dcConfig->hsw; - elcdifConfig.hfp = (uint8_t)dcConfig->hfp; - elcdifConfig.hbp = (uint8_t)dcConfig->hbp; - elcdifConfig.vsw = (uint8_t)dcConfig->vsw; - elcdifConfig.vfp = (uint8_t)dcConfig->vfp; - elcdifConfig.vbp = (uint8_t)dcConfig->vbp; - elcdifConfig.bufferAddr = 0; - elcdifConfig.dataBus = dcConfig->dataBus; - elcdifConfig.pixelFormat = DC_FB_ELCDIF_DEFAULT_PIXEL_FORMAT_ELCDIF; - elcdifConfig.polarityFlags = dcConfig->polarityFlags; - - dcHandle->height = dcConfig->height; - dcHandle->width = dcConfig->width; - dcHandle->elcdif = dcConfig->elcdif; - - ELCDIF_RgbModeInit(dcHandle->elcdif, &elcdifConfig); - } - - return kStatus_Success; -} - -status_t DC_FB_ELCDIF_Deinit(const dc_fb_t *dc) -{ - dc_fb_elcdif_handle_t *dcHandle = dc->prvData; - - if (dcHandle->initTimes > 0U) - { - if ((--dcHandle->initTimes) == 0U) - { - ELCDIF_Deinit(dcHandle->elcdif); - } - } - - return kStatus_Success; -} - -status_t DC_FB_ELCDIF_EnableLayer(const dc_fb_t *dc, uint8_t layer) -{ - assert(layer < DC_FB_ELCDIF_MAX_LAYER); - - status_t status = kStatus_Success; - dc_fb_elcdif_handle_t *dcHandle = dc->prvData; - - /* If the layer is already started. */ - if (!dcHandle->layers[layer].enabled) - { - /* Must have valid frame buffer to show. */ - if (dcHandle->layers[layer].activeBuffer == NULL) - { - status = kStatus_Fail; - } - else - { - ELCDIF_RgbModeStart(dcHandle->elcdif); - dcHandle->layers[layer].enabled = true; - ELCDIF_EnableInterrupts(dcHandle->elcdif, (uint32_t)kELCDIF_CurFrameDoneInterruptEnable); - } - } - - return status; -} - -status_t DC_FB_ELCDIF_DisableLayer(const dc_fb_t *dc, uint8_t layer) -{ - assert(layer < DC_FB_ELCDIF_MAX_LAYER); - - dc_fb_elcdif_handle_t *dcHandle = dc->prvData; - - if (dcHandle->layers[layer].enabled) - { - ELCDIF_RgbModeStop(dcHandle->elcdif); - dcHandle->layers[layer].enabled = false; - ELCDIF_DisableInterrupts(dcHandle->elcdif, (uint32_t)kELCDIF_CurFrameDoneInterruptEnable); - } - - return kStatus_Success; -} - -status_t DC_FB_ELCDIF_SetLayerConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo) -{ - assert(layer < DC_FB_ELCDIF_MAX_LAYER); - - elcdif_pixel_format_t pixelFormat; - status_t status; - - dc_fb_elcdif_handle_t *dcHandle = (dc_fb_elcdif_handle_t *)(dc->prvData); - - assert(fbInfo->startX == 0U); - assert(fbInfo->startY == 0U); - assert(fbInfo->width == dcHandle->width); - assert(fbInfo->height == dcHandle->height); - assert(fbInfo->strideBytes == VIDEO_GetPixelSizeBits(fbInfo->pixelFormat) * dcHandle->width / 8U); - - status = DC_FB_ELCDIF_GetPixelFormat(fbInfo->pixelFormat, &pixelFormat); - if (kStatus_Success != status) - { - return status; - } - - ELCDIF_RgbModeSetPixelFormat(dcHandle->elcdif, pixelFormat); - - return kStatus_Success; -} - -status_t DC_FB_ELCDIF_GetLayerDefaultConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo) -{ - assert(layer < DC_FB_ELCDIF_MAX_LAYER); - - dc_fb_elcdif_handle_t *dcHandle = (dc_fb_elcdif_handle_t *)(dc->prvData); - - fbInfo->startX = 0; - fbInfo->startY = 0; - fbInfo->width = dcHandle->width; - fbInfo->height = dcHandle->height; - fbInfo->strideBytes = 2U * dcHandle->width; - fbInfo->pixelFormat = DC_FB_ELCDIF_DEFAULT_PIXEL_FORMAT; - - return kStatus_Success; -} - -status_t DC_FB_ELCDIF_SetFrameBuffer(const dc_fb_t *dc, uint8_t layer, void *frameBuffer) -{ - assert(layer < DC_FB_ELCDIF_MAX_LAYER); - dc_fb_elcdif_handle_t *dcHandle = dc->prvData; - - ELCDIF_SetNextBufferAddr(dcHandle->elcdif, (uint32_t)(uint8_t *)frameBuffer); - dcHandle->layers[layer].inactiveBuffer = frameBuffer; - - /* - * If the layer is not started, set the current buffer and next buffer to - * new frame buffer, there is not pending frame. - * If the layer already started, only set the next buffer, and the new frameBuffer - * is pending until current buffer switched out. - */ - if (!dcHandle->layers[layer].enabled) - { - dcHandle->elcdif->CUR_BUF = ELCDIF_ADDR_CPU_2_IP((uint32_t)(uint8_t *)frameBuffer); - dcHandle->layers[layer].activeBuffer = frameBuffer; - } - else - { - dcHandle->layers[layer].framePending = true; - } - - return kStatus_Success; -} - -void DC_FB_ELCDIF_SetCallback(const dc_fb_t *dc, uint8_t layer, dc_fb_callback_t callback, void *param) -{ - assert(layer < DC_FB_ELCDIF_MAX_LAYER); - dc_fb_elcdif_handle_t *dcHandle = dc->prvData; - - dcHandle->layers[layer].callback = callback; - dcHandle->layers[layer].cbParam = param; -} - -uint32_t DC_FB_ELCDIF_GetProperty(const dc_fb_t *dc) -{ - return (uint32_t)kDC_FB_ReserveFrameBuffer; -} - -void DC_FB_ELCDIF_IRQHandler(const dc_fb_t *dc) -{ - dc_fb_elcdif_handle_t *dcHandle = dc->prvData; - dc_fb_elcdif_layer_t *layer; - void *oldActiveBuffer; - ELCDIF_ClearInterruptStatus(dcHandle->elcdif, (uint32_t)kELCDIF_CurFrameDone); - - for (uint8_t i = 0; i < DC_FB_ELCDIF_MAX_LAYER; i++) - { - if (dcHandle->layers[i].framePending) - { - layer = &dcHandle->layers[i]; - - oldActiveBuffer = layer->activeBuffer; - layer->activeBuffer = layer->inactiveBuffer; - dcHandle->layers[i].framePending = false; - - layer->callback(layer->cbParam, oldActiveBuffer); - } - } -} diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_elcdif.h b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_elcdif.h deleted file mode 100644 index 09be21405227..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_elcdif.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2019-2020 NXP - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _FSL_DC_FB_ELCDIF_H_ -#define _FSL_DC_FB_ELCDIF_H_ - -#include "fsl_dc_fb.h" -#include "fsl_elcdif.h" - -/* - * Change log: - * - * 1.0.1 - * - Fixed MISRA-C 2012 issues. - * - * 1.0.0 - * - Initial version - */ - -/*! - * @addtogroup dc_fb_elcdif - * @{ - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -#define DC_FB_ELCDIF_MAX_LAYER 1U /* Only support one layer currently. */ -#define DC_FB_ELCDIF_DEFAULT_PIXEL_FORMAT kVIDEO_PixelFormatRGB565 -#define DC_FB_ELCDIF_DEFAULT_PIXEL_FORMAT_ELCDIF kELCDIF_PixelFormatRGB565 - -/*! @brief Data for ELCDIF display controller layer. */ -typedef struct _dc_fb_elcdif_layer -{ - bool enabled; /*!< The layer is enabled. */ - volatile bool framePending; /*!< New frame pending. */ - void *activeBuffer; /*!< The frame buffer which is shown. */ - void *inactiveBuffer; /*!< The frame buffer which will be shown. */ - dc_fb_callback_t callback; /*!< Callback for buffer switch off. */ - void *cbParam; /*!< Callback parameter. */ -} dc_fb_elcdif_layer_t; - -/*! @brief Data for ELCDIF display controller driver handle. */ -typedef struct _dc_fb_elcdif_handle -{ - LCDIF_Type *elcdif; /*!< eLCDIF peripheral. */ - uint8_t initTimes; /*!< How many times the DC is initialized. */ - uint16_t height; /*!< Panel height. */ - uint16_t width; /*!< Panel width. */ - dc_fb_elcdif_layer_t layers[DC_FB_ELCDIF_MAX_LAYER]; /*!< Information of the layer. */ -} dc_fb_elcdif_handle_t; - -/*! @brief Configuration for ELCDIF display controller driver handle. */ -typedef struct _dc_fb_elcdif_config -{ - LCDIF_Type *elcdif; /*!< ELCDIF peripheral. */ - uint16_t width; /*!< Width of the panel. */ - uint16_t height; /*!< Height of the panel. */ - uint16_t hsw; /*!< HSYNC pulse width. */ - uint16_t hfp; /*!< Horizontal front porch. */ - uint16_t hbp; /*!< Horizontal back porch. */ - uint16_t vsw; /*!< VSYNC pulse width. */ - uint16_t vfp; /*!< Vertical front porch. */ - uint16_t vbp; /*!< Vertical back porch. */ - uint32_t polarityFlags; /*!< Control flags, OR'ed value of @ref _elcdif_polarity_flags. */ - elcdif_lcd_data_bus_t dataBus; /*!< LCD data bus. */ -} dc_fb_elcdif_config_t; - -extern const dc_fb_ops_t g_dcFbOpsElcdif; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif - -status_t DC_FB_ELCDIF_Init(const dc_fb_t *dc); -status_t DC_FB_ELCDIF_Deinit(const dc_fb_t *dc); -status_t DC_FB_ELCDIF_EnableLayer(const dc_fb_t *dc, uint8_t layer); -status_t DC_FB_ELCDIF_DisableLayer(const dc_fb_t *dc, uint8_t layer); -status_t DC_FB_ELCDIF_SetLayerConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo); -status_t DC_FB_ELCDIF_GetLayerDefaultConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo); -status_t DC_FB_ELCDIF_SetFrameBuffer(const dc_fb_t *dc, uint8_t layer, void *frameBuffer); -uint32_t DC_FB_ELCDIF_GetProperty(const dc_fb_t *dc); -void DC_FB_ELCDIF_SetCallback(const dc_fb_t *dc, uint8_t layer, dc_fb_callback_t callback, void *param); -void DC_FB_ELCDIF_IRQHandler(const dc_fb_t *dc); - -#if defined(__cplusplus) -} -#endif - -/*! @} */ - -#endif /* _FSL_DC_FB_ELCDIF_H_ */ diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_lcdifv2.c b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_lcdifv2.c deleted file mode 100644 index 8f23786b62c0..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_lcdifv2.c +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (c) 2019-2020, 2021 NXP - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "fsl_dc_fb_lcdifv2.h" -#if defined(SDK_OS_FREE_RTOS) -#include "FreeRTOS.h" -#include "task.h" -#endif - -/******************************************************************************* - * Definitions - ******************************************************************************/ -const dc_fb_ops_t g_dcFbOpsLcdifv2 = { - .init = DC_FB_LCDIFV2_Init, - .deinit = DC_FB_LCDIFV2_Deinit, - .enableLayer = DC_FB_LCDIFV2_EnableLayer, - .disableLayer = DC_FB_LCDIFV2_DisableLayer, - .setLayerConfig = DC_FB_LCDIFV2_SetLayerConfig, - .getLayerDefaultConfig = DC_FB_LCDIFV2_GetLayerDefaultConfig, - .setFrameBuffer = DC_FB_LCDIFV2_SetFrameBuffer, - .getProperty = DC_FB_LCDIFV2_GetProperty, - .setCallback = DC_FB_LCDIFV2_SetCallback, -}; - -typedef struct -{ - video_pixel_format_t videoFormat; - lcdifv2_pixel_format_t lcdifv2Format; -} dc_fb_lcdifv2_pixel_foramt_map_t; - -/******************************************************************************* - * Prototypes - ******************************************************************************/ -static status_t DC_FB_LCDIFV2_GetPixelFormat(video_pixel_format_t input, lcdifv2_pixel_format_t *output); - -/******************************************************************************* - * Variables - ******************************************************************************/ -static const dc_fb_lcdifv2_pixel_foramt_map_t s_lcdifv2PixelFormatMap[] = { - {kVIDEO_PixelFormatRGB565, kLCDIFV2_PixelFormatRGB565}, - {kVIDEO_PixelFormatRGB888, kLCDIFV2_PixelFormatRGB888}, - {kVIDEO_PixelFormatXRGB8888, kLCDIFV2_PixelFormatARGB8888}, - {kVIDEO_PixelFormatXBGR8888, kLCDIFV2_PixelFormatABGR8888}, - {kVIDEO_PixelFormatLUT8, kLCDIFV2_PixelFormatIndex8BPP}, - {kVIDEO_PixelFormatXRGB4444, kLCDIFV2_PixelFormatARGB4444}, - {kVIDEO_PixelFormatXRGB1555, kLCDIFV2_PixelFormatARGB1555}}; - -/******************************************************************************* - * Code - ******************************************************************************/ -static status_t DC_FB_LCDIFV2_GetPixelFormat(video_pixel_format_t input, lcdifv2_pixel_format_t *output) -{ - uint8_t i; - - for (i = 0; i < ARRAY_SIZE(s_lcdifv2PixelFormatMap); i++) - { - if (s_lcdifv2PixelFormatMap[i].videoFormat == input) - { - *output = s_lcdifv2PixelFormatMap[i].lcdifv2Format; - return kStatus_Success; - } - } - - return kStatus_InvalidArgument; -} - -status_t DC_FB_LCDIFV2_Init(const dc_fb_t *dc) -{ - status_t status = kStatus_Success; - const dc_fb_lcdifv2_config_t *dcConfig; - - lcdifv2_display_config_t lcdifv2Config = {0}; - - dc_fb_lcdifv2_handle_t *dcHandle = dc->prvData; - - if (0U == dcHandle->initTimes++) - { - dcConfig = (const dc_fb_lcdifv2_config_t *)(dc->config); - - LCDIFV2_DisplayGetDefaultConfig(&lcdifv2Config); - - lcdifv2Config.panelWidth = dcConfig->width; - lcdifv2Config.panelHeight = dcConfig->height; - lcdifv2Config.hsw = (uint8_t)dcConfig->hsw; - lcdifv2Config.hfp = (uint8_t)dcConfig->hfp; - lcdifv2Config.hbp = (uint8_t)dcConfig->hbp; - lcdifv2Config.vsw = (uint8_t)dcConfig->vsw; - lcdifv2Config.vfp = (uint8_t)dcConfig->vfp; - lcdifv2Config.vbp = (uint8_t)dcConfig->vbp; - lcdifv2Config.polarityFlags = dcConfig->polarityFlags; - lcdifv2Config.lineOrder = dcConfig->lineOrder; - - dcHandle->height = dcConfig->height; - dcHandle->width = dcConfig->width; - dcHandle->lcdifv2 = dcConfig->lcdifv2; - dcHandle->domain = dcConfig->domain; - - LCDIFV2_Init(dcHandle->lcdifv2); - - LCDIFV2_SetDisplayConfig(dcHandle->lcdifv2, &lcdifv2Config); - - LCDIFV2_EnableInterrupts(dcHandle->lcdifv2, dcHandle->domain, (uint32_t)kLCDIFV2_VerticalBlankingInterrupt); - - LCDIFV2_EnableDisplay(dcHandle->lcdifv2, true); - } - - return status; -} - -status_t DC_FB_LCDIFV2_Deinit(const dc_fb_t *dc) -{ - dc_fb_lcdifv2_handle_t *dcHandle = dc->prvData; - - if (dcHandle->initTimes > 0U) - { - if (--dcHandle->initTimes == 0U) - { - LCDIFV2_DisableInterrupts(dcHandle->lcdifv2, dcHandle->domain, - (uint32_t)kLCDIFV2_VerticalBlankingInterrupt); - LCDIFV2_Deinit(dcHandle->lcdifv2); - } - } - - return kStatus_Success; -} - -status_t DC_FB_LCDIFV2_EnableLayer(const dc_fb_t *dc, uint8_t layer) -{ - assert(layer < DC_FB_LCDIFV2_MAX_LAYER); - - status_t status = kStatus_Success; - dc_fb_lcdifv2_handle_t *dcHandle = dc->prvData; - - /* If the layer is not started. */ - if (!dcHandle->layers[layer].enabled) - { - LCDIFV2_SetLayerBackGroundColor(dcHandle->lcdifv2, layer, 0U); - LCDIFV2_EnableLayer(dcHandle->lcdifv2, layer, true); - LCDIFV2_TriggerLayerShadowLoad(dcHandle->lcdifv2, layer); - dcHandle->layers[layer].shadowLoadPending = true; - - while (true == dcHandle->layers[layer].shadowLoadPending) - { -#if defined(SDK_OS_FREE_RTOS) - vTaskDelay(1); -#endif - } - - dcHandle->layers[layer].activeBuffer = dcHandle->layers[layer].inactiveBuffer; - dcHandle->layers[layer].enabled = true; - } - - return status; -} - -status_t DC_FB_LCDIFV2_DisableLayer(const dc_fb_t *dc, uint8_t layer) -{ - assert(layer < DC_FB_LCDIFV2_MAX_LAYER); - - dc_fb_lcdifv2_handle_t *dcHandle = dc->prvData; - - if (dcHandle->layers[layer].enabled) - { - LCDIFV2_EnableLayer(dcHandle->lcdifv2, layer, false); - LCDIFV2_TriggerLayerShadowLoad(dcHandle->lcdifv2, layer); - dcHandle->layers[layer].enabled = false; - } - - return kStatus_Success; -} - -status_t DC_FB_LCDIFV2_SetLayerConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo) -{ - assert(layer < DC_FB_LCDIFV2_MAX_LAYER); - - lcdifv2_buffer_config_t bufferConfig = {0}; - lcdifv2_pixel_format_t pixelFormat; - LCDIFV2_Type *lcdifv2; - status_t status; - - dc_fb_lcdifv2_handle_t *dcHandle = (dc_fb_lcdifv2_handle_t *)(dc->prvData); - - lcdifv2 = dcHandle->lcdifv2; - - status = DC_FB_LCDIFV2_GetPixelFormat(fbInfo->pixelFormat, &pixelFormat); - if (kStatus_Success != status) - { - return status; - } - - LCDIFV2_SetLayerSize(lcdifv2, layer, fbInfo->width, fbInfo->height); - LCDIFV2_SetLayerOffset(lcdifv2, layer, fbInfo->startX, fbInfo->startY); - - bufferConfig.strideBytes = fbInfo->strideBytes; - bufferConfig.pixelFormat = pixelFormat; - LCDIFV2_SetLayerBufferConfig(lcdifv2, layer, &bufferConfig); - - return kStatus_Success; -} - -status_t DC_FB_LCDIFV2_GetLayerDefaultConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo) -{ - assert(layer < DC_FB_LCDIFV2_MAX_LAYER); - - dc_fb_lcdifv2_handle_t *dcHandle = (dc_fb_lcdifv2_handle_t *)(dc->prvData); - - fbInfo->startX = 0; - fbInfo->startY = 0; - fbInfo->width = dcHandle->width; - fbInfo->height = dcHandle->height; - fbInfo->strideBytes = DC_FB_LCDIFV2_DEFAULT_BYTE_PER_PIXEL * dcHandle->width; - fbInfo->pixelFormat = DC_FB_LCDIFV2_DEFAULT_PIXEL_FORMAT; - - return kStatus_Success; -} - -status_t DC_FB_LCDIFV2_SetFrameBuffer(const dc_fb_t *dc, uint8_t layer, void *frameBuffer) -{ - assert(layer < DC_FB_LCDIFV2_MAX_LAYER); - dc_fb_lcdifv2_handle_t *dcHandle = dc->prvData; - - LCDIFV2_SetLayerBufferAddr(dcHandle->lcdifv2, layer, (uint32_t)(uint8_t *)frameBuffer); - dcHandle->layers[layer].inactiveBuffer = frameBuffer; - - if (dcHandle->layers[layer].enabled) - { - LCDIFV2_TriggerLayerShadowLoad(dcHandle->lcdifv2, layer); - dcHandle->layers[layer].shadowLoadPending = true; - dcHandle->layers[layer].framePending = true; - } - else - { - } - - return kStatus_Success; -} - -void DC_FB_LCDIFV2_SetCallback(const dc_fb_t *dc, uint8_t layer, dc_fb_callback_t callback, void *param) -{ - assert(layer < DC_FB_LCDIFV2_MAX_LAYER); - dc_fb_lcdifv2_handle_t *dcHandle = dc->prvData; - - dcHandle->layers[layer].callback = callback; - dcHandle->layers[layer].cbParam = param; -} - -uint32_t DC_FB_LCDIFV2_GetProperty(const dc_fb_t *dc) -{ - return (uint32_t)kDC_FB_ReserveFrameBuffer; -} - -void DC_FB_LCDIFV2_IRQHandler(const dc_fb_t *dc) -{ - uint32_t intStatus; - dc_fb_lcdifv2_handle_t *dcHandle = dc->prvData; - dc_fb_lcdifv2_layer_t *layer; - void *oldActiveBuffer; - - intStatus = LCDIFV2_GetInterruptStatus(dcHandle->lcdifv2, dcHandle->domain); - LCDIFV2_ClearInterruptStatus(dcHandle->lcdifv2, dcHandle->domain, intStatus); - - if (0U == (intStatus & (uint32_t)kLCDIFV2_VerticalBlankingInterrupt)) - { - return; - } - - for (uint8_t i = 0; i < DC_FB_LCDIFV2_MAX_LAYER; i++) - { - if (dcHandle->layers[i].shadowLoadPending) - { - dcHandle->layers[i].shadowLoadPending = false; - } - - if (dcHandle->layers[i].framePending) - { - layer = &dcHandle->layers[i]; - - oldActiveBuffer = layer->activeBuffer; - layer->activeBuffer = layer->inactiveBuffer; - dcHandle->layers[i].framePending = false; - - layer->callback(layer->cbParam, oldActiveBuffer); - } - } -} diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_lcdifv2.h b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_lcdifv2.h deleted file mode 100644 index 190437e54d6c..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_dc_fb_lcdifv2.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2019-2021 NXP - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _FSL_DC_FB_LCDIFV2_H_ -#define _FSL_DC_FB_LCDIFV2_H_ - -#include "fsl_dc_fb.h" -#include "fsl_lcdifv2.h" - -/* - * Change log: - * - * 1.0.2 - * - Add more pixel format support. - * - * 1.0.1 - * - Fix MISRA-C 2012 issues. - * - * 1.0.0 - * - Initial version - */ - -/*! - * @addtogroup dc_fb_lcdifv2 - * @{ - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -#define DC_FB_LCDIFV2_MAX_LAYER ((uint32_t)LCDIFV2_LAYER_COUNT) -#define DC_FB_LCDIFV2_DEFAULT_BUF_PER_LAYER 3U -#define DC_FB_LCDIFV2_DEFAULT_PIXEL_FORMAT kVIDEO_PixelFormatRGB565 -#define DC_FB_LCDIFV2_DEFAULT_PIXEL_FORMAT_LCDIFV2 kLCDIFV2_PixelFormatRGB565 -#define DC_FB_LCDIFV2_DEFAULT_BYTE_PER_PIXEL 2U - -/*! @brief Data for LCDIFV2 display controller layer. */ -typedef struct _dc_fb_lcdifv2_layer -{ - bool enabled; /*!< The layer is enabled. */ - volatile bool framePending; /*!< New frame pending. */ - volatile bool shadowLoadPending; /*!< Shadow load pending. */ - void *activeBuffer; /*!< The frame buffer which is shown. */ - void *inactiveBuffer; /*!< The frame buffer which will be shown. */ - dc_fb_callback_t callback; /*!< Callback for buffer switch off. */ - void *cbParam; /*!< Callback parameter. */ -} dc_fb_lcdifv2_layer_t; - -/*! @brief Data for LCDIFV2 display controller driver handle. */ -typedef struct _dc_fb_lcdifv2_handle -{ - LCDIFV2_Type *lcdifv2; /*!< LCDIFV2 peripheral. */ - uint8_t initTimes; /*!< How many times the DC is initialized. */ - uint16_t height; /*!< Panel height. */ - uint16_t width; /*!< Panel width. */ - uint8_t domain; /*!< Domain used for interrupt. */ - dc_fb_lcdifv2_layer_t layers[DC_FB_LCDIFV2_MAX_LAYER]; /*!< Information of the layer. */ -} dc_fb_lcdifv2_handle_t; - -/*! @brief Configuration for LCDIFV2 display controller driver handle. */ -typedef struct _dc_fb_lcdifv2_config -{ - LCDIFV2_Type *lcdifv2; /*!< LCDIFV2 peripheral. */ - uint16_t width; /*!< Width of the panel. */ - uint16_t height; /*!< Height of the panel. */ - uint16_t hsw; /*!< HSYNC pulse width. */ - uint16_t hfp; /*!< Horizontal front porch. */ - uint16_t hbp; /*!< Horizontal back porch. */ - uint16_t vsw; /*!< VSYNC pulse width. */ - uint16_t vfp; /*!< Vertical front porch. */ - uint16_t vbp; /*!< Vertical back porch. */ - uint32_t polarityFlags; /*!< Control flags, OR'ed value of @ref _lcdifv2_polarity_flags. */ - lcdifv2_line_order_t lineOrder; /*!< Line order. */ - uint8_t domain; /*!< Domain used to for interrupt. */ -} dc_fb_lcdifv2_config_t; - -extern const dc_fb_ops_t g_dcFbOpsLcdifv2; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif - -status_t DC_FB_LCDIFV2_Init(const dc_fb_t *dc); -status_t DC_FB_LCDIFV2_Deinit(const dc_fb_t *dc); -status_t DC_FB_LCDIFV2_EnableLayer(const dc_fb_t *dc, uint8_t layer); -status_t DC_FB_LCDIFV2_DisableLayer(const dc_fb_t *dc, uint8_t layer); -status_t DC_FB_LCDIFV2_SetLayerConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo); -status_t DC_FB_LCDIFV2_GetLayerDefaultConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo); -status_t DC_FB_LCDIFV2_SetFrameBuffer(const dc_fb_t *dc, uint8_t layer, void *frameBuffer); -uint32_t DC_FB_LCDIFV2_GetProperty(const dc_fb_t *dc); -void DC_FB_LCDIFV2_SetCallback(const dc_fb_t *dc, uint8_t layer, dc_fb_callback_t callback, void *param); -void DC_FB_LCDIFV2_IRQHandler(const dc_fb_t *dc); - -#if defined(__cplusplus) -} -#endif - -/*! @} */ - -#endif /* _FSL_DC_FB_LCDIFV2_H_ */ diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_display.h b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_display.h deleted file mode 100644 index c285cf7ab6d8..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_display.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2017-2018 NXP - * All rights reserved. - * - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _FSL_DISPLAY_H_ -#define _FSL_DISPLAY_H_ - -#include "fsl_video_common.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/*! @brief Display common configuration. */ -typedef struct _display_common_cfg_t -{ - uint16_t width; - uint16_t height; - uint16_t hsw; /*!< HSYNC pulse width. */ - uint16_t hfp; /*!< Horizontal front porch. */ - uint16_t hbp; /*!< Horizontal back porch. */ - uint16_t vsw; /*!< VSYNC pulse width. */ - uint16_t vfp; /*!< Vrtical front porch. */ - uint16_t vbp; /*!< Vertical back porch. */ - uint32_t clock; /* !< pixecl clock in kHz>. */ -} display_common_cfg; - -/*! @brief Display control flags. */ -enum _display_flags -{ - kDISPLAY_VsyncActiveLow = 0U, /*!< VSYNC active low. */ - kDISPLAY_VsyncActiveHigh = (1U << 0U), /*!< VSYNC active high. */ - kDISPLAY_HsyncActiveLow = 0U, /*!< HSYNC active low. */ - kDISPLAY_HsyncActiveHigh = (1U << 1U), /*!< HSYNC active high. */ - kDISPLAY_DataEnableActiveHigh = 0U, /*!< Data enable line active high. */ - kDISPLAY_DataEnableActiveLow = (1U << 2U), /*!< Data enable line active low. */ - kDISPLAY_DataLatchOnRisingEdge = 0U, /*!< Latch data on rising clock edge. */ - kDISPLAY_DataLatchOnFallingEdge = (1U << 3U), /*!< Latch data on falling clock edge. */ -}; - -/*! @brief Display configuration. */ -typedef struct _display_config -{ - uint32_t resolution; /*!< Resolution, see @ref video_resolution_t and @ref FSL_VIDEO_RESOLUTION. */ - uint16_t hsw; /*!< HSYNC pulse width. */ - uint16_t hfp; /*!< Horizontal front porch. */ - uint16_t hbp; /*!< Horizontal back porch. */ - uint16_t vsw; /*!< VSYNC pulse width. */ - uint16_t vfp; /*!< Vrtical front porch. */ - uint16_t vbp; /*!< Vertical back porch. */ - uint32_t controlFlags; /*!< Control flags, OR'ed value of @ref _display_flags. */ - uint8_t dsiLanes; /*!< MIPI DSI data lanes number. */ - uint32_t pixelClock_Hz; /*!< Pixel clock in Hz. */ - video_pixel_format_t pixelFormat; /*!< Pixel format. */ -} display_config_t; - -typedef struct _display_handle display_handle_t; - -/*! @brief Display device operations. */ -typedef struct _display_operations -{ - status_t (*init)(display_handle_t *handle, const display_config_t *config); /*!< Init the device. */ - status_t (*deinit)(display_handle_t *handle); /*!< Deinit the device. */ - status_t (*start)(display_handle_t *handle); /*!< Start the device. */ - status_t (*stop)(display_handle_t *handle); /*!< Stop the device. */ -} display_operations_t; - -/*! @brief Display handle. */ -struct _display_handle -{ - const void *resource; - const display_operations_t *ops; - uint16_t width; - uint16_t height; - video_pixel_format_t pixelFormat; -}; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif - -/*! - * @brief Initializes the display device with user defined configuration. - * - * @param handle Display device handle. - * @param config Pointer to the user-defined configuration structure. - * @return Returns @ref kStatus_Success if initialize success, otherwise returns - * error code. - */ -static inline status_t DISPLAY_Init(display_handle_t *handle, const display_config_t *config) -{ - return handle->ops->init(handle, config); -} - -/*! - * @brief Deinitialize the display device. - * - * @param handle Display device handle. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -static inline status_t DISPLAY_Deinit(display_handle_t *handle) -{ - return handle->ops->deinit(handle); -} - -/*! - * @brief Start the display device. - * - * @param handle Display device handle. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -static inline status_t DISPLAY_Start(display_handle_t *handle) -{ - return handle->ops->start(handle); -} - -/*! - * @brief Stop the display device. - * - * @param handle Display device handle. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -static inline status_t DISPLAY_Stop(display_handle_t *handle) -{ - return handle->ops->stop(handle); -} - -#if defined(__cplusplus) -} -#endif - -#endif /* _FSL_DISPLAY_H_ */ diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_gt911.c b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_gt911.c deleted file mode 100644 index 38912aa4df43..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_gt911.c +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Copyright 2019-2020 NXP - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "fsl_gt911.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief GT911 I2C address. */ -#define GT911_I2C_ADDRESS0 (0x5D) -#define GT911_I2C_ADDRESS1 (0x14) - -#define GT911_REG_ADDR_SIZE 2 - -/*! @brief GT911 registers. */ -#define GT911_REG_ID 0x8140U -#define GT911_CONFIG_ADDR 0x8047U -#define GT911_REG_XL 0x8048U -#define GT911_REG_XH 0x8049U -#define GT911_REG_YL 0x804AU -#define GT911_REG_YH 0x804BU -#define GT911_REG_TOUCH_NUM 0x804CU -#define GT911_REG_CONFIG_VERSION 0x8047U -#define GT911_REG_MODULE_SWITCH1 0x804DU -#define GT911_REG_STAT 0x814EU -#define GT911_REG_FIRST_POINT 0x814FU - -#define GT911_STAT_BUF_MASK (1U << 7U) -#define GT911_STAT_POINT_NUMBER_MASK (0xFU << 0U) -#define GT911_MODULE_SWITCH_X2Y_MASK (1U << 3U) -#define GT911_MODULE_SWITCH_INT_MASK (3U << 0U) - -#define GT911_CONFIG_SIZE (186U) - -/******************************************************************************* - * Prototypes - ******************************************************************************/ -/* Verify firmware, return true if pass. */ -static bool GT911_VerifyFirmware(const uint8_t *firmware); -static uint8_t GT911_GetFirmwareCheckSum(const uint8_t *firmware); - -/******************************************************************************* - * Variables - ******************************************************************************/ - -/******************************************************************************* - * Code - ******************************************************************************/ -static uint8_t GT911_GetFirmwareCheckSum(const uint8_t *firmware) -{ - uint8_t sum = 0; - uint16_t i = 0; - - for (i = 0; i < GT911_CONFIG_SIZE - 2U; i++) - { - sum += (*firmware); - firmware++; - } - - return (~sum + 1U); -} - -static bool GT911_VerifyFirmware(const uint8_t *firmware) -{ - return ((firmware[GT911_REG_CONFIG_VERSION - GT911_CONFIG_ADDR] != 0U) && - (GT911_GetFirmwareCheckSum(firmware) == firmware[GT911_CONFIG_SIZE - 2U])); -} - -status_t GT911_Init(gt911_handle_t *handle, const gt911_config_t *config) -{ - status_t status; - uint32_t deviceID; - uint8_t gt911Config[GT911_CONFIG_SIZE]; - - assert(NULL != handle); - - (void)memset(handle, 0, sizeof(*handle)); - - handle->I2C_SendFunc = config->I2C_SendFunc; - handle->I2C_ReceiveFunc = config->I2C_ReceiveFunc; - handle->timeDelayMsFunc = config->timeDelayMsFunc; - handle->pullResetPinFunc = config->pullResetPinFunc; - - /* Reset the panel and set the I2C address mode. */ - config->intPinFunc(kGT911_IntPinPullDown); - config->pullResetPinFunc(false); - - /* >= 10ms. */ - handle->timeDelayMsFunc(20); - - if (kGT911_I2cAddrAny == config->i2cAddrMode) - { - config->pullResetPinFunc(true); - - /* >= 55ms */ - handle->timeDelayMsFunc(55); - - config->intPinFunc(kGT911_IntPinInput); - - /* Try address 0 */ - handle->i2cAddr = GT911_I2C_ADDRESS0; - status = handle->I2C_ReceiveFunc(handle->i2cAddr, GT911_REG_ID, GT911_REG_ADDR_SIZE, (uint8_t *)&deviceID, 4); - - if (kStatus_Success != status) - { - /* Try address 1 */ - handle->i2cAddr = GT911_I2C_ADDRESS1; - status = - handle->I2C_ReceiveFunc(handle->i2cAddr, GT911_REG_ID, GT911_REG_ADDR_SIZE, (uint8_t *)&deviceID, 4); - - if (kStatus_Success != status) - { - return status; - } - } - } - else - { - if (kGT911_I2cAddrMode1 == config->i2cAddrMode) - { - config->intPinFunc(kGT911_IntPinPullUp); - handle->i2cAddr = GT911_I2C_ADDRESS1; - } - else - { - handle->i2cAddr = GT911_I2C_ADDRESS0; - } - - /* >= 100us */ - handle->timeDelayMsFunc(1); - - config->pullResetPinFunc(true); - - /* >= 5ms */ - handle->timeDelayMsFunc(5); - - config->intPinFunc(kGT911_IntPinPullDown); - - /* >= 50ms */ - handle->timeDelayMsFunc(50); - - config->intPinFunc(kGT911_IntPinInput); - - status = handle->I2C_ReceiveFunc(handle->i2cAddr, GT911_REG_ID, GT911_REG_ADDR_SIZE, (uint8_t *)&deviceID, 4); - if (kStatus_Success != status) - { - return status; - } - } - - /* Verify the device. */ - if (deviceID != 0x00313139U) - { - return kStatus_Fail; - } - - /* Initialize the IC. */ - status = handle->I2C_ReceiveFunc(handle->i2cAddr, GT911_CONFIG_ADDR, GT911_REG_ADDR_SIZE, gt911Config, - GT911_CONFIG_SIZE); - if (kStatus_Success != status) - { - return status; - } - - /* - * GT911 driver gets the original firmware from touch panel control IC, modify - * the configuration, then set it to the IC again. The original firmware - * read from the touch IC must be correct, otherwise setting wrong firmware - * to the touch IC will break it. - */ - if (true != GT911_VerifyFirmware(gt911Config)) - { - return kStatus_Fail; - } - - handle->resolutionX = ((uint16_t)gt911Config[GT911_REG_XH - GT911_CONFIG_ADDR]) << 8U; - handle->resolutionX += gt911Config[GT911_REG_XL - GT911_CONFIG_ADDR]; - handle->resolutionY = ((uint16_t)gt911Config[GT911_REG_YH - GT911_CONFIG_ADDR]) << 8U; - handle->resolutionY += gt911Config[GT911_REG_YL - GT911_CONFIG_ADDR]; - - gt911Config[GT911_REG_TOUCH_NUM - GT911_CONFIG_ADDR] = (config->touchPointNum) & 0x0FU; - - gt911Config[GT911_REG_MODULE_SWITCH1 - GT911_CONFIG_ADDR] &= (uint8_t)(~GT911_MODULE_SWITCH_INT_MASK); - gt911Config[GT911_REG_MODULE_SWITCH1 - GT911_CONFIG_ADDR] |= (uint8_t)(config->intTrigMode); - - gt911Config[GT911_CONFIG_SIZE - 2U] = GT911_GetFirmwareCheckSum(gt911Config); - gt911Config[GT911_CONFIG_SIZE - 1U] = 1U; /* Mark the firmware as valid. */ - - return handle->I2C_SendFunc(handle->i2cAddr, GT911_CONFIG_ADDR, GT911_REG_ADDR_SIZE, gt911Config, - GT911_CONFIG_SIZE); -} - -status_t GT911_Deinit(gt911_handle_t *handle) -{ - handle->pullResetPinFunc(false); - return kStatus_Success; -} - -static status_t GT911_ReadRawTouchData(gt911_handle_t *handle, uint8_t *touchPointNum) -{ - status_t status; - uint8_t gt911Stat; - - status = handle->I2C_ReceiveFunc(handle->i2cAddr, GT911_REG_STAT, GT911_REG_ADDR_SIZE, >911Stat, 1); - if (kStatus_Success != status) - { - *touchPointNum = 0; - return status; - } - - *touchPointNum = gt911Stat & GT911_STAT_POINT_NUMBER_MASK; - - if (0U != (gt911Stat & GT911_STAT_BUF_MASK)) - { - if (*touchPointNum > 0U) - { - status = handle->I2C_ReceiveFunc(handle->i2cAddr, GT911_REG_FIRST_POINT, GT911_REG_ADDR_SIZE, - (void *)handle->pointReg, (*touchPointNum) * sizeof(gt911_point_reg_t)); - } - - /* Must set the status register to 0 after read. */ - gt911Stat = 0; - status = handle->I2C_SendFunc(handle->i2cAddr, GT911_REG_STAT, GT911_REG_ADDR_SIZE, >911Stat, 1); - } - - return status; -} - -status_t GT911_GetSingleTouch(gt911_handle_t *handle, int *touch_x, int *touch_y) -{ - status_t status; - uint8_t touchPointNum; - - status = GT911_ReadRawTouchData(handle, &touchPointNum); - - if (kStatus_Success == status) - { - if (touchPointNum > 0U) - { - *touch_x = - (int)(uint16_t)((uint16_t)handle->pointReg[0].lowX + (((uint16_t)handle->pointReg[0].highX) << 8U)); - *touch_y = - (int)(uint16_t)((uint16_t)handle->pointReg[0].lowY + (((uint16_t)handle->pointReg[0].highY) << 8U)); - } - else - { - status = (status_t)kStatus_TOUCHPANEL_NotTouched; - } - } - else - { - status = kStatus_Fail; - } - - return status; -} - -status_t GT911_GetMultiTouch(gt911_handle_t *handle, uint8_t *touch_count, touch_point_t touch_array[]) -{ - status_t status; - uint32_t i; - uint8_t desiredTouchPointNum; - uint8_t actualTouchPointNum; - - status = GT911_ReadRawTouchData(handle, &actualTouchPointNum); - - if (kStatus_Success == status) - { - desiredTouchPointNum = *touch_count; - - if (0U == actualTouchPointNum) - { - status = (status_t)kStatus_TOUCHPANEL_NotTouched; - } - else if (actualTouchPointNum > desiredTouchPointNum) - { - actualTouchPointNum = desiredTouchPointNum; - } - else - { - /* MISRA compatible. */ - } - - for (i = 0; i < actualTouchPointNum; i++) - { - touch_array[i].valid = true; - touch_array[i].touchID = handle->pointReg[i].id; - touch_array[i].x = handle->pointReg[i].lowX + (((uint16_t)handle->pointReg[i].highX) << 8U); - touch_array[i].y = handle->pointReg[i].lowY + (((uint16_t)handle->pointReg[i].highY) << 8U); - } - - for (; i < desiredTouchPointNum; i++) - { - touch_array[i].valid = false; - } - } - else - { - status = kStatus_Fail; - } - - *touch_count = actualTouchPointNum; - - return status; -} - -status_t GT911_GetResolution(gt911_handle_t *handle, int *resolutionX, int *resolutionY) -{ - *resolutionX = (int)handle->resolutionX; - *resolutionY = (int)handle->resolutionY; - - return kStatus_Success; -} diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_gt911.h b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_gt911.h deleted file mode 100644 index 816b3e313fb7..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_gt911.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright 2019-2020 NXP - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _FSL_GT911_H_ -#define _FSL_GT911_H_ - -#include "fsl_common.h" - -/* - * Change Log: - * - * 1.0.3: - * - Fixed MISRA 2012 issues. - * - * 1.0.2: - * - Fixed the issue that INT pin is output low when using kGT911_I2cAddrAny. - * - * 1.0.1: - * - Update GT911_GetMultiTouch and GT911_GetSingleTouch to return - * kStatus_TOUCHPANEL_NotTouched when no touch happens. - * - * 1.0.0: - * - Initial version. - */ - -/*! - * @addtogroup gt911 - * @{ - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief GT911 maximum number of simultaneously detected touches. */ -#define GT911_MAX_TOUCHES (10U) - -/*! @brief Error code definition. */ -enum _touch_status -{ - kStatus_TOUCHPANEL_NotTouched = MAKE_STATUS(kStatusGroup_TOUCH_PANEL, 0) /*!< No touch happen. */ -}; - -/*! @brief Touch point definition. */ -typedef struct -{ - bool valid; /*!< Whether the touch point coordinate value is valid. */ - uint8_t touchID; /*!< Id of the touch point. This numeric value stays constant between down and up event. */ - uint16_t x; /*!< X coordinate of the touch point */ - uint16_t y; /*!< Y coordinate of the touch point */ -} touch_point_t; - -/*! @brief gt911 I2C address mode.*/ -typedef enum _gt911_i2c_addr_mode -{ - kGT911_I2cAddrMode0, /*!< 7-bit address 0x5D, or 8-bit 0xBA/0xBB */ - kGT911_I2cAddrMode1, /*!< 7-bit address 0x14, or 8-bit 0x28/0x29 */ - kGT911_I2cAddrAny, /*!< Use 0x5D or 0x14, driver selects the right one to use, - this is used for the case that MCU could not pull - the INT pin level. - */ -} gt911_i2c_addr_mode_t; - -/*! @brief gt911 interrupt pin mode.*/ -typedef enum _gt911_int_pin_mode -{ - kGT911_IntPinPullDown, /*!< Interrupt pin output pull down. */ - kGT911_IntPinPullUp, /*!< Interrupt pin output pull up. */ - kGT911_IntPinInput, /*!< Interrupt pin set to input mode. */ -} gt911_int_pin_mode_t; - -/*! @brief gt911 interrupt trigger mode.*/ -typedef enum _gt911_int_trig_mode -{ - kGT911_IntRisingEdge, /*!< Rising edge. */ - kGT911_IntFallingEdge, /*!< Falling edge. */ - kGT911_IntLowLevel, /*!< Low level. */ - kGT911_IntHighLevel, /*!< High edge. */ -} gt911_int_trig_mode_t; - -typedef status_t (*gt911_i2c_send_func_t)( - uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, const uint8_t *txBuff, uint8_t txBuffSize); -typedef status_t (*gt911_i2c_receive_func_t)( - uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); -typedef void (*gt911_int_pin_func_t)(gt911_int_pin_mode_t mode); -typedef void (*gt911_reset_pin_func_t)(bool pullUp); - -/*! @brief gt911 configure structure.*/ -typedef struct _gt911_point_reg -{ - uint8_t id; /*!< Track ID. */ - uint8_t lowX; /*!< Low byte of x coordinate. */ - uint8_t highX; /*!< High byte of x coordinate. */ - uint8_t lowY; /*!< Low byte of y coordinate. */ - uint8_t highY; /*!< High byte of x coordinate. */ - uint8_t lowSize; /*!< Low byte of point size. */ - uint8_t highSize; /*!< High byte of point size. */ - uint8_t reserved; /*!< Reserved. */ -} gt911_point_reg_t; - -/*! @brief gt911 configure structure.*/ -typedef struct _gt911_config -{ - gt911_i2c_send_func_t I2C_SendFunc; /*!< Function to send I2C data. */ - gt911_i2c_receive_func_t I2C_ReceiveFunc; /*!< Function to receive I2C data. */ - void (*timeDelayMsFunc)(uint32_t delayMs); /*!< Function to delay some MS. */ - gt911_int_pin_func_t intPinFunc; /*!< Function to set interrupt pin to different mode. */ - gt911_reset_pin_func_t pullResetPinFunc; /*!< Function to pull reset pin high or low. */ - uint8_t touchPointNum; /*!< How many touch points to enable. */ - gt911_i2c_addr_mode_t i2cAddrMode; /*!< I2C address mode. */ - gt911_int_trig_mode_t intTrigMode; /*!< Interrupt trigger mode. */ -} gt911_config_t; - -/*! @brief gt911 driver structure.*/ -typedef struct _gt911_handle -{ - gt911_i2c_send_func_t I2C_SendFunc; /*!< Function to send I2C data. */ - gt911_i2c_receive_func_t I2C_ReceiveFunc; /*!< Function to receive I2C data. */ - void (*timeDelayMsFunc)(uint32_t delayMs); /*!< Function to delay some MS. */ - gt911_reset_pin_func_t pullResetPinFunc; /*!< Function to pull reset pin high or low. */ - gt911_point_reg_t pointReg[GT911_MAX_TOUCHES]; /*!< Buffer to receive touch point raw data. */ - uint8_t touchPointNum; /*!< How many touch points to enable. */ - uint8_t i2cAddr; /*!< I2C address. */ - uint16_t resolutionX; /*!< Resolution. */ - uint16_t resolutionY; /*!< Resolution. */ -} gt911_handle_t; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif - -/*! - * @brief Initialize the driver. - * - * @param[in] handle Pointer to the GT911 driver. - * @param[in] config Pointer to the configuration. - * @return Returns @ref kStatus_Success if succeeded, otherwise return error code. - */ -status_t GT911_Init(gt911_handle_t *handle, const gt911_config_t *config); - -/*! - * @brief De-initialize the driver. - * - * @param[in] handle Pointer to the GT911 driver. - * @return Returns @ref kStatus_Success if succeeded, otherwise return error code. - */ -status_t GT911_Deinit(gt911_handle_t *handle); - -/*! - * @brief Get single touch point coordinate. - * - * @param[in] handle Pointer to the GT911 driver. - * @param[out] touch_x X coordinate of the touch point. - * @param[out] touch_y Y coordinate of the touch point. - * @return Returns @ref kStatus_Success if succeeded, otherwise return error code. - */ -status_t GT911_GetSingleTouch(gt911_handle_t *handle, int *touch_x, int *touch_y); - -/*! - * @brief Get multiple touch points coordinate. - * - * When calling this function, parameter @ref touch_count means the array size - * of @p touch_array. After the function returns, the @p touch_count means how - * many valid touch points there are in the @p touch_array. - * - * @param[in] handle Pointer to the GT911 driver. - * @param[in, out] touch_count The touch point number. - * @param[out] touch_array Array of touch points coordinate. - * @return Returns @ref kStatus_Success if succeeded, otherwise return error code. - */ -status_t GT911_GetMultiTouch(gt911_handle_t *handle, uint8_t *touch_count, touch_point_t touch_array[]); - -/*! - * @brief Get touch IC resolution. - * - * Note the touch resolution might be different with display resolution. - * - * @param handle Pointer to the driver. - * @param touch_x X resolution. - * @param touch_y Y resolution. - * @return Returns @ref kStatus_Success if succeeded, otherwise return error code. - */ -status_t GT911_GetResolution(gt911_handle_t *handle, int *resolutionX, int *resolutionY); - -#if defined(__cplusplus) -} -#endif - -/*! @} */ - -#endif /* _FSL_GT911_H_ */ diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_hx8394.c b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_hx8394.c deleted file mode 100644 index 91303ce47c32..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_hx8394.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright 2021 NXP - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "fsl_display.h" -#include "fsl_hx8394.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#define HX8394_DelayMs VIDEO_DelayMs - -typedef struct -{ - const uint8_t *cmd; - uint8_t cmdLen; -} hx8394_cmd_t; - -/******************************************************************************* - * Variables - ******************************************************************************/ -const display_operations_t hx8394_ops = { - .init = HX8394_Init, - .deinit = HX8394_Deinit, - .start = HX8394_Start, - .stop = HX8394_Stop, -}; - -static const hx8394_cmd_t s_hx8394Cmds[] = { - {(const uint8_t[]){0x36U, 0x02U}, 2U}, - - {(const uint8_t[]){0xB1U, 0x48U, 0x12U, 0x72U, 0x09U, 0x32U, 0x54U, 0x71U, 0x71U, 0x57U, 0x47U}, 11U}, - - {(const uint8_t[]){0xB2U, 0x00U, 0x80U, 0x64U, 0x0CU, 0x0DU, 0x2FU}, 7U}, - - {(const uint8_t[]){0xB4U, 0x73U, 0x74U, 0x73U, 0x74U, 0x73U, 0x74U, 0x01U, 0x0CU, 0x86U, /* 10 */ - 0x75U, 0x00U, 0x3FU, 0x73U, 0x74U, 0x73U, 0x74U, 0x73U, 0x74U, 0x01U, /* 20 */ - 0x0CU, 0x86U}, - 22U}, - - {(const uint8_t[]){0xD3U, 0x00U, 0x00U, 0x07U, 0x07U, 0x40U, 0x07U, 0x0CU, 0x00U, 0x08U, /* 10 */ - 0x10U, 0x08U, 0x00U, 0x08U, 0x54U, 0x15U, 0x0AU, 0x05U, 0x0AU, 0x02U, /* 20 */ - 0x15U, 0x06U, 0x05U, 0x06U, 0x47U, 0x44U, 0x0AU, 0x0AU, 0x4BU, 0x10U, /* 30 */ - 0x07U, 0x07U, 0x0CU, 0x40U}, - 34U}, - - {(const uint8_t[]){0xD5U, 0x1CU, 0x1CU, 0x1DU, 0x1DU, 0x00U, 0x01U, 0x02U, 0x03U, 0x04U, /* 10 */ - 0x05U, 0x06U, 0x07U, 0x08U, 0x09U, 0x0AU, 0x0BU, 0x24U, 0x25U, 0x18U, /* 20 */ - 0x18U, 0x26U, 0x27U, 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, /* 30 */ - 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, 0x20U, /* 40 */ - 0x21U, 0x18U, 0x18U, 0x18U, 0x18U}, - 45U}, - - {(const uint8_t[]){0xD6U, 0x1CU, 0x1CU, 0x1DU, 0x1DU, 0x07U, 0x06U, 0x05U, 0x04U, 0x03U, /* 10 */ - 0x02U, 0x01U, 0x00U, 0x0BU, 0x0AU, 0x09U, 0x08U, 0x21U, 0x20U, 0x18U, /* 20 */ - 0x18U, 0x27U, 0x26U, 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, /* 30 */ - 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, 0x18U, 0x25U, /* 40 */ - 0x24U, 0x18U, 0x18U, 0x18U, 0x18U}, - 45U}, - - {(const uint8_t[]){0xB6U, 0x92U, 0x92U}, 3U}, - - {(const uint8_t[]){0xE0U, 0x00U, 0x0AU, 0x15U, 0x1BU, 0x1EU, 0x21U, 0x24U, 0x22U, 0x47U, /* 10 */ - 0x56U, 0x65U, 0x66U, 0x6EU, 0x82U, 0x88U, 0x8BU, 0x9AU, 0x9DU, 0x98U, /* 20 */ - 0xA8U, 0xB9U, 0x5DU, 0x5CU, 0x61U, 0x66U, 0x6AU, 0x6FU, 0x7FU, 0x7FU, /* 30 */ - 0x00U, 0x0AU, 0x15U, 0x1BU, 0x1EU, 0x21U, 0x24U, 0x22U, 0x47U, 0x56U, /* 40 */ - 0x65U, 0x65U, 0x6EU, 0x81U, 0x87U, 0x8BU, 0x98U, 0x9DU, 0x99U, 0xA8U, /* 50 */ - 0xBAU, 0x5DU, 0x5DU, 0x62U, 0x67U, 0x6BU, 0x72U, 0x7FU, 0x7FU}, - 59U}, - - {(const uint8_t[]){0xC0U, 0x1FU, 0x31U}, 3U}, - {(const uint8_t[]){0xCCU, 0x03U}, 2U}, - {(const uint8_t[]){0xD4U, 0x02U}, 2U}, - {(const uint8_t[]){0xBDU, 0x02U}, 2U}, - - {(const uint8_t[]){0xD8U, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, /* 10 */ - 0xFFU, 0xFFU, 0xFFU}, - 13U}, - - {(const uint8_t[]){0xBDU, 0x00U}, 2U}, - {(const uint8_t[]){0xBDU, 0x01U}, 2U}, - {(const uint8_t[]){0xB1U, 0x00U}, 2U}, - {(const uint8_t[]){0xBDU, 0x00U}, 2U}, - - {(const uint8_t[]){0xBFU, 0x40U, 0x81U, 0x50U, 0x00U, 0x1AU, 0xFCU, 0x01}, 8U}, - - {(const uint8_t[]){0xC6U, 0xEDU}, 2U}, - - {(const uint8_t[]){0x35U, 0x00U}, 2U}, -}; - -/******************************************************************************* - * Code - ******************************************************************************/ - -status_t HX8394_Init(display_handle_t *handle, const display_config_t *config) -{ - uint8_t i; - status_t status = kStatus_Success; - const hx8394_resource_t *resource = (const hx8394_resource_t *)(handle->resource); - mipi_dsi_device_t *dsiDevice = resource->dsiDevice; - uint8_t setmipi[7] = {0xBAU, 0x60U, 0x03U, 0x68U, 0x6BU, 0xB2U, 0xC0U}; - - /* Only support 720 * 1280 */ - if (config->resolution != FSL_VIDEO_RESOLUTION(720, 1280)) - { - return kStatus_InvalidArgument; - } - - /* Power on. */ - resource->pullPowerPin(true); - HX8394_DelayMs(1); - - /* Perform reset. */ - resource->pullResetPin(false); - HX8394_DelayMs(1); - resource->pullResetPin(true); - HX8394_DelayMs(50U); - - status = MIPI_DSI_GenericWrite(dsiDevice, (const uint8_t[]){0xB9U, 0xFFU, 0x83U, 0x94U}, 4); - - setmipi[1] |= (config->dsiLanes - 1U); - - if (kStatus_Success == status) - { - status = MIPI_DSI_GenericWrite(dsiDevice, setmipi, 7); - } - - if (kStatus_Success == status) - { - for (i = 0; i < ARRAY_SIZE(s_hx8394Cmds); i++) - { - status = MIPI_DSI_GenericWrite(dsiDevice, s_hx8394Cmds[i].cmd, (int32_t)s_hx8394Cmds[i].cmdLen); - - if (kStatus_Success != status) - { - break; - } - } - } - - if (kStatus_Success == status) - { - status = MIPI_DSI_DCS_EnterSleepMode(dsiDevice, false); - } - - if (kStatus_Success == status) - { - HX8394_DelayMs(120U); - - status = MIPI_DSI_DCS_SetDisplayOn(dsiDevice, true); - } - - return status; -} - -status_t HX8394_Deinit(display_handle_t *handle) -{ - const hx8394_resource_t *resource = (const hx8394_resource_t *)(handle->resource); - mipi_dsi_device_t *dsiDevice = resource->dsiDevice; - - (void)MIPI_DSI_DCS_EnterSleepMode(dsiDevice, true); - - resource->pullResetPin(false); - resource->pullPowerPin(false); - - return kStatus_Success; -} - -status_t HX8394_Start(display_handle_t *handle) -{ - const hx8394_resource_t *resource = (const hx8394_resource_t *)(handle->resource); - mipi_dsi_device_t *dsiDevice = resource->dsiDevice; - - return MIPI_DSI_DCS_SetDisplayOn(dsiDevice, true); -} - -status_t HX8394_Stop(display_handle_t *handle) -{ - const hx8394_resource_t *resource = (const hx8394_resource_t *)(handle->resource); - mipi_dsi_device_t *dsiDevice = resource->dsiDevice; - - return MIPI_DSI_DCS_SetDisplayOn(dsiDevice, false); -} diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_hx8394.h b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_hx8394.h deleted file mode 100644 index b33aea98ac5b..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_hx8394.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2021 NXP - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _FSL_HX8394_H_ -#define _FSL_HX8394_H_ - -#include "fsl_display.h" -#include "fsl_mipi_dsi_cmd.h" - -/* - * Change log: - * - * 1.0.0 - * - Initial version - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/*! - * @brief HX8394 resource. - */ -typedef struct _hx8394_resource -{ - mipi_dsi_device_t *dsiDevice; /*!< MIPI DSI device. */ - void (*pullResetPin)(bool pullUp); /*!< Function to pull reset pin high or low. */ - void (*pullPowerPin)(bool pullUp); /*!< Function to pull power pin high or low. */ -} hx8394_resource_t; - -extern const display_operations_t hx8394_ops; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif - -status_t HX8394_Init(display_handle_t *handle, const display_config_t *config); - -status_t HX8394_Deinit(display_handle_t *handle); - -status_t HX8394_Start(display_handle_t *handle); - -status_t HX8394_Stop(display_handle_t *handle); - -#if defined(__cplusplus) -} -#endif - -#endif /* _FSL_HX8394_H_ */ diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_mipi_dsi_cmd.c b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_mipi_dsi_cmd.c deleted file mode 100644 index bf50a5acb429..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_mipi_dsi_cmd.c +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright 2017-2020 NXP - * All rights reserved. - * - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "fsl_mipi_dsi_cmd.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * Variables - ******************************************************************************/ - -/******************************************************************************* - * Code - ******************************************************************************/ -status_t MIPI_DSI_DCS_SoftReset(mipi_dsi_device_t *device) -{ - dsi_transfer_t dsiXfer = {0}; - uint8_t txData = (uint8_t)kMIPI_DCS_SoftReset; - - dsiXfer.virtualChannel = device->virtualChannel; - dsiXfer.txDataType = kDSI_TxDataDcsShortWrNoParam; - dsiXfer.txDataSize = 1; - dsiXfer.txData = &txData; - - return device->xferFunc(&dsiXfer); -} - -status_t MIPI_DSI_DCS_SetDisplayOn(mipi_dsi_device_t *device, bool on) -{ - dsi_transfer_t dsiXfer = {0}; - uint8_t txData; - - dsiXfer.virtualChannel = device->virtualChannel; - dsiXfer.txDataType = kDSI_TxDataDcsShortWrNoParam; - dsiXfer.txDataSize = 1; - dsiXfer.txData = &txData; - - if (on) - { - txData = (uint8_t)kMIPI_DCS_SetDisplayOn; - } - else - { - txData = (uint8_t)kMIPI_DCS_SetDisplayOff; - } - - return device->xferFunc(&dsiXfer); -} - -status_t MIPI_DSI_DCS_SetPixelFormat(mipi_dsi_device_t *device, - mipi_dsc_pixel_format_t dbiFormat, - mipi_dsc_pixel_format_t dpiFormat) -{ - dsi_transfer_t dsiXfer = {0}; - uint8_t txData[2]; - - dsiXfer.virtualChannel = device->virtualChannel; - dsiXfer.txDataType = kDSI_TxDataDcsShortWrOneParam; - dsiXfer.txDataSize = 2; - dsiXfer.txData = txData; - - txData[0] = (uint8_t)kMIPI_DCS_SetPixelFormat; - txData[1] = ((uint8_t)dbiFormat << 0U) | ((uint8_t)dpiFormat << 4U); - - return device->xferFunc(&dsiXfer); -} - -status_t MIPI_DSI_DCS_EnterSleepMode(mipi_dsi_device_t *device, bool enter) -{ - dsi_transfer_t dsiXfer = {0}; - uint8_t txData; - - dsiXfer.virtualChannel = device->virtualChannel; - dsiXfer.txDataType = kDSI_TxDataDcsShortWrNoParam; - dsiXfer.txDataSize = 1; - dsiXfer.txData = &txData; - - if (enter) - { - txData = (uint8_t)kMIPI_DCS_EnterSleepMode; - } - else - { - txData = (uint8_t)kMIPI_DCS_ExitSleepMode; - } - - return device->xferFunc(&dsiXfer); -} - -status_t MIPI_DSI_DCS_EnterPartialMode(mipi_dsi_device_t *device, bool enter) -{ - dsi_transfer_t dsiXfer = {0}; - uint8_t txData; - - dsiXfer.virtualChannel = device->virtualChannel; - dsiXfer.txDataType = kDSI_TxDataDcsShortWrNoParam; - dsiXfer.txDataSize = 1; - dsiXfer.txData = &txData; - - if (enter) - { - txData = (uint8_t)kMIPI_DCS_EnterPartialMode; - } - else - { - txData = (uint8_t)kMIPI_DCS_EnterNormalMode; - } - - return device->xferFunc(&dsiXfer); -} - -status_t MIPI_DSI_DCS_EnterInvertMode(mipi_dsi_device_t *device, bool enter) -{ - dsi_transfer_t dsiXfer = {0}; - uint8_t txData; - - dsiXfer.virtualChannel = device->virtualChannel; - dsiXfer.txDataType = kDSI_TxDataDcsShortWrNoParam; - dsiXfer.txDataSize = 1; - dsiXfer.txData = &txData; - - if (enter) - { - txData = (uint8_t)kMIPI_DCS_EnterInvertMode; - } - else - { - txData = (uint8_t)kMIPI_DCS_ExitInvertMode; - } - - return device->xferFunc(&dsiXfer); -} - -status_t MIPI_DSI_DCS_EnterIdleMode(mipi_dsi_device_t *device, bool enter) -{ - dsi_transfer_t dsiXfer = {0}; - uint8_t txData; - - dsiXfer.virtualChannel = device->virtualChannel; - dsiXfer.txDataType = kDSI_TxDataDcsShortWrNoParam; - dsiXfer.txDataSize = 1; - dsiXfer.txData = &txData; - - if (enter) - { - txData = (uint8_t)kMIPI_DCS_EnterIdleMode; - } - else - { - txData = (uint8_t)kMIPI_DCS_ExitIdleMode; - } - - return device->xferFunc(&dsiXfer); -} - -status_t MIPI_DSI_DCS_Write(mipi_dsi_device_t *device, const uint8_t *txData, int32_t txDataSize) -{ - dsi_transfer_t dsiXfer = {0}; - - dsiXfer.virtualChannel = device->virtualChannel; - dsiXfer.txDataSize = (uint16_t)txDataSize; - dsiXfer.txData = txData; - - if (0 == txDataSize) - { - /* For DSC command, the data size should not be 0. */ - return kStatus_InvalidArgument; - } - else if (1 == txDataSize) - { - dsiXfer.txDataType = kDSI_TxDataDcsShortWrNoParam; - } - else if (2 == txDataSize) - { - dsiXfer.txDataType = kDSI_TxDataDcsShortWrOneParam; - } - else - { - dsiXfer.txDataType = kDSI_TxDataDcsLongWr; - } - - return device->xferFunc(&dsiXfer); -} - -status_t MIPI_DSI_GenericWrite(mipi_dsi_device_t *device, const uint8_t *txData, int32_t txDataSize) -{ - dsi_transfer_t dsiXfer = {0}; - - dsiXfer.virtualChannel = device->virtualChannel; - dsiXfer.txDataSize = (uint16_t)txDataSize; - dsiXfer.txData = txData; - - if (0 == txDataSize) - { - dsiXfer.txDataType = kDSI_TxDataGenShortWrNoParam; - } - else if (1 == txDataSize) - { - dsiXfer.txDataType = kDSI_TxDataGenShortWrOneParam; - } - else if (2 == txDataSize) - { - dsiXfer.txDataType = kDSI_TxDataGenShortWrTwoParam; - } - else - { - dsiXfer.txDataType = kDSI_TxDataGenLongWr; - } - - return device->xferFunc(&dsiXfer); -} - -status_t MIPI_DSI_DCS_SetMaxReturnPktSize(mipi_dsi_device_t *device, uint16_t sizeBytes) -{ - dsi_transfer_t dsiXfer = {0}; - - dsiXfer.virtualChannel = device->virtualChannel; - dsiXfer.txDataType = kDSI_TxDataSetMaxReturnPktSize; - dsiXfer.txDataSize = 2; - dsiXfer.txData = (uint8_t *)&sizeBytes; - - return device->xferFunc(&dsiXfer); -} - -status_t MIPI_DSI_GenericRead( - mipi_dsi_device_t *device, const uint8_t *txData, int32_t txDataSize, uint8_t *rxData, int32_t *rxDataSize) -{ - status_t status; - dsi_transfer_t dsiXfer = {0}; - - dsiXfer.virtualChannel = device->virtualChannel; - dsiXfer.txDataSize = (uint16_t)txDataSize; - dsiXfer.txData = txData; - dsiXfer.rxDataSize = (uint16_t)*rxDataSize; - dsiXfer.rxData = rxData; - - *rxDataSize = 0; - - if (0 == txDataSize) - { - dsiXfer.txDataType = kDSI_TxDataGenShortRdNoParam; - } - else if (1 == txDataSize) - { - dsiXfer.txDataType = kDSI_TxDataGenShortRdOneParam; - } - else if (2 == txDataSize) - { - dsiXfer.txDataType = kDSI_TxDataGenShortRdTwoParam; - } - else - { - return kStatus_InvalidArgument; - } - - status = device->xferFunc(&dsiXfer); - - /* Return actual received size. */ - *rxDataSize = (int32_t)dsiXfer.rxDataSize; - - return status; -} - -status_t MIPI_DSI_ReadCMD(mipi_dsi_device_t *device, enum _mipi_dcs dcsCmd, uint8_t *rxData, int32_t *rxDataSize) -{ - uint8_t txData[2]; - status_t status = kStatus_Fail; - - txData[0] = (uint8_t)dcsCmd; - if (kStatus_Success == MIPI_DSI_DCS_SetMaxReturnPktSize(device, (uint16_t)*rxDataSize)) - { - status = MIPI_DSI_GenericRead(device, txData, 1, rxData, rxDataSize); - } - - return status; -} - -status_t MIPI_DSI_SelectArea(mipi_dsi_device_t *device, uint16_t startX, uint16_t startY, uint16_t endX, uint16_t endY) -{ - status_t status; - dsi_transfer_t dsiXfer = {0}; - uint8_t txData[4]; - - dsiXfer.virtualChannel = device->virtualChannel; - dsiXfer.txDataType = kDSI_TxDataDcsLongWr; - dsiXfer.txDataSize = 4; - dsiXfer.txData = txData; - dsiXfer.sendDscCmd = true; - dsiXfer.dscCmd = (uint8_t)kMIPI_DCS_SetColumnAddress; - - txData[0] = (uint8_t)((startX >> 8U) & 0xFFU); - txData[1] = (uint8_t)(startX & 0xFFU); - txData[2] = (uint8_t)((endX >> 8U) & 0xFFU); - txData[3] = (uint8_t)(endX & 0xFFU); - - status = device->xferFunc(&dsiXfer); - - if (kStatus_Success != status) - { - return status; - } - - dsiXfer.dscCmd = (uint8_t)kMIPI_DCS_SetPageAddress; - txData[0] = (uint8_t)((startY >> 8U) & 0xFFU); - txData[1] = (uint8_t)(startY & 0xFFU); - txData[2] = (uint8_t)((endY >> 8U) & 0xFFU); - txData[3] = (uint8_t)(endY & 0xFFU); - - return device->xferFunc(&dsiXfer); -} - -status_t MIPI_DSI_WriteMemory(mipi_dsi_device_t *device, const uint8_t *data, uint32_t length) -{ - return device->memWriteFunc(device->virtualChannel, data, length); -} - -void MIPI_DSI_SetMemoryDoneCallback(mipi_dsi_device_t *device, mipi_dsi_mem_done_callback_t callback, void *userData) -{ - device->callback = callback; - device->userData = userData; -} - -void MIPI_DSI_MemoryDoneDriverCallback(status_t status, void *userData) -{ - mipi_dsi_device_t *device = (mipi_dsi_device_t *)userData; - - if (NULL != device->callback) - { - device->callback(status, device->userData); - } -} diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_mipi_dsi_cmd.h b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_mipi_dsi_cmd.h deleted file mode 100644 index d0b4d6fbfb48..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_mipi_dsi_cmd.h +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright 2017-2020 NXP - * All rights reserved. - * - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _FSL_MIPI_DSI_CMD_H_ -#define _FSL_MIPI_DSI_CMD_H_ - -#include "fsl_common.h" -#include "fsl_mipi_dsi.h" - -/* - * Change log: - * - * 1.0.2 - * - Fix MISRA-C 2012 issues. - * - * 1.0.1 - * - Add more functions for panel works in command mode. - * - * 1.0.0 - * - Initial version - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -enum _mipi_dcs -{ - kMIPI_DCS_Nop = 0x00, - kMIPI_DCS_SoftReset = 0x01, - kMIPI_DCS_GetRedChannel = 0x06, - kMIPI_DCS_GetGreenChannel = 0x07, - kMIPI_DCS_GetBlueChannel = 0x08, - kMIPI_DCS_GetPowerMode = 0x0A, - kMIPI_DCS_GetAddressMode = 0x0B, - kMIPI_DCS_GetPixelFormat = 0x0C, - kMIPI_DCS_GetDisplayMode = 0x0D, - kMIPI_DCS_GetSignalMode = 0x0E, - kMIPI_DCS_GetDiagnosticResult = 0x0F, - kMIPI_DCS_EnterSleepMode = 0x10, - kMIPI_DCS_ExitSleepMode = 0x11, - kMIPI_DCS_EnterPartialMode = 0x12, - kMIPI_DCS_EnterNormalMode = 0x13, - kMIPI_DCS_ExitInvertMode = 0x20, - kMIPI_DCS_EnterInvertMode = 0x21, - kMIPI_DCS_SetGammaCurve = 0x26, - kMIPI_DCS_SetDisplayOff = 0x28, - kMIPI_DCS_SetDisplayOn = 0x29, - kMIPI_DCS_SetColumnAddress = 0x2a, - kMIPI_DCS_SetPageAddress = 0x2b, - kMIPI_DCS_WriteMemoryStart = 0x2C, - kMIPI_DCS_WriteLUT = 0x2D, - kMIPI_DCS_ReadMemoryStart = 0x2E, - kMIPI_DCS_SetPartialRows = 0x30, - kMIPI_DCS_SetPartialColumns = 0x31, - kMIPI_DCS_SetScrollArea = 0x33, - kMIPI_DCS_SetTearOff = 0x34, - kMIPI_DCS_SetTearOn = 0x35, - kMIPI_DCS_SetAddressMode = 0x36, - kMIPI_DCS_SetScrollStart = 0x37, - kMIPI_DCS_ExitIdleMode = 0x38, - kMIPI_DCS_EnterIdleMode = 0x39, - kMIPI_DCS_SetPixelFormat = 0x3A, - kMIPI_DCS_WriteMemoryContinue = 0x3C, - kMIPI_DCS_Set3DControl = 0x3D, - kMIPI_DCS_ReadMemoryContinue = 0x3E, - kMIPI_DCS_Get3DControl = 0x3F, - kMIPI_DCS_SetVsyncTiming = 0x40, - kMIPI_DCS_SetTearScanline = 0x44, - kMIPI_DCS_GetScanline = 0x45, - kMIPI_DCS_SetDisplayBrightness = 0x51, - kMIPI_DCS_GetDisplayBrightness = 0x52, - kMIPI_DCS_WriteControlDisplay = 0x53, - kMIPI_DCS_GetControlDisplay = 0x54, - kMIPI_DCS_WritePowerSave = 0x55, - kMIPI_DCS_GetPowerSave = 0x56, - kMIPI_DCS_SetCABCMinBrightness = 0x5E, - kMIPI_DCS_GetCABCMinBrightness = 0x5F, - kMIPI_DCS_ReadDDBStart = 0xA1, - kMIPI_DCS_ReadDDBContinue = 0xA8, -}; - -/*! - * @brief Pixel format used by DSC command. - */ -typedef enum _mipi_dsc_pixel_format -{ - kMIPI_DCS_Pixel3Bits = 1U, /*!< 3-bit per pixel. */ - kMIPI_DCS_Pixel8Bits = 2U, /*!< 8-bit per pixel. */ - kMIPI_DCS_Pixel12Bits = 3U, /*!< 12-bit per pixel. */ - kMIPI_DCS_Pixel16Bits = 5U, /*!< 16-bit per pixel. */ - kMIPI_DCS_Pixel18Bits = 6U, /*!< 18-bit per pixel. */ - kMIPI_DCS_Pixel24Bits = 7U, /*!< 24-bit per pixel. */ -} mipi_dsc_pixel_format_t; - -/*! - * @brief Callback function when the write memory finished. - * - * If transfer done successfully, the @p status is kStatus_Success. - */ -typedef void (*mipi_dsi_mem_done_callback_t)(status_t status, void *userData); - -/*! @brief MIPI DSI transfer function. */ -typedef status_t (*mipi_dsi_transfer_func_t)(dsi_transfer_t *xfer); - -/*! @brief MIPI DSI memory write function. */ -typedef status_t (*mipi_dsi_mem_write_func_t)(uint8_t virtualChannel, const uint8_t *data, uint32_t length); - -/*! @brief MIPI DSI device. */ -typedef struct _mipi_dsi_device -{ - uint8_t virtualChannel; - mipi_dsi_transfer_func_t xferFunc; - mipi_dsi_mem_write_func_t memWriteFunc; /*!< Function to write display memory, - it should be non-blocking function and - notify upper layer using callback when finished. - Not used when panel works in video mode. */ - mipi_dsi_mem_done_callback_t callback; /*!< The callback function to notify upper layer - that memory write done. Not used when panel - works in video mode. */ - void *userData; /*!< Parameter for the memory write done callback. - not used when panel works in video mode. */ -} mipi_dsi_device_t; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif - -/*! - * @brief Send software reset to MIPI DSI device. - * - * @param device The MIPI DSI device. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -status_t MIPI_DSI_DCS_SoftReset(mipi_dsi_device_t *device); - -/*! - * @brief Set display on or off. - * - * @param device The MIPI DSI device. - * @param on Set true to turn on, false to turn off. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -status_t MIPI_DSI_DCS_SetDisplayOn(mipi_dsi_device_t *device, bool on); - -/*! - * @brief Enter or exit sleep mode. - * - * @param device The MIPI DSI device. - * @param enter Set true to enter sleep mode, false to exit. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -status_t MIPI_DSI_DCS_EnterSleepMode(mipi_dsi_device_t *device, bool enter); - -/*! - * @brief Enter or exit partial mode. - * - * @param device The MIPI DSI device. - * @param enter Set true to enter partial mode, false to exit. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -status_t MIPI_DSI_DCS_EnterPartialMode(mipi_dsi_device_t *device, bool enter); - -/*! - * @brief Enter or exit invert mode. - * - * @param device The MIPI DSI device. - * @param enter Set true to enter invert mode, false to exit. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -status_t MIPI_DSI_DCS_EnterInvertMode(mipi_dsi_device_t *device, bool enter); - -/*! - * @brief Enter or exit idle mode. - * - * @param device The MIPI DSI device. - * @param enter Set true to enter idle mode, false to exit. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -status_t MIPI_DSI_DCS_EnterIdleMode(mipi_dsi_device_t *device, bool enter); - -/*! - * @brief Send DCS command. - * - * @param device The MIPI DSI device. - * @param txData The data to send. - * @param txDataSize Size of the data to send (in bytes). - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -status_t MIPI_DSI_DCS_Write(mipi_dsi_device_t *device, const uint8_t *txData, int32_t txDataSize); - -/*! - * @brief Send generic data. - * - * @param device The MIPI DSI device. - * @param txData The data to send. - * @param txDataSize Size of the data to send (in bytes). - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -status_t MIPI_DSI_GenericWrite(mipi_dsi_device_t *device, const uint8_t *txData, int32_t txDataSize); - -/*! - * @brief Set the maximum return data length. - * - * @param device The MIPI DSI device. - * @param sizeBytes Maximum return data length. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -status_t MIPI_DSI_DCS_SetMaxReturnPktSize(mipi_dsi_device_t *device, uint16_t sizeBytes); - -/*! - * @brief Generic read. - * - * @param device The MIPI DSI device. - * @param txData The data to send before read. - * @param txDataSize Size of the data to send (in bytes). - * @param rxData The data to read. - * @param rxDataSize Size of the data to read (in bytes), after this function returns, - * it is the actual read length. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -status_t MIPI_DSI_GenericRead( - mipi_dsi_device_t *device, const uint8_t *txData, int32_t txDataSize, uint8_t *rxData, int32_t *rxDataSize); - -/*! - * @brief Read DCS command(read type command, such as: Get Display ID). - * - * @param device The MIPI DSI device. - * @param dcsCmd The command to send before read. - * @param rxData The data to read. - * @param rxDataSize Size of the data to read (in bytes), after this function returns, - * it is the actual read length. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -status_t MIPI_DSI_ReadCMD(mipi_dsi_device_t *device, enum _mipi_dcs dcsCmd, uint8_t *rxData, int32_t *rxDataSize); - -/*! - * @brief Set the panel pixel format. - * - * @param device The MIPI DSI device. - * @param dbiFormat The DBI interface pixel format. - * @param dpiFormat The DPI interface pixel format. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -status_t MIPI_DSI_DCS_SetPixelFormat(mipi_dsi_device_t *device, - mipi_dsc_pixel_format_t dbiFormat, - mipi_dsc_pixel_format_t dpiFormat); - -/*! - * @brief Select area to write or read pixels. - * - * @param device The MIPI DSI device. - * @param startX Start point X coordination. - * @param startY Start point Y coordination. - * @param endX End point X coordination. - * @param endY End point Y coordination. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -status_t MIPI_DSI_SelectArea(mipi_dsi_device_t *device, uint16_t startX, uint16_t startY, uint16_t endX, uint16_t endY); - -/*! - * @brief Send pixel data to the display controller's frame memory. - * - * The pixels will be shown in the region selected by @ref MIPI_DSI_SelectArea. - * This function is non-blocking function, user should install callback function - * using @ref MIPI_DSI_SetMemoryDoneCallback to get informed when write finished. - * - * @param device The MIPI DSI device. - * @param data The pixel data to send. - * @param length Length of the data in byte. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -status_t MIPI_DSI_WriteMemory(mipi_dsi_device_t *device, const uint8_t *data, uint32_t length); - -/*! - * @brief Install the callback called when write memory finished. - * - * Upper layer should install callback function using this function to - * get memory write done notification. - * - * @param device The MIPI DSI device. - * @param callback The callback function to inform upper layer that memory write done. - * @param userData Parameter used by the callback. - * @return Returns @ref kStatus_Success if success, otherwise returns error code. - */ -void MIPI_DSI_SetMemoryDoneCallback(mipi_dsi_device_t *device, mipi_dsi_mem_done_callback_t callback, void *userData); - -/*! - * @brief The callback function lower layer should call when write memory finished. - * - * When implement the @ref mipi_dsi_device_t, this function should be called when - * the memory writing finished. The parameter @p userData should be pointer to the - * @ref mipi_dsi_device_t. - * - * @param status The memory writing result. @ref kStatus_Success if success. - * @param userData Must be pointer to the @ref mipi_dsi_device_t instance. - */ -void MIPI_DSI_MemoryDoneDriverCallback(status_t status, void *userData); - -#if defined(__cplusplus) -} -#endif - -#endif /* _FSL_MIPI_DSI_CMD_H_ */ diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68191.c b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68191.c deleted file mode 100644 index 3ca01fb28e9b..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68191.c +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright 2019-2020 NXP - * All rights reserved. - * - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "fsl_display.h" -#include "fsl_rm68191.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#define RM68191_DelayMs VIDEO_DelayMs - -typedef struct _rm68191_setting -{ - const uint8_t *value; - uint8_t len; -} rm68191_setting_t; - -#define RM68191_MAKE_SETTING_ITEM(setting) \ - { \ - (setting), (uint8_t)sizeof(setting) \ - } - -/******************************************************************************* - * Variables - ******************************************************************************/ -static const uint8_t s_rm68191Cmd0[] = {0xF0, 0x55, 0xAA, 0x52, 0x08, 0x03}; -static const uint8_t s_rm68191Cmd1[] = {0x90, 0x05, 0x16, 0x09, 0x03, 0xCD, 0x00, 0x00, 0x00, 0x00}; -static const uint8_t s_rm68191Cmd2[] = {0x91, 0x05, 0x16, 0x0B, 0x03, 0xCF, 0x00, 0x00, 0x00, 0x00}; -static const uint8_t s_rm68191Cmd3[] = {0x92, 0x40, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x8F, 0x00, 0x00, 0x04, 0x08}; -static const uint8_t s_rm68191Cmd4[] = {0x94, 0x00, 0x08, 0x0C, 0x03, 0xD1, 0x03, 0xD2, 0x0C}; -static const uint8_t s_rm68191Cmd5[] = {0x95, 0x40, 0x10, 0x00, 0x11, 0x00, 0x12, 0x00, 0x13, - 0x00, 0x8F, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08}; -static const uint8_t s_rm68191Cmd6[] = {0x99, 0x00, 0x00}; -static const uint8_t s_rm68191Cmd7[] = {0x9A, 0x80, 0x10, 0x03, 0xD5, 0x03, 0xD7, 0x00, 0x00, 0x00, 0x00, 0x50}; -static const uint8_t s_rm68191Cmd8[] = {0x9B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -static const uint8_t s_rm68191Cmd9[] = {0x9C, 0x00, 0x00}; -static const uint8_t s_rm68191Cmd10[] = {0x9D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00}; -static const uint8_t s_rm68191Cmd11[] = {0x9E, 0x00, 0x00}; -static const uint8_t s_rm68191Cmd12[] = {0xA0, 0x84, 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x08, 0x1F, 0x0A, 0x1F}; -static const uint8_t s_rm68191Cmd13[] = {0xA1, 0x1F, 0x1F, 0x1F, 0x1F, 0x0C, 0x1F, 0x0E, 0x1F, 0x1F, 0x1F}; -static const uint8_t s_rm68191Cmd14[] = {0xA2, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x02, 0x1F, 0x06, 0x1F}; -static const uint8_t s_rm68191Cmd15[] = {0xA3, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F}; -static const uint8_t s_rm68191Cmd16[] = {0xA4, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x07, 0x1F, 0x03, 0x1F, 0x0F}; -static const uint8_t s_rm68191Cmd17[] = {0xA5, 0x1F, 0x0D, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0B, 0x1F, 0x09}; -static const uint8_t s_rm68191Cmd18[] = {0xA6, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x01, 0x05}; -static const uint8_t s_rm68191Cmd19[] = {0xA7, 0x03, 0x07, 0x1F, 0x1F, 0x1F, 0x1F, 0x0B, 0x1F, 0x09, 0x1F}; -static const uint8_t s_rm68191Cmd20[] = {0xA8, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x1F, 0x0D, 0x1F, 0x1F, 0x1F}; -static const uint8_t s_rm68191Cmd21[] = {0xA9, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x05, 0x1F, 0x01, 0x1F}; -static const uint8_t s_rm68191Cmd22[] = {0xAA, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F}; -static const uint8_t s_rm68191Cmd23[] = {0xAB, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x1F, 0x04, 0x1F, 0x0C}; -static const uint8_t s_rm68191Cmd24[] = {0xAC, 0x1F, 0x0E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x08, 0x1F, 0x0A}; -static const uint8_t s_rm68191Cmd25[] = {0xAD, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x06, 0x02}; -static const uint8_t s_rm68191Cmd26[] = {0xF0, 0x55, 0xAA, 0x52, 0x08, 0x02}; -static const uint8_t s_rm68191Cmd27[] = {0xEA, 0x7D}; -static const uint8_t s_rm68191Cmd28[] = {0xF0, 0x55, 0xAA, 0x52, 0x08, 0x00}; -static const uint8_t s_rm68191Cmd29[] = {0xBC, 0x00, 0x00, 0x00}; -static const uint8_t s_rm68191Cmd30[] = {0xB8, 0x01, 0xAF, 0x8F, 0x8F}; -static const uint8_t s_rm68191Cmd31[] = {0xF0, 0x55, 0xAA, 0x52, 0x08, 0x01}; -static const uint8_t s_rm68191Cmd32[] = {0xD1, 0x00, 0x00, 0x00, 0x26, 0x00, 0x5E, 0x00, 0x88, - 0x00, 0xA8, 0x00, 0xDB, 0x01, 0x02, 0x01, 0x3D}; -static const uint8_t s_rm68191Cmd33[] = {0xD2, 0x01, 0x67, 0x01, 0xA6, 0x01, 0xD3, 0x02, 0x16, - 0x02, 0x49, 0x02, 0x4B, 0x02, 0x7B, 0x02, 0xB3}; -static const uint8_t s_rm68191Cmd34[] = {0xD3, 0x02, 0xD9, 0x03, 0x0E, 0x03, 0x31, 0x03, 0x61, - 0x03, 0x80, 0x03, 0xA5, 0x03, 0xBD, 0x03, 0xD2}; -static const uint8_t s_rm68191Cmd35[] = {0xD4, 0x03, 0xE5, 0x03, 0xFF}; -static const uint8_t s_rm68191Cmd36[] = {0xD5, 0x00, 0x00, 0x00, 0x26, 0x00, 0x5E, 0x00, 0x88, - 0x00, 0xA8, 0x00, 0xDB, 0x01, 0x02, 0x01, 0x3D}; -static const uint8_t s_rm68191Cmd37[] = {0xD6, 0x01, 0x67, 0x01, 0xA6, 0x01, 0xD3, 0x02, 0x16, - 0x02, 0x49, 0x02, 0x4B, 0x02, 0x7B, 0x02, 0xB3}; -static const uint8_t s_rm68191Cmd38[] = {0xD7, 0x02, 0xD9, 0x03, 0x0E, 0x03, 0x31, 0x03, 0x61, - 0x03, 0x80, 0x03, 0xA5, 0x03, 0xBD, 0x03, 0xD2}; -static const uint8_t s_rm68191Cmd39[] = {0xD8, 0x03, 0xE5, 0x03, 0xFF}; -static const uint8_t s_rm68191Cmd40[] = {0xD9, 0x00, 0x00, 0x00, 0x26, 0x00, 0x5E, 0x00, 0x88, - 0x00, 0xA8, 0x00, 0xDB, 0x01, 0x02, 0x01, 0x3D}; -static const uint8_t s_rm68191Cmd41[] = {0xDD, 0x01, 0x67, 0x01, 0xA6, 0x01, 0xD3, 0x02, 0x16, - 0x02, 0x49, 0x02, 0x4B, 0x02, 0x7B, 0x02, 0xB3}; -static const uint8_t s_rm68191Cmd42[] = {0xDE, 0x02, 0xD9, 0x03, 0x0E, 0x03, 0x31, 0x03, 0x61, - 0x03, 0x80, 0x03, 0xA5, 0x03, 0xBD, 0x03, 0xD2}; -static const uint8_t s_rm68191Cmd43[] = {0xDF, 0x03, 0xE5, 0x03, 0xFF}; -static const uint8_t s_rm68191Cmd44[] = {0xE0, 0x00, 0x00, 0x00, 0x26, 0x00, 0x5E, 0x00, 0x88, - 0x00, 0xA8, 0x00, 0xDB, 0x01, 0x02, 0x01, 0x3D}; -static const uint8_t s_rm68191Cmd45[] = {0xE1, 0x01, 0x67, 0x01, 0xA6, 0x01, 0xD3, 0x02, 0x16, - 0x02, 0x49, 0x02, 0x4B, 0x02, 0x7B, 0x02, 0xB3}; -static const uint8_t s_rm68191Cmd46[] = {0xE2, 0x02, 0xD9, 0x03, 0x0E, 0x03, 0x31, 0x03, 0x61, - 0x03, 0x80, 0x03, 0xA5, 0x03, 0xBD, 0x03, 0xD2}; -static const uint8_t s_rm68191Cmd47[] = {0xE3, 0x03, 0xE5, 0x03, 0xFF}; -static const uint8_t s_rm68191Cmd48[] = {0xE4, 0x00, 0x00, 0x00, 0x26, 0x00, 0x5E, 0x00, 0x88, - 0x00, 0xA8, 0x00, 0xDB, 0x01, 0x02, 0x01, 0x3D}; -static const uint8_t s_rm68191Cmd49[] = {0xE5, 0x01, 0x67, 0x01, 0xA6, 0x01, 0xD3, 0x02, 0x16, - 0x02, 0x49, 0x02, 0x4B, 0x02, 0x7B, 0x02, 0xB3}; -static const uint8_t s_rm68191Cmd50[] = {0xE6, 0x02, 0xD9, 0x03, 0x0E, 0x03, 0x31, 0x03, 0x61, - 0x03, 0x80, 0x03, 0xA5, 0x03, 0xBD, 0x03, 0xD2}; -static const uint8_t s_rm68191Cmd51[] = {0xE7, 0x03, 0xE5, 0x03, 0xFF}; -static const uint8_t s_rm68191Cmd52[] = {0xE8, 0x00, 0x00, 0x00, 0x26, 0x00, 0x5E, 0x00, 0x88, - 0x00, 0xA8, 0x00, 0xDB, 0x01, 0x02, 0x01, 0x3D}; -static const uint8_t s_rm68191Cmd53[] = {0xE9, 0x01, 0x67, 0x01, 0xA6, 0x01, 0xD3, 0x02, 0x16, - 0x02, 0x49, 0x02, 0x4B, 0x02, 0x7B, 0x02, 0xB3}; -static const uint8_t s_rm68191Cmd54[] = {0xEA, 0x02, 0xD9, 0x03, 0x0E, 0x03, 0x31, 0x03, 0x61, - 0x03, 0x80, 0x03, 0xA5, 0x03, 0xBD, 0x03, 0xD2}; -static const uint8_t s_rm68191Cmd55[] = {0xEB, 0x03, 0xE5, 0x03, 0xFF}; -static const uint8_t s_rm68191Cmd56[] = {0xB0, 0x07, 0x07, 0x07}; -static const uint8_t s_rm68191Cmd57[] = {0xB1, 0x07, 0x07, 0x07}; -static const uint8_t s_rm68191Cmd58[] = {0xB3, 0x11, 0x11, 0x11}; -static const uint8_t s_rm68191Cmd59[] = {0xB4, 0x09, 0x09, 0x09}; -static const uint8_t s_rm68191Cmd60[] = {0xB6, 0x44, 0x44, 0x44}; -static const uint8_t s_rm68191Cmd61[] = {0xB7, 0x34, 0x34, 0x34}; -static const uint8_t s_rm68191Cmd62[] = {0xB9, 0x34, 0x34, 0x34}; -static const uint8_t s_rm68191Cmd63[] = {0xBA, 0x14, 0x14, 0x14}; -static const uint8_t s_rm68191Cmd64[] = {0xBC, 0x00, 0x98, 0x00}; -static const uint8_t s_rm68191Cmd65[] = {0xBD, 0x00, 0x98, 0x00}; -static const uint8_t s_rm68191Cmd66[] = {0xBE, 0x1D}; -static const uint8_t s_rm68191Cmd67[] = {0x35, 0x00}; - -static const rm68191_setting_t s_rm68191InitSetting[] = { - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd0), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd1), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd2), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd3), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd4), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd5), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd6), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd7), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd8), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd9), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd10), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd11), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd12), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd13), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd14), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd15), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd16), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd17), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd18), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd19), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd20), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd21), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd22), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd23), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd24), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd25), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd26), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd27), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd28), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd29), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd30), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd31), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd32), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd33), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd34), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd35), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd36), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd37), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd38), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd39), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd40), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd41), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd42), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd43), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd44), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd45), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd46), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd47), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd48), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd49), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd50), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd51), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd52), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd53), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd54), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd55), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd56), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd57), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd58), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd59), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd60), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd61), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd62), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd63), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd64), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd65), - RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd66), RM68191_MAKE_SETTING_ITEM(s_rm68191Cmd67), -}; - -const display_operations_t rm68191_ops = { - .init = RM68191_Init, - .deinit = RM68191_Deinit, - .start = RM68191_Start, - .stop = RM68191_Stop, -}; - -/******************************************************************************* - * Code - ******************************************************************************/ - -status_t RM68191_Init(display_handle_t *handle, const display_config_t *config) -{ - uint32_t i; - status_t status = kStatus_Success; - const rm68191_resource_t *resource = (const rm68191_resource_t *)(handle->resource); - mipi_dsi_device_t *dsiDevice = resource->dsiDevice; - - /* Only support 540 * 960 */ - if (config->resolution != FSL_VIDEO_RESOLUTION(540, 960)) - { - return kStatus_InvalidArgument; - } - - /* Power on. */ - resource->pullPowerPin(true); - RM68191_DelayMs(1); - - /* Perform reset. */ - resource->pullResetPin(false); - RM68191_DelayMs(1); - resource->pullResetPin(true); - RM68191_DelayMs(5); - - /* Set the LCM init settings. */ - for (i = 0; i < ARRAY_SIZE(s_rm68191InitSetting); i++) - { - status = MIPI_DSI_DCS_Write(dsiDevice, s_rm68191InitSetting[i].value, (int32_t)s_rm68191InitSetting[i].len); - - if (kStatus_Success != status) - { - return status; - } - } - - /* Exit sleep mode */ - status = MIPI_DSI_DCS_EnterSleepMode(dsiDevice, false); - - if (kStatus_Success != status) - { - return status; - } - - RM68191_DelayMs(200); - - /* Set display on. */ - status = MIPI_DSI_DCS_SetDisplayOn(dsiDevice, true); - - if (kStatus_Success != status) - { - return status; - } - - RM68191_DelayMs(200); - - return kStatus_Success; -} - -status_t RM68191_Deinit(display_handle_t *handle) -{ - const rm68191_resource_t *resource = (const rm68191_resource_t *)(handle->resource); - mipi_dsi_device_t *dsiDevice = resource->dsiDevice; - - (void)MIPI_DSI_DCS_EnterSleepMode(dsiDevice, true); - - resource->pullResetPin(false); - resource->pullPowerPin(false); - - return kStatus_Success; -} - -status_t RM68191_Start(display_handle_t *handle) -{ - const rm68191_resource_t *resource = (const rm68191_resource_t *)(handle->resource); - mipi_dsi_device_t *dsiDevice = resource->dsiDevice; - - return MIPI_DSI_DCS_SetDisplayOn(dsiDevice, true); -} - -status_t RM68191_Stop(display_handle_t *handle) -{ - const rm68191_resource_t *resource = (const rm68191_resource_t *)(handle->resource); - mipi_dsi_device_t *dsiDevice = resource->dsiDevice; - - return MIPI_DSI_DCS_SetDisplayOn(dsiDevice, false); -} diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68191.h b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68191.h deleted file mode 100644 index 2f372da00282..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68191.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2019-2020 NXP - * All rights reserved. - * - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _FSL_RM68191_H_ -#define _FSL_RM68191_H_ - -#include "fsl_display.h" -#include "fsl_mipi_dsi_cmd.h" - -/* - * Change log: - * - * 1.1.0 - * - Fix MISRA-C 2012 issues. - * - Change rm68191_resource_t structure. - * - * 1.0.0 - * - Initial version - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/*! - * @brief RM68191 resource. - */ -typedef struct _rm68191_resource -{ - mipi_dsi_device_t *dsiDevice; /*!< MIPI DSI device. */ - void (*pullResetPin)(bool pullUp); /*!< Function to pull reset pin high or low. */ - void (*pullPowerPin)(bool pullUp); /*!< Function to pull power pin high or low. */ -} rm68191_resource_t; - -extern const display_operations_t rm68191_ops; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif - -status_t RM68191_Init(display_handle_t *handle, const display_config_t *config); - -status_t RM68191_Deinit(display_handle_t *handle); - -status_t RM68191_Start(display_handle_t *handle); - -status_t RM68191_Stop(display_handle_t *handle); - -#if defined(__cplusplus) -} -#endif - -#endif /* _FSL_RM68191_H_ */ diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68200.c b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68200.c deleted file mode 100644 index 1d8c2831f52b..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68200.c +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright 2019-2021 NXP - * All rights reserved. - * - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "fsl_display.h" -#include "fsl_rm68200.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#define RM68200_DelayMs VIDEO_DelayMs - -/******************************************************************************* - * Variables - ******************************************************************************/ - -uint8_t RM68200_DDB_START[5] = {0x00, 0x00, 0x00, 0x00, 0xff}; - -static const uint8_t lcmInitPage0Setting[][2] = { - {0xFE, 0x01}, {0x24, 0xC0}, {0x25, 0x53}, {0x26, 0x00}, {0x2B, 0xE5}, {0x27, 0x0A}, - {0x29, 0x0A}, {0x16, 0x52}, {0x2F, 0x53}, {0x34, 0x5A}, {0x1B, 0x00}, {0x12, 0x0A}, - {0x1A, 0x06}, {0x46, 0x56}, {0x52, 0xA0}, {0x53, 0x00}, {0x54, 0xA0}, {0x55, 0x00}, -}; - -static const uint8_t lcmInitSetting[][2] = { - {0xFE, 0x03}, - {0x00, 0x05}, - {0x02, 0x0B}, - {0x03, 0x0F}, - {0x04, 0x7D}, - {0x05, 0x00}, - {0x06, 0x50}, - {0x07, 0x05}, - {0x08, 0x16}, - {0x09, 0x0D}, - {0x0A, 0x11}, - {0x0B, 0x7D}, - {0x0C, 0x00}, - {0x0D, 0x50}, - {0x0E, 0x07}, - {0x0F, 0x08}, - {0x10, 0x01}, - {0x11, 0x02}, - {0x12, 0x00}, - {0x13, 0x7D}, - {0x14, 0x00}, - {0x15, 0x85}, - {0x16, 0x08}, - {0x17, 0x03}, - {0x18, 0x04}, - {0x19, 0x05}, - {0x1A, 0x06}, - {0x1B, 0x00}, - {0x1C, 0x7D}, - {0x1D, 0x00}, - {0x1E, 0x85}, - {0x1F, 0x08}, - {0x20, 0x00}, - {0x21, 0x00}, - {0x22, 0x00}, - {0x23, 0x00}, - {0x24, 0x00}, - {0x25, 0x00}, - {0x26, 0x00}, - {0x27, 0x00}, - {0x28, 0x00}, - {0x29, 0x00}, - {0x2A, 0x07}, - {0x2B, 0x08}, - {0x2D, 0x01}, - {0x2F, 0x02}, - {0x30, 0x00}, - {0x31, 0x40}, - {0x32, 0x05}, - {0x33, 0x08}, - {0x34, 0x54}, - {0x35, 0x7D}, - {0x36, 0x00}, - {0x37, 0x03}, - {0x38, 0x04}, - {0x39, 0x05}, - {0x3A, 0x06}, - {0x3B, 0x00}, - {0x3D, 0x40}, - {0x3F, 0x05}, - {0x40, 0x08}, - {0x41, 0x54}, - {0x42, 0x7D}, - {0x43, 0x00}, - {0x44, 0x00}, - {0x45, 0x00}, - {0x46, 0x00}, - {0x47, 0x00}, - {0x48, 0x00}, - {0x49, 0x00}, - {0x4A, 0x00}, - {0x4B, 0x00}, - {0x4C, 0x00}, - {0x4D, 0x00}, - {0x4E, 0x00}, - {0x4F, 0x00}, - {0x50, 0x00}, - {0x51, 0x00}, - {0x52, 0x00}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x00}, - {0x56, 0x00}, - {0x58, 0x00}, - {0x59, 0x00}, - {0x5A, 0x00}, - {0x5B, 0x00}, - {0x5C, 0x00}, - {0x5D, 0x00}, - {0x5E, 0x00}, - {0x5F, 0x00}, - {0x60, 0x00}, - {0x61, 0x00}, - {0x62, 0x00}, - {0x63, 0x00}, - {0x64, 0x00}, - {0x65, 0x00}, - {0x66, 0x00}, - {0x67, 0x00}, - {0x68, 0x00}, - {0x69, 0x00}, - {0x6A, 0x00}, - {0x6B, 0x00}, - {0x6C, 0x00}, - {0x6D, 0x00}, - {0x6E, 0x00}, - {0x6F, 0x00}, - {0x70, 0x00}, - {0x71, 0x00}, - {0x72, 0x20}, - {0x73, 0x00}, - {0x74, 0x08}, - {0x75, 0x08}, - {0x76, 0x08}, - {0x77, 0x08}, - {0x78, 0x08}, - {0x79, 0x08}, - {0x7A, 0x00}, - {0x7B, 0x00}, - {0x7C, 0x00}, - {0x7D, 0x00}, - {0x7E, 0xBF}, - {0x7F, 0x02}, - {0x80, 0x06}, - {0x81, 0x14}, - {0x82, 0x10}, - {0x83, 0x16}, - {0x84, 0x12}, - {0x85, 0x08}, - {0x86, 0x3F}, - {0x87, 0x3F}, - {0x88, 0x3F}, - {0x89, 0x3F}, - {0x8A, 0x3F}, - {0x8B, 0x0C}, - {0x8C, 0x0A}, - {0x8D, 0x0E}, - {0x8E, 0x3F}, - {0x8F, 0x3F}, - {0x90, 0x00}, - {0x91, 0x04}, - {0x92, 0x3F}, - {0x93, 0x3F}, - {0x94, 0x3F}, - {0x95, 0x3F}, - {0x96, 0x05}, - {0x97, 0x01}, - {0x98, 0x3F}, - {0x99, 0x3F}, - {0x9A, 0x0F}, - {0x9B, 0x0B}, - {0x9C, 0x0D}, - {0x9D, 0x3F}, - {0x9E, 0x3F}, - {0x9F, 0x3F}, - {0xA0, 0x3F}, - {0xA2, 0x3F}, - {0xA3, 0x09}, - {0xA4, 0x13}, - {0xA5, 0x17}, - {0xA6, 0x11}, - {0xA7, 0x15}, - {0xA9, 0x07}, - {0xAA, 0x03}, - {0xAB, 0x3F}, - {0xAC, 0x3F}, - {0xAD, 0x05}, - {0xAE, 0x01}, - {0xAF, 0x17}, - {0xB0, 0x13}, - {0xB1, 0x15}, - {0xB2, 0x11}, - {0xB3, 0x0F}, - {0xB4, 0x3F}, - {0xB5, 0x3F}, - {0xB6, 0x3F}, - {0xB7, 0x3F}, - {0xB8, 0x3F}, - {0xB9, 0x0B}, - {0xBA, 0x0D}, - {0xBB, 0x09}, - {0xBC, 0x3F}, - {0xBD, 0x3F}, - {0xBE, 0x07}, - {0xBF, 0x03}, - {0xC0, 0x3F}, - {0xC1, 0x3F}, - {0xC2, 0x3F}, - {0xC3, 0x3F}, - {0xC4, 0x02}, - {0xC5, 0x06}, - {0xC6, 0x3F}, - {0xC7, 0x3F}, - {0xC8, 0x08}, - {0xC9, 0x0C}, - {0xCA, 0x0A}, - {0xCB, 0x3F}, - {0xCC, 0x3F}, - {0xCD, 0x3F}, - {0xCE, 0x3F}, - {0xCF, 0x3F}, - {0xD0, 0x0E}, - {0xD1, 0x10}, - {0xD2, 0x14}, - {0xD3, 0x12}, - {0xD4, 0x16}, - {0xD5, 0x00}, - {0xD6, 0x04}, - {0xD7, 0x3F}, - {0xDC, 0x02}, - {0xDE, 0x12}, - {0xFE, 0x0E}, - {0x01, 0x75}, - - /* Gamma Settings */ - {0xFE, 0x04}, - {0x60, 0x00}, - {0x61, 0x0C}, - {0x62, 0x12}, - {0x63, 0x0E}, - {0x64, 0x06}, - {0x65, 0x12}, - {0x66, 0x0E}, - {0x67, 0x0B}, - {0x68, 0x15}, - {0x69, 0x0B}, - {0x6A, 0x10}, - {0x6B, 0x07}, - {0x6C, 0x0F}, - {0x6D, 0x12}, - {0x6E, 0x0C}, - {0x6F, 0x00}, - {0x70, 0x00}, - {0x71, 0x0C}, - {0x72, 0x12}, - {0x73, 0x0E}, - {0x74, 0x06}, - {0x75, 0x12}, - {0x76, 0x0E}, - {0x77, 0x0B}, - {0x78, 0x15}, - {0x79, 0x0B}, - {0x7A, 0x10}, - {0x7B, 0x07}, - {0x7C, 0x0F}, - {0x7D, 0x12}, - {0x7E, 0x0C}, - {0x7F, 0x00}, - - /* Page 0. */ - {0xFE, 0x00}, - {0x11, 0x00}, -}; - -const display_operations_t rm68200_ops = { - .init = RM68200_Init, - .deinit = RM68200_Deinit, - .start = RM68200_Start, - .stop = RM68200_Stop, -}; - -/******************************************************************************* - * Code - ******************************************************************************/ - -status_t RM68200_Init(display_handle_t *handle, const display_config_t *config) -{ - uint32_t i; - uint8_t param[2]; - status_t status = kStatus_Success; - const rm68200_resource_t *resource = (const rm68200_resource_t *)(handle->resource); - mipi_dsi_device_t *dsiDevice = resource->dsiDevice; - - /* Only support 720 * 1280 */ - if (config->resolution != FSL_VIDEO_RESOLUTION(720, 1280)) - { - return kStatus_InvalidArgument; - } - - /* Power on. */ - resource->pullPowerPin(true); - RM68200_DelayMs(1); - - /* Perform reset. */ - resource->pullResetPin(false); - RM68200_DelayMs(1); - resource->pullResetPin(true); - RM68200_DelayMs(5); - - /* Set the LCM page0 init settings. */ - for (i = 0; i < ARRAY_SIZE(lcmInitPage0Setting); i++) - { - status = MIPI_DSI_GenericWrite(dsiDevice, lcmInitPage0Setting[i], 2); - - if (kStatus_Success != status) - { - return status; - } - } - - /* Data lane number selection. */ - param[0] = 0x5FU; - param[1] = 0x10U | (config->dsiLanes - 1U); - status = MIPI_DSI_GenericWrite(dsiDevice, param, 2); - if (kStatus_Success != status) - { - return status; - } - - /* Set the LCM init settings. */ - for (i = 0; i < ARRAY_SIZE(lcmInitSetting); i++) - { - status = MIPI_DSI_GenericWrite(dsiDevice, lcmInitSetting[i], 2); - - if (kStatus_Success != status) - { - return status; - } - } - - RM68200_DelayMs(200); - - param[0] = 0x29; - param[1] = 0x00; - status = MIPI_DSI_GenericWrite(dsiDevice, param, 2); - if (kStatus_Success != status) - { - return status; - } - - RM68200_DelayMs(100); - - param[0] = 0x2c; - status = MIPI_DSI_GenericWrite(dsiDevice, param, 1); - if (kStatus_Success != status) - { - return status; - } - - param[0] = 0x35; - param[1] = 0x00; - status = MIPI_DSI_GenericWrite(dsiDevice, param, 2); - if (kStatus_Success != status) - { - return status; - } - - RM68200_DelayMs(200); - - return kStatus_Success; -} - -status_t RM68200_Deinit(display_handle_t *handle) -{ - const rm68200_resource_t *resource = (const rm68200_resource_t *)(handle->resource); - mipi_dsi_device_t *dsiDevice = resource->dsiDevice; - - (void)MIPI_DSI_DCS_EnterSleepMode(dsiDevice, true); - - resource->pullResetPin(false); - resource->pullPowerPin(false); - - return kStatus_Success; -} - -status_t RM68200_Start(display_handle_t *handle) -{ - const rm68200_resource_t *resource = (const rm68200_resource_t *)(handle->resource); - mipi_dsi_device_t *dsiDevice = resource->dsiDevice; - - return MIPI_DSI_DCS_SetDisplayOn(dsiDevice, true); -} - -status_t RM68200_Stop(display_handle_t *handle) -{ - const rm68200_resource_t *resource = (const rm68200_resource_t *)(handle->resource); - mipi_dsi_device_t *dsiDevice = resource->dsiDevice; - - return MIPI_DSI_DCS_SetDisplayOn(dsiDevice, false); -} diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68200.h b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68200.h deleted file mode 100644 index f039e89e995a..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_rm68200.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2019-2021 NXP - * All rights reserved. - * - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _FSL_RM68200_H_ -#define _FSL_RM68200_H_ - -#include "fsl_display.h" -#include "fsl_mipi_dsi_cmd.h" - -/* - * Change log: - * - * 1.1.1 - * - Support 1 lane to 4 lanes, previously only support 2 lanes. - * - * 1.1.0 - * - Fix MISRA-C 2012 issues. - * - Change rm68200_resource_t structure. - * - * 1.0.0 - * - Initial version - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/*! - * @brief RM68200 resource. - */ -typedef struct _rm68200_resource -{ - mipi_dsi_device_t *dsiDevice; /*!< MIPI DSI device. */ - void (*pullResetPin)(bool pullUp); /*!< Function to pull reset pin high or low. */ - void (*pullPowerPin)(bool pullUp); /*!< Function to pull power pin high or low. */ -} rm68200_resource_t; - -extern const display_operations_t rm68200_ops; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif - -extern uint8_t RM68200_DDB_START[5]; - -status_t RM68200_Init(display_handle_t *handle, const display_config_t *config); - -status_t RM68200_Deinit(display_handle_t *handle); - -status_t RM68200_Start(display_handle_t *handle); - -status_t RM68200_Stop(display_handle_t *handle); - -#if defined(__cplusplus) -} -#endif - -#endif /* _FSL_RM68200_H_ */ diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_video_common.c b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_video_common.c deleted file mode 100644 index f8aaeef2e2da..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_video_common.c +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright 2017, 2020-2021 NXP - * All rights reserved. - * - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "fsl_video_common.h" -#if defined(SDK_OS_FREE_RTOS) -#include "FreeRTOS.h" -#include "task.h" -#endif - -/******************************************************************************* - * Code - ******************************************************************************/ - -bool VIDEO_IsYUV(video_pixel_format_t format) -{ - if ((kVIDEO_PixelFormatYUYV == format) || (kVIDEO_PixelFormatYVYU == format) || - (kVIDEO_PixelFormatUYVY == format) || (kVIDEO_PixelFormatVYUY == format) || - (kVIDEO_PixelFormatXYVU == format) || (kVIDEO_PixelFormatXYUV == format)) - { - return true; - } - else - { - return false; - } -} - -void VIDEO_DelayMs(uint32_t ms) -{ -#if defined(SDK_OS_FREE_RTOS) - TickType_t tick; - - tick = ms * configTICK_RATE_HZ / 1000U; - - tick = (0U == tick) ? 1U : tick; - - vTaskDelay(tick); -#else - while (0U != (ms--)) - { - SDK_DelayAtLeastUs(1000U, SystemCoreClock); - } -#endif -} - -uint8_t VIDEO_GetPixelSizeBits(video_pixel_format_t pixelFormat) -{ - uint8_t ret; - - switch (pixelFormat) - { - case kVIDEO_PixelFormatXRGB8888: - case kVIDEO_PixelFormatRGBX8888: - case kVIDEO_PixelFormatXBGR8888: - case kVIDEO_PixelFormatBGRX8888: - case kVIDEO_PixelFormatXYUV: - case kVIDEO_PixelFormatXYVU: - ret = 32; - break; - - case kVIDEO_PixelFormatRGB888: - case kVIDEO_PixelFormatBGR888: - ret = 24; - break; - - case kVIDEO_PixelFormatRGB565: - case kVIDEO_PixelFormatBGR565: - case kVIDEO_PixelFormatXRGB1555: - case kVIDEO_PixelFormatRGBX5551: - case kVIDEO_PixelFormatXBGR1555: - case kVIDEO_PixelFormatBGRX5551: - case kVIDEO_PixelFormatXRGB4444: - case kVIDEO_PixelFormatRGBX4444: - case kVIDEO_PixelFormatXBGR4444: - case kVIDEO_PixelFormatBGRX4444: - case kVIDEO_PixelFormatYUYV: - case kVIDEO_PixelFormatYVYU: - case kVIDEO_PixelFormatUYVY: - case kVIDEO_PixelFormatVYUY: - ret = 16; - break; - - default: - ret = 0; - break; - } - - return ret; -} - -status_t VIDEO_RINGBUF_Init(video_ringbuf_t *ringbuf, void **buf, uint32_t size) -{ - assert(ringbuf); - - ringbuf->rear = 0; - ringbuf->front = 0; - ringbuf->size = size; - ringbuf->buf = buf; - - return kStatus_Success; -} - -status_t VIDEO_RINGBUF_Get(video_ringbuf_t *ringbuf, void **item) -{ - uint32_t front_next; - - /* To fix IAR Pa082 warning. */ - uint32_t rear = ringbuf->rear; - uint32_t front = ringbuf->front; - - if (rear != front) - { - *item = ringbuf->buf[ringbuf->front]; - - /* - * Here don't use ringbuf->front = (ringbuf->front + 1) % ringbuf->size, - * because mod operation might be slow. - */ - front_next = (ringbuf->front + 1U); - - /* Use two steps to make sure ringbuf->front is always a valid value. */ - ringbuf->front = (front_next == ringbuf->size) ? 0UL : front_next; - - return kStatus_Success; - } - else - { - return kStatus_Fail; - } -} - -status_t VIDEO_RINGBUF_Put(video_ringbuf_t *ringbuf, void *item) -{ - /* - * Here don't use ringbuf->rear = (ringbuf->rear + 1) % ringbuf->size, - * because mod operation might be slow. - */ - uint32_t rear_next = ringbuf->rear + 1U; - - rear_next = (rear_next == ringbuf->size) ? 0U : rear_next; - - if (rear_next != ringbuf->front) - { - ringbuf->buf[ringbuf->rear] = item; - ringbuf->rear = rear_next; - - return kStatus_Success; - } - /* No room. */ - else - { - return kStatus_Fail; - } -} - -uint32_t VIDEO_RINGBUF_GetLength(video_ringbuf_t *ringbuf) -{ - uint32_t ret; - - /* To fix IAR Pa082 warning. */ - uint32_t rear = ringbuf->rear; - uint32_t front = ringbuf->front; - - ret = (rear + ringbuf->size) - front; - - if (ret >= ringbuf->size) - { - ret -= ringbuf->size; - } - - return ret; -} - -bool VIDEO_RINGBUF_IsEmpty(video_ringbuf_t *ringbuf) -{ - /* To fix IAR Pa082 warning. */ - uint32_t rear = ringbuf->rear; - uint32_t front = ringbuf->front; - - if (rear == front) - { - return true; - } - else - { - return false; - } -} - -bool VIDEO_RINGBUF_IsFull(video_ringbuf_t *ringbuf) -{ - uint32_t rear = ringbuf->rear; - uint32_t front = ringbuf->front; - - rear++; - - if (rear >= ringbuf->size) - { - rear = 0; - } - - if (rear == front) - { - return true; - } - else - { - return false; - } -} - -status_t VIDEO_MEMPOOL_Init(video_mempool_t *mempool, void *initMem, uint32_t size, uint32_t count) -{ - (void)memset(mempool, 0, sizeof(video_mempool_t)); - - while (0U != (count--)) - { - VIDEO_MEMPOOL_Put(mempool, initMem); - initMem = &((uint8_t *)initMem)[size]; - } - - return kStatus_Success; -} - -void VIDEO_MEMPOOL_InitEmpty(video_mempool_t *mempool) -{ - mempool->pool = NULL; - mempool->cnt = 0; -} - -void VIDEO_MEMPOOL_Put(video_mempool_t *mempool, void *mem) -{ - *(void **)mem = mempool->pool; - mempool->pool = mem; - mempool->cnt++; -} - -void *VIDEO_MEMPOOL_Get(video_mempool_t *mempool) -{ - void *mem = mempool->pool; - - if (NULL != mem) - { - mempool->cnt--; - mempool->pool = *(void **)mem; - } - - return mem; -} - -uint32_t VIDEO_MEMPOOL_GetCount(video_mempool_t *mempool) -{ - return mempool->cnt; -} diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_video_common.h b/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_video_common.h deleted file mode 100644 index b4b0ce78e22e..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/fsl_video_common.h +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright 2017, 2020-2021 NXP - * All rights reserved. - * - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _FSL_VIDEO_COMMON_H_ -#define _FSL_VIDEO_COMMON_H_ - -#include "fsl_common.h" - -/* - * Change log: - * - * 1.0.5 - * - Fix IAR Pa082 warning. - * - * 1.0.4 - * - Add LUT8 definition. - * - * 1.0.3 - * - Add RAW8 definition. - * - * 1.0.2 - * - Fixed MISRA-C 2012 issues. - * - * 1.0.1 - * - Update the VIDEO_DelayMs for bare metal. - * - * 1.0.0 - * - Initial version - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/*! @brief Pixel format FOURCC. */ -#define FSL_VIDEO_FOURCC(a, b, c, d) \ - ((uint32_t)(a) | ((uint32_t)(b) << 8U) | ((uint32_t)(c) << 16U) | ((uint32_t)(d) << 24U)) - -/*! @brief Macro to define resolution. */ -#define FSL_VIDEO_RESOLUTION(width, height) ((uint32_t)(width) | ((uint32_t)(height) << 16U)) - -#define FSL_VIDEO_EXTRACT_WIDTH(resolution) ((uint16_t)((resolution)&0xFFFFU)) -#define FSL_VIDEO_EXTRACT_HEIGHT(resolution) ((uint16_t)((resolution) >> 16U)) - -/*! @brief Pixel format definition. */ -typedef enum _video_pixel_format -{ - /* RAW */ - kVIDEO_PixelFormatRAW8 = FSL_VIDEO_FOURCC('G', 'R', 'B', 'G'), /*!< RAW8, GRBG. */ - - /* LUT/palette */ - kVIDEO_PixelFormatLUT8 = FSL_VIDEO_FOURCC('L', 'U', 'T', '8'), /*!< 8-bit Indexed Color. */ - - /* RGB */ - kVIDEO_PixelFormatXRGB8888 = FSL_VIDEO_FOURCC('X', 'R', '2', '4'), /*!< 32-bit XRGB8888. */ - kVIDEO_PixelFormatRGBX8888 = FSL_VIDEO_FOURCC('R', 'X', '2', '4'), /*!< 32-bit RGBX8888. */ - kVIDEO_PixelFormatXBGR8888 = FSL_VIDEO_FOURCC('X', 'B', '2', '4'), /*!< 32-bit XBGR8888. */ - kVIDEO_PixelFormatBGRX8888 = FSL_VIDEO_FOURCC('B', 'X', '2', '4'), /*!< 32-bit BGRX8888. */ - - kVIDEO_PixelFormatRGB888 = FSL_VIDEO_FOURCC('R', 'G', '2', '4'), /*!< 24-bit RGB888. */ - kVIDEO_PixelFormatBGR888 = FSL_VIDEO_FOURCC('B', 'G', '2', '4'), /*!< 24-bit BGR888. */ - - kVIDEO_PixelFormatRGB565 = FSL_VIDEO_FOURCC('R', 'G', '1', '6'), /*!< 16-bit RGB565. */ - kVIDEO_PixelFormatBGR565 = FSL_VIDEO_FOURCC('B', 'G', '1', '6'), /*!< 16-bit BGR565. */ - - kVIDEO_PixelFormatXRGB1555 = FSL_VIDEO_FOURCC('X', 'R', '1', '5'), /*!< 16-bit XRGB1555. */ - kVIDEO_PixelFormatRGBX5551 = FSL_VIDEO_FOURCC('R', 'X', '1', '5'), /*!< 16-bit RGBX5551. */ - kVIDEO_PixelFormatXBGR1555 = FSL_VIDEO_FOURCC('X', 'B', '1', '5'), /*!< 16-bit XBGR1555. */ - kVIDEO_PixelFormatBGRX5551 = FSL_VIDEO_FOURCC('B', 'X', '1', '5'), /*!< 16-bit BGRX5551. */ - - kVIDEO_PixelFormatXRGB4444 = FSL_VIDEO_FOURCC('X', 'R', '1', '2'), /*!< 16-bit XRGB4444. */ - kVIDEO_PixelFormatRGBX4444 = FSL_VIDEO_FOURCC('R', 'X', '1', '2'), /*!< 16-bit RGBX4444. */ - kVIDEO_PixelFormatXBGR4444 = FSL_VIDEO_FOURCC('X', 'B', '1', '2'), /*!< 16-bit XBGR4444. */ - kVIDEO_PixelFormatBGRX4444 = FSL_VIDEO_FOURCC('B', 'X', '1', '2'), /*!< 16-bit BGRX4444. */ - - /* YUV. */ - kVIDEO_PixelFormatYUYV = FSL_VIDEO_FOURCC('Y', 'U', 'Y', 'V'), /*!< YUV422, Y-U-Y-V. */ - kVIDEO_PixelFormatYVYU = FSL_VIDEO_FOURCC('Y', 'V', 'Y', 'U'), /*!< YUV422, Y-V-Y-U. */ - kVIDEO_PixelFormatUYVY = FSL_VIDEO_FOURCC('U', 'Y', 'V', 'Y'), /*!< YUV422, U-Y-V-Y. */ - kVIDEO_PixelFormatVYUY = FSL_VIDEO_FOURCC('V', 'Y', 'U', 'Y'), /*!< YUV422, V-Y-U-Y. */ - - kVIDEO_PixelFormatXYUV = FSL_VIDEO_FOURCC('X', 'Y', 'U', 'V'), /*!< YUV444, X-Y-U-V. */ - kVIDEO_PixelFormatXYVU = FSL_VIDEO_FOURCC('X', 'Y', 'V', 'U'), /*!< YUV444, X-Y-V-U. */ -} video_pixel_format_t; - -/*! @brief Resolution definition. */ -typedef enum _video_resolution -{ - kVIDEO_ResolutionVGA = FSL_VIDEO_RESOLUTION(640, 480), /*!< VGA, 640 * 480 */ - kVIDEO_ResolutionQVGA = FSL_VIDEO_RESOLUTION(320, 240), /*!< QVGA, 320 * 240 */ - kVIDEO_ResolutionQQVGA = FSL_VIDEO_RESOLUTION(160, 120), /*!< QQVGA, 160 * 120 */ - kVIDEO_ResolutionCIF = FSL_VIDEO_RESOLUTION(352, 288), /*!< CIF, 352 * 288 */ - kVIDEO_ResolutionQCIF = FSL_VIDEO_RESOLUTION(176, 144), /*!< QCIF, 176 * 144 */ - kVIDEO_ResolutionQQCIF = FSL_VIDEO_RESOLUTION(88, 72), /*!< QQCIF, 88 * 72 */ - kVIDEO_Resolution720P = FSL_VIDEO_RESOLUTION(1280, 720), /*!< 720P, 1280 * 720 */ - kVIDEO_Resolution1080P = FSL_VIDEO_RESOLUTION(1920, 1080), /*!< 1080P, 1920 * 1280*/ - kVIDEO_ResolutionWXGA = FSL_VIDEO_RESOLUTION(1280, 800), /*!< WXGA, 1280 * 800 */ -} video_resolution_t; - -/*! - * @brief Ring buffer structure. - * - * There is one empty room reserved in the ring buffer, used to distinguish - * whether the ring buffer is full or empty. When rear equals front, it is empty; - * when rear+1 equals front, it is full. - */ -typedef struct -{ - volatile uint32_t rear; /*!< Pointer to save the incoming item. */ - volatile uint32_t front; /*!< Pointer to read out the item. */ - void *volatile *buf; /*!< Memory to the ring buffer. */ - uint32_t size; /*!< Ring buffer total size. */ -} video_ringbuf_t; - -/*! - * @brief Memory pool structure. - */ -typedef struct -{ - void *volatile pool; /*!< Pointer to the pool. */ - volatile uint32_t cnt; /*!< Count of memory blocks in the pool. */ -} video_mempool_t; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif - -/*! - * @name Common - * @{ - */ - -/*! - * @brief Check the pixel format is YUV or not. - * - * @param format Pixel format. - */ -bool VIDEO_IsYUV(video_pixel_format_t format); - -/*! - * @brief Delay the specific time. - * - * @param ms How many milli-second to delay. - */ -void VIDEO_DelayMs(uint32_t ms); - -/*! - * @brief Get the pixel size in bits. - * - * @param pixelFormat The pixel format. - * @return Bits per pixel. - */ -uint8_t VIDEO_GetPixelSizeBits(video_pixel_format_t pixelFormat); - -/* @} */ - -/*! - * @name Ring buffer. - * @{ - */ - -/*! - * @brief Initializes ring buffer. - * - * @param ringbuf Pointer to the ring buffer handle. - * @param buf Memory to save the items. - * @param size Size of the @p buf. - * @return Returns @ref kStatus_Success if initialize success, otherwise returns - * error code. - */ -status_t VIDEO_RINGBUF_Init(video_ringbuf_t *ringbuf, void **buf, uint32_t size); - -/*! - * @brief Get one item from the ring buffer. - * - * @param ringbuf Pointer to the ring buffer handle. - * @param item Memory to save the item. - * @return Returns @ref kStatus_Success if get success, otherwise returns - * error code. - */ -status_t VIDEO_RINGBUF_Get(video_ringbuf_t *ringbuf, void **item); - -/*! - * @brief Put one item to the ring buffer. - * - * @param ringbuf Pointer to the ring buffer handle. - * @param item The new item to save. - * @return Returns @ref kStatus_Success if put success, otherwise returns - * error code. - */ -status_t VIDEO_RINGBUF_Put(video_ringbuf_t *ringbuf, void *item); - -/*! - * @brief Get current count of items in the ring buffer. - * - * @param ringbuf Pointer to the ring buffer handle. - * @return Returns the item count. - */ -uint32_t VIDEO_RINGBUF_GetLength(video_ringbuf_t *ringbuf); - -/*! - * @brief Check whether the ring buffer is empty. - * - * @param ringbuf Pointer to the ring buffer handle. - * @return Returns true if the ring buffer is empty, otherwise returns false. - */ -bool VIDEO_RINGBUF_IsEmpty(video_ringbuf_t *ringbuf); - -/*! - * @brief Check whether the ring buffer is full. - * - * @param ringbuf Pointer to the ring buffer handle. - * @return Returns true if the ring buffer is full, otherwise returns false. - */ -bool VIDEO_RINGBUF_IsFull(video_ringbuf_t *ringbuf); -/* @} */ - -/*! - * @name Memory Pool - * - * User can put memory block to the pool, or get memory block from the pool. - * There is no count limitation to put memory block in to the pool. The memory - * content in the pool might be modified. - * - * The memory block should be 4-byte aligned, and the dividable by 4-byte. - * - * @{ - */ - -/*! - * @brief Initializes memory pool. - * - * Initializes memory pool. Initial memory blocks in the memory pool is optional. - * If initial blocks are used, user should specify the initial block size and count. - * - * @param mempool Pointer to the memory pool handle. - * @param initMem Initial memory blocks to saved in the pool. - * @param size Every memory block's size (bytes) in the @p initMem. - * @param count Number of memory blocks @p initMem. - * @return Returns @ref kStatus_Success if initialize success, otherwise returns - * error code. - */ -status_t VIDEO_MEMPOOL_Init(video_mempool_t *mempool, void *initMem, uint32_t size, uint32_t count); - -/*! - * @brief Create an empty memory pool. - * - * @param mempool Pointer to the memory pool handle. - */ -void VIDEO_MEMPOOL_InitEmpty(video_mempool_t *mempool); - -/*! - * @brief Put memory block in the pool. - * - * @param mempool Pointer to the memory pool handle. - * @param mem Pointer to the memory block. - */ -void VIDEO_MEMPOOL_Put(video_mempool_t *mempool, void *mem); - -/*! - * @brief Get memory block in the pool. - * - * @param mempool Pointer to the memory pool handle. - * @return The memory block get from pool. If the pool is empty, returns NULL. - */ -void *VIDEO_MEMPOOL_Get(video_mempool_t *mempool); - -/*! - * @brief How many memory blocks in the pool. - * - * @param mempool Pointer to the memory pool handle. - * @return The memory block count in the pool - */ -uint32_t VIDEO_MEMPOOL_GetCount(video_mempool_t *mempool); - -/* @} */ - -#if defined(__cplusplus) -} -#endif - -#endif /* _FSL_VIDEO_COMMON_H_ */ diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/lvgl_support.c b/ports/mimxrt/boards/MIMXRT1170_EVK/lvgl_support.c deleted file mode 100644 index 43edaf109132..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/lvgl_support.c +++ /dev/null @@ -1,581 +0,0 @@ -/* - * Copyright 2019-2022 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" -#include "fsl_cache.h" -// #include "fsl_debug_console.h" - -#include "fsl_gt911.h" - -#if LV_USE_GPU_NXP_VG_LITE -#include "vg_lite.h" -#include "vg_lite_platform.h" -#endif - -#if LV_USE_GPU_NXP_PXP -// #include "../lvgl/lvgl/src/draw/nxp/pxp/lv_draw_pxp_blend.h" -#endif - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/* Ratate panel or not. */ -#ifndef DEMO_USE_ROTATE -#if LV_USE_GPU_NXP_PXP -#define DEMO_USE_ROTATE 1 -#else -#define DEMO_USE_ROTATE 0 -#endif -#endif - -/* Cache line size. */ -#ifndef FSL_FEATURE_L2CACHE_LINESIZE_BYTE -#define FSL_FEATURE_L2CACHE_LINESIZE_BYTE 0 -#endif -#ifndef FSL_FEATURE_L1DCACHE_LINESIZE_BYTE -#define FSL_FEATURE_L1DCACHE_LINESIZE_BYTE 0 -#endif - -#if (FSL_FEATURE_L2CACHE_LINESIZE_BYTE > FSL_FEATURE_L1DCACHE_LINESIZE_BYTE) -#define DEMO_CACHE_LINE_SIZE FSL_FEATURE_L2CACHE_LINESIZE_BYTE -#else -#define DEMO_CACHE_LINE_SIZE FSL_FEATURE_L1DCACHE_LINESIZE_BYTE -#endif - -#if (DEMO_CACHE_LINE_SIZE > FRAME_BUFFER_ALIGN) -#define DEMO_FB_ALIGN DEMO_CACHE_LINE_SIZE -#else -#define DEMO_FB_ALIGN FRAME_BUFFER_ALIGN -#endif - -#if (LV_ATTRIBUTE_MEM_ALIGN_SIZE > DEMO_FB_ALIGN) -#undef DEMO_FB_ALIGN -#define DEMO_FB_ALIGN LV_ATTRIBUTE_MEM_ALIGN_SIZE -#endif - -#define DEMO_FB_SIZE \ - (((DEMO_BUFFER_WIDTH * DEMO_BUFFER_HEIGHT * LCD_FB_BYTE_PER_PIXEL) + DEMO_FB_ALIGN - 1) & ~(DEMO_FB_ALIGN - 1)) - -#if LV_USE_GPU_NXP_VG_LITE -#define VG_LITE_MAX_CONTIGUOUS_SIZE 0x200000 -#define VG_LITE_COMMAND_BUFFER_SIZE (256 << 10) -#endif - -#if DEMO_USE_ROTATE -#define LVGL_BUFFER_WIDTH DEMO_BUFFER_HEIGHT -#define LVGL_BUFFER_HEIGHT DEMO_BUFFER_WIDTH -#else -#define LVGL_BUFFER_WIDTH DEMO_BUFFER_WIDTH -#define LVGL_BUFFER_HEIGHT DEMO_BUFFER_HEIGHT -#endif - -#if __CORTEX_M == 4 -#define DEMO_FLUSH_DCACHE() L1CACHE_CleanInvalidateSystemCache() -#else -#define DEMO_FLUSH_DCACHE() SCB_CleanInvalidateDCache() -#endif - -/******************************************************************************* - * Prototypes - ******************************************************************************/ -// static void DEMO_FlushDisplay(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p); -static void DEMO_FlushDisplay(lv_display_t * disp, const lv_area_t * area, uint8_t * px_map); - -#if 0 && (LV_USE_GPU_NXP_VG_LITE || LV_USE_GPU_NXP_PXP) -static void DEMO_CleanInvalidateCache(lv_disp_drv_t *disp_drv); -#endif - -static void DEMO_InitTouch(void); - -// static void DEMO_ReadTouch(lv_indev_drv_t *drv, lv_indev_data_t *data); -static void DEMO_ReadTouch(lv_indev_t * indev_drv, lv_indev_data_t * data); - -static void DEMO_BufferSwitchOffCallback(void *param, void *switchOffBuffer); - -static void BOARD_PullMIPIPanelTouchResetPin(bool pullUp); - -static void BOARD_ConfigMIPIPanelTouchIntPin(gt911_int_pin_mode_t mode); - -#if LV_USE_GPU_NXP_VG_LITE -static status_t BOARD_PrepareVGLiteController(void); - -static status_t BOARD_InitVGliteClock(void); -#endif /* LV_USE_GPU_NXP_VG_LITE */ - -static void DEMO_WaitBufferSwitchOff(void); - -/******************************************************************************* - * Variables - ******************************************************************************/ -SDK_ALIGN(static uint8_t __attribute__((section(".sdram"))) s_frameBuffer[2][DEMO_FB_SIZE], DEMO_FB_ALIGN); -#if DEMO_USE_ROTATE -SDK_ALIGN(static uint8_t __attribute__((section(".sdram"))) s_lvglBuffer[1][DEMO_FB_SIZE], DEMO_FB_ALIGN); -#endif - -#if defined(SDK_OS_FREE_RTOS) -static SemaphoreHandle_t s_transferDone; -#else -static volatile bool s_transferDone; -#endif - -#if DEMO_USE_ROTATE -/* - * When rotate is used, LVGL stack draws in one buffer (s_lvglBuffer), and LCD - * driver uses two buffers (s_frameBuffer) to remove tearing effect. - */ -static void *volatile s_inactiveFrameBuffer; -#endif - -static gt911_handle_t s_touchHandle; -static const gt911_config_t s_touchConfig = { - .I2C_SendFunc = BOARD_MIPIPanelTouch_I2C_Send, - .I2C_ReceiveFunc = BOARD_MIPIPanelTouch_I2C_Receive, - .pullResetPinFunc = BOARD_PullMIPIPanelTouchResetPin, - .intPinFunc = BOARD_ConfigMIPIPanelTouchIntPin, - .timeDelayMsFunc = VIDEO_DelayMs, - .touchPointNum = 1, - .i2cAddrMode = kGT911_I2cAddrMode0, - .intTrigMode = kGT911_IntRisingEdge, -}; -static int s_touchResolutionX; -static int s_touchResolutionY; - -#if LV_USE_GPU_NXP_VG_LITE -static uint32_t registerMemBase = 0x41800000; -static uint32_t gpu_mem_base = 0x0; - -/* - * In case custom VGLite memory parameters are used, the application needs to - * allocate and publish the VGLite heap base, its size and the size of the - * command buffer(s) using the following global variables: - */ -extern void *vglite_heap_base; -extern uint32_t vglite_heap_size; -extern uint32_t vglite_cmd_buff_size; - -#if (CUSTOM_VGLITE_MEMORY_CONFIG == 0) -/* VGLite driver heap */ -AT_NONCACHEABLE_SECTION_ALIGN(static uint8_t vglite_contiguous_mem[VG_LITE_MAX_CONTIGUOUS_SIZE], 64); - -void *vglite_heap_base = &vglite_contiguous_mem; -uint32_t vglite_heap_size = VG_LITE_MAX_CONTIGUOUS_SIZE; -uint32_t vglite_cmd_buff_size = VG_LITE_COMMAND_BUFFER_SIZE; -#endif /* CUSTOM_VGLITE_MEMORY_CONFIG */ - -#endif /* LV_USE_GPU_NXP_VG_LITE */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -void lv_port_pre_init(void) { -} - -void lv_port_disp_init(void) { - // static lv_disp_draw_buf_t disp_buf; - - BOARD_InitMipiPanelPins(); - - memset(s_frameBuffer, 0, sizeof(s_frameBuffer)); - #if DEMO_USE_ROTATE - memset(s_lvglBuffer, 0, sizeof(s_lvglBuffer)); - // lv_disp_draw_buf_init(&disp_buf, s_lvglBuffer[0], NULL, DEMO_BUFFER_WIDTH * DEMO_BUFFER_HEIGHT); - #else - // lv_disp_draw_buf_init(&disp_buf, s_frameBuffer[0], s_frameBuffer[1], DEMO_BUFFER_WIDTH * DEMO_BUFFER_HEIGHT); - #endif - - status_t status; - dc_fb_info_t fbInfo; - - #if LV_USE_GPU_NXP_VG_LITE - /* Initialize GPU. */ - BOARD_PrepareVGLiteController(); - #endif - - /*------------------------- - * Initialize your display - * -----------------------*/ - BOARD_PrepareDisplayController(); - - status = g_dc.ops->init(&g_dc); - if (kStatus_Success != status) { - assert(0); - } - - g_dc.ops->getLayerDefaultConfig(&g_dc, 0, &fbInfo); - fbInfo.pixelFormat = DEMO_BUFFER_PIXEL_FORMAT; - fbInfo.width = DEMO_BUFFER_WIDTH; - fbInfo.height = DEMO_BUFFER_HEIGHT; - fbInfo.startX = DEMO_BUFFER_START_X; - fbInfo.startY = DEMO_BUFFER_START_Y; - fbInfo.strideBytes = DEMO_BUFFER_STRIDE_BYTE; - g_dc.ops->setLayerConfig(&g_dc, 0, &fbInfo); - - g_dc.ops->setCallback(&g_dc, 0, DEMO_BufferSwitchOffCallback, NULL); - - #if defined(SDK_OS_FREE_RTOS) - s_transferDone = xSemaphoreCreateBinary(); - if (NULL == s_transferDone) { - PRINTF("Frame semaphore create failed\r\n"); - assert(0); - } - #else - s_transferDone = false; - #endif - - #if DEMO_USE_ROTATE - /* s_frameBuffer[1] is first shown in the panel, s_frameBuffer[0] is inactive. */ - s_inactiveFrameBuffer = (void *)s_frameBuffer[0]; - #endif - - /* lvgl starts render in frame buffer 0, so show frame buffer 1 first. */ - g_dc.ops->setFrameBuffer(&g_dc, 0, (void *)s_frameBuffer[1]); - - /* Wait for frame buffer sent to display controller video memory. */ - if ((g_dc.ops->getProperty(&g_dc) & kDC_FB_ReserveFrameBuffer) == 0) { - DEMO_WaitBufferSwitchOff(); - } - - g_dc.ops->enableLayer(&g_dc, 0); - - /*----------------------------------- - * Register the display in LittlevGL - *----------------------------------*/ - - // Changes in master (v9 development) https://github.com/lvgl/lvgl/issues/4011 - - // static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ - // lv_disp_drv_init(&disp_drv); /*Basic initialization*/ - - lv_display_t * disp = lv_display_create(LCD_WIDTH, LCD_HEIGHT); - lv_display_set_flush_cb(disp, (void *)DEMO_FlushDisplay); - lv_display_set_buffers(disp, s_frameBuffer[0], s_frameBuffer[1], DEMO_BUFFER_WIDTH*DEMO_BUFFER_HEIGHT*DEMO_BUFFER_BYTE_PER_PIXEL, LCD_RENDER_MODE); - - /*Set up the functions to access to your display*/ - - /*Set the resolution of the display*/ - // disp_drv.hor_res = LVGL_BUFFER_WIDTH; - // disp_drv.ver_res = LVGL_BUFFER_HEIGHT; - - /*Used to copy the buffer's content to the display*/ - // disp_drv.flush_cb = DEMO_FlushDisplay; - - // #if (LV_USE_GPU_NXP_VG_LITE || LV_USE_GPU_NXP_PXP) - // disp_drv.clean_dcache_cb = DEMO_CleanInvalidateCache; - // #endif - - /*Set a display buffer*/ - // disp_drv.draw_buf = &disp_buf; - - /* Partial refresh */ - // disp_drv.full_refresh = 0; - // disp_drv.direct_mode = 1; - - /*Finally register the driver*/ - // lv_disp_drv_register(&disp_drv); - - #if LV_USE_GPU_NXP_VG_LITE - if (vg_lite_init(64, 64) != VG_LITE_SUCCESS) { - PRINTF("VGLite init error. STOP."); - vg_lite_close(); - assert(0); - } - #endif -} - -void lv_port_disp_deinit(void) { - BOARD_DeinitLcdPanel(); -} - -static void DEMO_BufferSwitchOffCallback(void *param, void *switchOffBuffer) { - #if defined(SDK_OS_FREE_RTOS) - BaseType_t taskAwake = pdFALSE; - - xSemaphoreGiveFromISR(s_transferDone, &taskAwake); - portYIELD_FROM_ISR(taskAwake); - #else - s_transferDone = true; - #endif - - #if DEMO_USE_ROTATE - s_inactiveFrameBuffer = switchOffBuffer; - #endif -} - -#if 0 && (LV_USE_GPU_NXP_VG_LITE || LV_USE_GPU_NXP_PXP) -static void DEMO_CleanInvalidateCache(lv_disp_drv_t *disp_drv) { - DEMO_FLUSH_DCACHE(); -} -#endif - -static void DEMO_WaitBufferSwitchOff(void) { - #if defined(SDK_OS_FREE_RTOS) - if (xSemaphoreTake(s_transferDone, portMAX_DELAY) != pdTRUE) { - PRINTF("Display flush failed\r\n"); - assert(0); - } - #else - while (false == s_transferDone) { - } - s_transferDone = false; - #endif -} - - -#if 1 - -void DEMO_FlushDisplay(lv_display_t * disp_drv, const lv_area_t * area, uint8_t * color_p) { -// static void DEMO_FlushDisplay(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) { - // D2_On(); - - if (!lv_disp_flush_is_last(disp_drv)) { - lv_disp_flush_ready(disp_drv); - // D2_Off(); - return; - } - #if DEMO_USE_ROTATE - - /* - * Work flow: - * - * 1. Wait for the available inactive frame buffer to draw. - * 2. Draw the ratated frame to inactive buffer. - * 3. Pass inactive to LCD controller to show. - */ - - static bool firstFlush = true; - - /* Only wait for the first time. */ - if (firstFlush) { - firstFlush = false; - } else { - /* Wait frame buffer. */ - DEMO_WaitBufferSwitchOff(); - } - - DEMO_FLUSH_DCACHE(); - - /* Copy buffer. */ - void *inactiveFrameBuffer = s_inactiveFrameBuffer; - - #if LV_USE_GPU_NXP_PXP /* Use PXP to rotate the panel. */ - lv_area_t dest_area = { - .x1 = 0, - .x2 = DEMO_BUFFER_HEIGHT - 1, - .y1 = 0, - .y2 = DEMO_BUFFER_WIDTH - 1, - }; - - lv_gpu_nxp_pxp_blit(((lv_color_t *)inactiveFrameBuffer), &dest_area, DEMO_BUFFER_WIDTH, color_p, area, DEMO_BUFFER_HEIGHT, LV_OPA_COVER, - LV_DISP_ROT_270); - - - - - #else /* Use CPU to rotate the panel. */ - for (uint32_t y = 0; y < LVGL_BUFFER_HEIGHT; y++) - { - for (uint32_t x = 0; x < LVGL_BUFFER_WIDTH; x++) - { - ((lv_color_t *)inactiveFrameBuffer)[(DEMO_BUFFER_HEIGHT - x) * DEMO_BUFFER_WIDTH + y] = - color_p[y * LVGL_BUFFER_WIDTH + x]; - } - } - #endif - - DEMO_FLUSH_DCACHE(); - - g_dc.ops->setFrameBuffer(&g_dc, 0, inactiveFrameBuffer); - - /* IMPORTANT!!! - * Inform the graphics library that you are ready with the flushing*/ - lv_disp_flush_ready(disp_drv); - - #else /* DEMO_USE_ROTATE */ - DEMO_FLUSH_DCACHE(); - - g_dc.ops->setFrameBuffer(&g_dc, 0, (void *)color_p); - - DEMO_WaitBufferSwitchOff(); - - /* IMPORTANT!!! - * Inform the graphics library that you are ready with the flushing*/ - lv_disp_flush_ready(disp_drv); - #endif /* DEMO_USE_ROTATE */ - // D2_Off(); -} - -#else - -void DEMO_FlushDisplay(lv_display_t * disp, const lv_area_t * area, uint8_t * px_map) -{ - static bool firstFlush = true; - - if (firstFlush) - { firstFlush = false;} - else - { DEMO_WaitBufferSwitchOff();} - - DEMO_FLUSH_DCACHE(); - - void *inactiveFrameBuffer = s_inactiveFrameBuffer; - - for (uint32_t y = 0; y < LVGL_BUFFER_HEIGHT; y++) - { - for (uint32_t x = 0; x < LVGL_BUFFER_WIDTH; x++) - { - ((uint8_t *)inactiveFrameBuffer)[(DEMO_BUFFER_HEIGHT - x) * DEMO_BUFFER_WIDTH + y] = - px_map[y * LVGL_BUFFER_WIDTH + x]; - } - } - - g_dc.ops->setFrameBuffer(&g_dc, 0, inactiveFrameBuffer); - - lv_disp_flush_ready(disp); -} -#endif - -void lv_port_indev_init(void) { - BOARD_MIPIPanelTouch_I2C_Init(); - // 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); - - lv_indev_t * indev = lv_indev_create(); - lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER); - lv_indev_set_read_cb(indev, DEMO_ReadTouch); - -} - -static void BOARD_PullMIPIPanelTouchResetPin(bool pullUp) { - if (pullUp) { - GPIO_PinWrite(BOARD_MIPI_PANEL_TOUCH_RST_GPIO, BOARD_MIPI_PANEL_TOUCH_RST_PIN, 1); - } else { - GPIO_PinWrite(BOARD_MIPI_PANEL_TOUCH_RST_GPIO, BOARD_MIPI_PANEL_TOUCH_RST_PIN, 0); - } -} - -static void BOARD_ConfigMIPIPanelTouchIntPin(gt911_int_pin_mode_t mode) { - if (mode == kGT911_IntPinInput) { - BOARD_MIPI_PANEL_TOUCH_INT_GPIO->GDIR &= ~(1UL << BOARD_MIPI_PANEL_TOUCH_INT_PIN); - } else { - if (mode == kGT911_IntPinPullDown) { - GPIO_PinWrite(BOARD_MIPI_PANEL_TOUCH_INT_GPIO, BOARD_MIPI_PANEL_TOUCH_INT_PIN, 0); - } else { - GPIO_PinWrite(BOARD_MIPI_PANEL_TOUCH_INT_GPIO, BOARD_MIPI_PANEL_TOUCH_INT_PIN, 1); - } - - BOARD_MIPI_PANEL_TOUCH_INT_GPIO->GDIR |= (1UL << BOARD_MIPI_PANEL_TOUCH_INT_PIN); - } -} - -/*Initialize your touchpad*/ -static void DEMO_InitTouch(void) { - status_t status; - - const gpio_pin_config_t resetPinConfig = { - .direction = kGPIO_DigitalOutput, .outputLogic = 0, .interruptMode = kGPIO_NoIntmode - }; - GPIO_PinInit(BOARD_MIPI_PANEL_TOUCH_INT_GPIO, BOARD_MIPI_PANEL_TOUCH_INT_PIN, &resetPinConfig); - GPIO_PinInit(BOARD_MIPI_PANEL_TOUCH_RST_GPIO, BOARD_MIPI_PANEL_TOUCH_RST_PIN, &resetPinConfig); - - status = GT911_Init(&s_touchHandle, &s_touchConfig); - - if (kStatus_Success != status) { - PRINTF("Touch IC initialization failed\r\n"); - // assert(false); - } - - GT911_GetResolution(&s_touchHandle, &s_touchResolutionX, &s_touchResolutionY); -} - -/* Will be called by the library to read the touchpad */ -static void DEMO_ReadTouch(lv_indev_t * drv, lv_indev_data_t * data) { -// static void DEMO_ReadTouch(lv_indev_drv_t *drv, lv_indev_data_t *data) { - // D4_On(); - static int touch_x = 0; - static int touch_y = 0; - - if (kStatus_Success == GT911_GetSingleTouch(&s_touchHandle, &touch_x, &touch_y)) { - data->state = LV_INDEV_STATE_PR; - } else { - data->state = LV_INDEV_STATE_REL; - } - - /*Set the last pressed coordinates*/ - #if DEMO_USE_ROTATE - data->point.x = DEMO_PANEL_HEIGHT - (touch_y * DEMO_PANEL_HEIGHT / s_touchResolutionY); - data->point.y = touch_x * DEMO_PANEL_WIDTH / s_touchResolutionX; - #else - data->point.x = touch_x * DEMO_PANEL_WIDTH / s_touchResolutionX; - data->point.y = touch_y * DEMO_PANEL_HEIGHT / s_touchResolutionY; - #endif - // D4_Off(); -} - -#if LV_USE_GPU_NXP_VG_LITE -void GPU2D_IRQHandler(void) { - vg_lite_IRQHandler(); -} - -static status_t BOARD_InitVGliteClock(void) { - const clock_root_config_t gc355ClockConfig = { - .clockOff = false, - .mux = kCLOCK_GC355_ClockRoot_MuxVideoPllOut, - .div = 2, - }; - - CLOCK_SetRootClock(kCLOCK_Root_Gc355, &gc355ClockConfig); - - CLOCK_GetRootClockFreq(kCLOCK_Root_Gc355); - - CLOCK_EnableClock(kCLOCK_Gpu2d); - - NVIC_SetPriority(GPU2D_IRQn, 3); - - EnableIRQ(GPU2D_IRQn); - - return kStatus_Success; -} - -static status_t BOARD_PrepareVGLiteController(void) { - status_t status; - - status = BOARD_InitVGliteClock(); - - if (kStatus_Success != status) { - return status; - } - - vg_lite_init_mem(registerMemBase, gpu_mem_base, vglite_heap_base, vglite_heap_size); - - vg_lite_set_command_buffer_size(vglite_cmd_buff_size); - - return kStatus_Success; -} -#endif /* LV_USE_GPU_NXP_VG_LITE */ diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/lvgl_support.h b/ports/mimxrt/boards/MIMXRT1170_EVK/lvgl_support.h deleted file mode 100644 index 5c308188457e..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/lvgl_support.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2019-2021 NXP - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef LVGL_SUPPORT_H -#define LVGL_SUPPORT_H - -#include -#include "display_support.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -#define DEMO_USE_ROTATE 0 - -#define LCD_WIDTH DEMO_PANEL_WIDTH -#define LCD_HEIGHT DEMO_PANEL_HEIGHT -#define LCD_FB_BYTE_PER_PIXEL DEMO_BUFFER_BYTE_PER_PIXEL - -// #define LCD_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL -#define LCD_RENDER_MODE LV_DISPLAY_RENDER_MODE_DIRECT - -#define LV_PORT_DISP_INIT lv_port_disp_init -#define LV_PORT_INDEV_INIT lv_port_indev_init -#define LV_PORT_DISP_DEINIT lv_port_disp_deinit -// #define LV_PORT_INDEX_DEINIT lv_port_indev_deinit - -/******************************************************************************* - * API - ******************************************************************************/ - -#ifdef __cplusplus -extern "C" { -#endif - - -void lv_port_pre_init(void); -void lv_port_disp_init(void); -void lv_port_disp_deinit(void); -void lv_port_indev_init(void); - -#if defined(__cplusplus) -} -#endif - -#endif /*LVGL_SUPPORT_H */ diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/pin_mux.c b/ports/mimxrt/boards/MIMXRT1170_EVK/pin_mux.c deleted file mode 100644 index c7ddfff9dcee..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/pin_mux.c +++ /dev/null @@ -1,364 +0,0 @@ -/*********************************************************************************************************************** - * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file - * will be overwritten if the respective MCUXpresso Config Tools is used to update this file. - **********************************************************************************************************************/ - -/* - * TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* -!!GlobalInfo -product: Pins v13.0 -processor: MIMXRT1176xxxxx -package_id: MIMXRT1176DVMAA -mcu_data: ksdk2_0 -processor_version: 13.0.1 -board: MIMXRT1170-EVK -pin_labels: -- {pin_num: R5, pin_signal: GPIO_LPSR_10, label: 'JTAG_nTRST/J1[3]/LPSPI6_SCK /J26[9]/DMIC_DATA1', identifier: DMIC_DATA1} -- {pin_num: D9, pin_signal: GPIO_DISP_B2_10, label: 'LPUART2_TXD/BT_UART_TXD/U354[4]/U16[2]/J25[3]/J9[4]', identifier: BT_UART_TXD;D1} -- {pin_num: A6, pin_signal: GPIO_DISP_B2_11, label: 'LPUART2_RXD/BT_UART_RXD/U16[3]/U355[20]/J9[2]', identifier: BT_UART_RXD;D0} -- {pin_num: B6, pin_signal: GPIO_DISP_B2_12, label: 'RGMII1_PHY_INTB/U10[31]/BT_UART_CTS/U16[5]/U355[19]/J9[6]', identifier: GPIO_DISP_B2_12;D2} -- {pin_num: M13, pin_signal: GPIO_AD_04, label: 'SIM1_PD/J44[C8]/USER_LED_CTL1/J9[8]/J25[7]', identifier: SIM1_PD;D3} -- {pin_num: P13, pin_signal: GPIO_AD_05, label: 'SIM1_PWR_FAIL/J9[12]/J25[5]/LCD_LPTE', identifier: SIM1_PWR_FAIL;D5} -- {pin_num: N13, pin_signal: GPIO_AD_06, label: 'USB_OTG2_OC/U18[A2]/J9[10]/AUD_INT', identifier: D4} -- {pin_num: L14, pin_signal: GPIO_AD_26, label: 'CSI_PWR_CTL/USER_LED_CTL2/J50[16]', identifier: RED_LED} - * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS *********** - */ - -#include "fsl_common.h" -#include "fsl_iomuxc.h" -#include "fsl_gpio.h" -#include "pin_mux.h" - -/* FUNCTION ************************************************************************************************************ - * - * Function Name : BOARD_InitBootPins - * Description : Calls initialization functions. - * - * END ****************************************************************************************************************/ -void BOARD_InitBootPins(void) { -} - -/* - * TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* -BOARD_InitLpuartPins: -- options: {callFromInitBoot: 'false', coreID: cm7, enableClock: 'true'} -- pin_list: - - {pin_num: M15, peripheral: LPUART1, signal: RXD, pin_signal: GPIO_AD_25, software_input_on: Enable, pull_up_down_config: Pull_Down, pull_keeper_select: Keeper, - open_drain: Disable, drive_strength: Normal, slew_rate: Slow} - - {pin_num: L13, peripheral: LPUART1, signal: TXD, pin_signal: GPIO_AD_24, pull_up_down_config: Pull_Down, pull_keeper_select: Keeper, open_drain: Disable, drive_strength: Normal, - slew_rate: Slow} - * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS *********** - */ - -/* FUNCTION ************************************************************************************************************ - * - * Function Name : BOARD_InitLpuartPins, assigned for the Cortex-M7F core. - * Description : Configures pin routing and optionally pin electrical features. - * - * END ****************************************************************************************************************/ -void BOARD_InitLpuartPins(void) { - CLOCK_EnableClock(kCLOCK_Iomuxc); /* LPCG on: LPCG is ON. */ - - IOMUXC_SetPinMux( - IOMUXC_GPIO_AD_24_LPUART1_TXD, /* GPIO_AD_24 is configured as LPUART1_TXD */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ - IOMUXC_SetPinMux( - IOMUXC_GPIO_AD_25_LPUART1_RXD, /* GPIO_AD_25 is configured as LPUART1_RXD */ - 1U); /* Software Input On Field: Force input path of pad GPIO_AD_25 */ - IOMUXC_SetPinConfig( - IOMUXC_GPIO_AD_24_LPUART1_TXD, /* GPIO_AD_24 PAD functional properties : */ - 0x00U); /* Slew Rate Field: Slow Slew Rate - Drive Strength Field: normal drive strength - Pull / Keep Select Field: Pull Disable, Highz - Pull Up / Down Config. Field: Weak pull down - Open Drain Field: Disabled - Domain write protection: Both cores are allowed - Domain write protection lock: Neither of DWP bits is locked */ - IOMUXC_SetPinConfig( - IOMUXC_GPIO_AD_25_LPUART1_RXD, /* GPIO_AD_25 PAD functional properties : */ - 0x00U); /* Slew Rate Field: Slow Slew Rate - Drive Strength Field: normal drive strength - Pull / Keep Select Field: Pull Disable, Highz - Pull Up / Down Config. Field: Weak pull down - Open Drain Field: Disabled - Domain write protection: Both cores are allowed - Domain write protection lock: Neither of DWP bits is locked */ -} - - -/* - * TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* -BOARD_InitMipiPanelPins: -- options: {callFromInitBoot: 'false', coreID: cm7, enableClock: 'true'} -- pin_list: - - {pin_num: A4, peripheral: GPIO11, signal: 'gpio_io, 16', pin_signal: GPIO_DISP_B2_15, software_input_on: Disable} - - {pin_num: N8, peripheral: LPI2C5, signal: SCL, pin_signal: GPIO_LPSR_05, software_input_on: Enable, pull_up_down_config: Pull_Down, pull_keeper_select: Keeper, - open_drain: Enable, drive_strength: Normal, slew_rate: Slow} - - {pin_num: N7, peripheral: LPI2C5, signal: SDA, pin_signal: GPIO_LPSR_04, software_input_on: Enable, pull_up_down_config: Pull_Down, pull_keeper_select: Keeper, - open_drain: Enable, drive_strength: Normal, slew_rate: Slow} - - {pin_num: N12, peripheral: GPIO8, signal: 'gpio_io, 31', pin_signal: GPIO_AD_00, software_input_on: Enable, pull_up_down_config: Pull_Down, pull_keeper_select: Keeper, - open_drain: Disable, drive_strength: Normal, slew_rate: Slow} - - {pin_num: R14, peripheral: GPIO9, signal: 'gpio_io, 00', pin_signal: GPIO_AD_01, pull_up_down_config: Pull_Down, pull_keeper_select: Keeper, open_drain: Disable, - drive_strength: Normal, slew_rate: Slow} - - {pin_num: R13, peripheral: GPIO9, signal: 'gpio_io, 01', pin_signal: GPIO_AD_02} - - {pin_num: K17, peripheral: GPIO9, signal: 'gpio_io, 29', pin_signal: GPIO_AD_30} - * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS *********** - */ - -/* FUNCTION ************************************************************************************************************ - * - * Function Name : BOARD_InitMipiPanelPins, assigned for the Cortex-M7F core. - * Description : Configures pin routing and optionally pin electrical features. - * - * END ****************************************************************************************************************/ -void BOARD_InitMipiPanelPins(void) { - CLOCK_EnableClock(kCLOCK_Iomuxc); /* LPCG on: LPCG is ON. */ - CLOCK_EnableClock(kCLOCK_Iomuxc_Lpsr); /* LPCG on: LPCG is ON. */ - - IOMUXC_SetPinMux( - IOMUXC_GPIO_AD_00_GPIO8_IO31, /* GPIO_AD_00 is configured as GPIO8_IO31 */ - 1U); /* Software Input On Field: Force input path of pad GPIO_AD_00 */ - IOMUXC_SetPinMux( - IOMUXC_GPIO_AD_01_GPIO9_IO00, /* GPIO_AD_01 is configured as GPIO9_IO00 */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ - IOMUXC_SetPinMux( - IOMUXC_GPIO_AD_02_GPIO9_IO01, /* GPIO_AD_02 is configured as GPIO9_IO01 */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ - IOMUXC_SetPinMux( - IOMUXC_GPIO_AD_30_GPIO9_IO29, /* GPIO_AD_30 is configured as GPIO9_IO29 */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ - IOMUXC_SetPinMux( - IOMUXC_GPIO_DISP_B2_15_GPIO11_IO16, /* GPIO_DISP_B2_15 is configured as GPIO11_IO16 */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ - IOMUXC_SetPinMux( - IOMUXC_GPIO_LPSR_04_LPI2C5_SDA, /* GPIO_LPSR_04 is configured as LPI2C5_SDA */ - 1U); /* Software Input On Field: Force input path of pad GPIO_LPSR_04 */ - IOMUXC_SetPinMux( - IOMUXC_GPIO_LPSR_05_LPI2C5_SCL, /* GPIO_LPSR_05 is configured as LPI2C5_SCL */ - 1U); /* Software Input On Field: Force input path of pad GPIO_LPSR_05 */ - IOMUXC_SetPinConfig( - IOMUXC_GPIO_AD_00_GPIO8_IO31, /* GPIO_AD_00 PAD functional properties : */ - 0x00U); /* Slew Rate Field: Slow Slew Rate - Drive Strength Field: normal drive strength - Pull / Keep Select Field: Pull Disable, Highz - Pull Up / Down Config. Field: Weak pull down - Open Drain Field: Disabled - Domain write protection: Both cores are allowed - Domain write protection lock: Neither of DWP bits is locked */ - IOMUXC_SetPinConfig( - IOMUXC_GPIO_AD_01_GPIO9_IO00, /* GPIO_AD_01 PAD functional properties : */ - 0x00U); /* Slew Rate Field: Slow Slew Rate - Drive Strength Field: normal drive strength - Pull / Keep Select Field: Pull Disable, Highz - Pull Up / Down Config. Field: Weak pull down - Open Drain Field: Disabled - Domain write protection: Both cores are allowed - Domain write protection lock: Neither of DWP bits is locked */ - IOMUXC_SetPinConfig( - IOMUXC_GPIO_LPSR_04_LPI2C5_SDA, /* GPIO_LPSR_04 PAD functional properties : */ - 0x20U); /* Slew Rate Field: Slow Slew Rate - Drive Strength Field: normal driver - Pull / Keep Select Field: Pull Disable - Pull Up / Down Config. Field: Weak pull down - Open Drain LPSR Field: Enabled - Domain write protection: Both cores are allowed - Domain write protection lock: Neither of DWP bits is locked */ - IOMUXC_SetPinConfig( - IOMUXC_GPIO_LPSR_05_LPI2C5_SCL, /* GPIO_LPSR_05 PAD functional properties : */ - 0x20U); /* Slew Rate Field: Slow Slew Rate - Drive Strength Field: normal driver - Pull / Keep Select Field: Pull Disable - Pull Up / Down Config. Field: Weak pull down - Open Drain LPSR Field: Enabled - Domain write protection: Both cores are allowed - Domain write protection lock: Neither of DWP bits is locked */ -} - - -/* - * TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* -BOARD_InitMicPins: -- options: {callFromInitBoot: 'false', coreID: cm7, enableClock: 'true'} -- pin_list: - - {pin_num: U8, peripheral: MIC, signal: CLK, pin_signal: GPIO_LPSR_08, slew_rate: Fast} - - {pin_num: P5, peripheral: MIC, signal: 'mic_bitstream, 00', pin_signal: GPIO_LPSR_09, slew_rate: Fast} - - {pin_num: R5, peripheral: MIC, signal: 'mic_bitstream, 01', pin_signal: GPIO_LPSR_10} - * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS *********** - */ - -/* FUNCTION ************************************************************************************************************ - * - * Function Name : BOARD_InitMicPins, assigned for the Cortex-M7F core. - * Description : Configures pin routing and optionally pin electrical features. - * - * END ****************************************************************************************************************/ -void BOARD_InitMicPins(void) { - CLOCK_EnableClock(kCLOCK_Iomuxc_Lpsr); /* LPCG on: LPCG is ON. */ - - IOMUXC_SetPinMux( - IOMUXC_GPIO_LPSR_08_MIC_CLK, /* GPIO_LPSR_08 is configured as MIC_CLK */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ - IOMUXC_SetPinMux( - IOMUXC_GPIO_LPSR_09_MIC_BITSTREAM0, /* GPIO_LPSR_09 is configured as MIC_BITSTREAM0 */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ - IOMUXC_SetPinMux( - IOMUXC_GPIO_LPSR_10_MIC_BITSTREAM1, /* GPIO_LPSR_10 is configured as MIC_BITSTREAM1 */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ - IOMUXC_SetPinConfig( - IOMUXC_GPIO_LPSR_08_MIC_CLK, /* GPIO_LPSR_08 PAD functional properties : */ - 0x03U); /* Slew Rate Field: Fast Slew Rate - Drive Strength Field: high driver - Pull / Keep Select Field: Pull Disable - Pull Up / Down Config. Field: Weak pull down - Open Drain LPSR Field: Disabled - Domain write protection: Both cores are allowed - Domain write protection lock: Neither of DWP bits is locked */ - IOMUXC_SetPinConfig( - IOMUXC_GPIO_LPSR_09_MIC_BITSTREAM0, /* GPIO_LPSR_09 PAD functional properties : */ - 0x03U); /* Slew Rate Field: Fast Slew Rate - Drive Strength Field: high driver - Pull / Keep Select Field: Pull Disable - Pull Up / Down Config. Field: Weak pull down - Open Drain LPSR Field: Disabled - Domain write protection: Both cores are allowed - Domain write protection lock: Neither of DWP bits is locked */ -} - - -/* - * TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* -BOARD_InitTestPins: -- options: {callFromInitBoot: 'false', prefix: TEST_GPIO_, coreID: cm7, enableClock: 'true'} -- pin_list: - - {pin_num: A6, peripheral: GPIO5, signal: 'gpio_mux_io, 12', pin_signal: GPIO_DISP_B2_11, identifier: D0, direction: OUTPUT} - - {pin_num: D9, peripheral: GPIO5, signal: 'gpio_mux_io, 11', pin_signal: GPIO_DISP_B2_10, identifier: D1, direction: OUTPUT} - - {pin_num: B6, peripheral: GPIO5, signal: 'gpio_mux_io, 13', pin_signal: GPIO_DISP_B2_12, identifier: D2, direction: OUTPUT} - - {pin_num: M13, peripheral: GPIO3, signal: 'gpio_mux_io, 03', pin_signal: GPIO_AD_04, identifier: D3, direction: OUTPUT} - - {pin_num: N13, peripheral: GPIO3, signal: 'gpio_mux_io, 05', pin_signal: GPIO_AD_06, direction: OUTPUT} - - {pin_num: P13, peripheral: GPIO3, signal: 'gpio_mux_io, 04', pin_signal: GPIO_AD_05, identifier: D5, direction: OUTPUT} - * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS *********** - */ - -/* FUNCTION ************************************************************************************************************ - * - * Function Name : BOARD_InitTestPins, assigned for the Cortex-M7F core. - * Description : Configures pin routing and optionally pin electrical features. - * - * END ****************************************************************************************************************/ -void BOARD_InitTestPins(void) { - CLOCK_EnableClock(kCLOCK_Iomuxc); /* LPCG on: LPCG is ON. */ - - /* GPIO configuration of D3 on GPIO_AD_04 (pin M13) */ - gpio_pin_config_t D3_config = { - .direction = kGPIO_DigitalOutput, - .outputLogic = 0U, - .interruptMode = kGPIO_NoIntmode - }; - /* Initialize GPIO functionality on GPIO_AD_04 (pin M13) */ - GPIO_PinInit(GPIO3, 3U, &D3_config); - - /* GPIO configuration of D5 on GPIO_AD_05 (pin P13) */ - gpio_pin_config_t D5_config = { - .direction = kGPIO_DigitalOutput, - .outputLogic = 0U, - .interruptMode = kGPIO_NoIntmode - }; - /* Initialize GPIO functionality on GPIO_AD_05 (pin P13) */ - GPIO_PinInit(GPIO3, 4U, &D5_config); - - /* GPIO configuration of D4 on GPIO_AD_06 (pin N13) */ - gpio_pin_config_t D4_config = { - .direction = kGPIO_DigitalOutput, - .outputLogic = 0U, - .interruptMode = kGPIO_NoIntmode - }; - /* Initialize GPIO functionality on GPIO_AD_06 (pin N13) */ - GPIO_PinInit(GPIO3, 5U, &D4_config); - - /* GPIO configuration of D1 on GPIO_DISP_B2_10 (pin D9) */ - gpio_pin_config_t D1_config = { - .direction = kGPIO_DigitalOutput, - .outputLogic = 0U, - .interruptMode = kGPIO_NoIntmode - }; - /* Initialize GPIO functionality on GPIO_DISP_B2_10 (pin D9) */ - GPIO_PinInit(GPIO5, 11U, &D1_config); - - /* GPIO configuration of D0 on GPIO_DISP_B2_11 (pin A6) */ - gpio_pin_config_t D0_config = { - .direction = kGPIO_DigitalOutput, - .outputLogic = 0U, - .interruptMode = kGPIO_NoIntmode - }; - /* Initialize GPIO functionality on GPIO_DISP_B2_11 (pin A6) */ - GPIO_PinInit(GPIO5, 12U, &D0_config); - - /* GPIO configuration of D2 on GPIO_DISP_B2_12 (pin B6) */ - gpio_pin_config_t D2_config = { - .direction = kGPIO_DigitalOutput, - .outputLogic = 0U, - .interruptMode = kGPIO_NoIntmode - }; - /* Initialize GPIO functionality on GPIO_DISP_B2_12 (pin B6) */ - GPIO_PinInit(GPIO5, 13U, &D2_config); - - IOMUXC_SetPinMux( - IOMUXC_GPIO_AD_04_GPIO_MUX3_IO03, /* GPIO_AD_04 is configured as GPIO_MUX3_IO03 */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ - IOMUXC_SetPinMux( - IOMUXC_GPIO_AD_05_GPIO_MUX3_IO04, /* GPIO_AD_05 is configured as GPIO_MUX3_IO04 */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ - IOMUXC_SetPinMux( - IOMUXC_GPIO_AD_06_GPIO_MUX3_IO05, /* GPIO_AD_06 is configured as GPIO_MUX3_IO05 */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ - IOMUXC_SetPinMux( - IOMUXC_GPIO_DISP_B2_10_GPIO_MUX5_IO11, /* GPIO_DISP_B2_10 is configured as GPIO_MUX5_IO11 */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ - IOMUXC_SetPinMux( - IOMUXC_GPIO_DISP_B2_11_GPIO_MUX5_IO12, /* GPIO_DISP_B2_11 is configured as GPIO_MUX5_IO12 */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ - IOMUXC_SetPinMux( - IOMUXC_GPIO_DISP_B2_12_GPIO_MUX5_IO13, /* GPIO_DISP_B2_12 is configured as GPIO_MUX5_IO13 */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ - IOMUXC_GPR->GPR42 = ((IOMUXC_GPR->GPR42 & - (~(BOARD_INITTESTPINS_IOMUXC_GPR_GPR42_GPIO_MUX3_GPIO_SEL_LOW_MASK))) /* Mask bits to zero which are setting */ - | IOMUXC_GPR_GPR42_GPIO_MUX3_GPIO_SEL_LOW(0x00U) /* GPIO3 and CM7_GPIO3 share same IO MUX function, GPIO_MUX3 selects one GPIO function: 0x00U */ - ); -} - - -/* - * TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* -BOARD_InitLEDPins: -- options: {callFromInitBoot: 'false', coreID: cm7, enableClock: 'true'} -- pin_list: - - {pin_num: L14, peripheral: GPIO9, signal: 'gpio_io, 25', pin_signal: GPIO_AD_26, direction: OUTPUT, pull_up_down_config: no_init} - * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS *********** - */ - -/* FUNCTION ************************************************************************************************************ - * - * Function Name : BOARD_InitLEDPins, assigned for the Cortex-M7F core. - * Description : Configures pin routing and optionally pin electrical features. - * - * END ****************************************************************************************************************/ -void BOARD_InitLEDPins(void) { - CLOCK_EnableClock(kCLOCK_Iomuxc); /* LPCG on: LPCG is ON. */ - - /* GPIO configuration of RED_LED on GPIO_AD_26 (pin L14) */ - gpio_pin_config_t RED_LED_config = { - .direction = kGPIO_DigitalOutput, - .outputLogic = 0U, - .interruptMode = kGPIO_NoIntmode - }; - /* Initialize GPIO functionality on GPIO_AD_26 (pin L14) */ - GPIO_PinInit(GPIO9, 25U, &RED_LED_config); - - IOMUXC_SetPinMux( - IOMUXC_GPIO_AD_26_GPIO9_IO25, /* GPIO_AD_26 is configured as GPIO9_IO25 */ - 0U); /* Software Input On Field: Input Path is determined by functionality */ -} - -/*********************************************************************************************************************** - * EOF - **********************************************************************************************************************/ diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/pin_mux.h b/ports/mimxrt/boards/MIMXRT1170_EVK/pin_mux.h deleted file mode 100644 index 3f257df273db..000000000000 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/pin_mux.h +++ /dev/null @@ -1,199 +0,0 @@ -/*********************************************************************************************************************** - * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file - * will be overwritten if the respective MCUXpresso Config Tools is used to update this file. - **********************************************************************************************************************/ - -#ifndef _PIN_MUX_H_ -#define _PIN_MUX_H_ - -/*! - * @addtogroup pin_mux - * @{ - */ - -/*********************************************************************************************************************** - * API - **********************************************************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif - -/*! - * @brief Calls initialization functions. - * - */ -void BOARD_InitBootPins(void); - -/* GPIO_AD_25 (coord M15), LPUART1_RXD/J32[2] */ -/* Routed pin properties */ -#define BOARD_INITLPUARTPINS_LPUART1_RXD_PERIPHERAL LPUART1 /*!< Peripheral name */ -#define BOARD_INITLPUARTPINS_LPUART1_RXD_SIGNAL RXD /*!< Signal name */ - -/* GPIO_AD_24 (coord L13), LPUART1_TXD/J31[2] */ -/* Routed pin properties */ -#define BOARD_INITLPUARTPINS_LPUART1_TXD_PERIPHERAL LPUART1 /*!< Peripheral name */ -#define BOARD_INITLPUARTPINS_LPUART1_TXD_SIGNAL TXD /*!< Signal name */ - -/*! - * @brief Configures pin routing and optionally pin electrical features. - * - */ -void BOARD_InitLpuartPins(void); /* Function assigned for the Cortex-M7F */ - -/* GPIO_LPSR_05 (coord N8), I2C5_SCL/J48[27]/U32[17]/U34[4]/J10[20] */ -/* Routed pin properties */ -#define BOARD_INITMIPIPANELPINS_I2C5_SCL_PERIPHERAL LPI2C5 /*!< Peripheral name */ -#define BOARD_INITMIPIPANELPINS_I2C5_SCL_SIGNAL SCL /*!< Signal name */ - -/* GPIO_LPSR_04 (coord N7), I2C5_SDA/J48[26]/U32[18]/U34[6]/J10[18] */ -/* Routed pin properties */ -#define BOARD_INITMIPIPANELPINS_I2C5_SDA_PERIPHERAL LPI2C5 /*!< Peripheral name */ -#define BOARD_INITMIPIPANELPINS_I2C5_SDA_SIGNAL SDA /*!< Signal name */ - -/* GPIO_AD_00 (coord N12), SIM1_TRXD/J44[C7]/J57[9]/CTP_INT/J48[29]/J25[15]/J9[14] */ -/* Routed pin properties */ -#define BOARD_INITMIPIPANELPINS_SIM1_TRXD_PERIPHERAL GPIO8 /*!< Peripheral name */ -#define BOARD_INITMIPIPANELPINS_SIM1_TRXD_SIGNAL gpio_io /*!< Signal name */ -#define BOARD_INITMIPIPANELPINS_SIM1_TRXD_CHANNEL 31U /*!< Signal channel */ - -/* Symbols to be used with GPIO driver */ -#define BOARD_INITMIPIPANELPINS_SIM1_TRXD_GPIO GPIO8 /*!< GPIO peripheral base pointer */ -#define BOARD_INITMIPIPANELPINS_SIM1_TRXD_GPIO_PIN 31U /*!< GPIO pin number */ -#define BOARD_INITMIPIPANELPINS_SIM1_TRXD_GPIO_PIN_MASK (1U << 31U) /*!< GPIO pin mask */ - -/* GPIO_AD_01 (coord R14), SIM1_CLK/J44[C3]/J57[7]/CTP_RST_B/J48[28]/J10[4]/J25[13] */ -/* Routed pin properties */ -#define BOARD_INITMIPIPANELPINS_SIM1_CLK_PERIPHERAL GPIO9 /*!< Peripheral name */ -#define BOARD_INITMIPIPANELPINS_SIM1_CLK_SIGNAL gpio_io /*!< Signal name */ -#define BOARD_INITMIPIPANELPINS_SIM1_CLK_CHANNEL 0U /*!< Signal channel */ - -/* Symbols to be used with GPIO driver */ -#define BOARD_INITMIPIPANELPINS_SIM1_CLK_GPIO GPIO9 /*!< GPIO peripheral base pointer */ -#define BOARD_INITMIPIPANELPINS_SIM1_CLK_GPIO_PIN 0U /*!< GPIO pin number */ -#define BOARD_INITMIPIPANELPINS_SIM1_CLK_GPIO_PIN_MASK (1U << 0U) /*!< GPIO pin mask */ - -/* GPIO_AD_02 (coord R13), SIM1_RST/J57[5]/J44[C2]/LCD_RST_B/J48[21]/J25[11]/J10[6] */ -/* Routed pin properties */ -#define BOARD_INITMIPIPANELPINS_SIM1_RST_PERIPHERAL GPIO9 /*!< Peripheral name */ -#define BOARD_INITMIPIPANELPINS_SIM1_RST_SIGNAL gpio_io /*!< Signal name */ -#define BOARD_INITMIPIPANELPINS_SIM1_RST_CHANNEL 1U /*!< Signal channel */ - -/* Symbols to be used with GPIO driver */ -#define BOARD_INITMIPIPANELPINS_SIM1_RST_GPIO GPIO9 /*!< GPIO peripheral base pointer */ -#define BOARD_INITMIPIPANELPINS_SIM1_RST_GPIO_PIN 1U /*!< GPIO pin number */ -#define BOARD_INITMIPIPANELPINS_SIM1_RST_GPIO_PIN_MASK (1U << 1U) /*!< GPIO pin mask */ - -/* GPIO_AD_30 (coord K17), LPSPI1_SDO/U27[5]/J10[8]/Backlight_CTL/J48[34]/U46[4] */ -/* Routed pin properties */ -#define BOARD_INITMIPIPANELPINS_LPSPI1_SDO_PERIPHERAL GPIO9 /*!< Peripheral name */ -#define BOARD_INITMIPIPANELPINS_LPSPI1_SDO_SIGNAL gpio_io /*!< Signal name */ -#define BOARD_INITMIPIPANELPINS_LPSPI1_SDO_CHANNEL 29U /*!< Signal channel */ - -/* Symbols to be used with GPIO driver */ -#define BOARD_INITMIPIPANELPINS_LPSPI1_SDO_GPIO GPIO9 /*!< GPIO peripheral base pointer */ -#define BOARD_INITMIPIPANELPINS_LPSPI1_SDO_GPIO_PIN 29U /*!< GPIO pin number */ -#define BOARD_INITMIPIPANELPINS_LPSPI1_SDO_GPIO_PIN_MASK (1U << 29U) /*!< GPIO pin mask */ - -/*! - * @brief Configures pin routing and optionally pin electrical features. - * - */ -void BOARD_InitMipiPanelPins(void); /* Function assigned for the Cortex-M7F */ - -/* GPIO_LPSR_08 (coord U8), DMIC_CLK/U41[1]/U44[1]/J50[18] */ -/* Routed pin properties */ -#define BOARD_INITMICPINS_DMIC_CLK_PERIPHERAL MIC /*!< Peripheral name */ -#define BOARD_INITMICPINS_DMIC_CLK_SIGNAL CLK /*!< Signal name */ - -/* GPIO_LPSR_09 (coord P5), DMIC_DATA0/U41[5]/J50[20]/LPSPI6_CS0/J26[11] */ -/* Routed pin properties */ -#define BOARD_INITMICPINS_DMIC_DATA0_PERIPHERAL MIC /*!< Peripheral name */ -#define BOARD_INITMICPINS_DMIC_DATA0_SIGNAL mic_bitstream /*!< Signal name */ -#define BOARD_INITMICPINS_DMIC_DATA0_CHANNEL 0U /*!< Signal channel */ - -/* GPIO_LPSR_10 (coord R5), JTAG_nTRST/J1[3]/LPSPI6_SCK /J26[9]/DMIC_DATA1 */ -/* Routed pin properties */ -#define BOARD_INITMICPINS_DMIC_DATA1_PERIPHERAL MIC /*!< Peripheral name */ -#define BOARD_INITMICPINS_DMIC_DATA1_SIGNAL mic_bitstream /*!< Signal name */ -#define BOARD_INITMICPINS_DMIC_DATA1_CHANNEL 1U /*!< Signal channel */ - -/*! - * @brief Configures pin routing and optionally pin electrical features. - * - */ -void BOARD_InitMicPins(void); /* Function assigned for the Cortex-M7F */ - -#define BOARD_INITTESTPINS_IOMUXC_GPR_GPR42_GPIO_MUX3_GPIO_SEL_LOW_MASK 0x38U /*!< GPIO3 and CM7_GPIO3 share same IO MUX function, GPIO_MUX3 selects one GPIO function: affected bits mask */ - -/* GPIO_DISP_B2_11 (coord A6), LPUART2_RXD/BT_UART_RXD/U16[3]/U355[20]/J9[2] */ -/* Routed pin properties */ -#define TEST_GPIO_D0_PERIPHERAL GPIO5 /*!< Peripheral name */ -#define TEST_GPIO_D0_SIGNAL gpio_mux_io /*!< Signal name */ -#define TEST_GPIO_D0_CHANNEL 12U /*!< Signal channel */ - -/* GPIO_DISP_B2_10 (coord D9), LPUART2_TXD/BT_UART_TXD/U354[4]/U16[2]/J25[3]/J9[4] */ -/* Routed pin properties */ -#define TEST_GPIO_D1_PERIPHERAL GPIO5 /*!< Peripheral name */ -#define TEST_GPIO_D1_SIGNAL gpio_mux_io /*!< Signal name */ -#define TEST_GPIO_D1_CHANNEL 11U /*!< Signal channel */ - -/* GPIO_DISP_B2_12 (coord B6), RGMII1_PHY_INTB/U10[31]/BT_UART_CTS/U16[5]/U355[19]/J9[6] */ -/* Routed pin properties */ -#define TEST_GPIO_D2_PERIPHERAL GPIO5 /*!< Peripheral name */ -#define TEST_GPIO_D2_SIGNAL gpio_mux_io /*!< Signal name */ -#define TEST_GPIO_D2_CHANNEL 13U /*!< Signal channel */ - -/* GPIO_AD_04 (coord M13), SIM1_PD/J44[C8]/USER_LED_CTL1/J9[8]/J25[7] */ -/* Routed pin properties */ -#define TEST_GPIO_D3_PERIPHERAL GPIO3 /*!< Peripheral name */ -#define TEST_GPIO_D3_SIGNAL gpio_mux_io /*!< Signal name */ -#define TEST_GPIO_D3_CHANNEL 3U /*!< Signal channel */ - -/* GPIO_AD_06 (coord N13), USB_OTG2_OC/U18[A2]/J9[10]/AUD_INT */ -/* Routed pin properties */ -#define TEST_GPIO_D4_PERIPHERAL GPIO3 /*!< Peripheral name */ -#define TEST_GPIO_D4_SIGNAL gpio_mux_io /*!< Signal name */ -#define TEST_GPIO_D4_CHANNEL 5U /*!< Signal channel */ - -/* GPIO_AD_05 (coord P13), SIM1_PWR_FAIL/J9[12]/J25[5]/LCD_LPTE */ -/* Routed pin properties */ -#define TEST_GPIO_D5_PERIPHERAL GPIO3 /*!< Peripheral name */ -#define TEST_GPIO_D5_SIGNAL gpio_mux_io /*!< Signal name */ -#define TEST_GPIO_D5_CHANNEL 4U /*!< Signal channel */ - -/*! - * @brief Configures pin routing and optionally pin electrical features. - * - */ -void BOARD_InitTestPins(void); /* Function assigned for the Cortex-M7F */ - -/* GPIO_AD_26 (coord L14), CSI_PWR_CTL/USER_LED_CTL2/J50[16] */ -/* Routed pin properties */ -#define BOARD_INITLEDPINS_RED_LED_PERIPHERAL GPIO9 /*!< Peripheral name */ -#define BOARD_INITLEDPINS_RED_LED_SIGNAL gpio_io /*!< Signal name */ -#define BOARD_INITLEDPINS_RED_LED_CHANNEL 25U /*!< Signal channel */ - -/* Symbols to be used with GPIO driver */ -#define BOARD_INITLEDPINS_RED_LED_GPIO GPIO9 /*!< GPIO peripheral base pointer */ -#define BOARD_INITLEDPINS_RED_LED_GPIO_PIN 25U /*!< GPIO pin number */ -#define BOARD_INITLEDPINS_RED_LED_GPIO_PIN_MASK (1U << 25U) /*!< GPIO pin mask */ - -/*! - * @brief Configures pin routing and optionally pin electrical features. - * - */ -void BOARD_InitLEDPins(void); /* Function assigned for the Cortex-M7F */ - -#if defined(__cplusplus) -} -#endif - -/*! - * @} - */ -#endif /* _PIN_MUX_H_ */ - -/*********************************************************************************************************************** - * EOF - **********************************************************************************************************************/