st7565.c lvgl711 - JohnHau/mis GitHub Wiki
/**
- @file ST7565.c
*/
/*********************
-
INCLUDES
*********************/
#include "product_config.h"
#include "ST7565.h"
#include "fsl_debug_console.h"
//#include "snap_on_option.h"
#define ST75320 1
#if 1//USE_ST7565
#include <stdbool.h> #include <stddef.h> #include <string.h> #include "fsl_lpspi.h" #include "fsl_gpio.h" #include "fsl_iomuxc.h" #include "board_io_cfg.h"
//#include "lvgl/lv_core/lv_vdb.h" #include LV_DRV_DISP_INCLUDE #include LV_DRV_DELAY_INCLUDE #include "board_ConfigFileParser_FS_SNAP_ON_IO.h" /*********************
-
DEFINES
*******************/ #define ST7565_BAUD 2000000 /< 2,5 MHz (400 ns)/
#define ST7565_CMD_MODE 0 #define ST7565_DATA_MODE 1
#define ST7565_HOR_RES 281//281 #define ST7565_VER_RES 118//118
#define CMD_DISPLAY_OFF 0xAE #define CMD_DISPLAY_ON 0xAF
#define CMD_SET_DISP_START_LINE 0x40 #define CMD_SET_PAGE 0xB0
#define CMD_SET_COLUMN_UPPER 0x10 #define CMD_SET_COLUMN_LOWER 0x00
#define CMD_SET_ADC_NORMAL 0xA0 #define CMD_SET_ADC_REVERSE 0xA1
#define CMD_SET_DISP_NORMAL 0xA6 #define CMD_SET_DISP_REVERSE 0xA7
#define CMD_SET_ALLPTS_NORMAL 0xA4 #define CMD_SET_ALLPTS_ON 0xA5 #define CMD_SET_BIAS_9 0xA2 #define CMD_SET_BIAS_7 0xA3
#define CMD_RMW 0xE0 #define CMD_RMW_CLEAR 0xEE #define CMD_INTERNAL_RESET 0xE2 #define CMD_SET_COM_NORMAL 0xC0 #define CMD_SET_COM_REVERSE 0xC8 #define CMD_SET_POWER_CONTROL 0x28 #define CMD_SET_RESISTOR_RATIO 0x20 #define CMD_SET_VOLUME_FIRST 0x81 #define CMD_SET_VOLUME_SECOND 0x00 #define CMD_SET_STATIC_OFF 0xAC #define CMD_SET_STATIC_ON 0xAD #define CMD_SET_STATIC_REG 0x00 #define CMD_SET_BOOSTER_FIRST 0xF8 #define CMD_SET_BOOSTER_234 0x00 #define CMD_SET_BOOSTER_5 0x01 #define CMD_SET_BOOSTER_6 0x03 #define CMD_NOP 0xE3 #define CMD_TEST 0xF0
/**********************
-
TYPEDEFS
**********************/
/**********************
- STATIC PROTOTYPES **********************/ static void st7565_sync(int32_t x1, int32_t y1, int32_t x2, int32_t y2); static void st7565_command(uint8_t cmd); static void st7565_data(uint8_t data);
/**********************
- STATIC VARIABLES / uint8_t lcd_fb[LV_HOR_RES_MAX * (LV_VER_RES_MAX+2)/8] = {0xAA, 0xAA}; //static uint8_t lcd_fb[ST7565_HOR_RES * ST7565_VER_RES /8] = {0xAA, 0xAA}; static uint8_t pagemap[] = {14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; //static uint8_t pagemap[] = { 7, 6, 5, 4, 3, 2, 1, 0 }; /
-
MACROS
**********************/ const uint8_t test_pic[] = {
0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF8,0xF8,0xF8,0x18,0x00,0x00,0x80, 0xF8,0xF8,0xF8,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0xC0,0xF8,0xF8,0xF8,0x18,0x00,0x00,0x80,0xF8,0xF8,0xF8,0x78,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF8,0xF8,0xF8, 0x18,0x00,0x00,0x80,0xF8,0xF8,0xF8,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF8,0xF8,0xF8,0x18,0x00,0x00,0x80,0xF8,0xF8, 0xF8,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0xC0,0xF8,0xF8,0xF8,0x18,0x00,0x00,0x80,0xF8,0xF8,0xF8,0x78,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF8,0xF8,0xF8,0x18, 0x00,0x00,0x80,0xF8,0xF8,0xF8,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xC0,0xF8,0xF8,0xF8,0x18,0x00,0x00,0x80,0xF8,0xF8,0xF8, 0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0, 0xF8,0xF8,0xF8,0x18,0x00,0x00,0x80,0xF8,0xF8,0xF8,0x78,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C, 0x1C,0xFC,0xFF,0xFF,0x7F,0x1C,0x1C,0x1C,0xDC,0xFF,0xFF,0x1F,0x1F,0x1C,0x1C,0x1C, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C,0x1C,0xFC,0xFF,0xFF,0x7F,0x1C, 0x1C,0x1C,0xDC,0xFF,0xFF,0x1F,0x1F,0x1C,0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x1C,0x1C,0x1C,0x1C,0xFC,0xFF,0xFF,0x7F,0x1C,0x1C,0x1C,0xDC,0xFF,0xFF,0x1F, 0x1F,0x1C,0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C,0x1C,0xFC, 0xFF,0xFF,0x7F,0x1C,0x1C,0x1C,0xDC,0xFF,0xFF,0x1F,0x1F,0x1C,0x1C,0x1C,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C,0x1C,0xFC,0xFF,0xFF,0x7F,0x1C,0x1C, 0x1C,0xDC,0xFF,0xFF,0x1F,0x1F,0x1C,0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x1C,0x1C,0x1C,0x1C,0xFC,0xFF,0xFF,0x7F,0x1C,0x1C,0x1C,0xDC,0xFF,0xFF,0x1F,0x1F, 0x1C,0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C,0x1C,0xFC,0xFF, 0xFF,0x7F,0x1C,0x1C,0x1C,0xDC,0xFF,0xFF,0x1F,0x1F,0x1C,0x1C,0x1C,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C,0x1C,0xFC,0xFF,0xFF,0x7F,0x1C,0x1C,0x1C,0xDC, 0xFF,0xFF,0x1F,0x1F,0x1C,0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C,0xFC,0xFE,0xFF,0xFF,0x1F,0x1C,0x9C, 0xFC,0xFC,0xFF,0xFF,0x1D,0x1C,0x1C,0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x1C,0x1C,0x1C,0xFC,0xFE,0xFF,0xFF,0x1F,0x1C,0x9C,0xFC,0xFC,0xFF,0xFF,0x1D,0x1C, 0x1C,0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C,0xFC,0xFE,0xFF, 0xFF,0x1F,0x1C,0x9C,0xFC,0xFC,0xFF,0xFF,0x1D,0x1C,0x1C,0x1C,0x1C,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C,0xFC,0xFE,0xFF,0xFF,0x1F,0x1C,0x9C,0xFC,0xFC, 0xFF,0xFF,0x1D,0x1C,0x1C,0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C, 0x1C,0x1C,0xFC,0xFE,0xFF,0xFF,0x1F,0x1C,0x9C,0xFC,0xFC,0xFF,0xFF,0x1D,0x1C,0x1C, 0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C,0xFC,0xFE,0xFF,0xFF, 0x1F,0x1C,0x9C,0xFC,0xFC,0xFF,0xFF,0x1D,0x1C,0x1C,0x1C,0x1C,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x1C,0x1C,0x1C,0xFC,0xFE,0xFF,0xFF,0x1F,0x1C,0x9C,0xFC,0xFC,0xFF, 0xFF,0x1D,0x1C,0x1C,0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C, 0xFC,0xFE,0xFF,0xFF,0x1F,0x1C,0x9C,0xFC,0xFC,0xFF,0xFF,0x1D,0x1C,0x1C,0x1C,0x1C, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07, 0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x07,0x07,0x07, 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x00, 0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x07,0x07,0x07,0x07, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x07,0x07,0x07,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00, 0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00, 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFC,0xFC,0x7C,0x0C,0x00,0x00, 0xC0,0xFC,0xFC,0xFC,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xE0,0xFC,0xFC,0x7C,0x0C,0x00,0x00,0xC0,0xFC,0xFC,0xFC,0x3C,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFC,0xFC, 0x7C,0x0C,0x00,0x00,0xC0,0xFC,0xFC,0xFC,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFC,0xFC,0x7C,0x0C,0x00,0x00,0xC0,0xFC, 0xFC,0xFC,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0xE0,0xFC,0xFC,0x7C,0x0C,0x00,0x00,0xC0,0xFC,0xFC,0xFC,0x3C,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFC,0xFC,0x7C, 0x0C,0x00,0x00,0xC0,0xFC,0xFC,0xFC,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFC,0xFC,0x7C,0x0C,0x00,0x00,0xC0,0xFC,0xFC, 0xFC,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xE0,0xFC,0xFC,0x7C,0x0C,0x00,0x00,0xC0,0xFC,0xFC,0xFC,0x3C,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x0E, 0x0E,0x0E,0xFE,0xFF,0xFF,0x3F,0x0E,0x0E,0x0E,0xEE,0xFF,0xFF,0x0F,0x0F,0x0E,0x0E, 0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x0E,0x0E,0x0E,0xFE,0xFF,0xFF,0x3F, 0x0E,0x0E,0x0E,0xEE,0xFF,0xFF,0x0F,0x0F,0x0E,0x0E,0x0E,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x0E,0x0E,0x0E,0x0E,0xFE,0xFF,0xFF,0x3F,0x0E,0x0E,0x0E,0xEE,0xFF,0xFF, 0x0F,0x0F,0x0E,0x0E,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x0E,0x0E,0x0E, 0xFE,0xFF,0xFF,0x3F,0x0E,0x0E,0x0E,0xEE,0xFF,0xFF,0x0F,0x0F,0x0E,0x0E,0x0E,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x0E,0x0E,0x0E,0xFE,0xFF,0xFF,0x3F,0x0E, 0x0E,0x0E,0xEE,0xFF,0xFF,0x0F,0x0F,0x0E,0x0E,0x0E,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x0E,0x0E,0x0E,0x0E,0xFE,0xFF,0xFF,0x3F,0x0E,0x0E,0x0E,0xEE,0xFF,0xFF,0x0F, 0x0F,0x0E,0x0E,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x0E,0x0E,0x0E,0xFE, 0xFF,0xFF,0x3F,0x0E,0x0E,0x0E,0xEE,0xFF,0xFF,0x0F,0x0F,0x0E,0x0E,0x0E,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x0E,0x0E,0x0E,0x0E,0xFE,0xFF,0xFF,0x3F,0x0E,0x0E,0x0E, 0xEE,0xFF,0xFF,0x0F,0x0F,0x0E,0x0E,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x0E,0x8E,0xFE,0xFF,0xFF,0x7F,0x0F,0x0E, 0xCE,0xFE,0xFE,0xFF,0x7F,0x0E,0x0E,0x0E,0x0E,0x0E,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x0E,0x0E,0x8E,0xFE,0xFF,0xFF,0x7F,0x0F,0x0E,0xCE,0xFE,0xFE,0xFF,0x7F,0x0E, 0x0E,0x0E,0x0E,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x0E,0x8E,0xFE,0xFF, 0xFF,0x7F,0x0F,0x0E,0xCE,0xFE,0xFE,0xFF,0x7F,0x0E,0x0E,0x0E,0x0E,0x0E,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x0E,0x0E,0x8E,0xFE,0xFF,0xFF,0x7F,0x0F,0x0E,0xCE,0xFE, 0xFE,0xFF,0x7F,0x0E,0x0E,0x0E,0x0E,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x0E,0x0E,0x8E,0xFE,0xFF,0xFF,0x7F,0x0F,0x0E,0xCE,0xFE,0xFE,0xFF,0x7F,0x0E,0x0E, 0x0E,0x0E,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x0E,0x8E,0xFE,0xFF,0xFF, 0x7F,0x0F,0x0E,0xCE,0xFE,0xFE,0xFF,0x7F,0x0E,0x0E,0x0E,0x0E,0x0E,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x0E,0x0E,0x8E,0xFE,0xFF,0xFF,0x7F,0x0F,0x0E,0xCE,0xFE,0xFE, 0xFF,0x7F,0x0E,0x0E,0x0E,0x0E,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x0E, 0x8E,0xFE,0xFF,0xFF,0x7F,0x0F,0x0E,0xCE,0xFE,0xFE,0xFF,0x7F,0x0E,0x0E,0x0E,0x0E, 0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03, 0x03,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x03,0x03, 0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x03, 0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x03,0x03,0x03, 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x00,0x00, 0x00,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x3F,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x20,0x20,0x20,0x20,0x3F,0x00,
};
#define numoflcd 1 #define numoflcdspi 1
#define A0(S) GPIO_PinWrite(GPIO1, 3U, S) #define RES(S) GPIO_PinWrite(GPIO1, 16U, S)
struct _bapi_io_lcdProperties _lcd_pin_properties[numoflcd]; struct _bapi_io_lcdspiProperties _io_lcdspiProperties[numoflcdspi];
/**********************
- GLOBAL FUNCTIONS **********************/ //status_t SPI_Transfer_LCD(uint8_t *txData, uint8_t *rxData, uint16_t size); status_t SPI_Transfer_LCD(spi_bus_idx_t busIdx, spi_dev_idx_t devIdx, uint8_t *txData, uint8_t *rxData, uint16_t size, bool blocking, spi_dma_callback_t lcd_spi_dma_cb); extern uint32_t LCD_SpiReadWrite(uint8_t *pBufferTx, uint8_t *pBufferRx, uint32_t nbBytes, bool useDma, uint8_t devIdx);
void write_com(uint8_t para);
void write_data(uint8_t para);
void sdelay(uint32_t t) { //#define EXAMPLE_DELAY_COUNT 8000000 #define EXAMPLE_DELAY_COUNT 80
volatile uint32_t i = 0;
while(t--)
{
for (i = 0; i < EXAMPLE_DELAY_COUNT; ++i)
{
__asm("NOP"); /* delay */
}
}
}
typedef enum { SPI_DEV_LCD_1 = 0, SPI_DEV_LCD_2, SPI_DEV_LCD_3, SPI_DEV_LCD_4,
}spi_dev_lcd_idx_t; #if 0 typedef struct sku_io { uint8_t is_uio; uint8_t is_bi; uint8_t is_bo; uint8_t is_lcd; uint8_t is_led;
uint8_t uio_ch_num;
uint8_t bi_ch_num;
uint8_t bo_ch_num;
}sku_io_t; #endif
LPSPI_Type * lcdSpi_base = 0; #if 0 status_t SPI_Transfer_LCD(uint8_t *txData, uint8_t *rxData, uint16_t size) {
status_t sts = 0xff;
lpspi_transfer_t transfer;
#if 0 if ((NULL == txData) || (0 == size)) { PRINTF("SPI_Transfer: Invalid parameters!\r\n"); return kStatus_InvalidArgument; } #endif
transfer.configFlags = kLPSPI_MasterPcs2|kLPSPI_MasterPcsContinuous;
transfer.dataSize = size;
transfer.rxData = rxData;
transfer.txData = txData;
#if 0
LPSPI_Type * spi_base;
if( (sku_status.has_lcd == 1) && (sku_status.has_uio == 0)){spi_base = (LPSPI_Type *)cf_spi_get_base(0);}
//kStatus_Success
sts =LPSPI_MasterTransferBlocking( lcdSpi_base, &transfer);//spi_base
#endif
sts =LPSPI_MasterTransferBlocking(LPSPI3, &transfer);
if(sts != kStatus_Success)
{
while(1);
}
return sts;
} #endif
volatile bool isLcdTransferCompleted; //static uint8_t dma_resume_flag = 0;
void lcd_spi_dma_transfer_completed(void) { isLcdTransferCompleted = true; }
void lcd_spi_dma_transfer_completed_flush(void) { ui_signalset(); }
spi_dma_callback_t lcd_spi_dma_callback;
status_t SPI_Transfer_LCD(spi_bus_idx_t busIdx, spi_dev_idx_t devIdx, uint8_t *txData, uint8_t *rxData, uint16_t size, bool blocking, spi_dma_callback_t lcd_spi_dma_cb) { status_t rv=-1;
if(lcd_spi_dma_cb == NULL)
{
return rv;
}
if(blocking)
{
isLcdTransferCompleted = false;
lcd_spi_dma_callback = lcd_spi_dma_cb;
rv = LCD_SpiReadWrite(txData, rxData, size, 0, devIdx);
while(isLcdTransferCompleted == false)
{
}
}
else
{
lcd_spi_dma_callback = lcd_spi_dma_cb;
rv = LCD_SpiReadWrite(txData, rxData, size, 0, devIdx);
ui_signalwait();
}
return rv;
}
void write_com(uint8_t para) {
uint8_t temp[2] ={0};
uint8_t tpara[2] ={0};
#if DV1_SNAP_ON tpara[0]=(para>>1)&0x7F; tpara[1]=((para<<7)&0x80)|0x7f; //A0(0); //sdelay(4);//delay(20);//delay(20); SPI_Transfer_LCD(tpara, temp, 2);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if DV2_SNAP_ON
tpara[0]=para;
//A0(0);
GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 0U);
//sdelay(40);//delay(20);//delay(20);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, 1, true, lcd_spi_dma_transfer_completed);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if REDESIGN_DV1_SNAP_ON
tpara[0]=para;
//A0(0);
GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 0U);
//sdelay(40);//delay(20);//delay(20);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, 1, true, lcd_spi_dma_transfer_completed);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
}
void write_com_dma(uint8_t* para, const uint16_t size) {
uint8_t *temp =(uint8_t *)malloc(size);
uint8_t *tpara =(uint8_t *)malloc(size);
//static uint8_t temp[256] ={0};
//static uint8_t x_send[256] ={0};
#if DV1_SNAP_ON tpara[0]=(para>>1)&0x7F; tpara[1]=((para<<7)&0x80)|0x7f; //A0(0); //sdelay(4);//delay(20);//delay(20); SPI_Transfer_LCD(tpara, temp, 2);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if DV2_SNAP_ON
for(int i_size = 0; i_size <size; i_size++)
{
tpara[i_size]=para[i_size];
}
//A0(0);
GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 0U);
//sdelay(40);//delay(20);//delay(20);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, size, true, lcd_spi_dma_transfer_completed);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if REDESIGN_DV1_SNAP_ON
for(int i_size = 0; i_size <size; i_size++)
{
tpara[i_size]=para[i_size];
}
//A0(0);
GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 0U);
//sdelay(40);//delay(20);//delay(20);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, size, true, lcd_spi_dma_transfer_completed);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif free(temp); free(tpara);
}
void write_data(uint8_t para) {
uint8_t temp[2] ={0};
uint8_t tpara[2] ={0};
#if DV1_SNAP_ON tpara[0]=(para>>1)|0x80; tpara[1]=((para<<7)&0x80)|0x7f;
//A0(1);
//sdelay(4);//delay(20);//delay(20);
SPI_Transfer_LCD(tpara, temp, 2);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if DV2_SNAP_ON
tpara[0]=para;
//A0(1);
GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 1U);
//sdelay(40);//delay(20);//delay(20);
//SPI_Transfer_LCD(tpara, temp, 1);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, 1, true, lcd_spi_dma_transfer_completed);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if REDESIGN_DV1_SNAP_ON
tpara[0]=para;
//A0(1);
GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 1U);
//sdelay(40);//delay(20);//delay(20);
//SPI_Transfer_LCD(tpara, temp, 1);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, 1, true, lcd_spi_dma_transfer_completed);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
}
void write_data_dma(uint8_t* para, const uint16_t size) {
uint8_t *temp =(uint8_t *)malloc(size);
uint8_t *tpara =(uint8_t *)malloc(size);
#if DV1_SNAP_ON tpara[0]=(para>>1)|0x80; tpara[1]=((para<<7)&0x80)|0x7f;
//A0(1);
//sdelay(4);//delay(20);//delay(20);
SPI_Transfer_LCD(tpara, temp, 2);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if DV2_SNAP_ON for(int i_size = 0; i_size <size; i_size++) { tpara[i_size]=para[i_size]; } //A0(1); GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 1U); //sdelay(40);//delay(20);//delay(20);
//SPI_Transfer_LCD(tpara, temp, 1);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, size, true, lcd_spi_dma_transfer_completed);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if REDESIGN_DV1_SNAP_ON for(int i_size = 0; i_size <size; i_size++) { tpara[i_size]=para[i_size]; } //A0(1); GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 1U); //sdelay(40);//delay(20);//delay(20);
//SPI_Transfer_LCD(tpara, temp, 1);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, size, true, lcd_spi_dma_transfer_completed);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif free(temp); free(tpara);
}
void write_data_raw(uint8_t para) {
uint8_t temp[2] ={0};
uint8_t tpara[2] ={0};
#if DV1_SNAP_ON tpara[0]=(para>>1)|0x80; tpara[1]=((para<<7)&0x80)|0x7f;
//A0(1);
//sdelay(4);//delay(20);//delay(20);
SPI_Transfer_LCD(tpara, temp, 2);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if DV2_SNAP_ON
tpara[0]=para;
//A0(1);
//sdelay(40);//delay(20);//delay(20);
//SPI_Transfer_LCD(tpara, temp, 1);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, 1, true, lcd_spi_dma_transfer_completed);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if REDESIGN_DV1_SNAP_ON
tpara[0]=para;
//A0(1);
//sdelay(40);//delay(20);//delay(20);
//SPI_Transfer_LCD(tpara, temp, 1);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, 1, true, lcd_spi_dma_transfer_completed);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
}
/////////////////////////////// void write_com_flush(uint8_t para) {
uint8_t temp[2] ={0};
uint8_t tpara[2] ={0};
#if DV1_SNAP_ON tpara[0]=(para>>1)&0x7F; tpara[1]=((para<<7)&0x80)|0x7f; //A0(0); //sdelay(4);//delay(20);//delay(20); SPI_Transfer_LCD(tpara, temp, 2);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if DV2_SNAP_ON
tpara[0]=para;
//A0(0);
GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 0U);
//sdelay(40);//delay(20);//delay(20);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, 1, false, lcd_spi_dma_transfer_completed_flush);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if REDESIGN_DV1_SNAP_ON
tpara[0]=para;
//A0(0);
GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 0U);
//sdelay(40);//delay(20);//delay(20);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, 1, false, lcd_spi_dma_transfer_completed_flush);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
}
void write_com_dma_flush(uint8_t* para, const uint16_t size) {
uint8_t *temp =(uint8_t *)malloc(size);
uint8_t *tpara =(uint8_t *)malloc(size);
//static uint8_t temp[256] ={0};
//static uint8_t x_send[256] ={0};
#if DV1_SNAP_ON tpara[0]=(para>>1)&0x7F; tpara[1]=((para<<7)&0x80)|0x7f; //A0(0); //sdelay(4);//delay(20);//delay(20); SPI_Transfer_LCD(tpara, temp, 2);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if DV2_SNAP_ON
for(int i_size = 0; i_size <size; i_size++)
{
tpara[i_size]=para[i_size];
}
//A0(0);
GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 0U);
//sdelay(40);//delay(20);//delay(20);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, size, false, lcd_spi_dma_transfer_completed_flush);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if REDESIGN_DV1_SNAP_ON
for(int i_size = 0; i_size <size; i_size++)
{
tpara[i_size]=para[i_size];
}
//A0(0);
GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 0U);
//sdelay(40);//delay(20);//delay(20);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, size, false, lcd_spi_dma_transfer_completed_flush);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif free(temp); free(tpara);
}
void write_data_flush(uint8_t para) {
uint8_t temp[2] ={0};
uint8_t tpara[2] ={0};
#if DV1_SNAP_ON tpara[0]=(para>>1)|0x80; tpara[1]=((para<<7)&0x80)|0x7f;
//A0(1);
//sdelay(4);//delay(20);//delay(20);
SPI_Transfer_LCD(tpara, temp, 2);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if DV2_SNAP_ON
tpara[0]=para;
//A0(1);
GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 1U);
//sdelay(40);//delay(20);//delay(20);
//SPI_Transfer_LCD(tpara, temp, 1);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, 1, false, lcd_spi_dma_transfer_completed_flush);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if REDESIGN_DV1_SNAP_ON
tpara[0]=para;
//A0(1);
GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 1U);
//sdelay(40);//delay(20);//delay(20);
//SPI_Transfer_LCD(tpara, temp, 1);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, 1, false, lcd_spi_dma_transfer_completed_flush);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
}
void write_data_dma_flush(uint8_t* para, const uint16_t size) {
uint8_t *temp =(uint8_t *)malloc(size);
uint8_t *tpara =(uint8_t *)malloc(size);
#if DV1_SNAP_ON tpara[0]=(para>>1)|0x80; tpara[1]=((para<<7)&0x80)|0x7f;
//A0(1);
//sdelay(4);//delay(20);//delay(20);
SPI_Transfer_LCD(tpara, temp, 2);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if DV2_SNAP_ON for(int i_size = 0; i_size <size; i_size++) { tpara[i_size]=para[i_size]; } //A0(1); GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 1U); //sdelay(40);//delay(20);//delay(20);
//SPI_Transfer_LCD(tpara, temp, 1);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, size, false, lcd_spi_dma_transfer_completed_flush);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if REDESIGN_DV1_SNAP_ON for(int i_size = 0; i_size <size; i_size++) { tpara[i_size]=para[i_size]; } //A0(1); GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 1U); //sdelay(40);//delay(20);//delay(20);
//SPI_Transfer_LCD(tpara, temp, 1);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, size, false, lcd_spi_dma_transfer_completed_flush);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif free(temp); free(tpara);
}
void write_data_raw_flush(uint8_t para) {
uint8_t temp[2] ={0};
uint8_t tpara[2] ={0};
#if DV1_SNAP_ON tpara[0]=(para>>1)|0x80; tpara[1]=((para<<7)&0x80)|0x7f;
//A0(1);
//sdelay(4);//delay(20);//delay(20);
SPI_Transfer_LCD(tpara, temp, 2);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if DV2_SNAP_ON
tpara[0]=para;
//A0(1);
//sdelay(40);//delay(20);//delay(20);
//SPI_Transfer_LCD(tpara, temp, 1);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, 1, false, lcd_spi_dma_transfer_completed_flush);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
#if REDESIGN_DV1_SNAP_ON
tpara[0]=para;
//A0(1);
//sdelay(40);//delay(20);//delay(20);
//SPI_Transfer_LCD(tpara, temp, 1);
SPI_Transfer_LCD(SPI_BUS_UIO_3, 2, tpara, temp, 1, false, lcd_spi_dma_transfer_completed_flush);
//delay(30);//delay(20);//delay(10);//delay(20);
#endif
}
/////////////////////////////////
#define ST7565_CMDX_MODE 0 #define ST7565_DATAX_MODE 1
#define XCMD_DISPLAY_OFF 0xAE #define XCMD_DISPLAY_ON 0xAF
#define XCMD_SET_DISP_START_LINE 0x40 #define XCMD_SET_PAGE 0xB0
#define XCMD_SET_COLUMN_UPPER 0x10 #define XCMD_SET_COLUMN_LOWER 0x00
#define XCMD_SET_ADC_NORMAL 0xA0 #define XCMD_SET_ADC_REVERSE 0xA1
#define XCMD_SET_DISP_NORMAL 0xA6 #define XCMD_SET_DISP_REVERSE 0xA7
#define XCMD_SET_ALLPTS_NORMAL 0xA4 #define XCMD_SET_ALLPTS_ON 0xA5 #define XCMD_SET_BIAS_9 0xA2 #define XCMD_SET_BIAS_7 0xA3
#define XCMD_RMW 0xE0 #define XCMD_RMW_CLEAR 0xEE #define XCMD_INTERNAL_RESET 0xE2 #define XCMD_SET_COM_NORMAL 0xC0 #define XCMD_SET_COM_REVERSE 0xC8 #define XCMD_SET_POWER_CONTROL 0x28 #define XCMD_SET_RESISTOR_RATIO 0x20 #define XCMD_SET_VOLUME_FIRST 0x81 #define XCMD_SET_VOLUME_SECOND 0x00 #define XCMD_SET_STATIC_OFF 0xAC #define XCMD_SET_STATIC_ON 0xAD #define XCMD_SET_STATIC_REG 0x00 #define XCMD_SET_BOOSTER_FIRST 0xF8 #define XCMD_SET_BOOSTER_234 0x00 #define XCMD_SET_BOOSTER_5 0x01 #define XCMD_SET_BOOSTER_6 0x03 #define XCMD_NOP 0xE3 #define XCMD_TEST 0xF0
//============================================================================== //LPSPI2 //============================================================================== #if 1
/* Master related */ #define EXAMPLE_LPSPI_MASTER_BASEADDR (LPSPI3) #define EXAMPLE_LPSPI_MASTER_IRQN LPSPI3_IRQn #define EXAMPLE_LPSPI_MASTER_IRQHandler LPSPI3_IRQHandler
#define EXAMPLE_LPSPI_MASTER_PCS_FOR_INIT (kLPSPI_Pcs0) #define EXAMPLE_LPSPI_MASTER_PCS_FOR_TRANSFER (kLPSPI_MasterPcs0)
/* Select USB1 PLL PFD0 (720 MHz) as lpspi clock source / #define EXAMPLE_LPSPI_CLOCK_SOURCE_SELECT (2)//(1U) / Clock divider for master lpspi clock source / #define EXAMPLE_LPSPI_CLOCK_SOURCE_DIVIDER (3)//(7U) //kCLOCK_SysPllClk //kCLOCK_Usb1PllPfd0Clk // #define LPSPI_MASTER_CLK_FREQ (CLOCK_GetFreq(kCLOCK_SysPllClk) / (EXAMPLE_LPSPI_CLOCK_SOURCE_DIVIDER + 1U)) #define TRANSFER_SIZE 64U /! Transfer dataSize / //#define TRANSFER_BAUDRATE 500000U /! Transfer baudrate - 500k */ #endif //==============================================================================
//#define A0(S) GPIO_PinWrite(GPIO1, 17U, S) //#define RES(S) GPIO_PinWrite(GPIO1, 16U, S)
//#define LCD_SPI 3 extern _spi_bus_Property_t spi_Property[NUMOFSPI];
void _LCD_configureGpioPins(void) { int spiIndex = 0;
#pragma diag_suppress=Pe223 spiIndex = cf_lcd_get_spi_index(); #pragma diag_default=Pe223 // cf_lcd_get_spi(&_io_lcdspiProperties[0]);
// for(spiIndex = 0; spiIndex < SpiTolNum; spiIndex++) // { // if( spi_Property[spiIndex].spi_id == LCD_SPI ) // { // break; // } // } lcdSpi_base = spi_Property[spiIndex].spi_base; // if( (sku_status.has_lcd == 1) && (sku_status.has_uio == 0)) // { // lcdSpi_base = spi_Property[0].spi_base;//(LPSPI_Type *)cf_spi_get_base(0); // } // // else if((sku_status.has_lcd == 1) && (sku_status.has_uio == 1)) // { // lcdSpi_base = spi_Property[1].spi_base;//(LPSPI_Type *)cf_spi_get_base(1); // } #if 0 cf_spi_read_sck_cfg(1, &spi_sck); cf_spi_read_sdo_cfg(1, &spi_sdo); cf_spi_read_sdi_cfg(1, &spi_sdi);
IOMUXC_SetPinMux(spi_sck.muxRegister, spi_sck.muxMode, spi_sck.inputRegister,
spi_sck.inputDaisy, spi_sck.configRegister, 0U);
IOMUXC_SetPinConfig(spi_sck.muxRegister, spi_sck.muxMode, spi_sck.inputRegister,
spi_sck.inputDaisy, spi_sck.configRegister, 0x10B0u);
IOMUXC_SetPinMux(spi_sdo.muxRegister, spi_sdo.muxMode, spi_sdo.inputRegister,
spi_sdo.inputDaisy, spi_sdo.configRegister, 0U);
IOMUXC_SetPinConfig(spi_sdo.muxRegister, spi_sdo.muxMode, spi_sdo.inputRegister,
spi_sdo.inputDaisy, spi_sdo.configRegister, 0x10B0u);
IOMUXC_SetPinMux(spi_sdi.muxRegister, spi_sdi.muxMode, spi_sdi.inputRegister,
spi_sdi.inputDaisy, spi_sdi.configRegister, 0U);
IOMUXC_SetPinConfig(spi_sdi.muxRegister, spi_sdi.muxMode, spi_sdi.inputRegister,
spi_sdi.inputDaisy, spi_sdi.configRegister, 0x10B0u);
//--------------------------------------------------------
cf_spi_read_scs_cfg(1, 0, &spi_scs);
IOMUXC_SetPinMux(spi_scs.muxRegister, spi_scs.muxMode, spi_scs.inputRegister,
spi_scs.inputDaisy, spi_scs.configRegister, 0U);
IOMUXC_SetPinConfig(spi_scs.muxRegister, spi_scs.muxMode, spi_scs.inputRegister,
spi_scs.inputDaisy, spi_scs.configRegister, 0x10B0u);
#endif
#if 0 IOMUXC_SetPinMux( IOMUXC_GPIO_AD_B0_00_LPSPI3_SCK, /* GPIO_SD_B0_00 is configured as LPSPI1_SCK / 0U); / Software Input On Field: Input Path is determined by functionality / IOMUXC_SetPinMux( IOMUXC_GPIO_AD_B0_05_LPSPI3_PCS2, / GPIO_SD_B0_01 is configured as LPSPI1_PCS0 / 0U); / Software Input On Field: Input Path is determined by functionality / IOMUXC_SetPinMux( IOMUXC_GPIO_AD_B0_01_LPSPI3_SDO, / GPIO_SD_B0_02 is configured as LPSPI1_SDO / 0U); / Software Input On Field: Input Path is determined by functionality / IOMUXC_SetPinMux( IOMUXC_GPIO_AD_B0_02_LPSPI3_SDI, / GPIO_SD_B0_03 is configured as LPSPI1_SDI / 0U); / Software Input On Field: Input Path is determined by functionality */
IOMUXC_SetPinConfig(
IOMUXC_GPIO_AD_B0_00_LPSPI3_SCK, /* GPIO_SD_B0_00 PAD functional properties : */
0x10B0u); /* Slew Rate Field: Slow Slew Rate
Drive Strength Field: R0/6
Speed Field: medium(100MHz)
Open Drain Enable Field: Open Drain Disabled
Pull / Keep Enable Field: Pull/Keeper Enabled
Pull / Keep Select Field: Keeper
Pull Up / Down Config. Field: 100K Ohm Pull Down
Hyst. Enable Field: Hysteresis Disabled */
IOMUXC_SetPinConfig(
IOMUXC_GPIO_AD_B0_05_LPSPI3_PCS2, /* GPIO_SD_B0_01 PAD functional properties : */
0x10B0u); /* Slew Rate Field: Slow Slew Rate
Drive Strength Field: R0/6
Speed Field: medium(100MHz)
Open Drain Enable Field: Open Drain Disabled
Pull / Keep Enable Field: Pull/Keeper Enabled
Pull / Keep Select Field: Keeper
Pull Up / Down Config. Field: 100K Ohm Pull Down
Hyst. Enable Field: Hysteresis Disabled */
IOMUXC_SetPinConfig(
IOMUXC_GPIO_AD_B0_01_LPSPI3_SDO, /* GPIO_SD_B0_02 PAD functional properties : */
0x10B0u); /* Slew Rate Field: Slow Slew Rate
Drive Strength Field: R0/6
Speed Field: medium(100MHz)
Open Drain Enable Field: Open Drain Disabled
Pull / Keep Enable Field: Pull/Keeper Enabled
Pull / Keep Select Field: Keeper
Pull Up / Down Config. Field: 100K Ohm Pull Down
Hyst. Enable Field: Hysteresis Disabled */
IOMUXC_SetPinConfig(
IOMUXC_GPIO_AD_B0_02_LPSPI3_SDI, /* GPIO_SD_B0_03 PAD functional properties : */
0x10B0u); /* Slew Rate Field: Slow Slew Rate
Drive Strength Field: R0/6
Speed Field: medium(100MHz)
Open Drain Enable Field: Open Drain Disabled
Pull / Keep Enable Field: Pull/Keeper Enabled
Pull / Keep Select Field: Keeper
Pull Up / Down Config. Field: 100K Ohm Pull Down
Hyst. Enable Field: Hysteresis Disabled */
#endif
#if DV1_SNAP_ON
IOMUXC_SetPinMux( IOMUXC_GPIO_AD_B0_03_GPIO1_IO03, 0U);
IOMUXC_SetPinConfig( IOMUXC_GPIO_AD_B0_03_GPIO1_IO03, 0x10B0u);
IOMUXC_SetPinMux( IOMUXC_GPIO_AD_B1_00_GPIO1_IO16, 0U);
IOMUXC_SetPinConfig( IOMUXC_GPIO_AD_B1_00_GPIO1_IO16, 0x10B0u);
#endif
#if DV2_SNAP_ON uint8_t Num = cf_lcd_get_num();
for(int i = 0; i<Num; i++)
{
cf_lcd_get_pin_config(i, &_lcd_pin_properties[i]);
IOMUXC_SetPinMux(_lcd_pin_properties[i].rstpin.muxReg,_lcd_pin_properties[i].rstpin.muxMode,_lcd_pin_properties[i].rstpin.inputReg,
_lcd_pin_properties[i].rstpin.inputDaisy,_lcd_pin_properties[i].rstpin.configReg, 0U);
IOMUXC_SetPinConfig(_lcd_pin_properties[i].rstpin.muxReg,_lcd_pin_properties[i].rstpin.muxMode,_lcd_pin_properties[i].rstpin.inputReg,
_lcd_pin_properties[i].rstpin.inputDaisy,_lcd_pin_properties[i].rstpin.configReg,0x10B0u);
IOMUXC_SetPinMux(_lcd_pin_properties[i].A0pin.muxReg,_lcd_pin_properties[i].A0pin.muxMode,_lcd_pin_properties[i].A0pin.inputReg,
_lcd_pin_properties[i].A0pin.inputDaisy,_lcd_pin_properties[i].rstpin.configReg, 0U);
IOMUXC_SetPinConfig(_lcd_pin_properties[i].A0pin.muxReg,_lcd_pin_properties[i].A0pin.muxMode,_lcd_pin_properties[i].A0pin.inputReg,
_lcd_pin_properties[i].A0pin.inputDaisy,_lcd_pin_properties[i].A0pin.configReg,0x10B0u);
IOMUXC_SetPinMux(_lcd_pin_properties[i].bkpin.muxReg,_lcd_pin_properties[i].bkpin.muxMode,_lcd_pin_properties[i].bkpin.inputReg,
_lcd_pin_properties[i].bkpin.inputDaisy,_lcd_pin_properties[i].bkpin.configReg, 0U);
IOMUXC_SetPinConfig(_lcd_pin_properties[i].bkpin.muxReg,_lcd_pin_properties[i].bkpin.muxMode,_lcd_pin_properties[i].bkpin.inputReg,
_lcd_pin_properties[i].bkpin.inputDaisy,_lcd_pin_properties[i].bkpin.configReg,0x10B0u);
cf_lcd_get_bk_pwm_config(i, &_lcd_pin_properties[i]);
}
#endif
#if REDESIGN_DV1_SNAP_ON uint8_t Num = cf_lcd_get_num();
for(int i = 0; i<Num; i++)
{
cf_lcd_get_pin_config(i, &_lcd_pin_properties[i]);
IOMUXC_SetPinMux(_lcd_pin_properties[i].rstpin.muxReg,_lcd_pin_properties[i].rstpin.muxMode,_lcd_pin_properties[i].rstpin.inputReg,
_lcd_pin_properties[i].rstpin.inputDaisy,_lcd_pin_properties[i].rstpin.configReg, 0U);
IOMUXC_SetPinConfig(_lcd_pin_properties[i].rstpin.muxReg,_lcd_pin_properties[i].rstpin.muxMode,_lcd_pin_properties[i].rstpin.inputReg,
_lcd_pin_properties[i].rstpin.inputDaisy,_lcd_pin_properties[i].rstpin.configReg,0x10B0u);
IOMUXC_SetPinMux(_lcd_pin_properties[i].A0pin.muxReg,_lcd_pin_properties[i].A0pin.muxMode,_lcd_pin_properties[i].A0pin.inputReg,
_lcd_pin_properties[i].A0pin.inputDaisy,_lcd_pin_properties[i].rstpin.configReg, 0U);
IOMUXC_SetPinConfig(_lcd_pin_properties[i].A0pin.muxReg,_lcd_pin_properties[i].A0pin.muxMode,_lcd_pin_properties[i].A0pin.inputReg,
_lcd_pin_properties[i].A0pin.inputDaisy,_lcd_pin_properties[i].A0pin.configReg,0x10B0u);
IOMUXC_SetPinMux(_lcd_pin_properties[i].bkpin.muxReg,_lcd_pin_properties[i].bkpin.muxMode,_lcd_pin_properties[i].bkpin.inputReg,
_lcd_pin_properties[i].bkpin.inputDaisy,_lcd_pin_properties[i].bkpin.configReg, 0U);
IOMUXC_SetPinConfig(_lcd_pin_properties[i].bkpin.muxReg,_lcd_pin_properties[i].bkpin.muxMode,_lcd_pin_properties[i].bkpin.inputReg,
_lcd_pin_properties[i].bkpin.inputDaisy,_lcd_pin_properties[i].bkpin.configReg,0x10B0u);
cf_lcd_get_bk_pwm_config(i, &_lcd_pin_properties[i]);
}
#endif
}
#if DV2_SNAP_ON //==================================================================== //lcd pwm backlight pin #include "fsl_flexio.h" //==================================== /*******************************************************************************
- Definitions *****************************************************************************/ #define DEMO_FLEXIO_BASEADDR FLEXIO2 //#define DEMO_FLEXIO_OUTPUTPIN (5U) / Select FXIO2_D5 as PWM output / #define DEMO_FLEXIO_OUTPUTPIN (4U) / Select FXIO2_D4 as PWM output / #define DEMO_FLEXIO_TIMER_CH (0U) / Flexio timer0 used */
/* Select USB1 PLL (480 MHz) as flexio clock source /
#define FLEXIO_CLOCK_SELECT (3U)
/ Clock pre divider for flexio clock source /
#define FLEXIO_CLOCK_PRE_DIVIDER (4U)
/ Clock divider for flexio clock source /
#define FLEXIO_CLOCK_DIVIDER (7U)
#define DEMO_FLEXIO_CLOCK_FREQUENCY
(CLOCK_GetFreq(kCLOCK_Usb1PllClk) / (FLEXIO_CLOCK_PRE_DIVIDER + 1U) / (FLEXIO_CLOCK_DIVIDER + 1U))
/ FLEXIO output PWM frequency */
//#define DEMO_FLEXIO_FREQUENCY (48000U)
// #define DEMO_FLEXIO_FREQUENCY (125000U)
#define FLEXIO_MAX_FREQUENCY (DEMO_FLEXIO_CLOCK_FREQUENCY / 2U)
#define FLEXIO_MIN_FREQUENCY (DEMO_FLEXIO_CLOCK_FREQUENCY / 256U)
/*******************************************************************************
- Code ******************************************************************************/ uint8_t xduty=50;
void flexio_pwm_init(uint32_t freq_Hz, uint32_t duty) { assert((freq_Hz < FLEXIO_MAX_FREQUENCY) && (freq_Hz > FLEXIO_MIN_FREQUENCY));
uint32_t lowerValue = 0; /* Number of clock cycles in high logic state in one period */
uint32_t upperValue = 0; /* Number of clock cycles in low logic state in one period */
uint32_t sum = 0; /* Number of clock cycles in one period */
flexio_timer_config_t fxioTimerConfig;
/* Check parameter */
//if ((duty > 99) || (duty == 0))
if ((duty > 99))
{
duty = 99;
}
if (duty == 0)
{
duty = 1;
}
/* Configure the timer DEMO_FLEXIO_TIMER_CH for generating PWM */
fxioTimerConfig.triggerSelect = FLEXIO_TIMER_TRIGGER_SEL_SHIFTnSTAT(0U);
fxioTimerConfig.triggerSource = kFLEXIO_TimerTriggerSourceInternal;
fxioTimerConfig.triggerPolarity = kFLEXIO_TimerTriggerPolarityActiveLow;
fxioTimerConfig.pinConfig = kFLEXIO_PinConfigOutput;
fxioTimerConfig.pinPolarity = kFLEXIO_PinActiveHigh;
// fxioTimerConfig.pinSelect = DEMO_FLEXIO_OUTPUTPIN; /* Set pwm output / fxioTimerConfig.pinSelect = _lcd_pin_properties[0].bkpin.pin;//DEMO_FLEXIO_OUTPUTPIN; / Set pwm output */ fxioTimerConfig.timerMode = kFLEXIO_TimerModeDisabled; fxioTimerConfig.timerOutput = kFLEXIO_TimerOutputOneNotAffectedByReset; fxioTimerConfig.timerDecrement = kFLEXIO_TimerDecSrcOnFlexIOClockShiftTimerOutput; fxioTimerConfig.timerDisable = kFLEXIO_TimerDisableNever; fxioTimerConfig.timerEnable = kFLEXIO_TimerEnabledAlways; fxioTimerConfig.timerReset = kFLEXIO_TimerResetNever; fxioTimerConfig.timerStart = kFLEXIO_TimerStartBitDisabled; fxioTimerConfig.timerStop = kFLEXIO_TimerStopBitDisabled;
/* Calculate timer lower and upper values of TIMCMP */
/* Calculate the nearest integer value for sum, using formula round(x) = (2 * floor(x) + 1) / 2 */
/* sum = DEMO_FLEXIO_CLOCK_FREQUENCY / freq_H */
sum = (DEMO_FLEXIO_CLOCK_FREQUENCY * 2 / freq_Hz + 1) / 2;
/* Calculate the nearest integer value for lowerValue, the high period of the pwm output */
/* lowerValue = sum * duty / 100 */
lowerValue = (sum * duty / 50 + 1) / 2;
/* Calculate upper value, the low period of the pwm output */
upperValue = sum - lowerValue;
fxioTimerConfig.timerCompare = ((upperValue - 1) << 8U) | (lowerValue - 1);
// FLEXIO_SetTimerConfig(DEMO_FLEXIO_BASEADDR, DEMO_FLEXIO_TIMER_CH, &fxioTimerConfig); FLEXIO_SetTimerConfig((FLEXIO_Type *)_lcd_pin_properties[0].bk_pwm.base, _lcd_pin_properties[0].bk_pwm.timer_ch, &fxioTimerConfig); }
void flexio_pwm_start(void) { /* Set Timer mode to kFLEXIO_TimerModeDual8BitPWM to start timer */ // DEMO_FLEXIO_BASEADDR->TIMCTL[DEMO_FLEXIO_TIMER_CH] |= FLEXIO_TIMCTL_TIMOD(kFLEXIO_TimerModeDual8BitPWM); ((FLEXIO_Type *)_lcd_pin_properties[0].bk_pwm.base)->TIMCTL[_lcd_pin_properties[0].bk_pwm.timer_ch] |= FLEXIO_TIMCTL_TIMOD(kFLEXIO_TimerModeDual8BitPWM); }
#pragma diag_suppress=Pe177 static void flexio_pwm_stop(void) { /* Set Timer mode to kFLEXIO_TimerModeDisabled to stop timer */ // DEMO_FLEXIO_BASEADDR->TIMCTL[DEMO_FLEXIO_TIMER_CH] |= FLEXIO_TIMCTL_TIMOD(kFLEXIO_TimerModeDisabled); ((FLEXIO_Type *)_lcd_pin_properties[0].bk_pwm.base)->TIMCTL[_lcd_pin_properties[0].bk_pwm.timer_ch] |= FLEXIO_TIMCTL_TIMOD(kFLEXIO_TimerModeDisabled); }
static void flexio_pwm_duty_change(uint32_t freq_Hz,uint32_t duty) { assert((freq_Hz < FLEXIO_MAX_FREQUENCY) && (freq_Hz > FLEXIO_MIN_FREQUENCY));
uint32_t lowerValue = 0; /* Number of clock cycles in high logic state in one period */
uint32_t upperValue = 0; /* Number of clock cycles in low logic state in one period */
uint32_t sum = 0; /* Number of clock cycles in one period */
uint32_t timerCompare;
if ((duty > 99))
{
duty = 99;
}
if (duty == 0)
{
duty = 1;
}
/* Calculate timer lower and upper values of TIMCMP */
/* Calculate the nearest integer value for sum, using formula round(x) = (2 * floor(x) + 1) / 2 */
/* sum = DEMO_FLEXIO_CLOCK_FREQUENCY / freq_H */
sum = (DEMO_FLEXIO_CLOCK_FREQUENCY * 2 / freq_Hz + 1) / 2;
/* Calculate the nearest integer value for lowerValue, the high period of the pwm output */
/* lowerValue = sum * duty / 100 */
lowerValue = (sum * duty / 50 + 1) / 2;
/* Calculate upper value, the low period of the pwm output */
upperValue = sum - lowerValue;
timerCompare = ((upperValue - 1) << 8U) | (lowerValue - 1);
((FLEXIO_Type *)_lcd_pin_properties[0].bk_pwm.base)->TIMCMP[_lcd_pin_properties[0].bk_pwm.timer_ch] = FLEXIO_TIMCMP_CMP(timerCompare);
}
#pragma diag_default=Pe177 //============================================================================= static void flexio_pwm_configure(void) { flexio_config_t fxioUserConfig; /* Clock setting for Flexio */ CLOCK_SetMux(kCLOCK_Flexio2Mux, FLEXIO_CLOCK_SELECT); CLOCK_SetDiv(kCLOCK_Flexio2PreDiv, FLEXIO_CLOCK_PRE_DIVIDER); CLOCK_SetDiv(kCLOCK_Flexio2Div, FLEXIO_CLOCK_DIVIDER);
/* Init flexio, use default configure
* Disable doze and fast access mode
* Enable in debug mode
*/
FLEXIO_GetDefaultConfig(&fxioUserConfig);
FLEXIO_Init(DEMO_FLEXIO_BASEADDR, &fxioUserConfig);
flexio_pwm_init(DEMO_FLEXIO_FREQUENCY, 0);
flexio_pwm_start();
//============================================================================
//IOMUXC_GPIO_B0_04_FLEXIO2_FLEXIO04
//==================================================================== } #endif
#if REDESIGN_DV1_SNAP_ON //==================================================================== //lcd pwm backlight pin #include "fsl_flexio.h" //==================================== /*******************************************************************************
- Definitions *****************************************************************************/ #define DEMO_FLEXIO_BASEADDR FLEXIO2 //#define DEMO_FLEXIO_OUTPUTPIN (5U) / Select FXIO2_D5 as PWM output / #define DEMO_FLEXIO_OUTPUTPIN (4U) / Select FXIO2_D4 as PWM output / #define DEMO_FLEXIO_TIMER_CH (0U) / Flexio timer0 used */
/* Select USB1 PLL (480 MHz) as flexio clock source /
#define FLEXIO_CLOCK_SELECT (3U)
/ Clock pre divider for flexio clock source /
#define FLEXIO_CLOCK_PRE_DIVIDER (4U)
/ Clock divider for flexio clock source /
#define FLEXIO_CLOCK_DIVIDER (7U)
#define DEMO_FLEXIO_CLOCK_FREQUENCY
(CLOCK_GetFreq(kCLOCK_Usb1PllClk) / (FLEXIO_CLOCK_PRE_DIVIDER + 1U) / (FLEXIO_CLOCK_DIVIDER + 1U))
/ FLEXIO output PWM frequency */
//#define DEMO_FLEXIO_FREQUENCY (48000U)
// #define DEMO_FLEXIO_FREQUENCY (125000U)
#define FLEXIO_MAX_FREQUENCY (DEMO_FLEXIO_CLOCK_FREQUENCY / 2U)
#define FLEXIO_MIN_FREQUENCY (DEMO_FLEXIO_CLOCK_FREQUENCY / 256U)
/*******************************************************************************
- Code ******************************************************************************/ uint8_t xduty=50;
void flexio_pwm_init(uint32_t freq_Hz, uint32_t duty) { assert((freq_Hz < FLEXIO_MAX_FREQUENCY) && (freq_Hz > FLEXIO_MIN_FREQUENCY));
uint32_t lowerValue = 0; /* Number of clock cycles in high logic state in one period */
uint32_t upperValue = 0; /* Number of clock cycles in low logic state in one period */
uint32_t sum = 0; /* Number of clock cycles in one period */
flexio_timer_config_t fxioTimerConfig;
/* Check parameter */
//if ((duty > 99) || (duty == 0))
if ((duty > 99))
{
duty = 99;
}
if (duty == 0)
{
duty = 1;
}
/* Configure the timer DEMO_FLEXIO_TIMER_CH for generating PWM */
fxioTimerConfig.triggerSelect = FLEXIO_TIMER_TRIGGER_SEL_SHIFTnSTAT(0U);
fxioTimerConfig.triggerSource = kFLEXIO_TimerTriggerSourceInternal;
fxioTimerConfig.triggerPolarity = kFLEXIO_TimerTriggerPolarityActiveLow;
fxioTimerConfig.pinConfig = kFLEXIO_PinConfigOutput;
fxioTimerConfig.pinPolarity = kFLEXIO_PinActiveHigh;
// fxioTimerConfig.pinSelect = DEMO_FLEXIO_OUTPUTPIN; /* Set pwm output / fxioTimerConfig.pinSelect = _lcd_pin_properties[0].bkpin.pin;//DEMO_FLEXIO_OUTPUTPIN; / Set pwm output */ fxioTimerConfig.timerMode = kFLEXIO_TimerModeDisabled; fxioTimerConfig.timerOutput = kFLEXIO_TimerOutputOneNotAffectedByReset; fxioTimerConfig.timerDecrement = kFLEXIO_TimerDecSrcOnFlexIOClockShiftTimerOutput; fxioTimerConfig.timerDisable = kFLEXIO_TimerDisableNever; fxioTimerConfig.timerEnable = kFLEXIO_TimerEnabledAlways; fxioTimerConfig.timerReset = kFLEXIO_TimerResetNever; fxioTimerConfig.timerStart = kFLEXIO_TimerStartBitDisabled; fxioTimerConfig.timerStop = kFLEXIO_TimerStopBitDisabled;
/* Calculate timer lower and upper values of TIMCMP */
/* Calculate the nearest integer value for sum, using formula round(x) = (2 * floor(x) + 1) / 2 */
/* sum = DEMO_FLEXIO_CLOCK_FREQUENCY / freq_H */
sum = (DEMO_FLEXIO_CLOCK_FREQUENCY * 2 / freq_Hz + 1) / 2;
/* Calculate the nearest integer value for lowerValue, the high period of the pwm output */
/* lowerValue = sum * duty / 100 */
lowerValue = (sum * duty / 50 + 1) / 2;
/* Calculate upper value, the low period of the pwm output */
upperValue = sum - lowerValue;
fxioTimerConfig.timerCompare = ((upperValue - 1) << 8U) | (lowerValue - 1);
// FLEXIO_SetTimerConfig(DEMO_FLEXIO_BASEADDR, DEMO_FLEXIO_TIMER_CH, &fxioTimerConfig); FLEXIO_SetTimerConfig((FLEXIO_Type *)_lcd_pin_properties[0].bk_pwm.base, _lcd_pin_properties[0].bk_pwm.timer_ch, &fxioTimerConfig); }
void flexio_pwm_start(void) { /* Set Timer mode to kFLEXIO_TimerModeDual8BitPWM to start timer */ // DEMO_FLEXIO_BASEADDR->TIMCTL[DEMO_FLEXIO_TIMER_CH] |= FLEXIO_TIMCTL_TIMOD(kFLEXIO_TimerModeDual8BitPWM); ((FLEXIO_Type *)_lcd_pin_properties[0].bk_pwm.base)->TIMCTL[_lcd_pin_properties[0].bk_pwm.timer_ch] |= FLEXIO_TIMCTL_TIMOD(kFLEXIO_TimerModeDual8BitPWM); }
#pragma diag_suppress=Pe177 static void flexio_pwm_stop(void) { /* Set Timer mode to kFLEXIO_TimerModeDisabled to stop timer */ // DEMO_FLEXIO_BASEADDR->TIMCTL[DEMO_FLEXIO_TIMER_CH] |= FLEXIO_TIMCTL_TIMOD(kFLEXIO_TimerModeDisabled); ((FLEXIO_Type *)_lcd_pin_properties[0].bk_pwm.base)->TIMCTL[_lcd_pin_properties[0].bk_pwm.timer_ch] |= FLEXIO_TIMCTL_TIMOD(kFLEXIO_TimerModeDisabled); }
static void flexio_pwm_duty_change(uint32_t freq_Hz,uint32_t duty) { assert((freq_Hz < FLEXIO_MAX_FREQUENCY) && (freq_Hz > FLEXIO_MIN_FREQUENCY));
uint32_t lowerValue = 0; /* Number of clock cycles in high logic state in one period */
uint32_t upperValue = 0; /* Number of clock cycles in low logic state in one period */
uint32_t sum = 0; /* Number of clock cycles in one period */
uint32_t timerCompare;
if ((duty > 99))
{
duty = 99;
}
if (duty == 0)
{
duty = 1;
}
/* Calculate timer lower and upper values of TIMCMP */
/* Calculate the nearest integer value for sum, using formula round(x) = (2 * floor(x) + 1) / 2 */
/* sum = DEMO_FLEXIO_CLOCK_FREQUENCY / freq_H */
sum = (DEMO_FLEXIO_CLOCK_FREQUENCY * 2 / freq_Hz + 1) / 2;
/* Calculate the nearest integer value for lowerValue, the high period of the pwm output */
/* lowerValue = sum * duty / 100 */
lowerValue = (sum * duty / 50 + 1) / 2;
/* Calculate upper value, the low period of the pwm output */
upperValue = sum - lowerValue;
timerCompare = ((upperValue - 1) << 8U) | (lowerValue - 1);
((FLEXIO_Type *)_lcd_pin_properties[0].bk_pwm.base)->TIMCMP[_lcd_pin_properties[0].bk_pwm.timer_ch] = FLEXIO_TIMCMP_CMP(timerCompare);
}
#pragma diag_default=Pe177 //============================================================================= static void flexio_pwm_configure(void) { #if 0 flexio_config_t fxioUserConfig; /* Clock setting for Flexio */ CLOCK_SetMux(kCLOCK_Flexio2Mux, FLEXIO_CLOCK_SELECT); CLOCK_SetDiv(kCLOCK_Flexio2PreDiv, FLEXIO_CLOCK_PRE_DIVIDER); CLOCK_SetDiv(kCLOCK_Flexio2Div, FLEXIO_CLOCK_DIVIDER);
/* Init flexio, use default configure
* Disable doze and fast access mode
* Enable in debug mode
*/
FLEXIO_GetDefaultConfig(&fxioUserConfig);
FLEXIO_Init(DEMO_FLEXIO_BASEADDR, &fxioUserConfig);
#endif flexio_pwm_init(DEMO_FLEXIO_FREQUENCY, 0); flexio_pwm_start();
//============================================================================
//IOMUXC_GPIO_B0_04_FLEXIO2_FLEXIO04
//==================================================================== } #endif
//======================================================== void clealddram() { int i,j; for(i=0Xb0;i<0Xb9;i++) { write_com(i); write_com(0x10); write_com(0x00); for(j=0;j<128;j++) { write_data(0x00); } } } //======================================================== void font1() { int i,j; //for(i=0Xb0;i<0Xb8;i++) for(i=0X00;i<0X08;i++) { write_com(i); write_com(0x10); write_com(0x00); for(j=0;j<64;j++) { write_data(0X55); } } }
void display_test(uint8_t DAT1, uint8_t DAT2) { uint16_t i,j;
for(j=0;j<15;j++)
{
write_com(0xb1);//set page address D0~D7,icon D0
write_data(0x00+j);
write_com(0x8a);//set start line
write_data(0x00);
write_com(0x13);//set column Address
write_data(0x00);
write_data(0x27);
write_com(0x1d) ; //Write Data
for(i=0;i<141;i++)
{
write_data(DAT1);
write_data(DAT2);
}
}
}
void display_mono(const uint8_t *ptr) { uint16_t i,j,l=0;
for(j=0;j<15;j++)
{
write_com(0xb1);//set page address D0~D7,icon D0
write_data(0x00+j);
write_com(0x8a);//set start line
write_data(0x00);
write_com(0x13);//set column Address
write_data(0x00);
write_data(0x27);
write_com(0x1d) ; //Write Data
for(i=0;i<282;i++)
{
write_data(ptr[l++]);
}
}
}
void display_from_col(uint8_t dat) { uint16_t i=0,j=0;
//for(j=0;j<15;j++)
{
write_com(0xb1);//set page address D0~D7,icon D0
write_data(0x00+j);
write_com(0x8a);//set start line
write_data(0x00);
write_com(0x13);//set column Address
write_data(0x01);
write_data(0x27 + 24);//0x18
write_com(0x1d) ; //Write Data
for(i=0;i<282;i++)
{
write_data(dat);
}
}
}
void fill_screen(uint8_t dat) { uint16_t i,j;
for(j=0;j<15;j++)
{
write_com(0xb1);//set page address D0~D7,icon D0
write_data(0x00+j);
write_com(0x8a);//set start line
write_data(0x00);
write_com(0x13);//set column Address
#if DV1_SNAP_ON write_data(0x00); write_data(0x27);
write_com(0x1d) ; //Write Data
for(i=0;i<282;i++)
{
write_data(dat);
}
#endif
#if DV2_SNAP_ON
//GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 1U);
uint8_t b1[2] = {0x00, 0x27};
write_data_dma(b1, 2);
write_com(0x1d) ; //Write Data
//GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 1U);
uint8_t b2[282] = {0};
for(i=0;i<282;i++)
{
b2[i] = dat;
}
write_data_dma(b2, 282);
#endif
#if REDESIGN_DV1_SNAP_ON
//GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 1U);
uint8_t b1[2] = {0x00, 0x27};
write_data_dma(b1, 2);
write_com(0x1d) ; //Write Data
//GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 1U);
uint8_t b2[282] = {0};
for(i=0;i<282;i++)
{
b2[i] = dat;
}
write_data_dma(b2, 282);
#endif } }
void display_page(uint8_t page,uint8_t dat) {
uint16_t i=0;
write_com(0xb1);//set page address D0~D7,icon D0
write_data(0x00+page);
write_com(0x8a);//set start line
write_data(0x00);
write_com(0x13);//set column Address
write_data(0x00);
write_data(0x27);
write_com(0x1d) ; //Write Data
for(i=0;i<282;i++)
{
write_data(dat);
}
}
void display_pxy(uint8_t page,uint8_t sl,uint8_t dat) {
uint16_t i=0;
write_com(0xb1);//set page address D0~D7,icon D0
write_data(0x00+page);
write_com(0x8a);//set start line
write_data(0x00+sl);
write_com(0x13);//set column Address
write_data(0x00);
write_data(0x27);
write_com(0x1d) ; //Write Data
for(i=0;i<282;i++)
{
write_data(dat);
}
}
void LCD_chipset_init(void) { RES(1); sdelay(50000);//delay(20);//delay(2); RES(0); sdelay(50000);//delay(20);//delay(2);delay(2); RES(1); sdelay(50000);//delay(20);//delay(20);
//=========================================================================== #if 0 write_com(0xa2); sdelay(100);//delay(20); //1/9 Bias write_com(0xa6); sdelay(100);//delay(20); // write_com(0xa0); sdelay(100);//delay(20); //ADC set (SEG) write_com(0xc8); sdelay(100);//delay(20); //COM reves
write_com(0x24); sdelay(100);//delay(20);
write_com(0x81); sdelay(100);//delay(20); //Electronic Volume Mode Set
write_com(0x25); sdelay(100);//delay(20);
write_com(0x2c); sdelay(100);//delay(20);
sdelay(20);
write_com(0x2e);
sdelay(20);
write_com(0x2f); //The Power Control Set
sdelay(20);
write_com(0xaf); //Lcd Disply ON
#endif //==========================================================================
//============================================================================== #if 0
write_com(0xa3);//delay(10);//write_com(XCMD_SET_BIAS_7);
write_com(0xa7);////////////////////////////////////// write_com(0xa0);//delay(10);//write_com(XCMD_SET_ADC_NORMAL);////////////////////////// write_com(0xc0);//delay(10);//write_com(XCMD_SET_COM_NORMAL);///////////////////////////
//write_com(0x40);//write_com(XCMD_SET_DISP_START_LINE);
//write_com(0x28 | 0x1);//write_com(XCMD_SET_POWER_CONTROL | 0x4); //write_com(0x28 | 0x3);//write_com(XCMD_SET_POWER_CONTROL | 0x4);
write_com(0x28 | 0x7);//delay(10);//write_com(XCMD_SET_POWER_CONTROL | 0x4);/////////////////////////////
// write_com(0x28 | 0x4);//write_com(XCMD_SET_POWER_CONTROL | 0x4); //delay(20);//LV_DRV_DELAY_MS(50);
//write_com(0x28 | 0x6);//write_com(XCMD_SET_POWER_CONTROL | 0x6); //delay(20);//LV_DRV_DELAY_MS(50);
//write_com(0x28 | 0x7);//write_com(XCMD_SET_POWER_CONTROL | 0x7); //delay(10);//LV_DRV_DELAY_MS(10);
write_com(0x20 | 0x6); //delay(10);//write_com(XCMD_SET_RESISTOR_RATIO | 0x6); // Defaulted to 0x26 (but could also be between 0x20-0x27 based on display's specs)
write_com(0xaf);//delay(10);//write_com(XCMD_DISPLAY_ON); //write_com(XCMD_DISPLAY_OFF); write_com(0xa4);//delay(10);//write_com(XCMD_SET_ALLPTS_NORMAL);/////////////////////////////////
/Set brightness/ write_com(XCMD_SET_VOLUME_FIRST);//delay(10);/////////////////////////////////////// //write_com(XCMD_SET_VOLUME_SECOND | (0x18 & 0x3f)); write_com(XCMD_SET_VOLUME_SECOND);//delay(10);//////////////////////////////////////////////
//LV_DRV_DISP_SPI_CS(1);
//memset(lcd_fb, 0x00, sizeof(lcd_fb));
#endif //==============================================================================
//======================================================== #if 0//ST75320
#define LDELAY 50000 write_com(0xAE);// Display OFF
write_com(0xEA);// Power Discharge Control write_data(0x00);// Discharge OFF
write_com(0xA8);// Sleep-Out
write_com(0xAB); //OSC ON
write_com(0x69); //Temperature Detection ON
write_com(0x4E); //TC write_data(0x33); //MT1,MT0 write_data(0x33); //MT3,MT2 write_data(0x33); //MT5,MT4 write_data(0x33); //MT7,MT6 write_data(0x22); //MT9,MT8 write_data(0x00); //MTB,MTA write_data(0x00); //MTD,MTC write_data(0x64); //MTF,MTE
write_com(0x39); //TC Flag write_data(0xFF); //Positive TC write_data(0x3F);
write_com(0x2B); //Frame Rate Level write_data(0x01); //DBL=1
write_com(0x5F); //Operation Clock Frequency write_data(0x00);//DA write_data(0x00);//00
write_com(0xEC); //Frequency TC
write_data(0x1F); //TA[6:0]=00h7Fh
write_data(0x66); //TB[6:0]=00h7Fh
write_data(0x66); //TC[6:0]=00h~7Fh
write_com(0xED); //Temperature Hysteresis Value
//write_data(0x02); //THV[5:0]=00h3Fh
//write_data(0x02); //THF[3:0]=00h0Fh
uint8_t a[2] = {0x02, 0x02};
write_data_dma(a, 2);
write_com(0xA7);// Display Inverse ON
write_com(0xA4);// Disable Display All Pixel ON
write_com(0xC4);// COM Output Status write_data(0x03);// Interlace mode, MY=0 COM239-COM0
write_com(0xA1);// Column Address Direction: MX=1 COL319-COL0
write_com(0x6D);// Display Area //write_data(0x03);// Duty = 1/64 duty //write_data(0x00);// Start Group = 1
uint8_t c[2] = {0x03, 0x00};
write_data_dma(c, 2);
write_com(0x84);// Display Data Input Direction: Column
write_com(0x36);// Set N-Line write_data(0x08);// N-Line=(8+1)x4=36 write_com(0xE4);// N-Line OFF
write_com(0xE7);// LCD Drive Method write_data(0x19);// NLFR=1
write_com(0x81);// Set EV=0C8H write_data(0xC8);// VOP=18V write_data(0x00);
write_com(0xA2);// BIAS write_data(0x06);
write_com(0x25);// Power Control write_data(0x40);// VOUT ON sdelay(LDELAY);//delayms(100);
write_com(0x25);// Power Control write_data(0x70);// VOUT, AVDD, V3 ON sdelay(LDELAY);//delayms(100);
write_com(0x25);// Power Control write_data(0x78);// VOUT, AVDD, V3 & VPF ON sdelay(LDELAY);//delayms(100);
write_com(0x25);// Power Control write_data(0x7C);// VOUT, AVDD, V3, VPF & MV3 ON sdelay(LDELAY);//delayms(100);
write_com(0x25);// Power Control write_data(0x7E);// VOUT, AVDD, V3, VPF, MV3 & NAVDD ON sdelay(LDELAY);//delayms(100);
write_com(0x25);// Power Control write_data(0x7F);// VOUT, AVDD, V3, VPF, MV3, NAVDD & VNF ON sdelay(LDELAY);//delayms(100);
write_com(0xAF);// Display ON #endif
////////////////////////////// #define LDELAY 50000
uint8_t a1[2] = {0xAE, 0xEA};// Display OFF write_com_dma(a1, 2);// Sleep-Out
write_data(0x00);// Discharge OFF
uint8_t a2[3] = {0xA8, 0xAB, 0x69}; write_com_dma(a2, 3);// Sleep-Out
write_com(0x4E); //TC
uint8_t a3[8] = {0x33, 0x33, 0x33, 0x33, 0x22, 0x00, 0x00, 0x64}; write_data_dma(a3,8); //MT1,MT0
write_com(0x39); //TC Flag
uint8_t a4[2] = {0xFF, 0x3F}; write_data_dma(a4, 2); //Positive TC
write_com(0x2B); //Frame Rate Level write_data(0x01); //DBL=1
write_com(0x5F); //Operation Clock Frequency
uint8_t a5[2] = {0x00, 0x00}; write_data_dma(a5, 2);//DA
write_com(0xEC); //Frequency TC
uint8_t a6[3] = {0x1F, 0x66, 0x66}; write_data_dma(a6, 3); //TA[6:0]=00h~7Fh
write_com(0xED); //Temperature Hysteresis Value
uint8_t a7[2] = {0x02, 0x02};
write_data_dma(a7, 2);
uint8_t a8[3] = {0xA7, 0xA4, 0xC4}; write_com_dma(a8, 3);// Display Inverse ON
write_data(0x03);// Interlace mode, MY=0 COM239-COM0
uint8_t a9[2] = {0xA1, 0x6D}; write_com_dma(a9, 2);// Column Address Direction: MX=1 COL319-COL0
uint8_t a10[2] = {0x03, 0x00};
write_data_dma(a10, 2);
uint8_t a11[2] = {0x84, 0x36}; write_com_dma(a11, 2);// Display Data Input Direction: Column
write_data(0x08);// N-Line=(8+1)x4=36
uint8_t a12[2] = {0xE4, 0xE7}; write_com_dma(a12, 2);// N-Line OFF
write_data(0x19);// NLFR=1
write_com(0x81);// Set EV=0C8H
uint8_t a13[2] = {0xC8, 0x00}; write_data_dma(a13, 2);// VOP=18V
write_com(0xA2);// BIAS write_data(0x06);
write_com(0x25);// Power Control write_data(0x40);// VOUT ON sdelay(LDELAY);//delayms(100);
write_com(0x25);// Power Control write_data(0x70);// VOUT, AVDD, V3 ON sdelay(LDELAY);//delayms(100);
write_com(0x25);// Power Control write_data(0x78);// VOUT, AVDD, V3 & VPF ON sdelay(LDELAY);//delayms(100);
write_com(0x25);// Power Control write_data(0x7C);// VOUT, AVDD, V3, VPF & MV3 ON sdelay(LDELAY);//delayms(100);
write_com(0x25);// Power Control write_data(0x7E);// VOUT, AVDD, V3, VPF, MV3 & NAVDD ON sdelay(LDELAY);//delayms(100);
write_com(0x25);// Power Control write_data(0x7F);// VOUT, AVDD, V3, VPF, MV3, NAVDD & VNF ON sdelay(LDELAY);//delayms(100);
//write_data(0xAF);// Display ON //////////////////////////////
while(0) {
//display_test(0xFF, 0xFF);
//sdelay(50000);//delayms(2000);
fill_screen(0x00);
sdelay(500000);
fill_screen(0xFF);
sdelay(500000);
#if 0 display_test(0x00, 0x00); sdelay(50000);//delayms(2000);
display_test(0x55, 0x55);
sdelay(50000);//delayms(2000);
display_test(0xFF, 0x00);
sdelay(50000);//delayms(2000);
display_test(0x55, 0xAA);
sdelay(50000);//delayms(2000);
//display_mono(test_pic);
sdelay(50000);//delayms(2000);
//display_mono(casil);
sdelay(50000);//delayms(2000);
#endif
//display_mono(test_pic);
//sdelay(50000);
#if 0 display_page(0, ttdat); sdelay(500000);
display_page(1, ttdat);
sdelay(500000);
display_page(2, ttdat);
sdelay(500000);
display_page(3, ttdat);
sdelay(500000);
display_page(4, ttdat);
sdelay(500000);
display_page(5, ttdat);
sdelay(500000);
display_page(6, ttdat);
sdelay(500000);
display_page(7, ttdat);
sdelay(500000);
display_page(8, ttdat);
sdelay(500000);
display_page(9, ttdat);
sdelay(500000);
display_page(10, ttdat);
sdelay(500000);
display_page(11, ttdat);
sdelay(500000);
display_page(12, ttdat);
sdelay(500000);
display_page(13, ttdat);
sdelay(500000);
display_page(14, ttdat);
sdelay(500000);
if(ttdat == 0xff)
{
ttdat =0x00;
}
else if(ttdat == 0x00)
{
ttdat = 0xff;
}
#endif
//display_from_col(0xff);
//sdelay(500000);
//fill_screen(0x00);
//sdelay(500000);
}
}
void init_LCD(void) { _LCD_configureGpioPins();
//==========================================================================
//SPI mode
//==========================================================================
#if 0 lpspi_master_config_t masterConfig; uint32_t srcClock_Hz;
/*Set clock source for LPSPI*/
CLOCK_SetMux(kCLOCK_LpspiMux, EXAMPLE_LPSPI_CLOCK_SOURCE_SELECT);
CLOCK_SetDiv(kCLOCK_LpspiDiv, EXAMPLE_LPSPI_CLOCK_SOURCE_DIVIDER);
uint32_t spi_baud = cf_spi_get_baudrate(1);
LPSPI_Type * spi_base = (LPSPI_Type *)cf_spi_get_base(1);
/*Master config*/
masterConfig.baudRate = TRANSFER_BAUDRATE;
masterConfig.bitsPerFrame = 8;
masterConfig.cpol = kLPSPI_ClockPolarityActiveHigh;
masterConfig.cpha = kLPSPI_ClockPhaseSecondEdge;//kLPSPI_ClockPhaseFirstEdge;
//masterConfig.cpha = kLPSPI_ClockPhaseFirstEdge;//kLPSPI_ClockPhaseFirstEdge;
masterConfig.direction = kLPSPI_MsbFirst;
masterConfig.pcsToSckDelayInNanoSec = 1000000000 / masterConfig.baudRate;
masterConfig.lastSckToPcsDelayInNanoSec = 1000000000 / masterConfig.baudRate;
masterConfig.betweenTransferDelayInNanoSec = 1000000000 / masterConfig.baudRate;
masterConfig.whichPcs = EXAMPLE_LPSPI_MASTER_PCS_FOR_INIT;
masterConfig.pcsActiveHighOrLow = kLPSPI_PcsActiveLow;
masterConfig.pinCfg = kLPSPI_SdiInSdoOut;
masterConfig.dataOutConfig = kLpspiDataOutRetained;
srcClock_Hz = LPSPI_MASTER_CLK_FREQ;
LPSPI_MasterInit(spi_base, &masterConfig, srcClock_Hz);//EXAMPLE_LPSPI_MASTER_BASEADDR
#endif
#if DV1_SNAP_ON
gpio_pin_config_t led_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode};
GPIO_PinInit(GPIO1, 16U, &led_config);//rst
//GPIO_PinInit(GPIO1, 16U, &led_config);//A0
gpio_pin_config_t bk_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode};//LCD BACKLIGHT OFF
GPIO_PinInit(GPIO1, 3U, &bk_config);//lcd_backlight
GPIO_PinWrite(GPIO1, 3U, 1U); //open lcd_backlight
#endif
#if DV2_SNAP_ON gpio_pin_config_t led_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode}; GPIO_PinInit((GPIO_Type *)_lcd_pin_properties[0].rstpin.port, _lcd_pin_properties[0].rstpin.pin, &led_config);//rst GPIO_PinInit((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, &led_config);//A0 gpio_pin_config_t bk_config = {kGPIO_DigitalOutput, 1, kGPIO_NoIntmode}; GPIO_PinInit((GPIO_Type *)_lcd_pin_properties[0].bkpin.port, _lcd_pin_properties[0].bkpin.pin, &bk_config);//lcd_backlight
flexio_pwm_configure();
#if 0 flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 5); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 10); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 15); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 20); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 25); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 30); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 35); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 40); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 100); sdelay(1000*1000); #endif #endif
#if REDESIGN_DV1_SNAP_ON gpio_pin_config_t led_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode}; GPIO_PinInit((GPIO_Type *)_lcd_pin_properties[0].rstpin.port, _lcd_pin_properties[0].rstpin.pin, &led_config);//rst GPIO_PinInit((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, &led_config);//A0 gpio_pin_config_t bk_config = {kGPIO_DigitalOutput, 1, kGPIO_NoIntmode}; GPIO_PinInit((GPIO_Type *)_lcd_pin_properties[0].bkpin.port, _lcd_pin_properties[0].bkpin.pin, &bk_config);//lcd_backlight
flexio_pwm_configure();
#if 0 flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 5); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 10); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 15); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 20); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 25); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 30); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 35); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 40); sdelay(10001000); flexio_pwm_duty_change(DEMO_FLEXIO_FREQUENCY, 100); sdelay(1000*1000); #endif #endif
//============================================================================
//chipset lcd
//============================================================================
LCD_chipset_init();
//display_mono(test_pic);
//display_test(0x00, 0x00);
//fill_screen(0xff);
#if 0 for(int iii=0; iii<5;iii++) { fill_screen(0x00); sdelay(10001000); display_mono(test_pic); sdelay(10001000); } #endif #if 0 sdelay(50); clealddram(); write_com(0xaf); //Lcd Disply ON sdelay(50); font1(); while(1) { sdelay(1000); font1();
}
#endif
//==============================================================================
}
/**
-
Initialize the ST7565 */ void st7565_init(void) { LV_DRV_DISP_RST(1); LV_DRV_DELAY_MS(10); LV_DRV_DISP_RST(0); LV_DRV_DELAY_MS(10); LV_DRV_DISP_RST(1); LV_DRV_DELAY_MS(10);
LV_DRV_DISP_SPI_CS(0);
st7565_command(CMD_SET_BIAS_7); st7565_command(CMD_SET_ADC_NORMAL); st7565_command(CMD_SET_COM_NORMAL); st7565_command(CMD_SET_DISP_START_LINE); st7565_command(CMD_SET_POWER_CONTROL | 0x4); LV_DRV_DELAY_MS(50);
st7565_command(CMD_SET_POWER_CONTROL | 0x6); LV_DRV_DELAY_MS(50);
st7565_command(CMD_SET_POWER_CONTROL | 0x7); LV_DRV_DELAY_MS(10);
st7565_command(CMD_SET_RESISTOR_RATIO | 0x6); // Defaulted to 0x26 (but could also be between 0x20-0x27 based on display's specs)
st7565_command(CMD_DISPLAY_ON); st7565_command(CMD_SET_ALLPTS_NORMAL);
/Set brightness/ st7565_command(CMD_SET_VOLUME_FIRST); st7565_command(CMD_SET_VOLUME_SECOND | (0x18 & 0x3f));
LV_DRV_DISP_SPI_CS(1);
memset(lcd_fb, 0x00, sizeof(lcd_fb)); }
void st7565_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p) { /Return if the area is out the screen/ if(x2 < 0) return; if(y2 < 0) return; if(x1 > ST7565_HOR_RES - 1) return; if(y1 > ST7565_VER_RES - 1) return;
/*Truncate the area to the screen*/
int32_t act_x1 = x1 < 0 ? 0 : x1;
int32_t act_y1 = y1 < 0 ? 0 : y1;
int32_t act_x2 = x2 > ST7565_HOR_RES - 1 ? ST7565_HOR_RES - 1 : x2;
int32_t act_y2 = y2 > ST7565_VER_RES - 1 ? ST7565_VER_RES - 1 : y2;
int32_t x, y;
/*Set the first row in */
/*Refresh frame buffer*/
for(y = act_y1; y <= act_y2; y++) {
for(x = act_x1; x <= act_x2; x++) {
if(lv_color_to1(*color_p) != 0) {
lcd_fb[x + (y / 8)*ST7565_HOR_RES] &= ~(1 << (7 - (y % 8)));
} else {
lcd_fb[x + (y / 8)*ST7565_HOR_RES] |= (1 << (7 - (y % 8)));
}
color_p ++;
}
color_p += x2 - act_x2; /*Next row*/
}
st7565_sync(act_x1, act_y1, act_x2, act_y2);
//lv_flush_ready();
}
#if 0 void st7565_flush1(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p) { /Return if the area is out the screen/ if(x2 < 0) return; if(y2 < 0) return; if(x1 > ST7565_HOR_RES - 1) return; if(y1 > ST7565_VER_RES - 1) return;
LV_DRV_DISP_SPI_CS(0);
uint8_t row1 = y1>>3;
uint8_t row2 = y2>>3;
uint8_t *buf = (uint8_t*) color_p;
//PRINTF("\r\nx1=%d, y1=%d, x2=%d, y2=%d\r\n",x1,y1,x2,y2);
//__disable_irq();
for(uint8_t row = row1; row <= row2; row++)
{
write_com(0xb1);//set page address D0~D7,icon D0
write_data(0x00+pagemap[row]);
//write_com(0x8a);//set start line
//write_data(0x00);
write_com(0x13);//set column Address
//if(x1+0x27 > 0xff)
if(x1 > 216)
{
//write_data(0x01);
//uint8_t x1_temp = x1 -217;
//write_data(x1_temp);
uint8_t x1_temp[2] = {0x01,x1 -217};
write_data_dma(x1_temp, 2);
}
else
{
//write_data(0x00);
//write_data(0x27 + x1);
uint8_t x2_temp[2] = {0x00,0x27 + x1};
write_data_dma(x2_temp, 2);
}
write_com(0x1d) ; //Write Data
write_data_dma(buf, x2-x1+1);
//GPIO_PinWrite((GPIO_Type *)_lcd_pin_properties[0].A0pin.port, _lcd_pin_properties[0].A0pin.pin, 1U);
for(uint32_t c = x1; c <= x2; c++) {
//st7565_data(*buf);
//write_data_raw(*buf);
buf++;
//st7565_data(0xFF);
//PRINTF("%d\t",lcd_fb[(ST7565_HOR_RES * p) + c]);
}
}
//__enable_irq();
LV_DRV_DISP_SPI_CS(1);
} #else void st7565_flush1(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p) { /Return if the area is out the screen/ if(x2 < 0) return; if(y2 < 0) return; if(x1 > ST7565_HOR_RES - 1) return; if(y1 > ST7565_VER_RES - 1) return;
LV_DRV_DISP_SPI_CS(0);
uint8_t row1 = y1>>3;
uint8_t row2 = y2>>3;
uint8_t *buf = (uint8_t*) color_p;
//PRINTF("\r\nx1=%d, y1=%d, x2=%d, y2=%d\r\n",x1,y1,x2,y2);
for(uint8_t row = row1; row <= row2; row++)
{
write_com_flush(0xb1);//set page address D0~D7,icon D0
write_data_flush(0x00+pagemap[row]);
write_com_flush(0x13);//set column Address
//if(x1+0x27 > 0xff)
if(x1 > 216)
{
uint8_t x1_temp[2] = {0x01,x1 -217};
write_data_dma_flush(x1_temp, 2);
}
else
{
uint8_t x2_temp[2] = {0x00,0x27 + x1};
write_data_dma_flush(x2_temp, 2);
}
write_com_flush(0x1d) ; //Write Data
write_data_dma_flush(buf, x2-x1+1);
for(uint32_t c = x1; c <= x2; c++) {
buf++;
}
}
LV_DRV_DISP_SPI_CS(1);
} #endif
void st7565_rounder_cb(struct _disp_drv_t * disp_drv, lv_area_t *area) { area->y1 = (area->y1 & (~0x7)); area->y2 = (area->y2 & (~0x7)) + 7; }
void st7565_set_px_cb(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa) { /* Write to the buffer as required for the display. * Write only 1-bit for monochrome displays mapped vertically:*/ buf += buf_w * (y >> 3) + x; if (color.full) { (*buf) &= ~(1 << (7-(y % 8))); } else { (*buf) |= (1 << (7-(y % 8))); }
//printf("px_cb buf_w= %d, x=%d, y=%d \n", buf_w, x, y); }
void st7565_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color) { /Return if the area is out the screen/ if(x2 < 0) return; if(y2 < 0) return; if(x1 > ST7565_HOR_RES - 1) return; if(y1 > ST7565_VER_RES - 1) return;
/*Truncate the area to the screen*/
int32_t act_x1 = x1 < 0 ? 0 : x1;
int32_t act_y1 = y1 < 0 ? 0 : y1;
int32_t act_x2 = x2 > ST7565_HOR_RES - 1 ? ST7565_HOR_RES - 1 : x2;
int32_t act_y2 = y2 > ST7565_VER_RES - 1 ? ST7565_VER_RES - 1 : y2;
int32_t x, y;
uint8_t white = lv_color_to1(color);
/*Refresh frame buffer*/
for(y = act_y1; y <= act_y2; y++) {
for(x = act_x1; x <= act_x2; x++) {
if(white != 0) {
lcd_fb[x + (y / 8)*ST7565_HOR_RES] |= (1 << (7 - (y % 8)));
} else {
lcd_fb[x + (y / 8)*ST7565_HOR_RES] &= ~(1 << (7 - (y % 8)));
}
}
}
st7565_sync(act_x1, act_y1, act_x2, act_y2);
}
void st7565_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p) { /Return if the area is out the screen/ if(x2 < 0) return; if(y2 < 0) return; if(x1 > ST7565_HOR_RES - 1) return; if(y1 > ST7565_VER_RES - 1) return;
/*Truncate the area to the screen*/
int32_t act_x1 = x1 < 0 ? 0 : x1;
int32_t act_y1 = y1 < 0 ? 0 : y1;
int32_t act_x2 = x2 > ST7565_HOR_RES - 1 ? ST7565_HOR_RES - 1 : x2;
int32_t act_y2 = y2 > ST7565_VER_RES - 1 ? ST7565_VER_RES - 1 : y2;
int32_t x, y;
/*Set the first row in */
/*Refresh frame buffer*/
for(y = act_y1; y <= act_y2; y++) {
for(x = act_x1; x <= act_x2; x++) {
if(lv_color_to1(*color_p) != 0) {
lcd_fb[x + (y / 8)*ST7565_HOR_RES] &= ~(1 << (7 - (y % 8)));
} else {
lcd_fb[x + (y / 8)*ST7565_HOR_RES] |= (1 << (7 - (y % 8)));
}
color_p ++;
}
color_p += x2 - act_x2; /*Next row*/
}
st7565_sync(act_x1, act_y1, act_x2, act_y2);
} /**********************
-
STATIC FUNCTIONS ********************/ /
-
Flush a specific part of the buffer to the display
-
@param x1 left coordinate of the area to flush
-
@param y1 top coordinate of the area to flush
-
@param x2 right coordinate of the area to flush
-
@param y2 bottom coordinate of the area to flush */ static void st7565_sync(int32_t x1, int32_t y1, int32_t x2, int32_t y2) {
LV_DRV_DISP_SPI_CS(0);
int32_t c, p;
//PRINTF("\r\nx1=%d, y1=%d, x2=%d, y2=%d\r\n",x1,y1,x2,y2); __disable_irq(); for(p = y1 / 8; p <= y2 / 8; p++) {
#if 0 st7565_command(CMD_SET_PAGE | pagemap[p]); st7565_command(CMD_SET_COLUMN_LOWER | (x1 & 0xf)); st7565_command(CMD_SET_COLUMN_UPPER | ((x1 >> 4) & 0xf)); st7565_command(CMD_RMW); #endif
write_com(0xb1);//set page address D0~D7,icon D0
write_data(0x00+pagemap[p]);
//write_com(0x8a);//set start line
//write_data(0x00);
write_com(0x13);//set column Address
#if 1 if(x1+0x27 > 0xff) { write_data(0x01);
uint8_t x1_temp = x1&0xFF;
write_data(x1_temp);
}
else
{
write_data(0x00);
write_data(0x27 + x1);
}
#endif //write_data(0x00); //write_data(0x27);
write_com(0x1d) ; //Write Data
for(c = x1; c <= x2; c++) {
st7565_data(lcd_fb[(ST7565_HOR_RES * p) + c]);
//st7565_data(0xFF);
//PRINTF("%d\t",lcd_fb[(ST7565_HOR_RES * p) + c]);
}
}
__enable_irq();
LV_DRV_DISP_SPI_CS(1);
}
/**
-
Write a command to the ST7565
-
@param cmd the command */ static void st7565_command(uint8_t cmd) { //LV_DRV_DISP_CMD_DATA(ST7565_CMD_MODE); //LV_DRV_DISP_SPI_WR_BYTE(cmd);
write_com(cmd);
}
/**
-
Write data to the ST7565
-
@param data the data */ static void st7565_data(uint8_t data) { //LV_DRV_DISP_CMD_DATA(ST7565_DATA_MODE); //LV_DRV_DISP_SPI_WR_BYTE(data);
write_data(data);
}
#endif