{
POWER_ON = 0x01,
POWER_OFF = 0x02,
+ READ_POWER_STATE = 0x03,
READ_TRACK_CURRENT = 0x08,
SET_OVERCURRENT_LIMIT = 0x09,
READ_INPUT_VOLTAGE = 0x0A,
OVERCURRENT = 0xA0,
TRACK_CURRENT = 0xC0,
INPUT_VOLTAGE = 0xC1,
+ POWER_STATE = 0xC2,
S88_DATA = 0xD0
};
#include <avr/io.h>
-#include "commands.h"
+#include "interface.h"
#include "output.h"
#include "timer.h"
PORTD &= ~BIT(ENABLE);
}
+uint8_t output_is_power_on()
+{
+ return (PORTD&BIT(ENABLE))!=0;
+}
+
uint8_t output_command(const uint8_t *cmd_buf, uint8_t cmd_length)
{
if(cmd_buf[0]==POWER_ON || cmd_buf[0]==POWER_OFF)
output_set_power(cmd_buf[0]==POWER_ON);
}
+ else if(cmd_buf[0]==READ_POWER_STATE)
+ {
+ if(cmd_length!=1)
+ return LENGTH_ERROR;
+
+ uint8_t reply[2];
+ reply[0] = POWER_STATE;
+ reply[1] = output_is_power_on();
+ interface_send(reply, 2);
+ }
else
return INVALID_COMMAND;
void output_init(void);
void clear_packet(void);
void output_set_power(uint8_t);
+uint8_t output_is_power_on();
uint8_t output_command(const uint8_t *, uint8_t);
#endif