From 5bae4f841d9fe1e2d6d2fbc7f3339e1fb74586fc Mon Sep 17 00:00:00 2001 From: Oliver Hahm <oleg@hobbykeller.org> Date: Mon, 24 Jun 2013 22:12:57 +0200 Subject: [PATCH] added one-time-initialization guard to transceiver --- core/include/flags.h | 8 ++++---- sys/transceiver/transceiver.c | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/core/include/flags.h b/core/include/flags.h index a45027a48a..f2185946d0 100644 --- a/core/include/flags.h +++ b/core/include/flags.h @@ -16,10 +16,10 @@ #ifndef _FLAGS_H #define _FLAGS_H -#define CREATE_SLEEPING 1 -#define AUTO_FREE 2 -#define CREATE_WOUT_YIELD 4 -#define CREATE_STACKTEST 8 +#define CREATE_SLEEPING (1) +#define AUTO_FREE (2) +#define CREATE_WOUT_YIELD (4) +#define CREATE_STACKTEST (8) /** * @} diff --git a/sys/transceiver/transceiver.c b/sys/transceiver/transceiver.c index 0bef5158b6..c46f8b63e4 100644 --- a/sys/transceiver/transceiver.c +++ b/sys/transceiver/transceiver.c @@ -62,7 +62,7 @@ msg_t msg_buffer[TRANSCEIVER_MSG_BUFFER_SIZE]; uint32_t response; ///< response bytes for messages to upper layer threads -int transceiver_pid; ///< the transceiver thread's pid +int transceiver_pid = -1; ///< the transceiver thread's pid static volatile uint8_t rx_buffer_pos = 0; static volatile uint8_t transceiver_buffer_pos = 0; @@ -107,6 +107,11 @@ void transceiver_init(transceiver_type_t t) { uint8_t i; + if (transceiver_pid >= 0) { + /* do not re-initialize an already running transceiver */ + return; + } + /* Initializing transceiver buffer and data buffer */ memset(transceiver_buffer, 0, TRANSCEIVER_BUFFER_SIZE); memset(data_buffer, 0, TRANSCEIVER_BUFFER_SIZE * PAYLOAD_SIZE); -- GitLab