//****************************************************************************** // Temp Sensor Test // This function tests the temp sensor on the PRU Cape. If the temperature // rises, a red LED will turn on. If the temperature falls, a blue LED // will turn on. //****************************************************************************** int HDQTest(void) { char answer[1]; ConsoleUtilsPrintf("\n**************************************************************\n"); ConsoleUtilsPrintf("\n TEMP SENSOR TEST \n"); ConsoleUtilsPrintf("\n**************************************************************\n"); ConsoleUtilsPrintf("\nLoading PRU Instructions and Data.\n"); PRUMemLoad(PRU_ICSS1, PRU0_IRAM, 0, sizeof(SLAVE_INST), (unsigned int*)SLAVE_INST); PRUMemLoad(PRU_ICSS1, PRU0_DRAM, 0, sizeof(SLAVE_DATA), (unsigned int*)SLAVE_DATA); PRUMemLoad(PRU_ICSS1, PRU1_IRAM, 0, sizeof(MASTER_INST), (unsigned int*)MASTER_INST); PRUMemLoad(PRU_ICSS1, PRU1_DRAM, 0, sizeof(MASTER_DATA), (unsigned int*)MASTER_DATA); PRUEnable(PRU_ICSS1, PRU1); PRUEnable(PRU_ICSS1, PRU0); ConsoleUtilsPrintf("\nDoes the red and blue LEDs light up during heating and \n cooling the temperature sensor? y/n\n"); ConsoleUtilsGets(answer, 3); PRUHalt(PRU_ICSS1, PRU0); PRUHalt(PRU_ICSS1, PRU1); return(answer[0]); }
int main(void) { /* Setup the MMU and do necessary MMU configurations. */ MMUConfigAndEnable(); /* Enable all levels of CACHE. */ CacheEnable(CACHE_ALL); /* Initialize the UART console */ ConsoleUtilsInit(); /* Select the console type based on compile time check */ ConsoleUtilsSetType(CONSOLE_UART); ConsoleUtilsPrintf("McASP Example Application. "); ConsoleUtilsPrintf("Please connect headphone/speaker to the LINE OUT"); ConsoleUtilsPrintf(" of the EVM to listen to the audio tone."); /* Enable the module clock for I2C0 Instance. */ I2C0ModuleClkConfig(); /* Set up the pin mux for I2C0 instance. */ I2CPinMuxSetup(0); /* Enable the module clock for McASP1 Instance. */ McASP1ModuleClkConfig(); /* Enable pin-mux for McASP1 instance. */ McASP1PinMuxSetup(); /* Enable the EDMA module clocks. */ EDMAModuleClkConfig(); /* Initialize the ARM Interrupt Controller.*/ IntAINTCInit(); /* Enable EDMA Interrupt. */ EDMA3IntSetup(); /* Enable McASP Interrupt. */ McASPIntSetup(); /* Initialize the I2C interface for the codec AIC31 */ I2CCodecIfInit(I2C_INST_BASE, I2C_SLAVE_CODEC_AIC31); /* Enable the interrupts generation at global level */ IntMasterIRQEnable(); /* Configure the Codec for I2S mode */ AudioCodecInit(); /* Initialize the looping of tone. */ ToneLoopInit(); /* Start playing tone. */ AudioTxActivate(); while(1); }
void enableWakeSource(unsigned int wakeSource) { StepDisable(); /* TS Step disable */ switch(wakeSource) { case WAKE_SOURCE_TSC: /* Enable touch screen wake */ configTSWakeup(); enableTSWakeup(); /* Skip ADC IO Pads for low power mode configuration */ IOPadSel(&ctrlContext, CONTROL_CONF_AIN0, true); IOPadSel(&ctrlContext, CONTROL_CONF_AIN1, true); IOPadSel(&ctrlContext, CONTROL_CONF_AIN2, true); IOPadSel(&ctrlContext, CONTROL_CONF_AIN3, true); IOPadSel(&ctrlContext, CONTROL_CONF_AIN4, true); IOPadSel(&ctrlContext, CONTROL_CONF_AIN5, true); IOPadSel(&ctrlContext, CONTROL_CONF_AIN6, true); IOPadSel(&ctrlContext, CONTROL_CONF_AIN7, true); break; case WAKE_SOURCE_UART: enableUartWakeup(); /* Skip UART IO Pads for low power mode configuration */ IOPadSel(&ctrlContext, CONTROL_CONF_UART_CTSN(0), true); IOPadSel(&ctrlContext, CONTROL_CONF_UART_RTSN(0), true); IOPadSel(&ctrlContext, CONTROL_CONF_UART_RXD(0), true); IOPadSel(&ctrlContext, CONTROL_CONF_UART_TXD(0), true); break; case WAKE_SOURCE_TMR: ConsoleUtilsPrintf("\t...system will wakeup after 20 Sec... "); setTimerCount(TIMER_OVRFLW_20_SECOND_16KHZ); /* 20 Sec */ break; case WAKE_SOURCE_GPIO: configWakeGpio(); enableGpioWake(); /* Skip GPIO SW Pad for low power mode configuration */ IOPadSel(&ctrlContext, GPIO_SW_PAD_OFFSET, true); break; case WAKE_SOURCE_RTC: ConsoleUtilsPrintf("\t..Alarm is configured to wakeup system after " "20 Sec.."); configWakeRTC(); enableRTCAlarmWake(); break; default: break; } }
int main(void) { unsigned int triggerValue = 0; unsigned char inputVal = 0u; /* Setup the MMU and do necessary MMU configurations. */ MMUConfigAndEnable(); /* Enable all levels of CACHE. */ CacheEnable(CACHE_ALL); /* Initialize the UART console */ ConsoleUtilsInit(); /* Select the console type based on compile time check */ ConsoleUtilsSetType(CONSOLE_UART); /* Enable the WDT clocks */ WatchdogTimer1ModuleClkConfig(); /* Reset the Watchdog Timer */ WatchdogTimerReset(SOC_WDT_1_REGS); /* Disable the Watchdog timer */ WatchdogTimerDisable(SOC_WDT_1_REGS); /* Perform the initial settings for the Watchdog Timer */ WatchdogTimerSetUp(); /* Send the message to UART console */ ConsoleUtilsPrintf("Program Reset!"); ConsoleUtilsPrintf("Input any key at least once in every 4 seconds"); ConsoleUtilsPrintf(" to avoid a further reset.\n\r"); /* Enable the Watchdog Timer */ WatchdogTimerEnable(SOC_WDT_1_REGS); while(1) { /* Wait for an input through console. If no input is given, ** the WDT will timeout and reset will occur. */ if(ConsoleUtilsScanf("%c", &inputVal)) { triggerValue += 1; /* Write into the trigger register. This will load the value from the ** load register into the counter register and hence timer will start ** from the initial count. */ WatchdogTimerTriggerSet(SOC_WDT_1_REGS, triggerValue); } } }
/* ** Wait for ACK from CM3 */ void waitForM3Txevent(void) { /* wait until CM3 TX Event is generated */ while(!isM3IntReceived); while(PM_IN_PROGRESS == readCmdStatus()) { CM3EventsClear(); } switch(readCmdStatus()) { case PM_CMD_PASS: case PM_WAIT4OK: break; case PM_CMD_FAIL: default: /* Command failed or invalid status */ ConsoleUtilsPrintf("\n\n ACK Failed \r\n"); while(1); } CM3EventsClear(); /* Reset interrupt flag */ isM3IntReceived = 0; }
/* ** Perform file operations on MMCSD */ static void ActionMMCSD(void) { pmFlag = FALSE; rtcSetFlag = FALSE; tmrClick = FALSE; tmrFlag = FALSE; LedOff(); if(TRUE == HSMMCSDCardPresentStat()) { sdCardAccessFlag = TRUE; } else { sdCardAccessFlag = FALSE; ConsoleUtilsPrintf("\n\rSD card not present. Please insert an" " SD card and try again! \n\r"); } /* ** Check for SD Card */ if(TRUE == sdCardAccessFlag) { HSMMCSDCardAccessSetup(); } pageIndex = MENU_IDX_SD; UpdateUartConsoleHelp(); }
/* ** Print on Uart console the available configuration to navigate. */ void UpdateUartConsoleHelp(void) { unsigned int idx = 0; unsigned int numIcon = contextInfo[pageIndex].numIcon; tPageNavSpec const *pageNavSpec; ConsoleUtilsPrintf("\n\r\n\r Select/Execute/Goto: "); for(idx = 0; idx < numIcon; idx++) { pageNavSpec = contextInfo[pageIndex].pageNavSpec + idx; ConsoleUtilsPrintf("\n\r %d. %s", idx, pageNavSpec->helpStr); } ConsoleUtilsPrintf("\n\r Selected: "); }
/* ** Steps to be taken when DS0 is selected */ void ActionDeepSleep0(void) { ConsoleUtilsPrintf("\n\rEntering DS0 Power Saving Mode..."); PowerSaveModeEnter(ds0Data, SLEEP_MODE_DS0); /* update the console */ UpdateUartConsoleHelp(); }
/****************************************************************************** ** FUNCTION DEFINITIONS *******************************************************************************/ int main(void) { /* This function will enable clocks for the DMTimer2 instance */ DMTimer2ModuleClkConfig(); /* Initialize the UART console */ ConsoleUtilsInit(); /* Select the console type based on compile time check */ ConsoleUtilsSetType(CONSOLE_UART); /* Enable IRQ in CPSR */ IntMasterIRQEnable(); /* Register DMTimer2 interrupts on to AINTC */ DMTimerAintcConfigure(); /* Perform the necessary configurations for DMTimer */ DMTimerSetUp(); /* Enable the DMTimer interrupts */ DMTimerIntEnable(SOC_DMTIMER_2_REGS, DMTIMER_INT_OVF_EN_FLAG); ConsoleUtilsPrintf("Tencounter: "); /* Start the DMTimer */ DMTimerEnable(SOC_DMTIMER_2_REGS); while(cntValue) { if(flagIsr == 1) { ConsoleUtilsPrintf("\b%d",(cntValue - 1)); cntValue--; flagIsr = 0; } } /* Stop the DMTimer */ DMTimerDisable(SOC_DMTIMER_2_REGS); PRINT_STATUS(S_PASS); /* Halt the program */ while(1); }
//****************************************************************************** // LED Test // This function tests the 7 LEDs on the PRU Cape. //****************************************************************************** int LEDTest(void) { char answer[1]; ConsoleUtilsPrintf("\n**************************************************************\n"); ConsoleUtilsPrintf("\n LED TEST \n"); ConsoleUtilsPrintf("\n**************************************************************\n"); ConsoleUtilsPrintf("\nLoading PRU0 Instructions and Data...\n"); PRUMemLoad(PRU_ICSS1, PRU0_IRAM, 0, sizeof(LED0_INST), (unsigned int*)LED0_INST); PRUMemLoad(PRU_ICSS1, PRU0_DRAM, 0, sizeof(LED0_DATA), (unsigned int*)LED0_DATA); ConsoleUtilsPrintf("\nLoading PRU1 Instructions and Data...\n"); PRUMemLoad(PRU_ICSS1, PRU1_IRAM, 0, sizeof(LED1_INST), (unsigned int*)LED1_INST); PRUMemLoad(PRU_ICSS1, PRU1_DRAM, 0, sizeof(LED1_DATA), (unsigned int*)LED1_DATA); ConsoleUtilsPrintf("\nRunning PRUs...\n"); PRUEnable(PRU_ICSS1, PRU0); PRUEnable(PRU_ICSS1, PRU1); ConsoleUtilsPrintf("\nDo you see all 7 LEDs flashing? y/n\n"); ConsoleUtilsGets(answer, 3); PRUHalt(PRU_ICSS1, PRU0); PRUHalt(PRU_ICSS1, PRU1); return(answer[0]); }
/* ** Select wake source */ void ActionWakeOnTimer() { /* update wake source */ wakeSource = WAKE_SOURCE_TMR; ConsoleUtilsPrintf("\n\n Timer wake selected \r\n"); /* update console */ UpdateUartConsoleHelp(); }
/* ** Select wake source */ void ActionWakeOnUart() { /* update wake source */ wakeSource = WAKE_SOURCE_UART; ConsoleUtilsPrintf("\n\n Uart wake selected \r\n"); /* update the console */ UpdateUartConsoleHelp(); }
/* ** Steps to be taken when Standby mode is selected */ void ActionStandBy(void) { ConsoleUtilsPrintf("\n\rEntering Standby Power Saving Mode..."); /* Enter PM Standby mode. */ PowerSaveModeEnter(standbyData, SLEEP_STAND_BY_MODE); /* update the console */ UpdateUartConsoleHelp(); }
/* ** Print current OPP confiuration */ void PrintConfigDVFS(void) { tValStr *tempValStr; /* ** Print string name of the OPP. */ ConsoleUtilsPrintf("\n\r%s mode selected (vdd_mpu at ", oppStrMap[mpuOpp].str); tempValStr = &voltStrMap[0]; /* Enter a loop to search the matching voltage string. */ while(tempValStr->val) { /* ** If a match is found, then print string name of the voltage. */ if(tempValStr->val == mpuVdd1) { ConsoleUtilsPrintf("%sV, ", tempValStr->str); } tempValStr++; } tempValStr = &freqStrMap[0]; /* Enter a loop to search the matching frequency string. */ while(tempValStr->val) { /* ** If a match is found, then print string name of the frequency. */ if(tempValStr->val == mpuFreq) { ConsoleUtilsPrintf("%sMHz) \r\n", tempValStr->str); } tempValStr++; } }
int main(void) { MMUConfigAndEnable(); CacheEnable(CACHE_ALL); IntMasterIRQEnable(); IntAINTCInit(); /* Initialize console for communication with the Host Machine */ ConsoleUtilsInit(); // //Delay timer setup // DelayTimerSetup(); /* Select the console type based on compile time check */ ConsoleUtilsSetType(CONSOLE_UART); ConsoleUtilsPrintf("LCDC Controller\r\n"); LCDAINTCConfigure(); LCDBackLightEnable(); SetUpLCD(); /* Configuring the base ceiling */ RasterDMAFBConfig(LCDC_INSTANCE, (unsigned int)curr_image, (unsigned int)curr_image + sizeof(image1) - 2, 0); RasterDMAFBConfig(LCDC_INSTANCE, (unsigned int)curr_image, (unsigned int)curr_image + sizeof(image1) - 2, 1); /* Enable End of frame0/frame1 interrupt */ RasterIntEnable(LCDC_INSTANCE, RASTER_END_OF_FRAME0_INT | RASTER_END_OF_FRAME1_INT); /* Enable raster */ RasterEnable(LCDC_INSTANCE); while(1) { if (curr_image == image1) { curr_image = image2; } else { curr_image = image1; } delay(5000); } }
/* ** Action to be taken when the demo is to be driven via Ethernet */ static void ActionEnetInit(void) { unsigned int linkFlag = FALSE; if(!EnetIfIsUp()) { ContextReset(); linkFlag = FALSE; EnetHttpServerInit(); if(ipAddr) { linkFlag = TRUE; } } else { if(EnetLinkIsUp()) { linkFlag = TRUE; } else { ContextReset(); linkFlag = FALSE; } } if((TRUE == linkFlag) && (ipAddr != 0)) { ConsoleUtilsPrintf("\n\rAccess the home page using http://"); IpAddrDisplay(); ConsoleUtilsPrintf("/index.html \n\r"); } else { ConsoleUtilsPrintf("\n\rNetwork Connection failed.\n\r"); } UpdateUartConsoleHelp(); }
/* ** Steps to be taken when Nitro is selected */ void ActionDVFSNitro(void) { if(OPP_NITRO <= DemoMaxOppGet()) { if(DemoOppChange(OPP_NITRO)) { PrintConfigDVFS(); updatePage(CLICK_IDX_DVFS); } else { ConsoleUtilsPrintf("Failed to configure SoC for Nitro !!!\r\n"); } } else { ConsoleUtilsPrintf("Nitro not supported in this version of SoC !!\r\n"); } UpdateUartConsoleHelp(); }
/* ** Steps to be taken when SR Turbo is selected */ void ActionDVFSSrTurbo(void) { if(SR_TURBO <= DemoMaxOppGet()) { if(DemoOppChange(SR_TURBO)) { PrintConfigDVFS(); updatePage(CLICK_IDX_DVFS); } else { ConsoleUtilsPrintf("Failed to configure SoC for SR Turbo !!!\r\n"); } } else { ConsoleUtilsPrintf("SR Turbo not supported in this ver of SoC !!!\r\n"); } UpdateUartConsoleHelp(); }
//****************************************************************************** // Audio Test // This function tests the audio output on the PRU Cape by playing a // single tone. //****************************************************************************** int AudioTest(void) { char answer[1]; ConsoleUtilsPrintf("\n**************************************************************\n"); ConsoleUtilsPrintf("\n AUDIO TEST \n"); ConsoleUtilsPrintf("\n**************************************************************\n"); ConsoleUtilsPrintf("\nLoading PRU Instructions and Data.\n"); PRUHalt(PRU_ICSS1, PRU1); PRUMemLoad(PRU_ICSS1, PRU1_IRAM, 0, sizeof(AUDIO_INST), (unsigned int*)AUDIO_INST); PRUMemLoad(PRU_ICSS1, PRU1_DRAM, 0, sizeof(AUDIO_DATA), (unsigned int*)AUDIO_DATA); ConsoleUtilsPrintf("\nRunning PRU1...\n"); PRUEnable(PRU_ICSS1, PRU1); ConsoleUtilsPrintf("\nAre the speakers making a tone? y/n\n"); ConsoleUtilsGets(answer, 3); PRUHalt(PRU_ICSS1, PRU1); return(answer[0]); }
int main(void) { SetupIntc(); /* Initialize the UART console */ ConsoleUtilsInit(); /* Select the console type based on compile time check */ ConsoleUtilsSetType(CONSOLE_UART); ADCConfigure(); while(flag); val1 = (sample1 * RESOL_X_MILLION) / 1000; ConsoleUtilsPrintf("Voltage sensed on the AN0 line : "); ConsoleUtilsPrintf("%d", val1); ConsoleUtilsPrintf("mV\r\n"); val2 = (sample2 * RESOL_X_MILLION) / 1000; ConsoleUtilsPrintf("Voltage sensed on the AN1 line : "); ConsoleUtilsPrintf("%d", val2); ConsoleUtilsPrintf("mV\r\n"); while(1); }
//****************************************************************************** // UART Test // This function tests the RS-232 UART port on the PRU Cape by requesting // the user type 5 characters in a console and echoing the characters back. //****************************************************************************** int UARTTest(void) { char answer[1]; ConsoleUtilsPrintf("\n**************************************************************\n"); ConsoleUtilsPrintf("\n UART TEST \n"); ConsoleUtilsPrintf("\n**************************************************************\n"); ConsoleUtilsPrintf("\nLoading PRU Instructions and Data.\n"); PRUHalt(PRU_ICSS1, PRU1); PRUMemLoad(PRU_ICSS1, PRU1_IRAM, 0, sizeof(UART_INST), (unsigned int*)UART_INST); PRUMemLoad(PRU_ICSS1, PRU1_DRAM, 0, sizeof(UART_DATA), (unsigned int*)UART_DATA); PRUEnable(PRU_ICSS1, PRU1); ConsoleUtilsPrintf("\nDid the UART work? y/n\n"); ConsoleUtilsGets(answer, 3); return(answer[0]); }
/* ** Take the actions on the uart. */ static void UartAction(unsigned int actionInput) { unsigned int numIcon = contextInfo[pageIndex].numIcon; tPageNavSpec const *pageNavSpec; if(actionInput < numIcon) { pageNavSpec = contextInfo[pageIndex].pageNavSpec + actionInput; if((1 == actionInput) && (0 != pageIndex)) { prevAction = 1; } (pageNavSpec->action)(); } else { ConsoleUtilsPrintf("Invalid Selection!!\r\n"); ConsoleUtilsPrintf("\n\r Selected: "); return; } }
/* ** Configure wake up for RTC alarm interrupt */ void configWakeRTC(void) { unsigned int currTime = 0; unsigned int alarmTime = 0x00002000; /* 20 Seconds for RTC Wake */ unsigned int alarmDate = 0; unsigned char time[9]= {0}; unsigned char date[9]= {0}; /* Force RTC into 24hr format */ RTCHourModeSet(RTC_INST_BASE, RTC_24HOUR_MODE); /* get current time */ currTime = RTCTimeGet(RTC_INST_BASE); /* get current date */ alarmDate = RTCCalendarGet(RTC_INST_BASE); TimeToStr(currTime, time); DateToStr(alarmDate, date); ConsoleUtilsPrintf("\n\r Current Time & Date: %s, %s", time, date); /* Add alarm time to current time */ alarmTime = addTime(alarmTime, currTime, &alarmDate); /* Set alarm Time */ RTCAlarmTimeSet(RTC_INST_BASE, alarmTime); /* Set alarm Date */ RTCAlarmCalendarSet(RTC_INST_BASE, alarmDate); TimeToStr(alarmTime, time); DateToStr(alarmDate, date); ConsoleUtilsPrintf("\n\r RTC Alarm Wake Time & Date: %s, %s", time, date); /* Run the RTC. The seconds tick from now on.*/ RTCRun(RTC_INST_BASE); }
/* ** Displays the Time and Date on the UART console */ void RtcTimeCalDisplay(void) { unsigned int time = 0; unsigned int cal = 0; unsigned char strTime[9] = {'\0'}; unsigned char strDate[9] = {'\0'}; time = RTCTimeGet(SOC_RTC_0_REGS); cal = RTCCalendarGet(SOC_RTC_0_REGS); TimeToStr(time, strTime); DateToStr(cal, strDate); ConsoleUtilsPrintf("\rCurrent Time And Date: %s, %s, ", strTime, strDate); switch(cal & MASK_DOTW) { case 0x00: ConsoleUtilsPrintf("Sun"); break; case 0x01: ConsoleUtilsPrintf("Mon"); break; case 0x02: ConsoleUtilsPrintf("Tue"); break; case 0x03: ConsoleUtilsPrintf("Wed"); break; case 0x04: ConsoleUtilsPrintf("Thu"); break; case 0x05: ConsoleUtilsPrintf("Fri"); break; case 0x06: ConsoleUtilsPrintf("Sat"); default: break; } }
//****************************************************************************** // Switch Test // This function tests the Push Button switches on the PRU Cape. // Pressing each switch will toggle an LED on the PRU Cape. //****************************************************************************** int SwitchTest(void) { char answer[1]; ConsoleUtilsPrintf("\n**************************************************************\n"); ConsoleUtilsPrintf("\n SWITCH TEST \n"); ConsoleUtilsPrintf("\n**************************************************************\n"); ConsoleUtilsPrintf("\nLoading PRU Instructions and Data.\n"); PRUMemLoad(PRU_ICSS1, PRU0_IRAM, 0, sizeof(SW_INST), (unsigned int*)SW_INST); PRUMemLoad(PRU_ICSS1, PRU0_DRAM, 0, sizeof(SW_DATA), (unsigned int*)SW_DATA); ConsoleUtilsPrintf("\nRunning PRU0...\n"); PRUEnable(PRU_ICSS1, PRU0); ConsoleUtilsPrintf("\nDo the switches turn on LEDs? y/n\n"); ConsoleUtilsGets(answer, 3); PRUHalt(PRU_ICSS1, PRU0); return(answer[0]); }
/* ** Enter the desired power save mode */ void PowerSaveModeEnter(deepSleepData dsData, unsigned int slpMode) { unsigned int i = 0; unsigned int index = 0; unsigned int noOfElements = sizeof(pmModuleList)/sizeof(pmModuleList[0]); PeripheralsContextSave(slpMode, wakeSource); PeripheralsHalt(); dsData.dsDataBits.wakeSources = wakeSource; /* Configure CMD_ID and other parameters which are to be ** communicated with CM3 */ configIPCRegs(dsData); syncCm3(); if(SLEEP_STAND_BY_MODE == slpMode) { /* Enable wake source interupt */ enableStandbyWakeSrc(dsData.dsDataBits.wakeSources); } else { /* Enable wake source */ enableWakeSource(dsData.dsDataBits.wakeSources); } /* Include MPU Clock in the disable list */ for(index = 0; index < noOfElements; index++) { if(CLK_MPU_CLK == pmModuleList[index].module) { pmModuleList[index].select = TRUE; } } /* Disable clock */ while(true != disableSelModuleClock(pmModuleList, (sizeof(pmModuleList)/sizeof(pmModuleList[0])))); /* Configure for minimum OPP supported by SoC */ ConfigMinimumOPP(); disableModuleClock(CLK_I2C0, TRUE); /* Disable IRQ */ IntMasterIRQDisable(); if(SLEEP_MODE_DS0 == slpMode) { PowerDownConfig(); } /* ** Save A8 context ** WFI ** Restore A8 context */ saveRestoreContext(slpMode, deviceVersion); /* Enable Timer3 for DS2 */ enableModuleClock(CLK_TIMER3); /* Enable IRQ */ IntMasterIRQEnable(); enableModuleClock(CLK_I2C0); /* Restore OPP configuration */ DemoOppChange(mpuOpp); /* Exclude MPU Clock from the disable list */ for(index = 0; index < noOfElements; index++) { if(CLK_MPU_CLK == pmModuleList[index].module) { pmModuleList[index].select = FALSE; } } /* Device clock enable */ enableSelModuleClock(pmModuleList, (sizeof(pmModuleList)/sizeof(pmModuleList[0]))); EDMAModuleClkConfig(); /* disable wake source */ if(SLEEP_STAND_BY_MODE == slpMode) { disableStandbyWakeSrc(dsData.dsDataBits.wakeSources); } else { disableWakeSource(dsData.dsDataBits.wakeSources); } PeripheralsContextRestore(slpMode, dsData.dsDataBits.wakeSources); PeripheralsResume(); /* ** Print string name of the sleep mode. */ ConsoleUtilsPrintf("\n\r%s", sleepModeStrMap[slpMode].str); /* Check the DS status */ if(PM_CMD_FAIL == (readCmdStatus() & (PM_CMD_FAIL))) { ConsoleUtilsPrintf(" attempt failed"); } else { ConsoleUtilsPrintf(" attempt passed"); } /* Reset CM3 State Machine */ configIPCRegs(dsDataM3reset); syncCm3(); if(slpMode & SLEEP_MODE_DS1) { /* delay to reduce the frequency of sleep/wake cycle for DS1 */ delay(500); } for(i = 0; i < 2; i++) { x_data[i] = 0; y_data[i] = 0; } /* Reset sleep trigger flag */ IsTSPress = 0; }
/* ** This function configures given source for standby wakeup. */ void enableStandbyWakeSrc(unsigned int wakeSource) { /* Disable interrupt of SW pin to avoid wake through SW for other src sel */ GPIOPinIntDisable(GPIO_INST_BASE_SW, GPIO_INT_LINE_1, GPIO_SW_PIN_NUM); GPIOPinIntDisable(GPIO_INST_BASE_SW, GPIO_INT_LINE_2, GPIO_SW_PIN_NUM); /* IO Pad Configuration */ pmStdbySrcIOPin.padConfig.slewRate = 0; pmStdbySrcIOPin.padConfig.mode = 7; pmStdbySrcIOPin.padConfig.type = CONTROL_CONF_RXACTIVE; pmStdbySrcIOPin.padConfig.pullEnable = CONTROL_CONF_PULLUDDISABLE; pmStdbySrcIOPin.padConfig.pullSel = 0; /* GPIO Pin Configuration */ pmStdbySrcIOPin.gpioConfig.dir = GPIO_DIR_INPUT; pmStdbySrcIOPin.gpioConfig.debouEnable = GPIO_DEBOUNCE_FUNC_DISABLE; pmStdbySrcIOPin.gpioConfig.intrEnable = 1; pmStdbySrcIOPin.gpioConfig.intrType = GPIO_INT_TYPE_BOTH_EDGE; switch(wakeSource) { case WAKE_SOURCE_TSC: /* Skip Touchscreen for Enable/Disable Module */ ModuleListConfig(FALSE, CLK_ADC_TSC); /* Enable hardware pen event interrupt */ TSCADCEventInterruptEnable(TSC_ADC_INSTANCE, TSCADC_ASYNC_HW_PEN_EVENT_INT); break; case WAKE_SOURCE_UART: /* Skip GPIO for Enable/Disable Module */ ModuleListConfig(FALSE, CLK_GPIO1); /* Enable GPIO Interrupt on UART RXD Pin */ pmStdbySrcIOPin.ioPadOff = GPIO_UART_RDX_PAD_OFFSET; pmStdbySrcIOPin.pinNum = GPIO_UART_RDX_PIN_NUM; pmStdbySrcIOPin.gpioBaseAddr = GPIO_INST_BASE_UART_RXD; pmStdbySrcIOPin.gpioConfig.intrLine = GPIO_UART_RXD_INTR_LINE; pmStdbySrcIOPin.intrNum = GPIO_UART_RXD_SYS_INT_NUM; pmStdbySrcIOPin.gpioIsr = gpioStdbyUartIsr; DemoGpioPinStandbySrcConfig(&pmStdbySrcIOPin); break; case WAKE_SOURCE_TMR: /* Skip Timer for Enable/Disable Module */ ModuleListConfig(FALSE, CLK_TIMER6); ConsoleUtilsPrintf("\r\n Peripheral domain Timer is configured as" "wake source.\r\n\r\n ... system will release " "from standby in 20 seconds ...\r\n\r\n"); /* Configure Timer 6 */ Timer6Config(); /* Set the counter value */ DMTimerCounterSet(DMTIMER6_BASE_ADDR, TIMER_OVRFLW_20_SECOND_24MHZ); /* Start the timer */ Timer6Start(); break; case WAKE_SOURCE_GPIO: /* Skip GPIO for Enable/Disable Module */ ModuleListConfig(FALSE, CLK_GPIO0); /* Enable GPIO Interrupt on UART RXD Pin */ pmStdbySrcIOPin.ioPadOff = GPIO_SW_PAD_OFFSET; pmStdbySrcIOPin.pinNum = GPIO_SW_PIN_NUM; pmStdbySrcIOPin.gpioBaseAddr = GPIO_INST_BASE_SW; pmStdbySrcIOPin.gpioConfig.intrLine = GPIO_SW_INTR_LINE; pmStdbySrcIOPin.intrNum = GPIO_SW_SYS_INT_NUM; pmStdbySrcIOPin.gpioIsr = gpioStdbyGPIOIsr; DemoGpioPinStandbySrcConfig(&pmStdbySrcIOPin); break; case WAKE_SOURCE_RTC: /* Include GPIO for Enable/Disable Module */ ModuleListConfig(FALSE, CLK_RTC); ConsoleUtilsPrintf("\t..Alarm is configured to wakeup system after " "20 Sec.."); configWakeRTC(); enableRTCAlarmIntr(); break; default: break; } }
/* ** QDMA Application */ void EDMAAppQDMA3Test() { volatile unsigned int index = 0u; volatile unsigned int count = 0u; EDMA3CCPaRAMEntry paramSet; unsigned char data = 0u; unsigned int retVal = 0u; unsigned int isTestPassed = false; unsigned int numEnabled = 0u; unsigned int aCount = EDMAAPP_MAX_ACOUNT; unsigned int bCount = EDMAAPP_MAX_BCOUNT; unsigned int cCount = EDMAAPP_MAX_CCOUNT; unsigned int DstBuffAddr = 0u; volatile unsigned int opt = 0u; unsigned int paramId = 32u; /* Initalize source and destination buffers */ for(count = 0u; count < (aCount * bCount * cCount); count++) { SrcBuff[count] = data++; /* ** No need to initialize the destination buffer ** as it is being invalidated. */ } /* Request DMA channel and TCC */ retVal = EDMA3RequestChannel(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_CH_TYPE, EDMAAPP_DMA_CH_NUM, EDMAAPP_DMA_TCC_NUM, EDMAAPP_DMA_EVTQ); EDMA3MapQdmaChToPaRAM(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_CH_NUM, ¶mId); EDMA3SetQdmaTrigWord(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_CH_NUM, EDMA3CC_PARAM_ENTRY_DST); /* Registering Callback Function */ EDMAAppCallbackFxn[EDMAAPP_DMA_TCC_NUM] = &EDMAAppCallback; if(TRUE == retVal) { /* Fill the PaRAM Set with transfer specific information */ paramSet.srcAddr = (unsigned int)(SrcBuff); paramSet.destAddr = (unsigned int)(DstBuff); paramSet.aCnt = (unsigned short)aCount; paramSet.bCnt = (unsigned short)bCount; paramSet.cCnt = (unsigned short)cCount; /* Setting up the SRC/DES Index */ paramSet.srcBIdx = (short)aCount; paramSet.destBIdx = (short)aCount; if(EDMA3_SYNC_A == EDMAAPP_DMA_SYNC_TYPE) { /* A Sync Transfer Mode */ paramSet.srcCIdx = (short)aCount; paramSet.destCIdx = (short)aCount; } else { /* AB Sync Transfer Mode */ paramSet.srcCIdx = ((short)aCount * (short)bCount); paramSet.destCIdx = ((short)aCount * (short)bCount); } /* Configure the paramset with NULL link */ paramSet.linkAddr = (unsigned short)0xFFFFu; paramSet.bCntReload = (unsigned short)0u; paramSet.opt = 0u; /* Src & Dest are in INCR modes */ paramSet.opt &= ~(EDMA3CC_OPT_SAM | EDMA3CC_OPT_DAM); /* Program the TCC */ paramSet.opt |= ((EDMAAPP_DMA_TCC_NUM << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC); /* Enable Intermediate & Final transfer completion interrupt */ paramSet.opt |= (1u << EDMA3CC_OPT_ITCINTEN_SHIFT); paramSet.opt |= (1u << EDMA3CC_OPT_TCINTEN_SHIFT); if(EDMA3_SYNC_A == EDMAAPP_DMA_SYNC_TYPE) { paramSet.opt &= ~EDMA3CC_OPT_SYNCDIM; } else { /* AB Sync Transfer Mode */ paramSet.opt |= (1u << EDMA3CC_OPT_SYNCDIM_SHIFT); } opt = paramSet.opt; /* Now, write the PaRAM Set. */ EDMA3QdmaSetPaRAM(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_CH_NUM, paramId, ¶mSet); } retVal = EDMA3EnableTransfer(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_CH_NUM, EDMAAPP_DMA_TRIG_MODE); /* ** Since the transfer is going to happen in Manual mode of EDMA3 ** operation, we have to 'Enable the Transfer' multiple times. ** Number of times depends upon the Mode (A/AB Sync) ** and the different counts. */ if(TRUE == retVal) { /* Need to activate next param */ if(EDMA3_SYNC_A == EDMAAPP_DMA_SYNC_TYPE) { numEnabled = bCount * cCount; } else { /* AB Sync Transfer Mode */ numEnabled = cCount; } for(index = 0u; index < numEnabled; index++) { IrqRaised = EDMAAPP_IRQ_STATUS_XFER_INPROG; if(index == (numEnabled - 1u)) { /** ** Since OPT.STATIC field should be SET for isolated QDMA ** transfers or for the final transfer in a linked list of QDMA ** transfers, do the needful for the last request. */ opt |= EDMA3CC_OPT_STATIC; EDMA3QdmaSetPaRAMEntry(EDMAAPP_EDMACC_BASE_ADDRESS, paramId, EDMA3CC_PARAM_ENTRY_OPT, opt); } opt |= EDMA3CC_OPT_FWID_8BIT; EDMA3QdmaSetPaRAMEntry(EDMAAPP_EDMACC_BASE_ADDRESS, paramId, EDMA3CC_PARAM_ENTRY_OPT, opt); /* ** Now trigger the QDMA channel by writing to the Trigger ** Word which is set as Destination Address. */ DstBuffAddr = (unsigned int)EDMA3QdmaGetPaRAMEntry( EDMAAPP_EDMACC_BASE_ADDRESS, paramId, EDMA3CC_PARAM_ENTRY_DST); EDMA3QdmaSetPaRAMEntry(EDMAAPP_EDMACC_BASE_ADDRESS, paramId, EDMA3CC_PARAM_ENTRY_DST, DstBuffAddr); /* Wait for the Completion ISR. */ while(EDMAAPP_IRQ_STATUS_XFER_INPROG == IrqRaised) { /* ** Wait for the Completion ISR on Master Channel. ** You can insert your code here to do something ** meaningful. */ } /* Check the status of the completed transfer */ if(IrqRaised < (int)EDMAAPP_IRQ_STATUS_XFER_INPROG) { /* Some error occured, break from the FOR loop. */ ConsoleUtilsPrintf("\r\nQDMA3Test: Event Miss Occured!!!\r\n"); /* Clear the error bits first */ EDMA3ClearErrorBits(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_CH_NUM, EDMAAPP_DMA_EVTQ); break; } } } /* Match the Source and Destination Buffers. */ if(TRUE == retVal) { for(index = 0u; index < (aCount * bCount * cCount); index++) { if(SrcBuff[index] != DstBuff[index]) { isTestPassed = false; ConsoleUtilsPrintf("QDMA3Test: Data write-read matching FAILED.\r\n"); ConsoleUtilsPrintf("The mismatch happened at index : %d\r\n", ((int)index + 1u)); break; } } if(index == (aCount * bCount * cCount)) { isTestPassed = true; ConsoleUtilsPrintf("QDMA3Test: Data write-read matching PASSED.\r\n"); } /* Free the previously allocated channel. */ retVal = EDMA3FreeChannel(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_CH_TYPE, EDMAAPP_DMA_CH_NUM, EDMAAPP_DMA_TRIG_MODE, EDMAAPP_DMA_TCC_NUM, EDMAAPP_DMA_EVTQ); /* Unregister Callback Function */ EDMAAppCallbackFxn[EDMAAPP_DMA_TCC_NUM] = NULL; if(TRUE != retVal) { ConsoleUtilsPrintf("QDMA3Test: EDMA3_DRV_freeChannel() FAILED.\r\n"); } } if(true == isTestPassed) { ConsoleUtilsPrintf("QDMA3Test PASSED.\r\n"); } else { ConsoleUtilsPrintf("QDMA3Test FAILED.\r\n"); } }
/* ** The main function */ int main(void) { unsigned int ipAddr; LWIP_IF lwipIfPort1, lwipIfPort2; MMUConfigAndEnable(); #ifdef LWIP_CACHE_ENABLED CacheEnable(CACHE_ALL); #endif CPSWPinMuxSetup(); CPSWClkEnable(); /* Initialize console for communication with the Host Machine */ ConsoleUtilsInit(); /* Select the console type based on compile time check */ ConsoleUtilsSetType(CONSOLE_UART); /* Chip configuration RGMII selection */ EVMPortMIIModeSelect(); /* Get the MAC address */ EVMMACAddrGet(0, lwipIfPort1.macArray); EVMMACAddrGet(1, lwipIfPort2.macArray); AintcCPSWIntrSetUp(); //DelayTimerSetup(); ConsoleUtilsPrintf("\n\rStarterWare Ethernet Echo Application. \n\r\n\r" ); ConsoleUtilsPrintf("Acquiring IP Address for Port 1... \n\r" ); #if STATIC_IP_ADDRESS_PORT1 lwipIfPort1.instNum = 0; lwipIfPort1.slvPortNum = 1; lwipIfPort1.ipAddr = STATIC_IP_ADDRESS_PORT1; lwipIfPort1.netMask = 0; lwipIfPort1.gwAddr = 0; lwipIfPort1.ipMode = IPADDR_USE_STATIC; ipAddr = lwIPInit(&lwipIfPort1); #else lwipIfPort1.instNum = 0; lwipIfPort1.slvPortNum = 1; lwipIfPort1.ipAddr = 0; lwipIfPort1.netMask = 0; lwipIfPort1.gwAddr = 0; lwipIfPort1.ipMode = IPADDR_USE_DHCP; ipAddr = lwIPInit(&lwipIfPort1); #endif if(ipAddr) { ConsoleUtilsPrintf("\n\r\n\rPort 1 IP Address Assigned: "); IpAddrDisplay(ipAddr); } else { ConsoleUtilsPrintf("\n\r\n\rPort 1 IP Address Acquisition Failed."); } /* Initialize the sample httpd server. */ echo_init(); /* Loop forever. All the work is done in interrupt handlers. */ while(1) { ; /* Perform nothing */ } }
/* ** Interrupt Service Routine for UART. */ static void UARTIsr(void) { unsigned int rxErrorType = 0; unsigned char rxByte = 0; unsigned int intId = 0; unsigned int idx = 0; unsigned int i=0; unsigned short rx_array[22]; //unsigned int rx_integer=0,rx_integer1=0; /* Checking ths syource of UART interrupt. */ intId = UARTIntIdentityGet(SOC_UART_0_REGS); //printf("intId=0x%x\n\r",intId); switch(intId) { case UART_INTID_TX_THRES_REACH: printf("UART_INTID_TX_THRES_REACH\n\r"); /* ** Checking if the entire transmisssion is complete. If this ** condition fails, then the entire transmission has been completed. */ if(currNumTxBytes < (sizeof(txArray) - 1)) { txEmptyFlag = TRUE; } /* ** Disable the THR interrupt. This has to be done even if the ** transmission is not complete so as to prevent the Transmit ** empty interrupt to be continuously generated. */ UARTIntDisable(SOC_UART_0_REGS, UART_INT_THR); break; case UART_INTID_RX_THRES_REACH: /*Берём один байт из UART */ //printf("UART_INTID_RX_THRES_REACH"); rx_array[0]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[1]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[2]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[3]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[4]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[5]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[6]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[7]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[8]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[9]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[10]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[11]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[12]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[13]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[14]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[15]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[16]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[17]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[18]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[19]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[20]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); rx_array[21]=UARTCharGetTimeout(SOC_UART_0_REGS, 100); for(i=0;i<22;i++) { printf("rx_byte=%X\n\r",rx_array[i]); } //rxByte = UARTCharGetNonBlocking(SOC_UART_0_REGS); //printf("rx_byte=%c\n\r",rxByte); // printf("rx_byte=%x,rx_byte1=%x\n\r",rx_integer,rx_integer1); //UARTCharPutNonBlocking(SOC_UART_0_REGS, rxByte); break; case UART_INTID_RX_LINE_STAT_ERROR: printf("UART_INTID_RX_LINE_STAT_ERROR\n\r"); rxErrorType = UARTRxErrorGet(SOC_UART_0_REGS); /* Check if Overrun Error has occured. */ if(rxErrorType & UART_LSR_RX_OE) { ConsoleUtilsPrintf("\r\nUART Overrun Error occured." " Reading and Echoing all data in RX FIFO.\r\n"); /* Read the entire RX FIFO and the data in RX Shift register. */ for(idx = 0; idx < (RX_FIFO_SIZE + 1); idx++) { rxByte = UARTFIFOCharGet(SOC_UART_0_REGS); UARTFIFOCharPut(SOC_UART_0_REGS, rxByte); } break; } /* Check if Break Condition has occured. */ else if(rxErrorType & UART_LSR_RX_BI) { ConsoleUtilsPrintf("\r\nUART Break Condition occured."); } /* Check if Framing Error has occured. */ else if(rxErrorType & UART_LSR_RX_FE) { ConsoleUtilsPrintf("\r\nUART Framing Error occured."); } /* Check if Parity Error has occured. */ else if(rxErrorType & UART_LSR_RX_PE) { ConsoleUtilsPrintf("\r\nUART Parity Error occured."); } ConsoleUtilsPrintf(" Data at the top of RX FIFO is: "); rxByte = UARTFIFOCharGet(SOC_UART_0_REGS); UARTFIFOCharPut(SOC_UART_0_REGS, rxByte); break; case UART_INTID_CHAR_TIMEOUT: printf("UART_INTID_CHAR_TIMEOUT\n\r"); ConsoleUtilsPrintf("\r\nUART Character Timeout Interrupt occured." " Reading and Echoing all data in RX FIFO.\r\n"); /* Read all the data in RX FIFO. */ while(TRUE == UARTCharsAvail(SOC_UART_0_REGS)) { rxByte = UARTFIFOCharGet(SOC_UART_0_REGS); UARTFIFOCharPut(SOC_UART_0_REGS, rxByte); } break; default: printf("default\n\r"); break; } }