Merck / Mbed OS SmartCap_OS5

Dependencies:   nRF51822

main.h

Committer:
sgetz7908
Date:
2016-12-20
Revision:
2:def2c045c43a
Parent:
1:b08ee63a2822
Child:
4:1bfa16834dd4

File content as of revision 2:def2c045c43a:


#ifndef MAIN_H
#define MAIN_H


#define UART_DEBUGGING 1 // put a '1' here if you are debugging on the BLE UART, otherwise make it 0. Turns on: shows records being added to log, will not allow a ble connection to timeout

#define FW_VERSION  001 //  major revisions will be 1xx, 2xx, etc.

#define VDD_DELAY   3 // seconds to keep vdd on after PRESS is released.

#define ADC_FREQ        5000   // ADC Sample Frequency in Hz
#define TICKS_PER_MS    (uint32_t)ADC_FREQ/1000

#define ADC_2o5V    853     // =2.5/3.0*1023
#define ADC_1o25V   (ADC_2o5V/2)
#define ADC_MID     (ADC_1o25V)

//*************** Parameters for recognizing a press  *************************
// Pulse size is in % of the positive range.
// for the following pulse sizes, 
//    0=0% (1.25V) pulse rise
//    100=100% (2.5V) pulse rise which is the max range.
#define PULSE_BIG         50
#define PULSE_MED         30
#define PULSE_THRESHOLD   10

#define ADC_PULSE_BIG           (ADC_MID + (PULSE_BIG*ADC_MID)/100)
#define ADC_PULSE_MED           (ADC_MID + (PULSE_MED*ADC_MID)/100)
#define ADC_PULSE_THRESHOLD     (ADC_MID + (PULSE_THRESHOLD*ADC_MID)/100)


// <--T1--> |  <--T2-->   | <-T3-> |  <------T4------>   |  
//<PRESS>                         <RELEASE>
//            /\
//           /  \                        /\
//----------/    \    /-----------------/  \  /----------------------
//                \  /                      \/
//                 \/

// the following times are in ms
// T_PRESS refers to the pulses produced by pressing
// T_RELEASE refers to the pulses produced by releasing
#define T_STARTUP       20    // (T1) time after powerup to ignore the input
#define T_PRESS_MAX     2500 // (T2_MAX) maximum time to look for PRESS pulses 
#define T_DELAY         180  // (T3) after a press is recognized, delay this time before looking for release pulses
#define T_RELEASE_MAX   4500 // (T4_MAX) maximum time to look for release pulses
#define T_RELEASE_UP    500  // (T7) Max time after the button is released that we look for sound.  This can preempt T4_MAX
#define T_LEDON         2000 // (T5) time led comes on if a valid press/release was detected
#define T_SHUTDOWN      250  // (T6) In done state, time to delay after switch is released before powering down

// number of pulses needed to validate a PRESS or RELEASE
#define NUM_PRESS_BIG   1
#define NUM_PRESS_MED   3
#define NUM_RELEASE_BIG 1
#define NUM_RELEASE_MED 3

//******************************************************************************

#endif // #ifndef MAIN_H