r_gfxbus_api.h 10.3 KB
Newer Older
hu's avatar
hu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
/*
****************************************************************************
PROJECT : Gfx bus driver (wrapper)
FILE    : $Id: r_gfxbus_api.h 7640 2016-02-12 13:14:23Z florian.zimmermann $
============================================================================ 
DESCRIPTION
Driver for GFX bus  macro
============================================================================
                            C O P Y R I G H T
============================================================================
                       Copyright (c) 2013 - 2014
                                  by 
                       Renesas Electronics (Europe) GmbH. 
                           Arcadiastrasse 10
                          D-40472 Duesseldorf
                               Germany
                          All rights reserved.
============================================================================
Purpose: only for testing, not for mass production

DISCLAIMER

LICENSEE has read, understood and accepted the terms and conditions defined in
the license agreement, especially the usage rights. In any case, it is
LICENSEE's responsibility to make sure that any user of the software complies
with the terms and conditions of the signed license agreement.

SAMPLE CODE is not part of the licensed software, as such it must not be used in
mass-production applications. It can only be used for evaluation and
demonstration purposes at customer's premises listed in the signed license
agreement.

****************************************************************************
*/

#ifndef R_GFXBUS_API_H_
#define R_GFXBUS_API_H_

#ifdef __cplusplus
extern "C" {
#endif

#ifdef USE_HBUS
    #define R_GFXBUS_AREAS 4u
#else 
#ifdef USE_XBUS
    #define R_GFXBUS_AREAS 2u
#endif 
#endif    
/*******************************************************************************
  Title: GFXBUS API

  This a common API (wrapper) definition  for GFX buses (eg. hbus, xbus)
  An application should only need to include this header. The correct bus beneath
  will be selected in the device make file. The according function calls are handled 
  on the device (sys) level    

*/

/*******************************************************************************
  Section: Global Constants 
*/


/*******************************************************************************
  Constant:  R_XBUS_VERSION_HI and R_XBUS_VERSION_LO

  Driver version information  
*/

#define R_GFXBUS_VERSION_HI 0
#define R_GFXBUS_VERSION_LO 1



/*******************************************************************************
  Section: Global Types
*/

/*******************************************************************************
  Enum: r_gfxbus_Error_t

  GFXBUS macro driver error code.

  Values:
  R_GFXBUS_ERR_OK          - No error
  R_GFXBUS_ERR_NG          - Unspecified error
  R_GFXBUS_ERR_RANGE       - wrong parameter range
  R_GFXBUS_ERR_LAST        - Delimiter 
*/

typedef enum {
    R_GFXBUS_ERR_OK         = 0x00u,
    R_GFXBUS_ERR_NG         = 0x01u,
    R_GFXBUS_ERR_RANGE      = 0x02u,
    R_GFXBUS_ERR_LAST
} r_gfxbus_Error_t;



/*******************************************************************************
  Enum: r_gfxbus_BuffFill_t

  BUffer fill method

  Values:
    R_GFXBUS_FILL_SEQUENCIAL - sequencial fill 
    R_GFXBUS_FILL_CF         - critical data first      
*/
typedef enum {
    R_GFXBUS_FILL_SEQUENCIAL = 0u,
    R_GFXBUS_FILL_CF         = 1
} r_gfxbus_BuffFill_t; 

/*******************************************************************************
  Enum: r_gfxbus_BuffPref_t

  Prefetch method. 
  
  Values:
    R_GFXBUS_PREFETCH_NO          -  no prefetch 
    R_GFXBUS_PREFETCH_INC         - incremental  
    R_GFXBUS_PREFETCH_DEC         - decremental 
    R_GFXBUS_PREFETCH_RESERVED    - do not use  

*/
typedef enum {
    R_GFXBUS_PREFETCH_NO   = 0u,
    R_GFXBUS_PREFETCH_INC  = 1u,
    R_GFXBUS_PREFETCH_DEC  = 2u,
    R_GFXBUS_PREFETCH_RESERVED 
} r_gfxbus_BuffPref_t; 

/*******************************************************************************
  Enum: r_gfxbus_AreaMode_t

  Access mode for an addres range (area) 

  Values:
    R_GFXBUS_AM_DIRECT    - direct   access
    R_GFXBUS_AM_BUFFER    - buffered access 
    R_GFXBUS_AM_CACHE     - cached   access
    R_GFXBUS_AM_RESERVED  - do not use

*/
typedef enum {
    R_GFXBUS_AM_DIRECT = 0u,
    R_GFXBUS_AM_BUFFER = 1u, 
    R_GFXBUS_AM_CACHE  = 2u,
    R_GFXBUS_AM_RESERVED 
} r_gfxbus_AreaMode_t; 

/*******************************************************************************
  Enum: r_gfxbus_MasterAccess_t

  Permission to access CPU-SS from Bus Master.

  Values:
    R_GFXBUS_MASTER_ACCESS_DENIED    - Access not allowed
    R_GFXBUS_MASTER_ACCESS_ALLOWED   - Access allowed
    R_GFXBUS_MASTER_ACCESS_RESERVED  - do not use

*/
typedef enum {
    R_GFXBUS_MASTER_ACCESS_DENIED  = 0u,
    R_GFXBUS_MASTER_ACCESS_ALLOWED = 2u,
    R_GFXBUS_MASTER_ACCESS_RESERVED
} r_gfxbus_MasterAccess_t;

/*******************************************************************************
  Enum: r_gfxbus_Flush_t

  What will be flushed 
  
  Values:
    R_GFXBUS_DIRECT     - No buffer (no flush action)  
    R_GFXBUS_BUFFER     - Gfxbus buffer,
    R_GFXBUS_CACHE      - Gfxbus cache  
*/
typedef enum {
    R_GFXBUS_DIRECT = 0u,
    R_GFXBUS_BUFFER = 1u,
    R_GFXBUS_CACHE  = 2u
}r_gfxbus_Flush_t; 


/*******************************************************************************
  Type: r_gfxbus_AreaCfg_t

  Configuraton settings for a given memory area. 
  Attention:   The settings only have effect if the area is enabled.  
               Otherwise only the direct access mode is set.           
 
  Values:
      Mode      - access mode       , see <r_gfxbus_AreaMode_t> 
      Enable    - enable            , boolean
      BaseAddr  - start ddress of the memory area          
      AddrMask  - addres mask for the area                 


*/
typedef struct {
    r_gfxbus_AreaMode_t Mode; 
    uint8_t             Enable; 
    uint32_t            BaseAddr; 
    uint32_t            AddrMask; 
} r_gfxbus_AreaCfg_t; 


/*******************************************************************************
  Type: r_gfxbus_Cfg_t

  Configuraton of the (A)H-Bus.
  A note about Wait Insertion: 
  It is strongly recommended to use this feature for debug purpose only and to
  disable the wait limit by setting this register to zero!

  Values:

    BuffFill;           - buffer fill method   , see: <r_gfxbus_BuffFill_t>    
    BuffPref;           - prefetch type        , see: <r_gfxbus_BuffPref_t>    
    CacheFill;          - cache fill method    , see: <r_gfxbus_BuffFill_t>    
    WaitInsertion;      - the upper limit of bus clock that the GFXBUS may request a wait. 
    AreaCfg[4];         - memory area configuration, see  <r_gfxbus_AreaCfg_t>     
    MasterAccess;       - Bus master access permission, see <r_gfxbus_MasterAccess_t>

*/
typedef struct {
    r_gfxbus_BuffFill_t     BuffFill; 
    r_gfxbus_BuffPref_t     BuffPref; 
    r_gfxbus_BuffFill_t     CacheFill; 
    uint8_t                 WaitInsertion; 
    r_gfxbus_AreaCfg_t      AreaCfg[R_GFXBUS_AREAS]; 
    r_gfxbus_MasterAccess_t MasterAccess;
} r_gfxbus_Cfg_t; 


/*******************************************************************************
  Section: Global API Functions
*/

/*******************************************************************************
  Function: R_GFXBUS_GetVersionStr

  Get the driver version number in human readable form (string). 

  Parameters:
  void
  
  Returns:
  ReceiveString     - Pointer to receive string destination
  
*/

const int8_t * R_GFXBUS_GetVersionStr(void);

/*******************************************************************************
  Function: R_GFXBUS_GetMajorVersion

  Get the driver major version number. 

  Parameters:
  void
  
  Returns:
     - Major version number
  
*/

const uint16_t R_GFXBUS_GetMajorVersion(void); 

/*******************************************************************************
  Function: R_GFXBUS_GetMinorVersion

  Get the driver minor version number. 

  Parameters:
  void
  
  Returns:
     - Minor version number
  
*/

const uint16_t R_GFXBUS_GetMinorVersion(void); 


/*******************************************************************************
  Function: R_GFXBUS_Config

  Configure memory bus 

  Parameters:
  Unit   - Instance number
  HCfg   - pointer to bus configuration <r_gfxbus_Cfg_t>
   
  Returns:
  see: <r_gfxbus_Error_t>
*/
r_gfxbus_Error_t R_GFXBUS_Config(uint32_t Unit, r_gfxbus_Cfg_t * Cfg); 

/*******************************************************************************
  Function: R_GFXBUS_Flush

  Flush data on bus. Depending on the given Flush (either type or address) 
  the whole cache or a selected area will be flushed   
  
  Parameters:
  Unit       - Instance number
  Flush      - What to flush (buffer or cache or adress ) see also: <r_gfxbus_Flush_t>
               for reference 
  Size       - Amount of data to flush (in byte) strarting from the given address    
  Returns:
  void
*/
void R_GFXBUS_Flush(uint32_t Unit, uint32_t Flush, uint32_t Size); 

/*******************************************************************************
  Function: R_GFXBUS_SetMode

  Flush data on bus  
  
  Parameters:
  Unit       - Instance number
  Area       - selected memory area
  Mode       - access mode, see <r_gfxbus_AreaMode_t> 
   
  Returns:
  see: <r_gfxbus_Error_t>
*/
r_gfxbus_Error_t R_GFXBUS_SetMode(uint32_t Unit, uint8_t Area, r_gfxbus_AreaMode_t Mode); 

/*******************************************************************************
  Function: R_GFXBUS_Init

  Driver init function.

  Parameters:
  Unit       - Instance number
 
  Returns:
  see: <r_gfxbus_Error_t>
*/

int32_t R_GFXBUS_Init(uint32_t Unit);


/*******************************************************************************
  Function: R_GFXBUS_DeInit

  Driver deinit function.

  Parameters:
  Unit       - Instance number

  Returns:
  see: <r_gfxbus_Error_t>
*/

int32_t R_GFXBUS_DeInit(uint32_t Unit);


/*******************************************************************************
  Function: R_GFXBUS_SetErrorCallback

  Set a user function as an the error handler.

  Parameters:
  *ErrorHandler - a pointer to a user function (callback) 
                  with two paramerters (unit and error number) 
  
  Returns:
  void
 
*/

void R_GFXBUS_SetErrorCallback(void ( *ErrorCallback )(uint32_t Unit, uint32_t Error));



#ifdef __cplusplus
}
#endif

#endif /* R_GFXBUS_API_H_  */