#include "stm32f10x.h" #include "rtthread.h" #include "fmt0371/FMT0371.h" static rt_err_t lcd_init (rt_device_t dev) { ftm0371_port_init(); ftm0371_init(); return RT_EOK; } static rt_err_t lcd_open(rt_device_t dev, rt_uint16_t oflag) { return RT_EOK; } static rt_err_t lcd_close(rt_device_t dev) { return RT_EOK; } static rt_err_t lcd_control(rt_device_t dev, rt_uint8_t cmd, void *args) { /* rate control */ return RT_EOK; } static rt_size_t lcd_write (rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size) { unsigned int i; unsigned short *p; unsigned int x,y; size = size / 2; y = (pos/2) / 240; x = (pos/2)%240; LCD_ADDR = 0x02; // X start point LCD_DATA = x; LCD_ADDR = 0x03; // Y start point LCD_DATA16( y ); LCD_ADDR = 0x0E; // start write p = (unsigned short *) buffer; if (size > (240-x)) { for (i=0;i<(240-x);i++) { LCD_DATA16(*p++); } LCD_ADDR = 0x02; // X start point LCD_DATA = 0; LCD_ADDR = 0x03; // Y start point LCD_DATA16( y+1 ); size -= (x+1); while (size--) { LCD_DATA16(*p++); } } else { for (i=0;i