aboutsummaryrefslogtreecommitdiffstats
path: root/src/fsm
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-01-24 19:36:14 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-01-24 19:36:14 +0100
commit1ad000c91896483a06d0450f882cbdae8671068f (patch)
tree56f19cf61017401b40a42cbd127ac8e34b7926bc /src/fsm
parent0f3cc45ca2e90ad7c7a6c5695b52c49844b35931 (diff)
downloadglutte-o-matic-1ad000c91896483a06d0450f882cbdae8671068f.tar.gz
glutte-o-matic-1ad000c91896483a06d0450f882cbdae8671068f.tar.bz2
glutte-o-matic-1ad000c91896483a06d0450f882cbdae8671068f.zip
Nicer debug prints
Diffstat (limited to 'src/fsm')
-rw-r--r--src/fsm/i2c.c3
-rw-r--r--src/fsm/main.c46
-rw-r--r--src/fsm/pio.txt12
-rw-r--r--src/fsm/usart.c6
4 files changed, 40 insertions, 27 deletions
diff --git a/src/fsm/i2c.c b/src/fsm/i2c.c
index 556b55f..af1eb34 100644
--- a/src/fsm/i2c.c
+++ b/src/fsm/i2c.c
@@ -31,6 +31,7 @@
#include "FreeRTOSConfig.h"
#include "task.h"
#include "semphr.h"
+#include "usart.h"
/* I2C 1 on PB9 and PB6
* See pio.txt for PIO allocation details */
@@ -62,6 +63,8 @@ static void i2c_device_init(void);
*/
static void i2c_recover_from_lockup(void)
{
+ usart_debug_puts("ERROR: I2C lockup\r\n");
+
I2C_SoftwareResetCmd(I2Cx, ENABLE);
// Configure I2C SCL and SDA pins.
diff --git a/src/fsm/main.c b/src/fsm/main.c
index 54fc485..bf1c541 100644
--- a/src/fsm/main.c
+++ b/src/fsm/main.c
@@ -72,7 +72,7 @@ void vApplicationStackOverflowHook( TaskHandle_t xTask,
int main(void) {
init();
usart_init();
- usart_debug_puts("glutt-o-matique version " GIT_VERSION "\r\n");
+ usart_debug_puts("******* glutt-o-matique version " GIT_VERSION " *******\r\n");
TaskHandle_t task_handle;
xTaskCreate(
@@ -98,17 +98,22 @@ int main(void) {
// already running when calling the init functions.
static void launcher_task(void *pvParameters)
{
- usart_debug_puts("1");
+ usart_debug_puts("CW init\r\n");
cw_psk31_init(16000);
- usart_debug_puts("2");
+
+ usart_debug_puts("PIO init\r\n");
pio_init();
- usart_debug_puts("3");
+
+ usart_debug_puts("I2C init\r\n");
i2c_init();
- usart_debug_puts("4");
+
+ usart_debug_puts("common init\r\n");
common_init();
- usart_debug_puts("5");
+
+ usart_debug_puts("GPS init\r\n");
gps_init();
- usart_debug_puts("6");
+
+ usart_debug_puts("TaskButton init\r\n");
TaskHandle_t task_handle;
xTaskCreate(
@@ -123,7 +128,7 @@ static void launcher_task(void *pvParameters)
trigger_fault(FAULT_SOURCE_MAIN);
}
- usart_debug_puts("8");
+ usart_debug_puts("TaskFSM init\r\n");
xTaskCreate(
exercise_fsm,
@@ -137,7 +142,7 @@ static void launcher_task(void *pvParameters)
trigger_fault(FAULT_SOURCE_MAIN);
}
- usart_debug_puts("9");
+ usart_debug_puts("TaskGPS init\r\n");
xTaskCreate(
gps_monit_task,
@@ -151,16 +156,17 @@ static void launcher_task(void *pvParameters)
trigger_fault(FAULT_SOURCE_MAIN);
}
- usart_debug_puts("A");
+ usart_debug_puts("Audio init\r\n");
InitializeAudio(Audio16000HzSettings);
- usart_debug_puts("B");
+
+ usart_debug_puts("Audio set volume\r\n");
SetAudioVolume(210);
- usart_debug_puts("C");
+ usart_debug_puts("Audio set callback\r\n");
PlayAudioWithCallback(audio_callback, NULL);
- usart_debug_puts("D\r\n");
+ usart_debug_puts("Init done.\r\n");
/* We are done now, suspend this task
* With FreeDOS' heap_1.c, we cannot delete it.
@@ -229,12 +235,13 @@ static void audio_callback(void* context, int select_buffer)
ProvideAudioBufferWithoutBlocking(samples, samples_len);
}
-
static struct gps_time_s gps_time;
static void gps_monit_task(void *pvParameters)
{
GPIO_SetBits(GPIOD, GPIOD_BOARD_LED_BLUE);
+ int t_gps_print_latch = 0;
+
while (1) {
if (gps_locked()) {
@@ -247,10 +254,15 @@ static void gps_monit_task(void *pvParameters)
GPIO_ResetBits(GPIOD, GPIOD_BOARD_LED_BLUE);
}
- if (gps_time.sec % 30 == 0) {
- usart_debug("T_GPS %04d-%02d-%02d %02d:%02d\r\n",
+ if (gps_time.sec % 30 == 0 && t_gps_print_latch == 0) {
+ usart_debug("T_GPS %04d-%02d-%02d %02d:%02d:%02d\r\n",
gps_time.year, gps_time.month, gps_time.day,
- gps_time.hour, gps_time.min);
+ gps_time.hour, gps_time.min, gps_time.sec);
+
+ t_gps_print_latch = 1;
+ }
+ if (gps_time.sec % 30 > 0) {
+ t_gps_print_latch = 0;
}
}
diff --git a/src/fsm/pio.txt b/src/fsm/pio.txt
index 64f5b04..cd29cd1 100644
--- a/src/fsm/pio.txt
+++ b/src/fsm/pio.txt
@@ -7,13 +7,13 @@ Test logic
u-blox NEO-M8N GPS module connection
------------------------------------
-Yellow out UART TX to GPS RX PD8
-Orange in UART RX to GPS TX PD9
+Yellow out UART3 TX to GPS RX PD8
+Orange in UART3 RX to GPS TX PD9
Debug USART
-----------
-- out UART TX to PC RX PA2
-- in UART RX to PC TX PA3
+- out UART2 TX to PC RX PA2
+- in UART2 RX to PC TX PA3
For the little test board with the 3 LEDs and switches
------------------------------------------------------
@@ -34,8 +34,8 @@ I2C to Audio Codec
- - I2S3 CK PC10
- - I2S3 SD PC12
- - I2S3 WS PA4
-- i/o SDA PB9
-- i/o SCL PB6
+- i/o I2C1 SDA PB9
+- i/o I2C1 SCL PB6
STM32DISCOVERY onboard things
-----------------------------
diff --git a/src/fsm/usart.c b/src/fsm/usart.c
index 31c112e..70b16ba 100644
--- a/src/fsm/usart.c
+++ b/src/fsm/usart.c
@@ -84,7 +84,7 @@ void usart_init()
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 6;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
+ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
@@ -101,8 +101,6 @@ void usart_gps_init()
while(1); /* fatal error */
}
- return;
-
// ============== GPS USART ===========
// Setup GPIO D and connect to USART 3
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
@@ -136,7 +134,7 @@ void usart_gps_init()
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 6;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
+ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);