aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/includes/GPIO/temperature.h (renamed from src/fsm/temperature.h)10
-rw-r--r--src/common/src/Core/main.c11
-rw-r--r--src/common/src/GPIO/temperature.c62
-rw-r--r--src/simulator/src/GPIO/temperature.c16
-rw-r--r--src/simulator/src/Gui/gui.c23
-rw-r--r--src/stm32f/Makefile2
-rw-r--r--src/stm32f/includes/Core/delay.h (renamed from src/fsm/delay.h)0
-rw-r--r--src/stm32f/src/Core/delay.c (renamed from src/fsm/delay.c)0
-rw-r--r--src/stm32f/src/GPIO/temperature.c (renamed from src/fsm/temperature.c)65
l---------src/stm32f/src/GPIO/tm_stm32f4_ds18b20.c1
l---------src/stm32f/src/GPIO/tm_stm32f4_ds18b20.h1
l---------src/stm32f/src/GPIO/tm_stm32f4_onewire.c1
l---------src/stm32f/src/GPIO/tm_stm32f4_onewire.h1
l---------src/stm32f/tm_stm32f4_ds18b20.c1
l---------src/stm32f/tm_stm32f4_ds18b20.h1
l---------src/stm32f/tm_stm32f4_onewire.c1
l---------src/stm32f/tm_stm32f4_onewire.h1
17 files changed, 120 insertions, 77 deletions
diff --git a/src/fsm/temperature.h b/src/common/includes/GPIO/temperature.h
index 56145f2..a054fab 100644
--- a/src/fsm/temperature.h
+++ b/src/common/includes/GPIO/temperature.h
@@ -27,16 +27,8 @@
#ifndef __TEMPERATURE_H
#define __TEMPERATURE_H
-/* Setup DS18B20 and report temperature */
-/* On wire connection: PA1
- */
-
-
-#define TEMPERATURE_ONEWIRE_PIN GPIO_Pin_1
-
-
-// Setup communication and GPS receiver
+// Setup communication and temperature
void temperature_init();
// Return 1 if the temperature is valid
diff --git a/src/common/src/Core/main.c b/src/common/src/Core/main.c
index 7760d6c..f1d8e61 100644
--- a/src/common/src/Core/main.c
+++ b/src/common/src/Core/main.c
@@ -43,7 +43,7 @@
#include "Core/common.h"
#include "GPIO/usart.h"
/* #include "delay.h" */
-/* #include "temperature.h" */
+#include "GPIO/temperature.h"
#include "GPIO/leds.h"
#include "vc.h"
@@ -102,8 +102,6 @@ int main(void) {
}
vTaskStartScheduler();
- /* pthread_t pth; */
- /* pthread_create(&pth, NULL, threadscheduler, "processing..."); */
/* HALT */
while(1);
@@ -149,9 +147,9 @@ static void launcher_task(void *pvParameters)
usart_debug_puts("GPS init\r\n");
gps_init();
- /* usart_debug_puts("DS18B20 init\r\n"); */
- /* temperature_init(); */
- /* */
+ usart_debug_puts("DS18B20 init\r\n");
+ temperature_init();
+
/* usart_debug_puts("TaskButton init\r\n"); */
TaskHandle_t task_handle;
@@ -345,6 +343,7 @@ static void gps_monit_task(void *pvParameters) {
time.tm_mon, time.tm_mday,
time.tm_hour, time.tm_min, time.tm_sec);
+
t_gps_print_latch = 1;
}
if (gps_time.tm_sec % 30 > 0) {
diff --git a/src/common/src/GPIO/temperature.c b/src/common/src/GPIO/temperature.c
new file mode 100644
index 0000000..21cb9f8
--- /dev/null
+++ b/src/common/src/GPIO/temperature.c
@@ -0,0 +1,62 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Matthias P. Braendli, Maximilien Cuony
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+*/
+
+#include "FreeRTOS.h"
+#include "FreeRTOSConfig.h"
+#include "task.h"
+#include "Core/common.h"
+#include "GPIO/temperature.h"
+
+
+float _temperature_last_value;
+int _temperature_valid;
+
+
+static void temperature_task(void *pvParameters);
+
+
+void temperature_init() {
+
+ xTaskCreate(
+ temperature_task,
+ "TaskTemperature",
+ 4*configMINIMAL_STACK_SIZE,
+ (void*) NULL,
+ tskIDLE_PRIORITY + 2UL,
+ NULL);
+}
+
+// Return the current temperature
+float temperature_get() {
+ if (_temperature_valid) {
+ return _temperature_last_value;
+ } else {
+ return 0.0f;
+ }
+}
+
+// Return 1 if the temperature is valid
+int temperature_valid() {
+ return _temperature_valid;
+}
diff --git a/src/simulator/src/GPIO/temperature.c b/src/simulator/src/GPIO/temperature.c
new file mode 100644
index 0000000..6befb2a
--- /dev/null
+++ b/src/simulator/src/GPIO/temperature.c
@@ -0,0 +1,16 @@
+#include "../../../common/src/GPIO/temperature.c"
+
+extern int gui_temperature_valid;
+extern float gui_temperature;
+
+static void temperature_task(void *pvParameters) {
+
+ while (1) {
+
+ _temperature_last_value = gui_temperature;
+ _temperature_valid = gui_temperature_valid;
+
+ vTaskDelay(1000 / portTICK_PERIOD_MS);
+
+ }
+}
diff --git a/src/simulator/src/Gui/gui.c b/src/simulator/src/Gui/gui.c
index cd7e004..2fcebe3 100644
--- a/src/simulator/src/Gui/gui.c
+++ b/src/simulator/src/Gui/gui.c
@@ -94,6 +94,13 @@ char gui_audio_on = 0;
char gui_cw_text[4096];
+/**
+ * Temperature
+ **/
+int gui_temperature_valid = 1;
+float gui_temperature = 25.0;
+
+
struct XWindow {
Display *dpy;
Window win;
@@ -541,6 +548,22 @@ int main_gui() {
}
nk_end(ctx);
+ if (nk_begin(ctx, &layout, "Temperature", nk_rect(670, 50, 200, 200), NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE)) {
+
+ nk_layout_row_dynamic(ctx, 25, 1);
+
+ nk_checkbox_label(ctx, "Valid temperature", &gui_temperature_valid);
+
+ if (gui_temperature_valid) {
+
+ nk_layout_row_dynamic(ctx, 25, 2);
+
+ nk_label(ctx, "Temperature", NK_TEXT_LEFT);
+ nk_property_float(ctx, "°C", -20.0f, &gui_temperature, 50.0f, 0.1f, 0.5f);
+ }
+
+ }
+ nk_end(ctx);
}
/* if (nk_window_is_closed(ctx, "Demo")) break; */
diff --git a/src/stm32f/Makefile b/src/stm32f/Makefile
index a26cdbd..29bf265 100644
--- a/src/stm32f/Makefile
+++ b/src/stm32f/Makefile
@@ -20,7 +20,7 @@ ASOURCES=$(shell find -L $(SRCDIR) -name '*.s')
CSOURCES+=$(shell find -L $(SRCDIR) -name '*.c')
# Find header directories
INC=$(shell find -L . -name '*.h' -exec dirname {} \; | uniq)
-INCLUDES=$(INC:%=-I%) -I ../common/includes/
+INCLUDES=$(INC:%=-I%) -I ../common/includes/ -I ./includes/
# Create object list
OBJECTS=$(ASOURCES:%.s=%.o)
OBJECTS+=$(CSOURCES:%.c=obj/%.o)
diff --git a/src/fsm/delay.h b/src/stm32f/includes/Core/delay.h
index 73ed669..73ed669 100644
--- a/src/fsm/delay.h
+++ b/src/stm32f/includes/Core/delay.h
diff --git a/src/fsm/delay.c b/src/stm32f/src/Core/delay.c
index 8c9d24c..8c9d24c 100644
--- a/src/fsm/delay.c
+++ b/src/stm32f/src/Core/delay.c
diff --git a/src/fsm/temperature.c b/src/stm32f/src/GPIO/temperature.c
index 84c537e..780a019 100644
--- a/src/fsm/temperature.c
+++ b/src/stm32f/src/GPIO/temperature.c
@@ -1,47 +1,24 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2016 Matthias P. Braendli, Maximilien Cuony
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
-*/
+/* On wire connection: PA1
+ */
+
+#define TEMPERATURE_ONEWIRE_PIN GPIO_Pin_1
#include "stm32f4xx_conf.h"
#include "stm32f4xx.h"
-#include "FreeRTOS.h"
-#include "FreeRTOSConfig.h"
-#include "task.h"
-#include "common.h"
+
#include "tm_stm32f4_ds18b20.h"
#include "tm_stm32f4_onewire.h"
-#include "temperature.h"
-#include "delay.h"
+#include "Core/delay.h"
-float _temperature_last_value;
-int _temperature_valid;
+#include "../../../common/src/GPIO/temperature.c"
const TickType_t _temperature_delay = 60000 / portTICK_PERIOD_MS; // 60s
static TM_OneWire_t tm_onewire;
+
void ds18b20_init() {
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
@@ -96,7 +73,6 @@ int ds18b20_gettemp(float *temperature) {
return status;
}
-
static void temperature_task(void *pvParameters) {
while (1) {
@@ -115,28 +91,3 @@ static void temperature_task(void *pvParameters) {
}
}
-
-void temperature_init() {
-
- xTaskCreate(
- temperature_task,
- "TaskTemperature",
- 4*configMINIMAL_STACK_SIZE,
- (void*) NULL,
- tskIDLE_PRIORITY + 2UL,
- NULL);
-}
-
-// Return the current temperature
-float temperature_get() {
- if (_temperature_valid) {
- return _temperature_last_value;
- } else {
- return 0.0f;
- }
-}
-
-// Return 1 if the temperature is valid
-int temperature_valid() {
- return _temperature_valid;
-}
diff --git a/src/stm32f/src/GPIO/tm_stm32f4_ds18b20.c b/src/stm32f/src/GPIO/tm_stm32f4_ds18b20.c
new file mode 120000
index 0000000..ffa5c2a
--- /dev/null
+++ b/src/stm32f/src/GPIO/tm_stm32f4_ds18b20.c
@@ -0,0 +1 @@
+../../../ds18b20/tm_stm32f4_ds18b20.c \ No newline at end of file
diff --git a/src/stm32f/src/GPIO/tm_stm32f4_ds18b20.h b/src/stm32f/src/GPIO/tm_stm32f4_ds18b20.h
new file mode 120000
index 0000000..51c9ece
--- /dev/null
+++ b/src/stm32f/src/GPIO/tm_stm32f4_ds18b20.h
@@ -0,0 +1 @@
+../../../ds18b20/tm_stm32f4_ds18b20.h \ No newline at end of file
diff --git a/src/stm32f/src/GPIO/tm_stm32f4_onewire.c b/src/stm32f/src/GPIO/tm_stm32f4_onewire.c
new file mode 120000
index 0000000..241eefa
--- /dev/null
+++ b/src/stm32f/src/GPIO/tm_stm32f4_onewire.c
@@ -0,0 +1 @@
+../../../ds18b20/tm_stm32f4_onewire.c \ No newline at end of file
diff --git a/src/stm32f/src/GPIO/tm_stm32f4_onewire.h b/src/stm32f/src/GPIO/tm_stm32f4_onewire.h
new file mode 120000
index 0000000..81ebf8e
--- /dev/null
+++ b/src/stm32f/src/GPIO/tm_stm32f4_onewire.h
@@ -0,0 +1 @@
+../../../ds18b20/tm_stm32f4_onewire.h \ No newline at end of file
diff --git a/src/stm32f/tm_stm32f4_ds18b20.c b/src/stm32f/tm_stm32f4_ds18b20.c
deleted file mode 120000
index 1dca5f5..0000000
--- a/src/stm32f/tm_stm32f4_ds18b20.c
+++ /dev/null
@@ -1 +0,0 @@
-../ds18b20/tm_stm32f4_ds18b20.c \ No newline at end of file
diff --git a/src/stm32f/tm_stm32f4_ds18b20.h b/src/stm32f/tm_stm32f4_ds18b20.h
deleted file mode 120000
index 6b8bae8..0000000
--- a/src/stm32f/tm_stm32f4_ds18b20.h
+++ /dev/null
@@ -1 +0,0 @@
-../ds18b20/tm_stm32f4_ds18b20.h \ No newline at end of file
diff --git a/src/stm32f/tm_stm32f4_onewire.c b/src/stm32f/tm_stm32f4_onewire.c
deleted file mode 120000
index 21e6c82..0000000
--- a/src/stm32f/tm_stm32f4_onewire.c
+++ /dev/null
@@ -1 +0,0 @@
-../ds18b20/tm_stm32f4_onewire.c \ No newline at end of file
diff --git a/src/stm32f/tm_stm32f4_onewire.h b/src/stm32f/tm_stm32f4_onewire.h
deleted file mode 120000
index 1779648..0000000
--- a/src/stm32f/tm_stm32f4_onewire.h
+++ /dev/null
@@ -1 +0,0 @@
-../ds18b20/tm_stm32f4_onewire.h \ No newline at end of file