資源簡(jiǎn)介
驅(qū)動(dòng)IC為SH1106G的OLED屏驅(qū)動(dòng)源程序.

代碼片段和文件信息
/*?OLED?驅(qū)動(dòng)源文件*/
/*?Includes?------------------------------------------------------------------*/
#include?“OLED_Driver.h“
#include?“bsp_spi.h“
#include?“QUTU-HZ.h“
#include?“ASCII6x8.h“
/*?Private?define?------------------------------------------------------------*/
#define?STATUS_TYPE?0xFC
/**?@addtogroup?LCD_Private_Functions?*/
void?LCD_Delay(u16?nCount)
{
??/*?Decrement?nCount?value?*/
??while?(nCount?!=?0)?{nCount--;}
}
/**
??*?@brief?read?status?from?LCD
??*?@par?Parameters:
??*?None
??*?@retval?void?None
??*?@par?Required?preconditions:
??*?None
??*?@par?Functions?called:
??*?-?LCD_SendByte()
*?-?LCD_Delay()
??*/
void?LCD_ReadStatus(void)
{
??return;
}
/**
??*?@brief?Send?a?byte?to?LCD?through?the?SPI?peripheral
??*?@param[in]?DataToSend?Data?to?be?sent
??*?@retval?u8?Data?read
??*?@par?Required?preconditions:?*?None
??*?@par?Functions?called:?*?None
??*/
//static?void?LCD_SPISendByte(u8?DataToSend) //移植到M0系統(tǒng)改用M0的函數(shù)
//{
??/*?Send?byte?through?the?SPI?peripheral?*/
??//SPI->DR?=?DataToSend;
??//while?((SPI->SR?&?SPI_SR_TXE)?==?0)
??//{
????/*?Wait?while?the?byte?is?transmitted?*/
??//}
// Send_Byte(DataToSend);
//}
/**?@addtogroup?LCD_Public_Functions?*/
/**
??*?@brief?Enable?or?Disable?the?LCD?through?CS?pin
??*?@param[in]?NewState?CS?pin?state
??*?@retval?void?None
??*?@par?Required?preconditions:?*?None
??*?@par?Functions?called:?*?-?GPIO_WriteHigh()?*?-?GPIO_WriteLow()
??*?@par?Example:?*?@code
??*?LCD_ChipSelect(ENABLE);?*?@endcode
??*/
void?LCD_ChipSelect(FunctionalState?NewState)
{
??if?(NewState?!=?DISABLE)?{GPIO_ResetBits(LCD_CS_PORT?LCD_CS_PIN);}? /*?CS?pin?low:?LCD?disabled?*/
??else?{GPIO_SetBits(LCD_CS_PORT?LCD_CS_PIN);}? /*?CS?pin?high:?LCD?enabled?*/
}
/**
??*?@brief?Send?a?byte?to?LCD
??*?@param[in]?DataType?Type?of?Data?to?be?sent
??*?@param[in]?DataToSend?Data?to?be?sent
??*?@retval?void?None
??*?@par?Required?preconditions:?*?None
??*?@par?Functions?called:?*?-?LCD_ChipSelect?*?-?LCD_SPISendByte
??*?@par?Example:?LCD_SendByte(COMMAND_TYPE?DISPLAY_ON);?*?@endcode
??*/
void?LCD_SendByte(u8?DataType?u8?DataToSend)
{
//static?u8?t;
if(DataType==COMMAND_TYPE)???GPIO_ResetBits(LCD_DC_PORT?LCD_DC_PIN);? /*?DC?pin?Low:?command?*/
else?if(DataType==DATA_TYPE)?GPIO_SetBits(LCD_DC_PORT?LCD_DC_PIN);? /*?DC?pin?high:?Data?*/
else?return;
??LCD_ChipSelect(ENABLE);? /*?Enable?access?to?LCD?*/
??//LCD_SPISendByte(DataToSend);?/*?Send??byte?*/
??Send_Byte(DataToSend);
//for(t=0;t<100;t++);
??LCD_ChipSelect(DISABLE);? /*?Disable?access?to?LCD?*/
}
//------------------------------------------------------------
void?LCD_WDATA(unsigned?char?data)?
{?
LCD_SendByte(DATA_TYPEdata);
}
//------------------------------------------------------------
void?LCD_WCOMM(unsigned?char?commend)
{
LCD_SendByte(COMMAND_TYPEcommend);
}
void?Write_Command(unsigned?char?com
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????31765??2014-08-07?16:38??OLED_Driver.c
?????文件???????3178??2014-08-18?08:06??OLED_Driver.h
-----------?---------??----------?-----??----
????????????????34943????????????????????2
評(píng)論
共有 條評(píng)論