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.
main.cpp
00001 #include "mbed.h" 00002 00003 I2C i2c(I2C_SDA , I2C_SCL ); 00004 Serial debug(USBTX, USBRX); 00005 00006 int main() { 00007 char buffer[2]; 00008 buffer[1] = 0xE0; 00009 buffer[0] = 0x86; 00010 int count = 2; 00011 int address = 0x77; 00012 int error; 00013 // int i2c_frequency = 200 * 1000; 00014 int i2c_frequency = 100 * 1000; 00015 debug.printf("\nI2C BME280 Rest Test"); 00016 00017 i2c.frequency(i2c_frequency); 00018 00019 i2c.start(); 00020 error = i2c.write(address << 1); //We shift it left because mbed takes in 8 bit addreses 00021 i2c.stop(); 00022 if (error == 1) 00023 { 00024 debug.printf("\nI2C device found at address 0x%X", address); 00025 } 00026 else 00027 { 00028 debug.printf("\nDevice at IC address Ox%X, not responding", address); 00029 } 00030 00031 i2c.start(); 00032 error = i2c.write(address << 1, buffer, count); //We shift it left because mbed takes in 8 bit addreses 00033 i2c.stop(); 00034 if (error == 1) 00035 { 00036 debug.printf("\nBME280 reset request send success"); 00037 } 00038 else 00039 { 00040 debug.printf("\nBME280 reset request send failed Error Code: %d", error); 00041 } 00042 debug.printf("\ndone\n"); 00043 }
Generated on Thu Jul 14 2022 20:04:30 by
1.7.2