/******************************************************************************* * File Name : r_fsl_praxis01_boot_write.c * Version : 1.00 * Device(s) : RL78/G13( R5F100LEA ) * Tool-Chain : CubeSuite+ ( V1.01 ) * OS : none * H/W Platform : QB-R5F100LE-TB * Description : * Operation : * Limitations : FSL AN-sample. ******************************************************************************/ /****************************************************************************** * History : Version Description * : 09.29.2011 1.00 First Release ******************************************************************************/ /*----------------------------------------------------------------------------*/ /* (#pragma) Expanded functions */ /*----------------------------------------------------------------------------*/ #pragma sfr /* */ #pragma DI /* */ #pragma EI /* */ #pragma NOP /* */ /*----------------------------------------------------------------------------*/ /* Include files */ /*----------------------------------------------------------------------------*/ #include "fsl_user.h" /* */ /*----------------------------------------------------------------------------*/ /* Parameter */ /*----------------------------------------------------------------------------*/ /* */ static __far const fsl_descriptor_t fsl_descriptor_pstr = { 0x00, 0x20, 0x01 }; /*----------------------------------------------------------------------------*/ /* FSL functions */ /*----------------------------------------------------------------------------*/ /****************************************************************************** * Outline : * Include : none * Declaration : UB prFslStart(void) * Function Name : prFslStart * Description : * Argument : none * Return Value : processing result * Calling Functions : prBootWriteProgram ******************************************************************************/ fsl_u08 prFslStart( void ) { fsl_u08 dubRetCode; /* Flash self-programming library initialization */ dubRetCode = FSL_Init( &fsl_descriptor_pstr ); /* When initialization has completed normally */ if( dubRetCode == FSL_OK ) { /* Flash self-programming library start processing */ FSL_Open(); /* */ FSL_PrepareFunctions(); /* */ FSL_PrepareExtFunctions(); } return dubRetCode; } /****************************************************************************** * Outline : * Include : none * Declaration : void prFslEnd(void) * Function Name : prFslEnd * Description : * Argument : none * Return Value : none * Calling Functions : prBootWriteProgram ******************************************************************************/ void prFslEnd( void ) { /* Flash self-programming library end processing */ FSL_Close(); } /****************************************************************************** * Outline : * Include : none * Declaration : void prFslErase(void) * Function Name : prFslErase * Description : * Argument : none * Return Value : none * Calling Functions : ******************************************************************************/ fsl_u08 prFslErase( fsl_u08 start_block,fsl_u08 num ) { fsl_u08 ret_code,erase_cnt,erase_err; if(APP_START_BLOCK <= start_block && 0 < num){ ret_code = prFslStart(); if(FSL_OK==ret_code){ erase_cnt = 0; erase_err = 0; while(erase_cnt=APP_START_ADDR && start_addr<=APP_END_ADDR && 0!=write_num && 0==(write_num%4)) || (start_addr>=DID_0200_ADDR && start_addr<= DID_0201_ADDR && 0!=write_num && 0==(write_num%4)) ) { WriteConfig.fsl_data_buffer_p_u08 = buf; WriteConfig.fsl_destination_address_u32 = start_addr; WriteConfig.fsl_word_count_u08 = (fsl_u08)(write_num/4); ret_code = prFslStart(); if(FSL_OK==ret_code){ DI(); ret_code = FSL_Write(&WriteConfig); EI(); if(FSL_OK==ret_code){ return_code = FSL_OK; } else{ return_code = FSL_ERR_WRITE; } } prFslEnd(); } else{ return_code = FSL_ERR_PARAMETER; } return return_code; }