Skip to content

Commit

Permalink
Merge branch 'master' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
k105la authored Jun 9, 2020
2 parents 2ade9b7 + b37de77 commit b724640
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- name: Install dependencies
run: cd board && sh install.sh
- name: Build PanFLUte firmware
run: cd board && make
run: cd board && make
12 changes: 11 additions & 1 deletion board/adc/adc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "../driver/adc.h"


void adcInit(void) {
/* Enable ADC */
ADCSRA = (1 << ADEN) | (1 << ADSC);
Expand All @@ -8,11 +9,20 @@ void adcInit(void) {
//printf("ADC has started\n");
}


/*
void getPSI(void) {
ADCSRA |= (1 << ADSC); // Start ADC conversion
float rawPresureData = ADCH; // Max is 8bit value
printf("PSI: %.2f", (rawPresureData / 255.0) * 14.5);
_delay_ms(100);


uint8_t adcStart(void) {
ADCSRA |= (1 << ADSC); // Start ADC conversion
loop_until_bit_is_clear(ADCSRA, ADSC);
uint8_t rawPresureData = ADCH; // Max is 8bit value

return rawPresureData;

}
*/
3 changes: 3 additions & 0 deletions board/driver/adc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
#include <stdint.h>

void adcInit(void);

//void getPSI(void);

uint8_t adcStart(void);
18 changes: 14 additions & 4 deletions board/main.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
#include <util/delay.h>
#include "driver/usart.h"
#include "driver/led.h"
#include "driver/adc.h"

static FILE mystdout = FDEV_SETUP_STREAM(print, NULL, _FDEV_SETUP_RW);


int main(void) {
adcInit();
usartInit(MYUBRR);
stdout = &mystdout;
while(1) {
while(ADCSRA & (1 << ADSC));
ADCSRA |= (1 << ADSC); // Start ADC conversion
// TODO: Must subtract ADCH from offset.
printf("PSI: %.2f\n", (ADCH / 255.0) * 14.5);
_delay_ms(150);
// TODO: Must subtract ADCH from offset.
printf("PSI: %.2f\n", (ADCH / 255.0) * 14.5);
delay_ms(150);

int main(void) {
adcInit();
usartInit(MYUBRR);
stdout = &mystdout;
while(1) {
printf("Should be sensor data: %d\n", adcStart());
delay_ms(1000);
}
return 0;
}
}

0 comments on commit b724640

Please sign in to comment.