Compare commits

...

No commits in common. '522dc8312787e7820d0bd7a97ec3468787796aa6' and 'b5b9383d4e4e8c49d5163cbdf92bf6998f45fb61' have entirely different histories.

@ -212,7 +212,7 @@ static uint8_t senddsc(void)
static uint8_t is_bus_free(void)
{
if(sdelay || slocked)
if(sdelay || slocked || sind)
return 0;
return 1;
}
@ -299,6 +299,7 @@ void hbw_init(void)
void snext(void)
{
#ifdef HBW_MAXLINKS
uint8_t linkchannel;
if (amessage[0] != 'K') {
@ -315,7 +316,7 @@ void snext(void)
((uint8_t*)&aaddress)[3]=eeprom_read_byte((const uint8_t *)(alink*6)+HBW_LINKOFFS+4);
linkchannel=eeprom_read_byte((const uint8_t *)(alink*6)+HBW_LINKOFFS+5);
if(aaddress == my_address) {
hbw_receive_key(linkchannel, amessage[3] >> 2, amessage[3] & 0x3);
hbw_receive_key(aaddress, amessage[1], linkchannel, amessage[3]);
} else {
amessage[2] = linkchannel;
sbusy = 1;
@ -325,6 +326,7 @@ void snext(void)
}
alink++;
}
#endif
alink = 0;
}
@ -508,7 +510,7 @@ static void rprocess(void)
case 0xCB:
if (rlen != 4)
return;
hbw_receive_key(rmessage[2], rmessage[3] >> 2, rmessage[3] & 0x3);
hbw_receive_key(raddress, rmessage[1], rmessage[2], rmessage[3]);
slen = 0;
sctl = 0x19 | (seq << 5);
sendmsg();

@ -15,7 +15,7 @@ void hbw_init(void);
void hbw_loop(void);
uint8_t hbw_send_channel(uint8_t channel, uint8_t length, uint8_t const * const data);
uint8_t hbw_send_key(uint8_t channel, uint8_t count, uint8_t flag);
void hbw_receive_key(uint8_t channel, uint8_t count, uint8_t flag);
void hbw_receive_key(uint32_t saddress, uint8_t schannel, uint8_t channel, uint8_t countflag);
uint8_t hbw_get_channel(uint8_t channel, uint8_t data[]);
void hbw_set_channel(uint8_t channel, uint8_t len, uint8_t data[]);
void hbw_read_config(void);

@ -50,6 +50,69 @@
</physical>
</parameter>
</paramset>
<paramset id="hmw_switch_ch_link" type="LINK" count="16" address_start="0x10" address_step="7" peer_param="SENSOR" channel_param="CHANNEL">
<parameter id="SENSOR" hidden="true" operations="none">
<logical type="address"/>
<physical type="array">
<physical size="4.0" type="integer" interface="eeprom">
<address index="+0"/>
</physical>
<physical size="1.0" type="integer" interface="eeprom">
<address index="+4"/>
</physical>
</physical>
</parameter>
<parameter id="CHANNEL" hidden="true" operations="none">
<logical type="integer" min="0" max="255" default="255"/>
<physical size="1.0" type="integer" interface="eeprom">
<address index="+5"/>
</physical>
</parameter>
<parameter id="SHORT_ACTION_TYPE">
<logical type="option">
<option id="ON"/>
<option id="OFF"/>
<option id="INACTIVE"/>
<option id="TOGGLE" default="true"/>
</logical>
<physical size="0.2" type="integer" interface="eeprom">
<address index="+6"/>
</physical>
</parameter>
<parameter id="LONG_ACTION_TYPE">
<logical type="option">
<option id="ON"/>
<option id="OFF"/>
<option id="INACTIVE"/>
<option id="TOGGLE" default="true"/>
</logical>
<physical size="0.2" type="integer" interface="eeprom">
<address index="+6.2"/>
</physical>
</parameter>
<parameter id="LONGRELEASE_ACTION_TYPE">
<logical type="option">
<option id="ON"/>
<option id="OFF"/>
<option id="INACTIVE" default="true"/>
<option id="TOGGLE"/>
</logical>
<physical size="0.2" type="integer" interface="eeprom">
<address index="+6.4"/>
</physical>
</parameter>
<parameter id="DOUBLE_ACTION_TYPE">
<logical type="option">
<option id="ON"/>
<option id="OFF"/>
<option id="INACTIVE" default="true"/>
<option id="TOGGLE"/>
</logical>
<physical size="0.2" type="integer" interface="eeprom">
<address index="+6.6"/>
</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"/>

@ -44,6 +44,10 @@
<parameter const_value="0" size="0.2" index="12.0" type="integer"/>
<parameter size="0.6" index="12.2" type="integer" param="COUNTER"/>
</frame>
<frame id="KEY_EVENT_DOUBLE" type="#K" channel_field="10" direction="from_device" event="true">
<parameter const_value="1" size="0.2" index="12.0" type="integer"/>
<parameter size="0.6" index="12.2" type="integer" param="COUNTER"/>
</frame>
</frames>
<channels>
@ -61,6 +65,69 @@
</physical>
</parameter>
</paramset>
<paramset id="hmw_switch_ch_link" type="LINK" count="16" address_start="0x10" address_step="7" peer_param="SENSOR" channel_param="CHANNEL">
<parameter id="SENSOR" hidden="true" operations="none">
<logical type="address"/>
<physical type="array">
<physical size="4.0" type="integer" interface="eeprom">
<address index="+0"/>
</physical>
<physical size="1.0" type="integer" interface="eeprom">
<address index="+4"/>
</physical>
</physical>
</parameter>
<parameter id="CHANNEL" hidden="true" operations="none">
<logical type="integer" min="0" max="255" default="255"/>
<physical size="1.0" type="integer" interface="eeprom">
<address index="+5"/>
</physical>
</parameter>
<parameter id="SHORT_ACTION_TYPE">
<logical type="option">
<option id="ON"/>
<option id="OFF"/>
<option id="INACTIVE"/>
<option id="TOGGLE" default="true"/>
</logical>
<physical size="0.2" type="integer" interface="eeprom">
<address index="+6"/>
</physical>
</parameter>
<parameter id="LONG_ACTION_TYPE">
<logical type="option">
<option id="ON"/>
<option id="OFF"/>
<option id="INACTIVE"/>
<option id="TOGGLE" default="true"/>
</logical>
<physical size="0.2" type="integer" interface="eeprom">
<address index="+6.2"/>
</physical>
</parameter>
<parameter id="LONGRELEASE_ACTION_TYPE">
<logical type="option">
<option id="ON"/>
<option id="OFF"/>
<option id="INACTIVE" default="true"/>
<option id="TOGGLE"/>
</logical>
<physical size="0.2" type="integer" interface="eeprom">
<address index="+6.4"/>
</physical>
</parameter>
<parameter id="DOUBLE_ACTION_TYPE">
<logical type="option">
<option id="ON"/>
<option id="OFF"/>
<option id="INACTIVE" default="true"/>
<option id="TOGGLE"/>
</logical>
<physical size="0.2" type="integer" interface="eeprom">
<address index="+6.6"/>
</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"/>
@ -89,7 +156,7 @@
</conversion>
</parameter>
</paramset>
<paramset id="hmw_input_ch_link" type="LINK" count="6" address_step="6" address_start="0x10" channel_param="CHANNEL" peer_param="ACTUATOR">
<paramset id="hmw_input_ch_link" type="LINK" count="16" address_step="6" address_start="0x80" channel_param="CHANNEL" peer_param="ACTUATOR">
<parameter hidden="true" id="CHANNEL" operations="none">
<logical type="integer" default="255" max="255" min="0"/>
<physical size="1.0" type="integer" interface="eeprom">
@ -107,7 +174,7 @@
</physical>
</physical>
</parameter>
</paramset>
</paramset>
<paramset id="hmw_input_ch_values" type="VALUES">
<parameter id="PRESS_SHORT" operations="event,write" loopback="true" control="BUTTON.SHORT">
<logical type="action"/>
@ -123,6 +190,20 @@
</physical>
<conversion type="action_key_counter" counter_size="6" sim_counter="SIM_COUNTER"/>
</parameter>
<parameter id="RELEASE_LONG" operations="event" loopback="true" control="BUTTON.RELEASE">
<logical type="action"/>
<physical type="integer" interface="command" value_id="COUNTER">
<event frame="KEY_EVENT_LONGRELEASE"/>
</physical>
<conversion type="action_key_counter" counter_size="6" sim_counter="SIM_COUNTER"/>
</parameter>
<parameter id="DOUBLECLICK" operations="event" loopback="true" control="BUTTON.DOUBLE">
<logical type="action"/>
<physical type="integer" interface="command" value_id="COUNTER">
<event frame="KEY_EVENT_DOUBLE"/>
</physical>
<conversion type="action_key_counter" counter_size="6" sim_counter="SIM_COUNTER"/>
</parameter>
</paramset>
</channel>
</channels>

@ -20,7 +20,4 @@
#define HBWSERIAL8 '0'
#define HBWSERIAL9 '1'
#define HBW_MAXLINKS 16
#define HBW_LINKOFFS 0x10
#endif

@ -8,6 +8,7 @@ uint8_t relais1state;
uint8_t relais2state;
uint8_t pc0state;
uint8_t pc1state;
uint8_t scount;
void hbw_read_config(void)
{
@ -62,12 +63,59 @@ void hbw_set_channel(uint8_t channel, uint8_t len, uint8_t data[])
}
}
void hbw_receive_key(uint8_t channel, uint8_t count, uint8_t flag)
void hbw_receive_key(uint32_t saddress, uint8_t schannel, uint8_t channel, uint8_t countflag)
{
if(channel == 0)
PORTB ^= (1<<Relais1);
if(channel == 1)
PORTB ^= (1<<Relais2);
uint8_t i, type;
if (channel > 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<<Relais1);
else
PORTB |= (1<<Relais2);
break;
case 1:
if(channel == 0)
PORTB &= ~(1<<Relais1);
else
PORTB &= ~(1<<Relais2);
break;
case 3:
if(channel == 0)
PORTB ^= (1<<Relais1);
else
PORTB ^= (1<<Relais2);
}
return;
}
}
}
int main(void)

@ -21,5 +21,5 @@
#define HBWSERIAL9 '1'
#define HBW_MAXLINKS 16
#define HBW_LINKOFFS 0x10
#define HBW_LINKOFFS 0x80
#endif

@ -11,6 +11,7 @@ uint16_t explong;
uint16_t longtime;
uint16_t logtime;
uint8_t logging;
uint8_t scount;
void hbw_read_config(void)
{
@ -59,10 +60,50 @@ void hbw_set_channel(uint8_t channel, uint8_t len, uint8_t data[])
}
}
void hbw_receive_key(uint8_t channel, uint8_t count, uint8_t flag)
void hbw_receive_key(uint32_t saddress, uint8_t schannel, uint8_t channel, uint8_t countflag)
{
if(channel == 0)
PORTD ^= (1<<ExpLED);
uint8_t i, type;
if (channel != 0)
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:
PORTD |= (1<<ExpLED);
break;
case 1:
PORTD &= ~(1<<ExpLED);
break;
case 3:
PORTD ^= (1<<ExpLED);
}
return;
}
}
}
int main(void)

Loading…
Cancel
Save