活动详情参见:http://forum.eepw.com.cn/thread/264486/1
第一期:常用12864液晶屏驱动的编写
本次版主依据自身情况选取了 主控芯片为FG12864A的黄底液晶屏。
其数据手册见附件1
现在版主对底层驱动做了以下简单的架构,欢迎大家来认领自己的函数,一起来编程,分享我的硬件,分享你的作品。
版主的LCD12864.C的文件还有若干个函数没有编写完成,各位亲爱的网友,有木有人想一起将其编写完成。最终此文件能应用于嵌入式系统整体的工程里。当然,项目完结的时候,肯定会嵌入大家的昵称的~~
/**
******************************************************************************
* @file lcd12864.h
* @author Jobs Zheng jobszheng@eepw.com.cn
* @version
* @date 2014-11-23 11:25
* @brief 本文件为LCD12864.c的头文件
* @note fg12864a的驱动文件
******************************************************************************
* @attention
*
*
© COPYRIGHT 2014 jobszheng@eepw.com.cn
*
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __lcd12864_H
#define __lcd12864_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"
#include
#include
/** @addtogroup STM32_EEPW
* @{
*/
/** @addtogroup LCD12864
* @{
*/
/** @defgroup LCD12864_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup LCD12864_Exported_Constants
* @{
*/
#ifndef _ERRORNO_
typedef uint8_t ErrorNo;
#endif
/**
* @brief LCD12864引脚定义
*
*/
#define LCD_PIN_DATA GPIO_Pin_8
#define LCD_PIN_INSTRUCT GPIO_Pin_8
#define LCD_PIN_READ GPIO_Pin_9
#define LCD_PIN_WRITE GPIO_Pin_9
#define LCD_PIN_ENABLE GPIO_Pin_10
#define LCD_PIN_CS1 GPIO_Pin_11
#define LCD_PIN_CS2 GPIO_Pin_12
#define LCD_PIN_RST GPIO_Pin_13
#define LCD_PIN_BUSY GPIO_Pin_7
#define LCD_PIN_DISPLAY GPIO_Pin_5
//LCD数据位8位并行 PD0..8
#define LCD_PIN_DATABUS (0x00FF)
#define LCD_PIN_ALL (0x1FFF)
#define LCD_GPIO_PORT GPIOD
#define LCD_GPIO_CLK RCC_APB2Periph_GPIOD
/**
* @}
*/
/** @defgroup LCD12864_Exported_Macros
* @{
*/
/**
* @brief 发送时序宏定义
*
*/
#define LCD_DATA_SELECT() GPIO_SetBits(LCD_GPIO_PORT, LCD_PIN_DATA)
#define LCD_INST_SELECT() GPIO_ResetBits(LCD_GPIO_PORT, LCD_PIN_INSTRUCT)
#define LCD_READ_SELECT() GPIO_SetBits(LCD_GPIO_PORT, LCD_PIN_READ)
#define LCD_WRITE_SELECT() GPIO_ResetBits(LCD_GPIO_PORT, LCD_PIN_WRITE)
#define LCD_ENABLE() GPIO_SetBits(LCD_GPIO_PORT, LCD_PIN_ENABLE)
#define LCD_DISABLE() GPIO_ResetBits(LCD_GPIO_PORT, LCD_PIN_ENABLE)
#define LCD_SET_RST() GPIO_ResetBits(LCD_GPIO_PORT, LCD_PIN_RST)
#define LCD_CLR_RST() GPIO_SetBits(LCD_GPIO_PORT, LCD_PIN_RST)
/**
* @brief LCD12864使用命令字
*
*/
#define LCD_CMD_FIRST_LINE (0xC0)
#define LCD_CMD_PAGE_NUM (0xB8)
#define LCD_CMD_ROW_NUM (0x40)
#define LCD_CMD_LCM_ON (0x3F)
#define LCD_CMD_LCM_OFF (0x3E)
/**
* @brief 硬件操作时,右值限定
*
*/
#define ROW_MAX (64)
#define LOOP_MAX (20)
#define LCD_SELECT_CS_1 (0x01)
#define LCD_SELECT_CS_2 (0x02)
#define LCD_SELECT_CS_ALL (0x03)
/**
* @}
*/
/** @defgroup LCD12864_Exported_Functions
* @{
*/
#ifdef __cplusplus
}
#endif
#endif /* __lcd12864 */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/******************* (C) COPYRIGHT 2013 EEPW.com.cn *****END OF FILE****/
/**
******************************************************************************
* @file lcd12864.c
* @author Jobs Zheng jobszheng@eepw.com.cn
* @version v1.0
* @date 2014-11-23 12:07
* @brief fg12864a的驱动文件
* @note
******************************************************************************
* @attention
*
*
© COPYRIGHT 2014 jobszheng@eepw.com.cn
*
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "lcd12864.h"
/** @addtogroup STM32_EEPW
* @{
*/
/** @defgroup LCD12864
* @brief
* @{
*/
/** @defgroup LCD12864_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup LCD12864_Private_Defines
* @{
*/
//#define XXXX () /*!< */
/**
* @}
*/
/** @defgroup LCD12864_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup LCD12864_Private_Variables
* @{
*/
/**
* @}
*/
/** @defgroup LCD12864_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup LCD12864_Private_Functions
* @{
*/
/**
* @brief 检查LCD12864现在是否处于空闲状态
* @param none
* @retval true:处于空闲状态
* false:处于busy状态
* @date 2014-11-23
* @note
*/
static bool LcdIsIdle(void)
{
}
/**
* @brief 写LCD指令
* @param cmd:命令字
* cs:半屏芯片片选,cs = 0x01为右半屏;cs = 0x02为左半屏
* @retval ErrorNo:返回错误代码,没有错误为 0x00
* @date 2014-11-23
* @note
*/
static ErrorNo LCD_WriteCmd(uint8_t cmd, uint8_t cs)
{
}
/**
* @brief 写LCD数据
* @param data:8位并行数据
* cs:半屏芯片片选,cs = 0x01为右半屏;cs = 0x02为左半屏
* @retval ErrorNo:返回错误代码,没有错误为 0x00
* @date 2014-11-23
* @note
*/
static ErrorNo LCD_WriteData(uint8_t data, uint8_t cs)
{
}
/**
* @brief 设置显示起始行寄存器的内容
* @param lineNum:起始行号 0-63
* @retval ErrorNo:返回错误代码,没有错误为 0x00
* @date 2014-11-23
* @note
*/
ErrorNo LCD_SetFirstLine(uint8_t lineNum)
{
}
/**
* @brief 设置显示指针X方向,即页地址(0-7)
* @param page:页地址(0-7)
* @retval ErrorNo:返回错误代码,没有错误为 0x00
* @date 2014-11-23
* @note
*/
static ErrorNo LCD_SetXDirect(uint8_t page)
{
}
/**
* @brief 设置显示指针Y方向,即列号(0-63)
* @param row:列号(0-63)
* @retval ErrorNo:返回错误代码,没有错误为 0x00
* @date 2014-11-23
* @note
*/
static ErrorNo LCD_SetYDirect(uint8_t row)
{
}
/**
* @brief 设置起始点的X、Y值。当y > 63时,cs2选通,否则cs1选通
* @param
* @retval ErrorNo:返回错误代码,没有错误为 0x00
* @date 2014-11-23
* @note
*/
ErrorNo LCD_SetStartPoint(uint8_t point_x, uint8_t point_y)
{
}
/**
* @brief 将LCD复位
* @param
* @retval None
* @date 2014-11-23
* @note
*/
void LCD_Rst(void)
{
}
/**
* @brief 开启LCD屏幕显示
* @param none
* @retval ErrorNo:返回错误代码,没有错误为 0x00
* @date 2014-11-23
* @note
*/
ErrorNo LCD_On(void)
{
}
/**
* @brief 关闭LCD屏幕显示
* @param none
* @retval ErrorNo:返回错误代码,没有错误为 0x00
* @date 2014-11-23
* @note
*/
ErrorNo LCD_Off(void)
{
}
/**
* @brief 清屏
* @param none
* @retval ErrorNo:返回错误代码,没有错误为 0x00
* @date 2014-11-23
* @note
*/
ErrorNo LCD_ClrScreen(void)
{
}
/**
* @brief 初始化FG12864A液晶屏
* @param None
* @retval None
* @date 2014-11-23
* @note
*/
void LcdInit(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(LCD_GPIO_CLK, ENABLE);
GPIO_InitStructure.GPIO_Pin = LCD_PIN_ALL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(LCD_GPIO_PORT, &GPIO_InitStructure);
LCD_DISABLE();
LCD_READ_SELECT();
LCD_DATA_SELECT();
LCD_SET_RST();
LCD_CLR_RST();
}
/**
* @brief 显示图片,128 x 64 点阵大小
* @param *content: 图形数组的首地址
* @retval ErrorNo:返回错误代码,没有错误为 0x00
* @date 2014-11-23
* @note
*/
ErrorNo DispBmp(uint8_t *content)
{
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/******************* (C) jobszheng@eepw.com.cn*****END OF FILE****/
液晶屏说明书,详见附件
我要赚赏金
