#include #include "pinout.h" #include "power_switch.h" void power_switch_init(void) { // Solar switch: output, initially low = off gpio_clear(SOLAR_SWITCH_PORT, SOLAR_SWITCH_PIN); gpio_mode_setup(SOLAR_SWITCH_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, SOLAR_SWITCH_PIN); // Load switch: output, initially low = off gpio_clear(LOAD_SWITCH_PORT, LOAD_SWITCH_PIN); gpio_mode_setup(LOAD_SWITCH_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOAD_SWITCH_PIN); } void power_switch_solar_on(void) { gpio_set(SOLAR_SWITCH_PORT, SOLAR_SWITCH_PIN); } void power_switch_solar_off(void) { gpio_clear(SOLAR_SWITCH_PORT, SOLAR_SWITCH_PIN); } bool power_switch_solar_status(void) { return gpio_get(SOLAR_SWITCH_PORT, SOLAR_SWITCH_PIN) != 0; } void power_switch_load_on(void) { gpio_set(LOAD_SWITCH_PORT, LOAD_SWITCH_PIN); } void power_switch_load_off(void) { gpio_clear(LOAD_SWITCH_PORT, LOAD_SWITCH_PIN); } bool power_switch_load_status(void) { return gpio_get(LOAD_SWITCH_PORT, LOAD_SWITCH_PIN) != 0; }