int main( void )
{
  System_Init();

#if FLASH_RW_U8
  Flash_ErasePages(FLASH_USER_START_ADDR, WRITE_PAGE_NBPAGE);
  Flash_WritePageU8(FLASH_USER_START_ADDR, WriteDataU8, 1024);
  Flash_ReadPageU8(FLASH_USER_START_ADDR, ReadDataU8, 1024);
  if(Cmp_ArrU8(WriteDataU8, ReadDataU8, 1024) == SUCCESS)
    LED_R_Reset();
#endif
  Delay_100ms(5);

#if FLASH_RW_U16
  Flash_ErasePages(FLASH_USER_START_ADDR, WRITE_PAGE_NBPAGE);
  Flash_WritePageU16(FLASH_USER_START_ADDR, WriteDataU16, 512);
  Flash_ReadPageU16(FLASH_USER_START_ADDR, ReadDataU16, 512);
  if(Cmp_ArrU16(WriteDataU16, ReadDataU16, 512) == SUCCESS)
    LED_G_Reset();
#endif
  Delay_100ms(5);

#if FLASH_RW_U32
  Flash_ErasePages(FLASH_USER_START_ADDR, WRITE_PAGE_NBPAGE);
  Flash_WritePageU32(FLASH_USER_START_ADDR, WriteDataU32, 256);
  Flash_ReadPageU32(FLASH_USER_START_ADDR, ReadDataU32, 256);
  if(Cmp_ArrU32(WriteDataU32, ReadDataU32, 256) == SUCCESS)
    LED_B_Reset();
#endif
  Delay_100ms(5);

#if FLASH_RW_U64
  Flash_ErasePages(FLASH_USER_START_ADDR, WRITE_SECTOR_NSECTOR);
  Flash_WritePageU64(FLASH_USER_START_ADDR, WriteDataU64, 128);
  Flash_ReadPageU64(FLASH_USER_START_ADDR, ReadDataU64, 128);
  if(Cmp_ArrU64(WriteDataU64, ReadDataU64, 128) == SUCCESS) {
    LED_R_Toggle;
    Delay_100ms(5);
    LED_R_Toggle;
    Delay_100ms(5);
  }
#endif
  Delay_100ms(20);

  while (1) {
    LED_R_Toggle();
    LED_G_Toggle();
    LED_B_Toggle();
    Delay_100ms(2);
  }
}
Esempio n. 2
0
/*====================================================================================================*/
void testFlash( void )
{
#if FLASH_RW_U8
  Flash_ErasePages(WRITE_SECTOR_START, WRITE_SECTOR_NSECTOR);
  Flash_WritePageU8(FLASH_USER_START_ADDR, WriteDataU8, 1024);
  Flash_ReadPageU8(FLASH_USER_START_ADDR, ReadDataU8, 1024);
  if(Cmp_ArrU8(WriteDataU8, ReadDataU8, 1024) == SUCCESS)
    LED_R_Reset();
#endif
  delay_ms(500);

#if FLASH_RW_U16
  Flash_ErasePages(WRITE_SECTOR_START, WRITE_SECTOR_NSECTOR);
  Flash_WritePageU16(FLASH_USER_START_ADDR, WriteDataU16, 512);
  Flash_ReadPageU16(FLASH_USER_START_ADDR, ReadDataU16, 512);
  if(Cmp_ArrU16(WriteDataU16, ReadDataU16, 512) == SUCCESS)
    LED_G_Reset();
#endif
  delay_ms(500);

#if FLASH_RW_U32
  Flash_ErasePages(WRITE_SECTOR_START, WRITE_SECTOR_NSECTOR);
  Flash_WritePageU32(FLASH_USER_START_ADDR, WriteDataU32, 256);
  Flash_ReadPageU32(FLASH_USER_START_ADDR, ReadDataU32, 256);
  if(Cmp_ArrU32(WriteDataU32, ReadDataU32, 256) == SUCCESS)
    LED_B_Reset();
#endif
  delay_ms(500);

#if FLASH_RW_U64
  Flash_ErasePages(WRITE_SECTOR_START, WRITE_SECTOR_NSECTOR);
  Flash_WritePageU64(FLASH_USER_START_ADDR, WriteDataU64, 128);
  Flash_ReadPageU64(FLASH_USER_START_ADDR, ReadDataU64, 128);
  if(Cmp_ArrU64(WriteDataU64, ReadDataU64, 128) == SUCCESS) {
    LED_R_Toggle;
    Delay_100ms(5);
    LED_R_Toggle;
    Delay_100ms(5);
  }
#endif
  delay_ms(1000);
}