打印
[GUI]

使用littlevgl显示呼吸灯

[复制链接]
1553|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
本帖最后由 muyichuan2012 于 2021-1-6 11:22 编辑

XMC 8080驱动 LCDAT32F403A作为主控芯片
主频200MHz
GUI: LittlevGL V7
显示效果:
视频链接:点我



/**
**************************************************************************
* @file      : EXTI/EXTI_Config/main.c
* @author    : Artery Technology
* @version   : V1.0.4
* @date      : 2020-09-28
* @brief     : Main program body
*/

/* Includes ------------------------------------------------------------------*/

#ifdef CHOSE_LCD9341
#include "xmc_lcd_9341.h"
#endif
#ifdef CHOSE_LCD5510
#include "xmc_lcd_5510.h"
#endif


#include "at32f4xx.h"
#include "at32_board.h"
#include <stdio.h>
#include "lvgl.h"
#ifdef CHOSE_LCD9341
#include "xmc_lcd_9341.h"
#endif
#ifdef CHOSE_LCD5510
#include "xmc_lcd_5510.h"
#endif
#include "touch.h"
#include "iwdg.h"
#include "lv_port_disp_template.h"
#include "lv_port_indev_template.h"

#include "../lvgl.h"
#include <stdio.h>
#include <stdlib.h>
#include "lv_test_core/lv_test_core.h"


#include "task_breathing_led.h"



/** @addtogroup AT32F413_StdPeriph_Examples
  * @{
  */

/** @addtogroup EXTI_Config
  * @{
  */
/* Define External SPI flash unlock key --------------------------------------*/
#define FLASH_KEY1                      ((UINT32)0x45670123)
#define FLASH_KEY2                      ((UINT32)0xCDEF89AB)
#define FLASH_BANK3_TYPE1  1
#define FLASH_BANK3_TYPE2  2
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/

/* Private functions ---------------------------------------------------------*/
void TRM3_Int_Init(u16 arr, u16 psc);
void TRM2_Int_Init(u16 arr, u16 psc);



/**
  * @brief  Configures the ext.flash
  * @param  None
  * @retval None
  */

void FLASH_InitExtFlash(void)
{
  GPIO_InitType GPIO_InitStructure;

  /* Enable ext.flash GPIO clock */
  RCC_APB2PeriphClockCmd(RCC_APB2PERIPH_AFIO|RCC_APB2PERIPH_GPIOA|RCC_APB2PERIPH_GPIOB, ENABLE);

  GPIO_PinsRemapConfig(GPIO_Remap_XMC_NADV,ENABLE);
  /* Configure ext.flash pin */
  GPIO_StructInit(&GPIO_InitStructure);
  GPIO_InitStructure.GPIO_Pins = GPIO_Pins_8;
  GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
  GPIO_InitStructure.GPIO_Pins = GPIO_Pins_1|GPIO_Pins_6|GPIO_Pins_7|GPIO_Pins_10|GPIO_Pins_11;
  GPIO_Init(GPIOB, &GPIO_InitStructure);

  /* Select PB10, PB11 as SPIF_TX and SPIF_RX */
  GPIO_PinsRemapConfig(GPIO_Remap_EXT_FLASH, ENABLE);
  GPIO_PinsRemapConfig(AFIO_MAP7_SPIF_1001, ENABLE);

  /* In this example, use on-board EN25QH128A as ext.flash */
  FLASH->B3SEL = FLASH_BANK3_TYPE2;

  /* Unlock the ext.flash program erase controller */  
  while (BIT_READ(FLASH->STS3, FLASH_STS_BSY));
  FLASH->FCKEY3 = FLASH_KEY1;
  FLASH->FCKEY3 = FLASH_KEY2;
  while (BIT_READ(FLASH->CTRL3, FLASH_CTRL_LCK));

  /* If the data written to ext.flash need to be scrambled, please specify the scrambled range */
  FLASH->DA = 0;  

  return;
}
/**
*        @brief  main function
*        @param  None
*        @retval None
*/



int main(void)
{
    //初始化SPIM 用于存放图片字体等大文件
    FLASH_InitExtFlash();
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);

    //Initialize LED 、KEY、USART1
    AT32_Board_Init();   
    UART_Print_Init(115200);
    printf("init ok\r\n");

    //用于防呆
    //    IWDG_init();

    //初始化LCD
    LCD_init();


    // 2400000/(999+1)/(239+1)=1 KHz操作lv_tick_inc  each 1 ms
    TRM3_Int_Init(999, 239);

    //刷lv_task_handler   
    TRM2_Int_Init(99, 239);

    //初始化lvgl  
    lv_init();
    lv_port_disp_init();
    lv_port_indev_init();

    //调用呼吸灯任务
    task_breathing_led();

    //调用数字显示任务
    task_font();

    //调用电池进度显示任务
    task_battery();

    while (1)
    {

    }
}

void TRM3_Int_Init(u16 arr, u16 psc)
{
    TMR_TimerBaseInitType  TMR_TimeBaseStructure;
    NVIC_InitType NVIC_InitStructure;
    RCC_APB1PeriphClockCmd(RCC_APB1PERIPH_TMR3, ENABLE);

    TMR_TimeBaseStructure.TMR_Period = arr;
    TMR_TimeBaseStructure.TMR_DIV = psc;
    TMR_TimeBaseStructure.TMR_ClockDivision = TMR_CKD_DIV1;
    TMR_TimeBaseStructure.TMR_CounterMode = TMR_CounterDIR_Up;
    TMR_TimeBaseInit(TMR3, &TMR_TimeBaseStructure);
    TMR_INTConfig(TMR3, TMR_INT_Overflow, ENABLE );

    NVIC_InitStructure.NVIC_IRQChannel = TMR3_GLOBAL_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
    TMR_Cmd(TMR3, ENABLE);
}

void TMR3_GLOBAL_IRQHandler(void)
{                                                                  
    if(TMR3->STS&0X0001)
    {
        TMR3->STS&=~(1<<0);
        lv_tick_inc(1);               
//        IWDG->KEY = (uint16_t)0xAAAA;  //喂狗  用于防呆   
    }                                   
}

void TRM2_Int_Init(u16 arr, u16 psc)
{
    TMR_TimerBaseInitType  TMR_TimeBaseStructure;
    NVIC_InitType NVIC_InitStructure;
    RCC_APB1PeriphClockCmd(RCC_APB1PERIPH_TMR2, ENABLE);

    TMR_TimeBaseStructure.TMR_Period = arr;
    TMR_TimeBaseStructure.TMR_DIV = psc;
    TMR_TimeBaseStructure.TMR_ClockDivision = TMR_CKD_DIV1;
    TMR_TimeBaseStructure.TMR_CounterMode = TMR_CounterDIR_Up;
    TMR_TimeBaseInit(TMR2, &TMR_TimeBaseStructure);
    TMR_INTConfig(TMR2, TMR_INT_Overflow, ENABLE );

    NVIC_InitStructure.NVIC_IRQChannel = TMR2_GLOBAL_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
    TMR_Cmd(TMR2, ENABLE);
}

void TMR2_GLOBAL_IRQHandler(void)
{                 
    TMR2->STS&=~(1<<0);   
    lv_task_handler();                                   

}




#ifdef  USE_FULL_ASSERT

/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t* file, uint32_t line)
{
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while (1)
  {
  }
}

#endif

/**
  * @}
  */

/**
  * @}
  */

/******************* (C) COPYRIGHT 2018 ArteryTek *****END OF FILE****/





  

LittlevGL_V7_ON_403A_Breathing_LED.rar

18.03 MB

使用特权

评论回复
沙发
HiHuiji| | 2021-1-19 18:21 | 只看该作者
这个是怎么实现代码字库放外部的flash,代码在内部呢

使用特权

评论回复
评论
muyichuan2012 2021-1-21 12:58 回复TA
@HiHuiji :可以的。 
HiHuiji 2021-1-21 10:01 回复TA
@muyichuan2012 :是用keil一次编译能生成两个bin吗?一个内部一个外部? 
muyichuan2012 2021-1-19 18:50 回复TA
您好,这需要使用到SPIM外设。应用指南如下:https://bbs.21ic.com/icview-2989430-1-1.html?_dsign=2e4b5fa9 
板凳
fuqinyyy| | 2021-1-20 07:49 | 只看该作者
学习了,感谢楼主分享。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

198

主题

1910

帖子

29

粉丝