Ok for EveConnect

Dependents:   FT800_RGB_demo-for_ConnectEve

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FT_Gpu_Hal.h Source File

FT_Gpu_Hal.h

00001 /*!
00002  * \file FT_GPU_HAL.h
00003  *
00004  * \author FTDI
00005  * \date 2013.04.24
00006  *
00007  * Copyright 2013 Future Technology Devices International Limited
00008  *
00009  * Project: FT800 or EVE compatible silicon
00010  * File Description:
00011  *    This file defines the generic APIs of host access layer for the FT800 or EVE compatible silicon.
00012  *    Application shall access FT800 or EVE resources over these APIs. In addition, there are
00013  *    some helper functions defined for FT800 coprocessor engine as well as host commands.
00014  * Rivision History:
00015  * ported to mbed by Peter Drescher, DC2PD 2014
00016  *
00017  */
00018 
00019 #ifndef FT_GPU_HAL_H
00020 #define FT_GPU_HAL_H
00021 
00022 #include "mbed.h"
00023 #include "FT_DataTypes.h"
00024 
00025 typedef enum {
00026     FT_GPU_I2C_MODE = 0,
00027     FT_GPU_SPI_MODE,
00028 
00029     FT_GPU_MODE_COUNT,
00030     FT_GPU_MODE_UNKNOWN = FT_GPU_MODE_COUNT
00031 } FT_GPU_HAL_MODE_E;
00032 
00033 typedef enum {
00034     OPENED,
00035     READING,
00036     WRITING,
00037     CLOSED,
00038     STATUS_COUNT,
00039     STATUS_ERROR = STATUS_COUNT
00040 } FT_GPU_HAL_STATUS_E;
00041 
00042 typedef struct {
00043     ft_uint8_t reserved;
00044 } Ft_Gpu_App_Context_t;
00045 
00046 typedef struct {
00047     /* Total number channels for libmpsse */
00048     ft_uint32_t TotalChannelNum;
00049 } Ft_Gpu_HalInit_t;
00050 
00051 typedef enum {
00052     FT_GPU_READ = 0,
00053     FT_GPU_WRITE,
00054 } FT_GPU_TRANSFERDIR_T;
00055 
00056 
00057 typedef struct {
00058     ft_uint32_t length; //IN and OUT
00059     ft_uint32_t address;
00060     ft_uint8_t  *buffer;
00061 } Ft_Gpu_App_Transfer_t;
00062 
00063 class FT800
00064 {
00065 public:
00066     FT800(PinName mosi,
00067           PinName miso,
00068           PinName sck,
00069           PinName ss,
00070           PinName intr,
00071           PinName pd);
00072 
00073 private:
00074     SPI _spi;
00075     DigitalOut  _ss;
00076     DigitalOut  _pd;
00077     InterruptIn _f800_isr;
00078 public:
00079     /* Global used for buffer optimization */
00080     //Ft_Gpu_Hal_Context_t host,*phost;
00081     Ft_Gpu_App_Context_t        app_header;
00082     ft_uint16_t cmd_fifo_wp; //coprocessor fifo write pointer
00083     ft_uint16_t dl_buff_wp;  //display command memory write pointer
00084     FT_GPU_HAL_STATUS_E        status;            //OUT
00085     ft_void_t*                 hal_handle;        //IN/OUT
00086     ft_uint32_t CmdBuffer_Index;
00087     ft_uint32_t DlBuffer_Index;
00088     ft_int16_t DispWidth;
00089     ft_int16_t DispHeight;
00090     ft_int16_t DispHCycle;
00091     ft_int16_t DispHOffset;
00092     ft_int16_t DispHSync0;
00093     ft_int16_t DispHSync1;
00094     ft_int16_t DispVCycle;
00095     ft_int16_t DispVOffset;
00096     ft_int16_t DispVSync0;
00097     ft_int16_t DispVSync1;
00098     ft_uint8_t DispPCLK;
00099     ft_char8_t DispSwizzle;
00100     ft_char8_t DispPCLKPol;
00101 
00102 
00103     ft_void_t BootupConfig(void);
00104     ft_bool_t Bootup(void);
00105     
00106     
00107     
00108 ft_void_t menu(void);
00109 ft_void_t temperature(float t);
00110 ft_void_t bus_can(float trmin_can,float vitesse_can);
00111 ft_void_t GPS(float latitude,float longitude,float vitesse_gps,unsigned int n_sat,char ns, char ew);
00112 ft_void_t home(float t,float trmin_can,float vitesse_can,float acc,float latitude,float longitude,float vitesse_gps);
00113 ft_void_t accelerometre(float acc,float x, float y, float z);
00114 ft_void_t reglages(unsigned int r);
00115 ft_void_t Start_Screen(ft_char8_t *str);
00116 
00117 
00118     /*The basic APIs Level 1*/
00119     ft_bool_t              Init( );
00120     ft_bool_t              Open( );
00121 
00122     /*The APIs for reading/writing transfer continuously only with small buffer system*/
00123     ft_void_t              StartTransfer(FT_GPU_TRANSFERDIR_T rw,ft_uint32_t addr);
00124     ft_uint8_t             Transfer8(ft_uint8_t value);
00125     ft_uint16_t            Transfer16(ft_uint16_t value);
00126     ft_uint32_t            Transfer32(ft_uint32_t value);
00127     ft_void_t              EndTransfer( );
00128 
00129     /*Read & Write APIs for both burst and single transfer,depending on buffer size*/
00130     ft_void_t              Read(Ft_Gpu_App_Transfer_t *transfer);
00131     ft_void_t              Write(Ft_Gpu_App_Transfer_t *transfer);
00132 
00133     ft_void_t              Close();
00134     ft_void_t              DeInit();
00135 
00136     /*Helper function APIs Read*/
00137     ft_uint8_t  Rd8(ft_uint32_t addr);
00138     ft_uint16_t Rd16(ft_uint32_t addr);
00139     ft_uint32_t Rd32(ft_uint32_t addr);
00140 
00141     /*Helper function APIs Write*/
00142     ft_void_t Wr8(ft_uint32_t addr, ft_uint8_t v);
00143     ft_void_t Wr16(ft_uint32_t addr, ft_uint16_t v);
00144     ft_void_t Wr32(ft_uint32_t addr, ft_uint32_t v);
00145 
00146     /*******************************************************************************/
00147     /*******************************************************************************/
00148     /*APIs for coprocessor Fifo read/write and space management*/
00149     ft_void_t Updatecmdfifo(ft_uint16_t count);
00150     ft_void_t WrCmd32(ft_uint32_t cmd);
00151     ft_void_t WrCmdBuf(ft_uint8_t *buffer,ft_uint16_t count);
00152     ft_void_t WaitCmdfifo_empty();
00153     ft_void_t ResetCmdFifo();
00154     ft_void_t CheckCmdBuffer(ft_uint16_t count);
00155     ft_void_t ResetDLBuffer();
00156 
00157     ft_void_t StartCmdTransfer(FT_GPU_TRANSFERDIR_T rw, ft_uint16_t count);
00158     ft_void_t Powercycle(ft_bool_t up);
00159 
00160 
00161     /*******************************************************************************/
00162     /*******************************************************************************/
00163     /*APIs for Host Commands*/
00164     typedef enum {
00165         FT_GPU_INTERNAL_OSC = 0x48, //default
00166         FT_GPU_EXTERNAL_OSC = 0x44,
00167     } FT_GPU_PLL_SOURCE_T;
00168     typedef enum {
00169         FT_GPU_PLL_48M = 0x62,  //default
00170         FT_GPU_PLL_36M = 0x61,
00171         FT_GPU_PLL_24M = 0x64,
00172     } FT_GPU_PLL_FREQ_T;
00173 
00174     typedef enum {
00175         FT_GPU_ACTIVE_M =  0x00,
00176         FT_GPU_STANDBY_M = 0x41,//default
00177         FT_GPU_SLEEP_M =   0x42,
00178         FT_GPU_POWERDOWN_M = 0x50,
00179     } FT_GPU_POWER_MODE_T;
00180 
00181 #define FT_GPU_CORE_RESET  (0x68)
00182 
00183     ft_int32_t hal_strlen(const ft_char8_t *s);
00184     ft_void_t Sleep(ft_uint16_t ms);
00185     ft_void_t ClockSelect(FT_GPU_PLL_SOURCE_T pllsource);
00186     ft_void_t PLL_FreqSelect(FT_GPU_PLL_FREQ_T freq);
00187     ft_void_t PowerModeSwitch(FT_GPU_POWER_MODE_T pwrmode);
00188     ft_void_t CoreReset();
00189 //ft_void_t Ft_Gpu_Hal_StartTransfer( ,FT_GPU_TRANSFERDIR_T rw,ft_uint32_t addr);
00190     ft_void_t WrMem(ft_uint32_t addr, const ft_uint8_t *buffer, ft_uint32_t length);
00191     ft_void_t WrMemFromFlash(ft_uint32_t addr,const ft_prog_uchar8_t *buffer, ft_uint32_t length);
00192     ft_void_t WrCmdBufFromFlash(FT_PROGMEM ft_prog_uchar8_t *buffer,ft_uint16_t count);
00193     ft_void_t RdMem(ft_uint32_t addr, ft_uint8_t *buffer, ft_uint32_t length);
00194     ft_void_t WaitLogo_Finish();
00195     ft_uint8_t TransferString(const ft_char8_t *string);
00196     ft_void_t HostCommand(ft_uint8_t cmd);
00197     ft_int32_t Dec2Ascii(ft_char8_t *pSrc,ft_int32_t value);
00198 
00199     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);
00200     ft_void_t Number(ft_int16_t x, ft_int16_t y, ft_int16_t font, ft_uint16_t options, ft_int32_t n);
00201     ft_void_t LoadIdentity();
00202     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);
00203     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);
00204     ft_void_t RegRead(ft_uint32_t ptr, ft_uint32_t result);
00205     ft_void_t GetProps(ft_uint32_t ptr, ft_uint32_t w, ft_uint32_t h);
00206     ft_void_t Memcpy(ft_uint32_t dest, ft_uint32_t src, ft_uint32_t num);
00207     ft_void_t Spinner(ft_int16_t x, ft_int16_t y, ft_uint16_t style, ft_uint16_t scale);
00208     ft_void_t BgColor(ft_uint32_t c);
00209     ft_void_t Swap();
00210     ft_void_t Inflate(ft_uint32_t ptr);
00211     ft_void_t Translate(ft_int32_t tx, ft_int32_t ty);
00212     ft_void_t Stop();
00213     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);
00214     ft_void_t Interrupt(ft_uint32_t ms);
00215     ft_void_t luminosite( ft_int32_t lum);   
00216     ft_void_t FgColor(ft_uint32_t c);
00217     ft_void_t Rotate(ft_int32_t a);
00218     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);
00219     ft_void_t MemWrite(ft_uint32_t ptr, ft_uint32_t num);
00220     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);
00221     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);
00222     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);
00223     ft_void_t MemSet(ft_uint32_t ptr, ft_uint32_t value, ft_uint32_t num);
00224     ft_void_t Calibrate(ft_uint32_t result);
00225     ft_void_t SetFont(ft_uint32_t font, ft_uint32_t ptr);
00226     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);
00227     ft_void_t GradColor(ft_uint32_t c);
00228     ft_void_t Append(ft_uint32_t ptr, ft_uint32_t num);
00229     ft_void_t MemZero(ft_uint32_t ptr, ft_uint32_t num);
00230     ft_void_t Scale(ft_int32_t sx, ft_int32_t sy);
00231     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);
00232     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);
00233     ft_void_t SetMatrix();
00234     ft_void_t Track(ft_int16_t x, ft_int16_t y, ft_int16_t w, ft_int16_t h, ft_int16_t tag);
00235     ft_void_t GetPtr(ft_uint32_t result);
00236     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);
00237     ft_void_t ColdStart();
00238     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);
00239     ft_void_t Dial(ft_int16_t x, ft_int16_t y, ft_int16_t r, ft_uint16_t options, ft_uint16_t val);
00240     ft_void_t LoadImage(ft_uint32_t ptr, ft_uint32_t options);
00241     ft_void_t DLstart();
00242     ft_void_t Snapshot(ft_uint32_t ptr);
00243     ft_void_t ScreenSaver();
00244     ft_void_t Memcrc(ft_uint32_t ptr, ft_uint32_t num, ft_uint32_t result);
00245 
00246     ft_void_t Logo();
00247 
00248     ft_void_t SendCmd( ft_uint32_t cmd);
00249     ft_void_t SendStr( const ft_char8_t *s);
00250     ft_void_t StartFunc( ft_uint16_t count);
00251     ft_void_t EndFunc( ft_uint16_t count);
00252     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);
00253     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);
00254     ft_void_t MemCrc( ft_uint32_t ptr, ft_uint32_t num, ft_uint32_t result);
00255 
00256     ft_uint16_t fifo_Freespace( );
00257 
00258     ft_void_t DL(ft_uint32_t cmd);
00259     ft_void_t WrDlCmd_Buffer(ft_uint32_t cmd);
00260     ft_void_t Flush_DL_Buffer();
00261     ft_void_t Flush_Co_Buffer();
00262     ft_void_t fadeout();
00263     ft_void_t fadein();
00264     ft_void_t DLSwap(ft_uint8_t DL_Swap_Type);
00265 
00266     ft_void_t Sound_ON();
00267     ft_void_t Sound_OFF();
00268     
00269     int Load_jpg(char* filename, ft_int16_t* x_size, ft_int16_t* y_size);
00270     ft_void_t Calibrate();
00271 
00272 };  // end of class
00273 
00274 #endif  /*FT_GPU_HAL_H*/