speichern

This commit is contained in:
Tristan Krause 2019-04-02 10:59:37 +02:00
parent 86da74bed0
commit 8e785e4b70
15 changed files with 443 additions and 282 deletions

View file

@ -2,99 +2,99 @@
void rqTestConnection()
{
uint8_t dummy = usart.readByte();
usart.writeByte(USART::MSG_OK);
usart.writeByte(dummy);
uint8_t dummy = ((USART*) &usart)->readByte();
((USART*) &usart)->writeByte(USART::MSG_OK);
((USART*) &usart)->writeByte(dummy);
}
void rqBoardInfo()
{
usart.writeByte(3); // Anzahl an Strings
((USART*) &usart)->writeByte(3); // Anzahl an Strings
usart.writeStr(DATE, sizeof(DATE));
usart.writeStr(TIME, sizeof(TIME));
usart.writeStr(FSRC, sizeof(FSRC));
usart.writeByte(USART::MSG_OK);
((USART*) &usart)->writeStr(DATE, sizeof(DATE));
((USART*) &usart)->writeStr(TIME, sizeof(TIME));
((USART*) &usart)->writeStr(FSRC, sizeof(FSRC));
((USART*) &usart)->writeByte(USART::MSG_OK);
}
void rqTestIntConv()
{
usart.writeInt(usart.readInt() * 3);
((USART*) &usart)->writeInt(((USART*) &usart)->readInt() * 3);
}
void rqDigitalWrite0()
{
uint8_t port = usart.readByte();
beba0.writePortA(port);
uint8_t port = ((USART*) &usart)->readByte();
((MCP23S17*) &beba0)->writePortA(port);
usart.writeByte(USART::MSG_OK);
((USART*) &usart)->writeByte(USART::MSG_OK);
}
void rqDigitalWrite1()
{
uint8_t port = usart.readByte();
beba1.writePortA(port);
uint8_t port = ((USART*) &usart)->readByte();
((MCP23S17*) &beba1)->writePortA(port);
usart.writeByte(USART::MSG_OK);
((USART*) &usart)->writeByte(USART::MSG_OK);
}
void rqDigitalRead0()
{
uint8_t port = beba0.readPortB();
usart.writeByte(port);
uint8_t port = ((MCP23S17*) &beba0)->readPortB();
((USART*) &usart)->writeByte(port);
}
void rqDigitalRead1()
{
uint8_t port = beba1.readPortB();
usart.writeByte(port);
uint8_t port = ((MCP23S17*) &beba1)->readPortB();
((USART*) &usart)->writeByte(port);
}
void rqAnalogWrite0()
{
uint16_t value = usart.readInt();
dac0.setValue(value);
uint16_t value = ((USART*) &usart)->readInt();
((TLC5615*) &dac0)->setValue(value);
usart.writeByte(USART::MSG_OK);
((USART*) &usart)->writeByte(USART::MSG_OK);
}
void rqAnalogWrite1()
{
uint16_t value = usart.readInt();
dac1.setValue(value);
uint16_t value = ((USART*) &usart)->readInt();
((TLC5615*) &dac1)->setValue(value);
usart.writeByte(USART::MSG_OK);
((USART*) &usart)->writeByte(USART::MSG_OK);
}
void rqAnalogRead()
{
uint8_t channel = usart.readByte();
uint16_t value = adu.getValue(channel);
usart.writeInt(value);
uint8_t channel = ((USART*) &usart)->readByte();
uint16_t value = ((ADU*) &adu)->getValue(channel);
((USART*) &usart)->writeInt(value);
}
void rqAdcDacStroke()
{
uint8_t channel_a = usart.readByte();
uint8_t channel_b = usart.readByte();
uint8_t channel_a = ((USART*) &usart)->readByte();
uint8_t channel_b = ((USART*) &usart)->readByte();
int16_t start = static_cast<int16_t>(usart.readInt());
int16_t delta = static_cast<int16_t>(usart.readInt());
int16_t count = static_cast<int16_t>(usart.readInt());
int16_t start = static_cast<int16_t>(((USART*) &usart)->readInt());
int16_t delta = static_cast<int16_t>(((USART*) &usart)->readInt());
int16_t count = static_cast<int16_t>(((USART*) &usart)->readInt());
usart.writeByte(USART::MSG_OK);
((USART*) &usart)->writeByte(USART::MSG_OK);
count *= delta;
for(int16_t i = start; i < count; i += delta)
{
dac0.setValue(i);
((TLC5615*) &dac0)->setValue(i);
wdt_reset();
uint16_t val_a = adu.getValue(channel_a);
uint16_t val_b = adu.getValue(channel_b);
usart.writeInt(val_a);
usart.writeInt(val_b);
uint16_t val_a = ((ADU*) &adu)->getValue(channel_a);
uint16_t val_b = ((ADU*) &adu)->getValue(channel_b);
((USART*) &usart)->writeInt(val_a);
((USART*) &usart)->writeInt(val_b);
/*union doubleword
{
@ -103,19 +103,19 @@ void rqAdcDacStroke()
};
union doubleword dw;
dw.word[0] = adu.getValue(channel_a);
dw.word[1] = adu.getValue(channel_b);
dw.word[0] = ((ADU*) &adu)->getValue(channel_a);
dw.word[1] = ((ADU*) &adu)->getValue(channel_b);
uint8_t ret = 0;
do
{
wdt_reset();
ret = usart.writeBlock(&(dw.byte[0]), 4);
ret = ((USART*) &usart)->writeBlock(&(dw.byte[0]), 4);
if(ret == 0)
return;
} while(ret != USART::MSG_OK);*/
}
usart.writeByte(USART::MSG_OK);
((USART*) &usart)->writeByte(USART::MSG_OK);
}