Skip to content

Commit

Permalink
Created adc_init function and called it in proximity_init
Browse files Browse the repository at this point in the history
  • Loading branch information
PAOK-2001 committed May 16, 2022
1 parent 4493265 commit e7df5fb
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions CleanIt-SC/Headers/proximity.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@
#define PROXIMITY_H
#include <MKL25Z4.h>

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;
Expand Down

0 comments on commit e7df5fb

Please sign in to comment.