aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/includes/GPIO/analog.h6
-rw-r--r--src/common/src/Core/common.c2
-rw-r--r--src/common/src/GPIO/usart.c13
-rw-r--r--src/glutt-o-logique/analog_input.c11
4 files changed, 18 insertions, 14 deletions
diff --git a/src/common/includes/GPIO/analog.h b/src/common/includes/GPIO/analog.h
index 375708f..ddc19ac 100644
--- a/src/common/includes/GPIO/analog.h
+++ b/src/common/includes/GPIO/analog.h
@@ -29,16 +29,22 @@ void analog_init(void);
/* Measure the 12V supply voltage, in 0.5V increments.
* Returns 0.0f in case of error
+ *
+ * Warning, do not run from interrupt context!
*/
float analog_measure_12v(void);
/* Measure SWR, and return voltages in mV.
* Returns 0 in case of error, 1 in case of success
+ *
+ * Warning, do not run from interrupt context!
*/
int analog_measure_swr(int *forward_mv, int* reflected_mv);
/* Keep an average of measurements, and decide if the repeater should enter
* QRP. Returns 1 if low power must be activated
+ *
+ * Warning, do not run from interrupt context!
*/
int analog_supply_too_low(void);
diff --git a/src/common/src/Core/common.c b/src/common/src/Core/common.c
index 2790f15..9c7d3c5 100644
--- a/src/common/src/Core/common.c
+++ b/src/common/src/Core/common.c
@@ -253,7 +253,7 @@ int random_bool(void)
static int faultsource = 0;
void trigger_fault(int source)
{
- usart_debug("Fatal: %d", source);
+ usart_debug("Fatal: %d\r\n\r\n", source);
__disable_irq();
diff --git a/src/common/src/GPIO/usart.c b/src/common/src/GPIO/usart.c
index ee7ad9f..052c546 100644
--- a/src/common/src/GPIO/usart.c
+++ b/src/common/src/GPIO/usart.c
@@ -127,17 +127,8 @@ static void usart_clear_nmea_buffer(void) {
}
void usart_process_char(char c) {
-
- if (c == 'h') {
- usart_debug_puts("help: commands: [v]oltage.\r\n");
- }
- else if (c == 'v') {
- const float supply_voltage = analog_measure_12v();
- usart_debug("12V monitor %dmV\r\n", (int32_t)(supply_voltage * 1000.0f));
- }
- else {
- usart_debug("Unknown command %c\r\n", c);
- }
+// Warning: running in interrupt context
+ usart_debug("Unknown command %c\r\n", c);
}
void usart_gps_process_char(char c) {
diff --git a/src/glutt-o-logique/analog_input.c b/src/glutt-o-logique/analog_input.c
index 682472b..ebfa486 100644
--- a/src/glutt-o-logique/analog_input.c
+++ b/src/glutt-o-logique/analog_input.c
@@ -23,6 +23,11 @@
*/
#include "analog_input.h"
+
+#include "FreeRTOS.h"
+#include "task.h"
+#include "timers.h"
+
#include "Core/delay.h"
#include "Core/common.h"
#include "stm32f4xx_adc.h"
@@ -83,16 +88,18 @@ static uint16_t analog_read_channel(uint8_t channel)
* System clock is at 168MHz, ADC is on APB2 which has a prescaler of 2.
* 480 cycles at 84Mhz is about 6us.
*
- * If we have no result after 10ms it is a real problem.
+ * If we have no result after 10ms it is a real problem. Keep in mind
+ * we could get preempted.
*/
int ready = 0;
- for (int i = 0; i < 10000; i++) {
+ for (int i = 0; i < 10; i++) {
if (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == SET) {
ready = 1;
break;
}
+ vTaskDelay(pdMS_TO_TICKS(1));
}
if (!ready) {