Implement pump control via port register
This commit is contained in:
@@ -3,8 +3,11 @@
|
|||||||
#include <avr/sleep.h>
|
#include <avr/sleep.h>
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include "moisture.h"
|
|
||||||
#include "adc.h"
|
#include "adc.h"
|
||||||
|
#include "moisture.h"
|
||||||
|
#include "pump.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ISR(WDT_vect) {
|
ISR(WDT_vect) {
|
||||||
triggerRead();
|
triggerRead();
|
||||||
@@ -27,8 +30,8 @@ void enterSleep(void) {
|
|||||||
|
|
||||||
void setup(void) {
|
void setup(void) {
|
||||||
adcInit();
|
adcInit();
|
||||||
//pumpsInit();
|
|
||||||
sensorsInit();
|
sensorsInit();
|
||||||
|
//pumpsInit();
|
||||||
watchdogs();
|
watchdogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,17 +10,15 @@ void pumpsInit(void) {
|
|||||||
(1 << PUMP_D4) |
|
(1 << PUMP_D4) |
|
||||||
(1 << PUMP_D3) |
|
(1 << PUMP_D3) |
|
||||||
0 | 0 | 0 ));
|
0 | 0 | 0 ));
|
||||||
// Disable pullup
|
|
||||||
PORTD &= ~((1 << PUMP_D7) |
|
|
||||||
(1 << PUMP_D6) |
|
|
||||||
(1 << PUMP_D5) |
|
|
||||||
(1 << PUMP_D4) |
|
|
||||||
(1 << PUMP_D3) |
|
|
||||||
0 | 0 | 0 ));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void triggerPump(int8_t pump_pin, int16_t milliseconds) {
|
void triggerPump(int8_t pump_pin, int16_t milliseconds) {
|
||||||
// turn on pump
|
// Turn on pump
|
||||||
// watchdog for n milliseconds
|
PORTD |= (1 << pump_pin);
|
||||||
// turn of pump
|
|
||||||
|
// timer for n milliseconds
|
||||||
|
// NOTE: watchout for overflows!! create a safety net.
|
||||||
|
|
||||||
|
// Turn off pump
|
||||||
|
PORTD &= ~(1 << pump_pin);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user