77 lines
1.8 KiB
C
77 lines
1.8 KiB
C
// Copyright (C) 2025 Thies Lennart Alff
|
|
//
|
|
// This program is free software; you can redistribute it and/or
|
|
// modify it under the terms of the GNU General Public License
|
|
// as published by the Free Software Foundation; either version 2
|
|
// of the License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program; if not, write to the Free Software
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
// USA
|
|
|
|
#include "switch.h"
|
|
#include "gpio.h"
|
|
#include "macros.h"
|
|
|
|
GPIO_PIN(switch0, PORTA, NAME2PIN(SWITCH0_NAME))
|
|
GPIO_PIN(switch1, PORTA, NAME2PIN(SWITCH1_NAME))
|
|
GPIO_PIN(switch2, PORTA, NAME2PIN(SWITCH2_NAME))
|
|
GPIO_PIN(switch3, PORTA, NAME2PIN(SWITCH3_NAME))
|
|
|
|
void switch_init() {
|
|
gpio_switch0_out();
|
|
gpio_switch0_clr();
|
|
|
|
gpio_switch1_out();
|
|
gpio_switch1_clr();
|
|
|
|
gpio_switch2_out();
|
|
gpio_switch2_clr();
|
|
|
|
gpio_switch3_out();
|
|
gpio_switch3_clr();
|
|
}
|
|
|
|
void switch_set(int index, int value) {
|
|
switch (index) {
|
|
case 0:
|
|
gpio_switch0_write(value);
|
|
break;
|
|
case 1:
|
|
gpio_switch1_write(value);
|
|
break;
|
|
case 2:
|
|
gpio_switch2_write(value);
|
|
break;
|
|
case 3:
|
|
gpio_switch3_write(value);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void switch_toggle(int index) {
|
|
switch (index) {
|
|
case 0:
|
|
gpio_switch0_toggle();
|
|
break;
|
|
case 1:
|
|
gpio_switch1_toggle();
|
|
break;
|
|
case 2:
|
|
gpio_switch2_toggle();
|
|
break;
|
|
case 3:
|
|
gpio_switch3_toggle();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|