页次: 1
大神,裸机有这个驱动吗?我移植到裸机没反应!
改了,所以看到的是全屏蓝色的,奇怪的是全屏刷一个颜色就可以,可这样画线或画一个矩形,就不行,你有空试试上面画线的代码看看!!
原来是我的Bug,defe和debe的divider没有设对。PLL时钟要用f1c100s_tcon_clk_get_rate()来获取,主要是改动一下两个地方:
static void f1c100s_clk_defe_init(void) { clk_mux_set_parent(0x01c2010c, 3, 24, 0); clk_divider_set_rate(0x01c2010c, 4, 0, true, f1c100s_tcon_clk_get_rate(), 198000000); } static void f1c100s_clk_debe_init(void) { clk_mux_set_parent(0x01c20104, 3, 24, 0); clk_divider_set_rate(0x01c20104, 4, 0, true, f1c100s_tcon_clk_get_rate(), 198000000); }
main
framebuffer_t fb_f1c100s; fb_f1c100s_init(&fb_f1c100s); render_t* render = fb_f1c100s_create(&fb_f1c100s); for (int i = 0; i < render->pixlen/4;i++) { ((uint32_t*)render->pixels)[i] = 0xFF0000FF; } fb_f1c100s_present(&fb_f1c100s, render); for (int i = 0; i < 800;i++) { ((uint32_t*)render->pixels)[i+80000] = 0xFF00FF00; } fb_f1c100s_present(&fb_f1c100s, render); fb_f1c100s_setbl(&fb_f1c100s, 100);
厉害了!!
touch.h
/************************************************ name : touch.h desc : author : HuangXinfeng date : 2018.09.07 ************************************************/ #ifndef __TOUCH_H__ #define __TOUCH_H__ #ifdef __cplusplus extern "C" { #endif #define TP_BASE_ADDR 0x01c24800 #define TP_CTRL0 0x00 #define TP_CTRL1 0x04 #define TP_CTRL2 0x08 #define TP_CTRL3 0x0c #define TP_INT_FIFOC 0x10 #define TP_INT_FIFOS 0x14 #define TP_TPR 0x18 #define TP_CDAT 0x1c #define TEMP_DATA 0x20 #define TP_DATA 0x24 /* TP_CTRL0 bits */ #define ADC_FIRST_DLY(x) ((x) << 24) /* 8 bits */ #define ADC_FIRST_DLY_MODE(x) ((x) << 23) #define ADC_CLK_SEL(x) ((x) << 22) #define ADC_CLK_DIV(x) ((x) << 20) /* 3 bits */ #define FS_DIV(x) ((x) << 16) /* 4 bits */ #define T_ACQ(x) ((x) << 0) /* 16 bits */ /* TP_CTRL1 bits */ #define STYLUS_UP_DEBOUN(x) ((x) << 12) /* 8 bits */ #define STYLUS_UP_DEBOUN_EN(x) ((x) << 9) #define TOUCH_PAN_CALI_EN(x) ((x) << 6) #define TP_DUAL_EN(x) ((x) << 5) #define TP_MODE_EN(x) ((x) << 4) #define TP_ADC_SELECT(x) ((x) << 3) #define ADC_CHAN_SELECT(x) ((x) << 0) /* 3 bits */ /* on sun6i, bits 3~6 are left shifted by 1 to 4~7 */ #define SUN6I_TP_MODE_EN(x) ((x) << 5) /* TP_CTRL2 bits */ #define TP_SENSITIVE_ADJUST(x) ((x) << 28) /* 4 bits */ #define TP_MODE_SELECT(x) ((x) << 26) /* 2 bits */ #define PRE_MEA_EN(x) ((x) << 24) #define PRE_MEA_THRE_CNT(x) ((x) << 0) /* 24 bits */ /* TP_CTRL3 bits */ #define FILTER_EN(x) ((x) << 2) #define FILTER_TYPE(x) ((x) << 0) /* 2 bits */ /* TP_INT_FIFOC irq and fifo mask / control bits */ #define TEMP_IRQ_EN(x) ((x) << 18) #define OVERRUN_IRQ_EN(x) ((x) << 17) #define DATA_IRQ_EN(x) ((x) << 16) #define TP_DATA_XY_CHANGE(x) ((x) << 13) #define FIFO_TRIG(x) ((x) << 8) /* 5 bits */ #define DATA_DRQ_EN(x) ((x) << 7) #define FIFO_FLUSH(x) ((x) << 4) #define TP_UP_IRQ_EN(x) ((x) << 1) #define TP_DOWN_IRQ_EN(x) ((x) << 0) /* TP_INT_FIFOS irq and fifo status bits */ #define TEMP_DATA_PENDING BIT(18) #define FIFO_OVERRUN_PENDING BIT(17) #define FIFO_DATA_PENDING BIT(16) #define TP_IDLE_FLG BIT(2) #define TP_UP_PENDING BIT(1) #define TP_DOWN_PENDING BIT(0) /* TP_TPR bits */ #define TEMP_ENABLE(x) ((x) << 16) #define TEMP_PERIOD(x) ((x) << 0) /* t = x * 256 * 16 / clkin */ #ifdef __cplusplus } #endif #endif
touch.c
/************************************************ name : touch.h desc : author : HuangXinfeng date : 2018.09.08 ************************************************/ #include "touch.h" #include "io.h" struct IntTypeStu { u32_t INTC_VECTOR_REG; u32_t INTC_BASE_ADDR_REG; u32_t INTC_CTRL_REG; u32_t INTC_PEND_REG0; u32_t INTC_PEND_REG1; u32_t INTC_EN_REG0; u32_t INTC_EN_REG1; }; void TouchInit() { u32_t addr; u32_t val; /* 配置 GPIOA0 为 TPX1 TPY1 TP X2 TPY2*/ addr = 0x01c20800 + 0x00; val = read32(addr); val &= ~(0x0000ffff); //低14位清0 val |= 0x22222222; //010 TP模式即每位都是2 write32(addr, val); val = read32(TP_BASE_ADDR+TP_CTRL0); /*24M / 6 = 4Mhz(CLK_IN)/ 2^13(8192) = 488.28125 hz*/ /*Conversion Time = 1 / (4MHz/13Cycles) = 3.25us*/ /*触摸ADC获取时间T_ACQ = CLK_IN /(16*(1+63)) = 3906.25hz 左右*/ write32(TP_BASE_ADDR+TP_CTRL0, (0x1f << 23)|ADC_CLK_SEL(0) | ADC_CLK_DIV(2) | FS_DIV(7) | T_ACQ(63)); /*00: FIFO store X1,Y1 data for single touch no pressure mode*/ val = read32(TP_BASE_ADDR+TP_CTRL2); val = (0x08 << 28) | TP_MODE_SELECT(0) | (0 << 24)|0xFFF; write32(TP_BASE_ADDR+TP_CTRL2, val); val = read32(TP_BASE_ADDR+TP_CTRL3);//使能滤波器 write32(TP_BASE_ADDR + TP_CTRL3, FILTER_EN(1) | val); write32(TP_BASE_ADDR + TP_TPR, TEMP_ENABLE(1) | TEMP_PERIOD(1953));//温度转换寄存器 val = read32(TP_BASE_ADDR+TP_CTRL1); val = (5<<12) | (1<< 9) | (0<<8) | (1 << 5) | TP_MODE_EN(0) | 0x00; //4通道使能 write32( TP_BASE_ADDR + TP_CTRL1, val); write32( TP_BASE_ADDR + TP_CDAT, 0xc00); write32( TP_BASE_ADDR + 0x38, 0x22); write32(TP_BASE_ADDR + TP_INT_FIFOC , TEMP_IRQ_EN(1) | OVERRUN_IRQ_EN(0) | DATA_IRQ_EN(1) | FIFO_TRIG(0x02) | TP_DATA_XY_CHANGE(0)| FIFO_FLUSH(1) | TP_UP_IRQ_EN(1) | TP_DOWN_IRQ_EN(1)); // write32(TP_BASE_ADDR + TP_INT_FIFOC, 0x00); addr = 0x01c20400 + 0x20; //INT Enable register0 val = read32(addr); val |= (1 << 20); write32(addr, val); val = read32(0x01c20400 + 0x30); val &= ~(1 << 20); //释放屏蔽位 write32(0x01c20400 + 0x30, val); }
main.c
extern int touchx,touchy,temperature; __irq void HandleIRQ() { u32_t x, y; u32_t val; if(read32(INTC_PEND_REG0) & (1 << 13))//定时器0中断 { SystickMs(); write32(TIMER_BASS_ADDR+TMR_IRQ_STA_REG, 0x01);//清除中断 } else if(read32(INTC_PEND_REG0) & (1 << 20))//触摸屏中断 { val = read32(0x01C24800 + 0x14); if (val & (1 << 16))//fifo data irq { if (((val<<17) >> 8) > 5) { touchx = x = read32(TP_BASE_ADDR+TP_DATA); touchy = y = read32(TP_BASE_ADDR+TP_DATA); x = 1; } } if (val & (1 << 18))//温度传感器中断 { temperature = read32(TP_BASE_ADDR+0x20); } if (val & (1 << 0))//按下中断 { x = 1; } if (val & (1 << 1))//抬起中断 { y = 1; } write32(TP_BASE_ADDR+TP_INT_FIFOS, val); // write32(TP_BASE_ADDR + TP_INT_FIFOC , read32(0x01C24800 + 0x14) | FIFO_FLUSH(1)); // write32(TP_BASE_ADDR+TP_INT_FIFOS, read32(0x01C24800 + 0x14) | (0x01) | (1 << 17)); // write32(0x01c20400+ 0x10 , (1 << 20) ); } } int main(void) { ...... *((void * volatile *)0x00000038) = (void *volatile)HandleIRQ;//IRQ地址 ...... }
这个有完整工程吗?
Pese 说:达克罗德 说:present是把全屏都更新。你不要每画一个点都更新全屏,而是全部画完才调present
折腾一下,还是不行,不知道为什么,这是什么原因?
代码和显示如下(按代码应该是有一条绿线的)
https://whycan.cn/files/members/377/1.png
https://whycan.cn/files/members/377/3.jpg很奇怪,你全屏画蓝色都可以,没理由画一行不行呀。晕哥发现的我在驱动把480写成400这个问题你改了吗?
改了,所以看到的是全屏蓝色的,奇怪的是全屏刷一个颜色就可以,可这样画线或画一个矩形,就不行,你有空试试上面画线的代码看看!!
Pese 说:达克罗德 说:framebuffer都有了,画点就是把rgba写到对应行列的那个32位数
这样?下载麻烦未测试
void point(x,y,color){
((uint32_t *)render->pixels)[x+800*y] = color;
fb_f1c100s_present(&fb_f1c100s, render);
}
不过裸机真的麻烦,使用了标准库,makefile加-lc -lm -lnosys编译,就报错,外设驱动又不全,玩不来啊
In function `_sbrk':
sbrk.c:(.text._sbrk+0x28): undefined reference to `end'
collect2.exe: error: ld returned 1 exit status
噢gcc是gcc version 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907] (GNU Tools for Arm Embedded Processors 7-2018-q2-update)present是把全屏都更新。你不要每画一个点都更新全屏,而是全部画完才调present
折腾一下,还是不行,不知道为什么,这是什么原因?
代码和显示如下(按代码应该是有一条绿线的)
Pese 说:请教,楼主位的framebuffer,有没有画点函数?
framebuffer都有了,画点就是把rgba写到对应行列的那个32位数
这样?下载麻烦未测试
void point(x,y,color){
((uint32_t *)render->pixels)[x+800*y] = color;
fb_f1c100s_present(&fb_f1c100s, render);
}
不过裸机真的麻烦,使用了标准库,makefile加-lc -lm -lnosys编译,就报错,外设驱动又不全,玩不来啊
In function `_sbrk':
sbrk.c:(.text._sbrk+0x28): undefined reference to `end'
collect2.exe: error: ld returned 1 exit status
噢gcc是gcc version 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907] (GNU Tools for Arm Embedded Processors 7-2018-q2-update)
页次: 1