r_xbus_api.h 9.79 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
/*
****************************************************************************
PROJECT : VLIB macro driver
FILE    : $Id: r_xbus_api.h 7640 2016-02-12 13:14:23Z florian.zimmermann $
============================================================================ 
DESCRIPTION
Generic part of the macro driver
============================================================================
                            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_XBUS_API_H_
#define R_XBUS_API_H_

#ifdef __cplusplus
extern "C" {
#endif


/*******************************************************************************
  Title: XBUS Driver API 
  
  An application using XBUS should only need to include r_xbus_api.h
*/

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


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

  Driver version information  
*/

#define R_XBUS_VERSION_HI 0
#define R_XBUS_VERSION_LO 1

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

/*******************************************************************************
  Enum: r_xbus_Error_t

  XBUS macro driver error code.
  
  If an error occures these enums give information about the
  reason.

  Values:
  R_XBUS_ERR_OK           - No error
  R_XBUS_ERR_NG           - Unspecified error
*/

typedef enum
{
    R_XBUS_ERR_OK         = 0x00,
    R_XBUS_ERR_NG         ,
    R_XBUS_ERR_RANGE      ,
    R_XBUS_ERR_LOCKED     ,
    R_XBUS_ERR_NOTLOCKED  
} r_xbus_Error_t;

/*******************************************************************************
  Enum: r_xbus_AreaMode_t

  Access mode for an addres range (area) 

  Values:
    R_XBUS_AM_DIRECT    - direct    access
    R_XBUS_AM_CACHE     - cached    access
    R_XBUS_AM_BUFF      - buffered  access
    R_XBUS_AM_RESERVED  - do not use

*/
typedef enum {
    R_XBUS_AM_DIRECT = 0u,
    R_XBUS_AM_CACHE  = 1u,
    R_XBUS_AM_BUFF   = 2u,
    R_XBUS_AM_RESERVED 
} r_xbus_AreaMode_t; 

/*******************************************************************************
  Type: r_xbus_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_xbus_AreaMode_t> 
      Enable    - enable            , boolean
      BaseAddr  - start ddress of the memory area          
      AddrMask  - addres mask for the area                 


*/
typedef struct {
    r_xbus_AreaMode_t   Mode; 
    uint8_t             Enable;     
    uint32_t            BaseAddr; 
    uint32_t            AddrMask; 
} r_xbus_AreaCfg_t; 


/*******************************************************************************
  Type: r_xbus_Cfg_t

  Configuraton of the AXI-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_xbus_BuffFill_t>    
    BuffPref;           - prefetch type        , see: <r_xbus_BuffPref_t>    
    CacheFill;          - cache fill method    , see: <r_xbus_BuffFill_t>    
    WaitInsertion;      - the upper limit of bus clock that the XBUS may request a wait. 
    AreaCfg[4];         - memory area configuration, see  <r_xbus_AreaCfg_t>
                          Note: Area 0/1 is cached or direct, area 2/3 is bufferd or direct, 
                          DO NOT MIX      
    xbusMasterAccess;   - xbus master access permission, see <r_xbus_MasterAccess_t>

*/
typedef struct {
    uint8_t               WaitInsertion; 
    uint8_t               SecRewrite; 
    r_xbus_AreaCfg_t      AreaCfg[4]; 
} r_xbus_Cfg_t; 



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

/*******************************************************************************
  Function: R_XBUS_GetVersionStr

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

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

const int8_t * R_XBUS_GetVersionStr(void);

/*******************************************************************************
  Function: R_XBUS_GetMajorVersion

  Get the driver major version number. 

  Parameters:
  void
  
  Returns:
     - Major version number
  
*/

const uint16_t R_XBUS_GetMajorVersion(void); 

/*******************************************************************************
  Function: R_XBUS_GetMinorVersion

  Get the driver minor version number. 

  Parameters:
  void
  
  Returns:
     - Minor version number
  
*/

const uint16_t R_XBUS_GetMinorVersion(void); 

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

/*******************************************************************************
  Function: R_XBUS_Config

  Configure memory bus. 

  Parameters:
  Unit   - Instance number
  Cfg    - pointer to bus configuration, see <r_xbus_Cfg_t>
           Note: Area 0/1 is cached or direct, area 2/3 is bufferd or direct, 
                          DO NOT MIX   
   
  Returns:
  see: <r_xbus_Error_t>
*/
r_xbus_Error_t R_XBUS_Config(uint32_t Unit, r_xbus_Cfg_t * Cfg); 


/*******************************************************************************
  Function: R_XBUS_AreaConfig

  Configure one cache area  

  Parameters:
  Unit   - Instance number
  Area   - Index of the cache area 
  Cfg    - pointer to area configuration, see  <r_xbus_AreaCfg_t>
   
  Returns:
  see: <r_xbus_Error_t>
*/

r_xbus_Error_t R_XBUS_AreaConfig(uint32_t Unit, uint8_t Area, r_xbus_AreaCfg_t * Cfg); 

/*******************************************************************************
  Function: R_XBUS_SetMode

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

/*******************************************************************************
  Function: R_XBUS_Flush

  Flush the cache and/or buffer data on the x-bus. 
  The flush operation to be performed is depending on the parameters provided     
  
  Parameters:
  Unit       - Instance number
  FlushAddr  - What to flush  0: flush All
                              1: flush all Cache
                              2: flush all Buffer
                             >2: Flush address 
  FlushSize  - Size of the data to be flushed (starting from the given address >2) 
                
  Returns:
  void 
*/
void R_XBUS_Flush(uint32_t Unit, uint32_t FlushAddr, uint32_t FlushSize);

/*******************************************************************************
  Function: R_XBUS_Invalidate

  invalidate the whole cache. Note: pending data is not written.  
  Parameters:
  Unit       - Instance number
                 
  Returns:
  void 
*/

 r_xbus_Error_t R_XBUS_Invalidate(uint32_t Unit); 

/*******************************************************************************
  Function: R_XBUS_Init

  Driver init function.

  Parameters:
  Unit          - Macro instance number
 
  Returns:
  see: <r_xbus_Error_t>
*/

 r_xbus_Error_t R_XBUS_Init(uint32_t Unit);


/*******************************************************************************
  Function: R_XBUS_DeInit

  Driver deinit function.

  Parameters:
  Unit       - Macro Instance number

  Returns:
  see: <r_xbus_Error_t>
*/

 r_xbus_Error_t R_XBUS_DeInit(uint32_t Unit);


/*******************************************************************************
  Function: R_XBUS_SetErrorCallback

  Set a user function as error handler.
  
  When the driver detects any error, it will call this function.

  Parameters:
  ErrorCallback - Pointer to a user function
  
  Returns:
  void
*/

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


/*******************************************************************************
  Function: R_XBUS_XCopy

  Copy data from <Src> to <Dst> until reaching source <End> address,
  This function is optimised for cached high-latency access over the XC Bus,
  such as VRAM, SDRA/B, Serial Flash on D1Lx and D1Mx.

  Parameters:
  Src   - Source address for copy operation
  Dst   - Destination address for copy operation
  End   - Source end address for copy operation
  
  Returns:
  void
*/
void R_XBUS_XCopy(uint32_t Src, uint32_t Dst, uint32_t End); 


#ifdef __cplusplus
}
#endif

#endif /* R_XBUS_API_H_  */