/******************************************************************************************************** * 名 称:Synchro8563 * 功 能:从8563中读取时间,并设置RTC * 入口参数:none * 出口参数:FALSE or TRUE *********************************************************************************************************/ void Synchro8563(void) { RTCDateTime l_rdtTemp; GET8563(&l_rdtTemp); //读取8563 SetRTC(&l_rdtTemp); //将读出的时间保持到RTC }
//----- (00002788) -------------------------------------------------------- __myevic__ void hidGetOutReport( uint8_t *pu8Buffer, uint32_t u32BufferLen ) { uint8_t u8Cmd; uint8_t *hidDataPtr; uint32_t u32StartAddr; uint32_t u32DataSize; uint32_t u32ByteCount; uint32_t u32Page; uint32_t sz; uint32_t veo; u8Cmd = hidCmd.u8Cmd; u32StartAddr = hidCmd.u32Arg1; u32DataSize = hidCmd.u32Arg2; u32ByteCount = hidCmd.u32Signature; hidDataPtr = &hidData[hidDataIndex]; switch ( hidCmd.u8Cmd ) { case HID_CMD_SETPARAMS: { USBD_MemCopy( hidDataPtr, pu8Buffer, EP3_MAX_PKT_SIZE ); hidDataIndex += EP3_MAX_PKT_SIZE; if ( hidDataIndex >= u32DataSize ) { u8Cmd = HID_CMD_NONE; if ( u32StartAddr + u32DataSize > FMC_FLASH_PAGE_SIZE ) { sz = FMC_FLASH_PAGE_SIZE - u32StartAddr; } else { sz = u32DataSize; } MemCpy( (uint8_t*)(&hidDFData) + u32StartAddr, hidData, sz ); myprintf( "Set Sys Param complete.\n" ); dfStruct_t * df = (dfStruct_t*)hidDFData; if ( Checksum( (uint8_t*)df->params, FMC_FLASH_PAGE_SIZE - 4 ) == df->Checksum ) { myprintf( "\tCompany ID ............................ [0x%08x]\n", df->i.fmcCID ); myprintf( "\tDevice ID ............................. [0x%08x]\n", df->i.fmcDID ); myprintf( "\tProduct ID ............................ [0x%08x]\n", df->i.fmcPID ); myprintf( "\tu8UpdateAPRom ......................... [0x%08x]\n", df->p.BootFlag ); MemCpy( DataFlash.params, df->params, DATAFLASH_PARAMS_SIZE ); DFCheckValuesValidity(); UpdateDataFlash(); if ( df->i.Year >= 2000 && df->i.Year <= 2099 ) { S_RTC_TIME_DATA_T rtd; rtd.u32Year = df->i.Year; rtd.u32Month = df->i.Month; rtd.u32Day = df->i.Day; rtd.u32DayOfWeek = 0; rtd.u32Hour = df->i.Hour; rtd.u32Minute = df->i.Minute; rtd.u32Second = df->i.Second; rtd.u32TimeScale = RTC_CLOCK_24; SetRTC( &rtd ); } gFlags.refresh_display = 1; } else { myprintf( "Sys Param Receive fail.\n" ); } hidDataIndex = 0; } break; } case HID_CMD_SETLOGO: { USBD_MemCopy( hidDataPtr, pu8Buffer, EP3_MAX_PKT_SIZE ); hidDataIndex += EP3_MAX_PKT_SIZE; if ( hidDataIndex < FMC_FLASH_PAGE_SIZE && hidDataIndex + u32ByteCount < u32DataSize ) { break; } u32Page = u32StartAddr + u32ByteCount; myprintf( "Writing page %d\n", u32Page ); SYS_UnlockReg(); FMC_ENABLE_ISP(); FMC_ENABLE_AP_UPDATE(); if ( FMCEraseWritePage( u32Page, (uint32_t*)hidData ) ) { myprintf( "Data Flash Erase error!\n" ); } veo = FMCVerifyPage( u32Page, (uint32_t*)hidData ); if ( veo ) { myprintf( "Data Flash Verify error! 0x%x\n", 4 * veo - 4 ); } MemClear( hidData, FMC_FLASH_PAGE_SIZE ); u32ByteCount += hidDataIndex; myprintf( "g_u32BytesInPageBuf %d, u32LenCnt 0x%x\n", hidDataIndex, u32ByteCount ); FMC_DISABLE_AP_UPDATE(); FMC_DISABLE_ISP(); SYS_LockReg(); if ( u32ByteCount < u32DataSize ) { hidDataIndex = 0; } else { u8Cmd = HID_CMD_NONE; myprintf( "set boot logo command complete.\n" ); } break; } case HID_CMD_LDUPDATE: { USBD_MemCopy( hidDataPtr, pu8Buffer, EP3_MAX_PKT_SIZE ); hidDataIndex += EP3_MAX_PKT_SIZE; if ( hidDataIndex < FMC_FLASH_PAGE_SIZE && hidDataIndex + u32ByteCount < u32DataSize ) { break; } u32Page = u32StartAddr + u32ByteCount; myprintf( "Writing page 0x%08X\n", u32Page ); SYS_UnlockReg(); FMC_ENABLE_ISP(); FMC_EnableLDUpdate(); if ( FMCEraseWritePage( u32Page, (uint32_t*)hidData ) ) { myprintf( "Data Flash Erase error!\n" ); } veo = FMCVerifyPage( u32Page, (uint32_t*)hidData ); if ( veo ) { myprintf( "Data Flash Verify error! 0x%x\n", 4 * veo - 4 ); } MemClear( hidData, FMC_FLASH_PAGE_SIZE ); u32ByteCount += hidDataIndex; hidDataIndex = 0; myprintf( "g_u32BytesInPageBuf %d, u32LenCnt 0x%x\n", hidDataIndex, u32ByteCount ); FMC_DisableLDUpdate(); FMC_DISABLE_ISP(); SYS_LockReg(); if ( u32ByteCount >= u32DataSize ) { u8Cmd = HID_CMD_NONE; myprintf( "Update LDROM command complete.\n" ); } break; } default: { if ( hidProcessCommand( pu8Buffer, u32BufferLen ) ) { myprintf( "Unknown HID command!\n" ); } return; } } hidCmd.u8Cmd = u8Cmd; hidCmd.u32Signature = u32ByteCount; }
/******************************************************************************************************** * 名 称:SetRTCTime * 功 能:设置RTC时间 * 入口参数:p_pstTime * 出口参数:无 *********************************************************************************************************/ void SetRTCTime(SystemTime * p_pstTime) { SET8563(p_pstTime); //设置8563 SetRTC(p_pstTime); //设置RTC }
__myevic__ int DTMenuOnEvent( int event ) { int vret = 0; ScreenDuration = 120; switch ( event ) { case 1: switch ( CurrentMenuItem ) { case 0: case 1: if ( --dt_sel < 0 ) { dt_sel = 2; ++CurrentMenuItem; } gFlags.refresh_display = 1; vret = 1; break; case 3: { SetRTC( &rtd ); } break; default: break; } break; case 2: switch ( CurrentMenuItem ) { case 0: switch ( dt_sel ) { case 0: ++rtd.u32Second; rtd.u32Second %= 60; break; case 1: ++rtd.u32Minute; rtd.u32Minute %= 60; break; case 2: ++rtd.u32Hour; rtd.u32Hour %= 24; break; } gFlags.refresh_display = 1; vret = 1; break; case 1: switch ( dt_sel ) { case 0: if ( rtd.u32Year < RTC_YEAR2000 + 1000 ) ++rtd.u32Year; break; case 1: rtd.u32Month = (rtd.u32Month+1) %12; break; case 2: rtd.u32Day = (rtd.u32Day+1) %31; break; } gFlags.refresh_display = 1; vret = 1; break; default: break; } break; case 3: switch ( CurrentMenuItem ) { case 0: switch ( dt_sel ) { case 0: rtd.u32Second = ( rtd.u32Second + 59 ) % 60; break; case 1: rtd.u32Minute = ( rtd.u32Minute + 59 ) % 60; break; case 2: rtd.u32Hour = ( rtd.u32Hour + 23 ) % 24; break; } gFlags.refresh_display = 1; vret = 1; break; case 1: switch ( dt_sel ) { case 0: if ( rtd.u32Year > RTC_YEAR2000 ) --rtd.u32Year; break; case 1: rtd.u32Month = ( rtd.u32Month+11 ) %12; break; case 2: rtd.u32Day = ( rtd.u32Day + 30 ) %31; break; } gFlags.refresh_display = 1; vret = 1; break; default: break; } break; default: break; } return vret; }