Library for FT810 EVE chip

Fork of FT810 by Curtis Mattull

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FT_Gpu_Hal.h Source File

FT_Gpu_Hal.h

00001 #ifndef FT_GPU_HAL_H
00002 #define FT_GPU_HAL_H
00003  
00004 #include "mbed.h"
00005 #include "FT_DataTypes.h"
00006  
00007 typedef enum {
00008     FT_GPU_I2C_MODE = 0,
00009     FT_GPU_SPI_MODE,
00010  
00011     FT_GPU_MODE_COUNT,
00012     FT_GPU_MODE_UNKNOWN = FT_GPU_MODE_COUNT
00013 } FT_GPU_HAL_MODE_E;
00014  
00015 typedef enum {
00016     OPENED,
00017     READING,
00018     WRITING,
00019     CLOSED,
00020     STATUS_COUNT,
00021     STATUS_ERROR = STATUS_COUNT
00022 } FT_GPU_HAL_STATUS_E;
00023  
00024 typedef struct {
00025     ft_uint8_t reserved;
00026 } Ft_Gpu_App_Context_t;
00027  
00028 typedef struct {
00029     /* Total number channels for libmpsse */
00030     ft_uint32_t TotalChannelNum;
00031 } Ft_Gpu_HalInit_t;
00032  
00033 typedef enum {
00034     FT_GPU_READ = 0,
00035     FT_GPU_WRITE,
00036 } FT_GPU_TRANSFERDIR_T;
00037  
00038  
00039 typedef struct {
00040     ft_uint32_t length; //IN and OUT
00041     ft_uint32_t address;
00042     ft_uint8_t  *buffer;
00043 } Ft_Gpu_App_Transfer_t;
00044  
00045 class FT800
00046 {
00047 public:
00048     FT800(PinName mosi,
00049           PinName miso,
00050           PinName sck,
00051           PinName ss,
00052           PinName intr,
00053           PinName pd);
00054  
00055 private:
00056     SPI _spi;
00057     DigitalOut  _ss;
00058     DigitalOut  _pd;
00059     InterruptIn _f800_isr;
00060 public:
00061     /* Global used for buffer optimization */
00062     //Ft_Gpu_Hal_Context_t host,*phost;
00063     Ft_Gpu_App_Context_t        app_header;
00064     ft_uint16_t cmd_fifo_wp; //coprocessor fifo write pointer
00065     ft_uint16_t dl_buff_wp;  //display command memory write pointer
00066     FT_GPU_HAL_STATUS_E        status;            //OUT
00067     ft_void_t*                 hal_handle;        //IN/OUT
00068     ft_uint32_t CmdBuffer_Index;
00069     ft_uint32_t DlBuffer_Index;
00070     ft_int16_t DispWidth;
00071     ft_int16_t DispHeight;
00072     ft_int16_t DispHCycle;
00073     ft_int16_t DispHOffset;
00074     ft_int16_t DispHSync0;
00075     ft_int16_t DispHSync1;
00076     ft_int16_t DispVCycle;
00077     ft_int16_t DispVOffset;
00078     ft_int16_t DispVSync0;
00079     ft_int16_t DispVSync1;
00080     ft_uint8_t DispPCLK;
00081     ft_char8_t DispSwizzle;
00082     ft_char8_t DispPCLKPol; 
00083     ft_char8_t DispCSpread; //
00084     ft_char8_t DispDither; //
00085  
00086  
00087     ft_void_t BootupConfig(void);
00088     ft_bool_t Bootup(void);
00089  
00090  
00091     /*The basic APIs Level 1*/
00092     ft_bool_t              Init( );
00093     ft_bool_t              Open( );
00094  
00095     /*The APIs for reading/writing transfer continuously only with small buffer system*/
00096     ft_void_t              StartTransfer(FT_GPU_TRANSFERDIR_T rw,ft_uint32_t addr);
00097     ft_uint8_t             Transfer8(ft_uint8_t value);
00098     ft_uint16_t            Transfer16(ft_uint16_t value);
00099     ft_uint32_t            Transfer32(ft_uint32_t value);
00100     ft_void_t              EndTransfer( );
00101  
00102     /*Read & Write APIs for both burst and single transfer,depending on buffer size*/
00103     ft_void_t              Read(Ft_Gpu_App_Transfer_t *transfer);
00104     ft_void_t              Write(Ft_Gpu_App_Transfer_t *transfer);
00105  
00106     ft_void_t              Close();
00107     ft_void_t              DeInit();
00108  
00109     /*Helper function APIs Read*/
00110     ft_uint8_t  Rd8(ft_uint32_t addr);
00111     ft_uint16_t Rd16(ft_uint32_t addr);
00112     ft_uint32_t Rd32(ft_uint32_t addr);
00113  
00114     /*Helper function APIs Write*/
00115     ft_void_t Wr8(ft_uint32_t addr, ft_uint8_t v);
00116     ft_void_t Wr16(ft_uint32_t addr, ft_uint16_t v);
00117     ft_void_t Wr32(ft_uint32_t addr, ft_uint32_t v);
00118  
00119     /*******************************************************************************/
00120     /*******************************************************************************/
00121     /*APIs for coprocessor Fifo read/write and space management*/
00122     ft_void_t Updatecmdfifo(ft_uint16_t count);
00123     ft_void_t WrCmd32(ft_uint32_t cmd);
00124     ft_void_t WrCmdBuf(ft_uint8_t *buffer,ft_uint16_t count);
00125     ft_void_t WaitCmdfifo_empty();
00126     ft_void_t ResetCmdFifo();
00127     ft_void_t CheckCmdBuffer(ft_uint16_t count);
00128     ft_void_t ResetDLBuffer();
00129  
00130     ft_void_t StartCmdTransfer(FT_GPU_TRANSFERDIR_T rw, ft_uint16_t count);
00131     ft_void_t Powercycle(ft_bool_t up);
00132  
00133  
00134     /*******************************************************************************/
00135     /*******************************************************************************/
00136     /*APIs for Host Commands*/
00137     typedef enum {
00138         FT_GPU_INTERNAL_OSC = 0x48, //default
00139         FT_GPU_EXTERNAL_OSC = 0x44,
00140     } FT_GPU_PLL_SOURCE_T;
00141     typedef enum {
00142         FT_GPU_PLL_48M = 0x62,  //default
00143         FT_GPU_PLL_36M = 0x61,
00144         FT_GPU_PLL_24M = 0x64,
00145     } FT_GPU_PLL_FREQ_T;
00146  
00147     typedef enum {
00148         FT_GPU_ACTIVE_M =  0x00,
00149         FT_GPU_STANDBY_M = 0x41,//default
00150         FT_GPU_SLEEP_M =   0x42,
00151         FT_GPU_POWERDOWN_M = 0x50,
00152     } FT_GPU_POWER_MODE_T;
00153     
00154     #ifdef FT_81X_ENABLE
00155     typedef enum {
00156         FT_GPU_SYSCLK_DEFAULT = 0x00,  //default 60mhz
00157         FT_GPU_SYSCLK_72M = 0x06, 
00158         FT_GPU_SYSCLK_60M = 0x05,  
00159         FT_GPU_SYSCLK_48M = 0x04,  
00160         FT_GPU_SYSCLK_36M = 0x03,
00161         FT_GPU_SYSCLK_24M = 0x02,
00162     }FT_GPU_81X_PLL_FREQ_T;
00163 
00164     typedef enum{
00165         FT_GPU_MAIN_ROM = 0x80,  //main graphicas ROM used 
00166         FT_GPU_RCOSATAN_ROM = 0x40,  //line slope table used for 
00167         FT_GPU_SAMPLE_ROM = 0x20,  //JA samples
00168         FT_GPU_JABOOT_ROM = 0x10, //JA microcode
00169         FT_GPU_J1BOOT_ROM = 0x08, //J1 microcode
00170         FT_GPU_ADC = 0x01,  //
00171         FT_GPU_POWER_ON_ROM_AND_ADC = 0x00,  //specify this element to power on all ROMs and ADCs
00172     }FT_GPU_81X_ROM_AND_ADC_T;
00173 
00174     typedef enum{
00175         FT_GPU_5MA = 0x00,  //default current
00176         FT_GPU_10MA = 0x01,
00177         FT_GPU_15MA = 0x02,
00178         FT_GPU_20MA = 0x03,
00179     }FT_GPU_81X_GPIO_DRIVE_STRENGTH_T;
00180 
00181     typedef enum{
00182         FT_GPU_GPIO0 = 0x00,
00183         FT_GPU_GPIO1 = 0x04,
00184         FT_GPU_GPIO2 = 0x08,
00185         FT_GPU_GPIO3 = 0x0C,
00186         FT_GPU_GPIO4 = 0x10,
00187         FT_GPU_DISP = 0x20,
00188         FT_GPU_DE = 0x24,
00189         FT_GPU_VSYNC_HSYNC = 0x28,
00190         FT_GPU_PCLK = 0x2C,
00191         FT_GPU_BACKLIGHT = 0x30,
00192         FT_GPU_R_G_B = 0x34,
00193         FT_GPU_AUDIO_L = 0x38,
00194         FT_GPU_INT_N = 0x3C,
00195         FT_GPU_TOUCHWAKE = 0x40,
00196         FT_GPU_SCL = 0x44,
00197         FT_GPU_SDA = 0x48,
00198         FT_GPU_SPI_MISO_MOSI_IO2_IO3 = 0x4C,
00199     }FT_GPU_81X_GPIO_GROUP_T;
00200 
00201     #define FT_GPU_81X_RESET_ACTIVE 0x000268
00202 
00203     #define FT_GPU_81X_RESET_REMOVAL 0x002068
00204 #endif 
00205  
00206 #define FT_GPU_CORE_RESET  (0x68)
00207 
00208 /* Enums for number of SPI dummy bytes and number of channels */
00209 typedef enum {
00210     FT_GPU_SPI_SINGLE_CHANNEL = 0,
00211     FT_GPU_SPI_DUAL_CHANNEL = 1,
00212     FT_GPU_SPI_QUAD_CHANNEL = 2,
00213 }FT_GPU_SPI_NUMCHANNELS_T;
00214 typedef enum {
00215     FT_GPU_SPI_ONEDUMMY = 1,
00216     FT_GPU_SPI_TWODUMMY = 2,
00217 }FT_GPU_SPI_NUMDUMMYBYTES;
00218 
00219 #define FT_SPI_ONE_DUMMY_BYTE   (0x00)
00220 #define FT_SPI_TWO_DUMMY_BYTE   (0x04)
00221 #define FT_SPI_SINGLE_CHANNEL   (0x00)
00222 #define FT_SPI_DUAL_CHANNEL     (0x01)
00223 #define FT_SPI_QUAD_CHANNEL     (0x02)  
00224 
00225 /*
00226 #ifdef FT_81X_ENABLE
00227 ft_void_t Ft_Gpu_81X_SelectSysCLK(Ft_Gpu_Hal_Context_t *host, FT_GPU_81X_PLL_FREQ_T freq);
00228 ft_void_t Ft_GPU_81X_PowerOffComponents(Ft_Gpu_Hal_Context_t *host, ft_uint8_t val);
00229 ft_void_t Ft_GPU_81X_PadDriveStrength(Ft_Gpu_Hal_Context_t *host, FT_GPU_81X_GPIO_DRIVE_STRENGTH_T strength, FT_GPU_81X_GPIO_GROUP_T group);
00230 ft_void_t Ft_Gpu_81X_ResetActive(Ft_Gpu_Hal_Context_t *host);
00231 ft_void_t Ft_Gpu_81X_ResetRemoval(Ft_Gpu_Hal_Context_t *host);
00232 #endif
00233 */  
00234  
00235     ft_int32_t hal_strlen(const ft_char8_t *s);
00236     ft_void_t Sleep(ft_uint16_t ms);
00237     ft_void_t ClockSelect(FT_GPU_PLL_SOURCE_T pllsource);
00238     ft_void_t PLL_FreqSelect(FT_GPU_PLL_FREQ_T freq);
00239     ft_void_t PowerModeSwitch(FT_GPU_POWER_MODE_T pwrmode);
00240     ft_void_t CoreReset();
00241 //ft_void_t Ft_Gpu_Hal_StartTransfer( ,FT_GPU_TRANSFERDIR_T rw,ft_uint32_t addr);
00242     ft_void_t WrMem(ft_uint32_t addr, const ft_uint8_t *buffer, ft_uint32_t length);
00243     ft_void_t WrMemFromFlash(ft_uint32_t addr,const ft_prog_uchar8_t *buffer, ft_uint32_t length);
00244     ft_void_t WrCmdBufFromFlash(FT_PROGMEM ft_prog_uchar8_t *buffer,ft_uint16_t count);
00245     ft_void_t RdMem(ft_uint32_t addr, ft_uint8_t *buffer, ft_uint32_t length);
00246     ft_void_t WaitLogo_Finish();
00247     ft_uint8_t TransferString(const ft_char8_t *string);
00248     ft_void_t HostCommand(ft_uint8_t cmd);
00249     ft_int32_t Dec2Ascii(ft_char8_t *pSrc,ft_int32_t value);
00250  
00251     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);
00252     ft_void_t Number(ft_int16_t x, ft_int16_t y, ft_int16_t font, ft_uint16_t options, ft_int32_t n);
00253     ft_void_t LoadIdentity();
00254     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);
00255     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);
00256     ft_void_t RegRead(ft_uint32_t ptr, ft_uint32_t result);
00257     ft_void_t GetProps(ft_uint32_t ptr, ft_uint32_t w, ft_uint32_t h);
00258     ft_void_t Memcpy(ft_uint32_t dest, ft_uint32_t src, ft_uint32_t num);
00259     ft_void_t Spinner(ft_int16_t x, ft_int16_t y, ft_uint16_t style, ft_uint16_t scale);
00260     ft_void_t BgColor(ft_uint32_t c);
00261     ft_void_t Swap();
00262     ft_void_t Inflate(ft_uint32_t ptr);
00263     ft_void_t Translate(ft_int32_t tx, ft_int32_t ty);
00264     ft_void_t Stop();
00265     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);
00266     ft_void_t Interrupt(ft_uint32_t ms);
00267     ft_void_t FgColor(ft_uint32_t c);
00268     ft_void_t Rotate(ft_int32_t a);
00269     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);
00270     ft_void_t MemWrite(ft_uint32_t ptr, ft_uint32_t num);
00271     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);
00272     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);
00273     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);
00274     ft_void_t MemSet(ft_uint32_t ptr, ft_uint32_t value, ft_uint32_t num);
00275     ft_void_t Calibrate(ft_uint32_t result);
00276     ft_void_t SetFont(ft_uint32_t font, ft_uint32_t ptr);
00277     ft_void_t RomFont( ft_uint32_t font, ft_uint32_t rom_slot);
00278     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);
00279     ft_void_t GradColor(ft_uint32_t c);
00280     ft_void_t Append(ft_uint32_t ptr, ft_uint32_t num);
00281     ft_void_t MemZero(ft_uint32_t ptr, ft_uint32_t num);
00282     ft_void_t Scale(ft_int32_t sx, ft_int32_t sy);
00283     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);
00284     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);
00285     ft_void_t SetMatrix();
00286     ft_void_t Track(ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_int16_t tag);
00287     ft_void_t GetPtr(ft_uint32_t result);
00288     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);
00289     ft_void_t ColdStart();
00290     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);
00291     ft_void_t Dial(ft_int16_t x, ft_int16_t y, ft_int16_t r, ft_uint16_t options, ft_uint16_t val);
00292     ft_void_t LoadImage(ft_uint32_t ptr, ft_uint32_t options);
00293     ft_void_t DLstart();
00294     ft_void_t Snapshot(ft_uint32_t ptr);
00295     ft_void_t ScreenSaver();
00296     ft_void_t Memcrc(ft_uint32_t ptr, ft_uint32_t num, ft_uint32_t result);
00297  
00298     ft_void_t Logo();
00299  
00300     ft_void_t SendCmd( ft_uint32_t cmd);
00301     ft_void_t SendStr( const ft_char8_t *s);
00302     ft_void_t StartFunc( ft_uint16_t count);
00303     ft_void_t EndFunc( ft_uint16_t count);
00304     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);
00305     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);
00306     ft_void_t MemCrc( ft_uint32_t ptr, ft_uint32_t num, ft_uint32_t result);
00307  
00308     ft_uint16_t fifo_Freespace( );
00309  
00310     ft_void_t DL(ft_uint32_t cmd);
00311     ft_void_t WrDlCmd_Buffer(ft_uint32_t cmd);
00312     ft_void_t Flush_DL_Buffer();
00313     ft_void_t Flush_Co_Buffer();
00314     ft_void_t fadeout();
00315     ft_void_t fadein();
00316     ft_void_t DLSwap(ft_uint8_t DL_Swap_Type);
00317  
00318     ft_void_t Sound_ON();
00319     ft_void_t Sound_OFF();
00320     
00321     int Load_jpg(char* filename, ft_int16_t* x_size, ft_int16_t* y_size,ft_uint32_t address);
00322     
00323     //Curt added Load_raw 7/22/16
00324     int Load_raw(char* filename);
00325     
00326     ft_void_t Calibrate();
00327     ft_void_t read_calibrate(ft_uint8_t data[24]);
00328     ft_void_t write_calibrate(ft_uint8_t data[24]);
00329     
00330     ft_uint32_t color_rgb(ft_uint8_t red,ft_uint8_t green, ft_uint8_t blue);
00331     ft_uint32_t clear_color_rgb(ft_uint8_t red,ft_uint8_t green, ft_uint8_t blue);
00332  
00333 };  // end of class
00334  
00335 #endif  /*FT_GPU_HAL_H*/