summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Duchon2012-04-17 22:19:53 +0200
committerFlorent Duchon2012-04-17 22:19:53 +0200
commita3aff0c8e49cb325cd61afb3085ae98027d125ae (patch)
tree6be9a654588e90674d139df03979b331abd28a29
parent11106c0c472ad7b39ef87ecbd2d8d6f87a782429 (diff)
digital/beacon: add a debug task to display periodically debug information
-rw-r--r--digital/beacon/src/debug.c30
-rw-r--r--digital/beacon/src/debug.h22
2 files changed, 45 insertions, 7 deletions
diff --git a/digital/beacon/src/debug.c b/digital/beacon/src/debug.c
index 224934fe..7d0f32cd 100644
--- a/digital/beacon/src/debug.c
+++ b/digital/beacon/src/debug.c
@@ -24,11 +24,13 @@
* }}} */
#include <stdarg.h>
#include <string.h>
+#include <appTimer.h>
#include "configuration.h"
#include "debug.h"
#include "servo.h"
HAL_UsartDescriptor_t appUsartDescriptor; // USART descriptor (required by stack)
+HAL_AppTimer_t debugTimer; // TIMER descripor used by the DEBUG task
uint8_t usartRxBuffer[APP_USART_RX_BUFFER_SIZE]; // USART Rx buffer
uint8_t usartTxBuffer[APP_USART_TX_BUFFER_SIZE]; // USART Tx buffer
@@ -102,6 +104,9 @@ void usartRXCallback(uint16_t bytesToRead)
/* Decrease servo 2 angle */
uprintf("SERVO_2 = %d\r\n",servo_angle_decrease(SERVO_2));
break;
+ case 'd':
+ debug_start_stop_task();
+ break;
/* Default */
default :
uprintf(" ?? Unknown command ??\r\n");
@@ -133,3 +138,28 @@ void uprintf(char *format, ...)
}
va_end(args);
}
+
+/* This function starts the debug task */
+void debug_start_stop_task(void)
+{
+ static bool debug_task_running = 0;
+ if(debug_task_running == 0)
+ {
+ debugTimer.interval = DEBUG_TASK_PERIOD;
+ debugTimer.mode = TIMER_REPEAT_MODE;
+ debugTimer.callback = debug_task;
+ HAL_StartAppTimer(&debugTimer);
+ debug_task_running = 1;
+ }
+ else
+ {
+ HAL_StopAppTimer(&debugTimer);
+ debug_task_running = 0;
+ }
+}
+
+/* Debug task callback */
+void debug_task(void)
+{
+ uprintf("------------------------- debug TASK -------------------------\r\n");
+}
diff --git a/digital/beacon/src/debug.h b/digital/beacon/src/debug.h
index 6ad1e074..3110e07f 100644
--- a/digital/beacon/src/debug.h
+++ b/digital/beacon/src/debug.h
@@ -28,13 +28,13 @@
#include <stdio.h>
#include "configuration.h"
-#define OPEN_USART HAL_OpenUsart
-#define CLOSE_USART HAL_CloseUsart
-#define WRITE_USART HAL_WriteUsart
-#define READ_USART HAL_ReadUsart
-#define USART_CHANNEL APP_USART_CHANNEL
-
-
+#define OPEN_USART HAL_OpenUsart
+#define CLOSE_USART HAL_CloseUsart
+#define WRITE_USART HAL_WriteUsart
+#define READ_USART HAL_ReadUsart
+#define USART_CHANNEL APP_USART_CHANNEL
+#define DEBUG_TASK_PERIOD 700L
+
// #define DEBUG_POSITION_ENABLE
// #define DEBUG_UPDATE_ENABLE
// #define DEBUG_RECOVERY_ENABLE
@@ -90,6 +90,7 @@ typedef enum
EMPTY,
FILLED
} TUSART_buffer_level;
+
/* This function initializes the USART interface for debugging on avr */
void initSerialInterface(void);
@@ -101,4 +102,11 @@ void usartRXCallback(uint16_t bytesToRead);
/* This function sends data string via the USART interface */
void uprintf(char *format, ...);
+
+/* This function starts the debug task */
+void debug_start_stop_task(void);
+
+/* Debug task callback */
+void debug_task(void);
+
#endif