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: nRF51822
main.h@4:1bfa16834dd4, 2017-01-24 (annotated)
- Committer:
- sgetz7908
- Date:
- Tue Jan 24 16:29:51 2017 +0000
- Revision:
- 4:1bfa16834dd4
- Parent:
- 2:def2c045c43a
- Child:
- 7:090f9eea7b3c
ADC reference uses the internal 1.2V reference rather than VCC.; Includes Fran's adjusted main.h parameters.; LED turns off sooner.;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sgetz7908 | 0:cec02cf6df66 | 1 | |
sgetz7908 | 0:cec02cf6df66 | 2 | #ifndef MAIN_H |
sgetz7908 | 0:cec02cf6df66 | 3 | #define MAIN_H |
sgetz7908 | 0:cec02cf6df66 | 4 | |
sgetz7908 | 0:cec02cf6df66 | 5 | |
sgetz7908 | 2:def2c045c43a | 6 | #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 |
sgetz7908 | 0:cec02cf6df66 | 7 | |
sgetz7908 | 2:def2c045c43a | 8 | #define FW_VERSION 001 // major revisions will be 1xx, 2xx, etc. |
sgetz7908 | 0:cec02cf6df66 | 9 | |
sgetz7908 | 1:b08ee63a2822 | 10 | #define VDD_DELAY 3 // seconds to keep vdd on after PRESS is released. |
sgetz7908 | 1:b08ee63a2822 | 11 | |
sgetz7908 | 2:def2c045c43a | 12 | #define ADC_FREQ 5000 // ADC Sample Frequency in Hz |
sgetz7908 | 2:def2c045c43a | 13 | #define TICKS_PER_MS (uint32_t)ADC_FREQ/1000 |
sgetz7908 | 2:def2c045c43a | 14 | |
sgetz7908 | 4:1bfa16834dd4 | 15 | #define ADC_2o5V 710 // =2.5/3.6*1023 |
sgetz7908 | 2:def2c045c43a | 16 | #define ADC_1o25V (ADC_2o5V/2) |
sgetz7908 | 2:def2c045c43a | 17 | #define ADC_MID (ADC_1o25V) |
sgetz7908 | 0:cec02cf6df66 | 18 | |
sgetz7908 | 2:def2c045c43a | 19 | //*************** Parameters for recognizing a press ************************* |
sgetz7908 | 2:def2c045c43a | 20 | // Pulse size is in % of the positive range. |
sgetz7908 | 2:def2c045c43a | 21 | // for the following pulse sizes, |
sgetz7908 | 2:def2c045c43a | 22 | // 0=0% (1.25V) pulse rise |
sgetz7908 | 2:def2c045c43a | 23 | // 100=100% (2.5V) pulse rise which is the max range. |
sgetz7908 | 2:def2c045c43a | 24 | #define PULSE_BIG 50 |
sgetz7908 | 2:def2c045c43a | 25 | #define PULSE_MED 30 |
sgetz7908 | 2:def2c045c43a | 26 | #define PULSE_THRESHOLD 10 |
sgetz7908 | 2:def2c045c43a | 27 | |
sgetz7908 | 2:def2c045c43a | 28 | #define ADC_PULSE_BIG (ADC_MID + (PULSE_BIG*ADC_MID)/100) |
sgetz7908 | 2:def2c045c43a | 29 | #define ADC_PULSE_MED (ADC_MID + (PULSE_MED*ADC_MID)/100) |
sgetz7908 | 2:def2c045c43a | 30 | #define ADC_PULSE_THRESHOLD (ADC_MID + (PULSE_THRESHOLD*ADC_MID)/100) |
sgetz7908 | 0:cec02cf6df66 | 31 | |
sgetz7908 | 0:cec02cf6df66 | 32 | |
sgetz7908 | 2:def2c045c43a | 33 | // <--T1--> | <--T2--> | <-T3-> | <------T4------> | |
sgetz7908 | 2:def2c045c43a | 34 | //<PRESS> <RELEASE> |
sgetz7908 | 2:def2c045c43a | 35 | // /\ |
sgetz7908 | 2:def2c045c43a | 36 | // / \ /\ |
sgetz7908 | 2:def2c045c43a | 37 | //----------/ \ /-----------------/ \ /---------------------- |
sgetz7908 | 2:def2c045c43a | 38 | // \ / \/ |
sgetz7908 | 2:def2c045c43a | 39 | // \/ |
sgetz7908 | 2:def2c045c43a | 40 | |
sgetz7908 | 2:def2c045c43a | 41 | // the following times are in ms |
sgetz7908 | 2:def2c045c43a | 42 | // T_PRESS refers to the pulses produced by pressing |
sgetz7908 | 2:def2c045c43a | 43 | // T_RELEASE refers to the pulses produced by releasing |
sgetz7908 | 4:1bfa16834dd4 | 44 | #define T_STARTUP 250 //20 // (T1) time after powerup to ignore the input |
sgetz7908 | 2:def2c045c43a | 45 | #define T_PRESS_MAX 2500 // (T2_MAX) maximum time to look for PRESS pulses |
sgetz7908 | 4:1bfa16834dd4 | 46 | #define T_DELAY 500 //180 // (T3) after a press is recognized, delay this time before looking for release pulses |
sgetz7908 | 2:def2c045c43a | 47 | #define T_RELEASE_MAX 4500 // (T4_MAX) maximum time to look for release pulses |
sgetz7908 | 4:1bfa16834dd4 | 48 | #define T_RELEASE_UP 100 //500 // (T7) Max time after the button is released that we look for sound. This can preempt T4_MAX |
sgetz7908 | 2:def2c045c43a | 49 | #define T_LEDON 2000 // (T5) time led comes on if a valid press/release was detected |
sgetz7908 | 2:def2c045c43a | 50 | #define T_SHUTDOWN 250 // (T6) In done state, time to delay after switch is released before powering down |
sgetz7908 | 2:def2c045c43a | 51 | |
sgetz7908 | 2:def2c045c43a | 52 | // number of pulses needed to validate a PRESS or RELEASE |
sgetz7908 | 2:def2c045c43a | 53 | #define NUM_PRESS_BIG 1 |
sgetz7908 | 2:def2c045c43a | 54 | #define NUM_PRESS_MED 3 |
sgetz7908 | 2:def2c045c43a | 55 | #define NUM_RELEASE_BIG 1 |
sgetz7908 | 2:def2c045c43a | 56 | #define NUM_RELEASE_MED 3 |
sgetz7908 | 2:def2c045c43a | 57 | |
sgetz7908 | 2:def2c045c43a | 58 | //****************************************************************************** |
sgetz7908 | 0:cec02cf6df66 | 59 | |
sgetz7908 | 0:cec02cf6df66 | 60 | #endif // #ifndef MAIN_H |