diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app/ledblink_and_other_pin/main.cc | 37 | ||||
-rw-r--r-- | src/driver/resistive_load.cc | 84 |
2 files changed, 121 insertions, 0 deletions
diff --git a/src/app/ledblink_and_other_pin/main.cc b/src/app/ledblink_and_other_pin/main.cc new file mode 100644 index 0000000..9a8afc1 --- /dev/null +++ b/src/app/ledblink_and_other_pin/main.cc @@ -0,0 +1,37 @@ +#include "arch.h" +#include "driver/gpio.h" +#include "driver/stdout.h" +#include "driver/uptime.h" + +bool on = false; + +void loop(void) +{ + gpio.led_toggle(1); + if(on) { + gpio.write(GPIO::p1_2, 1); + }else{ + + } + on = !on; +#ifdef TIMER_S + kout << dec << uptime.get_s() << endl; +#else + kout << "beep boop" << endl; +#endif +} + +int main(void) +{ + arch.setup(); + gpio.setup(); + kout.setup(); + + gpio.led_on(0); + kout << "Hello, World!" << endl; + kout << "Test, World!" << endl; + + arch.idle_loop(); + + return 0; +} diff --git a/src/driver/resistive_load.cc b/src/driver/resistive_load.cc index 419c6c0..0c3009c 100644 --- a/src/driver/resistive_load.cc +++ b/src/driver/resistive_load.cc @@ -18,12 +18,22 @@ #error RESISTIVE_LOAD_PIN4 must be set #endif +#ifndef RESISTIVE_LOAD_PIN5 +#error RESISTIVE_LOAD_PIN5 must be set +#endif + +#ifndef RESISTIVE_LOAD_PIN6 +#error RESISTIVE_LOAD_PIN6 must be set +#endif + void ResistiveLoad::setup() { gpio.output(RESISTIVE_LOAD_PIN1, 0); gpio.output(RESISTIVE_LOAD_PIN2, 0); gpio.output(RESISTIVE_LOAD_PIN3, 0); gpio.output(RESISTIVE_LOAD_PIN4, 0); + gpio.output(RESISTIVE_LOAD_PIN5, 0); + gpio.output(RESISTIVE_LOAD_PIN6, 0); } void ResistiveLoad::switchToNone() @@ -32,6 +42,8 @@ void ResistiveLoad::switchToNone() gpio.write(RESISTIVE_LOAD_PIN2, 0); gpio.write(RESISTIVE_LOAD_PIN3, 0); gpio.write(RESISTIVE_LOAD_PIN4, 0); + gpio.write(RESISTIVE_LOAD_PIN5, 0); + gpio.write(RESISTIVE_LOAD_PIN6, 0); } void ResistiveLoad::switchTo750() @@ -40,6 +52,8 @@ void ResistiveLoad::switchTo750() gpio.write(RESISTIVE_LOAD_PIN2, 1); gpio.write(RESISTIVE_LOAD_PIN3, 0); gpio.write(RESISTIVE_LOAD_PIN4, 0); + gpio.write(RESISTIVE_LOAD_PIN5, 0); + gpio.write(RESISTIVE_LOAD_PIN6, 0); } void ResistiveLoad::switchTo1K0() @@ -48,6 +62,8 @@ void ResistiveLoad::switchTo1K0() gpio.write(RESISTIVE_LOAD_PIN2, 0); gpio.write(RESISTIVE_LOAD_PIN3, 0); gpio.write(RESISTIVE_LOAD_PIN4, 0); + gpio.write(RESISTIVE_LOAD_PIN5, 0); + gpio.write(RESISTIVE_LOAD_PIN6, 0); } void ResistiveLoad::switchTo2K4() @@ -56,6 +72,8 @@ void ResistiveLoad::switchTo2K4() gpio.write(RESISTIVE_LOAD_PIN2, 1); gpio.write(RESISTIVE_LOAD_PIN3, 0); gpio.write(RESISTIVE_LOAD_PIN4, 1); + gpio.write(RESISTIVE_LOAD_PIN5, 0); + gpio.write(RESISTIVE_LOAD_PIN6, 0); } void ResistiveLoad::switchTo3K3() @@ -64,6 +82,8 @@ void ResistiveLoad::switchTo3K3() gpio.write(RESISTIVE_LOAD_PIN2, 1); gpio.write(RESISTIVE_LOAD_PIN3, 0); gpio.write(RESISTIVE_LOAD_PIN4, 0); + gpio.write(RESISTIVE_LOAD_PIN5, 0); + gpio.write(RESISTIVE_LOAD_PIN6, 0); } void ResistiveLoad::switchTo10K() @@ -72,6 +92,8 @@ void ResistiveLoad::switchTo10K() gpio.write(RESISTIVE_LOAD_PIN2, 0); gpio.write(RESISTIVE_LOAD_PIN3, 0); gpio.write(RESISTIVE_LOAD_PIN4, 1); + gpio.write(RESISTIVE_LOAD_PIN5, 0); + gpio.write(RESISTIVE_LOAD_PIN6, 0); } void ResistiveLoad::switchTo47K() @@ -80,6 +102,68 @@ void ResistiveLoad::switchTo47K() gpio.write(RESISTIVE_LOAD_PIN2, 0); gpio.write(RESISTIVE_LOAD_PIN3, 1); gpio.write(RESISTIVE_LOAD_PIN4, 0); + gpio.write(RESISTIVE_LOAD_PIN5, 0); + gpio.write(RESISTIVE_LOAD_PIN6, 0); +} + +void ResistiveLoad::switchTo2K2() +{ + gpio.write(RESISTIVE_LOAD_PIN1, 0); + gpio.write(RESISTIVE_LOAD_PIN2, 0); + gpio.write(RESISTIVE_LOAD_PIN3, 0); + gpio.write(RESISTIVE_LOAD_PIN4, 0); + gpio.write(RESISTIVE_LOAD_PIN5, 1); + gpio.write(RESISTIVE_LOAD_PIN6, 0); +} + +void ResistiveLoad::switchTo4K7() +{ + gpio.write(RESISTIVE_LOAD_PIN1, 0); + gpio.write(RESISTIVE_LOAD_PIN2, 0); + gpio.write(RESISTIVE_LOAD_PIN3, 0); + gpio.write(RESISTIVE_LOAD_PIN4, 0); + gpio.write(RESISTIVE_LOAD_PIN5, 0); + gpio.write(RESISTIVE_LOAD_PIN6, 1); +} + +void ResistiveLoad::switchTo680() +{ + gpio.write(RESISTIVE_LOAD_PIN1, 1); + gpio.write(RESISTIVE_LOAD_PIN2, 0); + gpio.write(RESISTIVE_LOAD_PIN3, 0); + gpio.write(RESISTIVE_LOAD_PIN4, 0); + gpio.write(RESISTIVE_LOAD_PIN5, 1); + gpio.write(RESISTIVE_LOAD_PIN6, 0); +} + +void ResistiveLoad::switchTo2K() +{ + gpio.write(RESISTIVE_LOAD_PIN1, 0); + gpio.write(RESISTIVE_LOAD_PIN2, 0); + gpio.write(RESISTIVE_LOAD_PIN3, 1); + gpio.write(RESISTIVE_LOAD_PIN4, 0); + gpio.write(RESISTIVE_LOAD_PIN5, 1); + gpio.write(RESISTIVE_LOAD_PIN6, 0); +} + +void ResistiveLoad::switchTo1K8() +{ + gpio.write(RESISTIVE_LOAD_PIN1, 0); + gpio.write(RESISTIVE_LOAD_PIN2, 0); + gpio.write(RESISTIVE_LOAD_PIN3, 0); + gpio.write(RESISTIVE_LOAD_PIN4, 1); + gpio.write(RESISTIVE_LOAD_PIN5, 1); + gpio.write(RESISTIVE_LOAD_PIN6, 0); +} + +void ResistiveLoad::switchTo1K3() +{ + gpio.write(RESISTIVE_LOAD_PIN1, 0); + gpio.write(RESISTIVE_LOAD_PIN2, 1); + gpio.write(RESISTIVE_LOAD_PIN3, 0); + gpio.write(RESISTIVE_LOAD_PIN4, 0); + gpio.write(RESISTIVE_LOAD_PIN5, 1); + gpio.write(RESISTIVE_LOAD_PIN6, 0); } void ResistiveLoad::nop1K0(unsigned int duration_ms) |