欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 6143|回復: 2
打印 上一主題 下一主題
收起左側(cè)

SPI接口1.54電子墨水屏STM32程序資料

[復制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:240618 發(fā)表于 2017-10-18 16:02 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
SPI接口1.54寸電子墨水屏E-Ink的STM32程序資料

所有資料51hei提供下載:
E-Ink_1.54.rar (1.78 MB, 下載次數(shù): 101)

單片機源程序如下:

  1. /*******************************************************************************/

  2. /* Includes ------------------------------------------------------------------*/
  3. #include "stm32f10x.h"
  4. #include "Display_EPD_W21_spi.h"
  5. #include "Display_EPD_W21.h"

  6. /* Private typedef -----------------------------------------------------------*/
  7. /* Private define ------------------------------------------------------------*/
  8. /* Private macro -------------------------------------------------------------*/
  9. /* Private variables ---------------------------------------------------------*/

  10. ErrorStatus HSEStartUpStatus;


  11. /* Private function prototypes -----------------------------------------------*/
  12. void RCC_Configuration(void);
  13. void NVIC_Configuration(void);
  14. void GPIO_Configuration(void);



  15. const unsigned char logo[] = {
  16. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  17. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,

  18. …………限于本文篇幅 余下代碼請從51黑下載附件…………

  19. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  20. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  21. };

  22. const unsigned char LUTDefault_part[31] = {
  23.         0x32,        // command

  24. /*        0x00,0x00,0x00,0x18,        
  25.         0x18,0x18,0x18,0x00,
  26.         0x00,0x00,0x00,0x00,
  27.         0x00,0x00,0x00,0x00,
  28.         0x00,0x00,0x00,0x00,
  29.         0x40,0x14,0x34,0x01,
  30.         0x00,0x00,0x00,0x00,
  31.         0x00,0x00,
  32. */
  33. 0x10 //C221 25C partial update waveform
  34. ,0x18
  35. ,0x18
  36. ,0x08
  37. ,0x18
  38. ,0x18
  39. ,0x08
  40. ,0x00
  41. ,0x00
  42. ,0x00
  43. ,0x00
  44. ,0x00
  45. ,0x00
  46. ,0x00
  47. ,0x00
  48. ,0x00
  49. ,0x00
  50. ,0x00
  51. ,0x00
  52. ,0x00
  53. ,0x13
  54. ,0x14
  55. ,0x44
  56. ,0x12
  57. ,0x00
  58. ,0x00
  59. ,0x00
  60. ,0x00
  61. ,0x00
  62. ,0x00

  63.         };

  64. const unsigned char LUTDefault_full[31] = {
  65.         0x32,        // command
  66. /*        0x11,0x11,0x10,0x02,        // full
  67.         0x02,0x22,0x22,0x22,
  68.         0x22,0x22,0x51,0x51,
  69.         0x55,0x88,0x08,0x08,
  70.     0x88,0x88,0x00,0x00,
  71.         0x34,0x23,0x12,0x21,
  72.         0x24,0x28,0x22,0x21,
  73.         0xA1,0x01
  74. */
  75. 0x02 //C221 25C Full update waveform
  76. ,0x02
  77. ,0x01
  78. ,0x11
  79. ,0x12
  80. ,0x12
  81. ,0x22
  82. ,0x22
  83. ,0x66
  84. ,0x69
  85. ,0x69
  86. ,0x59
  87. ,0x58
  88. ,0x99
  89. ,0x99
  90. ,0x88
  91. ,0x00
  92. ,0x00
  93. ,0x00
  94. ,0x00
  95. ,0xF8
  96. ,0xB4
  97. ,0x13
  98. ,0x51
  99. ,0x35
  100. ,0x51
  101. ,0x51
  102. ,0x19
  103. ,0x01
  104. ,0x00
  105.         };


  106. //unsigned int IC_SWITCH;
  107. //unsigned char vcom;
  108. void lcd_chkstatus(void);
  109. void lut_red(void);
  110. void lut_bw(void);
  111. void Ultrachip_red(void);
  112. void Ultrachip(void);
  113. void master_uc8154_init(void);
  114. void Ultrachip_red1(void);
  115. void Ultrachip1(void);
  116. void pic_display(void);
  117. unsigned char  EPD_W21_ReadDATA(void);
  118. void driver_delay_us(unsigned int xus)
  119. {
  120.         for(;xus>1;xus--);
  121. }

  122. void driver_delay_xms(unsigned long xms)        
  123. {        
  124.     unsigned long i = 0 , j=0;

  125.     for(j=0;j<xms;j++)
  126.         {
  127.         for(i=0; i<256; i++);
  128.     }
  129. }

  130. void parttest()
  131. {
  132.    unsigned int i,j,k;

  133.    EPD_W21_WirteLUT((unsigned char *)LUTDefault_part);
  134.    EPD_W21_POWERON();

  135.                 part_display(0x00,0x18,0xc7,0x00,0x00,0x00);        // set ram        
  136.                 EPD_W21_UpdataDisplay((unsigned char *)logo,200,200);
  137.                  EPD_W21_Update1();
  138.                 driver_delay_xms(100000);
  139.                 part_display(0x00,0x18,0xc7,0x00,0x00,0x00);        // set ram
  140.                 EPD_W21_UpdataDisplay((unsigned char *)logo,200,200);
  141.                 driver_delay_xms(10000);

  142.                 for(i=0;i<6;i++)
  143.                 {
  144.                     k=200-i*32-4;
  145.                         j=k-32;
  146.                         part_display(0x12,0x12,k%256,k/256,j%256,j/256);        // set ram        
  147.                         EPD_W21_WriteDispRamMono(8, 32, 0x00);        // white
  148.                          EPD_W21_Update1();
  149.                         driver_delay_xms(20000);
  150.                         part_display(0x12,0x12,k%256,k/256,j%256,j/256);        // set ram        
  151.                         EPD_W21_WriteDispRamMono(8, 32, 0x00);        // white
  152.                         driver_delay_xms(10000);        
  153.                 }        
  154. }        

  155. void EPD_init(void)
  156. {               
  157.                 EPD_W21_Init();                        // display
  158.                 EPD_W21_WirteLUT((unsigned char *)LUTDefault_full);
  159.             EPD_W21_POWERON();
  160.         driver_delay_xms(30000);

  161.                 EPD_W21_SetRamPointer(0x00,0xC7,0x00);        // set ram
  162.                 EPD_W21_WriteDispRam(200, 200, (unsigned char *)second);        // white        
  163.                 EPD_W21_Update();        
  164.                 driver_delay_xms(300000);

  165.                 EPD_W21_SetRamPointer(0x00,0xC7,0x00);        // set ram
  166.                 EPD_W21_WriteDispRam(200, 200, (unsigned char *)third);        // white        
  167.                 EPD_W21_Update();        
  168.                 driver_delay_xms(200000);

  169.                 EPD_W21_SetRamPointer(0x00,0xC7,0x00);        // set ram
  170.                 EPD_W21_WriteDispRam(200, 200, (unsigned char *)forth);        // white        
  171.                 EPD_W21_Update();        
  172.                 driver_delay_xms(200000);
  173.         
  174.                         EPD_W21_SetRamPointer(0x00,0xC7,0x00);        // set ram
  175.                 EPD_W21_WriteDispRam(200, 200, (unsigned char *)five);        // white        
  176.                 EPD_W21_Update();        
  177.                 driver_delay_xms(200000);
  178.         
  179.                 EPD_W21_SetRamPointer(0x00,0xC7,0x00);        // set ram
  180.                 EPD_W21_WriteDispRam(200, 200, (unsigned char *)logo);        // white        
  181.                 EPD_W21_Update();        
  182.                 driver_delay_xms(100000);

  183.                 EPD_W21_SetRamPointer(0x00,0xC7,0x00);        // set ram
  184.                 EPD_W21_WriteDispRam(200, 200, (unsigned char *)logo);        // white        
  185.                 EPD_W21_Update();        
  186.                 driver_delay_xms(100000);
  187.                 parttest();

  188. }


  189. /*******************************************************************************
  190. * Function Name  : main
  191. * Description    : Main program
  192. * Input          : None
  193. * Output         : None
  194. * Return         : None
  195. #define NVIC_VectTab_FLASH  misc.h
  196. *******************************************************************************/
  197. int main(void)
  198. {
  199.   

  200. #ifdef DEBUG
  201.   debug();
  202. #endif
  203.   // 系統(tǒng)時鐘設(shè)置
  204.    RCC_Configuration();
  205.   //GPIO參數(shù)設(shè)置
  206.    GPIO_Configuration();
  207.         
  208.    EPD_init();

  209. }


  210. /***********************************************************
  211.                                                 end file
  212. ***********************************************************/

  213. /*******************************************************************************
  214. * Function Name  : RCC_Configuration
  215. * Description    : Configures the different system clocks.
  216. * Input          : None
  217. * Output         : None
  218. * Return         : None
  219. *******************************************************************************/
  220. void RCC_Configuration(void)
  221. {

  222.   // 復位RCC時鐘配置(用于調(diào)試模式)
  223.   RCC_DeInit();

  224.   // 使能外部晶振
  225.   RCC_HSEConfig(RCC_HSE_ON);
  226.   
  227.   // 等待外部晶振穩(wěn)定
  228.   HSEStartUpStatus = RCC_WaitForHSEStartUp();
  229.   if(HSEStartUpStatus == SUCCESS)
  230.   {
  231.     // 設(shè)置鎖相環(huán)頻率PLLCLK = 8MHz * 9 = 72 MHz
  232.     RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
  233.   }
  234.   else {
  235.     // 使能內(nèi)部晶振
  236.     RCC_HSICmd(ENABLE);
  237.     // 等待內(nèi)置振蕩器穩(wěn)定
  238.     while(RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET);

  239.     // 設(shè)置鎖相環(huán)頻率PLLCLK = 8MHz/2 * 16 = 64 MHz
  240.     RCC_PLLConfig(RCC_PLLSource_HSI_Div2,RCC_PLLMul_16);
  241.   }

  242.     // 使能FLASH的預(yù)取緩沖
  243.   FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

  244.   //設(shè)置代碼延時值,FLASH_Latency_2為兩個延時周期
  245.   FLASH_SetLatency(FLASH_Latency_2);
  246.         
  247.   //設(shè)置系統(tǒng)總線時鐘
  248.   RCC_HCLKConfig(RCC_SYSCLK_Div1);

  249.   //設(shè)置高速設(shè)備總線時鐘,RCC_HCLK_Div1為系統(tǒng)時鐘除以1
  250.   RCC_PCLK2Config(RCC_HCLK_Div1);

  251.   //設(shè)置低速設(shè)備總線時鐘,RCC_HCLK_Div2為系統(tǒng)時鐘除以2
  252.   RCC_PCLK1Config(RCC_HCLK_Div2);
  253.   
  254.   //使能鎖相環(huán)倍頻
  255.   RCC_PLLCmd(ENABLE);
  256.   
  257.   // 等待鎖相環(huán)倍頻后的頻率穩(wěn)定
  258.   while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
  259.   
  260.   // 選擇鎖相環(huán)時鐘為系統(tǒng)時鐘源
  261.   RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
  262.   
  263.   // 等待設(shè)置完成
  264.   while(RCC_GetSYSCLKSource() != 0x08);
  265.    
  266.   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA |
  267.             RCC_APB2Periph_USART1|RCC_APB2Periph_AFIO,
  268.             ENABLE);

  269. }

  270. /*******************************************************************************
  271. * 函數(shù)名   : GPIO_Configuration
  272. * 描述         : 設(shè)置設(shè)置串口所用GPIO引腳的參數(shù)
  273. * 輸入         : None
  274. * 輸出         : None
  275. * 返回         : None
  276. *******************************************************************************/
  277. void GPIO_Configuration(void)
  278. {
  279.   GPIO_InitTypeDef GPIO_InitStructure;

  280.   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
  281.   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2 |GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5;    //abcd OE ST LT0輸出
  282.   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  283.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  284.   GPIO_Init(GPIOA, &GPIO_InitStructure);


  285. }

  286. /*******************************************************************************
  287. * Function Name  : NVIC_Configuration
  288. * Description    : Configures Vector Table base location.
  289. * Input          : None
  290. * Output         : None
  291. * Return         : None
  292. *******************************************************************************/
  293. void NVIC_Configuration(void)
  294. {
  295.   //NVIC_InitTypeDef NVIC_InitStructure;
  296.   ;
  297. }


  298. #ifdef  DEBUG
  299. /*******************************************************************************
  300. * Function Name  : assert_failed
  301. * Description    : Reports the name of the source file and the source line number
  302. *                  where the assert_param error has occurred.
  303. * Input          : - file: pointer to the source file name
  304. *                  - line: assert_param error line source number
  305. * Output         : None
  306. * Return         : None
  307. *******************************************************************************/
  308. void assert_failed(u8* file, u32 line)
  309. {
  310.   /* User can add his own implementation to report the file name and line number,
  311.      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  312.   /* Infinite loop */
  313.   while (1)
  314.   {
  315.   }
  316. }
  317. #endif
復制代碼




分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏3 分享淘帖 頂1 踩
回復

使用道具 舉報

沙發(fā)
ID:228360 發(fā)表于 2019-6-19 10:07 | 只看該作者
多謝分享,頂頂。
回復

使用道具 舉報

板凳
ID:134810 發(fā)表于 2021-7-1 15:53 | 只看該作者
感謝分享,局部刷新沒搞明白。。
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表