SPI接口1.54寸電子墨水屏E-Ink的STM32程序資料
所有資料51hei提供下載:
E-Ink_1.54.rar
(1.78 MB, 下載次數: 101)
2017-10-18 16:02 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
單片機源程序如下:
- /*******************************************************************************/
- /* Includes ------------------------------------------------------------------*/
- #include "stm32f10x.h"
- #include "Display_EPD_W21_spi.h"
- #include "Display_EPD_W21.h"
- /* Private typedef -----------------------------------------------------------*/
- /* Private define ------------------------------------------------------------*/
- /* Private macro -------------------------------------------------------------*/
- /* Private variables ---------------------------------------------------------*/
- ErrorStatus HSEStartUpStatus;
- /* Private function prototypes -----------------------------------------------*/
- void RCC_Configuration(void);
- void NVIC_Configuration(void);
- void GPIO_Configuration(void);
- const unsigned char logo[] = {
- 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
- 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
- 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
- 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
- };
- const unsigned char LUTDefault_part[31] = {
- 0x32, // command
- /* 0x00,0x00,0x00,0x18,
- 0x18,0x18,0x18,0x00,
- 0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,
- 0x40,0x14,0x34,0x01,
- 0x00,0x00,0x00,0x00,
- 0x00,0x00,
- */
- 0x10 //C221 25C partial update waveform
- ,0x18
- ,0x18
- ,0x08
- ,0x18
- ,0x18
- ,0x08
- ,0x00
- ,0x00
- ,0x00
- ,0x00
- ,0x00
- ,0x00
- ,0x00
- ,0x00
- ,0x00
- ,0x00
- ,0x00
- ,0x00
- ,0x00
- ,0x13
- ,0x14
- ,0x44
- ,0x12
- ,0x00
- ,0x00
- ,0x00
- ,0x00
- ,0x00
- ,0x00
- };
- const unsigned char LUTDefault_full[31] = {
- 0x32, // command
- /* 0x11,0x11,0x10,0x02, // full
- 0x02,0x22,0x22,0x22,
- 0x22,0x22,0x51,0x51,
- 0x55,0x88,0x08,0x08,
- 0x88,0x88,0x00,0x00,
- 0x34,0x23,0x12,0x21,
- 0x24,0x28,0x22,0x21,
- 0xA1,0x01
- */
- 0x02 //C221 25C Full update waveform
- ,0x02
- ,0x01
- ,0x11
- ,0x12
- ,0x12
- ,0x22
- ,0x22
- ,0x66
- ,0x69
- ,0x69
- ,0x59
- ,0x58
- ,0x99
- ,0x99
- ,0x88
- ,0x00
- ,0x00
- ,0x00
- ,0x00
- ,0xF8
- ,0xB4
- ,0x13
- ,0x51
- ,0x35
- ,0x51
- ,0x51
- ,0x19
- ,0x01
- ,0x00
- };
- //unsigned int IC_SWITCH;
- //unsigned char vcom;
- void lcd_chkstatus(void);
- void lut_red(void);
- void lut_bw(void);
- void Ultrachip_red(void);
- void Ultrachip(void);
- void master_uc8154_init(void);
- void Ultrachip_red1(void);
- void Ultrachip1(void);
- void pic_display(void);
- unsigned char EPD_W21_ReadDATA(void);
- void driver_delay_us(unsigned int xus)
- {
- for(;xus>1;xus--);
- }
- void driver_delay_xms(unsigned long xms)
- {
- unsigned long i = 0 , j=0;
- for(j=0;j<xms;j++)
- {
- for(i=0; i<256; i++);
- }
- }
- void parttest()
- {
- unsigned int i,j,k;
- EPD_W21_WirteLUT((unsigned char *)LUTDefault_part);
- EPD_W21_POWERON();
- part_display(0x00,0x18,0xc7,0x00,0x00,0x00); // set ram
- EPD_W21_UpdataDisplay((unsigned char *)logo,200,200);
- EPD_W21_Update1();
- driver_delay_xms(100000);
- part_display(0x00,0x18,0xc7,0x00,0x00,0x00); // set ram
- EPD_W21_UpdataDisplay((unsigned char *)logo,200,200);
- driver_delay_xms(10000);
- for(i=0;i<6;i++)
- {
- k=200-i*32-4;
- j=k-32;
- part_display(0x12,0x12,k%256,k/256,j%256,j/256); // set ram
- EPD_W21_WriteDispRamMono(8, 32, 0x00); // white
- EPD_W21_Update1();
- driver_delay_xms(20000);
- part_display(0x12,0x12,k%256,k/256,j%256,j/256); // set ram
- EPD_W21_WriteDispRamMono(8, 32, 0x00); // white
- driver_delay_xms(10000);
- }
- }
- void EPD_init(void)
- {
- EPD_W21_Init(); // display
- EPD_W21_WirteLUT((unsigned char *)LUTDefault_full);
- EPD_W21_POWERON();
- driver_delay_xms(30000);
- EPD_W21_SetRamPointer(0x00,0xC7,0x00); // set ram
- EPD_W21_WriteDispRam(200, 200, (unsigned char *)second); // white
- EPD_W21_Update();
- driver_delay_xms(300000);
- EPD_W21_SetRamPointer(0x00,0xC7,0x00); // set ram
- EPD_W21_WriteDispRam(200, 200, (unsigned char *)third); // white
- EPD_W21_Update();
- driver_delay_xms(200000);
- EPD_W21_SetRamPointer(0x00,0xC7,0x00); // set ram
- EPD_W21_WriteDispRam(200, 200, (unsigned char *)forth); // white
- EPD_W21_Update();
- driver_delay_xms(200000);
-
- EPD_W21_SetRamPointer(0x00,0xC7,0x00); // set ram
- EPD_W21_WriteDispRam(200, 200, (unsigned char *)five); // white
- EPD_W21_Update();
- driver_delay_xms(200000);
-
- EPD_W21_SetRamPointer(0x00,0xC7,0x00); // set ram
- EPD_W21_WriteDispRam(200, 200, (unsigned char *)logo); // white
- EPD_W21_Update();
- driver_delay_xms(100000);
- EPD_W21_SetRamPointer(0x00,0xC7,0x00); // set ram
- EPD_W21_WriteDispRam(200, 200, (unsigned char *)logo); // white
- EPD_W21_Update();
- driver_delay_xms(100000);
- parttest();
- }
- /*******************************************************************************
- * Function Name : main
- * Description : Main program
- * Input : None
- * Output : None
- * Return : None
- #define NVIC_VectTab_FLASH misc.h
- *******************************************************************************/
- int main(void)
- {
-
- #ifdef DEBUG
- debug();
- #endif
- // 系統時鐘設置
- RCC_Configuration();
- //GPIO參數設置
- GPIO_Configuration();
-
- EPD_init();
- }
- /***********************************************************
- end file
- ***********************************************************/
- /*******************************************************************************
- * Function Name : RCC_Configuration
- * Description : Configures the different system clocks.
- * Input : None
- * Output : None
- * Return : None
- *******************************************************************************/
- void RCC_Configuration(void)
- {
-
- // 復位RCC時鐘配置(用于調試模式)
- RCC_DeInit();
-
- // 使能外部晶振
- RCC_HSEConfig(RCC_HSE_ON);
-
- // 等待外部晶振穩定
- HSEStartUpStatus = RCC_WaitForHSEStartUp();
- if(HSEStartUpStatus == SUCCESS)
- {
- // 設置鎖相環頻率PLLCLK = 8MHz * 9 = 72 MHz
- RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
- }
- else {
- // 使能內部晶振
- RCC_HSICmd(ENABLE);
- // 等待內置振蕩器穩定
- while(RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET);
- // 設置鎖相環頻率PLLCLK = 8MHz/2 * 16 = 64 MHz
- RCC_PLLConfig(RCC_PLLSource_HSI_Div2,RCC_PLLMul_16);
- }
- // 使能FLASH的預取緩沖
- FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
- //設置代碼延時值,FLASH_Latency_2為兩個延時周期
- FLASH_SetLatency(FLASH_Latency_2);
-
- //設置系統總線時鐘
- RCC_HCLKConfig(RCC_SYSCLK_Div1);
- //設置高速設備總線時鐘,RCC_HCLK_Div1為系統時鐘除以1
- RCC_PCLK2Config(RCC_HCLK_Div1);
- //設置低速設備總線時鐘,RCC_HCLK_Div2為系統時鐘除以2
- RCC_PCLK1Config(RCC_HCLK_Div2);
-
- //使能鎖相環倍頻
- RCC_PLLCmd(ENABLE);
-
- // 等待鎖相環倍頻后的頻率穩定
- while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
-
- // 選擇鎖相環時鐘為系統時鐘源
- RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
-
- // 等待設置完成
- while(RCC_GetSYSCLKSource() != 0x08);
-
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA |
- RCC_APB2Periph_USART1|RCC_APB2Periph_AFIO,
- ENABLE);
- }
- /*******************************************************************************
- * 函數名 : GPIO_Configuration
- * 描述 : 設置設置串口所用GPIO引腳的參數
- * 輸入 : None
- * 輸出 : None
- * 返回 : None
- *******************************************************************************/
- void GPIO_Configuration(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2 |GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5; //abcd OE ST LT0輸出
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- }
- /*******************************************************************************
- * Function Name : NVIC_Configuration
- * Description : Configures Vector Table base location.
- * Input : None
- * Output : None
- * Return : None
- *******************************************************************************/
- void NVIC_Configuration(void)
- {
- //NVIC_InitTypeDef NVIC_InitStructure;
- ;
- }
- #ifdef DEBUG
- /*******************************************************************************
- * Function Name : assert_failed
- * Description : Reports the name of the source file and the source line number
- * where the assert_param error has occurred.
- * Input : - file: pointer to the source file name
- * - line: assert_param error line source number
- * Output : None
- * Return : None
- *******************************************************************************/
- void assert_failed(u8* file, u32 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
復制代碼
|