]> git.itanic.dy.fi Git - BME280_driver/blobdiff - README.md
Updated interface design and examples.
[BME280_driver] / README.md
index 312aeff761f93a477bd8b3edcd9a26d5cae409d8..0a0e398033830301c2b7bc5d4601e98bc32ac522 100644 (file)
--- a/README.md
+++ b/README.md
@@ -34,7 +34,9 @@ struct bme280_dev dev;
 int8_t rslt = BME280_OK;\r
 \r
 /* Sensor_0 interface over SPI with native chip select line */\r
-dev.dev_id = 0;\r
+uint8_t dev_addr = 0;\r
+\r
+dev.intf_ptr = &dev_addr;\r
 dev.intf = BME280_SPI_INTF;\r
 dev.read = user_spi_read;\r
 dev.write = user_spi_write;\r
@@ -46,8 +48,9 @@ rslt = bme280_init(&dev);
 ``` c\r
 struct bme280_dev dev;\r
 int8_t rslt = BME280_OK;\r
+uint8_t dev_addr = BME280_I2C_ADDR_PRIM;\r
 \r
-dev.dev_id = BME280_I2C_ADDR_PRIM;\r
+dev.intf_ptr = &dev_addr;\r
 dev.intf = BME280_I2C_INTF;\r
 dev.read = user_i2c_read;\r
 dev.write = user_i2c_write;\r
@@ -119,7 +122,7 @@ int8_t stream_sensor_data_forced_mode(struct bme280_dev *dev)
     while (1) {\r
         rslt = bme280_set_sensor_mode(BME280_FORCED_MODE, dev);\r
         /* Wait for the measurement to complete and print data @25Hz */\r
-        dev->delay_ms(req_delay);\r
+        dev->delay_ms(req_delay, dev->intf_ptr);\r
         rslt = bme280_get_sensor_data(BME280_ALL, &comp_data, dev);\r
         print_sensor_data(&comp_data);\r
     }\r
@@ -161,7 +164,7 @@ int8_t stream_sensor_data_normal_mode(struct bme280_dev *dev)
        printf("Temperature, Pressure, Humidity\r\n");\r
        while (1) {\r
                /* Delay while the sensor completes a measurement */\r
-               dev->delay_ms(70);\r
+               dev->delay_ms(70, dev->intf_ptr);\r
                rslt = bme280_get_sensor_data(BME280_ALL, &comp_data, dev);\r
                print_sensor_data(&comp_data);\r
        }\r
@@ -182,7 +185,7 @@ void print_sensor_data(struct bme280_data *comp_data)
 ### Templates for function pointers\r
 ``` c\r
 \r
-void user_delay_ms(uint32_t period)\r
+void user_delay_ms(uint32_t period, void *intf_ptr)\r
 {\r
     /*\r
      * Return control or wait,\r
@@ -190,12 +193,12 @@ void user_delay_ms(uint32_t period)
      */\r
 }\r
 \r
-int8_t user_spi_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)\r
+int8_t user_spi_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr)\r
 {\r
     int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */\r
 \r
     /*\r
-     * The parameter dev_id can be used as a variable to select which Chip Select pin has\r
+     * The parameter intf_ptr can be used as a variable to select which Chip Select pin has\r
      * to be set low to activate the relevant device on the SPI bus\r
      */\r
 \r
@@ -216,12 +219,12 @@ int8_t user_spi_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16
     return rslt;\r
 }\r
 \r
-int8_t user_spi_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)\r
+int8_t user_spi_write(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr)\r
 {\r
     int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */\r
 \r
     /*\r
-     * The parameter dev_id can be used as a variable to select which Chip Select pin has\r
+     * The parameter intf_ptr can be used as a variable to select which Chip Select pin has\r
      * to be set low to activate the relevant device on the SPI bus\r
      */\r
 \r
@@ -242,12 +245,12 @@ int8_t user_spi_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint1
     return rslt;\r
 }\r
 \r
-int8_t user_i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)\r
+int8_t user_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr)\r
 {\r
     int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */\r
 \r
     /*\r
-     * The parameter dev_id can be used as a variable to store the I2C address of the device\r
+     * The parameter intf_ptr can be used as a variable to store the I2C address of the device\r
      */\r
 \r
     /*\r
@@ -269,12 +272,12 @@ int8_t user_i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16
     return rslt;\r
 }\r
 \r
-int8_t user_i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)\r
+int8_t user_i2c_write(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr)\r
 {\r
     int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */\r
 \r
     /*\r
-     * The parameter dev_id can be used as a variable to store the I2C address of the device\r
+     * The parameter intf_ptr can be used as a variable to store the I2C address of the device\r
      */\r
 \r
     /*\r