From f44d4427e1f0c47713a49c7b306150a048f0fb3b Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Thu, 27 Dec 2012 16:27:23 +0100 Subject: digital/beacon: use common uprintf function --- digital/beacon/src/Makefile | 3 ++- digital/beacon/src/calibration.c | 2 +- digital/beacon/src/codewheel.c | 2 +- digital/beacon/src/debug_avr.c | 58 +++------------------------------------- digital/beacon/src/debug_avr.h | 23 ---------------- digital/beacon/src/laser.c | 2 +- digital/beacon/src/main_avr.c | 2 +- digital/beacon/src/motor.c | 2 +- digital/beacon/src/network.c | 2 +- digital/beacon/src/servo.c | 2 +- digital/beacon/src/trust.c | 2 +- digital/beacon/src/update.c | 2 +- 12 files changed, 15 insertions(+), 87 deletions(-) (limited to 'digital') diff --git a/digital/beacon/src/Makefile b/digital/beacon/src/Makefile index b198d974..e35b0b6b 100644 --- a/digital/beacon/src/Makefile +++ b/digital/beacon/src/Makefile @@ -16,6 +16,7 @@ include $(BASE)/make/Makefile.gen BITCLOUD_BASE = $(APB_REPO_PATH)/digital/zigbit/bitcloud BITCLOUD_MAKEFILE = $(BITCLOUD_BASE)/makefiles BITCLOUD_STACK = $(BITCLOUD_BASE)/stack +BITCLOUD_COMMON_SOURCES = $(APB_REPO_PATH)/digital/zigbit/common PROJECT_BASE = $(APB_REPO_PATH)/digital/beacon/src CONFIG_NAME = All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc @@ -34,7 +35,7 @@ simu:host avr: for count in $(NUMBER); do\ $(MAKE) -C $(BITCLOUD_MAKEFILE) -f Makefile_$(CONFIG_NAME) clean BITCLOUD_PATH=$(BITCLOUD_STACK);\ - $(MAKE) -C $(BITCLOUD_MAKEFILE) -f Makefile_$(CONFIG_NAME) all APP_NAME=beacon_$$count BITCLOUD_PATH=$(BITCLOUD_STACK) APB_AVR_PATH=$(BASE) PROJECT_BASE=$(PROJECT_BASE) LOL_NUMBER=$$count;\ + $(MAKE) -C $(BITCLOUD_MAKEFILE) -f Makefile_$(CONFIG_NAME) all APP_NAME=beacon_$$count BITCLOUD_PATH=$(BITCLOUD_STACK) APB_AVR_PATH=$(BASE) PROJECT_BASE=$(PROJECT_BASE) BITCLOUD_COMMON_SOURCES=$(BITCLOUD_COMMON_SOURCES) LOL_NUMBER=$$count;\ done;\ flash0: diff --git a/digital/beacon/src/calibration.c b/digital/beacon/src/calibration.c index a6fc6c00..481e96c3 100644 --- a/digital/beacon/src/calibration.c +++ b/digital/beacon/src/calibration.c @@ -24,7 +24,7 @@ * }}} */ #include -#include "debug_avr.h" +#include "print.h" #include "calibration.h" #include "servo.h" #include "motor.h" diff --git a/digital/beacon/src/codewheel.c b/digital/beacon/src/codewheel.c index 63036c98..74c8eb2e 100644 --- a/digital/beacon/src/codewheel.c +++ b/digital/beacon/src/codewheel.c @@ -26,7 +26,7 @@ #include #include #include -#include "debug_avr.h" +#include "print.h" #include "codewheel.h" #include "laser.h" #include "network.h" diff --git a/digital/beacon/src/debug_avr.c b/digital/beacon/src/debug_avr.c index 475068e8..0acb5098 100644 --- a/digital/beacon/src/debug_avr.c +++ b/digital/beacon/src/debug_avr.c @@ -26,6 +26,7 @@ #include #include #include "configuration.h" +#include "print.h" #include "calibration.h" #include "debug_avr.h" #include "servo.h" @@ -36,17 +37,11 @@ #include "misc.h" #include "position.h" -static HAL_UsartDescriptor_t appUsartDescriptor; // USART descriptor (required by stack) +HAL_UsartDescriptor_t appUsartDescriptor; // USART descriptor (required by stack) static HAL_AppTimer_t debugTimer; // TIMER descripor used by the DEBUG task -static uint8_t usartRxBuffer[APP_USART_RX_BUFFER_SIZE]; // USART Rx buffer -static uint8_t usartTxBuffer[APP_USART_TX_BUFFER_SIZE]; // USART Tx buffer - -static TUSART_buffer_level TXbuffer_level = EMPTY; // TX buffer state -static TUSART_bus_state TXbus_state = FREE; // TX line state - -static uint16_t start_offset = 0; // Start offset for TX buffer -static uint16_t end_offset = 0; // Stop offset for TX buffer +uint8_t usartRxBuffer[APP_USART_RX_BUFFER_SIZE]; // USART Rx buffer +uint8_t usartTxBuffer[APP_USART_TX_BUFFER_SIZE]; // USART Tx buffer uint8_t debug_network = 0; uint8_t debug_network_enable = 0; @@ -70,25 +65,6 @@ uint8_t debug_network_enable = 0; OPEN_USART(&appUsartDescriptor); } -/* TX USART Callback */ -void usartTXCallback(void) -{ - /* If buffer is not empty continue to send via USART line */ - if(TXbuffer_level != EMPTY) - { - WRITE_USART(&appUsartDescriptor,usartTxBuffer+start_offset,end_offset); - TXbuffer_level = EMPTY; - } - else - { - /* Bus is free so reset variables and flags */ - memset(usartTxBuffer,0,APP_USART_TX_BUFFER_SIZE); - start_offset = 0; - end_offset = 0; - TXbus_state = FREE; - } -} - /* RX USART Callback */ void usartRXCallback(uint16_t bytesToRead) { @@ -172,32 +148,6 @@ void usartRXCallback(uint16_t bytesToRead) } } -/* This function sends data string via the USART interface */ -void uprintf(char *format, ...) -{ - va_list args; - va_start(args,format); - - if(end_offset+strlen(format)+strlen(args) < APP_USART_TX_BUFFER_SIZE) - { - vsprintf(usartTxBuffer+end_offset,format,args); - end_offset = strlen(usartTxBuffer); - - /* Check if the bus is busy */ - if(TXbus_state == FREE) - { - WRITE_USART(&appUsartDescriptor,usartTxBuffer+start_offset,end_offset); - start_offset = end_offset; - TXbus_state = BUSY; - } - else - { - TXbuffer_level = FILLED; - } - } - va_end(args); -} - /* This function starts the debug task */ void debug_start_stop_task(void) { diff --git a/digital/beacon/src/debug_avr.h b/digital/beacon/src/debug_avr.h index 36667c88..e262462c 100644 --- a/digital/beacon/src/debug_avr.h +++ b/digital/beacon/src/debug_avr.h @@ -29,37 +29,14 @@ #include #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 DEBUG_TASK_PERIOD 100L -typedef enum -{ - FREE, - BUSY -} TUSART_bus_state; - -typedef enum -{ - EMPTY, - FILLED -} TUSART_buffer_level; - /* This function initializes the USART interface for debugging on avr */ void initSerialInterface(void); -/* TX USART Callback */ -void usartTXCallback(void); - /* RX USART Callback */ 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); diff --git a/digital/beacon/src/laser.c b/digital/beacon/src/laser.c index 38183b8f..45b4fe07 100644 --- a/digital/beacon/src/laser.c +++ b/digital/beacon/src/laser.c @@ -25,7 +25,7 @@ #include #include -#include "debug_avr.h" +#include "print.h" #include "laser.h" #include "servo.h" #include "network.h" diff --git a/digital/beacon/src/main_avr.c b/digital/beacon/src/main_avr.c index b7b4996b..5a069fc3 100644 --- a/digital/beacon/src/main_avr.c +++ b/digital/beacon/src/main_avr.c @@ -29,7 +29,7 @@ #include "twi_specific.h" #include "calibration.h" #include "codewheel.h" -#include "debug_avr.h" +#include "print.h" #include "network.h" #include "position.h" #include "motor.h" diff --git a/digital/beacon/src/motor.c b/digital/beacon/src/motor.c index 55da6a21..2a54e694 100644 --- a/digital/beacon/src/motor.c +++ b/digital/beacon/src/motor.c @@ -23,7 +23,7 @@ * * }}} */ -#include "debug_avr.h" +#include "print.h" #include "motor.h" #include "codewheel.h" diff --git a/digital/beacon/src/network.c b/digital/beacon/src/network.c index 71f03cf6..010d8608 100644 --- a/digital/beacon/src/network.c +++ b/digital/beacon/src/network.c @@ -28,7 +28,7 @@ #include #include "configuration.h" #include "network.h" -#include "debug_avr.h" +#include "print.h" #include "led.h" #include "motor.h" #include "position.h" diff --git a/digital/beacon/src/servo.c b/digital/beacon/src/servo.c index 630d1b1a..13cf2986 100644 --- a/digital/beacon/src/servo.c +++ b/digital/beacon/src/servo.c @@ -26,7 +26,7 @@ #include #include #include "servo.h" -#include "debug_avr.h" +#include "print.h" servo_s servo1; servo_s servo2; diff --git a/digital/beacon/src/trust.c b/digital/beacon/src/trust.c index 49bdb043..936d0138 100644 --- a/digital/beacon/src/trust.c +++ b/digital/beacon/src/trust.c @@ -26,7 +26,7 @@ #include "position.h" #include "trust.h" #include "debug_simu.h" -#include "debug_avr.h" +#include "print.h" extern opponent_s opponent[MAX_OBSTACLE]; static HAL_AppTimer_t trustTimer; diff --git a/digital/beacon/src/update.c b/digital/beacon/src/update.c index a9d19315..9b987b77 100644 --- a/digital/beacon/src/update.c +++ b/digital/beacon/src/update.c @@ -27,7 +27,7 @@ #include "trust.h" #include "update.h" #include "debug_simu.h" -#include "debug_avr.h" +#include "print.h" /* Globals Declaration */ extern opponent_s opponent[MAX_OBSTACLE]; -- cgit v1.2.3