APS Lab
/
STM32F4_SmartMesh_QSL
SmartMesh QSL for STM32F4 version
Fork of COG-AD4050_QSL by
Revision 1:b909b8399252, committed 2018-07-12
- Comitter:
- APS_Lab
- Date:
- Thu Jul 12 09:19:12 2018 +0000
- Parent:
- 0:8ca1e814a851
- Commit message:
- SmartMesh for STM32F4 version
Changed in this revision
diff -r 8ca1e814a851 -r b909b8399252 ADXL362.lib --- a/ADXL362.lib Wed May 02 09:26:10 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/rmcwilliam101/code/ADXL362/#d9853774f233
diff -r 8ca1e814a851 -r b909b8399252 dn_uart.cpp --- a/dn_uart.cpp Wed May 02 09:26:10 2018 +0000 +++ b/dn_uart.cpp Thu Jul 12 09:19:12 2018 +0000 @@ -14,9 +14,9 @@ //=========================== defines ========================================= -// Set correct pins for external UART on your board (USART1 for NUCLEO-L053R8) -#define UART_MOTE_TX USBTX -#define UART_MOTE_RX USBRX +// Set correct pins for external UART on your board (USART1 for NUCLEO-F411) +#define UART_MOTE_TX PA_9 +#define UART_MOTE_RX PA_10 //=========================== variables =======================================
diff -r 8ca1e814a851 -r b909b8399252 main.cpp --- a/main.cpp Wed May 02 09:26:10 2018 +0000 +++ b/main.cpp Thu Jul 12 09:19:12 2018 +0000 @@ -13,7 +13,7 @@ #include "dn_debug.h" // Included to borrow debug macros #include "dn_endianness.h" // Included to borrow array copying #include "dn_time.h" // Included to borrow sleep function -#include "ADXL362.h" +//#include "ADXL362.h" #define NETID 0 // Factory default value used if zero (1229) #define JOINKEY NULL // Factory default value used if NULL (44 55 53 54 4E 45 54 57 4F 52 4B 53 52 4F 43 4B) @@ -23,22 +23,22 @@ #define DATA_PERIOD_MS 500 // Should be longer than (or equal to) bandwidth // We can use debug macros from dn_debug, as stdio defaults to this serial -//Serial serialDebug(USBTX1, USBRX1); +Serial serialDebug(USBTX, USBRX); #define log_info serialDebug.printf // LED2 is the green LED on the NUCLEO-L053R8; might change for other boards DigitalOut myled(LED1); DigitalOut status(LED2); -ADXL362 Acc(P1_07, P1_08, P1_06, P1_10); +//ADXL362 Acc(P1_07, P1_08, P1_06, P1_10); static uint16_t randomWalk(void); static void parsePayload(const uint8_t *payload, uint8_t size); -void init_acc(void) -{ - Acc.init_spi(); - Acc.init_adxl362(); -} +//void init_acc(void) +//{ +// Acc.init_spi(); +// Acc.init_adxl362(); +//} int main() { @@ -46,7 +46,7 @@ uint8_t inboxBuf[DN_DEFAULT_PAYLOAD_SIZE_LIMIT]; uint8_t bytesRead; uint8_t i,e; - int8_t x0, y0, z0; + //int8_t x0, y0, z0; myled=1; status=1; @@ -61,14 +61,15 @@ myled=1; status=1; - init_acc(); + //init_acc(); // Configure SysTick for timing millisStart(); // Set PC debug serial baudrate - //serialDebug.baud(115200); + serialDebug.baud(115200); + serialDebug.printf("STM32F4 SmartMesh Demo\n"); - //log_info("Initializing..."); + log_info("Initializing..."); dn_qsl_init(); // Flash LED to indicate start-up complete @@ -82,25 +83,25 @@ while(TRUE) { if (dn_qsl_isConnected()) { - Acc.ACC_GetXYZ8(&x0, &y0, &z0); - payload[0]=x0; - payload[1]=y0; - payload[2]=z0; - //uint16_t val = randomWalk(); + //Acc.ACC_GetXYZ8(&x0, &y0, &z0); + //payload[0]=x0; + //payload[1]=y0; + //payload[2]=z0; + uint16_t val = randomWalk(); static uint8_t count = 0; myled = 1; // Turn off LED during send/read status = 0; - //dn_write_uint16_t(payload, val); - payload[3] = count; + dn_write_uint16_t(payload, val); + payload[0] = count; if (dn_qsl_send(payload, sizeof (payload), DEST_PORT)) { - //log_info("Sent message nr %u: %u", count, val); + log_info("Sent message nr %u: %u", count, val); count++; status=1; } else { - //log_info("Send failed"); + log_info("Send failed"); status=0; } @@ -114,7 +115,7 @@ dn_sleep_ms(DATA_PERIOD_MS); } else { - //log_info("Connecting..."); + log_info("Connecting..."); myled = 1; // Not connected; turn off LED if (dn_qsl_connect(NETID, JOINKEY, SRC_PORT, BANDWIDTH_MS)) { @@ -122,7 +123,7 @@ status=1;//log_info("Connected to network"); } else { - //log_info("Failed to connect"); + log_info("Failed to connect"); } } status=0; @@ -165,8 +166,8 @@ for (i = 0; i < size; i++) { msg[i] = payload[i]; - //log_info("\tByte# %03u: %#.2x (%u)", i, payload[i], payload[i]); + log_info("\tByte# %03u: %#.2x (%u)", i, payload[i], payload[i]); } msg[size] = '\0'; - //log_info("\tMessage: %s", msg); + log_info("\tMessage: %s", msg); }
diff -r 8ca1e814a851 -r b909b8399252 mbed-os.lib --- a/mbed-os.lib Wed May 02 09:26:10 2018 +0000 +++ b/mbed-os.lib Thu Jul 12 09:19:12 2018 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#f9ee4e849f8cbd64f1ec5fdd4ad256585a208360 +https://github.com/ARMmbed/mbed-os/#35fa909641fedcad9bbe0c7300d4ccdf15a2b71a
diff -r 8ca1e814a851 -r b909b8399252 sm_qsl/dn_debug.h --- a/sm_qsl/dn_debug.h Wed May 02 09:26:10 2018 +0000 +++ b/sm_qsl/dn_debug.h Thu Jul 12 09:19:12 2018 +0000 @@ -19,9 +19,9 @@ /* Comment out this define to include log messages */ #define NLOG 0 -#if 0 +#if 1 #ifdef NDEBUG -#define debug(M, ...) do {}while(0) +//#define debug(M, ...) do {}while(0) #else #define debug(M, ...) fprintf(stderr, "DEBUG %s:%d: " M "\r\n", __FILE__, __LINE__, ##__VA_ARGS__) #endif @@ -29,9 +29,9 @@ #define clean_errno() (errno == 0 ? "None" : strerror(errno)) #ifdef NLOG -#define log_err(M, ...) do {}while(0) -#define log_warn(M, ...) do {}while(0) -#define log_info(M, ...) do {}while(0) +//#define log_err(M, ...) do {}while(0) +//#define log_warn(M, ...) do {}while(0) +//#define log_info(M, ...) do {}while(0) #else #define log_err(M, ...) fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\r\n", __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__) #define log_warn(M, ...) fprintf(stderr, "[WARN] (%s:%d: errno: %s) " M "\r\n", __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__)