src/cpu/arm/at91sam7/serialtoflash.c
static inline int page_to_flash(u_long *pagebuf, u_long *flash_adr)
{
    int pagelongs = 1 << (FLASH_PAGE_BITS - 2);
    int i;

    // The FLASH is supposed to be ready now because it takes longer
    // to collect the serial bytes than to write a FLASH page.
    if ((MC_FSR & FRDY) == 0) {
        return -1;
    }

    for (i = 0; i < pagelongs; i++) {
        flash_adr[i] = pagebuf[i];
        pagebuf[i] = flash_adr[i + pagelongs];
    }

    MC_FMR = FCMN(TIMING_FACTOR) | FWS(1);
    MC_FCR = WP(flash_adr);   // Write page

    return 0;
}
// Copy the RAM page buffer to the FLASH page buffer and start writing
// it to FLASH.  Returns nonzero if the FLASH is not ready for writing
// when called.
Copy the RAM page buffer to the FLASH page buffer and start writing
it to FLASH.  Returns nonzero if the FLASH is not ready for writing
when called.
Copy the RAM page buffer to the FLASH page buffer and start writing it to FLASH . Returns nonzero if the FLASH is not ready for writing when called .
static inline int page_to_flash(u_long *pagebuf, u_long *flash_adr)
{
    int pagelongs = 1 << (FLASH_PAGE_BITS - 2);
    int i;
    if ((MC_FSR & FRDY) == 0) {
        return -1;
    }
    for (i = 0; i < pagelongs; i++) {
        flash_adr[i] = pagebuf[i];
        pagebuf[i] = flash_adr[i + pagelongs];
    }
    MC_FMR = FCMN(TIMING_FACTOR) | FWS(1);
    MC_FCR = WP(flash_adr);   
    return 0;
}
static inline int page_to_flash ( u_long * pagebuf , u_long * flash_adr ) { int pagelongs = 1 << ( FLASH_PAGE_BITS - 2 ) ; int i ; if ( ( MC_FSR & FRDY ) == 0 ) { return -1 ; } for ( i = 0 ; i < pagelongs ; i ++ ) { flash_adr [ i ] = pagebuf [ i ] ; pagebuf [ i ] = flash_adr [ i + pagelongs ] ; } MC_FMR = FCMN ( TIMING_FACTOR ) | FWS ( 1 ) ; MC_FCR = WP ( flash_adr ) ; return 0 ; }
Copy the RAM page buffer to the FLASH page buffer and start writing
it to FLASH.
Copy the RAM page buffer to the FLASH page buffer and start writing it to FLASH .
// The FLASH is supposed to be ready now because it takes longer // to collect the serial bytes than to write a FLASH page. // Write page