Lizzy project
Dependencies: aconno_I2C Lis2dh12 adc52832_common aconno_SEGGER_RTT
Revision 6:55607d577a42, committed 2018-03-13
- Comitter:
- dbartolovic
- Date:
- Tue Mar 13 15:41:35 2018 +0000
- Parent:
- 5:9903738f2587
- Child:
- 7:ac8277568115
- Commit message:
- Added simple test of leds and buzzer.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/acn_nrf52_pwm.lib Tue Mar 13 15:41:35 2018 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/Dautor/code/acn_nrf52_pwm/#ae812f51845a
--- a/source/main.cpp Fri Mar 09 18:09:57 2018 +0000
+++ b/source/main.cpp Tue Mar 13 15:41:35 2018 +0000
@@ -96,9 +96,67 @@
}
}
+void led_tick();
+
+void buzz_tick()
+{
+ static int start = 1;
+
+ if (start)
+ {
+ buzzer.enable(BUZZER_FREQUENCY_HZ);
+ buzzer.enableChannel(0, BUZZER_PIN);
+ buzzer.setDuty(0,0.5f);
+ start = 0;
+ }
+ else
+ {
+ buzzer.enable(0);
+ buzzer.setDuty(0, 0);
+ buzzer.disable();
+ start = 1;
+ led_tick();
+ test_ticker.detach();
+ test_ticker.attach(led_tick, 0.5);
+ }
+}
+
+
+void led_tick()
+{
+ static int count = 0;
+
+ switch(count)
+ {
+ case 0:
+ redLed = 0;
+ break;
+
+ case 1:
+ redLed = 1;
+ blueLed = 0;
+ break;
+
+ case 2:
+ blueLed = 1;
+ greenLed = 0;
+ break;
+
+ default:
+ greenLed = 1;
+ count = -1;
+ buzz_tick();
+ test_ticker.detach();
+ test_ticker.attach(buzz_tick, BUZZ_TIME_S);
+ }
+
+ count++;
+}
int main(){
+ test_ticker.attach(led_tick, 0.5);
+
printf("Main program started.\r\n");
NRF_NVMC->CONFIG = 0x00000002; // Erase enable UICR
@@ -106,8 +164,11 @@
NRF_NVMC->CONFIG = 0x00000001; // Write enable UICR
NRF_UICR->NFCPINS = 0xFFFFFFFE; // Change NFC to GPIO function
- redLed = 1;
+ redLed = 0;
AccVcc = 1;
+
+ blueLed = 1;
+ greenLed = 1;
wait_ms(POWER_UP_DELAY_MS);
/*
--- a/source/main.h Fri Mar 09 18:09:57 2018 +0000
+++ b/source/main.h Tue Mar 13 15:41:35 2018 +0000
@@ -13,10 +13,12 @@
#include "aconno_ble.h"
#include "ble/BLE.h"
#include "GapAdvertisingData.h"
+#include "acd52832_bsp.h"
+#include "acn_nrf52_pwm.h"
#define DEBUG (0)
#define PRINT_ON_RTT (1)
-#define DEBUG_LED (1)
+#define DEBUG_LED (0)
#define NANO_MODULE (0)
//#define LSB_VALUE (192)
#define LSB_VALUE (1)
@@ -35,12 +37,17 @@
#define INT_PIN2 (p15)
#define ACC_POWER_PIN (p11)
#define RED_LED_PIN (p22)
+ #define BUZZER_PIN (p18)
#endif
#define BLE_ACTIVE_TIME_S (0.4)
#define POWER_UP_DELAY_MS (200)
#define MEASURE_INTERVAL_MS (100)
+
+#define BUZZER_FREQUENCY_HZ (4000)
+#define BUZZ_TIME_S (2) /* Buzz time in s */
+
#if PRINT_ON_RTT
#include "SEGGER_RTT.h"
#define printf(...) SEGGER_RTT_printf(0, __VA_ARGS__)
@@ -70,10 +77,17 @@
DigitalOut AccVcc(ACC_POWER_PIN);
DigitalOut redLed(RED_LED_PIN);
+#if NANO_MODULE == 0
+DigitalOut blueLed(PIN_LED_BLUE);
+DigitalOut greenLed(PIN_LED_GREEN);
+#endif
InterruptIn INT1(INT_PIN1);
//InterruptIn INT2(INT_PIN2);
I2C i2c(I2C_DATA,I2C_CLK);
Lis2dh12 mems(&i2c, memsI2CAddress);
Ticker bleTicker;
+Ticker test_ticker;
+
+NRF52_PWM buzzer(NRF_PWM2);
#endif

