Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of FT810 by
Revision 0:2d0ef4830603, committed 2016-09-07
- Comitter:
- cpm219
- Date:
- Wed Sep 07 21:53:53 2016 +0000
- Child:
- 1:75efdc9d4bc2
- Commit message:
- first version
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/FT_DataTypes.h Wed Sep 07 21:53:53 2016 +0000 @@ -0,0 +1,65 @@ +/* mbed Library for FTDI FT800 Enbedded Video Engine "EVE" + * based on Original Code Sample from FTDI + * ported to mbed by Peter Drescher, DC2PD 2014 + * Released under the MIT License: http://mbed.org/license/mit */ + +#ifndef _FT_DATATYPES_H_ +#define _FT_DATATYPES_H_ + + +#define FT_FALSE (0) +#define FT_TRUE (1) + +typedef char ft_char8_t; +typedef signed char ft_schar8_t; +typedef unsigned char ft_uchar8_t; +typedef ft_uchar8_t ft_uint8_t; +typedef short ft_int16_t; +typedef unsigned short ft_uint16_t; +typedef unsigned int ft_uint32_t; +typedef int ft_int32_t; +typedef void ft_void_t; +typedef long long ft_int64_t; +typedef unsigned long long ft_uint64_t; +typedef float ft_float_t; +typedef double ft_double_t; +typedef char ft_bool_t; + +#define FT_BYTE_SIZE (1) +#define FT_SHORT_SIZE (2) +#define FT_WORD_SIZE (4) +#define FT_DWORD_SIZE (8) + +#define FT_NUMBITS_IN_BYTE (1*8) +#define FT_NUMBITS_IN_SHORT (2*8) +#define FT_NUMBITS_IN_WORD (4*8) +#define FT_NUMBITS_IN_DWORD (8*8) + +#define ft_prog_uchar8_t ft_uchar8_t +#define ft_prog_char8_t ft_char8_t +#define ft_prog_uint16_t ft_uint16_t + +#define ft_random(x) (rand() % (x)) + +#define ft_pgm_read_byte_near(x) (*(x)) +#define ft_pgm_read_byte(x) (*(x)) + +#define ft_strcpy_P strcpy +#define ft_strlen_P strlen + +#define FT_DBGPRINT(x) printf(x) +#define FT_PROGMEM const + +#define ft_pgm_read_byte_near(x) (*(x)) +#define ft_pgm_read_byte(x) (*(x)) + +#define ft_pgm_read_word(addr) (*(ft_int16_t*)(addr)) + +#endif /*_FT_DATATYPES_H_*/ + + +/* Nothing beyond this*/ + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/FT_Gpu.h Wed Sep 07 21:53:53 2016 +0000
@@ -0,0 +1,378 @@
+#ifndef _FT_GPU_H_
+#define _FT_GPU_H_
+
+/* Definitions used for FT800 co processor command buffer */
+#define FT_DL_SIZE (8*1024L) //8KB Display List buffer size
+#define FT_CMD_FIFO_SIZE (4*1024L) //4KB coprocessor Fifo size
+#define FT_CMD_SIZE (4) //4 byte per coprocessor command of EVE
+
+
+/* For FT801, FT811 and FT813 */
+#define CTOUCH_MODE_COMPATIBILITY 1
+#define CTOUCH_MODE_EXTENDED 0
+
+#define LOW_FREQ_BOUND 58800000L//98% of 60Mhz
+
+#define RAM_G_SIZE 1024*1024L
+#define FT81X_VERSION "1.0.4"
+
+#define ADC_DIFFERENTIAL 1UL
+#define ADC_SINGLE_ENDED 0UL
+#define ADPCM_SAMPLES 2UL
+#define ALWAYS 7UL
+#define ARGB1555 0UL
+#define ARGB2 5UL
+#define ARGB4 6UL
+#define BARGRAPH 11UL
+#define BILINEAR 1UL
+#define BITMAPS 1UL
+#define BORDER 0UL
+#define CMDBUF_SIZE 4096UL
+#define CMD_APPEND 4294967070UL
+#define CMD_BGCOLOR 4294967049UL
+#define CMD_BITMAP_TRANSFORM 4294967073UL
+#define CMD_BUTTON 4294967053UL
+#define CMD_CALIBRATE 4294967061UL
+#define CMD_CLOCK 4294967060UL
+#define CMD_COLDSTART 4294967090UL
+#define CMD_CRC 4294967043UL
+#define CMD_CSKETCH 4294967093UL
+#define CMD_DIAL 4294967085UL
+#define CMD_DLSTART 4294967040UL
+#define CMD_EXECUTE 4294967047UL
+#define CMD_FGCOLOR 4294967050UL
+#define CMD_GAUGE 4294967059UL
+#define CMD_GETMATRIX 4294967091UL
+#define CMD_GETPOINT 4294967048UL
+#define CMD_GETPROPS 4294967077UL
+#define CMD_GETPTR 4294967075UL
+#define CMD_GRADCOLOR 4294967092UL
+#define CMD_GRADIENT 4294967051UL
+#define CMD_HAMMERAUX 4294967044UL
+#define CMD_IDCT_DELETED 4294967046UL
+#define CMD_INFLATE 4294967074UL
+#define CMD_INTERRUPT 4294967042UL
+#define CMD_INT_RAMSHARED 4294967101UL
+#define CMD_INT_SWLOADIMAGE 4294967102UL
+#define CMD_KEYS 4294967054UL
+#define CMD_LOADIDENTITY 4294967078UL
+#define CMD_LOADIMAGE 4294967076UL
+#define CMD_LOGO 4294967089UL
+#define CMD_MARCH 4294967045UL
+#define CMD_MEDIAFIFO 4294967097UL
+#define CMD_MEMCPY 4294967069UL
+#define CMD_MEMCRC 4294967064UL
+#define CMD_MEMSET 4294967067UL
+#define CMD_MEMWRITE 4294967066UL
+#define CMD_MEMZERO 4294967068UL
+#define CMD_NUMBER 4294967086UL
+#define CMD_PLAYVIDEO 4294967098UL
+#define CMD_PROGRESS 4294967055UL
+#define CMD_REGREAD 4294967065UL
+#define CMD_ROMFONT 4294967103UL
+#define CMD_ROTATE 4294967081UL
+#define CMD_SCALE 4294967080UL
+#define CMD_SCREENSAVER 4294967087UL
+#define CMD_SCROLLBAR 4294967057UL
+#define CMD_SETBASE 4294967096UL
+#define CMD_SETBITMAP 4294967107UL
+#define CMD_SETFONT 4294967083UL
+#define CMD_SETFONT2 4294967099UL
+#define CMD_SETMATRIX 4294967082UL
+#define CMD_SETROTATE 4294967094UL
+#define CMD_SETSCRATCH 4294967100UL
+#define CMD_SKETCH 4294967088UL
+#define CMD_SLIDER 4294967056UL
+#define CMD_SNAPSHOT 4294967071UL
+#define CMD_SNAPSHOT2 4294967095UL
+#define CMD_SPINNER 4294967062UL
+#define CMD_STOP 4294967063UL
+#define CMD_SWAP 4294967041UL
+#define CMD_SYNC 4294967106UL
+#define CMD_TEXT 4294967052UL
+#define CMD_TOGGLE 4294967058UL
+#define CMD_TOUCH_TRANSFORM 4294967072UL
+#define CMD_TRACK 4294967084UL
+#define CMD_TRANSLATE 4294967079UL
+#define CMD_VIDEOFRAME 4294967105UL
+#define CMD_VIDEOSTART 4294967104UL
+#define DECR 4UL
+#define DLSWAP_DONE 0UL
+#define DLSWAP_FRAME 2UL
+#define DLSWAP_LINE 1UL
+#define DST_ALPHA 3UL
+#define EDGE_STRIP_A 7UL
+#define EDGE_STRIP_B 8UL
+#define EDGE_STRIP_L 6UL
+#define EDGE_STRIP_R 5UL
+#define EQUAL 5UL
+#define GEQUAL 4UL
+#define GREATER 3UL
+#define INCR 3UL
+#define INT_CMDEMPTY 32UL
+#define INT_CMDFLAG 64UL
+#define INT_CONVCOMPLETE 128UL
+#define INT_G8 18UL
+#define INT_L8C 12UL
+#define INT_PLAYBACK 16UL
+#define INT_SOUND 8UL
+#define INT_SWAP 1UL
+#define INT_TAG 4UL
+#define INT_TOUCH 2UL
+#define INT_VGA 13UL
+#define INVERT 5UL
+#define KEEP 1UL
+#define L1 1UL
+#define L2 17UL
+#define L4 2UL
+#define L8 3UL
+#define LEQUAL 2UL
+#define LESS 1UL
+#define LINEAR_SAMPLES 0UL
+#define LINES 3UL
+#define LINE_STRIP 4UL
+#define NEAREST 0UL
+#define NEVER 0UL
+#define NOTEQUAL 6UL
+#define ONE 1UL
+#define ONE_MINUS_DST_ALPHA 5UL
+#define ONE_MINUS_SRC_ALPHA 4UL
+#define OPT_CENTER 1536UL
+#define OPT_CENTERX 512UL
+#define OPT_CENTERY 1024UL
+#define OPT_FLAT 256UL
+#define OPT_FULLSCREEN 8UL
+#define OPT_MEDIAFIFO 16UL
+#define OPT_MONO 1UL
+#define OPT_NOBACK 4096UL
+#define OPT_NODL 2UL
+#define OPT_NOHANDS 49152UL
+#define OPT_NOHM 16384UL
+#define OPT_NOPOINTER 16384UL
+#define OPT_NOSECS 32768UL
+#define OPT_NOTEAR 4UL
+#define OPT_NOTICKS 8192UL
+#define OPT_RIGHTX 2048UL
+#define OPT_SIGNED 256UL
+#define OPT_SOUND 32UL
+#define PALETTED 8UL
+#define PALETTED4444 15UL
+#define PALETTED565 14UL
+#define PALETTED8 16UL
+#define FTPOINTS 2UL
+#define RAM_CMD 3178496UL
+#define RAM_DL 3145728UL
+#define RAM_G 0UL
+#define RAM_REG 3153920UL
+#define RAM_ROMSUB 3186688UL
+#define RECTS 9UL
+
+#define ROMFONT_TABLEADDRESS 3145724UL
+
+#define REG_ANALOG 3154284UL
+#define REG_ANA_COMP 3154308UL
+#define REG_BIST_EN 3154292UL
+#define REG_BUSYBITS 3154152UL
+#define REG_CLOCK 3153928UL
+#define REG_CMDB_SPACE 3155316UL
+#define REG_CMDB_WRITE 3155320UL
+#define REG_CMD_DL 3154176UL
+#define REG_CMD_READ 3154168UL
+#define REG_CMD_WRITE 3154172UL
+#define REG_CPURESET 3153952UL
+#define REG_CRC 3154296UL
+#define REG_CSPREAD 3154024UL
+#define REG_CTOUCH_EXTENDED 3154184UL
+//modified below to reflect the same as datasheet
+#define REG_CTOUCH_TOUCH0_XY 3154212UL
+#define REG_CTOUCH_TOUCH4_X 3154284UL
+#define REG_CTOUCH_TOUCH4_Y 3154208UL
+#define REG_CTOUCH_TOUCH1_XY 3154204UL
+#define REG_CTOUCH_TOUCH2_XY 3154316UL
+#define REG_CTOUCH_TOUCH3_XY 3154320UL
+#define REG_CYA_TOUCH 3154280UL
+#define REG_DATESTAMP 3155300UL
+#define REG_DITHER 3154016UL
+#define REG_DLSWAP 3154004UL
+#define REG_FRAMES 3153924UL
+#define REG_FREQUENCY 3153932UL
+#define REG_GPIO 3154068UL
+#define REG_GPIOX 3154076UL
+#define REG_GPIOX_DIR 3154072UL
+#define REG_GPIO_DIR 3154064UL
+#define REG_HCYCLE 3153964UL
+#define REG_HOFFSET 3153968UL
+#define REG_HSIZE 3153972UL
+#define REG_HSYNC0 3153976UL
+#define REG_HSYNC1 3153980UL
+#define REG_ID 3153920UL
+#define REG_INT_EN 3154092UL
+#define REG_INT_FLAGS 3154088UL
+#define REG_INT_MASK 3154096UL
+#define REG_MACRO_0 3154136UL
+#define REG_MACRO_1 3154140UL
+#define REG_MEDIAFIFO_READ 3182612UL
+#define REG_MEDIAFIFO_WRITE 3182616UL
+#define REG_OUTBITS 3154012UL
+#define REG_PATCHED_ANALOG 3154288UL
+#define REG_PATCHED_TOUCH_FAULT 3154284UL
+#define REG_PCLK 3154032UL
+#define REG_PCLK_POL 3154028UL
+#define REG_PLAY 3154060UL
+#define REG_PLAYBACK_FORMAT 3154116UL
+#define REG_PLAYBACK_FREQ 3154112UL
+#define REG_PLAYBACK_LENGTH 3154104UL
+#define REG_PLAYBACK_LOOP 3154120UL
+#define REG_PLAYBACK_PLAY 3154124UL
+#define REG_PLAYBACK_READPTR 3154108UL
+#define REG_PLAYBACK_START 3154100UL
+#define REG_PWM_DUTY 3154132UL
+#define REG_PWM_HZ 3154128UL
+#define REG_RENDERMODE 3153936UL
+#define REG_ROMSUB_SEL 3154160UL
+#define REG_ROTATE 3154008UL
+#define REG_SNAPFORMAT 3153948UL
+#define REG_SNAPSHOT 3153944UL
+#define REG_SNAPY 3153940UL
+#define REG_SOUND 3154056UL
+#define REG_SPI_EARLY_TX 3154300UL
+#define REG_SPI_WIDTH 3154312UL
+#define REG_SWIZZLE 3154020UL
+#define REG_TAG 3154044UL
+#define REG_TAG_X 3154036UL
+#define REG_TAG_Y 3154040UL
+#define REG_TAP_CRC 3153956UL
+#define REG_TAP_MASK 3153960UL
+#define REG_TOUCH_ADC_MODE 3154184UL
+#define REG_TOUCH_CHARGE 3154188UL
+#define REG_TOUCH_DIRECT_XY 3154316UL
+#define REG_TOUCH_DIRECT_Z1Z2 3154320UL
+#define REG_TOUCH_FAULT 3154288UL
+#define REG_TOUCH_MODE 3154180UL
+#define REG_TOUCH_OVERSAMPLE 3154196UL
+#define REG_TOUCH_RAW_XY 3154204UL
+#define REG_TOUCH_RZ 3154208UL
+#define REG_TOUCH_RZTHRESH 3154200UL
+#define REG_TOUCH_SCREEN_XY 3154212UL
+#define REG_TOUCH_SETTLE 3154192UL
+#define REG_TOUCH_TAG 3154220UL
+#define REG_TOUCH_TAG1 3154228UL
+#define REG_TOUCH_TAG1_XY 3154224UL
+#define REG_TOUCH_TAG2 3154236UL
+#define REG_TOUCH_TAG2_XY 3154232UL
+#define REG_TOUCH_TAG3 3154244UL
+#define REG_TOUCH_TAG3_XY 3154240UL
+#define REG_TOUCH_TAG4 3154252UL
+#define REG_TOUCH_TAG4_XY 3154248UL
+#define REG_TOUCH_TAG_XY 3154216UL
+#define REG_TOUCH_TRANSFORM_A 3154256UL
+#define REG_TOUCH_TRANSFORM_B 3154260UL
+#define REG_TOUCH_TRANSFORM_C 3154264UL
+#define REG_TOUCH_TRANSFORM_D 3154268UL
+#define REG_TOUCH_TRANSFORM_E 3154272UL
+#define REG_TOUCH_TRANSFORM_F 3154276UL
+#define REG_TRACKER 3182592UL
+#define REG_TRACKER_1 3182596UL
+#define REG_TRACKER_2 3182600UL
+#define REG_TRACKER_3 3182604UL
+#define REG_TRACKER_4 3182608UL
+#define REG_TRIM 3154304UL
+#define REG_VCYCLE 3153984UL
+#define REG_VOFFSET 3153988UL
+#define REG_VOL_PB 3154048UL
+#define REG_VOL_SOUND 3154052UL
+#define REG_VSIZE 3153992UL
+#define REG_VSYNC0 3153996UL
+#define REG_VSYNC1 3154000UL
+#define REPEAT 1UL
+#define REPLACE 2UL
+#define RGB332 4UL
+#define RGB565 7UL
+#define SRC_ALPHA 2UL
+#define TEXT8X8 9UL
+#define TEXTVGA 10UL
+#define TOUCHMODE_CONTINUOUS 3UL
+#define TOUCHMODE_FRAME 2UL
+#define TOUCHMODE_OFF 0UL
+#define TOUCHMODE_ONESHOT 1UL
+#define ULAW_SAMPLES 1UL
+#define ZERO 0UL
+#define VERTEX2F(x,y) ((1UL<<30)|(((x)&32767UL)<<15)|(((y)&32767UL)<<0))
+#define VERTEX2II(x,y,handle,cell) ((2UL<<30)|(((x)&511UL)<<21)|(((y)&511UL)<<12)|(((handle)&31UL)<<7)|(((cell)&127UL)<<0))
+#define BITMAP_SOURCE(addr) ((1UL<<24)|(((addr)&4194303UL)<<0))
+#define CLEAR_COLOR_RGB(red,green,blue) ((2UL<<24)|(((red)&255UL)<<16)|(((green)&255UL)<<8)|(((blue)&255UL)<<0))
+#define TAG(s) ((3UL<<24)|(((s)&255UL)<<0))
+#define COLOR_RGB(red,green,blue) ((4UL<<24)|(((red)&255UL)<<16)|(((green)&255UL)<<8)|(((blue)&255UL)<<0))
+#define BITMAP_HANDLE(handle) ((5UL<<24)|(((handle)&31UL)<<0))
+#define CELL(cell) ((6UL<<24)|(((cell)&127UL)<<0))
+#define BITMAP_LAYOUT(format,linestride,height) ((7UL<<24)|(((format)&31UL)<<19)|(((linestride)&1023UL)<<9)|(((height)&511UL)<<0))
+#define BITMAP_SIZE(filter,wrapx,wrapy,width,height) ((8UL<<24)|(((filter)&1UL)<<20)|(((wrapx)&1UL)<<19)|(((wrapy)&1UL)<<18)|(((width)&511UL)<<9)|(((height)&511UL)<<0))
+#define ALPHA_FUNC(func,ref) ((9UL<<24)|(((func)&7UL)<<8)|(((ref)&255UL)<<0))
+#define STENCIL_FUNC(func,ref,mask) ((10UL<<24)|(((func)&7UL)<<16)|(((ref)&255UL)<<8)|(((mask)&255UL)<<0))
+#define BLEND_FUNC(src,dst) ((11UL<<24)|(((src)&7UL)<<3)|(((dst)&7UL)<<0))
+#define STENCIL_OP(sfail,spass) ((12UL<<24)|(((sfail)&7UL)<<3)|(((spass)&7UL)<<0))
+#define POINT_SIZE(size) ((13UL<<24)|(((size)&8191UL)<<0))
+#define LINE_WIDTH(width) ((14UL<<24)|(((width)&4095UL)<<0))
+#define CLEAR_COLOR_A(alpha) ((15UL<<24)|(((alpha)&255UL)<<0))
+#define COLOR_A(alpha) ((16UL<<24)|(((alpha)&255UL)<<0))
+#define CLEAR_STENCIL(s) ((17UL<<24)|(((s)&255UL)<<0))
+#define CLEAR_TAG(s) ((18UL<<24)|(((s)&255UL)<<0))
+#define STENCIL_MASK(mask) ((19UL<<24)|(((mask)&255UL)<<0))
+#define TAG_MASK(mask) ((20UL<<24)|(((mask)&1UL)<<0))
+#define BITMAP_TRANSFORM_A(a) ((21UL<<24)|(((a)&131071UL)<<0))
+#define BITMAP_TRANSFORM_B(b) ((22UL<<24)|(((b)&131071UL)<<0))
+#define BITMAP_TRANSFORM_C(c) ((23UL<<24)|(((c)&16777215UL)<<0))
+#define BITMAP_TRANSFORM_D(d) ((24UL<<24)|(((d)&131071UL)<<0))
+#define BITMAP_TRANSFORM_E(e) ((25UL<<24)|(((e)&131071UL)<<0))
+#define BITMAP_TRANSFORM_F(f) ((26UL<<24)|(((f)&16777215UL)<<0))
+#define SCISSOR_XY(x,y) ((27UL<<24)|(((x)&2047UL)<<11)|(((y)&2047UL)<<0))
+#define SCISSOR_SIZE(width,height) ((28UL<<24)|(((width)&4095UL)<<12)|(((height)&4095UL)<<0))
+#define CALL(dest) ((29UL<<24)|(((dest)&65535UL)<<0))
+#define JUMP(dest) ((30UL<<24)|(((dest)&65535UL)<<0))
+#define BEGIN(prim) ((31UL<<24)|(((prim)&15UL)<<0))
+#define COLOR_MASK(r,g,b,a) ((32UL<<24)|(((r)&1UL)<<3)|(((g)&1UL)<<2)|(((b)&1UL)<<1)|(((a)&1UL)<<0))
+#define CLEAR(c,s,t) ((38UL<<24)|(((c)&1UL)<<2)|(((s)&1UL)<<1)|(((t)&1UL)<<0))
+#define VERTEX_FORMAT(frac) ((39UL<<24)|(((frac)&7UL)<<0))
+#define BITMAP_LAYOUT_H(linestride,height) ((40UL<<24)|(((linestride)&3UL)<<2)|(((height)&3UL)<<0))
+#define BITMAP_SIZE_H(width,height) ((41UL<<24)|(((width)&3UL)<<2)|(((height)&3UL)<<0))
+#define PALETTE_SOURCE(addr) ((42UL<<24)|(((addr)&4194303UL)<<0))
+#define VERTEX_TRANSLATE_X(x) ((43UL<<24)|(((x)&131071UL)<<0))
+#define VERTEX_TRANSLATE_Y(y) ((44UL<<24)|(((y)&131071UL)<<0))
+#define NOP() ((45UL<<24))
+#define END() ((33UL<<24))
+#define SAVE_CONTEXT() ((34UL<<24))
+#define RESTORE_CONTEXT() ((35UL<<24))
+#define RETURN() ((36UL<<24))
+#define MACRO(m) ((37UL<<24)|(((m)&1UL)<<0))
+#define DISPLAY() ((0UL<<24))
+#endif
+
+#define FT_GPU_NUMCHAR_PERFONT (128)
+#define FT_GPU_FONT_TABLE_SIZE (148)
+
+/* FT81x and FT80x font table structure */
+/* Font table address in ROM can be found by reading the address from 0xFFFFC location. */
+/* 16 font tables are present at the address read from location 0xFFFFC */
+typedef struct FT_Gpu_Fonts
+{
+ /* All the values are in bytes */
+ /* Width of each character font from 0 to 127 */
+ ft_uint8_t FontWidth[FT_GPU_NUMCHAR_PERFONT];
+ /* Bitmap format of font wrt bitmap formats supported by FT800 - L1, L4, L8 */
+ ft_uint32_t FontBitmapFormat;
+ /* Font line stride in FT800 ROM */
+ ft_uint32_t FontLineStride;
+ /* Font width in pixels */
+ ft_uint32_t FontWidthInPixels;
+ /* Font height in pixels */
+ ft_uint32_t FontHeightInPixels;
+ /* Pointer to font graphics raw data */
+ ft_uint32_t PointerToFontGraphicsData;
+}FT_Gpu_Fonts_t;
+
+
+
+
+/* Nothing beyond this */
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/FT_Gpu_Hal.h Wed Sep 07 21:53:53 2016 +0000
@@ -0,0 +1,276 @@
+/*!
+ * \file FT_GPU_HAL.h
+ *
+
+ Curt added Load_raw 7/22/16
+
+
+
+ * \author FTDI
+ * \date 2013.04.24
+ *
+ * Copyright 2013 Future Technology Devices International Limited
+ *
+ * Project: FT800 or EVE compatible silicon
+ * File Description:
+ * This file defines the generic APIs of host access layer for the FT800 or EVE compatible silicon.
+ * Application shall access FT800 or EVE resources over these APIs. In addition, there are
+ * some helper functions defined for FT800 coprocessor engine as well as host commands.
+ * Rivision History:
+ * ported to mbed by Peter Drescher, DC2PD 2014
+ *
+ */
+
+#ifndef FT_GPU_HAL_H
+#define FT_GPU_HAL_H
+
+#include "mbed.h"
+#include "FT_DataTypes.h"
+
+typedef enum {
+ FT_GPU_I2C_MODE = 0,
+ FT_GPU_SPI_MODE,
+
+ FT_GPU_MODE_COUNT,
+ FT_GPU_MODE_UNKNOWN = FT_GPU_MODE_COUNT
+} FT_GPU_HAL_MODE_E;
+
+typedef enum {
+ OPENED,
+ READING,
+ WRITING,
+ CLOSED,
+ STATUS_COUNT,
+ STATUS_ERROR = STATUS_COUNT
+} FT_GPU_HAL_STATUS_E;
+
+typedef struct {
+ ft_uint8_t reserved;
+} Ft_Gpu_App_Context_t;
+
+typedef struct {
+ /* Total number channels for libmpsse */
+ ft_uint32_t TotalChannelNum;
+} Ft_Gpu_HalInit_t;
+
+typedef enum {
+ FT_GPU_READ = 0,
+ FT_GPU_WRITE,
+} FT_GPU_TRANSFERDIR_T;
+
+
+typedef struct {
+ ft_uint32_t length; //IN and OUT
+ ft_uint32_t address;
+ ft_uint8_t *buffer;
+} Ft_Gpu_App_Transfer_t;
+
+class FT800
+{
+public:
+ FT800(PinName mosi,
+ PinName miso,
+ PinName sck,
+ PinName ss,
+ PinName intr,
+ PinName pd);
+
+private:
+ SPI _spi;
+ DigitalOut _ss;
+ DigitalOut _pd;
+ InterruptIn _f800_isr;
+public:
+ /* Global used for buffer optimization */
+ //Ft_Gpu_Hal_Context_t host,*phost;
+ Ft_Gpu_App_Context_t app_header;
+ ft_uint16_t cmd_fifo_wp; //coprocessor fifo write pointer
+ ft_uint16_t dl_buff_wp; //display command memory write pointer
+ FT_GPU_HAL_STATUS_E status; //OUT
+ ft_void_t* hal_handle; //IN/OUT
+ ft_uint32_t CmdBuffer_Index;
+ ft_uint32_t DlBuffer_Index;
+ ft_int16_t DispWidth;
+ ft_int16_t DispHeight;
+ ft_int16_t DispHCycle;
+ ft_int16_t DispHOffset;
+ ft_int16_t DispHSync0;
+ ft_int16_t DispHSync1;
+ ft_int16_t DispVCycle;
+ ft_int16_t DispVOffset;
+ ft_int16_t DispVSync0;
+ ft_int16_t DispVSync1;
+ ft_uint8_t DispPCLK;
+ ft_char8_t DispSwizzle;
+ ft_char8_t DispPCLKPol;
+
+
+ ft_void_t BootupConfig(void);
+ ft_bool_t Bootup(void);
+
+
+ /*The basic APIs Level 1*/
+ ft_bool_t Init( );
+ ft_bool_t Open( );
+
+ /*The APIs for reading/writing transfer continuously only with small buffer system*/
+ ft_void_t StartTransfer(FT_GPU_TRANSFERDIR_T rw,ft_uint32_t addr);
+ ft_uint8_t Transfer8(ft_uint8_t value);
+ ft_uint16_t Transfer16(ft_uint16_t value);
+ ft_uint32_t Transfer32(ft_uint32_t value);
+ ft_void_t EndTransfer( );
+
+ /*Read & Write APIs for both burst and single transfer,depending on buffer size*/
+ ft_void_t Read(Ft_Gpu_App_Transfer_t *transfer);
+ ft_void_t Write(Ft_Gpu_App_Transfer_t *transfer);
+
+ ft_void_t Close();
+ ft_void_t DeInit();
+
+ /*Helper function APIs Read*/
+ ft_uint8_t Rd8(ft_uint32_t addr);
+ ft_uint16_t Rd16(ft_uint32_t addr);
+ ft_uint32_t Rd32(ft_uint32_t addr);
+
+ /*Helper function APIs Write*/
+ ft_void_t Wr8(ft_uint32_t addr, ft_uint8_t v);
+ ft_void_t Wr16(ft_uint32_t addr, ft_uint16_t v);
+ ft_void_t Wr32(ft_uint32_t addr, ft_uint32_t v);
+
+ /*******************************************************************************/
+ /*******************************************************************************/
+ /*APIs for coprocessor Fifo read/write and space management*/
+ ft_void_t Updatecmdfifo(ft_uint16_t count);
+ ft_void_t WrCmd32(ft_uint32_t cmd);
+ ft_void_t WrCmdBuf(ft_uint8_t *buffer,ft_uint16_t count);
+ ft_void_t WaitCmdfifo_empty();
+ ft_void_t ResetCmdFifo();
+ ft_void_t CheckCmdBuffer(ft_uint16_t count);
+ ft_void_t ResetDLBuffer();
+
+ ft_void_t StartCmdTransfer(FT_GPU_TRANSFERDIR_T rw, ft_uint16_t count);
+ ft_void_t Powercycle(ft_bool_t up);
+
+
+ /*******************************************************************************/
+ /*******************************************************************************/
+ /*APIs for Host Commands*/
+ typedef enum {
+ FT_GPU_INTERNAL_OSC = 0x48, //default
+ FT_GPU_EXTERNAL_OSC = 0x44,
+ } FT_GPU_PLL_SOURCE_T;
+ typedef enum {
+ FT_GPU_PLL_48M = 0x62, //default
+ FT_GPU_PLL_36M = 0x61,
+ FT_GPU_PLL_24M = 0x64,
+ } FT_GPU_PLL_FREQ_T;
+
+ typedef enum {
+ FT_GPU_ACTIVE_M = 0x00,
+ FT_GPU_STANDBY_M = 0x41,//default
+ FT_GPU_SLEEP_M = 0x42,
+ FT_GPU_POWERDOWN_M = 0x50,
+ } FT_GPU_POWER_MODE_T;
+
+#define FT_GPU_CORE_RESET (0x68)
+
+ ft_int32_t hal_strlen(const ft_char8_t *s);
+ ft_void_t Sleep(ft_uint16_t ms);
+ ft_void_t ClockSelect(FT_GPU_PLL_SOURCE_T pllsource);
+ ft_void_t PLL_FreqSelect(FT_GPU_PLL_FREQ_T freq);
+ ft_void_t PowerModeSwitch(FT_GPU_POWER_MODE_T pwrmode);
+ ft_void_t CoreReset();
+//ft_void_t Ft_Gpu_Hal_StartTransfer( ,FT_GPU_TRANSFERDIR_T rw,ft_uint32_t addr);
+ ft_void_t WrMem(ft_uint32_t addr, const ft_uint8_t *buffer, ft_uint32_t length);
+ ft_void_t WrMemFromFlash(ft_uint32_t addr,const ft_prog_uchar8_t *buffer, ft_uint32_t length);
+ ft_void_t WrCmdBufFromFlash(FT_PROGMEM ft_prog_uchar8_t *buffer,ft_uint16_t count);
+ ft_void_t RdMem(ft_uint32_t addr, ft_uint8_t *buffer, ft_uint32_t length);
+ ft_void_t WaitLogo_Finish();
+ ft_uint8_t TransferString(const ft_char8_t *string);
+ ft_void_t HostCommand(ft_uint8_t cmd);
+ ft_int32_t Dec2Ascii(ft_char8_t *pSrc,ft_int32_t value);
+
+ ft_void_t Text(ft_int16_t x, ft_int16_t y, ft_int16_t font, ft_uint16_t options, const ft_char8_t* s);
+ ft_void_t Number(ft_int16_t x, ft_int16_t y, ft_int16_t font, ft_uint16_t options, ft_int32_t n);
+ ft_void_t LoadIdentity();
+ ft_void_t Toggle(ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t font, ft_uint16_t options, ft_uint16_t state, const ft_char8_t* s);
+ ft_void_t Gauge(ft_int16_t x, ft_int16_t y, ft_int16_t r, ft_uint16_t options, ft_uint16_t major, ft_uint16_t minor, ft_uint16_t val, ft_uint16_t range);
+ ft_void_t RegRead(ft_uint32_t ptr, ft_uint32_t result);
+ ft_void_t GetProps(ft_uint32_t ptr, ft_uint32_t w, ft_uint32_t h);
+ ft_void_t Memcpy(ft_uint32_t dest, ft_uint32_t src, ft_uint32_t num);
+ ft_void_t Spinner(ft_int16_t x, ft_int16_t y, ft_uint16_t style, ft_uint16_t scale);
+ ft_void_t BgColor(ft_uint32_t c);
+ ft_void_t Swap();
+ ft_void_t Inflate(ft_uint32_t ptr);
+ ft_void_t Translate(ft_int32_t tx, ft_int32_t ty);
+ ft_void_t Stop();
+ ft_void_t Slider(ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_uint16_t options, ft_uint16_t val, ft_uint16_t range);
+ ft_void_t Interrupt(ft_uint32_t ms);
+ ft_void_t FgColor(ft_uint32_t c);
+ ft_void_t Rotate(ft_int32_t a);
+ ft_void_t Button(ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_int16_t font, ft_uint16_t options, const ft_char8_t* s);
+ ft_void_t MemWrite(ft_uint32_t ptr, ft_uint32_t num);
+ ft_void_t Scrollbar(ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_uint16_t options, ft_uint16_t val, ft_uint16_t size, ft_uint16_t range);
+ ft_void_t GetMatrix(ft_int32_t a, ft_int32_t b, ft_int32_t c, ft_int32_t d, ft_int32_t e, ft_int32_t f);
+ ft_void_t Sketch(ft_int16_t x, ft_int16_t y, ft_uint16_t w, ft_uint16_t h, ft_uint32_t ptr, ft_uint16_t format);
+ ft_void_t MemSet(ft_uint32_t ptr, ft_uint32_t value, ft_uint32_t num);
+ ft_void_t Calibrate(ft_uint32_t result);
+ ft_void_t SetFont(ft_uint32_t font, ft_uint32_t ptr);
+ ft_void_t Bitmap_Transform(ft_int32_t x0, ft_int32_t y0, ft_int32_t x1, ft_int32_t y1, ft_int32_t x2, ft_int32_t y2, ft_int32_t tx0, ft_int32_t ty0, ft_int32_t tx1, ft_int32_t ty1, ft_int32_t tx2, ft_int32_t ty2, ft_uint16_t result);
+ ft_void_t GradColor(ft_uint32_t c);
+ ft_void_t Append(ft_uint32_t ptr, ft_uint32_t num);
+ ft_void_t MemZero(ft_uint32_t ptr, ft_uint32_t num);
+ ft_void_t Scale(ft_int32_t sx, ft_int32_t sy);
+ ft_void_t Clock(ft_int16_t x, ft_int16_t y, ft_int16_t r, ft_uint16_t options, ft_uint16_t h, ft_uint16_t m, ft_uint16_t s, ft_uint16_t ms);
+ ft_void_t Gradient(ft_int16_t x0, ft_int16_t y0, ft_uint32_t rgb0, ft_int16_t x1, ft_int16_t y1, ft_uint32_t rgb1);
+ ft_void_t SetMatrix();
+ ft_void_t Track(ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_int16_t tag);
+ ft_void_t GetPtr(ft_uint32_t result);
+ ft_void_t Progress(ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_uint16_t options, ft_uint16_t val, ft_uint16_t range);
+ ft_void_t ColdStart();
+ ft_void_t Keys(ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_int16_t font, ft_uint16_t options, const ft_char8_t* s);
+ ft_void_t Dial(ft_int16_t x, ft_int16_t y, ft_int16_t r, ft_uint16_t options, ft_uint16_t val);
+ ft_void_t LoadImage(ft_uint32_t ptr, ft_uint32_t options);
+ ft_void_t DLstart();
+ ft_void_t Snapshot(ft_uint32_t ptr);
+ ft_void_t ScreenSaver();
+ ft_void_t Memcrc(ft_uint32_t ptr, ft_uint32_t num, ft_uint32_t result);
+
+ ft_void_t Logo();
+
+ ft_void_t SendCmd( ft_uint32_t cmd);
+ ft_void_t SendStr( const ft_char8_t *s);
+ ft_void_t StartFunc( ft_uint16_t count);
+ ft_void_t EndFunc( ft_uint16_t count);
+ ft_void_t TouchTransform( ft_int32_t x0, ft_int32_t y0, ft_int32_t x1, ft_int32_t y1, ft_int32_t x2, ft_int32_t y2, ft_int32_t tx0, ft_int32_t ty0, ft_int32_t tx1, ft_int32_t ty1, ft_int32_t tx2, ft_int32_t ty2, ft_uint16_t result);
+ ft_void_t BitmapTransform( ft_int32_t x0, ft_int32_t y0, ft_int32_t x1, ft_int32_t y1, ft_int32_t x2, ft_int32_t y2, ft_int32_t tx0, ft_int32_t ty0, ft_int32_t tx1, ft_int32_t ty1, ft_int32_t tx2, ft_int32_t ty2, ft_uint16_t result);
+ ft_void_t MemCrc( ft_uint32_t ptr, ft_uint32_t num, ft_uint32_t result);
+
+ ft_uint16_t fifo_Freespace( );
+
+ ft_void_t DL(ft_uint32_t cmd);
+ ft_void_t WrDlCmd_Buffer(ft_uint32_t cmd);
+ ft_void_t Flush_DL_Buffer();
+ ft_void_t Flush_Co_Buffer();
+ ft_void_t fadeout();
+ ft_void_t fadein();
+ ft_void_t DLSwap(ft_uint8_t DL_Swap_Type);
+
+ ft_void_t Sound_ON();
+ ft_void_t Sound_OFF();
+
+ int Load_jpg(char* filename, ft_int16_t* x_size, ft_int16_t* y_size,ft_uint32_t address);
+
+ //Curt added Load_raw 7/22/16
+ int Load_raw(char* filename);
+
+ ft_void_t Calibrate();
+ ft_void_t read_calibrate(ft_uint8_t data[24]);
+ ft_void_t write_calibrate(ft_uint8_t data[24]);
+
+ ft_uint32_t color_rgb(ft_uint8_t red,ft_uint8_t green, ft_uint8_t blue);
+ ft_uint32_t clear_color_rgb(ft_uint8_t red,ft_uint8_t green, ft_uint8_t blue);
+
+}; // end of class
+
+#endif /*FT_GPU_HAL_H*/
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/FT_Hal_Utils.h Wed Sep 07 21:53:53 2016 +0000 @@ -0,0 +1,24 @@ +/* mbed Library for FTDI FT800 Enbedded Video Engine "EVE" + * based on Original Code Sample from FTDI + * ported to mbed by Peter Drescher, DC2PD 2014 + * Released under the MIT License: http://mbed.org/license/mit */ + +#ifndef _FT_HAL_UTILS_H_ +#define _FT_HAL_UTILS_H_ + + +#define RGB(r, g, b) ((((vc_int32_t)(r)) << 16) | (((vc_int32_t)(g)) << 8) | (b)) +#define SQ(v) ((v) * (v)) +#define MIN(x,y) ((x) > (y) ? (y) : (x)) +#define MAX(x,y) ((x) > (y) ? (x) : (y)) +#define PLAYCOLOR 0x00A0A080 +#define NOTE(n, sharp) (((n) - 'C') + ((sharp) * 128)) +#define F16(s) ((vc_int32_t)((s) * 65536)) +#define INVALID_TOUCH_XY 0x8000 +#define ABS(x) ((x) > (0) ? (x) : (-x)) + +#endif /* _FT_HAL_UTILS_H_ */ + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/FT_LCD_Type.h Wed Sep 07 21:53:53 2016 +0000 @@ -0,0 +1,57 @@ +//this file modified by Curtis Mattull 7/21/16 +// to add support for beyondtek lcd screen + +//comment out line 12 unless using beyondtek + +/* mbed Library for FTDI FT810 Enbedded Video Engine "EVE" + * ported to mbed by David Childs, based on the great work of Peter Drescher (DC2PD 2014) + * Released under the MIT License: http://mbed.org/license/mit */ +// This is for the 800x480 screen that comes with the FTDI FT810 demo board + +//comment line 12 if not beyondtek display +#define beyondtek + +#ifndef FT_LCD_TYPE_H +#define FT_LCD_TYPE_H +/* Global variables for display resolution to support various display panels */ + +#ifdef beyondtek + +//added by curt +#define my_rotate 0x00 + +#define my_DispWidth 800 +#define my_DispHeight 480 +#define my_DispHCycle 862 +#define my_DispHOffset 46 +#define my_DispHSync0 0 +#define my_DispHSync1 1 +#define my_DispVCycle 510 +#define my_DispVOffset 23 +#define my_DispVSync0 0 +#define my_DispVSync1 1 +#define my_DispPCLK 1 +#define my_DispSwizzle 0 +#define my_DispPCLKPol 1 + +#else + +//added by curt +#define my_rotate 0x01 + +#define my_DispWidth 800 +#define my_DispHeight 480 +#define my_DispHCycle 1056 +#define my_DispHOffset 46 +#define my_DispHSync0 210 +#define my_DispHSync1 230 +#define my_DispVCycle 525 +#define my_DispVOffset 23 +#define my_DispVSync0 22 +#define my_DispVSync1 32 +#define my_DispPCLK 1 +#define my_DispSwizzle 0 +#define my_DispPCLKPol 1 + +#endif +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/FT_Platform.h Wed Sep 07 21:53:53 2016 +0000 @@ -0,0 +1,24 @@ +/* mbed Library for FTDI FT800 Enbedded Video Engine "EVE" + * based on Original Code Sample from FTDI + * ported to mbed by Peter Drescher, DC2PD 2014 + * Released under the MIT License: http://mbed.org/license/mit */ + +#ifndef _FT_PLATFORM_H_ +#define _FT_PLATFORM_H_ + +#include "FT_DataTypes.h" +#include "FT_Gpu_Hal.h" +#include "FT_Hal_Utils.h" +#include "FT_Gpu.h" +#include "FT_LCD_Type.h" +#include "FT_color.h" + + +#endif /*_FT_PLATFORM_H_*/ +/* Nothing beyond this*/ + + + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/FT_color.h Wed Sep 07 21:53:53 2016 +0000 @@ -0,0 +1,38 @@ +// color definitions for FT800 controler + +#define Red 255,0,0 +#define Pink 255,192,203 +#define DarkRed 139,0,0 +#define OrangeRed 255,69,0 +#define Orange 255,165,0 +#define Gold 255,215,0 +#define Yellow 255,255,0 +#define LightYellow 255,255,224 +#define Magenta 255,0,255 +#define Indigo 75,0,130 +#define SlateBlue 106,90,205 +#define Blue 0,0,255 +#define DarkBlue 0,0,139 +#define SkyBlue 135,206,235 +#define LightBlue 173,216,230 +#define White 255,255,255 +#define Black 0,0,0 +#define Gray 128,128,128 +#define DarkGray 169,169,169 +#define Silver 192,192,192 +#define Brown 165,42,42 +#define Green 0,128,0 +#define DarkGreen 0,100,0 +#define YellowGreen 154,205,50 +#define Olive 128,128,0 +#define Lime 0,255,0 +#define Purple 128,0,128 +#define Tomato 255,99,71 +#define Violet 235,130,238 +#define Plum 221,160,221 +#define GreenYellow 173,255,47 +#define Cyan 0,255,255 +#define Aquamarine 127,255,212 +#define LightGray 211,211,211 + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/FT_CoPro_Cmds.cpp Wed Sep 07 21:53:53 2016 +0000
@@ -0,0 +1,538 @@
+/* mbed Library for FTDI FT800 Enbedded Video Engine "EVE"
+ * based on Original Code Sample from FTDI
+ * ported to mbed by Peter Drescher, DC2PD 2014
+ * Released under the MIT License: http://mbed.org/license/mit */
+
+#include "FT_Platform.h"
+
+
+ft_void_t FT800::SendCmd( ft_uint32_t cmd)
+{
+ Transfer32( cmd);
+}
+
+ft_void_t FT800::SendStr( const ft_char8_t *s)
+{
+ TransferString( s);
+}
+
+
+ft_void_t FT800::StartFunc( ft_uint16_t count)
+{
+ CheckCmdBuffer( count);
+ StartCmdTransfer( FT_GPU_WRITE,count);
+}
+
+ft_void_t FT800::EndFunc( ft_uint16_t count)
+{
+ EndTransfer( );
+ Updatecmdfifo( count);
+}
+
+ft_void_t FT800::Text( ft_int16_t x, ft_int16_t y, ft_int16_t font, ft_uint16_t options, const ft_char8_t* s)
+{
+ StartFunc( FT_CMD_SIZE*3 + strlen(s) + 1);
+ SendCmd( CMD_TEXT);
+ //Copro_SendCmd( (((ft_uint32_t)y<<16)|(ft_uint32_t)x));
+ SendCmd( (((ft_uint32_t)y<<16)|(x & 0xffff)));
+ SendCmd( (((ft_uint32_t)options<<16)|(ft_uint32_t)font));
+ SendStr( s);
+ EndFunc( (FT_CMD_SIZE*3 + strlen(s) + 1));
+}
+
+ft_void_t FT800::Number( ft_int16_t x, ft_int16_t y, ft_int16_t font, ft_uint16_t options, ft_int32_t n)
+{
+ StartFunc( FT_CMD_SIZE*4);
+ SendCmd( CMD_NUMBER);
+ SendCmd( (((ft_uint32_t)y<<16)|(x & 0xffff)));
+ SendCmd( (((ft_uint32_t)options<<16)|font));
+ SendCmd( n);
+ EndFunc( (FT_CMD_SIZE*4));
+}
+
+ft_void_t FT800::LoadIdentity( )
+{
+ StartFunc( FT_CMD_SIZE*1);
+ SendCmd( CMD_LOADIDENTITY);
+ EndFunc( (FT_CMD_SIZE*1));
+}
+
+ft_void_t FT800::Toggle( ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t font, ft_uint16_t options, ft_uint16_t state, const ft_char8_t* s)
+{
+ StartFunc( FT_CMD_SIZE*4 + strlen(s) + 1);
+ SendCmd( CMD_TOGGLE);
+ SendCmd( (((ft_uint32_t)y<<16)|(x & 0xffff)));
+ SendCmd( (((ft_uint32_t)font<<16)|w));
+ SendCmd( (((ft_uint32_t)state<<16)|options));
+ SendStr( s);
+ EndFunc( (FT_CMD_SIZE*4 + strlen(s) + 1));
+}
+
+/* Error handling for val is not done, so better to always use range of 65535 in order that needle is drawn within display region */
+ft_void_t FT800::Gauge( ft_int16_t x, ft_int16_t y, ft_int16_t r, ft_uint16_t options, ft_uint16_t major, ft_uint16_t minor, ft_uint16_t val, ft_uint16_t range)
+{
+ StartFunc( FT_CMD_SIZE*5);
+ SendCmd( CMD_GAUGE);
+ SendCmd( (((ft_uint32_t)y<<16)|(x & 0xffff)));
+ SendCmd( (((ft_uint32_t)options<<16)|r));
+ SendCmd( (((ft_uint32_t)minor<<16)|major));
+ SendCmd( (((ft_uint32_t)range<<16)|val));
+ EndFunc( (FT_CMD_SIZE*5));
+}
+
+ft_void_t FT800::RegRead( ft_uint32_t ptr, ft_uint32_t result)
+{
+ StartFunc( FT_CMD_SIZE*3);
+ SendCmd( CMD_REGREAD);
+ SendCmd( ptr);
+ SendCmd( 0);
+ EndFunc( (FT_CMD_SIZE*3));
+
+}
+
+ft_void_t FT800::GetProps( ft_uint32_t ptr, ft_uint32_t w, ft_uint32_t h)
+{
+ StartFunc( FT_CMD_SIZE*4);
+ SendCmd( CMD_GETPROPS);
+ SendCmd( ptr);
+ SendCmd( w);
+ SendCmd( h);
+ EndFunc( (FT_CMD_SIZE*4));
+}
+
+ft_void_t FT800::Memcpy( ft_uint32_t dest, ft_uint32_t src, ft_uint32_t num)
+{
+ StartFunc( FT_CMD_SIZE*4);
+ SendCmd( CMD_MEMCPY);
+ SendCmd( dest);
+ SendCmd( src);
+ SendCmd( num);
+ EndFunc( (FT_CMD_SIZE*4));
+}
+
+ft_void_t FT800::Spinner( ft_int16_t x, ft_int16_t y, ft_uint16_t style, ft_uint16_t scale)
+{
+ StartFunc( FT_CMD_SIZE*3);
+ SendCmd( CMD_SPINNER);
+ SendCmd( (((ft_uint32_t)y<<16)|(x & 0xffff)));
+ SendCmd( (((ft_uint32_t)scale<<16)|style));
+ EndFunc( (FT_CMD_SIZE*3));
+}
+
+ft_void_t FT800::BgColor( ft_uint32_t c)
+{
+ StartFunc( FT_CMD_SIZE*2);
+ SendCmd( CMD_BGCOLOR);
+ SendCmd( c);
+ EndFunc( (FT_CMD_SIZE*2));
+}
+
+ft_void_t FT800::Swap()
+{
+ StartFunc( FT_CMD_SIZE*1);
+ SendCmd( CMD_SWAP);
+ EndFunc( (FT_CMD_SIZE*1));
+}
+
+ft_void_t FT800::Inflate( ft_uint32_t ptr)
+{
+ StartFunc( FT_CMD_SIZE*2);
+ SendCmd( CMD_INFLATE);
+ SendCmd( ptr);
+ EndFunc( (FT_CMD_SIZE*2));
+}
+
+ft_void_t FT800::Translate( ft_int32_t tx, ft_int32_t ty)
+{
+ StartFunc( FT_CMD_SIZE*3);
+ SendCmd( CMD_TRANSLATE);
+ SendCmd( tx);
+ SendCmd( ty);
+ EndFunc( (FT_CMD_SIZE*3));
+}
+
+ft_void_t FT800::Stop()
+{
+ StartFunc( FT_CMD_SIZE*1);
+ SendCmd( CMD_STOP);
+ EndFunc( (FT_CMD_SIZE*1));
+}
+
+ft_void_t FT800::Slider( ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_uint16_t options, ft_uint16_t val, ft_uint16_t range)
+{
+ StartFunc( FT_CMD_SIZE*5);
+ SendCmd( CMD_SLIDER);
+ SendCmd( (((ft_uint32_t)y<<16)|(x & 0xffff)));
+ SendCmd( (((ft_uint32_t)h<<16)|w));
+ SendCmd( (((ft_uint32_t)val<<16)|options));
+ SendCmd( range);
+ EndFunc( (FT_CMD_SIZE*5));
+}
+
+ft_void_t FT800::TouchTransform( ft_int32_t x0, ft_int32_t y0, ft_int32_t x1, ft_int32_t y1, ft_int32_t x2, ft_int32_t y2, ft_int32_t tx0, ft_int32_t ty0, ft_int32_t tx1, ft_int32_t ty1, ft_int32_t tx2, ft_int32_t ty2, ft_uint16_t result)
+{
+ StartFunc( FT_CMD_SIZE*6*2+FT_CMD_SIZE*2);
+ SendCmd( CMD_TOUCH_TRANSFORM);
+ SendCmd( x0);
+ SendCmd( y0);
+ SendCmd( x1);
+ SendCmd( y1);
+ SendCmd( x2);
+ SendCmd( y2);
+ SendCmd( tx0);
+ SendCmd( ty0);
+ SendCmd( tx1);
+ SendCmd( ty1);
+ SendCmd( tx2);
+ SendCmd( ty2);
+ SendCmd( result);
+ EndFunc( (FT_CMD_SIZE*6*2+FT_CMD_SIZE*2));
+}
+
+ft_void_t FT800::Interrupt( ft_uint32_t ms)
+{
+ StartFunc( FT_CMD_SIZE*2);
+ SendCmd( CMD_INTERRUPT);
+ SendCmd( ms);
+ EndFunc( (FT_CMD_SIZE*2));
+}
+
+ft_void_t FT800::FgColor( ft_uint32_t c)
+{
+ StartFunc( FT_CMD_SIZE*2);
+ SendCmd( CMD_FGCOLOR);
+ SendCmd( c);
+ EndFunc( (FT_CMD_SIZE*2));
+}
+
+ft_void_t FT800::Rotate( ft_int32_t a)
+{
+ StartFunc( FT_CMD_SIZE*2);
+ SendCmd( CMD_ROTATE);
+ SendCmd( a);
+ EndFunc( (FT_CMD_SIZE*2));
+}
+
+ft_void_t FT800::Button( ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_int16_t font, ft_uint16_t options, const ft_char8_t* s)
+{
+ StartFunc( FT_CMD_SIZE*4 + strlen(s) + 1);
+ SendCmd( CMD_BUTTON);
+ SendCmd( (((ft_uint32_t)y<<16)|(x & 0xffff)));
+ SendCmd( (((ft_uint32_t)h<<16)|w));
+ SendCmd( (((ft_uint32_t)options<<16)|font)); // patch from Ivano Pelicella to draw flat buttons
+ SendStr( s);
+ EndFunc( (FT_CMD_SIZE*4 + strlen(s) + 1));
+}
+
+ft_void_t FT800::MemWrite( ft_uint32_t ptr, ft_uint32_t num)
+{
+ StartFunc( FT_CMD_SIZE*3);
+ SendCmd( CMD_MEMWRITE);
+ SendCmd( ptr);
+ SendCmd( num);
+ EndFunc( (FT_CMD_SIZE*3));
+}
+
+ft_void_t FT800::Scrollbar( ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_uint16_t options, ft_uint16_t val, ft_uint16_t size, ft_uint16_t range)
+{
+ StartFunc( FT_CMD_SIZE*5);
+ SendCmd( CMD_SCROLLBAR);
+ SendCmd( (((ft_uint32_t)y<<16)|(x & 0xffff)));
+ SendCmd( (((ft_uint32_t)h<<16)|w));
+ SendCmd( (((ft_uint32_t)val<<16)|options));
+ SendCmd( (((ft_uint32_t)range<<16)|size));
+ EndFunc( (FT_CMD_SIZE*5));
+}
+
+ft_void_t FT800::GetMatrix( ft_int32_t a, ft_int32_t b, ft_int32_t c, ft_int32_t d, ft_int32_t e, ft_int32_t f)
+{
+ StartFunc( FT_CMD_SIZE*7);
+ SendCmd( CMD_GETMATRIX);
+ SendCmd( a);
+ SendCmd( b);
+ SendCmd( c);
+ SendCmd( d);
+ SendCmd( e);
+ SendCmd( f);
+ EndFunc( (FT_CMD_SIZE*7));
+}
+
+ft_void_t FT800::Sketch( ft_int16_t x, ft_int16_t y, ft_uint16_t w, ft_uint16_t h, ft_uint32_t ptr, ft_uint16_t format)
+{
+ StartFunc( FT_CMD_SIZE*5);
+ SendCmd( CMD_SKETCH);
+ SendCmd( (((ft_uint32_t)y<<16)|(x & 0xffff)));
+ SendCmd( (((ft_uint32_t)h<<16)|w));
+ SendCmd( ptr);
+ SendCmd( format);
+ EndFunc( (FT_CMD_SIZE*5));
+}
+ft_void_t FT800::MemSet( ft_uint32_t ptr, ft_uint32_t value, ft_uint32_t num)
+{
+ StartFunc( FT_CMD_SIZE*4);
+ SendCmd( CMD_MEMSET);
+ SendCmd( ptr);
+ SendCmd( value);
+ SendCmd( num);
+ EndFunc( (FT_CMD_SIZE*4));
+}
+ft_void_t FT800::GradColor( ft_uint32_t c)
+{
+ StartFunc( FT_CMD_SIZE*2);
+ SendCmd( CMD_GRADCOLOR);
+ SendCmd( c);
+ EndFunc( (FT_CMD_SIZE*2));
+}
+ft_void_t FT800::BitmapTransform( ft_int32_t x0, ft_int32_t y0, ft_int32_t x1, ft_int32_t y1, ft_int32_t x2, ft_int32_t y2, ft_int32_t tx0, ft_int32_t ty0, ft_int32_t tx1, ft_int32_t ty1, ft_int32_t tx2, ft_int32_t ty2, ft_uint16_t result)
+{
+ StartFunc( FT_CMD_SIZE*6*2+FT_CMD_SIZE*2);
+ SendCmd( CMD_BITMAP_TRANSFORM);
+ SendCmd( x0);
+ SendCmd( y0);
+ SendCmd( x1);
+ SendCmd( y1);
+ SendCmd( x2);
+ SendCmd( y2);
+ SendCmd( tx0);
+ SendCmd( ty0);
+ SendCmd( tx1);
+ SendCmd( ty1);
+ SendCmd( tx2);
+ SendCmd( ty2);
+ SendCmd( result);
+ EndFunc( (FT_CMD_SIZE*6*2+FT_CMD_SIZE*2));
+}
+ft_void_t FT800::Calibrate( ft_uint32_t result)
+{
+ StartFunc( FT_CMD_SIZE*2);
+ SendCmd( CMD_CALIBRATE);
+ SendCmd( result);
+ EndFunc( (FT_CMD_SIZE*2));
+ WaitCmdfifo_empty( );
+
+}
+ft_void_t FT800::SetFont( ft_uint32_t font, ft_uint32_t ptr)
+{
+ StartFunc( FT_CMD_SIZE*3);
+ SendCmd( CMD_SETFONT);
+ SendCmd( font);
+ SendCmd( ptr);
+ EndFunc( (FT_CMD_SIZE*3));
+}
+ft_void_t FT800::Logo( )
+{
+ StartFunc( FT_CMD_SIZE*1);
+ SendCmd( CMD_LOGO);
+ EndFunc( FT_CMD_SIZE*1);
+}
+ft_void_t FT800::Append( ft_uint32_t ptr, ft_uint32_t num)
+{
+ StartFunc( FT_CMD_SIZE*3);
+ SendCmd( CMD_APPEND);
+ SendCmd( ptr);
+ SendCmd( num);
+ EndFunc( (FT_CMD_SIZE*3));
+}
+ft_void_t FT800::MemZero( ft_uint32_t ptr, ft_uint32_t num)
+{
+ StartFunc( FT_CMD_SIZE*3);
+ SendCmd( CMD_MEMZERO);
+ SendCmd( ptr);
+ SendCmd( num);
+ EndFunc( (FT_CMD_SIZE*3));
+}
+ft_void_t FT800::Scale( ft_int32_t sx, ft_int32_t sy)
+{
+ StartFunc( FT_CMD_SIZE*3);
+ SendCmd( CMD_SCALE);
+ SendCmd( sx);
+ SendCmd( sy);
+ EndFunc( (FT_CMD_SIZE*3));
+}
+ft_void_t FT800::Clock( ft_int16_t x, ft_int16_t y, ft_int16_t r, ft_uint16_t options, ft_uint16_t h, ft_uint16_t m, ft_uint16_t s, ft_uint16_t ms)
+{
+ StartFunc( FT_CMD_SIZE*5);
+ SendCmd( CMD_CLOCK);
+ SendCmd( (((ft_uint32_t)y<<16)|(x & 0xffff)));
+ SendCmd( (((ft_uint32_t)options<<16)|r));
+ SendCmd( (((ft_uint32_t)m<<16)|h));
+ SendCmd( (((ft_uint32_t)ms<<16)|s));
+ EndFunc( (FT_CMD_SIZE*5));
+}
+
+ft_void_t FT800::Gradient( ft_int16_t x0, ft_int16_t y0, ft_uint32_t rgb0, ft_int16_t x1, ft_int16_t y1, ft_uint32_t rgb1)
+{
+ StartFunc( FT_CMD_SIZE*5);
+ SendCmd( CMD_GRADIENT);
+ SendCmd( (((ft_uint32_t)y0<<16)|(x0 & 0xffff)));
+ SendCmd( rgb0);
+ SendCmd( (((ft_uint32_t)y1<<16)|(x1 & 0xffff)));
+ SendCmd( rgb1);
+ EndFunc( (FT_CMD_SIZE*5));
+}
+
+ft_void_t FT800::SetMatrix( )
+{
+ StartFunc( FT_CMD_SIZE*1);
+ SendCmd( CMD_SETMATRIX);
+ EndFunc( (FT_CMD_SIZE*1));
+}
+
+ft_void_t FT800::Track( ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_int16_t tag)
+{
+ StartFunc( FT_CMD_SIZE*4);
+ SendCmd( CMD_TRACK);
+ SendCmd( (((ft_uint32_t)y<<16)|(x & 0xffff)));
+ SendCmd( (((ft_uint32_t)h<<16)|w));
+ SendCmd( tag);
+ EndFunc( (FT_CMD_SIZE*4));
+}
+
+ft_void_t FT800::GetPtr( ft_uint32_t result)
+{
+ StartFunc( FT_CMD_SIZE*2);
+ SendCmd( CMD_GETPTR);
+ SendCmd( result);
+ EndFunc( (FT_CMD_SIZE*2));
+}
+
+ft_void_t FT800::Progress( ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_uint16_t options, ft_uint16_t val, ft_uint16_t range)
+{
+ StartFunc( FT_CMD_SIZE*5);
+ SendCmd( CMD_PROGRESS);
+ SendCmd( (((ft_uint32_t)y<<16)|(x & 0xffff)));
+ SendCmd( (((ft_uint32_t)h<<16)|w));
+ SendCmd( (((ft_uint32_t)val<<16)|options));
+ SendCmd( range);
+ EndFunc( (FT_CMD_SIZE*5));
+}
+
+ft_void_t FT800::ColdStart( )
+{
+ StartFunc( FT_CMD_SIZE*1);
+ SendCmd( CMD_COLDSTART);
+ EndFunc( (FT_CMD_SIZE*1));
+}
+
+ft_void_t FT800::Keys( ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_int16_t font, ft_uint16_t options, const ft_char8_t* s)
+{
+ StartFunc( FT_CMD_SIZE*4 + strlen(s) + 1);
+ SendCmd( CMD_KEYS);
+ SendCmd( (((ft_uint32_t)y<<16)|(x & 0xffff)));
+ SendCmd( (((ft_uint32_t)h<<16)|w));
+ SendCmd( (((ft_uint32_t)options<<16)|font));
+ SendStr( s);
+ EndFunc( (FT_CMD_SIZE*4 + strlen(s) + 1));
+}
+
+ft_void_t FT800::Dial( ft_int16_t x, ft_int16_t y, ft_int16_t r, ft_uint16_t options, ft_uint16_t val)
+{
+ StartFunc( FT_CMD_SIZE*4);
+ SendCmd( CMD_DIAL);
+ SendCmd( (((ft_uint32_t)y<<16)|(x & 0xffff)));
+ SendCmd( (((ft_uint32_t)options<<16)|r));
+ SendCmd( val);
+ EndFunc( (FT_CMD_SIZE*4));
+}
+
+ft_void_t FT800::LoadImage( ft_uint32_t ptr, ft_uint32_t options)
+{
+ StartFunc( FT_CMD_SIZE*3);
+ SendCmd( CMD_LOADIMAGE);
+ SendCmd( ptr);
+ SendCmd( options);
+ EndFunc( (FT_CMD_SIZE*3));
+}
+
+ft_void_t FT800::DLstart( )
+{
+ StartFunc( FT_CMD_SIZE*1);
+ SendCmd( CMD_DLSTART);
+ EndFunc( (FT_CMD_SIZE*1));
+}
+
+ft_void_t FT800::Snapshot( ft_uint32_t ptr)
+{
+ StartFunc( FT_CMD_SIZE*2);
+ SendCmd( CMD_SNAPSHOT);
+ SendCmd( ptr);
+ EndFunc( (FT_CMD_SIZE*2));
+}
+
+ft_void_t FT800::ScreenSaver( )
+{
+ StartFunc( FT_CMD_SIZE*1);
+ SendCmd( CMD_SCREENSAVER);
+ EndFunc( (FT_CMD_SIZE*1));
+}
+
+ft_void_t FT800::MemCrc( ft_uint32_t ptr, ft_uint32_t num, ft_uint32_t result)
+{
+ StartFunc( FT_CMD_SIZE*4);
+ SendCmd( CMD_MEMCRC);
+ SendCmd( ptr);
+ SendCmd( num);
+ SendCmd( result);
+ EndFunc( (FT_CMD_SIZE*4));
+}
+
+
+ft_void_t FT800::DL(ft_uint32_t cmd)
+{
+ WrCmd32(cmd);
+ /* Increment the command index */
+ CmdBuffer_Index += FT_CMD_SIZE;
+}
+
+ft_void_t FT800::WrDlCmd_Buffer(ft_uint32_t cmd)
+{
+ Wr32((RAM_DL+DlBuffer_Index),cmd);
+ /* Increment the command index */
+ DlBuffer_Index += FT_CMD_SIZE;
+}
+
+ft_void_t FT800::Flush_DL_Buffer()
+{
+ DlBuffer_Index = 0;
+
+}
+
+ft_void_t FT800::Flush_Co_Buffer()
+{
+ CmdBuffer_Index = 0;
+}
+
+
+/* API to check the status of previous DLSWAP and perform DLSWAP of new DL */
+/* Check for the status of previous DLSWAP and if still not done wait for few ms and check again */
+ft_void_t FT800::DLSwap(ft_uint8_t DL_Swap_Type)
+{
+ ft_uint8_t Swap_Type = DLSWAP_FRAME,Swap_Done = DLSWAP_FRAME;
+
+ if(DL_Swap_Type == DLSWAP_LINE)
+ {
+ Swap_Type = DLSWAP_LINE;
+ }
+
+ /* Perform a new DL swap */
+ Wr8(REG_DLSWAP,Swap_Type);
+
+ /* Wait till the swap is done */
+ while(Swap_Done)
+ {
+ Swap_Done = Rd8(REG_DLSWAP);
+
+ if(DLSWAP_DONE != Swap_Done)
+ {
+ Sleep(10);//wait for 10ms
+ }
+ }
+}
+
+
+
+/* Nothing beyond this */
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/FT_GPU_Hal.cpp Wed Sep 07 21:53:53 2016 +0000
@@ -0,0 +1,560 @@
+/* mbed Library for FTDI FT800 Enbedded Video Engine "EVE"
+ * based on Original Code Sample from FTDI
+ * ported to mbed by Peter Drescher, DC2PD 2014
+ * Released under the MIT License: http://mbed.org/license/mit
+ * 19.09.14 changed to shorter function names
+ * FTDI was using very long names.
+ * Ft_App_Flush_Co_Buffer -> Flush_Co_Buffer ... */
+
+#include "FT_Platform.h"
+#include "mbed.h"
+#include "FT_LCD_Type.h"
+Serial pc(USBTX, USBRX);
+
+FT800::FT800(PinName mosi,
+ PinName miso,
+ PinName sck,
+ PinName ss,
+ PinName intr,
+ PinName pd)
+ :
+ _spi(mosi, miso, sck),
+ _ss(ss),
+ _pd(pd),
+ _f800_isr(InterruptIn(intr))
+ {
+ _spi.format(8,0); // 8 bit spi mode 0
+ _spi.frequency(1000000); // start with 10 Mhz SPI clock
+ _ss = 1; // cs high
+ _pd = 1; // PD high
+ Bootup();
+ }
+
+
+ft_bool_t FT800::Bootup(void){
+ Open();
+ BootupConfig();
+
+ return(1);
+ }
+
+
+ft_void_t FT800::BootupConfig(void){
+ ft_uint8_t chipid;
+ /* Do a power cycle for safer side */
+ Powercycle( FT_TRUE);
+ /*
+ 7/8/16: Curt added the sleep delay below...
+ */
+// Sleep(30);
+
+ /* Set the clk to external clock */
+ HostCommand( FT_GPU_EXTERNAL_OSC);
+ Sleep(10);
+
+ /* Access address 0 to wake up the FT800 */
+ HostCommand( FT_GPU_ACTIVE_M);
+ Sleep(500);
+
+ /* Switch PLL output to 48MHz */
+// HostCommand( FT_GPU_PLL_48M);
+ Sleep(10);
+
+ /* Do a core reset for safer side */
+ HostCommand( FT_GPU_CORE_RESET);
+ Sleep(500);
+ //Read Register ID to check if FT800 is ready.
+ chipid = Rd8( REG_ID);
+// chipid = Rd8(0x0C0000);
+ pc.printf("ID%08X\n", chipid);
+ while(chipid != 0x7C)
+
+
+ // Speed up
+ _spi.frequency(20000000); // 20 Mhz SPI clock DC
+// _spi.frequency(12000000); // 12 Mhz SPI clock
+ /* Configuration of LCD display */
+ DispHCycle = my_DispHCycle;
+ Wr16( REG_HCYCLE, DispHCycle);
+ DispHOffset = my_DispHOffset;
+ Wr16( REG_HOFFSET, DispHOffset);
+ DispWidth = my_DispWidth;
+ Wr16( REG_HSIZE, DispWidth);
+ DispHSync0 = my_DispHSync0;
+ Wr16( REG_HSYNC0, DispHSync0);
+ DispHSync1 = my_DispHSync1;
+ Wr16( REG_HSYNC1, DispHSync1);
+ DispVCycle = my_DispVCycle;
+ Wr16( REG_VCYCLE, DispVCycle);
+ DispVOffset = my_DispVOffset;
+ Wr16( REG_VOFFSET, DispVOffset);
+ DispHeight = my_DispHeight;
+ Wr16( REG_VSIZE, DispHeight);
+ DispVSync0 = my_DispVSync0;
+ Wr16( REG_VSYNC0, DispVSync0);
+ DispVSync1 = my_DispVSync1;
+ Wr16( REG_VSYNC1, DispVSync1);
+ DispSwizzle = my_DispSwizzle;
+ Wr8( REG_SWIZZLE, DispSwizzle);
+ DispPCLKPol = my_DispPCLKPol;
+ Wr8( REG_PCLK_POL, DispPCLKPol);
+ Wr8( REG_CSPREAD, 0);
+ DispPCLK = my_DispPCLK;
+ Wr8( REG_PCLK, DispPCLK);//after this display is visible on the LCD
+
+ Wr16( REG_PWM_HZ, 10000);
+
+#ifdef Inv_Backlite // turn on backlite
+ Wr16( REG_PWM_DUTY, 0);
+#else
+ Wr16( REG_PWM_DUTY, 100);
+#endif
+
+ Wr8( REG_GPIO_DIR,0x82); //| Rd8( REG_GPIO_DIR));
+ Wr8( REG_GPIO,0x080); //| Rd8( REG_GPIO));
+
+ Wr32( RAM_DL, CLEAR(1,1,1));
+ Wr32( RAM_DL+4, DISPLAY());
+ Wr32( REG_DLSWAP,1);
+
+ Wr16( REG_PCLK, DispPCLK);
+
+ /* Touch configuration - configure the resistance value to 1200 - this value is specific to customer requirement and derived by experiment */
+ Wr16( REG_TOUCH_RZTHRESH,2400);
+
+}
+
+
+
+/* API to initialize the SPI interface */
+ft_bool_t FT800::Init()
+{
+ // is done in constructor
+ return 1;
+}
+
+
+ft_bool_t FT800::Open()
+{
+ cmd_fifo_wp = dl_buff_wp = 0;
+ status = OPENED;
+ return 1;
+}
+
+ft_void_t FT800::Close( )
+{
+ status = CLOSED;
+}
+
+ft_void_t FT800::DeInit()
+{
+
+}
+
+/*The APIs for reading/writing transfer continuously only with small buffer system*/
+ft_void_t FT800::StartTransfer( FT_GPU_TRANSFERDIR_T rw,ft_uint32_t addr)
+{
+ if (FT_GPU_READ == rw){
+ _ss = 0; // cs low
+ _spi.write(addr >> 16);
+ _spi.write(addr >> 8);
+ _spi.write(addr & 0xff);
+ _spi.write(0); //Dummy Read Byte
+ status = READING;
+ }else{
+ _ss = 0; // cs low
+ _spi.write(0x80 | (addr >> 16));
+ _spi.write(addr >> 8);
+ _spi.write(addr & 0xff);
+ status = WRITING;
+ }
+}
+
+
+/*The APIs for writing transfer continuously only*/
+ft_void_t FT800::StartCmdTransfer( FT_GPU_TRANSFERDIR_T rw, ft_uint16_t count)
+{
+ StartTransfer( rw, cmd_fifo_wp + RAM_CMD);
+}
+
+ft_uint8_t FT800::TransferString( const ft_char8_t *string)
+{
+ ft_uint16_t length = strlen(string);
+ while(length --){
+ Transfer8( *string);
+ string ++;
+ }
+ //Append one null as ending flag
+ Transfer8( 0);
+ return(1);
+}
+
+
+ft_uint8_t FT800::Transfer8( ft_uint8_t value)
+{
+ return _spi.write(value);
+}
+
+
+ft_uint16_t FT800::Transfer16( ft_uint16_t value)
+{
+ ft_uint16_t retVal = 0;
+
+ if (status == WRITING){
+ Transfer8( value & 0xFF);//LSB first
+ Transfer8( (value >> 8) & 0xFF);
+ }else{
+ retVal = Transfer8( 0);
+ retVal |= (ft_uint16_t)Transfer8( 0) << 8;
+ }
+
+ return retVal;
+}
+
+ft_uint32_t FT800::Transfer32( ft_uint32_t value)
+{
+ ft_uint32_t retVal = 0;
+ if (status == WRITING){
+ Transfer16( value & 0xFFFF);//LSB first
+ Transfer16( (value >> 16) & 0xFFFF);
+ }else{
+ retVal = Transfer16( 0);
+ retVal |= (ft_uint32_t)Transfer16( 0) << 16;
+ }
+ return retVal;
+}
+
+ft_void_t FT800::EndTransfer( )
+{
+ _ss = 1;
+ status = OPENED;
+}
+
+
+ft_uint8_t FT800::Rd8( ft_uint32_t addr)
+{
+ ft_uint8_t value;
+ StartTransfer( FT_GPU_READ,addr);
+ value = Transfer8( 0);
+ EndTransfer( );
+ return value;
+}
+ft_uint16_t FT800::Rd16( ft_uint32_t addr)
+{
+ ft_uint16_t value;
+ StartTransfer( FT_GPU_READ,addr);
+ value = Transfer16( 0);
+ EndTransfer( );
+ return value;
+}
+ft_uint32_t FT800::Rd32( ft_uint32_t addr)
+{
+ ft_uint32_t value;
+ StartTransfer( FT_GPU_READ,addr);
+ value = Transfer32( 0);
+ EndTransfer( );
+ return value;
+}
+
+ft_void_t FT800::Wr8( ft_uint32_t addr, ft_uint8_t v)
+{
+ StartTransfer( FT_GPU_WRITE,addr);
+ Transfer8( v);
+ EndTransfer( );
+}
+ft_void_t FT800::Wr16( ft_uint32_t addr, ft_uint16_t v)
+{
+ StartTransfer( FT_GPU_WRITE,addr);
+ Transfer16( v);
+ EndTransfer( );
+}
+ft_void_t FT800::Wr32( ft_uint32_t addr, ft_uint32_t v)
+{
+ StartTransfer( FT_GPU_WRITE,addr);
+ Transfer32( v);
+ EndTransfer( );
+}
+
+ft_void_t FT800::HostCommand( ft_uint8_t cmd)
+{
+ _ss = 0;
+ _spi.write(cmd);
+ _spi.write(0);
+ _spi.write(0);
+ _ss = 1;
+}
+
+ft_void_t FT800::ClockSelect( FT_GPU_PLL_SOURCE_T pllsource)
+{
+ HostCommand( pllsource);
+}
+
+ft_void_t FT800::PLL_FreqSelect( FT_GPU_PLL_FREQ_T freq)
+{
+ HostCommand( freq);
+}
+
+ft_void_t FT800::PowerModeSwitch( FT_GPU_POWER_MODE_T pwrmode)
+{
+ HostCommand( pwrmode);
+}
+
+ft_void_t FT800::CoreReset( )
+{
+ HostCommand( 0x68);
+}
+
+
+ft_void_t FT800::Updatecmdfifo( ft_uint16_t count)
+{
+ cmd_fifo_wp = ( cmd_fifo_wp + count) & 4095;
+ //4 byte alignment
+ cmd_fifo_wp = ( cmd_fifo_wp + 3) & 0xffc;
+ Wr16( REG_CMD_WRITE, cmd_fifo_wp);
+}
+
+
+ft_uint16_t FT800::fifo_Freespace( )
+{
+ ft_uint16_t fullness,retval;
+
+ fullness = ( cmd_fifo_wp - Rd16( REG_CMD_READ)) & 4095;
+ retval = (FT_CMD_FIFO_SIZE - 4) - fullness;
+ return (retval);
+}
+
+ft_void_t FT800::WrCmdBuf( ft_uint8_t *buffer,ft_uint16_t count)
+{
+ ft_uint32_t length =0, SizeTransfered = 0;
+
+#define MAX_CMD_FIFO_TRANSFER fifo_Freespace( )
+ do {
+ length = count;
+ if (length > MAX_CMD_FIFO_TRANSFER){
+ length = MAX_CMD_FIFO_TRANSFER;
+ }
+ CheckCmdBuffer( length);
+
+ StartCmdTransfer( FT_GPU_WRITE,length);
+
+ SizeTransfered = 0;
+ while (length--) {
+ Transfer8( *buffer);
+ buffer++;
+ SizeTransfered ++;
+ }
+ length = SizeTransfered;
+
+ EndTransfer( );
+ Updatecmdfifo( length);
+
+ WaitCmdfifo_empty( );
+
+ count -= length;
+ }while (count > 0);
+}
+
+
+ft_void_t FT800::WrCmdBufFromFlash( FT_PROGMEM ft_prog_uchar8_t *buffer,ft_uint16_t count)
+{
+ ft_uint32_t length =0, SizeTransfered = 0;
+
+#define MAX_CMD_FIFO_TRANSFER fifo_Freespace( )
+ do {
+ length = count;
+ if (length > MAX_CMD_FIFO_TRANSFER){
+ length = MAX_CMD_FIFO_TRANSFER;
+ }
+ CheckCmdBuffer( length);
+
+ StartCmdTransfer( FT_GPU_WRITE,length);
+
+
+ SizeTransfered = 0;
+ while (length--) {
+ Transfer8( ft_pgm_read_byte_near(buffer));
+ buffer++;
+ SizeTransfered ++;
+ }
+ length = SizeTransfered;
+
+ EndTransfer( );
+ Updatecmdfifo( length);
+
+ WaitCmdfifo_empty( );
+
+ count -= length;
+ }while (count > 0);
+}
+
+
+ft_void_t FT800::CheckCmdBuffer( ft_uint16_t count)
+{
+ ft_uint16_t getfreespace;
+ do{
+ getfreespace = fifo_Freespace( );
+ }while(getfreespace < count);
+}
+
+ft_void_t FT800::WaitCmdfifo_empty( )
+{
+ while(Rd16( REG_CMD_READ) != Rd16( REG_CMD_WRITE));
+
+ cmd_fifo_wp = Rd16( REG_CMD_WRITE);
+}
+
+ft_void_t FT800::WaitLogo_Finish( )
+{
+ ft_int16_t cmdrdptr,cmdwrptr;
+
+ do{
+ cmdrdptr = Rd16( REG_CMD_READ);
+ cmdwrptr = Rd16( REG_CMD_WRITE);
+ }while ((cmdwrptr != cmdrdptr) || (cmdrdptr != 0));
+ cmd_fifo_wp = 0;
+}
+
+
+ft_void_t FT800::ResetCmdFifo( )
+{
+ cmd_fifo_wp = 0;
+}
+
+
+ft_void_t FT800::WrCmd32( ft_uint32_t cmd)
+{
+ CheckCmdBuffer( sizeof(cmd));
+
+ Wr32( RAM_CMD + cmd_fifo_wp,cmd);
+
+ Updatecmdfifo( sizeof(cmd));
+}
+
+
+ft_void_t FT800::ResetDLBuffer( )
+{
+ dl_buff_wp = 0;
+}
+
+/* Toggle PD_N pin of FT800 board for a power cycle*/
+ft_void_t FT800::Powercycle( ft_bool_t up)
+{
+ if (up)
+ {
+ //Toggle PD_N from low to high for power up switch
+ _pd = 0;
+ Sleep(20);
+
+ _pd = 1;
+ Sleep(20);
+ }else
+ {
+ //Toggle PD_N from high to low for power down switch
+ _pd = 1;
+ Sleep(20);
+
+ _pd = 0;
+ Sleep(20);
+ }
+}
+
+ft_void_t FT800::WrMemFromFlash( ft_uint32_t addr,const ft_prog_uchar8_t *buffer, ft_uint32_t length)
+{
+ //ft_uint32_t SizeTransfered = 0;
+
+ StartTransfer( FT_GPU_WRITE,addr);
+
+ while (length--) {
+ Transfer8( ft_pgm_read_byte_near(buffer));
+ buffer++;
+ }
+
+ EndTransfer( );
+}
+
+ft_void_t FT800::WrMem( ft_uint32_t addr,const ft_uint8_t *buffer, ft_uint32_t length)
+{
+ //ft_uint32_t SizeTransfered = 0;
+
+ StartTransfer( FT_GPU_WRITE,addr);
+
+ while (length--) {
+ Transfer8( *buffer);
+ buffer++;
+ }
+
+ EndTransfer( );
+}
+
+
+ft_void_t FT800::RdMem( ft_uint32_t addr, ft_uint8_t *buffer, ft_uint32_t length)
+{
+ //ft_uint32_t SizeTransfered = 0;
+
+ StartTransfer( FT_GPU_READ,addr);
+
+ while (length--) {
+ *buffer = Transfer8( 0);
+ buffer++;
+ }
+
+ EndTransfer( );
+}
+
+ft_int32_t FT800::Dec2Ascii(ft_char8_t *pSrc,ft_int32_t value)
+{
+ ft_int16_t Length;
+ ft_char8_t *pdst,charval;
+ ft_int32_t CurrVal = value,tmpval,i;
+ ft_char8_t tmparray[16],idx = 0;
+
+ Length = strlen(pSrc);
+ pdst = pSrc + Length;
+
+ if(0 == value)
+ {
+ *pdst++ = '0';
+ *pdst++ = '\0';
+ return 0;
+ }
+
+ if(CurrVal < 0)
+ {
+ *pdst++ = '-';
+ CurrVal = - CurrVal;
+ }
+ /* insert the value */
+ while(CurrVal > 0){
+ tmpval = CurrVal;
+ CurrVal /= 10;
+ tmpval = tmpval - CurrVal*10;
+ charval = '0' + tmpval;
+ tmparray[idx++] = charval;
+ }
+
+ for(i=0;i<idx;i++)
+ {
+ *pdst++ = tmparray[idx - i - 1];
+ }
+ *pdst++ = '\0';
+
+ return 0;
+}
+
+
+ft_void_t FT800::Sleep(ft_uint16_t ms)
+{
+ wait_ms(ms);
+}
+
+ft_void_t FT800::Sound_ON(){
+ Wr8( REG_GPIO, 0x02 | Rd8( REG_GPIO));
+}
+
+ft_void_t FT800::Sound_OFF(){
+ Wr8( REG_GPIO, 0xFD & Rd8( REG_GPIO));
+}
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/FT_Hal_Utils.cpp Wed Sep 07 21:53:53 2016 +0000
@@ -0,0 +1,168 @@
+#include "FT_Platform.h"
+#include "mbed.h"
+#include "SDFileSystem.h"
+
+/* function to load jpg file from filesystem */
+/* return 0 if jpg is ok */
+/* return x_size and y_size of jpg */
+
+int FT800::Load_jpg(char* filename, ft_int16_t* x_size, ft_int16_t* y_size, ft_uint32_t address)
+{
+ unsigned char pbuff[8291];
+ unsigned short marker;
+ unsigned short length;
+ unsigned char data[4];
+
+ ft_uint16_t blocklen;
+// sd.mount();
+ FILE *fp = fopen(filename, "r");
+ if(fp == NULL) return (-1); // connot open file
+
+ // search for 0xFFC0 marker
+ fseek(fp, 0, SEEK_END);
+ unsigned int Fsize = ftell(fp);
+ fseek(fp, 2, SEEK_SET);
+ fread(data,4,1,fp);
+ marker = data[0] << 8 | data[1];
+ length = data[2] << 8 | data[3];
+ do {
+ if(marker == 0xFFC0) break;
+ if(marker & 0xFF00 != 0xFF00) break;
+ if (fseek(fp, length - 2,SEEK_CUR) != 0) break;
+ fread(data,4,1,fp);
+ marker = data[0] << 8 | data[1];
+ length = data[2] << 8 | data[3];
+ } while(1);
+ if(marker != 0xFFC0) return (-2); // no FFC0 Marker, wrong format no baseline DCT-based JPEG
+ fseek(fp, 1,SEEK_CUR);
+ fread(data,4,1,fp);
+ *y_size = (data[0] << 8 | data[1]);
+ *x_size = (data[2] << 8 | data[3]);
+
+ //if(*x_size > DispWidth || *y_size > DispHeight) return (-3); // to big to fit on screen
+
+ fseek(fp, 0, SEEK_SET);
+ WrCmd32(CMD_LOADIMAGE); // load a JPEG image
+ WrCmd32(address); //destination address of jpg decode
+ WrCmd32(0); //output format of the bitmap - default is rgb565
+ while(Fsize > 0) {
+ /* download the data into the command buffer by 8kb one shot */
+ blocklen = Fsize>8192?8192:Fsize;
+ /* copy the data into pbuff and then transfter it to command buffer */
+ fread(pbuff,1,blocklen,fp);
+ Fsize -= blocklen;
+ /* copy data continuously into command memory */
+ WrCmdBuf(pbuff, blocklen); //alignment is already taken care by this api
+ }
+ fclose(fp);
+// sd.unmount();
+
+ return(0);
+}
+
+//int FT800::Load_raw(char* filename)
+//{
+// ft_uint8_t imbuff[8192];
+// ft_uint16_t filesize;
+// ft_uint16_t blocklen;
+//// ft_uint16_t ram_start = 0x00;
+//
+//// sd.mount();
+// FILE *fp = fopen(filename, "rb"); // open file
+//// if(fp == NULL) return (-1); // connot open file
+// fseek(fp, 0, SEEK_END); // set file position to end of file
+// filesize= ftell(fp); // determine file size
+// fseek(fp, 2, SEEK_SET); // return to beginning of file
+//
+// while(filesize > 0)
+// {
+// //copy the .raw file data to imbuff[8192] in 8k block
+// blocklen = filesize>8192?8192:filesize;
+// fread(imbuff,1,blocklen,fp);
+// filesize-= blocklen;
+// //write imbuff contents to graphics RAM at address ram_start = 0x00
+// WrCmdBuf(imbuff, blocklen); //alignment is already taken care by this api
+//// ram_start += 8192;
+// }
+// fclose(fp);
+//// sd.unmount();
+//
+// return 0;
+//}
+
+
+
+
+
+
+/* calibrate touch */
+ft_void_t FT800::Calibrate()
+{
+ /*************************************************************************/
+ /* Below code demonstrates the usage of calibrate function. Calibrate */
+ /* function will wait untill user presses all the three dots. Only way to*/
+ /* come out of this api is to reset the coprocessor bit. */
+ /*************************************************************************/
+ {
+
+ DLstart(); // start a new display command list
+ DL(CLEAR_COLOR_RGB(64,64,64)); // set the clear color R, G, B
+ DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer
+ DL(COLOR_RGB(0xff,0xff,0xff)); // set the current color R, G, B
+ Text((DispWidth/2), (DispHeight/2), 27, OPT_CENTER, "Please Tap on the dot"); // draw Text at x,y, font 27, centered
+ Calibrate(0); // start the calibration of touch screen
+ Flush_Co_Buffer(); // download the commands into FT800 FIFO
+ WaitCmdfifo_empty(); // Wait till coprocessor completes the operation
+ }
+}
+
+
+/* API to give fadeout effect by changing the display PWM from 100 till 0 */
+ft_void_t FT800::fadeout()
+{
+ ft_int32_t i;
+
+ for (i = 100; i >= 0; i -= 3)
+ {
+ Wr8(REG_PWM_DUTY,i);
+ Sleep(2);//sleep for 2 ms
+ }
+}
+
+/* API to perform display fadein effect by changing the display PWM from 0 till 100 and finally 128 */
+ft_void_t FT800::fadein()
+{
+ ft_int32_t i;
+
+ for (i = 0; i <=100 ; i += 3)
+ {
+ Wr8(REG_PWM_DUTY,i);
+ Sleep(2);//sleep for 2 ms
+ }
+ /* Finally make the PWM 100% */
+ i = 128;
+ Wr8(REG_PWM_DUTY,i);
+}
+
+ft_void_t FT800::read_calibrate(ft_uint8_t data[24]){
+ unsigned int i;
+ for(i=0;i<24;i++){
+ data[i] = Rd8(REG_TOUCH_TRANSFORM_A + i);
+ }
+}
+
+ft_void_t FT800::write_calibrate(ft_uint8_t data[24]){
+ unsigned int i;
+ for(i=0;i<24;i++) {
+ Wr8(REG_TOUCH_TRANSFORM_A + i,data[i]);
+ }
+}
+
+ft_uint32_t FT800::color_rgb(ft_uint8_t red,ft_uint8_t green, ft_uint8_t blue){
+ return ((4UL<<24)|(((red)&255UL)<<16)|(((green)&255UL)<<8)|(((blue)&255UL)<<0));
+ }
+
+ft_uint32_t FT800::clear_color_rgb(ft_uint8_t red,ft_uint8_t green, ft_uint8_t blue){
+ return ((2UL<<24)|(((red)&255UL)<<16)|(((green)&255UL)<<8)|(((blue)&255UL)<<0));
+ }
+
\ No newline at end of file
