From: Mikko Rasa Date: Sun, 3 Nov 2013 17:08:22 +0000 (+0200) Subject: Make current and voltage readings public to other modules X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=7cbb1042ee8a255ed1d1e008ebee4bffe1137565;p=model-railway-devices.git Make current and voltage readings public to other modules --- diff --git a/arducontrol/monitor.c b/arducontrol/monitor.c index 7966c3d..920f56d 100644 --- a/arducontrol/monitor.c +++ b/arducontrol/monitor.c @@ -17,9 +17,6 @@ static volatile uint16_t input_voltage_sum = 0; static volatile uint8_t adc_state = 0; static volatile uint16_t adc_value = 0; -static uint16_t track_current_milliamps(void); -static uint16_t input_voltage_millivolts(void); - void monitor_init(void) { DDRB |= 0x02; @@ -77,7 +74,7 @@ uint8_t monitor_command(const uint8_t *cmd_buf, uint8_t cmd_length) if(cmd_length!=1) return LENGTH_ERROR; - uint16_t value = track_current_milliamps(); + uint16_t value = monitor_track_current(); uint8_t reply[3]; reply[0] = TRACK_CURRENT; reply[1] = value>>8; @@ -103,7 +100,7 @@ uint8_t monitor_command(const uint8_t *cmd_buf, uint8_t cmd_length) if(cmd_length!=1) return LENGTH_ERROR; - uint16_t value = input_voltage_millivolts(); + uint16_t value = monitor_input_voltage(); uint8_t reply[3]; reply[0] = INPUT_VOLTAGE; reply[1] = value>>8; @@ -116,7 +113,7 @@ uint8_t monitor_command(const uint8_t *cmd_buf, uint8_t cmd_length) return COMMAND_OK; } -static uint16_t track_current_milliamps(void) +uint16_t monitor_track_current(void) { uint16_t value = track_current_sum; @@ -133,7 +130,7 @@ static uint16_t track_current_milliamps(void) } } -static uint16_t input_voltage_millivolts(void) +uint16_t monitor_input_voltage(void) { uint16_t value = input_voltage_sum; diff --git a/arducontrol/monitor.h b/arducontrol/monitor.h index 031d26e..c727c9c 100644 --- a/arducontrol/monitor.h +++ b/arducontrol/monitor.h @@ -5,6 +5,8 @@ void monitor_init(void); void monitor_check(void); +uint16_t monitor_track_current(void); +uint16_t monitor_input_voltage(void); uint8_t monitor_command(const uint8_t *, uint8_t); #endif