Skip to content

Commit

Permalink
Added driver code
Browse files Browse the repository at this point in the history
  • Loading branch information
PAOK-2001 committed May 16, 2022
1 parent 478056c commit d92fa39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions CleanIt-SC/Headers/proximity.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

void adc_init(void);
void proximity_init(void);
int proximity_read(void);
int proximity_read(int sensorValue);

//adc_init()
// Initialized clock for ADC0 and configures necessary register.
Expand All @@ -25,7 +25,9 @@ void proximity_init(void){
PORTB->PCR[1] = 1;
adc_init();
}

//proximity_read()
// @param integer corresponding to ADC channel. Should be 8 or 9.
// @returns int value corresponding to the sensor value
int proximity_read(int sensorChannel){
int readValue;
ADC0->SC1[0] = sensorChannel;
Expand Down
10 changes: 6 additions & 4 deletions CleanIt-SC/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include "mbed.h"

#include <MKL25Z4.h>
#include"Headers/proximity.h"
// main() runs in its own thread in the OS
int main()
{
int main(){
proximity_init();
int leftSensor, rightSensor;
while (true) {

leftSensor = proximity_read(8);
}
}

0 comments on commit d92fa39

Please sign in to comment.