-
大小: 12KB文件类型: .c金币: 1下载: 0 次发布日期: 2021-06-05
- 语言: 其他
- 标签: TJC3224T022 spi驱动
资源简介
TJC3224T022屏幕的驱动测试驱动程序(lcd12864)
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define MAP_SIZE 0xFF
#define GPH_base 0xE0200000
#define RAM(x) (*(volatile unsigned int *)(x))
#define GPH3CON_OFFSET 0xC60
#define GPH3DAT_OFFSET 0xC64
#define GPH3PUD_OFFSET 0xC68
//正显示宏
#define NORMAL_DISPLAY 1
//数据大小
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
unsigned char * map_base;
int gpio_fd=0;
int fd = 0;
static const char *device = “/dev/spidev0.0“;
static uint8_t mode = 0;
static uint8_t bits = 8;
static uint32_t speed = 1000000; //2M
static uint16_t delay;
static uint8_t mode1 ;
unsigned int pageData[8][132];//用于储存点阵数据变量
void E8GPH3DASet(int gpio_x);
void E8GPH3DASet1(int gpio_x);
//显示字符
void LCD12864_displayPOSblock(uint8_t cx0uint8_t py0uint8_t cx1uint8_t py1uint8_t *datauint8_t dir);
void LCD12864_SetPoint(uint8_t x uint8_t y uint8_t data);
/*开机界面显示字库区域*/
const unsigned char Focusbanker_73x9[ ] = {
0xFF0xFF0x110x110x110x000xF80xFC0x040x040xFC0xF80x000xF80xFC0x04
0x040x8C0x880x000xFC0xFC0x000x800xFC0xFC0x000x980xBC0x340x640xEC
0xC80x000xFF0xFF0x880x040xFC0xF80x000xC80xE40x340x140xFC0xF80x00
0xFC0xFC0x080x040xFC0xF80x000xFF0xFF0x300x780xEC0x840x000xF80xFC
0x240x240xBC0xB80x000xFC0xFC0x040x04
0x010x010x000x000x000x000x000x010x010x010x010x000x000x000x010x01
0x010x010x000x000x000x010x010x000x010x010x000x000x010x010x010x01
0x000x000x010x010x000x010x010x000x000x000x010x010x010x010x010x00
0x010x010x000x000x010x010x000x010x010x000x000x010x010x000x000x01
0x010x010x010x000x000x010x010x000x00
};
//一个指令周期时间1000M---1ns 72M---13.8ns
void delayns(unsigned int num)
{
int time=0;
while(num*13 > time++);
}
//cs 片选
void CS_SELECT(int res)//GPIO25
{
if(res)
{
E8GPH3DASet(1);//高电平
}
else
{
E8GPH3DASet(0);//低电平
}
}
//0 --写指令 1--写数据
//A0
void AO_SELECT(int res)//GPIO23
{
if(res)
{
E8GPH3DASet1(1);//高电平
}
else
{
E8GPH3DASet1(0);//低电平
}
}
//rst 复位
void RST_SELECT(int res)//GPIO24
{
if(res)
{
E8GPH3DASet1(2);//高电平
}
else
{
E8GPH3DASet1(3);//低电平
}
}
//****************spi 读写**********************************
unsigned int SPI_ReadWriteByte( uint8_t data)
{
uint8_t tx[] = {
data
};
struct spi_ioc_transfer tr = { //声明并初始化spi_ioc_transfer结构体
.tx_buf = (unsigned long)tx
.rx_buf = 0
.len = ARRAY_SIZE(tx)
.delay_usecs = delay
.speed_hz = speed
.bits_per_word = bits
};
//SPI_IOC_MESSAGE(1)的1表示spi_ioc_transfer的数量
int ret = ioctl(fd SPI_IOC_MESSAGE(1) &tr); //ioctl默认操作传输数据
if (ret < 1)
{
printf(“can‘t send spi message\n“);
return -1;
}
for (ret = 0; ret < 1; ret++) { //打印
评论
共有 条评论