Compare commits
No commits in common. '4a9572c40fde82ca106253cd1239a241fff034c6' and '221905f27c17e9d396b218dbbfb6c23831532266' have entirely different histories.
4a9572c40f
...
221905f27c
@ -1,7 +0,0 @@
|
||||
#ifndef __ALARMHW_H__
|
||||
#define __ALARMHW_H__
|
||||
#define RedLED PD4
|
||||
#define GreenLED PD5
|
||||
#define BuzzerON PD6
|
||||
#define ReedSwitch PD7
|
||||
#endif
|
@ -1,130 +0,0 @@
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include "alarmhw.h"
|
||||
#include "rs485.h"
|
||||
#include "eb.h"
|
||||
|
||||
uint8_t reedstate;
|
||||
uint8_t buzzerstate;
|
||||
|
||||
uint8_t waitforack;
|
||||
uint8_t waitforsend;
|
||||
uint8_t acktimer;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
init_rs485();
|
||||
DDRD |= (1<<RedLED);
|
||||
DDRD |= (1<<GreenLED);
|
||||
DDRD |= (1<<BuzzerON);
|
||||
DDRD &= ~(1<<ReedSwitch);
|
||||
|
||||
PORTD &= ~(1<<RedLED);
|
||||
PORTD |= (1<<GreenLED);
|
||||
PORTD &= ~(1<<BuzzerON);
|
||||
PORTD |= (1<<ReedSwitch);
|
||||
|
||||
ADMUX = (0<<REFS1) | (1<<REFS0);
|
||||
ADCSRA = (1<<ADPS2) | (1<<ADPS1);
|
||||
ADCSRA |= (1<<ADEN);
|
||||
ADCSRA |= (1<<ADSC);
|
||||
loop_until_bit_is_clear(ADCSRA, ADSC);
|
||||
svalue = ADCW;
|
||||
|
||||
my_address = eeprom_read_byte((const uint8_t *)0);
|
||||
my_prio = eeprom_read_byte((const uint8_t *)1);
|
||||
master = eeprom_read_byte((const uint8_t *)2);
|
||||
|
||||
buzzerstate = 0;
|
||||
reedstate = 0;
|
||||
|
||||
waitforsend = 0;
|
||||
acktimer = 0;
|
||||
|
||||
sei();
|
||||
while(1) {
|
||||
rs485_loop();
|
||||
if (rflag) {
|
||||
if (rsender)
|
||||
srecv = rsender;
|
||||
else
|
||||
srecv = master;
|
||||
smode = 0;
|
||||
if ((rrecv == my_address) && (rmode == 2)) {
|
||||
acktimer = 0;
|
||||
waitforsend = 0;
|
||||
}
|
||||
|
||||
if ((rrecv == my_address) && (rmode == 0)) {
|
||||
for (i=0; i<4; i++) {
|
||||
decodepart(i);
|
||||
scommand = 0;
|
||||
schannel = rchannel;
|
||||
if ((rcommand == 0x40) && (rchannel == 0)) {
|
||||
scommand = 0x40;
|
||||
svalue = 2; /* 2 LED keys + 4 ADCs */
|
||||
}
|
||||
if ((rcommand == 0x60) && (rchannel == 1)) {
|
||||
if (rvalue & 0x02) {
|
||||
buzzerstate = ~0;
|
||||
PORTD |= (1<<BuzzerON);
|
||||
} else {
|
||||
buzzerstate = 0;
|
||||
PORTD &= ~(1<<BuzzerON);
|
||||
}
|
||||
scommand = 0x40;
|
||||
svalue = (reedstate & 0x01) | (buzzerstate & 0x02);
|
||||
}
|
||||
if ((rcommand == 0x40) && (rchannel == 1)) {
|
||||
scommand = 0x40;
|
||||
svalue = (reedstate & 0x01) | (buzzerstate & 0x02);
|
||||
}
|
||||
if ((rcommand == 0x40) && ((rchannel > 1) && (rchannel < 6))) {
|
||||
ADMUX = (ADMUX & ~(0x1F)) | (rchannel - 2);
|
||||
ADCSRA |= (1<<ADSC);
|
||||
loop_until_bit_is_clear(ADCSRA, ADSC);
|
||||
scommand = 0x40;
|
||||
svalue = ADCW;
|
||||
}
|
||||
encodepart(i);
|
||||
}
|
||||
smode = 0;
|
||||
sendmsg();
|
||||
acktimer = 0;
|
||||
waitforsend = 0;
|
||||
}
|
||||
if ((rrecv == 0) && (rmode == 0) && waitforsend) {
|
||||
if (!acktimer) {
|
||||
scommand = 0x40;
|
||||
schannel = 1;
|
||||
svalue = (reedstate & 0x01) | (buzzerstate & 0x02);
|
||||
encodepart(0);
|
||||
scommand = 0;
|
||||
encodepart(1);
|
||||
encodepart(2);
|
||||
encodepart(3);
|
||||
smode = 1;
|
||||
sendmsg();
|
||||
acktimer = my_prio;
|
||||
} else
|
||||
acktimer--;
|
||||
}
|
||||
rflag = 0;
|
||||
}
|
||||
if (bit_is_clear(PIND, ReedSwitch) && (!reedstate)) {
|
||||
reedstate = ~0;
|
||||
waitforsend = ~0;
|
||||
PORTD |= (1<<RedLED);
|
||||
PORTD &= ~(1<<GreenLED);
|
||||
}
|
||||
if (bit_is_set(PIND, ReedSwitch) && reedstate) {
|
||||
reedstate = 0;
|
||||
waitforsend = ~0;
|
||||
PORTD &= ~(1<<RedLED);
|
||||
PORTD |= (1<<GreenLED);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<device eep_size="512" version="01">
|
||||
<supported_types>
|
||||
<type priority="2" id="HBW-EBALARM" name="EBus Alarm HBW">
|
||||
<parameter const_value="0xAB" size="1" index="0"/>
|
||||
<parameter const_value="0" size="1" index="1"/>
|
||||
</type>
|
||||
</supported_types>
|
||||
|
||||
<paramset id="HBW-EBALARM_dev_master" type="MASTER">
|
||||
<parameter id="LOGGING_TIME">
|
||||
<logical type="float" unit="s" default="5.0" max="25.5" min="0.1"/>
|
||||
<physical size="1.0" type="integer" interface="eeprom">
|
||||
<address index="0x0001"/>
|
||||
</physical>
|
||||
<conversion type="float_integer_scale" offset="0.0" factor="10"/>
|
||||
</parameter>
|
||||
<parameter id="CENTRAL_ADDRESS" hidden="true">
|
||||
<logical type="integer"/>
|
||||
<physical size="4" type="integer" interface="eeprom">
|
||||
<address index="0x0002"/>
|
||||
</physical>
|
||||
</parameter>
|
||||
<enforce id="CENTRAL_ADDRESS" value="1"/>
|
||||
</paramset>
|
||||
|
||||
<channels>
|
||||
<channel index="0" type="MAINTENANCE" count="1" class="maintenance" ui_flags="internal">
|
||||
</channel>
|
||||
<channel index="1" type="SWITCH" count="1" physical_index_offset="-1">
|
||||
</channel>
|
||||
</channels>
|
||||
|
||||
</device>
|
@ -1,90 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<device eep_size="512" version="01">
|
||||
<supported_types>
|
||||
<type priority="2" id="HBW-EBRELAY" name="Elektor EBus Relais Board">
|
||||
<parameter const_value="0xE1" size="1" index="0"/>
|
||||
<parameter const_value="0" size="1" index="1"/>
|
||||
</type>
|
||||
</supported_types>
|
||||
|
||||
<paramset id="HBW-EBRELAY_dev_master" type="MASTER">
|
||||
<parameter id="LOGGING_TIME">
|
||||
<logical type="float" unit="s" default="5.0" max="25.5" min="0.1"/>
|
||||
<physical size="1.0" type="integer" interface="eeprom">
|
||||
<address index="0x0001"/>
|
||||
</physical>
|
||||
<conversion type="float_integer_scale" offset="0.0" factor="10"/>
|
||||
</parameter>
|
||||
<parameter id="CENTRAL_ADDRESS" hidden="true">
|
||||
<logical type="integer"/>
|
||||
<physical size="4" type="integer" interface="eeprom">
|
||||
<address index="0x0002"/>
|
||||
</physical>
|
||||
</parameter>
|
||||
<enforce id="CENTRAL_ADDRESS" value="1"/>
|
||||
</paramset>
|
||||
|
||||
<frames>
|
||||
<frame id="LEVEL_SET" type="#x" channel_field="10" direction="to_device">
|
||||
<parameter size="1.0" index="11.0" type="integer" param="LEVEL"/>
|
||||
</frame>
|
||||
<frame id="LEVEL_GET" type="#S" channel_field="10" direction="to_device"/>
|
||||
<frame id="INFO_LEVEL" type="#i" channel_field="10" direction="from_device" event="true">
|
||||
<parameter size="1.0" index="11.0" type="integer" param="LEVEL"/>
|
||||
</frame>
|
||||
</frames>
|
||||
|
||||
|
||||
<channels>
|
||||
<channel index="0" type="MAINTENANCE" count="1" class="maintenance" ui_flags="internal">
|
||||
</channel>
|
||||
<channel index="1" type="SWITCH" count="2" physical_index_offset="-1">
|
||||
<paramset id="hmw_switch_ch_master" type="MASTER" address_step="2" address_start="0x06">
|
||||
<parameter id="LOGGING">
|
||||
<logical type="option">
|
||||
<option id="OFF"/>
|
||||
<option id="ON" default="true"/>
|
||||
</logical>
|
||||
<physical size="0.1" type="integer" interface="eeprom">
|
||||
<address index="+0"/>
|
||||
</physical>
|
||||
</parameter>
|
||||
</paramset>
|
||||
<paramset id="hmw_switch_ch_values" type="VALUES">
|
||||
<parameter id="STATE" operations="read,write,event" control="SWITCH.STATE">
|
||||
<logical type="boolean" default="false"/>
|
||||
<physical type="integer" interface="command" value_id="LEVEL">
|
||||
<set request="LEVEL_SET"/>
|
||||
<get request="LEVEL_GET" response="INFO_LEVEL"/>
|
||||
<event frame="INFO_LEVEL"/>
|
||||
</physical>
|
||||
<conversion type="boolean_integer" true="200" false="0" threshold="1"/>
|
||||
</parameter>
|
||||
</paramset>
|
||||
</channel>
|
||||
<channel index="2" type="SENSOR" count="2" physical_index_offset="-1">
|
||||
<paramset id="hmw_sensor_ch_master" type="MASTER" address_step="2" address_start="0x08">
|
||||
<parameter id="LOGGING">
|
||||
<logical type="option">
|
||||
<option id="OFF"/>
|
||||
<option id="ON" default="true"/>
|
||||
</logical>
|
||||
<physical size="0.1" type="integer" interface="eeprom">
|
||||
<address index="+0"/>
|
||||
</physical>
|
||||
</parameter>
|
||||
</paramset>
|
||||
<paramset id="hmw_sensor_ch_values" type="VALUES">
|
||||
<parameter id="STATE" operations="read,event" control="SWITCH.STATE">
|
||||
<logical type="boolean" default="false"/>
|
||||
<physical type="integer" interface="command" value_id="LEVEL">
|
||||
<get request="LEVEL_GET" response="INFO_LEVEL"/>
|
||||
<event frame="INFO_LEVEL"/>
|
||||
</physical>
|
||||
<conversion type="boolean_integer" true="200" false="0" threshold="1"/>
|
||||
</parameter>
|
||||
</paramset>
|
||||
</channel>
|
||||
</channels>
|
||||
|
||||
</device>
|
@ -1,89 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<device eep_size="512" version="01">
|
||||
<supported_types>
|
||||
<type priority="2" id="HBW-EBTEST" name="Elektor EBus Test Board">
|
||||
<parameter const_value="0xE0" size="1" index="0"/>
|
||||
<parameter const_value="0" size="1" index="1"/>
|
||||
</type>
|
||||
</supported_types>
|
||||
|
||||
<paramset id="HBW-EBTEST_dev_master" type="MASTER">
|
||||
<parameter id="LOGGING_TIME">
|
||||
<logical type="float" unit="s" default="5.0" max="25.5" min="0.1"/>
|
||||
<physical size="1.0" type="integer" interface="eeprom">
|
||||
<address index="0x0001"/>
|
||||
</physical>
|
||||
<conversion type="float_integer_scale" offset="0.0" factor="10"/>
|
||||
</parameter>
|
||||
<parameter id="CENTRAL_ADDRESS" hidden="true">
|
||||
<logical type="integer"/>
|
||||
<physical size="4" type="integer" interface="eeprom">
|
||||
<address index="0x0002"/>
|
||||
</physical>
|
||||
</parameter>
|
||||
<enforce id="CENTRAL_ADDRESS" value="1"/>
|
||||
</paramset>
|
||||
|
||||
<frames>
|
||||
<frame id="LEVEL_SET" type="#x" channel_field="10" direction="to_device">
|
||||
<parameter size="1.0" index="11.0" type="integer" param="LEVEL"/>
|
||||
</frame>
|
||||
<frame id="LEVEL_GET" type="#S" channel_field="10" direction="to_device"/>
|
||||
<frame id="INFO_LEVEL" type="#i" channel_field="10" direction="from_device" event="true">
|
||||
<parameter size="1.0" index="11.0" type="integer" param="LEVEL"/>
|
||||
</frame>
|
||||
</frames>
|
||||
|
||||
<channels>
|
||||
<channel index="0" type="MAINTENANCE" count="1" class="maintenance" ui_flags="internal">
|
||||
</channel>
|
||||
<channel index="1" type="SWITCH" count="1" physical_index_offset="-1">
|
||||
<paramset id="hmw_switch_ch_master" type="MASTER" address_step="2" address_start="0x06">
|
||||
<parameter id="LOGGING">
|
||||
<logical type="option">
|
||||
<option id="OFF"/>
|
||||
<option id="ON" default="true"/>
|
||||
</logical>
|
||||
<physical size="0.1" type="integer" interface="eeprom">
|
||||
<address index="+0"/>
|
||||
</physical>
|
||||
</parameter>
|
||||
</paramset>
|
||||
<paramset id="hmw_switch_ch_values" type="VALUES">
|
||||
<parameter id="STATE" operations="read,write,event" control="SWITCH.STATE">
|
||||
<logical type="boolean" default="false"/>
|
||||
<physical type="integer" interface="command" value_id="LEVEL">
|
||||
<set request="LEVEL_SET"/>
|
||||
<get request="LEVEL_GET" response="INFO_LEVEL"/>
|
||||
<event frame="INFO_LEVEL"/>
|
||||
</physical>
|
||||
<conversion type="boolean_integer" true="200" false="0" threshold="1"/>
|
||||
</parameter>
|
||||
</paramset>
|
||||
</channel>
|
||||
<channel index="2" type="SENSOR" count="1" physical_index_offset="-1">
|
||||
<paramset id="hmw_sensor_ch_master" type="MASTER" address_step="2" address_start="0x08">
|
||||
<parameter id="LOGGING">
|
||||
<logical type="option">
|
||||
<option id="OFF"/>
|
||||
<option id="ON" default="true"/>
|
||||
</logical>
|
||||
<physical size="0.1" type="integer" interface="eeprom">
|
||||
<address index="+0"/>
|
||||
</physical>
|
||||
</parameter>
|
||||
</paramset>
|
||||
<paramset id="hmw_sensor_ch_values" type="VALUES">
|
||||
<parameter id="STATE" operations="read,event" control="SWITCH.STATE">
|
||||
<logical type="boolean" default="false"/>
|
||||
<physical type="integer" interface="command" value_id="LEVEL">
|
||||
<get request="LEVEL_GET" response="INFO_LEVEL"/>
|
||||
<event frame="INFO_LEVEL"/>
|
||||
</physical>
|
||||
<conversion type="boolean_integer" true="200" false="0" threshold="1"/>
|
||||
</parameter>
|
||||
</paramset>
|
||||
</channel>
|
||||
</channels>
|
||||
|
||||
</device>
|
@ -1,7 +0,0 @@
|
||||
#ifndef __RELAISHW_H__
|
||||
#define __RELAISHW_H__
|
||||
#define TestLED PD4
|
||||
#define TestButton PD5
|
||||
#define Relais1 PB0
|
||||
#define Relais2 PB1
|
||||
#endif
|
@ -1,174 +0,0 @@
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include "relaishw.h"
|
||||
#include "rs485.h"
|
||||
#include "eb.h"
|
||||
|
||||
uint8_t testled;
|
||||
uint8_t testbutton;
|
||||
uint8_t relais1state;
|
||||
uint8_t relais2state;
|
||||
uint8_t pc0state;
|
||||
uint8_t pc1state;
|
||||
|
||||
uint8_t waitforack;
|
||||
uint8_t waitforsend;
|
||||
uint8_t acktimer;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
init_rs485();
|
||||
DDRD |= (1<<TestLED);
|
||||
DDRD &= ~(1<<TestButton);
|
||||
|
||||
DDRB |= (1<<Relais1);
|
||||
DDRB |= (1<<Relais2);
|
||||
|
||||
DDRC &= ~(1<<PC0);
|
||||
DDRC &= ~(1<<PC1);
|
||||
|
||||
PORTD &= ~(1<<TestLED);
|
||||
PORTD |= (1<<TestButton);
|
||||
|
||||
PORTB &= ~(1<<Relais1);
|
||||
PORTB &= ~(1<<Relais2);
|
||||
|
||||
PORTC |= (1<<PC0);
|
||||
PORTC |= (1<<PC1);
|
||||
|
||||
ADMUX = (0<<REFS1) | (1<<REFS0);
|
||||
ADCSRA = (1<<ADPS2) | (1<<ADPS1);
|
||||
ADCSRA |= (1<<ADEN);
|
||||
ADCSRA |= (1<<ADSC);
|
||||
loop_until_bit_is_clear(ADCSRA, ADSC);
|
||||
svalue = ADCW;
|
||||
|
||||
my_address = eeprom_read_byte((const uint8_t *)0);
|
||||
my_prio = eeprom_read_byte((const uint8_t *)1);
|
||||
master = eeprom_read_byte((const uint8_t *)2);
|
||||
|
||||
testled = 0;
|
||||
relais1state = 0;
|
||||
relais2state = 0;
|
||||
pc0state = 0;
|
||||
pc1state = 0;
|
||||
|
||||
waitforsend = 0;
|
||||
acktimer = 0;
|
||||
|
||||
sei();
|
||||
while(1) {
|
||||
rs485_loop();
|
||||
if (rflag) {
|
||||
if (rsender)
|
||||
srecv = rsender;
|
||||
else
|
||||
srecv = master;
|
||||
smode = 0;
|
||||
if ((rrecv == my_address) && (rmode == 2)) {
|
||||
acktimer = 0;
|
||||
waitforsend = 0;
|
||||
}
|
||||
|
||||
if ((rrecv == my_address) && (rmode == 0)) {
|
||||
for (i=0; i<4; i++) {
|
||||
decodepart(i);
|
||||
scommand = 0;
|
||||
schannel = rchannel;
|
||||
if ((rcommand == 0x40) && (rchannel == 0)) {
|
||||
scommand = 0x40;
|
||||
svalue = 4; /* Relais mit 2 Schalt-IO und 2 ADC*/
|
||||
}
|
||||
if ((rcommand == 0x60) && (rchannel == 1)) {
|
||||
if (rvalue & 0x01) {
|
||||
testled = ~0;
|
||||
PORTD |= (1<<TestLED);
|
||||
} else {
|
||||
testled = 0;
|
||||
PORTD &= ~(1<<TestLED);
|
||||
}
|
||||
if (rvalue & 0x02) {
|
||||
relais1state = ~0;
|
||||
PORTB |= (1<<Relais1);
|
||||
} else {
|
||||
relais1state = 0;
|
||||
PORTB &= ~(1<<Relais1);
|
||||
}
|
||||
if (rvalue & 0x04) {
|
||||
relais2state = ~0;
|
||||
PORTB |= (1<<Relais2);
|
||||
} else {
|
||||
relais2state = 0;
|
||||
PORTB &= ~(1<<Relais2);
|
||||
}
|
||||
scommand = 0x40;
|
||||
svalue = (testled & 0x01) | (relais1state & 0x02) | (relais2state & 0x04) | (pc0state & 0x08) | (pc1state & 0x10);
|
||||
}
|
||||
if ((rcommand == 0x40) && (rchannel == 1)) {
|
||||
scommand = 0x40;
|
||||
svalue = (testled & 0x01) | (relais1state & 0x02) | (relais2state & 0x04) | (pc0state & 0x08) | (pc1state & 0x10);
|
||||
}
|
||||
if ((rcommand == 0x40) && ((rchannel > 1) && (rchannel < 4))) {
|
||||
ADMUX = (ADMUX & ~(0x1F)) | (rchannel);
|
||||
ADCSRA |= (1<<ADSC);
|
||||
loop_until_bit_is_clear(ADCSRA, ADSC);
|
||||
scommand = 0x40;
|
||||
svalue = ADCW;
|
||||
}
|
||||
encodepart(i);
|
||||
}
|
||||
smode = 0;
|
||||
sendmsg();
|
||||
acktimer = 0;
|
||||
waitforsend = 0;
|
||||
}
|
||||
if ((rrecv == 0) && (rmode == 0) && waitforsend) {
|
||||
if (!acktimer) {
|
||||
scommand = 0x40;
|
||||
schannel = 1;
|
||||
svalue = (testled & 0x01) | (relais1state & 0x02) | (relais2state & 0x04) | (pc0state & 0x08) | (pc1state & 0x10);
|
||||
encodepart(0);
|
||||
scommand = 0;
|
||||
encodepart(1);
|
||||
encodepart(2);
|
||||
encodepart(3);
|
||||
smode = 1;
|
||||
sendmsg();
|
||||
acktimer = my_prio;
|
||||
} else
|
||||
acktimer--;
|
||||
}
|
||||
rflag = 0;
|
||||
}
|
||||
if (bit_is_clear(PIND, TestButton) && (!testbutton)) {
|
||||
testbutton = ~0;
|
||||
testled = ~testled;
|
||||
waitforsend = ~0;
|
||||
if (testled)
|
||||
PORTD |= (1<<TestLED);
|
||||
else
|
||||
PORTD &= ~(1<<TestLED);
|
||||
}
|
||||
if (bit_is_set(PIND, TestButton) && testbutton)
|
||||
testbutton = 0;
|
||||
if (bit_is_clear(PINC, PC0) && (!pc0state)) {
|
||||
pc0state = ~0;
|
||||
waitforsend = ~0;
|
||||
}
|
||||
if (bit_is_set(PINC, PC0) && (pc0state)) {
|
||||
pc0state = 0;
|
||||
waitforsend = ~0;
|
||||
}
|
||||
if (bit_is_clear(PINC, PC1) && (!pc1state)) {
|
||||
pc1state = ~0;
|
||||
waitforsend = ~0;
|
||||
}
|
||||
if (bit_is_set(PINC, PC1) && (pc1state)) {
|
||||
pc1state = 0;
|
||||
waitforsend = ~0;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue