Platform/ECM3532/M3/hw/csp/ecm3532/m3/csp/src/eta_csp_vhfo.c
/***************************************************************************/
/**
 *
 *  EtaCspVhfoTrimRecord - Record the current trim settings in the flash INO
 *                   page so that it will be used on all subsequent calls
 *                   to initialize the VHFO.
 * @return  eta CSP status
 *          this function will return status fail if any trim values have
 *          already been programmed in to the INFO page. This is OTP!!!
 *
 *
 * WARNING: This function assumes the flash is up and running when called.
 ******************************************************************************/
Record the current trim settings in the flash INO
page so that it will be used on all subsequent calls
to initialize the VHFO.
@return  eta CSP status
this function will return status fail if any trim values have
already been programmed in to the INFO page. This is OTP

This function assumes the flash is up and running when called.
Record the current trim settings in the flash INO page so that it will be used on all subsequent calls to initialize the VHFO . @return eta CSP status this function will return status fail if any trim values have already been programmed in to the INFO page . This is OTP This function assumes the flash is up and running when called .
tEtaStatus
EtaCspVhfoTrimRecord(void)
{
    tEtaStatus EtaStatus = eEtaSuccess;
    uint32_t ui32Value[4];
    uint32_t ui32InfoPage[ETA_CSP_FLASH_PAGE_SIZE_WORDS];
    uint32_t ui32AddressKey   = (VHFO_TRIM_ADDRESS & ~ETA_CSP_FLASH_PAGE_SIZE_MASK)
                              + (VHFO_TRIM_KEY_INDEX<<2);
    uint32_t ui32AddressValue = (VHFO_TRIM_ADDRESS & ~ETA_CSP_FLASH_PAGE_SIZE_MASK)
                              + (VHFO_TRIM_VALUE_INDEX<<2);
     Read the VHFO trm values from flash INFO page.
    EtaCspFlashInfoRead(VHFO_TRIM_ADDRESS, ui32Value);
     Check that VHFO trim key value and trim value are in their unprogrammed
     state.
    if(   (ui32Value[VHFO_TRIM_KEY_INDEX] != 0xFFFFFFFF) 
       || (ui32Value[VHFO_TRIM_VALUE_INDEX] != 0xFFFFFFFF))
    {
        return(eEtaFailure);
    }
     , read the entire INFO page.
    EtaCspFlashInfoGet(ETA_CSP_FLASH_BASE,(uint8_t *)ui32InfoPage,ETA_CSP_FLASH_PAGE_SIZE_BYTES);
     Setup for an 8 byte program operation to the flash INFO page.
    ui32InfoPage[ui32AddressKey >> 2]   = 0x9999AA55;
    ui32InfoPage[ui32AddressValue >> 2] = REG_RTC_OSC_CSR2.V;
     The trim key and trim value are OK to program so do it.
    ETA_CSP_FLASH_INFO_ERASE();
    EtaStatus = ETA_CSP_FLASH_INFO_PROGRAM(ETA_CSP_FLASH_BASE, 
                                           (uint8_t *)ui32InfoPage, 
                                            ETA_CSP_FLASH_PAGE_SIZE_BYTES);
     Return success (I hope).
    return(EtaStatus);
}
tEtaStatus EtaCspVhfoTrimRecord ( void ) { tEtaStatus EtaStatus = eEtaSuccess ; uint32_t ui32Value [ 4 ] ; uint32_t ui32InfoPage [ ETA_CSP_FLASH_PAGE_SIZE_WORDS ] ; uint32_t ui32AddressKey = ( VHFO_TRIM_ADDRESS & ~ ETA_CSP_FLASH_PAGE_SIZE_MASK ) + ( VHFO_TRIM_KEY_INDEX << 2 ) ; uint32_t ui32AddressValue = ( VHFO_TRIM_ADDRESS & ~ ETA_CSP_FLASH_PAGE_SIZE_MASK ) + ( VHFO_TRIM_VALUE_INDEX << 2 ) ; EtaCspFlashInfoRead ( VHFO_TRIM_ADDRESS , ui32Value ) ; if ( ( ui32Value [ VHFO_TRIM_KEY_INDEX ] != 0xFFFFFFFF ) || ( ui32Value [ VHFO_TRIM_VALUE_INDEX ] != 0xFFFFFFFF ) ) { return ( eEtaFailure ) ; } EtaCspFlashInfoGet ( ETA_CSP_FLASH_BASE , ( uint8_t * ) ui32InfoPage , ETA_CSP_FLASH_PAGE_SIZE_BYTES ) ; ui32InfoPage [ ui32AddressKey >> 2 ] = 0x9999AA55 ; ui32InfoPage [ ui32AddressValue >> 2 ] = REG_RTC_OSC_CSR2 . V ; ETA_CSP_FLASH_INFO_ERASE ( ) ; EtaStatus = ETA_CSP_FLASH_INFO_PROGRAM ( ETA_CSP_FLASH_BASE , ( uint8_t * ) ui32InfoPage , ETA_CSP_FLASH_PAGE_SIZE_BYTES ) ; return ( EtaStatus ) ; }
EtaCspVhfoTrimRecord - Record the current trim settings in the flash INO
                   page so that it will be used on all subsequent calls
                   to initialize the VHFO.
EtaCspVhfoTrimRecord - Record the current trim settings in the flash INO page so that it will be used on all subsequent calls to initialize the VHFO .
// // Read the VHFO trm values from flash INFO page. // // // Check that VHFO trim key value and trim value are in their unprogrammed // state. // // // , read the entire INFO page. // // // Setup for an 8 byte program operation to the flash INFO page. // // // The trim key and trim value are OK to program so do it. // // // Return success (I hope). //