int main(void) { SERIAL_Init(); TIMERS_Init(); char i, j = 0; int k, l = 0; int time = GetTime(); INTEnableSystemMultiVectoredInt(); AD_Init(IR_PINS); IR_Init(); while (1) { k = ReadADPin(IR_LEFT); l = ReadADPin(IR_RIGHT); char leftTrig = '_'; char rightTrig = '_'; if (IR_LeftTriggered()) leftTrig = 'x'; if (IR_RightTriggered()) rightTrig = 'x'; //if (time > GetTime() + 500) { if (IsTransmitEmpty()) { printf("\n %cLeft : %d \n %cRight : %d",leftTrig, k, rightTrig, l); } wait(); //time = GetTime(); //} //while (!IsTransmitEmpty()); // bad, this is blocking code } return 0; }
int main(void) { unsigned int wait = 0; int readcount = 0; SERIAL_Init(); INTEnableSystemMultiVectoredInt(); mJTAGPortEnable(0); printf("\r\nUno A/D Test Harness\r\nThis will initialize all A/D pins and read them %d times", TIMES_TO_READ); printf("Value of pcfg before test: %X",AD1PCFG); AD_Init(AD_PORTV3 | AD_PORTV4 | AD_PORTV5 | AD_PORTV6 | AD_PORTW4 | AD_PORTW3 | BAT_VOLTAGE | PINA); unsigned char cur = 0; while (readcount <= TIMES_TO_READ) { for (wait = 0; wait <= 100000; wait++) asm("nop"); printf("\r\nAN0\tAN1\tAN2\tAN3\tAN4\tAN5\tAN11\tAN10\n"); printf("%d\t", ReadADPin(PINA)); printf("%d\t", ReadADPin(BAT_VOLTAGE)); printf("%d\t", ReadADPin(AD_PORTV3)); printf("%d\t", ReadADPin(AD_PORTV4)); printf("%d\t", ReadADPin(AD_PORTV5)); printf("%d\t", ReadADPin(AD_PORTV6)); printf("%d\t", ReadADPin(AD_PORTW4)); printf("%d\t", ReadADPin(AD_PORTW3)); readcount++; } printf("Done Reading Them\r\n"); AD_End(); printf("Value of pcfg after test: %X",AD1PCFG); return 0; }
int main(void) { unsigned int wait = 0; int readcount = 0; SERIAL_Init(); INTEnableSystemMultiVectoredInt(); mJTAGPortEnable(0); printf("\r\nUno A/D Test Harness\r\nThis will initialize all A/D pins and read them %d times", TIMES_TO_READ); printf("Value of pcfg before test: %X",AD1PCFG); AD_Init(AD_PORTV3 | AD_PORTV4 | AD_PORTV5 | AD_PORTV6 | AD_PORTV7 | AD_PORTV8 | AD_PORTW3 | AD_PORTW4 | AD_PORTW5 | AD_PORTW6 | AD_PORTW7 | AD_PORTW8 | BAT_VOLTAGE); char numtoread = 13; unsigned char cur = 0; while (readcount <= TIMES_TO_READ) { for (wait = 0; wait <= 100000; wait++) asm("nop"); // printf("\r\nAN2\tAN3\tAN4\tAN5\tAN8\tAN9\tAN11\tAN10\tAN13\tAN12\tAN15\tAN14\tAN1\n"); for (cur = 0; cur < numtoread; cur++) { printf("%d\t", ReadADPin(1 << cur)); } printf("\r\n"); readcount++; } printf("Done Reading Them\r\n"); AD_End(); printf("Value of pcfg after test: %X",AD1PCFG); return 0; }
char IsLeftTriggered() { unsigned int val = ReadADPin(IR_LEFT); char result = OFF; //dbprintf("\nMain=%d", val); if (val > irThreshold[IR_LEFT_I]) { #ifndef USE_SAMPLING irThreshold[IR_LEFT_I] = LEFT_LOW_THRESHOLD; #endif result = ON; } if (val < irThreshold[IR_LEFT_I]) { #ifndef USE_SAMPLING irThreshold[IR_LEFT_I] = LEFT_HIGH_THRESHOLD; #endif result = OFF; } #ifdef USE_LEDS if (result) LED_OnBank(LED_BANK3, 0x8); else LED_OffBank(LED_BANK3, 0x8); #endif return result; }
unsigned int IR_RightReading() { return ReadADPin(IR_RIGHT); }
unsigned int IR_LeftReading() { return ReadADPin(IR_LEFT); }
unsigned int LightLevel(void) { return ReadADPin(LIGHT_SENSOR); }
/** * Function: ReadPotentiometer * @return Voltage at the wiper of the potentiometer * @remark Voltage is sampled from the ADC where 0V -> 0, and * 3.3V -> 1023 */ unsigned int ReadPotentiometer(void) { return ReadADPin(POT_INPUT); }