aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/perfboard.svg175
-rw-r--r--src/common/includes/Core/fsm.h1
-rw-r--r--src/common/includes/GPIO/analog.h5
-rw-r--r--src/common/sourcelist.txt1
-rw-r--r--src/common/src/Core/main.c14
-rw-r--r--src/common/src/GPIO/usart.c11
-rw-r--r--src/glutt-o-logique/analog_input.c19
-rw-r--r--src/glutt-o-logique/usart.c1
8 files changed, 190 insertions, 37 deletions
diff --git a/doc/perfboard.svg b/doc/perfboard.svg
index 4c09d48..d62fc46 100644
--- a/doc/perfboard.svg
+++ b/doc/perfboard.svg
@@ -2284,9 +2284,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="4"
- inkscape:cx="697.29742"
- inkscape:cy="566.29726"
+ inkscape:zoom="5.6568542"
+ inkscape:cx="337.57276"
+ inkscape:cy="212.30536"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -21050,8 +21050,8 @@
sodipodi:nodetypes="ccccccc"
inkscape:connector-curvature="0"
id="path47630"
- d="m 269.29135,853.937 5.66929,8.50394 589.60631,1.41732 0,-194.17324 14.17323,-14.17323 26.92914,11.33859 29.76378,-10e-6"
- style="fill:none;fill-rule:evenodd;stroke:#04495e;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ d="m 269.29135,853.937 11.33858,18.4252 581.10238,1.41732 0,-204.0945 17.00787,-14.17323 26.92914,11.33859 29.76378,-10e-6"
+ style="fill:none;fill-rule:evenodd;stroke:#04495e;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" />
<path
style="fill:none;fill-rule:evenodd;stroke:#04495e;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1"
d="m 311.81103,570.47242 7.08662,7.08662 120.47244,0 0,205.51182 411.02364,0 28.34645,-28.34646 41.10237,-35.43308 29.76378,0"
@@ -21100,13 +21100,13 @@
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:7.5px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- x="316.06299"
- y="858.18896"
+ x="258.90402"
+ y="869.05865"
id="text33214"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
- x="316.06299"
- y="858.18896"
+ x="258.90402"
+ y="869.05865"
style="font-size:7.5px"
id="tspan33220">QRPn in</tspan></text>
<path
@@ -22524,8 +22524,8 @@
d="m 283.46458,712.20471 24.09448,-24.09449 0,-279.21261 564.09451,0 0,76.53543 7.08661,0 48.18898,100.62993 4.25199,0"
style="fill:none;fill-rule:evenodd;stroke:#e38100;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" />
<path
- style="fill:none;fill-rule:evenodd;stroke:#008607;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 283.46458,853.937 5.66929,5.66929 578.26773,0 0,-107.71654 11.33858,-11.33858 39.68504,-25.51182 17.00788,0"
+ style="fill:none;fill-rule:evenodd;stroke:#008607;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1"
+ d="m 283.46458,853.937 14.17322,15.59055 569.7638,0 0,-117.6378 11.33858,-11.33858 39.68504,-25.51182 17.00788,0"
id="path30259"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccc" />
@@ -25205,14 +25205,14 @@
<text
sodipodi:linespacing="125%"
id="text47602"
- y="869.52753"
- x="252.28348"
+ y="868.00568"
+ x="227.9097"
style="font-style:normal;font-weight:normal;font-size:7.5px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
id="tspan47604"
style="font-size:7.5px"
- y="869.52753"
- x="252.28348"
+ y="868.00568"
+ x="227.9097"
sodipodi:role="line">RESETn</tspan></text>
<g
transform="matrix(0,1,-1,0,1080.6316,386.22046)"
@@ -28525,7 +28525,7 @@
sodipodi:nodetypes="ccccccccc"
inkscape:connector-curvature="0"
id="path35344"
- d="m 524.40946,457.08659 14.17323,0 164.40946,0 0,240.94489 147.40158,0 0,70.86615 28.34645,14.17322 43.93701,-49.6063 26.92914,0"
+ d="m 524.40946,457.08659 14.17323,0 164.40946,0 0,240.94489 147.40158,0 0,80.78741 28.34645,4.25196 43.93701,-49.6063 26.92914,0"
style="fill:none;fill-rule:evenodd;stroke:#008607;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" />
<g
id="g9148"
@@ -28783,15 +28783,15 @@
style="font-size:7.5px">8k2</tspan></text>
<path
style="fill:none;fill-rule:evenodd;stroke:#ff402b;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1"
- d="m 340.15749,811.41731 8.50394,35.43308 321.73229,0 0,-347.24411 52.44095,-56.69292 28.34645,0"
+ d="m 340.15749,811.41731 0,28.34646 8.50394,7.08662 321.73229,0 0,-347.24411 52.44095,-56.69292 28.34645,0"
id="path11024"
inkscape:connector-curvature="0"
- sodipodi:nodetypes="cccccc" />
+ sodipodi:nodetypes="ccccccc" />
<path
- sodipodi:nodetypes="cccccc"
+ sodipodi:nodetypes="ccccccc"
inkscape:connector-curvature="0"
id="path11026"
- d="m 354.33072,811.41731 5.66929,34.01575 308.97639,0 0,-347.24411 65.19685,-69.44882 87.87402,0"
+ d="m 354.33072,811.41731 0,28.34646 5.66929,5.66929 308.97639,0 0,-347.24411 65.19685,-69.44882 87.87402,0"
style="fill:none;fill-rule:evenodd;stroke:#2d2bff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" />
<text
xml:space="preserve"
@@ -28845,9 +28845,140 @@
id="tspan11107">monit</tspan></text>
<path
style="fill:none;fill-rule:evenodd;stroke:#2dff2b;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1"
- d="m 354.33072,797.24409 8.50394,46.77165 304.72441,0 0,-316.06301 12.75591,0 56.69292,0"
+ d="m 354.33072,797.24409 14.17323,42.51968 5.66929,4.25197 293.38583,0 0,-316.06301 12.75591,0 56.69292,0"
id="path11109"
inkscape:connector-curvature="0"
- sodipodi:nodetypes="cccccc" />
+ sodipodi:nodetypes="ccccccc" />
+ <g
+ transform="matrix(-1,0,0,-1,807.87404,1707.874)"
+ id="g9171">
+ <path
+ style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
+ d="m 459.21261,848.2677 17.00787,10e-6 -8.50393,12.75591 z"
+ id="path9205"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccc" />
+ <path
+ d="m 467.71654,851.02532 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168"
+ style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ id="path9207"
+ inkscape:connector-curvature="0" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path9268"
+ style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ d="m 467.71654,865.19855 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 467.71655,868.11023 c 0,-4.25197 0,-8.50393 0,-14.17322"
+ id="path9270"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ d="m 459.21261,863.85827 2.83464,-2.83465 11.33859,0 2.83464,-2.83465"
+ id="path9277"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccc" />
+ </g>
+ <g
+ id="g9279"
+ transform="matrix(-1,0,0,-1,822.04726,1707.874)">
+ <path
+ sodipodi:nodetypes="cccc"
+ inkscape:connector-curvature="0"
+ id="path9285"
+ d="m 459.21261,848.2677 17.00787,10e-6 -8.50393,12.75591 z"
+ style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path9287"
+ style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ d="m 467.71654,851.02532 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" />
+ <path
+ d="m 467.71654,865.19855 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168"
+ style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ id="path9297"
+ inkscape:connector-curvature="0" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0"
+ id="path9299"
+ d="m 467.71655,868.11023 c 0,-4.25197 0,-8.50393 0,-14.17322"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ sodipodi:nodetypes="cccc"
+ inkscape:connector-curvature="0"
+ id="path9305"
+ d="m 459.21261,863.85827 2.83464,-2.83465 11.33859,0 2.83464,-2.83465"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+ </g>
+ <g
+ transform="matrix(-1,0,0,-1,836.22049,1707.874)"
+ id="g9307">
+ <path
+ style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
+ d="m 459.21261,848.2677 17.00787,10e-6 -8.50393,12.75591 z"
+ id="path9311"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccc" />
+ <path
+ d="m 467.71654,851.02532 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168"
+ style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ id="path9317"
+ inkscape:connector-curvature="0" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path9339"
+ style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ d="m 467.71654,865.19855 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 467.71655,868.11023 c 0,-4.25197 0,-8.50393 0,-14.17322"
+ id="path9341"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ d="m 459.21261,863.85827 2.83464,-2.83465 11.33859,0 2.83464,-2.83465"
+ id="path9343"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccc" />
+ </g>
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 354.33072,853.937 0,7.79528 -4.25197,0 8.50394,0"
+ id="path9345"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccc" />
+ <path
+ sodipodi:nodetypes="cccc"
+ inkscape:connector-curvature="0"
+ id="path9347"
+ d="m 368.50395,854.29133 0,7.79528 -4.25197,0 8.50394,0"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 340.15749,854.29133 0,7.79528 -4.25197,0 8.50394,0"
+ id="path9349"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccc" />
+ <text
+ sodipodi:linespacing="125%"
+ id="text9352"
+ y="856.23157"
+ x="313.29129"
+ style="font-style:normal;font-weight:normal;font-size:7.5px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ xml:space="preserve"><tspan
+ id="tspan9354"
+ style="font-size:7.5px"
+ y="856.23157"
+ x="313.29129"
+ sodipodi:role="line">3V</tspan><tspan
+ style="font-size:7.5px"
+ y="865.60657"
+ x="313.29129"
+ sodipodi:role="line"
+ id="tspan9356">Zener</tspan></text>
</g>
</svg>
diff --git a/src/common/includes/Core/fsm.h b/src/common/includes/Core/fsm.h
index 75f1f46..94698b4 100644
--- a/src/common/includes/Core/fsm.h
+++ b/src/common/includes/Core/fsm.h
@@ -74,7 +74,6 @@ struct fsm_input_signals_t {
// All signals the FSM has to control
struct fsm_output_signals_t {
/* Signals to the repeater electronics */
- int qrp; // Place the repeater in QRP mode // TODO move out of FSM
int tx_on; // Enable TX circuitry
int modulation; // Enable repeater RX to TX modulation
diff --git a/src/common/includes/GPIO/analog.h b/src/common/includes/GPIO/analog.h
index 99404f6..54dfb5d 100644
--- a/src/common/includes/GPIO/analog.h
+++ b/src/common/includes/GPIO/analog.h
@@ -30,3 +30,8 @@ void analog_init(void);
* Returns 0.0f in case of error */
float analog_measure_12v(void);
+/* Keep an average of measurements, and decide if the repeater should enter
+ * QRP. Returns 1 if low power must be activated
+ */
+int analog_supply_too_low(void);
+
diff --git a/src/common/sourcelist.txt b/src/common/sourcelist.txt
index 0abc086..eada47f 100644
--- a/src/common/sourcelist.txt
+++ b/src/common/sourcelist.txt
@@ -1,3 +1,4 @@
+src/GPIO/analog.c
src/GPIO/usart.c
src/GPIO/temperature.c
src/GPS/gps.c
diff --git a/src/common/src/Core/main.c b/src/common/src/Core/main.c
index a30a3f6..22aca74 100644
--- a/src/common/src/Core/main.c
+++ b/src/common/src/Core/main.c
@@ -188,6 +188,7 @@ static void launcher_task(void __attribute__ ((unused))*pvParameters)
usart_debug_puts("Init done.\r\n");
+ int last_qrp = 0;
while(1) {
int i = 0;
vTaskDelay(pdMS_TO_TICKS(1000));
@@ -201,6 +202,14 @@ static void launcher_task(void __attribute__ ((unused))*pvParameters)
leds_turn_off(LED_GREEN);
}
+ const int qrp = analog_supply_too_low();
+ if (qrp != last_qrp) {
+ usart_debug("QRP should be %d\r\n", qrp);
+ last_qrp = qrp;
+
+ pio_set_qrp(qrp);
+ }
+
const float supply_voltage = analog_measure_12v();
usart_debug("12V monitor %dmV\r\n", (int32_t)(supply_voltage * 1000.0f));
}
@@ -232,10 +241,10 @@ static void detect_button_press(void __attribute__ ((unused))*pvParameters)
usart_debug_puts("Bouton bleu\r\n");
if (temperature_valid()) {
-
float temp = temperature_get();
+ int temp_decidegrees = temp * 10.0f;
- usart_debug("Temperature %f\r\n", temp);
+ usart_debug("Temperature %d.%01d\r\n", temp_decidegrees / 10, temp_decidegrees % 10);
} else {
usart_debug_puts("No temp\r\n");
@@ -434,7 +443,6 @@ static void exercise_fsm(void __attribute__ ((unused))*pvParameters)
pio_set_tx(fsm_out.tx_on);
pio_set_mod_off(!fsm_out.modulation);
- pio_set_qrp(fsm_out.qrp); // TODO move out of FSM
// Add message to CW generator only on rising edge of trigger
if (fsm_out.cw_psk31_trigger && !cw_last_trigger) {
diff --git a/src/common/src/GPIO/usart.c b/src/common/src/GPIO/usart.c
index ee7e96d..ee7ad9f 100644
--- a/src/common/src/GPIO/usart.c
+++ b/src/common/src/GPIO/usart.c
@@ -28,6 +28,7 @@
#include <inttypes.h>
#include "Core/common.h"
#include "GPIO/usart.h"
+#include "GPIO/analog.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
@@ -128,11 +129,15 @@ static void usart_clear_nmea_buffer(void) {
void usart_process_char(char c) {
if (c == 'h') {
- usart_debug_puts("help: no commands supported yet!\r\n");
- } else {
+ 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);
}
-
}
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 8b65cf8..d970238 100644
--- a/src/glutt-o-logique/analog_input.c
+++ b/src/glutt-o-logique/analog_input.c
@@ -39,7 +39,7 @@ void analog_init(void)
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(GPIOC, &GPIO_InitStructure);
+ GPIO_Init(GPIOA, &GPIO_InitStructure);
// Init ADC1 for supply measurement
ADC_CommonInitTypeDef ADC_CommonInitStruct;
@@ -78,12 +78,15 @@ float analog_measure_12v(void)
// TODO add timeout
while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
- const float raw_value = ADC_GetConversionValue(ADC1);
+ const uint16_t raw_value = ADC_GetConversionValue(ADC1);
- // Voltage divider 22k / (82k + 22k) must be inverted here
- // Also, we round to steps of 0.5
- float voltage = raw_value * (2.0f * 104.0f / 22.0f);
- voltage = roundf(voltage);
- voltage = voltage / 2.0f;
- return voltage;
+ const float adc_max_value = (1 << 12);
+ const float v_ref = 2.965f;
+
+ // Convert ADC measurement to voltage
+ float voltage = ((float)raw_value*v_ref/adc_max_value);
+
+ // Compensate resistor divider on board (see schematic)
+ return voltage * 202.0f / 22.0f;
}
+
diff --git a/src/glutt-o-logique/usart.c b/src/glutt-o-logique/usart.c
index 0b02ec5..29943e9 100644
--- a/src/glutt-o-logique/usart.c
+++ b/src/glutt-o-logique/usart.c
@@ -38,6 +38,7 @@ const uint16_t GPIOA_PIN_USART2_TX = GPIO_Pin_2;
#include "../common/includes/GPIO/usart.h"
+#define USART2_RECEIVE_ENABLE 0 // TODO something is not working
void USART2_IRQHandler(void);
void USART3_IRQHandler(void);