You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.1 KiB
C
78 lines
1.1 KiB
C
7 years ago
|
#include "hw.h"
|
||
|
#include <avr/io.h>
|
||
|
#include <avr/interrupt.h>
|
||
|
#include <avr/eeprom.h>
|
||
|
#include "hbw.h"
|
||
|
|
||
|
uint8_t expled;
|
||
|
uint8_t expbutton;
|
||
|
|
||
|
void hbw_read_config(void)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
uint8_t hbw_get_channel(uint8_t channel, uint8_t data[])
|
||
|
{
|
||
|
if (channel == 1) {
|
||
|
if (bit_is_clear(PIND, ExpButton))
|
||
|
data[0] = 200;
|
||
|
else
|
||
|
data[0] = 0;
|
||
|
return 1;
|
||
|
}
|
||
|
if (channel == 0) {
|
||
|
if (bit_is_clear(PIND, ExpLED))
|
||
|
data[0] = 0;
|
||
|
else
|
||
|
data[0] = 200;
|
||
|
return 1;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
void hbw_set_channel(uint8_t channel, uint8_t len, uint8_t data[])
|
||
|
{
|
||
|
if (channel == 0) {
|
||
|
if (data[0])
|
||
|
PORTD |= (1<<ExpLED);
|
||
|
else
|
||
|
PORTD &= ~(1<<ExpLED);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int main(void)
|
||
|
{
|
||
|
uint8_t state;
|
||
|
|
||
|
DDRD |= (1<<ExpLED);
|
||
|
DDRD &= ~(1<<ExpButton);
|
||
|
|
||
|
PORTD &= ~(1<<ExpLED);
|
||
|
PORTD |= (1<<ExpButton);
|
||
|
|
||
|
expled = 0;
|
||
|
expbutton = 0;
|
||
|
|
||
|
hbw_init();
|
||
|
|
||
|
while(1) {
|
||
|
hbw_loop();
|
||
|
|
||
|
if (bit_is_clear(PIND, ExpButton) && (!expbutton)) {
|
||
|
state = 200;
|
||
|
|
||
|
if (hbw_send_channel(1, 1, &state, 0)) {
|
||
|
expbutton = ~0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (bit_is_set(PIND, ExpButton) && expbutton) {
|
||
|
state = 0;
|
||
|
|
||
|
if (hbw_send_channel(1, 1, &state, 0)) {
|
||
|
expbutton = 0;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|