#include "hw.h" #include #include #include #include "hbw.h" uint8_t relais1state; uint8_t relais2state; uint8_t pc0state; uint8_t pc1state; uint8_t scount; void hbw_read_config(void) { } uint8_t hbw_get_channel(uint8_t channel, uint8_t data[]) { if (channel == 0) { if (bit_is_clear(PINB, Relais1)) data[0] = 0; else data[0] = 200; return 1; } if (channel == 1) { if (bit_is_clear(PINB, Relais2)) data[0] = 200; else data[0] = 0; return 1; } if (channel == 2) { if (bit_is_clear(PINC, PC0)) data[0] = 200; else data[0] = 0; return 1; } if (channel == 3) { if (bit_is_clear(PINC, PC1)) data[0] = 200; else data[0] = 0; return 1; } return 0; } void hbw_set_channel(uint8_t channel, uint8_t len, uint8_t data[]) { if (channel == 0) { if (data[0]) PORTB |= (1< 1) return; if (scount == countflag) return; for (i=0; i < 16; i++) { if ((eeprom_read_byte((const uint8_t *)(i*7)+0x10) == ((uint8_t*)&saddress)[0]) && (eeprom_read_byte((const uint8_t *)(i*7)+0x11) == ((uint8_t*)&saddress)[1]) && (eeprom_read_byte((const uint8_t *)(i*7)+0x12) == ((uint8_t*)&saddress)[2]) && (eeprom_read_byte((const uint8_t *)(i*7)+0x13) == ((uint8_t*)&saddress)[3]) && (eeprom_read_byte((const uint8_t *)(i*7)+0x14) == schannel) && (eeprom_read_byte((const uint8_t *)(i*7)+0x15) == channel)) { type = eeprom_read_byte((const uint8_t *)(i*7)+0x16); switch (countflag & 3) { case 1: type = (type >> 6) & 0x3; break; case 0: type = (type >> 4) & 0x3; break; case 3: type = (type >> 2) & 0x3; break; case 2: type = type & 0x3; } switch (type) { case 0: if(channel == 0) PORTB |= (1<