欢迎来到天天文库
浏览记录
ID:40141251
大小:40.51 KB
页数:5页
时间:2019-07-23
《使用stm32 SPI总线控制LCD12864》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、使用stm32SPI总线控制LCD12864一、SPI初始化/********************************************************************************FunctionName:SPI1_Init*Description:InitializestheperipheralsusedbytheSPIFLASHdriver.*Input:None*Output:None*Return:None****************************************
2、***************************************/voidSPI1_Init(void){SPI_InitTypeDefSPI_InitStructure;GPIO_InitTypeDefGPIO_InitStructure;/*EnableSPI1andGPIOclocks*//*!3、_SCK_GPIOPeriphclockenable*/RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);/*!4、d=GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;GPIO_Init(GPIOA,&GPIO_InitStructure);/*!5、GPIO_Pin=GPIO_Pin_7;GPIO_Init(GPIOA,&GPIO_InitStructure);/*!6、andDIOpinsareclockedoutonthefallingedgeofCLK.SPI_InitStructure.SPI_Direction=SPI_Direction_2Lines_FullDuplex;SPI_InitStructure.SPI_Mode=SPI_Mode_Master;SPI_InitStructure.SPI_DataSize=SPI_DataSize_8b;SPI_InitStructure.SPI_CPOL=SPI_CPOL_High;SPI_InitStructure.SPI_CPHA=SPI7、_CPHA_2Edge;SPI_InitStructure.SPI_NSS=SPI_NSS_Soft;SPI_InitStructure.SPI_BaudRatePrescaler=SPI_BaudRatePrescaler_256;SPI_InitStructure.SPI_FirstBit=SPI_FirstBit_MSB;SPI_InitStructure.SPI_CRCPolynomial=7;SPI_Init(SPI1,&SPI_InitStructure);/*EnableSPI1*/SPI_Cmd(SPI1,ENABLE8、);}二、LCD12864头文件#ifndef__LCD12864_H__#define__LCD12864_H__#include"stm32f10x.h"#defineDisIOGPIOA#defineDisClkR
3、_SCK_GPIOPeriphclockenable*/RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);/*!4、d=GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;GPIO_Init(GPIOA,&GPIO_InitStructure);/*!5、GPIO_Pin=GPIO_Pin_7;GPIO_Init(GPIOA,&GPIO_InitStructure);/*!6、andDIOpinsareclockedoutonthefallingedgeofCLK.SPI_InitStructure.SPI_Direction=SPI_Direction_2Lines_FullDuplex;SPI_InitStructure.SPI_Mode=SPI_Mode_Master;SPI_InitStructure.SPI_DataSize=SPI_DataSize_8b;SPI_InitStructure.SPI_CPOL=SPI_CPOL_High;SPI_InitStructure.SPI_CPHA=SPI7、_CPHA_2Edge;SPI_InitStructure.SPI_NSS=SPI_NSS_Soft;SPI_InitStructure.SPI_BaudRatePrescaler=SPI_BaudRatePrescaler_256;SPI_InitStructure.SPI_FirstBit=SPI_FirstBit_MSB;SPI_InitStructure.SPI_CRCPolynomial=7;SPI_Init(SPI1,&SPI_InitStructure);/*EnableSPI1*/SPI_Cmd(SPI1,ENABLE8、);}二、LCD12864头文件#ifndef__LCD12864_H__#define__LCD12864_H__#include"stm32f10x.h"#defineDisIOGPIOA#defineDisClkR
4、d=GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;GPIO_Init(GPIOA,&GPIO_InitStructure);/*!5、GPIO_Pin=GPIO_Pin_7;GPIO_Init(GPIOA,&GPIO_InitStructure);/*!6、andDIOpinsareclockedoutonthefallingedgeofCLK.SPI_InitStructure.SPI_Direction=SPI_Direction_2Lines_FullDuplex;SPI_InitStructure.SPI_Mode=SPI_Mode_Master;SPI_InitStructure.SPI_DataSize=SPI_DataSize_8b;SPI_InitStructure.SPI_CPOL=SPI_CPOL_High;SPI_InitStructure.SPI_CPHA=SPI7、_CPHA_2Edge;SPI_InitStructure.SPI_NSS=SPI_NSS_Soft;SPI_InitStructure.SPI_BaudRatePrescaler=SPI_BaudRatePrescaler_256;SPI_InitStructure.SPI_FirstBit=SPI_FirstBit_MSB;SPI_InitStructure.SPI_CRCPolynomial=7;SPI_Init(SPI1,&SPI_InitStructure);/*EnableSPI1*/SPI_Cmd(SPI1,ENABLE8、);}二、LCD12864头文件#ifndef__LCD12864_H__#define__LCD12864_H__#include"stm32f10x.h"#defineDisIOGPIOA#defineDisClkR
5、GPIO_Pin=GPIO_Pin_7;GPIO_Init(GPIOA,&GPIO_InitStructure);/*!6、andDIOpinsareclockedoutonthefallingedgeofCLK.SPI_InitStructure.SPI_Direction=SPI_Direction_2Lines_FullDuplex;SPI_InitStructure.SPI_Mode=SPI_Mode_Master;SPI_InitStructure.SPI_DataSize=SPI_DataSize_8b;SPI_InitStructure.SPI_CPOL=SPI_CPOL_High;SPI_InitStructure.SPI_CPHA=SPI7、_CPHA_2Edge;SPI_InitStructure.SPI_NSS=SPI_NSS_Soft;SPI_InitStructure.SPI_BaudRatePrescaler=SPI_BaudRatePrescaler_256;SPI_InitStructure.SPI_FirstBit=SPI_FirstBit_MSB;SPI_InitStructure.SPI_CRCPolynomial=7;SPI_Init(SPI1,&SPI_InitStructure);/*EnableSPI1*/SPI_Cmd(SPI1,ENABLE8、);}二、LCD12864头文件#ifndef__LCD12864_H__#define__LCD12864_H__#include"stm32f10x.h"#defineDisIOGPIOA#defineDisClkR
6、andDIOpinsareclockedoutonthefallingedgeofCLK.SPI_InitStructure.SPI_Direction=SPI_Direction_2Lines_FullDuplex;SPI_InitStructure.SPI_Mode=SPI_Mode_Master;SPI_InitStructure.SPI_DataSize=SPI_DataSize_8b;SPI_InitStructure.SPI_CPOL=SPI_CPOL_High;SPI_InitStructure.SPI_CPHA=SPI
7、_CPHA_2Edge;SPI_InitStructure.SPI_NSS=SPI_NSS_Soft;SPI_InitStructure.SPI_BaudRatePrescaler=SPI_BaudRatePrescaler_256;SPI_InitStructure.SPI_FirstBit=SPI_FirstBit_MSB;SPI_InitStructure.SPI_CRCPolynomial=7;SPI_Init(SPI1,&SPI_InitStructure);/*EnableSPI1*/SPI_Cmd(SPI1,ENABLE
8、);}二、LCD12864头文件#ifndef__LCD12864_H__#define__LCD12864_H__#include"stm32f10x.h"#defineDisIOGPIOA#defineDisClkR
此文档下载收益归作者所有