STM32cudemx SPI通信 OLED显示

I decide to write my blog in English because I have been preparing my IELTS test. I think it will not be difficult for you to understand because my English level is not pretty good. So please just ignore my grammar error and pay attention to what meaning I am going to convey. 

Well,let's go to the topic.

Today I want to show you how to transplant the OLED program from standard library into HAL library with STM32cudemx.Here are the files you can download from my CSDN:https://download.csdn.net/download/weixin_41892263/10704697 before you start your job.

OK,keep patient and just follow me:

NO.1:generate a new project with STM32cudemx, the parameter should be set as following:

you don't need to care about SPI1 or SPI2 from the picture, for we are not going to control the SPI in hardware way,on the contrary,we control it in the solfware way, that is why you need to download the files which need to be transplanted. Let me tell you more exactly, you just need to set GPIO_output among all of pins no matter which type your STM32 is. if only there are enough GPIO for output then it is OK to start your job. Then you can generate your files.

 

NO.2 transplant the program

After download the files you can see the catalogue like this:

copy the files 'OLED' and 'gpio' to the location of your project then add group to your project in MDK,and don't forget to reset the include path.

            

NO.3 change the pin in mxconstants.h according to your GPIO setting

for example,if your connection is  like this:

D0       D1      RST   DC    CS

PA5   PA7     PB0    PB1  PA4

then you just need to change the define in file mxconstants.h as the picture show you.

NO.4 write the main function:

int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
	OLED_Init();
  /* USER CODE BEGIN 2 */
		OLED_Clear();
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {

  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
		
	//	LED_ON;
		OLED_ShowCHinese(0,0,0);//中
		OLED_ShowCHinese(18,0,1);//景
		OLED_ShowCHinese(36,0,2);//园
		OLED_ShowCHinese(54,0,3);//电
		OLED_ShowCHinese(72,0,4);//子
		OLED_ShowCHinese(90,0,5);//科
		OLED_ShowCHinese(108,0,6);//技
		
  }
  /* USER CODE END 3 */

}

then you can see your OLED display '中景园电子科技' :

写英语写得太没感觉了写得官方正式完全表达不出我兴奋和喜悦的心情大家也没体会到博主是一个多么热情的人。。。哈哈哈哈哈哈哈觉得OK就点个赞吧谢谢谢谢。

 

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值