![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
AFE
Dependencies: mbed-os-retarget-segger-rtt
Diff: source/main.h
- Revision:
- 2:04b708fb234b
- Parent:
- 0:8388b3dcbdf3
--- a/source/main.h Thu Aug 13 11:43:01 2020 +0000 +++ b/source/main.h Fri Sep 04 12:35:01 2020 +0000 @@ -68,11 +68,121 @@ DigitalOut AFE_nRST(P1_7); DigitalIn AFE_LED_ALM(P1_8); DigitalIn AFE_PD_ALM(P1_9); -int nr_error = 0; -bool state = 0; + +unsigned long AFE_Default[49] = { +//Reg0: CONTROL0: CONTROL REGISTER 0 + 0x00000, +//Reg1:REDSTARTCOUNT: SAMPLE RED START COUNT + 6000, +//Reg2:REDENDCOUNT: SAMPLE RED END COUNT + 7999, +//Reg3:REDLEDSTARTCOUNT: RED LED START COUNT + 6000, +//Reg4:REDLEDENDCOUNT: RED LED END COUNT + 7998, +//Reg5:AMBREDSTARTCOUNT: SAMPLE AMBIENT RED START COUNT + 0000, +//Reg6:AMBREDENDCOUNT: SAMPLE AMBIENT RED END COUNT + 1998, +//Reg7:IRSTARTCOUNT: SAMPLE IR START COUNT + 2000, +//Reg8:IRENDCOUNT: SAMPLE IR END COUNT + 3999, +//Reg9:IRLEDSTARTCOUNT: IR LED START COUNT + 2000, +//Reg10:IRLEDENDCOUNT: IR LED END COUNT + 3999, +//Reg11:AMBIRSTARTCOUNT: SAMPLE AMBIENT IR START COUNT + 4000, +//Reg12:AMBIRENDCOUNT: SAMPLE AMBIENT IR END COUNT + 5998, +//Reg13:REDCONVSTART: REDCONVST + 2, +//Reg14:REDCONVEND: RED CONVERT END COUNT + 1999, +//Reg15:AMBREDCONVSTART: RED AMBIENT CONVERT START COUNT + 2002, +//Reg16:AMBREDCONVEND: RED AMBIENT CONVERT END COUNT + 3999, +//Reg17:IRCONVSTART: IR CONVERT START COUNT + 4002, +//Reg18:IRCONVEND: IR CONVERT END COUNT + 5999, +//Reg19:AMBIRCONVSTART: IR AMBIENT CONVERT START COUNT + 6002, +//Reg20:AMBIRCONVEND: IR AMBIENT CONVERT END COUNT + 7999, +//Reg21:ADCRESETSTCOUNT0: ADC RESET 0 START COUNT + 0, +//Reg22:ADCRESETENDCOUNT0: ADC RESET 0 END COUNT + 2, +//Reg23:ADCRESETSTCOUNT1: ADC RESET 1 START COUNT + 2000, +//Reg24:ADCRESETENDCOUNT1: ADC RESET 1 END COUNT + 2002, +//Reg25:ADCRESETENDCOUNT2: ADC RESET 2 START COUNT + 4000, +//Reg26:ADCRESETENDCOUNT2: ADC RESET 2 END COUNT + 4002, +//Reg27:ADCRESETENDCOUNT3: ADC RESET 3 START COUNT + 6000, +//Reg28:ADCRESETENDCOUNT3: ADC RESET 3 END COUNT + 6002, +//Reg29:PRPCOUNT: PULSE REPETITION PERIOD COUNT + 7999, +//Reg30:CONTROL1: CONTROL REGISTER 1 + 0x00107, //timer enabled, averages=3, RED and IR LED pulse ON PD_ALM AND LED_ALM pins +//Reg31:?: ?? + 0x00000, +//Reg32:TIAGAIN: TRANS IMPEDANCE AMPLIFIER GAIN SETTING REGISTER + 0x00000, +//Reg33:TIA_AMB_GAIN: TRANS IMPEDANCE AAMPLIFIER AND AMBIENT CANELLATION STAGE GAIN + 0x00000, +//Reg34:LEDCNTRL: LED CONTROL REGISTER + 0x11414, +//Reg35:CONTROL2: CONTROL REGISTER 2 + 0x00000, //bit 9 +//Reg36:?: ?? + 0x00000, +//Reg37:?: ?? + 0x00000, +//Reg38:?: ?? + 0x00000, +//Reg39:?: ?? + 0x00000, +//Reg40:: ?? + 0x00000, +//Reg41:ALARM: ?? + 0x00000, +//Reg42:REDVALUE: RED DIGITAL SAMPLE VALUE + 0x00000, +//Reg43:AMBREDVALUE: Ambient RED Digital Sample Value + 0x00000, +//Reg44:IRVALUE: IR Digital Sample Value + 0x00000, +//Reg45:AMBIRVALUE: Ambient IR Digital Sample Value + 0x00000, +//Reg46:RED-AMBREDVALUE: RED-AMBIENT RED DIGITAL SAMPLE VALUE + 0x00000, +//Reg47:IR-AMBIRVALUE: IR-AMBIENT IR DIGITAL SAMPLE VALUE + 0x00000, +//Reg48:DIGNOSTICS: DIAGNOSTICS FLAGS REGISTER + 0x00000 +}; // ==== Prototypes ==== void SPI_Write(char address, uint32_t data); uint32_t SPI_Read(char raddress); -bool error_check(int index, unsigned char data_in, unsigned char data_out); +void SPI_Write_Bit(char address, uint8_t bit, bool bit_high); + +void AFE_reset(); +void AFE_begin(); +void AFE_set_LED_current(uint8_t led1_current, uint8_t led2_current); +void AFE_measurement(); +void AFE_register_state(); +void AFE_control_register(); +void AFE_diag_flag(); +void AFE_Results(); + +bool error_check(int index, uint32_t data_in, uint32_t data_out); void blinky(int delay); \ No newline at end of file