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.
AS7000.cpp
00001 #include "AS7000.h" 00002 #include "mbed.h" 00003 00004 DigitalOut AS7000_GPIO8(p5); //NNN50-P5 map to GPIO-8 for AS7000 on/off 00005 DigitalInOut AS7000_INT(p4); //NNN50-P4 GPIO-5 for AS7000 INT 00006 00007 00008 AS7000::AS7000(PinName SDA, PinName SCL) : _i2c(SDA,SCL){ 00009 //Set I2C fast and bring reset line high 00010 _i2c.frequency(400000); 00011 address = AS7000Address; 00012 00013 AS7000_INT.mode(PullNone); 00014 00015 AS7000_INT.output(); 00016 00017 AS7000_GPIO8.write(1); // Power OFF AS7000 00018 AS7000_INT.write(1); // AS7000 GPIO OUTPUT LOW 00019 AS7000_INT.input(); 00020 wait_ms(100); 00021 } 00022 00023 void AS7000::enable(void){ 00024 char cmd[2]; 00025 00026 AS7000_GPIO8.write(0); //Power ON AS7000 00027 wait_ms(280); //Wait for > 250ms for booting 00028 00029 cmd[0] = AS7000_STARTUP; //0x04; 00030 cmd[1] = 0x02; 00031 _i2c.write(address, cmd, 2); 00032 wait_ms(35); 00033 00034 } 00035 00036 void AS7000::update(void){ 00037 hrm.transaction_id = rawdata[0]; 00038 hrm.status = rawdata[1]; 00039 hrm.hreat_rate = rawdata[2]; 00040 hrm.signal_QA = rawdata[3]; 00041 hrm.LED_current = ((rawdata[4]<<8)+rawdata[5]); 00042 hrm.SYNC = rawdata[6]; 00043 } 00044 00045 void AS7000::hr_only(void){ 00046 char cmd[2]; 00047 cmd[0] = HR_ONLY; 00048 if(AS7000_INT == 0) { 00049 _i2c.write(address, cmd, 1); 00050 _i2c.read(address, rawdata, 7, false); 00051 wait_ms(10); 00052 update(); 00053 } 00054 }
Generated on Mon Jul 18 2022 02:05:29 by
