int main(void){ int useless =0; int a,b,c; DisableInterrupts(); PLL_Init(); // 50 MHz I think? LCD_Open(); ADC_InitSWTriggerSeq3(3); SysTick_Init(); SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOG; // activate port G useless = 1; useless =0; GPIO_PORTG_DIR_R |= 0x04; // make PG2 out (built-in LED) GPIO_PORTG_AFSEL_R &= ~0x04; // disable alt func on PG2 GPIO_PORTG_DEN_R |= 0x04; // enable digital I/O on PG2 PG2 = 0; // turn off LED UART_Init(); ADC_Init(); LCD_Clear(); EnableInterrupts(); while(1) { if((FIFO_Get() !=1) && getmail==0x2) { int i; int sendme; flag =0; //FIFO_Get(); LCD_GoTo(0); for(i = 0; i <5; i++) { FIFO_Get(); sendme = getmail; LCD_OutChar( sendme); } LCD_GoTo(20); LCD_OutChar(99); LCD_OutChar(109); FIFO_Get(); FIFO_Get(); // these two gets just take the blank space and the Stop 0x03 off the FIFO } } }
void mainRECEIVER(void) { unsigned char CM[5] = { ' ',' ','c','m',0, }; unsigned char *txtPnt; InData = 0; asm sei // Disable interrupts PLL_Init(); LCD_Open(); // Initializes Timer LCD_Clear(); SCI1R_Init(); DDRP |= 0x80; // PP7 output OC1_InitR(); // Intializes timer as well, receiver uses interrupt channel 1 txtPnt = CM; asm cli // Enable interrupts for(;;) { SCI1_InData(); // InData returns pnter value LCD_Clear(); LCD_OutFix(Convert(adcValue)); // Displays data in fixed point format LCD_OutString(txtPnt); Timer_wait(10); // wait 10ms } }
//---------------------mainRx--------------------- // main used for receiver // Input: none // Output: none void main(void) { PLL_Init(); SCIb_Init(9600); XBee_Init(); LCD_Open(); LCD_Clear(); LCD_OutString("Xbee: "); EnableInterrupts; while(1) { // Rx DP512 continually polls the Rx FIFO and any available data is // displayed on the LCD using the LCD driver routines. XBee_ReceiveRxFrame(&rxFrame[0]); /*if(SCIb_InStatus() && (rxFrame != 0)) { unsigned short messageLength = ((rxFrame[1]<<8) + rxFrame[2])-5;//message length only unsigned short i; for(i = 0; i < messageLength; i++){ LCD_OutChar(rxFrame[i+8]); } printf("\n"); }*/ LCD_GoTo(1,1); LCD_OutString(&rxFrame[0]); } }
/** * @brief Main routine. * @param None. * @return None. */ int32_t main(void) { S_RTC_TIME_DATA_T sCurTime; SYS_Init(); UART0_Init(); DEBUG_MSG("\nNANO130 NuTiny EVB Demo Program V1.0.0\n"); DEBUG_MSG("[Power Down Demo]\n"); /* Unlock protected registers */ SYS_UnlockReg(); /* Time Setting */ sCurTime.u32Year = 2013; sCurTime.u32Month = 10; sCurTime.u32Day = 15; sCurTime.u32Hour = 0; sCurTime.u32Minute = 0; sCurTime.u32Second = 0; sCurTime.u32DayOfWeek = RTC_TUESDAY; sCurTime.u32TimeScale = RTC_CLOCK_24; RTC_Open(&sCurTime); DEBUG_MSG("RTC Init. complete!\n"); /* Do LCD Initializaton */ LCD_Open(LCD_C_TYPE, 4, LCD_BIAS_THIRD, LCD_FREQ_DIV64, LCD_CPVOl_3V); LCD_EnableDisplay(); DEBUG_MSG("LCD Init. complete!\n"); /* Start displaying on LCD */ LCDLIB_SetSymbol(2, 27, 1); CLK_SysTickDelay(335000); textticker("*** NUVOTON NANO130 ***", 335000); CLK_SysTickDelay(335000); LCDLIB_Printf(0, "NUVOTON"); LCD_EnableBlink(250); CLK_SysTickDelay(335000); CLK_SysTickDelay(335000); CLK_SysTickDelay(335000); CLK_SysTickDelay(335000); CLK_SysTickDelay(335000); LCD_DisableBlink(); /* Read curent RTC time */ RTC_GetDateAndTime(&sCurTime); DEBUG_MSG("Current Time:%d/%02d/%02d %02d:%02d:%02d\n",sCurTime.u32Year,sCurTime.u32Month,sCurTime.u32Day,sCurTime.u32Hour,sCurTime.u32Minute,sCurTime.u32Second); /* Display RTC time */ showTime(sCurTime.u32Hour, sCurTime.u32Minute); DEBUG_MSG("Start MAIN loop.\n"); while(1) { textticker("*** GOING TO POWER DOWN ***", 335000); DEBUG_MSG("Going to Power Down...\n"); #ifdef __DEBUG_MSG while(!(UART1->FSR & UART_FSR_TE_F)) ; /* waits for message send out */ #endif /* Enter power down mode */ /* This sample will not wake up*/ Enter_PowerDown(); DEBUG_MSG("Program resume...\n"); if (_Wakeup_Flag == 1) { _Wakeup_Flag = 0; textticker("*** WAKE UP ***", 335000); CLK_SysTickDelay(335000); CLK_SysTickDelay(335000); CLK_SysTickDelay(335000); } }; }