diff --git a/CleanIt-SC/Headers/proximity.h b/CleanIt-SC/Headers/proximity.h index f7ded5d..6343d36 100644 --- a/CleanIt-SC/Headers/proximity.h +++ b/CleanIt-SC/Headers/proximity.h @@ -2,19 +2,27 @@ #define PROXIMITY_H #include -void proximity_init(); -uint16_t proximity_read(); +void adc_init(void); +void proximity_init(void); +uint16_t proximity_read(void); -void proximity_init(){ - SIM->SCGC5 |= 0x2000; /* clock to PORTE */ - PORTE->PCR[20] = 0; /* PTE20 analog input */ +//adc_init() +// Initialized clock for ADC0 and configures necessary register. +void adc_init(void){ SIM->SCGC6 |= 0x8000000; /* clock to ADC0 */ ADC0->SC2 &= ~0x40; /* software trigger */ - /* clock div by 4, long sample time, single ended 12 bit, bus clock */ + /*CLKDIV/4, LS time, single ended 12 bit, bus clock */ ADC0->CFG1 = 0x40 | 0x10 | 0x04 | 0x00; } +//Proximity_init +// Configure necessary ports as analogue +void proximity_init(void){ + adc_init(); + -uint16_t proximity_read(){ +} + +uint16_t proximity_read(int sensorChannel){ uint16_t readValue; return readValue;