AFE

Dependencies:   mbed-os-retarget-segger-rtt

Committer:
d4rth_j0k3r
Date:
Thu Aug 13 11:37:58 2020 +0000
Revision:
0:8388b3dcbdf3
Child:
2:04b708fb234b
Test AFE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
d4rth_j0k3r 0:8388b3dcbdf3 1 /* Pneumoscope Version 1.0
d4rth_j0k3r 0:8388b3dcbdf3 2 Florian CHAYS
d4rth_j0k3r 0:8388b3dcbdf3 3 */
d4rth_j0k3r 0:8388b3dcbdf3 4
d4rth_j0k3r 0:8388b3dcbdf3 5 // Defines for Registers
d4rth_j0k3r 0:8388b3dcbdf3 6 #define CONTROL0 0x00
d4rth_j0k3r 0:8388b3dcbdf3 7
d4rth_j0k3r 0:8388b3dcbdf3 8 // timing registers
d4rth_j0k3r 0:8388b3dcbdf3 9 #define LED2STC 0x01
d4rth_j0k3r 0:8388b3dcbdf3 10 #define LED2ENDC 0x02
d4rth_j0k3r 0:8388b3dcbdf3 11 #define LED2LEDSTC 0x03
d4rth_j0k3r 0:8388b3dcbdf3 12 #define LED2LEDENDC 0x04
d4rth_j0k3r 0:8388b3dcbdf3 13 #define ALED2STC 0x05
d4rth_j0k3r 0:8388b3dcbdf3 14 #define ALED2ENDC 0x06
d4rth_j0k3r 0:8388b3dcbdf3 15 #define LED1STC 0x07
d4rth_j0k3r 0:8388b3dcbdf3 16 #define LED1ENDC 0x08
d4rth_j0k3r 0:8388b3dcbdf3 17 #define LED1LEDSTC 0x09
d4rth_j0k3r 0:8388b3dcbdf3 18 #define LED1LEDENDC 0x0A
d4rth_j0k3r 0:8388b3dcbdf3 19 #define ALED1STC 0x0B
d4rth_j0k3r 0:8388b3dcbdf3 20 #define ALED1ENDC 0x0C
d4rth_j0k3r 0:8388b3dcbdf3 21 #define LED2CONVST 0x0D
d4rth_j0k3r 0:8388b3dcbdf3 22 #define LED2CONVEND 0x0E
d4rth_j0k3r 0:8388b3dcbdf3 23 #define ALED2CONVST 0x0F
d4rth_j0k3r 0:8388b3dcbdf3 24 #define ALED2CONVEND 0x10
d4rth_j0k3r 0:8388b3dcbdf3 25 #define LED1CONVST 0x11
d4rth_j0k3r 0:8388b3dcbdf3 26 #define LED1CONVEND 0x12
d4rth_j0k3r 0:8388b3dcbdf3 27 #define ALED1CONVST 0x13
d4rth_j0k3r 0:8388b3dcbdf3 28 #define ALED1CONVEND 0x14
d4rth_j0k3r 0:8388b3dcbdf3 29 #define ADCRSTSTCT0 0x15
d4rth_j0k3r 0:8388b3dcbdf3 30 #define ADCRSTENDCT0 0x16
d4rth_j0k3r 0:8388b3dcbdf3 31 #define ADCRSTSTCT1 0x17
d4rth_j0k3r 0:8388b3dcbdf3 32 #define ADCRSTENDCT1 0x18
d4rth_j0k3r 0:8388b3dcbdf3 33 #define ADCRSTSTCT2 0x19
d4rth_j0k3r 0:8388b3dcbdf3 34 #define ADCRSTENDCT2 0x1A
d4rth_j0k3r 0:8388b3dcbdf3 35 #define ADCRSTSTCT3 0x1B
d4rth_j0k3r 0:8388b3dcbdf3 36 #define ADCRSTENDCT3 0x1C
d4rth_j0k3r 0:8388b3dcbdf3 37 #define PRPCOUNT 0x1D
d4rth_j0k3r 0:8388b3dcbdf3 38
d4rth_j0k3r 0:8388b3dcbdf3 39 #define CONTROL1 0x1E
d4rth_j0k3r 0:8388b3dcbdf3 40 #define SPARE1 0x1F
d4rth_j0k3r 0:8388b3dcbdf3 41 #define TIAGAIN 0x20
d4rth_j0k3r 0:8388b3dcbdf3 42 #define TIA_AMB_GAIN 0x21
d4rth_j0k3r 0:8388b3dcbdf3 43 #define LEDCNTRL 0x22
d4rth_j0k3r 0:8388b3dcbdf3 44 #define CONTROL2 0x23
d4rth_j0k3r 0:8388b3dcbdf3 45 #define SPARE2 0x24
d4rth_j0k3r 0:8388b3dcbdf3 46 #define SPARE3 0x25
d4rth_j0k3r 0:8388b3dcbdf3 47 #define SPARE4 0x26
d4rth_j0k3r 0:8388b3dcbdf3 48 #define RESERVED1 0x27
d4rth_j0k3r 0:8388b3dcbdf3 49 #define RESERVED2 0x28
d4rth_j0k3r 0:8388b3dcbdf3 50 #define ALARM 0x29
d4rth_j0k3r 0:8388b3dcbdf3 51 #define LED2VAL 0x2A
d4rth_j0k3r 0:8388b3dcbdf3 52 #define ALED2VAL 0x2B
d4rth_j0k3r 0:8388b3dcbdf3 53 #define LED1VAL 0x2C
d4rth_j0k3r 0:8388b3dcbdf3 54 #define ALED1VAL 0x2D
d4rth_j0k3r 0:8388b3dcbdf3 55 #define LED2_ALED2VAL 0x2E
d4rth_j0k3r 0:8388b3dcbdf3 56 #define LED1_ALED1VAL 0x2F
d4rth_j0k3r 0:8388b3dcbdf3 57 #define DIAG 0x30
d4rth_j0k3r 0:8388b3dcbdf3 58
d4rth_j0k3r 0:8388b3dcbdf3 59 // ==== Globals ====
d4rth_j0k3r 0:8388b3dcbdf3 60 SPI spi(P1_3,P1_4,P1_6); // mosi, miso, sclk
d4rth_j0k3r 0:8388b3dcbdf3 61 DigitalOut cs(P1_5);
d4rth_j0k3r 0:8388b3dcbdf3 62 DigitalIn AFE_DIAG_END(P0_11);
d4rth_j0k3r 0:8388b3dcbdf3 63 DigitalIn button(P0_12);
d4rth_j0k3r 0:8388b3dcbdf3 64 DigitalOut myled(P0_13);
d4rth_j0k3r 0:8388b3dcbdf3 65 DigitalOut SUP_EN(P0_25);
d4rth_j0k3r 0:8388b3dcbdf3 66 DigitalIn ADC_READY(P1_1);
d4rth_j0k3r 0:8388b3dcbdf3 67 DigitalOut AFE_PDN(P1_2);
d4rth_j0k3r 0:8388b3dcbdf3 68 DigitalOut AFE_nRST(P1_7);
d4rth_j0k3r 0:8388b3dcbdf3 69 DigitalIn AFE_LED_ALM(P1_8);
d4rth_j0k3r 0:8388b3dcbdf3 70 DigitalIn AFE_PD_ALM(P1_9);
d4rth_j0k3r 0:8388b3dcbdf3 71 int nr_error = 0;
d4rth_j0k3r 0:8388b3dcbdf3 72 bool state = 0;
d4rth_j0k3r 0:8388b3dcbdf3 73
d4rth_j0k3r 0:8388b3dcbdf3 74 // ==== Prototypes ====
d4rth_j0k3r 0:8388b3dcbdf3 75 void SPI_Write(char address, uint32_t data);
d4rth_j0k3r 0:8388b3dcbdf3 76 uint32_t SPI_Read(char raddress);
d4rth_j0k3r 0:8388b3dcbdf3 77 bool error_check(int index, unsigned char data_in, unsigned char data_out);
d4rth_j0k3r 0:8388b3dcbdf3 78 void blinky(int delay);