int main(){ // setup functions pwmSetup(); adcSetup(); ADC::Sync_result result; // begin I2C, slave address 0x01 // register event on receive Wire.begin(I2CADDR); Wire.onReceive(rxEvent); //Serial.begin(9600); while(1){ // read the adc result = adc->readSynchronizedContinuous(); adc1Val = (uint16_t)result.result_adc0; adc2Val = (uint16_t)result.result_adc1; // update outputs setSleep(SLPA, SLPB, sleepFlag); setDirection(DIRA, dirAflag); setDirection(DIRB, dirBflag); setPWM(PWMA, pwmAval); setPWM(PWMB, pwmBval); } }
int Stop(unsigned int *generalArray, void **args, unsigned int argsCount, unsigned int *argSize){ status = 0; pwmSetup(63, PWM_LEVELS); //reset the pwms back to very high duty cycle //this will hopefully help to avoid damaging the microcontroller if we get large voltages to the analog in when we're not //actively doing gain control return status; }
/* This should be called at startup. Starts the clocks for the Switched Cap filter, and initalizes the PWMs and sets their duty cycle to 50% */ int Init(unsigned int *generalArray, void **args, unsigned int argsCount, unsigned int *argSize){ //start up the 6kHz clock #include "timer3Clock.h" //start up the 12kHz clock #include "i2sClock.h" //start up the pwms (all pins). at this point we don't know what channels will run to just start up everything pwmSetup(63, PWM_LEVELS); return 1; }
int main(){ SystemInit(); setup(); adcSetup(); Init_Display(); timerSetup(); tempMeasure(); updateDegrees(); setupInterupts(5); lightMeasure(); pwmSetup(); setupInterupts(1000); PrintMenu(); *PWM_CDTYUPD = 1800; int input; while(nInterupts < 500){} while(1){ if(nInterupts >= 500){ tempMeasure(); nInterupts = 0; } updateDegrees(); Print(floatToChar, 33,1); //Skriv ut temperatur if(value > maxLimit){ Print("ALARM", 32, 3); Print("TOO HOT ", 32,4); } else if(value < lowLimit){ Print(" ALARM", 32, 3); Print("TOO COLD", 32,4); } else if(value >lowLimit || value<maxLimit){ Print(" ", 32, 3); Print(" ", 32, 4); } if(tempCount >= fastMode){ updateDegrees(); delay(60); if(tempFlag == 1){ tempCalc(); tempCount = 0; tempFlag = 0; } } input = readKeypad(); if(buttonPressed == 1){ buttonPressed = 0; menuCases(&input); } } }
int main () { LPC_SWM->PINENABLE0 |= 3<<2; // disable SWCLK and SWDIO LPC_SWM->PINASSIGN[8] = 0xFFFF03FF; // connect CTOUT_2 to PIO0_3 pwmSetup(); tick.init(50*1024); // run at 51,200 Hz to generate a 50 Hz sine int phase = 0; while (true) { uint8_t step = ++phase; if (phase & (1<<8)) step = ~step; int ampl = sineTable[step]; if (phase & (1<<9)) ampl = - ampl; __WFI(); // sync up with the systick timer LPC_SCT->MATCHREL[3].U = 512 + (ampl >> 6); } }
int main(void) { // _TRISD = 0; pinIO(); serialSetup(); pwmSetup(); setupA2D(); timerSetup(); //infinete loop in which we count while(1) { } //remain here forever, never end the main function. return 0; //we should never really return }
int main(void) { pinIO(); encSetup(); serialSetupUSB(); serialSetupP2P(); timerSetup(); pwmSetup(); setupA2D(); //infinete loop in which we count while(1) { //LED1LATCH = 1; } //remain here forever, never end the main function. return 0; //we should never really return }