void main(void) { char opt; // Make sure nCS is high before doing anything nCS_HIGH; // Enable user module interrupts SleepTimer_EnableInt(); // Enable global interrutps M8C_EnableGInt; // Start the user modules UART_Start(UART_PARITY_NONE); UART_PutCRLF(); SPIM_Start(SPIM_SPIM_MODE_0 | SPIM_SPIM_MSB_FIRST); SleepTimer_Start(); DAC8_Start(DAC8_FULLPOWER); UART_CPutString("Synthesiszing waveforms\r\n"); WriteBlock(0); WriteBlock(1); WriteBlock(2); WriteBlock(3); while(1) { UART_CPutString("Synthetic wave output is on Port0[4]\r\nCowabunga Dude! Time to catch some waves.\r\n\r\n0. Play block 0\r\n1. Play block 1\r\n2. Play block 2\r\n3. Play block 3\r\n4. Test status register\r\n5. Test byte mode\r\n6. Test sequential mode\r\n"); opt = GetNumber(0, 6); switch (opt) { case 4: while(SPIRAM_StatusRegisterTest()) SleepTimer_SyncWait(4, SleepTimer_WAIT_RELOAD); break; case 5: while(SPIRAM_ByteModeTest()) SleepTimer_SyncWait(4, SleepTimer_WAIT_RELOAD); break; case 6: while(SPIRAM_SequentialModeTest()) SleepTimer_SyncWait(4, SleepTimer_WAIT_RELOAD); break; default: PlayBlock(opt); break; } } }
void main(void) { int result; float voltage; int status; M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts // Insert your main routine code here. //Start PGA in high power mode PGA_Start(PGA_HIGHPOWER); //Start ADCINC in high power mode ADCINC_Start(ADCINC_HIGHPOWER); //Start LCD LCD_Start(); //Run the ADC continuously ADCINC_GetSamples(0); SleepTimer_Start(); SleepTimer_SetInterval(SleepTimer_1_HZ); SleepTimer_EnableInt(); while (1) { SleepTimer_SyncWait(1, SleepTimer_WAIT_RELOAD); // Wait for data to be ready while (ADCINC_fIsDataAvailable() == 0); // Get Data and clear flag result=ADCINC_iClearFlagGetData(); voltage = result * SCALE_FACTOR; LCD_Position(0, 0); LCD_PrCString(" "); LCD_Position(0, 0); LCD_PrHexInt(result); LCD_Position(1, 0); LCD_PrCString(" "); LCD_Position(1, 0); LCD_PrString(ftoa(voltage, &status)); } }
void main(void) { //Variables char lcdFirstLine[LCD_LENGTH], lcdSecondLine[LCD_LENGTH]; unsigned int displaymode = 3; // FIXME: sollte 0 sein! /** init **/ // interrupt and SleepTimer init M8C_EnableGInt ; // Turn on interrupts SleepTimer_Start(); SleepTimer_SetInterval(SleepTimer_8_HZ); // Set interrupt to a SleepTimer_EnableInt(); // 8 Hz rate // init PGA and SAR6 for sun and rain sensor PGA_sun_SetGain(PGA_sun_G5_33); // gain of 5,33 PGA_sun_Start(PGA_sun_HIGHPOWER); //PGA_rain_SetGain(PGA_rain_G8_00); //PGA_rain_Start(PGA_rain_MEDPOWER); SAR6_sun_Start(SAR6_sun_HIGHPOWER); //SAR6_rain_Start(SAR6_sun_MEDPOWER); // LCD init LCD_Init(); // print welcome screen to LCD csprintf(lcdFirstLine," Welcome to "); csprintf(lcdSecondLine, " Weatherstation "); LCD_Position(0,0); LCD_PrString(lcdFirstLine); LCD_Position(1,0); LCD_PrString(lcdSecondLine); while(1) { // get temp and humidity here switch(displaymode) { case 0: // overview(); break; case 1: // temp(); break; case 2: // humidity(); break; case 3: sunsensor(lcdFirstLine, lcdSecondLine); break; case 4: // wind(); break; default: displaymode = 0; csprintf(lcdFirstLine," Error "); csprintf(lcdSecondLine," "); } // lets see what we've got LCD_Position(0,0); LCD_PrString(lcdFirstLine); LCD_Position(1,0); LCD_PrString(lcdSecondLine); // lets sleep for a while SleepTimer_SyncWait(8, SleepTimer_WAIT_RELOAD); } }
void main(void) { //Variables char lcdFirstLine[LCD_LENGTH], lcdSecondLine[LCD_LENGTH]; int displaymode = 1; int temperature[5]; int humidity[5]; /** init **/ // interrupt and SleepTimer init M8C_EnableGInt ; // Turn on interrupts SleepTimer_Start(); SleepTimer_SetInterval(SleepTimer_8_HZ); // Set interrupt to a SleepTimer_EnableInt(); // 8 Hz rate // LCD init LCD_Init(); // print welcome screen to LCD csprintf(lcdFirstLine," Welcome to "); csprintf(lcdSecondLine, " Weatherstation "); LCD_Position(0,0); LCD_PrString(lcdFirstLine); LCD_Position(1,0); LCD_PrString(lcdSecondLine); while(1) { I2Cm_Start(); //Initialize I2C I2Cm_fSendStart( 0x28, 0); //Send Measuring Request measuring(temperature, humidity); //measuring temperature and humidity switch(displaymode) { case 0: // overview(); break; case 1: printtemp(lcdFirstLine, lcdSecondLine, temperature); //write temp in the variable for the lcd break; case 2: printhum(lcdFirstLine, lcdSecondLine, humidity); //wirte humidity in the variable for the lcd break; case 3: // rain(); break; case 4: // wind(); break; default: displaymode = 0; csprintf(lcdFirstLine," Error "); csprintf(lcdSecondLine," "); } // lets see what we've got LCD_Position(0,0); LCD_PrString(lcdFirstLine); LCD_Position(1,0); LCD_PrString(lcdSecondLine); // lets sleep for a while SleepTimer_SyncWait(8, SleepTimer_WAIT_RELOAD); } }