Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Lis2dh12 aconno_I2C aconno_nrf52_uart adc52832_common aconno_SEGGER_RTT
main.h
00001 /* 00002 * Made by Jurica Resetar @ aconno 00003 * More info @ aconno.de 00004 * 00005 */ 00006 00007 #ifndef MAIN_H 00008 #define MAIN_H 00009 00010 #include "mbed.h" 00011 #include "nrf52_uart.h" 00012 #include "Lis2dh12.h" 00013 #include "Lis2dh12_regs.h" 00014 #include "aconno_ble.h" 00015 #include "ble/BLE.h" 00016 #include "GapAdvertisingData.h" 00017 00018 #define DEBUG (0) 00019 #define PRINT_ON_RTT (0) 00020 #define DEBUG_LED (0) 00021 #define NANO_MODULE (1) 00022 #define LSB_VALUE (192) 00023 00024 #if NANO_MODULE 00025 #define I2C_DATA (p2) 00026 #define I2C_CLK (p3) 00027 #define INT_PIN1 (p10) 00028 #define INT_PIN2 (p9) 00029 #define ACC_POWER_PIN (p13) 00030 #define RED_LED_PIN (p12) 00031 #else 00032 #define I2C_DATA (p20) 00033 #define I2C_CLK (p17) 00034 #define INT_PIN1 (p16) 00035 #define INT_PIN2 (p15) 00036 #define ACC_POWER_PIN (p11) 00037 #define RED_LED_PIN (p22) 00038 #endif 00039 00040 #define BLE_ACTIVE_TIME_S (0.4) 00041 #define POWER_UP_DELAY_MS (200) 00042 00043 #if PRINT_ON_RTT 00044 #include "SEGGER_RTT.h" 00045 #define printf(...) SEGGER_RTT_printf(0, __VA_ARGS__) 00046 #else 00047 #define printf(...) 00048 #endif 00049 00050 #define INT1_THRESHOLD (20u) 00051 #define INT1_DUR (0x00) 00052 00053 #define ACC_INT_SIG (0x00001020) // Acc interrupt signal 00054 #define DISABLE_BLE_SIG (0x00001030) 00055 00056 #if DEBUG 00057 NRF52_UART uart(p12, p14, Baud9600); 00058 char buffer[255]; 00059 #define SEND(...) {uint8_t len = sprintf(buffer, __VA_ARGS__); uartM.lock(); uart.send(buffer, len); uartM.unlock();} 00060 #else 00061 #define SEND(...) 00062 #endif 00063 00064 char memsI2CAddress = I2C_ADDRESS; 00065 Mutex uartM; 00066 Thread uartT; 00067 Thread bleT; 00068 Thread measureT; 00069 00070 DigitalOut AccVcc(ACC_POWER_PIN); 00071 DigitalOut redLed(RED_LED_PIN); 00072 InterruptIn INT1(INT_PIN1); 00073 //InterruptIn INT2(INT_PIN2); 00074 I2C i2c(I2C_DATA,I2C_CLK); 00075 Lis2dh12 mems(&i2c, memsI2CAddress); 00076 Ticker bleTicker; 00077 00078 #endif
Generated on Mon Jul 18 2022 00:03:31 by
1.7.2