static void ReadTouchScreenPress(void) { int xDpos; int yDpos; POINT stDisplayPoint; POINT stTouchScreenPoint; do { if(IsTSPress) { IsTSPress = 0; stTouchScreenPoint.x = x_val[0]; stTouchScreenPoint.y = y_val[0]; getDisplayPoint(&stDisplayPoint, &stTouchScreenPoint, &stMatrix); xDpos = stDisplayPoint.x; xDpos = LCD_WIDTH - xDpos; if(xDpos < 0) { xDpos = 0; } if(xDpos > LCD_WIDTH) { xDpos = LCD_WIDTH; } UARTPuts("xDpos=",-1); UARTPutNum(xDpos); yDpos = stDisplayPoint.y; yDpos = LCD_HEIGHT - yDpos; if(yDpos < 0) { yDpos = 0; } if(yDpos > LCD_HEIGHT) { yDpos = LCD_HEIGHT; } UARTPuts("yDpos=",-1); UARTPutNum(yDpos); UARTPuts("\r\n", -1); } } while (1); }
unsigned int mpeg_idle(mpeg_struct_t *Mpeg_Struct, new_screen* ScreenBuff, FileInfo_t *mpgfile) { if(!Mpeg_Struct) return 0; if(!Mpeg_Struct->FrameReady) { do { Mpeg_Struct->state = mpeg2_parse(Mpeg_Struct->decoder); switch (Mpeg_Struct->state) { case STATE_BUFFER: //size = fread (buffer, 1, _BUFFER_SIZE_, mpgfile); Mpeg_Struct->size = read_from_buffer(Mpeg_Struct->buffer, 1, _BUFFER_SIZE_, mpgfile); if(!Mpeg_Struct->size) break; mpeg2_buffer (Mpeg_Struct->decoder, Mpeg_Struct->buffer, Mpeg_Struct->buffer + Mpeg_Struct->size); break; case STATE_SEQUENCE: mpeg2_convert (Mpeg_Struct->decoder, Mpeg_Struct->mpeg_convert, NULL); break; case STATE_SLICE: case STATE_END: case STATE_INVALID_END: if (Mpeg_Struct->info->display_fbuf) Mpeg_Struct->FrameReady = 1; break; default: break; } }while(!Mpeg_Struct->FrameReady && Mpeg_Struct->size); } #ifndef AVR32 if(Mpeg_Struct->FrameReady == true && (timer_tick(&Mpeg_Struct->FrameDisplay) == true || Mpeg_Struct->EnableFrameLimit == false)) #else if(Mpeg_Struct->FrameReady == true) #endif { Mpeg_Struct->FrameReady = false; /*save_ppm (ScreenBuff, Mpeg_Struct->info->sequence->width, Mpeg_Struct->info->sequence->height, Mpeg_Struct->info->display_fbuf->buf[0], Mpeg_Struct->framenum++);*/ _Fps++; //Mpeg_Struct->->info if(Mpeg_Struct->info->current_picture->temporal_reference != Mpeg_Struct->temporal_reference) { Mpeg_Struct->temporal_reference = Mpeg_Struct->info->current_picture->temporal_reference; Mpeg_Struct->CallbackDisplayFrame((void*)Mpeg_Struct->CallbackDisplayFrameVariable, Mpeg_Struct->info->display_fbuf->buf[0], 0, 0, Mpeg_Struct->info->sequence->width, Mpeg_Struct->info->sequence->height); } if(CntToDetermineTheFps != rtcSecUpdate) { CntToDetermineTheFps = rtcSecUpdate; //UARTPuts(DebugCom, "Screen fill capability = ", -1); UARTPutNum(DebugCom, _Fps); UARTPuts(DebugCom, "Fps\n\r", -1); _Fps = 0; } } //if(Mpeg_Struct->size == 0) mpeg2_close (Mpeg_Struct->decoder); return Mpeg_Struct->size; }
/* ** This function will verify the data written to and read from flash and will ** print the appropriate message. */ static void VerifyData(void) { unsigned int index = 0; for(index = 4; index < 260; index++) { if(rxBuffer[index] != vrfyData[index - 4]) { UARTPuts("\r\n\r\n", -1); UARTPuts("VerifyData: Comparing the data written to and read", -1); UARTPuts(" from flash.\r\nThe two data blocks are unequal.", -1); UARTPuts(" Mismatch found at index ", -1); UARTPutNum((int)index + 1); UARTPuts("\r\nThe data in the Flash and the one written ", -1); UARTPuts("to it are not equal.\r\n", -1); break; } } if(260 == index) { UARTPuts("\r\nThe data in the Flash and the one written ", -1); UARTPuts("to it are equal.\r\n", -1); } }
/****************************************************************************** * * * \brief This function prints the device ID info of NAND.\n * * * * \param nandInfo Pointer to structure which conatins controller and * * device information. * * * * \return none. * * * ******************************************************************************/ static void NANDDeviceIdInfoPrint(NandInfo_t *nandInfo) { UARTPuts(" ****************** NAND DEVICE INFO ****************** \r\n",-1); UARTPuts(" MANUFACTURER ID : ",-1); UARTPutHexNum((unsigned int)nandInfo->manId); UARTPuts("\r\n", -1); UARTPuts(" DEVICE ID : ",-1); UARTPutHexNum((unsigned int)nandInfo->devId); UARTPuts("\r\n", -1); UARTPuts(" PAGESIZE : ",-1); UARTPutNum((unsigned int)nandInfo->pageSize); UARTPuts(" Bytes\r\n", -1); UARTPuts(" BLK SIZE : ",-1); UARTPutNum((unsigned int)nandInfo->blkSize); UARTPuts(" Bytes\r\n", -1); UARTPuts(" PAGES PER BLOCK : ",-1); UARTPutNum((unsigned int)nandInfo->pagesPerBlk); UARTPuts("\r\n", -1); UARTPuts(" ****************************************************** \r\n",-1); }
static unsigned int verifyData(volatile char *string1, volatile char *string2, unsigned int length) { unsigned int index = 0; unsigned int retVal = TRUE; for(index = 0; index < length; index++) { if(*string1++ != *string2++) { retVal = FALSE; UARTPuts("\r\n\r\n", -1); UARTPuts("VerifyData: Comparing the data written to and read", -1); UARTPuts(" from flash.\r\nThe two data blocks are unequal.", -1); UARTPuts(" Mismatch found at index ", -1); UARTPutNum((int)index + 1); break; } } return retVal; }
/****************************************************************************** * * * \brief Main Function.\n * * * ******************************************************************************/ int main(void) { int blkNum; int pageNum; int numOfPages; unsigned int retVal; unsigned int eraseBlkFlg; /* NAND structure allocations for this application */ NandInfo_t nandInfo; NandCtrlInfo_t nandCtrlInfo; NandEccInfo_t nandEccInfo; NandDmaInfo_t nandDmaInfo; EMIFANANDTimingInfo_t nandTimingInfo; /* Initializing the UART instance for serial communication. */ UARTStdioInit(); UARTPuts("\r\n ************* StarterWare NAND Application ************" "\r\n\r\n", -1); /* Pin mux and clock setting */ EMIFAClkConfig(); NANDPinMuxSetup(); /* Initialize the nandInfo struct */ nandCtrlInfo.hNandTimingInfo = (void *) &nandTimingInfo; nandInfo.hNandCtrlInfo = &nandCtrlInfo; nandInfo.hNandEccInfo = &nandEccInfo; nandInfo.hNandDmaInfo = &nandDmaInfo; NANDInfoInit(&nandInfo, NAND_CHIP_SELECT); /* Open the NAND device */ retVal = NANDOpen(&nandInfo); if (retVal & NAND_STATUS_FAILED) { UARTPuts("\r\n*** ERROR : NAND Open Failed... ",-1); while(1); } else if (retVal & NAND_STATUS_WAITTIMEOUT) { UARTPuts("\r\n*** ERROR : Device Is Not Ready...!!!\r\n", -1); while(1); } else if (retVal & NAND_STATUS_NOT_FOUND) { UARTPuts("\r\n*** ERROR : DEVICE MAY NOT BE ACCESSABLE OR NOT PRESENT." "\r\n", -1); while(1); } else if(nandInfo.devId != NAND_DEVICE_ID) { /* Check if detected ID matches supplied ID */ UARTPuts("\r\n*** ERROR : INVALID DEVICE ID.", -1); while(1); } else { /* Print The Device ID info */ NANDDeviceIdInfoPrint(&nandInfo); } #ifdef NAND_DATAINTEGRITY_TEST_WITH_FIXED_ADDR /* Do read/write for predefined address */ pageNum = NAND_DEFAULT_START_PAGE; blkNum = NAND_DEFAULT_BLK; numOfPages = NAND_DEFAULT_NMBR_OF_PAGES; #else /* Take the read/write address from the user */ UARTPuts("\r\n Please Enter The Block Number(0 - ", -1); UARTPutNum((unsigned int)(NAND_NUMOF_BLK - 1)); UARTPuts(")\r\n", -1); blkNum = UARTGetNum(); UARTPuts("\r\n Please Enter The Page Start Page Number(0 - ", -1); UARTPutNum((unsigned int)(nandInfo.pagesPerBlk - 1)); UARTPuts(")\r\n", -1); pageNum = UARTGetNum(); UARTPuts("\r\n Please Enter The Number Of Pages To Write\r\n", -1); numOfPages = UARTGetNum(); #endif eraseBlkFlg = 1; if( (pageNum < 0 ) || (pageNum > (nandInfo.pagesPerBlk - 1)) || (blkNum < 0 || blkNum > (NAND_NUMOF_BLK - 1)) || (numOfPages <= 0) ) { UARTPuts("\r\n *** ERROR : Wrong Input(s) Entered...!!!\r\n", -1); while(1); } else if( ( blkNum * (nandInfo.pagesPerBlk ) + pageNum + numOfPages ) > ( NAND_NUMOF_BLK * nandInfo.pagesPerBlk)) { UARTPuts("\r\n *** ERROR : Requsted Page(s) For Read/Write Does Not" " Exist...!!!\r\n", -1); while(1); } while( numOfPages > 0 ) { if( eraseBlkFlg ) { retVal = NANDBadBlockCheck(&nandInfo, blkNum); if(retVal == NAND_BLOCK_BAD) { UARTPuts("\r\n Block Is Bad, Can't Continue ...!!! ",-1); while(1); } if(retVal == NAND_BLOCK_SPARE_AREA_READ_FAILED) { UARTPuts("\r\n Spare Area Read Failed While Checking ", -1); UARTPuts(" For Bad Block ", -1); while(1); } UARTPuts("\r\n Erasing The Block ", -1); UARTPutNum((unsigned int)blkNum); UARTPuts(" :", -1); retVal = NANDBlockErase(&nandInfo, blkNum); if( retVal == NAND_STATUS_PASSED ) { UARTPuts(" Succeeded.",-1); } else { UARTPuts(" Failed.", -1); UARTPuts("\r\n Marking The Block As Bad.\r\n Read/Write Test", -1); UARTPuts(" Will Be Continued On Next block. ", -1); NANDMarkBlockAsBad(&nandInfo, blkNum); blkNum++; pageNum = 0; eraseBlkFlg = 1; continue; } eraseBlkFlg = 0; } NANDBuffersInit(); UARTPuts("\r\n Writing To Page ", -1); UARTPutNum((unsigned int)pageNum); UARTPuts(" Of Block ", -1); UARTPutNum((unsigned int)blkNum); UARTPuts(" :", -1); retVal = NANDPageWrite(&nandInfo, blkNum, pageNum, &txData[0], &eccData[0]); if( (retVal & NAND_STATUS_WAITTIMEOUT) ) { UARTPuts(" Failed.(Device Is Busy).", -1); while(1); } else if( (retVal & NAND_STATUS_DEVWRPROTECT) ) { UARTPuts(" Failed.(Device Is Write Protected).", -1); while(1); } else if( (retVal & NAND_STATUS_READWRITE_DMA_FAIL) ) { UARTPuts(" Failed.(EDMA Transfer Failed.).", -1); while(1); } else { UARTPuts(" Succeeded.", -1); } /* As eccData, is filled by NANDPageWrite fun, reinit the same */ NANDBuffersInit(); UARTPuts("\r\n Reading From Page ", -1); UARTPutNum((unsigned int)pageNum); UARTPuts(" Of Block ", -1); UARTPutNum((unsigned int)blkNum); UARTPuts(" :", -1); retVal= NANDPageRead(&nandInfo, blkNum, pageNum, &rxData[0], &eccData[0]); if( (retVal & NAND_STATUS_READ_ECC_ERROR_CORRECTED) ) { UARTPuts(" Succeeded With ECC Errors And Corrected.", -1); } else if( (retVal & NAND_STATUS_READ_ECC_UNCORRECTABLE_ERROR) ) { UARTPuts(" Failed.(Uncorrectable ECC errors) ", -1); while(1); } else if( (retVal & NAND_STATUS_READWRITE_DMA_FAIL) ) { UARTPuts(" Failed.(EDMA Transfer Failed.)", -1); while(1); } else { UARTPuts(" Succeeded.",-1); } UARTPuts("\r\n NAND Data Integrity Test :", -1); retVal = NANDDataIntegrityCheck(); if(retVal == NAND_DATA_INTEGRITY_PASS) { UARTPuts(" Passed\r\n", -1); } else { UARTPuts(" Failed....!!!\r\n", -1); } pageNum++; numOfPages--; if( pageNum == ((nandInfo.pagesPerBlk) ) ) { pageNum = 0; eraseBlkFlg = 1; blkNum++; } } UARTPuts("\r\n ****************************************************** ", -1); while(1); }