Edit

Dependencies:   Lis2dh12 aconno_I2C aconno_nrf52_uart adc52832_common aconno_SEGGER_RTT

source/main.h

Committer:
jurica238814
Date:
2018-02-28
Branch:
NanoModule
Revision:
9:a9c5db477f35
Parent:
8:4b1ac4733b3d
Child:
10:83dab6cc625d

File content as of revision 9:a9c5db477f35:

/*
 *   Made by Jurica Resetar @ aconno
 *   More info @ aconno.de
 *
 */

#ifndef MAIN_H
#define MAIN_H
 
#include "mbed.h"
#include "nrf52_uart.h"
#include "Lis2dh12.h"
#include "Lis2dh12_regs.h"
#include "aconno_ble.h"
#include "ble/BLE.h"
#include "GapAdvertisingData.h"

#define DEBUG               (0)
#define DEBUG_LED           (1)
#define I2C_DATA            (p2)
#define I2C_CLK             (p3)
#define INT_PIN1            (p10)
#define INT_PIN2            (p9)
#define BLE_ACTIVE_TIME_S   (1)
#define POWER_UP_DELAY_MS   (200)

#define INT1_THRESHOLD      (0x10)
#define INT1_DURATION       (0x00)
    
#define ACC_INT_SIG         (0x00001020)    // Acc interrupt signal
#define DISABLE_BLE_SIG     (0x00001030)

#if DEBUG
    NRF52_UART uart(p12, p14, Baud9600);
    char buffer[255];
    #define SEND(...) {uint8_t len = sprintf(buffer, __VA_ARGS__); uartM.lock(); uart.send(buffer, len); uartM.unlock();}
#else
    #define SEND(...)
#endif

char memsI2CAddress = I2C_ADDRESS;
Mutex uartM;
Thread uartT;
Thread bleT;

DigitalOut AccVcc(p13);
DigitalOut redLed(p12);
InterruptIn INT1(INT_PIN1);
//InterruptIn INT2(INT_PIN2);
I2C i2c(I2C_DATA,I2C_CLK);
Lis2dh12 mems(&i2c, memsI2CAddress);
Ticker bleTicker;

#endif