eelapp_control.c 21.8 KB
Newer Older
时昊's avatar
时昊 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 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
/*********************************************************************************************************************
 * File Name     : $Source: eelapp_control.c $
 * Mod. Revision : $Revision: 1.8 $
 * Mod. Date     : $Date: 2014/09/10 18:53:53JST $
 * Device(s)     : RV40 Flash based RH850 microcontroller
 * Description   : Application sample program control module
 *********************************************************************************************************************/

/*********************************************************************************************************************
 * DISCLAIMER 
 * This software is supplied by Renesas Electronics Corporation and is only  intended for use with Renesas products. 
 * No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all 
 * applicable laws, including copyright laws. 
 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED 
 * OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 * NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. 
 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS 
 * AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY 
 * REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH 
 * DAMAGES.
 * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of 
 * this software. By using this software, you agree to the additional terms and conditions found by accessing the
 * following link: 
 * http://www.renesas.com/disclaimer 
 * 
 * Copyright (C) 2014 Renesas Electronics Corporation. All rights reserved.     
 *********************************************************************************************************************/


/*********************************************************************************************************************
 * header files include
 *********************************************************************************************************************/
#include "R_TypeDefs.h"
#include "R_FDL.h"
#include "FDL_Descriptor.h"
#include "R_EEL.h"
#include "EEL_Descriptor.h"
#include "target.h"
uint8_t EELRead_Buffer[256];
const uint8_t EELFill_Buffer_55[256] = 
{
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0xcc,0x55,0x55,0x55,0x55,0x55,0xdd,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
};

const uint8_t EELFill_Buffer_AA[256] = 
{
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0x11,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0x22,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
};

/*********************************************************************************************************************
 * Module internal function prototypes
 *********************************************************************************************************************/
r_eel_status_t SampleApp_EEL_Init( void );
void         SampleApp_EEL_HdrLoop( r_eel_request_t *req );
void         SampleApp_EEL_ErrorHdr( r_eel_status_t stat );

/*********************************************************************************************************************
   Function name:  SampleApp_EEL_ErrorHdr
 *********************************************************************************************************************/
/**
    error reaction function, to check the result of a EEL user operation or of the background 
    operations
    
    Note:
    The reaction of this applicaiton sample is a simple while loop. The user application need 
    to fill this or another error handler with life and with appropriate reactions on the 
    different errors and warnings!
   
    @param[in]  stat        (error) status of an ended EEL operation or of an ended background 
                            operation (operational status is idle)
    @return     ---
*/  
/*********************************************************************************************************************/
void SampleApp_EEL_ErrorHdr( r_eel_status_t stat )
{
    if( R_EEL_OK != stat )
    {
        if( R_EEL_ERR > stat )
        {
            /* If the status is a warning only, we might ignore it */
        }
        else
        {
            /* Error handler */
            while( 1 )
                ;
        }
    }
}


/*********************************************************************************************************************
   Function name:  SampleApp_EEL_HdrLoop
 *********************************************************************************************************************/
/**
    loop to finish initiated EEL operations (REad/Write/Format)
    
    Note:
    This simple sample function just polls the end of an EEL operation. In the user application
    the frequent R_EEL_Handler call will be most probably called differently, e.g. in a timed
    task.
   
    @param[in]  req         pointer to the operations request structure
    
    @return     ---
*/  
/*********************************************************************************************************************/
void SampleApp_EEL_HdrLoop( r_eel_request_t *req )
{
    /* Wait until operation end */
    r_eel_status_t m_condition;
    while( R_EEL_BUSY == req->status_enu )
    {
        R_EEL_Handler();
    }

    m_condition = req->status_enu;
    //SampleApp_EEL_ErrorHdr( req->status_enu);         /* Return value check */
    
    return;
}



/*********************************************************************************************************************
   Function name:  SampleApp_EEL_Init
 *********************************************************************************************************************/
/**
    function to initialize and start of the EEL operation.
    At functions end the EEL has passed the startup processing so far, that either limited access
    is possible (See documentation) or an error has occurred. 
    
    Note: 
    In this simple application sample the startup processing is forwarded by continuous handler 
    function call. So, the function execution time will be long

    @param[in]  req         pointer to the operations request structure
    
    @return     operations status return (OK, warning or error)
*/  
/*********************************************************************************************************************/
r_eel_status_t SampleApp_EEL_Init( void )
{
    r_fdl_status_t                fdlRet;
    r_eel_status_t                eelRet;
    r_eel_driver_status_t         driverStatus;
    r_fdl_request_t               req;
    
    /* 1st initialize the FDL */
    fdlRet = R_FDL_Init( &sampleApp_fdlConfig_enu );
    if( R_FDL_OK != fdlRet )
    {   
        /* Error handler */
        while( 1 )
            ;
    }
    
    /* Prepare the environment */
    req.command_enu     = R_FDL_CMD_PREPARE_ENV;
    req.idx_u32         = 0;
    req.cnt_u16         = 0;
    req.accessType_enu  = R_FDL_ACCESS_NONE;
    R_FDL_Execute( &req );
    
    while( R_FDL_BUSY == req.status_enu )
    {
        R_FDL_Handler();
    }
    if( R_FDL_OK != req.status_enu )
    {   
        /* Error handler */
        while( 1 )
            ;
    }
    
    /* Next initialize the EEL */
    eelRet = R_EEL_Init( &sampleApp_eelConfig_enu, R_EEL_OPERATION_MODE_NORMAL );
    SampleApp_EEL_ErrorHdr( eelRet );         /* Return value check */
    
    eelRet = R_EEL_Startup();
    SampleApp_EEL_ErrorHdr( eelRet );         /* Return value check */
    
    /* Call the R_EEL_Handler for startup processing until limited access is possible or 
       error occurred. */
    do
    {
        R_EEL_Handler();
        R_EEL_GetDriverStatus( &driverStatus );
    }
    /* Wait until early read/write is possible (or error) */
    while(   ( R_EEL_OPERATION_STARTUP == driverStatus.operationStatus_enu )
           &&( R_EEL_ACCESS_LOCKED     == driverStatus.accessStatus_enu) );

    return( driverStatus.backgroundStatus_enu );
}


#if 0
/*********************************************************************************************************************
   Function name:  SampleApp_EEL_Control 
 *********************************************************************************************************************/
/**
    EEL control program. Executing a set of dummy EEPROM emulaiton operations

    @param          ---
    @return         ---
*/  
/*********************************************************************************************************************/
void SampleApp_EEL_Control( void )
{
    r_eel_request_t           myReq;
    r_eel_driver_status_t     driverStatus;
    r_eel_status_t            reqStat;
    uint32_t                 i;
    
    uint8_t wBuf_au08[0x100] =  {   0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 
                                    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 
                                    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 
                                    0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 
                                    0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 
                                    0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 
                                    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 
                                    0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f 
                                };
    uint8_t rBuf_au08[0x100];
    
    
    /* ------------------------------------------------------------------------------------------
        EEL Initialization
        Here we wait until the EEL has at least partly access. Startup processing has not yet 
        ended
       ------------------------------------------------------------------------------------------ */
    reqStat = SampleApp_EEL_Init();

    /* Here we expect:
      driverStatus.operationStatus_enu  = R_EEL_OPERATION_STARTUP
    & driverStatus.accessStatus_enu     = R_EEL_ACCESS_READ_WRITE
    & driverStatus.backgroundStatus_enu = R_EEL_OK
    
    Possible error cases are:
      driverStatus.operationStatus_enu  = R_EEL_OPERATION_STARTUP
    & driverStatus.accessStatus_enu     = R_EEL_ACCESS_READ_WRITE
    & driverStatus.backgroundStatus_enu = a warning

      driverStatus.operationStatus_enu  = R_EEL_OPERATION_PASSIVE
    & driverStatus.accessStatus_enu     = R_EEL_ACCESS_LOCKED
    & driverStatus.backgroundStatus_enu = an error
    */

    /* For debug purpose we can react on an inconsistent pool with format. In the 
       final application, this ought to be avoided as all data is destroyed in the Data Flash */
    if( R_EEL_ERR_POOL_INCONSISTENT == reqStat )
    {    
        myReq.command_enu = R_EEL_CMD_FORMAT;
        R_EEL_Execute( &myReq );
        SampleApp_EEL_HdrLoop( &myReq );

        /* Format procedure ends with EEL re-init */
        reqStat = SampleApp_EEL_Init();
    }

    /* Error check of startup processing (with and without Format) */
    SampleApp_EEL_ErrorHdr( reqStat ); 


    /* ------------------------------------------------------------------------------------------
        Early operations before startup flow of the EEL has completely ended
       ------------------------------------------------------------------------------------------ */
    /* ----- write access ----- */
    myReq.address_pu08 = (uint8_t*)(&wBuf_au08[0]);
    myReq.identifier_u16 = 0xccccu;
    myReq.command_enu = R_EEL_CMD_WRITE;
    R_EEL_Execute( &myReq );
    SampleApp_EEL_HdrLoop( &myReq );

    /* ----- read access ----- */
    for( i=0; i<0x100; i++ )    /* Initialize the read buffer to prove the read effect */
    {
        rBuf_au08[i] = 0xaa;
    }
    myReq.address_pu08 = (uint8_t*)(&rBuf_au08[3]);
    myReq.identifier_u16 = 0xccccu;
    myReq.length_u16 = 0x9u;
    myReq.offset_u16 = 0x13u;
    myReq.command_enu = R_EEL_CMD_READ;
    R_EEL_Execute( &myReq );
    SampleApp_EEL_HdrLoop( &myReq );
                          
    /* ------------------------------------------------------------------------------------------
        Wait for fully operational and access unlock
       ------------------------------------------------------------------------------------------ */
    do
    {
        R_EEL_Handler();
        R_EEL_GetDriverStatus( &driverStatus );
    }
    /* Wait until the system is completely up and running (or error) */
    while( R_EEL_OPERATION_STARTUP == driverStatus.operationStatus_enu );

    /* Here we expect:
      driverStatus.operationStatus_enu  = R_EEL_OPERATION_BUSY or R_EEL_OPERATION_IDLE
    & driverStatus.accessStatus_enu     = R_EEL_ACCESS_UNLOCKED
    & driverStatus.backgroundStatus_enu = R_EEL_OK
    
    Possible error cases are:
      driverStatus.operationStatus_enu  = R_EEL_OPERATION_BUSY or R_EEL_OPERATION_IDLE
    & driverStatus.accessStatus_enu     = R_EEL_ACCESS_UNLOCKED
    & driverStatus.backgroundStatus_enu = a warning

      driverStatus.operationStatus_enu  = R_EEL_OPERATION_PASSIVE
    & driverStatus.accessStatus_enu     = R_EEL_ACCESS_LOCKED
    & driverStatus.backgroundStatus_enu = an error
    */
    
    /* Error check of background processing */
    SampleApp_EEL_ErrorHdr( driverStatus.backgroundStatus_enu ); 


    /* ------------------------------------------------------------------------------------------
        Normal operations 
       ------------------------------------------------------------------------------------------ */
    /* ----- write access ----- */
    myReq.address_pu08 = (uint8_t*)(&wBuf_au08[0]);
    myReq.identifier_u16 = 0xccccu;
    myReq.command_enu = R_EEL_CMD_WRITE;
    R_EEL_Execute( &myReq );
    SampleApp_EEL_HdrLoop( &myReq );

    /* ----- read access ----- */
    for( i=0; i<0x100; i++ )    /* Initialize the read buffer to prove the read effect */
    {
        rBuf_au08[i] = 0xaa;
    }
    myReq.address_pu08 = (uint8_t*)(&rBuf_au08[3]);
    myReq.identifier_u16 = 0xccccu;
    myReq.length_u16 = 0x10u;
    myReq.offset_u16 = 0x13u;
    myReq.command_enu = R_EEL_CMD_READ;
    R_EEL_Execute( &myReq );
    SampleApp_EEL_HdrLoop( &myReq );

    /* ------------------------------------------------------------------------------------------
        Shut down processing
       ------------------------------------------------------------------------------------------ */
    reqStat = R_EEL_ShutDown();
    SampleApp_EEL_ErrorHdr( reqStat ); 
    
    do
    {
        R_EEL_Handler();
        R_EEL_GetDriverStatus( &driverStatus );
    }
    while(R_EEL_OPERATION_PASSIVE != driverStatus.operationStatus_enu );
    
    /* Error check of startup processing (with and without Format) */
    SampleApp_EEL_ErrorHdr( driverStatus.backgroundStatus_enu ); 
    
    return;
}
#endif
r_eel_request_t           EEL_Req;
void EEL_Init(void)
{
     r_eel_status_t            reqStat;
//FDL_Open();
      reqStat = SampleApp_EEL_Init();

    if( R_EEL_ERR_POOL_INCONSISTENT == reqStat )
    {    
        EEL_Req.command_enu = R_EEL_CMD_FORMAT;
        R_EEL_Execute( &EEL_Req );
        SampleApp_EEL_HdrLoop( &EEL_Req );

        /* Format procedure ends with EEL re-init */
        reqStat = SampleApp_EEL_Init();
    }

    /* Error check of startup processing (with and without Format) */
    SampleApp_EEL_ErrorHdr( reqStat ); 
    
}


void EEL_WriteData(uint16 eel_id, uint8_t* data, uint16_t len,uint16_t offset)
{
    
    
    EEL_Req.address_pu08 = data;
    EEL_Req.identifier_u16 = eel_id;
    EEL_Req.length_u16 = len;
    EEL_Req.offset_u16 = offset;
    EEL_Req.command_enu = R_EEL_CMD_WRITE;
    R_EEL_Execute( &EEL_Req );
    SampleApp_EEL_HdrLoop( &EEL_Req );
}


#if 0
void EEL_Test(void)
{
    r_eel_request_t           myReq;
    r_eel_driver_status_t     driverStatus;
    r_eel_status_t            reqStat;
    uint32_t                 i;

    reqStat = SampleApp_EEL_Init();

if( R_EEL_ERR_POOL_INCONSISTENT == reqStat )
    {    
        myReq.command_enu = R_EEL_CMD_FORMAT;
        R_EEL_Execute( &myReq );
        SampleApp_EEL_HdrLoop( &myReq );

        /* Format procedure ends with EEL re-init */
        reqStat = SampleApp_EEL_Init();
    }

    /* Error check of startup processing (with and without Format) */
    SampleApp_EEL_ErrorHdr( reqStat ); 


    /* ------------------------------------------------------------------------------------------
        Early operations before startup flow of the EEL has completely ended
       ------------------------------------------------------------------------------------------ */
    /* ----- write access ----- */
    
        myReq.address_pu08 = (uint8_t*)(&EELFill_Buffer_55[0]);
        myReq.identifier_u16 = 0x1111;
        myReq.command_enu = R_EEL_CMD_WRITE;
        R_EEL_Execute( &myReq );
        SampleApp_EEL_HdrLoop( &myReq );
   
        myReq.address_pu08 = (uint8_t*)(&EELFill_Buffer_AA[0]);
        myReq.identifier_u16 = 0x2222;
        myReq.command_enu = R_EEL_CMD_WRITE;
        R_EEL_Execute( &myReq );
        SampleApp_EEL_HdrLoop( &myReq );
    
  
    myReq.address_pu08 = (uint8_t*)(&EELRead_Buffer[0]);
    myReq.identifier_u16 = 0x1111;
    myReq.length_u16 = 0xff-14u;
    myReq.offset_u16 = 14u;
    myReq.command_enu = R_EEL_CMD_READ;
    R_EEL_Execute( &myReq );
    SampleApp_EEL_HdrLoop( &myReq );


    myReq.address_pu08 = (uint8_t*)(&EELRead_Buffer[0]);
    myReq.identifier_u16 = 0x2222;
    myReq.length_u16 = 0xff-0x08u;
    myReq.offset_u16 = 0x8u;
    myReq.command_enu = R_EEL_CMD_READ;
    R_EEL_Execute( &myReq );
    SampleApp_EEL_HdrLoop( &myReq );
                          
    /* ------------------------------------------------------------------------------------------
        Wait for fully operational and access unlock
       ------------------------------------------------------------------------------------------ */
    do
    {
        R_EEL_Handler();
        R_EEL_GetDriverStatus( &driverStatus );
    }
    /* Wait until the system is completely up and running (or error) */
    while( R_EEL_OPERATION_STARTUP == driverStatus.operationStatus_enu );

    /* Here we expect:
      driverStatus.operationStatus_enu  = R_EEL_OPERATION_BUSY or R_EEL_OPERATION_IDLE
    & driverStatus.accessStatus_enu     = R_EEL_ACCESS_UNLOCKED
    & driverStatus.backgroundStatus_enu = R_EEL_OK
    
    Possible error cases are:
      driverStatus.operationStatus_enu  = R_EEL_OPERATION_BUSY or R_EEL_OPERATION_IDLE
    & driverStatus.accessStatus_enu     = R_EEL_ACCESS_UNLOCKED
    & driverStatus.backgroundStatus_enu = a warning

      driverStatus.operationStatus_enu  = R_EEL_OPERATION_PASSIVE
    & driverStatus.accessStatus_enu     = R_EEL_ACCESS_LOCKED
    & driverStatus.backgroundStatus_enu = an error
    */
    
    /* Error check of background processing */
    SampleApp_EEL_ErrorHdr( driverStatus.backgroundStatus_enu ); 


    /* ------------------------------------------------------------------------------------------
        Shut down processing
       ------------------------------------------------------------------------------------------ */
    reqStat = R_EEL_ShutDown();
    SampleApp_EEL_ErrorHdr( reqStat ); 
    
    do
    {
        R_EEL_Handler();
        R_EEL_GetDriverStatus( &driverStatus );
    }
    while(R_EEL_OPERATION_PASSIVE != driverStatus.operationStatus_enu );
    
    /* Error check of startup processing (with and without Format) */
    SampleApp_EEL_ErrorHdr( driverStatus.backgroundStatus_enu ); 
    
    return;

}

#endif