init
Dependencies: aconno_I2C Lis2dh12 WatchdogTimer
Revision 36:8e359069192b, committed 2019-01-15
- Comitter:
- pathfindr
- Date:
- Tue Jan 15 11:19:41 2019 +0000
- Parent:
- 35:d9421d57d116
- Child:
- 37:505ef618f06c
- Commit message:
- update
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/NRFuart.cpp Tue Jan 15 11:19:41 2019 +0000
@@ -0,0 +1,118 @@
+//bool NRFuart_enabled = false;
+#include "NRFuart.h"
+
+void NRFuart_init_nohwfc() {
+ if(NRF_UART0->ENABLE == UART_ENABLE_ENABLE_Disabled) {
+ //Configure UART0 pins.
+ nrf_gpio_cfg_output(PN_UART_TX);
+ nrf_gpio_cfg_input(PN_UART_RX, NRF_GPIO_PIN_NOPULL);
+ NRF_UART0->PSELTXD = PN_UART_TX;
+ NRF_UART0->PSELRXD = PN_UART_RX;
+ NRF_UART0->CONFIG = (UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos) | UART_CONFIG_HWFC_Disabled;
+ NRF_UART0->BAUDRATE = NRF_UART_BAUDRATE_115200;
+ NRF_UART0->ENABLE = UART_ENABLE_ENABLE_Enabled;
+ NRF_UART0->EVENTS_RXDRDY = 0;
+ NRF_UART0->EVENTS_TXDRDY = 0;
+ NRF_UART0->EVENTS_ERROR = 0;
+ NRF_UART0->EVENTS_TXDRDY = 0;
+ NRF_UART0->TASKS_STARTRX = 1;
+ NRF_UART0->TASKS_STARTTX = 1;
+ //NRF_UART0->INTENCLR = 0xffffffffUL;
+ //NRF_UART0->INTENSET = UART_INTENSET_RXDRDY_Msk; //or
+ /*NRF_UART0->INTENSET = (UART_INTENSET_RXDRDY_Set << UART_INTENSET_RXDRDY_Pos) |
+ (UART_INTENSET_TXDRDY_Set << UART_INTENSET_TXDRDY_Pos) |
+ (UART_INTENSET_ERROR_Set << UART_INTENSET_ERROR_Pos);*/
+ //NVIC_ClearPendingIRQ(UART0_IRQn);
+ //NVIC_SetPriority(UART0_IRQn, 1); //3
+ //NVIC_EnableIRQ(UART0_IRQn);
+ //NVIC_SetVector(UART0_IRQn, (uint32_t) UART0_IRQHandler);
+ }
+ //NRFuart_enabled = true;
+};
+void NRFuart_uninit() {
+ if (NRF_UART0->ENABLE == UART_ENABLE_ENABLE_Enabled) {
+ NVIC_DisableIRQ(UART0_IRQn);
+ NRF_UART0->INTENCLR = 0xffffffffUL;
+ NRF_UART0->TASKS_STOPRX = 1;
+ NRF_UART0->TASKS_STOPTX = 1;
+ NRF_UART0->ENABLE = UART_ENABLE_ENABLE_Disabled;
+ NRF_UART0->PSELTXD = 0xFFFFFFFF;
+ NRF_UART0->PSELRXD = 0xFFFFFFFF;
+ NRF_UART0->PSELRTS = 0xFFFFFFFF;
+ NRF_UART0->PSELCTS = 0xFFFFFFFF;
+ //NRFuart_enabled = false;
+ }
+};
+void NRFuart_putc(char byte) {
+ if (!NRF_UART0->ENABLE) NRFuart_init_nohwfc();
+ NRF_UART0->TXD = byte;
+ uint32_t safetycounter = 0;
+ while(NRF_UART0->EVENTS_TXDRDY != 1 && safetycounter < 10000) {
+ safetycounter ++; // Wait for the current TXD data to be sent.
+ }
+ NRF_UART0->EVENTS_TXDRDY = 0;
+};
+void NRFuart_puts(char* bytes) {
+ if (!NRF_UART0->ENABLE) NRFuart_init_nohwfc();
+ for(int i = 0; bytes[i] != '\0'; i++) {
+ NRFuart_putc(bytes[i]);
+ }
+};
+void NRFuart_puts_debug(char* bytes) {
+ if (!NRF_UART0->ENABLE) NRFuart_init_nohwfc();
+ for(int i = 0; bytes[i] != '\0'; i++) {
+ NRFuart_putc(bytes[i]);
+ }
+ NRFuart_putc('\n');
+};
+void debug_prep(){
+ memset(GLOBAL_debug_buffer, '\0', sizeof(GLOBAL_debug_buffer));
+}
+void debug_exe(){
+ NRFuart_puts_debug(GLOBAL_debug_buffer);
+}
+char NRFuart_getc() {
+ if (!NRF_UART0->ENABLE) NRFuart_init_nohwfc();
+ uint32_t safetycounter = 0;
+ while(NRF_UART0->EVENTS_RXDRDY != 1 && safetycounter < 10000){
+ safetycounter ++;
+ }
+ NRF_UART0->EVENTS_RXDRDY = 0;
+ return (uint8_t)NRF_UART0->RXD;
+};
+char* NRFuart_gets(char terminator) {
+ if (!NRF_UART0->ENABLE) NRFuart_init_nohwfc();
+ static char buffer[200];
+ int charindex = 0;
+ memset(buffer,0x00,sizeof(buffer));
+ while(1) {
+ if (NRF_UART0->EVENTS_RXDRDY == 0) {
+ //Nothing available from the UART.
+ continue;
+ } else {
+ char inbyte = NRFuart_getc();
+ if (inbyte == terminator) {
+ break;
+ } else {
+ buffer[charindex] = inbyte;
+ charindex++;
+ }
+ }
+ }
+ buffer[charindex] = '\n'; //make sure we end with whitespace lf
+ return buffer;
+};
+void NRFuart_flush() {
+ if (!NRF_UART0->ENABLE) NRFuart_init_nohwfc();
+ //THIS HASNT BEEN TESTED
+ char char1 = 0;
+ uint32_t safetycounter = 0;
+ while (NRFuart_readable() && safetycounter < 10000) {
+ safetycounter ++;
+ char1 = NRFuart_getc();
+ }
+};
+bool NRFuart_readable() {
+ if (!NRF_UART0->ENABLE) NRFuart_init_nohwfc();
+ return (NRF_UART0->EVENTS_RXDRDY == 1);
+};
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NRFuart.h Tue Jan 15 11:19:41 2019 +0000 @@ -0,0 +1,20 @@ +#ifndef NRFUART_H_ +#define NRFUART_H_ + +//------------------------------------------------------------------------------ +//Dependencies +//------------------------------------------------------------------------------ +#include "main.h" + +//extern bool NRFuart_enabled; +extern void NRFuart_init_nohwfc(); +extern void NRFuart_uninit(); +extern void NRFuart_putc(char byte); +extern void NRFuart_puts(char* bytes); +extern char NRFuart_getc(); +extern void NRFuart_flush(); +extern bool NRFuart_readable(); +extern void debug_prep(); +extern void debug_exe(); + +#endif \ No newline at end of file
--- a/board.h Sun Jan 13 23:48:41 2019 +0000 +++ b/board.h Tue Jan 15 11:19:41 2019 +0000 @@ -37,7 +37,4 @@ //#define BD_PAGE_ADDRESS 0x5d000 //380928 #define USERDATA_START 0x7E000 // - 8k for user data -#define APPDATA_START 0x3D000 // - 4k for app data - -//NVSTORAGE KEYS -//#define NV_IDENTIFIER 1 \ No newline at end of file +#define APPDATA_START 0x3D000 // - 4k for app data \ No newline at end of file
--- a/main.cpp Sun Jan 13 23:48:41 2019 +0000
+++ b/main.cpp Tue Jan 15 11:19:41 2019 +0000
@@ -3,7 +3,7 @@
//------------------------------------------------------------------------------
//DEFINES
//------------------------------------------------------------------------------
-#define FW_VERSION 1
+#define FW_VERSION 2
//MODES
#define USE_NRF_TEMP_SENSOR 1
@@ -26,81 +26,79 @@
//------------------------------------------------------------------------------
//FUNCTION PROTOTYPES
//------------------------------------------------------------------------------
-static void mainStateEngine(void);
-static void selftest(void);
-static void buttonPress(void);
-static void buttonRelease(void);
-static void dumpSettings(void);
-static void saveEventTimes(void);
-static void event_location_tx(void);
+void mainStateEngine(void);
+void selftest(void);
+void buttonPress(void);
+void buttonRelease(void);
+void dumpSettings(void);
+void saveEventTimes(void);
//------------------------------------------------------------------------------
-//GLOBAL VARS
+// GLOBALS
//------------------------------------------------------------------------------
-char* GLOBAL_defaultApi = "b:gps2";
-bool GLOBAL_accel_healthy = false;
-bool GLOBAL_motionStopFlagTriggered = false;
-bool GLOBAL_debugLED = true;
-bool GLOBAL_needToConfigureLis3dh = false;
-bool GLOBAL_registeredOnNetwork = false;
-bool GLOBAL_modemOn = false;
-bool GLOBAL_LEDSequenceinProgress = false;
-time_t GLOBAL_wakeTime = 0;
-char GLOBAL_exceptionString[15];
-bool NRFuart_enabled = false;
-char GLOBAL_debug_buffer[200];
+char* GLOBAL_defaultApi = "b:gps2";
+bool GLOBAL_accel_healthy = false;
+bool GLOBAL_motionStopFlagTriggered = false;
+bool GLOBAL_debugLED = true;
+bool GLOBAL_needToConfigureLis3dh = false;
+bool GLOBAL_registeredOnNetwork = false;
+bool GLOBAL_modemOn = false;
+bool GLOBAL_LEDSequenceinProgress = false;
+time_t GLOBAL_wakeTime = 0;
+char GLOBAL_exceptionString[15];
+char GLOBAL_debug_buffer[200];
-static int RET_setting_firmware;
-static uint32_t RET_setting_minimumupdate_hrs;
-static uint8_t RET_setting_location_mode;
-static uint8_t RET_setting_location_accuracy;
-static uint32_t RET_setting_location_tx_interval_mins;
-static uint32_t RET_setting_location_tx_failsafe_hrs;
-static uint16_t RET_setting_location_timeout;
-static uint32_t RET_setting_activity_tx_interval_hrs;
-static uint32_t RET_setting_environmental_tx_interval_mins;
-static uint16_t RET_setting_motion_g;
-static time_t RET_setting_motion_start_seconds;
-static time_t RET_setting_motion_stop_seconds;
-static uint16_t RET_setting_impact_g;
-static uint8_t RET_setting_impact_alert;
-static uint16_t RET_setting_connection_timeout;
-static uint16_t RET_setting_beacon_interval_seconds;
-static uint16_t RET_setting_beacon_scan;
+int RET_setting_firmware;
+uint32_t RET_setting_minimumupdate_hrs;
+uint8_t RET_setting_location_mode;
+uint8_t RET_setting_location_accuracy;
+uint32_t RET_setting_location_tx_interval_mins;
+uint32_t RET_setting_location_tx_failsafe_hrs;
+uint16_t RET_setting_location_timeout;
+uint32_t RET_setting_activity_tx_interval_hrs;
+uint32_t RET_setting_environmental_tx_interval_mins;
+uint16_t RET_setting_motion_g;
+time_t RET_setting_motion_start_seconds;
+time_t RET_setting_motion_stop_seconds;
+uint16_t RET_setting_impact_g;
+uint8_t RET_setting_impact_alert;
+uint16_t RET_setting_connection_timeout;
+uint16_t RET_setting_beacon_interval_seconds;
+uint16_t RET_setting_beacon_scan;
//STATE
-static uint8_t RET_coldBoot = 1;
-static bool RET_haveSettings;
-static uint8_t RET_state;
-static uint8_t RET_state_prev;
-static uint8_t RET_buttonPressCount;
-static time_t RET_buttonPressTime;
-static time_t RET_buttonHoldTime;
-static time_t RET_RTCunixtime;
-static time_t RET_SetupRunAt;
-static time_t RET_SettingsGotAt;
+uint8_t RET_coldBoot = 1;
+time_t RET_RTCunixtime;
+bool RET_haveSettings;
+uint8_t RET_state;
+uint8_t RET_state_prev;
+uint8_t RET_buttonPressCount;
+time_t RET_buttonPressTime;
+time_t RET_buttonHoldTime;
+time_t RET_SetupRunAt;
+time_t RET_SettingsGotAt;
//MOTION STATE
-static bool RET_motionTriggered;
-static bool RET_motionTriggeredInTXInterval;
-static time_t RET_motionStartTime;
-static time_t RET_motionStopTime;
-static bool RET_motionPendingOnState;
-static bool RET_motionPendingOffState;
-static bool RET_motionState;
-static float RET_motionTotalActivityHours;
-static time_t RET_motionFrameStart;
-static char RET_activityData[140];
+bool RET_motionTriggered;
+bool RET_motionTriggeredInTXInterval;
+time_t RET_motionStartTime;
+time_t RET_motionStopTime;
+bool RET_motionPendingOnState;
+bool RET_motionPendingOffState;
+bool RET_motionState;
+float RET_motionTotalActivityHours;
+time_t RET_motionFrameStart;
+char RET_activityData[140];
//IMPACT
-static bool RET_impactTriggered;
+bool RET_impactTriggered;
//EVENTS LOGGING
-static time_t RET_eventTime_location_log;
-static time_t RET_eventTime_environmental_log;
+time_t RET_eventTime_location_log;
+time_t RET_eventTime_environmental_log;
//EVENTS TX
-static time_t RET_eventTime_location_tx;
-static time_t RET_eventTime_location_failsafe_tx;
-static time_t RET_eventTime_environmental_tx;
-static time_t RET_eventTime_activity_tx;
-static time_t RET_eventTime_wakeFromDormant;
+time_t RET_eventTime_location_tx;
+time_t RET_eventTime_location_failsafe_tx;
+time_t RET_eventTime_environmental_tx;
+time_t RET_eventTime_activity_tx;
+time_t RET_eventTime_wakeFromDormant;
//------------------------------------------------------------------------------
//GPIO
@@ -116,10 +114,6 @@
SI7060 si7060(PN_I2C_SDA, PN_I2C_SCL);
LIS3DH lis3dh(PN_SPI_MOSI, PN_SPI_MISO, PN_SPI_CS0, PN_SPI_CLK);
Modem modem(PN_GSM_PWR_KEY, PN_VREG_EN, PN_GSM_WAKE_DISABLE);
-
-//------------------------------------------------------------------------------
-//TIMERS
-//-----------------------------------------------mi-------------------------------
LowPowerTicker RTCticker; //no impact on power consumption
//------------------------------------------------------------------------------
@@ -130,140 +124,6 @@
//------------------------------------------------------------------------------
// LOW LEVEL FUNCS
//------------------------------------------------------------------------------
-void NRFuart_init_nohwfc() {
- if(NRFuart_enabled == false) {
- //Configure UART0 pins.
- nrf_gpio_cfg_output(PN_UART_TX);
- nrf_gpio_cfg_input(PN_UART_RX, NRF_GPIO_PIN_NOPULL);
- NRF_UART0->PSELTXD = PN_UART_TX;
- NRF_UART0->PSELRXD = PN_UART_RX;
- NRF_UART0->CONFIG = (UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos) | UART_CONFIG_HWFC_Disabled;
- NRF_UART0->BAUDRATE = NRF_UART_BAUDRATE_115200;
- NRF_UART0->ENABLE = UART_ENABLE_ENABLE_Enabled;
- NRF_UART0->EVENTS_RXDRDY = 0;
- NRF_UART0->EVENTS_TXDRDY = 0;
- NRF_UART0->EVENTS_ERROR = 0;
- NRF_UART0->EVENTS_TXDRDY = 0;
- NRF_UART0->TASKS_STARTRX = 1;
- NRF_UART0->TASKS_STARTTX = 1;
-
- //NRF_UART0->INTENCLR = 0xffffffffUL;
- //NRF_UART0->INTENSET = UART_INTENSET_RXDRDY_Msk;
- /*NRF_UART0->INTENSET = (UART_INTENSET_RXDRDY_Set << UART_INTENSET_RXDRDY_Pos) |
- (UART_INTENSET_TXDRDY_Set << UART_INTENSET_TXDRDY_Pos) |
- (UART_INTENSET_ERROR_Set << UART_INTENSET_ERROR_Pos);*/
- //NVIC_ClearPendingIRQ(UART0_IRQn);
- //NVIC_SetPriority(UART0_IRQn, 1); //3
- //NVIC_EnableIRQ(UART0_IRQn);
- //NVIC_SetVector(UART0_IRQn, (uint32_t) UART0_IRQHandler);
- }
- NRFuart_enabled = true;
-};
-void NRFuart_uninit() {
- if (NRFuart_enabled) {
- NVIC_DisableIRQ(UART0_IRQn);
- NRF_UART0->INTENCLR = 0xffffffffUL;
- NRF_UART0->TASKS_STOPRX = 1;
- NRF_UART0->TASKS_STOPTX = 1;
- NRF_UART0->ENABLE = UART_ENABLE_ENABLE_Disabled;
- NRF_UART0->PSELTXD = 0xFFFFFFFF;
- NRF_UART0->PSELRXD = 0xFFFFFFFF;
- NRF_UART0->PSELRTS = 0xFFFFFFFF;
- NRF_UART0->PSELCTS = 0xFFFFFFFF;
- NRFuart_enabled = false;
- }
-};
-void NRFuart_putc(char byte) {
- if (!NRFuart_enabled) NRFuart_init_nohwfc();
- NRF_UART0->TXD = byte;
- uint32_t safetycounter = 0;
- while(NRF_UART0->EVENTS_TXDRDY != 1 && safetycounter < 10000)
- {
- safetycounter ++; // Wait for the current TXD data to be sent.
- }
- NRF_UART0->EVENTS_TXDRDY = 0;
-};
-void NRFuart_puts(char* bytes) {
- if (!NRFuart_enabled) NRFuart_init_nohwfc();
- for(int i = 0; bytes[i] != '\0'; i++) {
- NRFuart_putc(bytes[i]);
- }
-};
-void NRFuart_puts_debug(char* bytes) {
- if (!NRFuart_enabled) NRFuart_init_nohwfc();
- for(int i = 0; bytes[i] != '\0'; i++) {
- NRFuart_putc(bytes[i]);
- }
- NRFuart_putc('\n');
-};
-void debug_prep(){
- memset(GLOBAL_debug_buffer, '\0', sizeof(GLOBAL_debug_buffer));
-}
-void debug_exe(){
- NRFuart_puts_debug(GLOBAL_debug_buffer);
-}
-char NRFuart_getc() {
- if (!NRFuart_enabled) NRFuart_init_nohwfc();
- uint32_t safetycounter = 0;
- while(NRF_UART0->EVENTS_RXDRDY != 1 && safetycounter < 10000){
- safetycounter ++;
- }
- NRF_UART0->EVENTS_RXDRDY = 0;
- return (uint8_t)NRF_UART0->RXD;
-};
-char* NRFuart_gets(char terminator) {
- if (!NRFuart_enabled) NRFuart_init_nohwfc();
- static char buffer[200];
- int charindex = 0;
- memset(buffer,'\0',sizeof(buffer));
- while(1) {
- if (NRF_UART0->EVENTS_RXDRDY == 0) {
- //Nothing available from the UART.
- continue;
- } else {
- char inbyte = NRFuart_getc();
- if (inbyte == terminator) {
- break;
- } else {
- buffer[charindex] = inbyte;
- charindex++;
- }
- }
- }
- buffer[charindex] = '\n'; //make sure we end with whitespace lf
- return buffer;
-};
-void NRFuart_flush() {
- if (!NRFuart_enabled) NRFuart_init_nohwfc();
- //THIS HASNT BEEN TESTED
- char char1 = 0;
- while (NRFuart_readable()) {
- char1 = NRFuart_getc();
- }
-};
-bool NRFuart_readable() {
- if (!NRFuart_enabled) NRFuart_init_nohwfc();
- return (NRF_UART0->EVENTS_RXDRDY == 1);
-};
-#define CONSOLE_DEBUG 0
-#if CONSOLE_DEBUG
-#define DEBUG(str, ... ) do{\
- /*int n;\
- char buffer[200];\
- memset(buffer, '\0', sizeof(buffer));\
- n = snprintf(buffer, sizeof(buffer), str, __VA_ARGS__);\
- buffer[sizeof(buffer)-1] = 0x00;\
- if(n < 0) { }\
- else if(n >= sizeof(buffer)) { }\
- else\
- {\
- NRFuart_puts_debug(buffer);\
- }\
-}while(0)*/
-#else
-#define DEBUG(...)
-#endif
-
void nrf_configureGPIOForSleep(){
nrf_gpio_cfg_input(PN_SPI_MOSI, NRF_GPIO_PIN_NOPULL);
nrf_gpio_cfg_input(PN_SPI_MISO, NRF_GPIO_PIN_NOPULL);
@@ -327,17 +187,25 @@
}
return voltage;
}
+float nrfTemperature() {
+ //INTERNAL NRF52 TEMP SENSOR
+ uint32_t safetycounter = 0;
+ float temperature = 0.0;
+ NRF_TEMP->TASKS_START=1;
+ while (NRF_TEMP->EVENTS_DATARDY==0 && safetycounter < 10000) {
+ safetycounter ++;
+ };
+ NRF_TEMP->EVENTS_DATARDY=0;
+ temperature = nrf_temp_read()/4.0;
+ NRF_TEMP->TASKS_STOP=1;
+ return temperature;
+}
float getTemperature() {
float temperature;
-
+
if (USE_NRF_TEMP_SENSOR) {
//INTERNAL NRF52 TEMP SENSOR
- uint32_t safetycounter = 0;
- NRF_TEMP->TASKS_START=1;
- while (NRF_TEMP->EVENTS_DATARDY==0 && safetycounter < 10000);
- NRF_TEMP->EVENTS_DATARDY=0;
- temperature = nrf_temp_read()/4.0;
- NRF_TEMP->TASKS_STOP=1;
+ temperature = nrfTemperature();
} else {
temperature = si7060.getTemperature(); //currently disabled because its causing a high current 450ua sleep, most likely due to sensor not sleeping correctly, or i2c sleep issue
}
@@ -410,7 +278,7 @@
memset(GLOBAL_exceptionString,0x00,sizeof(GLOBAL_exceptionString));
if (DEBUG_ON) {memset(GLOBAL_debug_buffer,0x00,sizeof(GLOBAL_debug_buffer));}
}
-void factoryReset() {
+void setDefaults() {
//IDENTITY
//RET_imei = 0;
//STATE
@@ -486,12 +354,7 @@
float temperature;
if (USE_NRF_TEMP_SENSOR) {
//INTERNAL NRF52 TEMP SENSOR
- uint32_t safetycounter = 0;
- NRF_TEMP->TASKS_START=1;
- while (NRF_TEMP->EVENTS_DATARDY==0 && safetycounter < 10000);
- NRF_TEMP->EVENTS_DATARDY=0;
- temperature = nrf_temp_read()/4.0;
- NRF_TEMP->TASKS_STOP=1;
+ temperature = nrfTemperature();
} else {
temperature = si7060.getTemperature();
}
@@ -684,7 +547,7 @@
pass = false;
modem.off(false);
if(GLOBAL_debugLED) LED1errorCode(5,10); //ERROR 5
- }
+ }
} else {
//Response error
}
@@ -967,22 +830,30 @@
DEBUG("0x%08x. Hard Reset ST:%d\n",NRF_POWER->RESETREAS, RET_state);
RET_coldBoot = 1;
dumpSettings();
- NRF_POWER->RESETREAS = 0xffffffff;
break;
case 0x00000002 :
DEBUG("Watchdog ST:%d\n",RET_state);
- NRF_POWER->RESETREAS = 0xffffffff;
break;
case 0x00000004 :
DEBUG("Soft ST:%d\n",RET_state);
break;
}
+ NRF_POWER->RESETREAS = 0xffffffff;
}
//CHECK FOR FIRST BOOT
if (RET_coldBoot == 1) {
- factoryReset();
- LED1errorCode(6,2);
+ setDefaults();
+ //check battery
+ float voltage = getBatteryV();
+ if (voltage > 2.5) {
+ //battery ok
+ LED1errorCode(6,2);
+ } else {
+ //battery low
+ LED1errorCode(10,2);
+ }
+ mainthread.wait(2000);
}
//MAIN LOOP
--- a/main.h Sun Jan 13 23:48:41 2019 +0000
+++ b/main.h Tue Jan 15 11:19:41 2019 +0000
@@ -38,6 +38,7 @@
//------------------------------------------------------------------------------
//Application headers
//------------------------------------------------------------------------------
+#include "NRFuart.h"
#include "app_data.h"
#include "states.h"
#include "common.h"
@@ -52,19 +53,35 @@
#define DEBUG_ON 1
+//OLD DEBUG STUFF
+#define CONSOLE_DEBUG 0
+#if CONSOLE_DEBUG
+#define DEBUG(str, ... ) do{\
+ /*int n;\
+ char buffer[200];\
+ memset(buffer, '\0', sizeof(buffer));\
+ n = snprintf(buffer, sizeof(buffer), str, __VA_ARGS__);\
+ buffer[sizeof(buffer)-1] = 0x00;\
+ if(n < 0) { }\
+ else if(n >= sizeof(buffer)) { }\
+ else\
+ {\
+ NRFuart_puts_debug(buffer);\
+ }\
+}while(0)*/
+#else
+#define DEBUG(...)
+#endif
+
//------------------------------------------------------------------------------
//Global data structures
//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+//GLOBAL VARS
+//------------------------------------------------------------------------------
+
//PERFS
-extern void NRFuart_init_nohwfc();
-extern void NRFuart_uninit();
-extern void NRFuart_putc(char byte);
-extern void NRFuart_puts(char* bytes);
-extern char NRFuart_getc();
-extern void NRFuart_flush();
-extern bool NRFuart_readable();
-extern void debug_prep();
-extern void debug_exe();
//VARS
extern bool GLOBAL_accel_healthy;
--- a/mbed_app.json Sun Jan 13 23:48:41 2019 +0000
+++ b/mbed_app.json Tue Jan 15 11:19:41 2019 +0000
@@ -23,6 +23,8 @@
"platform.sys-stats-enabled": false
},
"NRF52_DK": {
+ "target.mbed_app_start": "0x3E000",
+ "target.bootloader_img": null,
"target.OUTPUT_EXT": "bin",
"target.uart_hwfc": 0,
"nordic.uart_0_fifo_size": 1024,
--- a/modem.cpp Sun Jan 13 23:48:41 2019 +0000
+++ b/modem.cpp Tue Jan 15 11:19:41 2019 +0000
@@ -4,7 +4,6 @@
Modem::Modem(PinName pwrkey, PinName vreg_en, PinName w_disable): _pwrkey(pwrkey), _vreg_en(vreg_en), _w_disable(w_disable)
{
- //GLOBAL_requireSoftReset = true; //TODO: this can be removed when uart sleep issue resolved
}
void Modem::ATsendCMD(char* cmd)
@@ -54,7 +53,7 @@
bool Modem::ATgetResponse(char terminator, uint32_t timeout)
{
- memset(ATinBuffer,'/0',sizeof(ATinBuffer));
+ memset(ATinBuffer,0x00,sizeof(ATinBuffer));
int charindex = 0;
bool gotTerminator = false;
Timer t;
@@ -302,7 +301,7 @@
bool haveGPSFix = false;
bool haveCellFix = false;
static char locDataOut[100];
- memset(locDataOut,'/0',sizeof(locDataOut));
+ memset(locDataOut,0x00,sizeof(locDataOut));
Timer t;
t.start();
uint32_t startmillis;