Updated with option to return from BP screen to main screen, resolved screen navigation issues
Dependencies: SDFileSystem TFTLCD_8bit ds3231 program mbed
Fork of poc_dis_5 by
ec_bp.h@3:9a06c2bed650, 2017-02-10 (annotated)
- Committer:
- nikitateggi
- Date:
- Fri Feb 10 10:39:13 2017 +0000
- Revision:
- 3:9a06c2bed650
Peak detect to 400 samples
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nikitateggi | 3:9a06c2bed650 | 1 | #ifndef EC_BP_H_ |
nikitateggi | 3:9a06c2bed650 | 2 | #define EC_BP_H_ |
nikitateggi | 3:9a06c2bed650 | 3 | |
nikitateggi | 3:9a06c2bed650 | 4 | typedef void (*func_ptr)(void) ; /*creates typedef to function pointer, does not take any arguement and returns void*/ |
nikitateggi | 3:9a06c2bed650 | 5 | |
nikitateggi | 3:9a06c2bed650 | 6 | void doHelp(void) ; |
nikitateggi | 3:9a06c2bed650 | 7 | void doStatus(void) ; |
nikitateggi | 3:9a06c2bed650 | 8 | void doFreq(void) ; |
nikitateggi | 3:9a06c2bed650 | 9 | void doMode(void) ; |
nikitateggi | 3:9a06c2bed650 | 10 | void doBit(void) ; |
nikitateggi | 3:9a06c2bed650 | 11 | void doWrite(void) ; |
nikitateggi | 3:9a06c2bed650 | 12 | void doWrite2(void) ; |
nikitateggi | 3:9a06c2bed650 | 13 | void doRead(void) ; |
nikitateggi | 3:9a06c2bed650 | 14 | void doLoop(void) ; |
nikitateggi | 3:9a06c2bed650 | 15 | void setup(void); |
nikitateggi | 3:9a06c2bed650 | 16 | void testsetup(void); |
nikitateggi | 3:9a06c2bed650 | 17 | void ecgsetup(void); |
nikitateggi | 3:9a06c2bed650 | 18 | void regWrite(int,int); |
nikitateggi | 3:9a06c2bed650 | 19 | void cmdWrite(int); |
nikitateggi | 3:9a06c2bed650 | 20 | void regRead(int); |
nikitateggi | 3:9a06c2bed650 | 21 | void lpf_coef(void); |
nikitateggi | 3:9a06c2bed650 | 22 | float lpf( float coeff[5], float); |
nikitateggi | 3:9a06c2bed650 | 23 | void drdy_int(void); |
nikitateggi | 3:9a06c2bed650 | 24 | void freqset(); |
nikitateggi | 3:9a06c2bed650 | 25 | void ecgtestsetupfunc(); |
nikitateggi | 3:9a06c2bed650 | 26 | |
nikitateggi | 3:9a06c2bed650 | 27 | #define PIN_MOSI PTA16 |
nikitateggi | 3:9a06c2bed650 | 28 | #define PIN_MISO PTA17 |
nikitateggi | 3:9a06c2bed650 | 29 | #define PIN_SCLK PTD1 |
nikitateggi | 3:9a06c2bed650 | 30 | #define MA4_SIZE 4 // DO NOT CHANGE |
nikitateggi | 3:9a06c2bed650 | 31 | //SDFileSystem sd(PTE1, PTE3, PTE2, PTE4, "sd"); |
nikitateggi | 3:9a06c2bed650 | 32 | |
nikitateggi | 3:9a06c2bed650 | 33 | //SPI commands |
nikitateggi | 3:9a06c2bed650 | 34 | #define CMD_WAKEUP 0x02 |
nikitateggi | 3:9a06c2bed650 | 35 | #define CMD_STANDBY 0x04 |
nikitateggi | 3:9a06c2bed650 | 36 | #define CMD_RESET 0x06 |
nikitateggi | 3:9a06c2bed650 | 37 | #define CMD_START 0x08 |
nikitateggi | 3:9a06c2bed650 | 38 | #define CMD_STOP 0x0A |
nikitateggi | 3:9a06c2bed650 | 39 | #define CMD_OFFSET_CAL 0x1A |
nikitateggi | 3:9a06c2bed650 | 40 | #define CMD_RDATAC 0x10 |
nikitateggi | 3:9a06c2bed650 | 41 | #define CMD_SDATAC 0x11 |
nikitateggi | 3:9a06c2bed650 | 42 | #define CMD_RDATA 0x12 |
nikitateggi | 3:9a06c2bed650 | 43 | //Note the following commands are 3 bits and have the following structure |
nikitateggi | 3:9a06c2bed650 | 44 | // CMD_REGr_rrrr; where r_rrrr is the register address given below |
nikitateggi | 3:9a06c2bed650 | 45 | #define CMD_WREG 0x02 |
nikitateggi | 3:9a06c2bed650 | 46 | #define CMD_RREG 0x01 |
nikitateggi | 3:9a06c2bed650 | 47 | |
nikitateggi | 3:9a06c2bed650 | 48 | //SPI registers addresses, 5 bits width |
nikitateggi | 3:9a06c2bed650 | 49 | #define REG_ID 0x00 |
nikitateggi | 3:9a06c2bed650 | 50 | #define REG_CONFIG1 0x01 |
nikitateggi | 3:9a06c2bed650 | 51 | #define REG_CONFIG2 0x02 |
nikitateggi | 3:9a06c2bed650 | 52 | #define REG_LOFF 0x03 |
nikitateggi | 3:9a06c2bed650 | 53 | #define REG_CH1SET 0x04 |
nikitateggi | 3:9a06c2bed650 | 54 | #define REG_CH2SET 0x05 |
nikitateggi | 3:9a06c2bed650 | 55 | #define REG_RLD_SENS 0x06 |
nikitateggi | 3:9a06c2bed650 | 56 | #define REG_LOFF_SENS 0x07 |
nikitateggi | 3:9a06c2bed650 | 57 | #define REG_LOFF_STAT 0x08 |
nikitateggi | 3:9a06c2bed650 | 58 | #define REG_MISC1 0x09 |
nikitateggi | 3:9a06c2bed650 | 59 | #define REG_MISC2 0x0A |
nikitateggi | 3:9a06c2bed650 | 60 | #define REG_GIPO 0x0B |
nikitateggi | 3:9a06c2bed650 | 61 | |
nikitateggi | 3:9a06c2bed650 | 62 | //Register bit configurations |
nikitateggi | 3:9a06c2bed650 | 63 | #define sps500 0x02 //CONFIG1 REG bits 010 |
nikitateggi | 3:9a06c2bed650 | 64 | #define sps125 0x00 //CONFIG1 REG bits 000 |
nikitateggi | 3:9a06c2bed650 | 65 | #define sps1k 0x03 //CONFIG1 REG bits 011 |
nikitateggi | 3:9a06c2bed650 | 66 | #define no_mode 0xA8 //CONFIG2 REG set to zero for device check |
nikitateggi | 3:9a06c2bed650 | 67 | #define test_mode 0xA3 //CONFIG2 REG bits set to test mode, to generate a square wave |
nikitateggi | 3:9a06c2bed650 | 68 | #define default_mode 0xE0 //CONFIG2 REG bits set to default mode, to generate ECG signal from an external input |
nikitateggi | 3:9a06c2bed650 | 69 | #define loff_conf 0xF0 //LOFF register bits set to F0 to configure LOFF reg for leadoff detection |
nikitateggi | 3:9a06c2bed650 | 70 | #define offset_meas 0x01 //CH1SET REG set to Gain = 6 and offset measurement |
nikitateggi | 3:9a06c2bed650 | 71 | #define test_inp 0x05 //CH1SET REG set to Gain = 6 and generate test signal |
nikitateggi | 3:9a06c2bed650 | 72 | #define elec_inp 0x00 //CH1SET REG set to Gain = 6 and take in electrode input |
nikitateggi | 3:9a06c2bed650 | 73 | #define rld_sens_sig 0x23 |
nikitateggi | 3:9a06c2bed650 | 74 | #define loff_sens_sig 0x03 |
nikitateggi | 3:9a06c2bed650 | 75 | #define misc1_inp 0x02 |
nikitateggi | 3:9a06c2bed650 | 76 | #define misc2_inp 0x03 |
nikitateggi | 3:9a06c2bed650 | 77 | |
nikitateggi | 3:9a06c2bed650 | 78 | #define LSHIFT_8 8 //left shift the obtained 8bit data by 8 values |
nikitateggi | 3:9a06c2bed650 | 79 | #define LSHIFT_16 16 ////left shift the obtained 8bit data by 16 values |
nikitateggi | 3:9a06c2bed650 | 80 | #define N_ERR 100 |
nikitateggi | 3:9a06c2bed650 | 81 | #define N_TEST 500 |
nikitateggi | 3:9a06c2bed650 | 82 | #define N_ECG 1000 |
nikitateggi | 3:9a06c2bed650 | 83 | |
nikitateggi | 3:9a06c2bed650 | 84 | |
nikitateggi | 3:9a06c2bed650 | 85 | //SPI SETTINGS |
nikitateggi | 3:9a06c2bed650 | 86 | #define baud_rate 115200 |
nikitateggi | 3:9a06c2bed650 | 87 | #define freq 1000000 |
nikitateggi | 3:9a06c2bed650 | 88 | #define bits 8 |
nikitateggi | 3:9a06c2bed650 | 89 | #define mode 1 |
nikitateggi | 3:9a06c2bed650 | 90 | #define loop 1000000 |
nikitateggi | 3:9a06c2bed650 | 91 | |
nikitateggi | 3:9a06c2bed650 | 92 | //PPG DECLARATION |
nikitateggi | 3:9a06c2bed650 | 93 | #define MAX_BRIGHTNESS 255 // BP ADD |
nikitateggi | 3:9a06c2bed650 | 94 | void setupfunc(); |
nikitateggi | 3:9a06c2bed650 | 95 | void ecgsetupfunc(); |
nikitateggi | 3:9a06c2bed650 | 96 | int readvalue(); |
nikitateggi | 3:9a06c2bed650 | 97 | #endif |
nikitateggi | 3:9a06c2bed650 | 98 | |
nikitateggi | 3:9a06c2bed650 | 99 | |
nikitateggi | 3:9a06c2bed650 | 100 |