diff options
author | Sylvain Miermont <smiermont@semtech.com> | 2013-07-02 16:11:43 +0200 |
---|---|---|
committer | Sylvain Miermont <smiermont@semtech.com> | 2013-10-23 09:46:47 +0200 |
commit | 3357493e096fc0bd4767d1a3cc0cb7e3e52a4f53 (patch) | |
tree | e669e6fbff1ad93425b1038146f99d1a51449598 /loragw_hal/src/loragw_aux.c | |
parent | dc7420bec4bc6eefff6198825023ee73f6027c60 (diff) | |
download | lora_gateway-3357493e096fc0bd4767d1a3cc0cb7e3e52a4f53.tar.gz lora_gateway-3357493e096fc0bd4767d1a3cc0cb7e3e52a4f53.tar.bz2 lora_gateway-3357493e096fc0bd4767d1a3cc0cb7e3e52a4f53.zip |
Release Candidate 1, initial diffusion.v0.rc1
Diffstat (limited to 'loragw_hal/src/loragw_aux.c')
-rw-r--r-- | loragw_hal/src/loragw_aux.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/loragw_hal/src/loragw_aux.c b/loragw_hal/src/loragw_aux.c new file mode 100644 index 0000000..52df612 --- /dev/null +++ b/loragw_hal/src/loragw_aux.c @@ -0,0 +1,51 @@ +/* + / _____) _ | | +( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | +(______/|_____)_|_|_| \__)_____)\____)_| |_| + ©2013 Semtech-Cycleo + +Description: + Lora gateway auxiliary functions +*/ + + +/* -------------------------------------------------------------------------- */ +/* --- DEPENDANCIES --------------------------------------------------------- */ + +#include <stdio.h> /* printf fprintf */ +#include <time.h> /* clock_nanosleep */ + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE MACROS ------------------------------------------------------- */ + +#ifdef DEBUG + #define DEBUG_MSG(str) fprintf(stderr, str) + #define DEBUG_PRINTF(fmt, args...) fprintf(stderr,"%s:%d: "fmt, __FUNCTION__, __LINE__, args) +#else + #define DEBUG_MSG(str) + #define DEBUG_PRINTF(fmt, args...) +#endif + +/* -------------------------------------------------------------------------- */ +/* --- PUBLIC FUNCTIONS DEFINITION ------------------------------------------ */ + +/* This implementation is POSIX-pecific and require a fix to be compatible with C99 */ +void wait_ms(unsigned long a) { + struct timespec dly; + struct timespec rem; + + dly.tv_sec = a / 1000; + dly.tv_nsec = ((long)a % 1000) * 1000000; + + DEBUG_PRINTF("NOTE dly: %ld sec %ld ns\n", dly.tv_sec, dly.tv_nsec); + + if((dly.tv_sec > 0) || ((dly.tv_sec == 0) && (dly.tv_nsec > 100000))) { + clock_nanosleep(CLOCK_MONOTONIC, 0, &dly, &rem); + DEBUG_PRINTF("NOTE remain: %ld sec %ld ns\n", rem.tv_sec, rem.tv_nsec); + } + return; +} + +/* --- EOF ------------------------------------------------------------------ */ |