예제 #1
0
uint8_t    parseUploadReq(uint16_t ssid,uint32_t fileSiz)
{

    if(fileSiz > MAX_FILE_SIZE)
    {
        curSession = 0;
        buildAckPacket(CMD_UPLOAD_REQ,ERR_TOO_LARGE,ssid);
        return 0;
    }

    if (u32IAP_PrepareSectors(APP_START_SECTOR, APP_END_SECTOR) == IAP_STA_CMD_SUCCESS)
    {
        if (u32IAP_EraseSectors(APP_START_SECTOR, APP_END_SECTOR) == IAP_STA_CMD_SUCCESS)
        {
            //uint16_t u16CRC = 0;

            curSession  = ssid;
            totalSize   = fileSiz;
            totalPktNum = fileSiz / PACKET_SIZE;
            u32NextFlashWriteAddr = APP_START_ADDR;
            buildAckPacket(CMD_UPLOAD_REQ,ERR_OK,ssid);
            return 1;
        }
    }

    buildAckPacket(CMD_UPLOAD_REQ,ERR_ERASE,ssid);
    return 0;

}
예제 #2
0
int flash1788_erase_sector(int sectorNumber)
{
    if(sectorNumber<0||sectorNumber>=flash1788_section_address[0]) {
        ASSERT_MINE(0);
    }
    ASSERT_MINE(u32IAP_PrepareSectors(sectorNumber, sectorNumber) == IAP_STA_CMD_SUCCESS);
    ASSERT_MINE(u32IAP_EraseSectors  (sectorNumber, sectorNumber) == IAP_STA_CMD_SUCCESS);
    return 0;
}
예제 #3
0
void saveUtcOffsetToFlash()
{
	flashImage[0] = utcOffset;

	__disable_irq();
	if(u32IAP_PrepareSectors(16, 16) == IAP_STA_CMD_SUCCESS)
	{
		u32IAP_EraseSectors(16, 16);
		u32IAP_PrepareSectors(16, 16);
		if(u32IAP_CopyRAMToFlash(IMG_START_SECTOR, (uint32_t)flashImage, IAP_FLASH_PAGE_SIZE_BYTES) == IAP_STA_CMD_SUCCESS)
		{
			if(u32IAP_Compare(IMG_START_SECTOR, (uint32_t)flashImage, IAP_FLASH_PAGE_SIZE_BYTES, 0) == IAP_STA_CMD_SUCCESS)
			{
				__enable_irq();
				ledSetState(TASK_LED, LedOn);
				return;
			}
		}
	}
	__enable_irq();
	ledSetState(TASK_LED, LedBlink);
}