Geo beacon for VF.
Dependencies: MMA8452 aconno_bsp adc52832_common
Diff: main.cpp
- Revision:
- 28:7b71c61d2160
- Parent:
- 27:2c67f07590fd
- Child:
- 29:7b794a8633b4
--- a/main.cpp Wed Sep 13 16:28:32 2017 +0000
+++ b/main.cpp Thu Sep 14 12:43:51 2017 +0000
@@ -25,8 +25,8 @@
#define USE_ACC (0)
-#define SLEEP_TIME_S (3.00) /* Sleep time (in s) */
-#define ADV_TIMER_TIME_S (1.00) /* Advertising time (in s) */
+#define SLEEP_TIME_S (7.00) /* Sleep time (in s) */
+#define ADV_TIMER_TIME_S (0.30) /* Advertising time (in s) */
#define SCAN_TIMER_TIME_S (0.25) /* Scanning time (in s) */
#define FREE_TIME_S (0.1) /* Time between end of a scanning and sleep mode */
#define AWAKE_TIME_S (ADV_TIMER_TIME_S+SCAN_TIMER_TIME_S+FREE_TIME_S) /* Was 0.15 */
@@ -41,7 +41,7 @@
#define MSD_ID (0xFF)
#define BUZZ_TIME_S (1) /* Buzz time in s */
-#define ADV_INTERVAL (100) /* Advertising interval (in ms) */
+#define ADV_INTERVAL (50) /* Advertising interval (in ms) */
#define SCAN_INTERVAL (SCAN_TIMER_TIME_S) /* Scan interval (in ms) */
#define SCAN_WINDOW (SCAN_TIMER_TIME_S)
@@ -115,7 +115,6 @@
void buzzerStart(){
buzzer.enable(BUZZER_FREQUENCY_Hz);
- //buzzer.enable(1);
buzzer.enableChannel(0, BUZZER);
buzzer.setDuty(0,0.5f);
}
@@ -442,6 +441,7 @@
#endif
//WakeSleepT.attach(GoToSleep, AWAKE_TIME_S);
+ __enable_irq();
GoToSleep();
ble.init(bleInitComplete);
ble.gap().setTxPower(txPower);
@@ -457,39 +457,29 @@
wait_ms(1);
acc.set_register((char)FF_COUNT, (char)0x01); //WAS 0x08 // Set Counter degister value (10ms)
wait_ms(1);
- acc.set_register((char)FF_MT_THS, (char)0x90); // Set TH value for motion detection on 1 G (1/0.063) and DBCNTM = 1 (Increments or clears counter)
+ acc.set_register((char)FF_MT_THS, (char)0x88); //WAS 0x90 // Set TH value for motion detection on 1 G (1/0.063) and DBCNTM = 1 (Increments or clears counter)
+
+ // TODO: SMANJITI OSJETILJVOST
wait_ms(1);
// Setup for the interrupt handler
accPulse.rise(&pulse_handler); // -------------------------------------
- //acc.set_register((char)CTRL_REG_1, (char)0x03); // Flow data rate and Active mode
- acc.set_register((char)CTRL_REG_1, (char)0x01); // Flow data rate and Active mode
- acc.set_register((char)CTRL_REG_2, (char)0x03); // Set Low power mode
+ //acc.set_register((char)CTRL_REG_1, (char)0xF9); // Flow data rate and Active mode
+ acc.set_register((char)CTRL_REG_1, (char)0x38); // Flow data rate and Active mode
+ acc.set_register((char)CTRL_REG_2, (char)0x1B); // Set Low power mode
wait(1);
#endif
- __enable_irq();
-
/* SpinWait for initialization to complete. This is necessary because the BLE object is used in the main loop below. */
while (ble.hasInitialized() == false){ /* spin loop */ }
+ /*
buzzerStart();
wait_ms(500);
-
- // Disconnect and stop PWM2
- /*
- NRF_PWM2->PSEL.OUT[0] = 0x80000000;
- NRF_PWM2->PSEL.OUT[1] = 0x80000000;
- NRF_PWM2->PSEL.OUT[2] = 0x80000000;
- NRF_PWM2->PSEL.OUT[3] = 0x80000000;
- NRF_PWM2->TASKS_STOP = 1;
+ buzzerStop();
*/
- buzzerStop();
-
-
while(true){
-
ble.waitForEvent();
}
}

