X_Nucleo_53L1A1 Expansion Board Class for VL53L1X Sensor.
Dependencies: VL53L1X_mbed
Dependents: HelloWorld_53L1A1_Interrupts 53L1A1_Satellites_MbedOS 53L1A1_Interrupts_MbedOS 53L1A1_Polling_All_MbedOS ... more
X-NUCLEO-53L1A1 Proximity Sensor Expansion Board Firmware Package
Introduction
This firmware package includes Component Device Drivers and the Board Support Package for STMicroelectronics' X-NUCLEO-53L1A1 Proximity sensor expansion board based on VL53L1X.
Firmware Library
Class XNucleo53L1A1 is intended to represent the Proximity sensor expansion board with the same name.
The expansion board provides support for the following components:
- on-board VL53L1X proximity sensor,
- up to two additional VL53L1X Satellites.
It is intentionally implemented as a singleton because only one X-NUCLEO-VL53L1A1 may be deployed at a time in a HW component stack. In order to get the singleton instance you have to call class method `Instance()`, e.g.:
// Sensors expansion board singleton instance static XNucleo53L1A1 *board = XNucleo53L1A1::instance(device_i2c, A2, D9, D2);
Example Applications
Diff: Components/STMPE1600/stmpe1600_class.h
- Revision:
- 15:44e6c9013bff
- Parent:
- 14:8320b5ff96fa
--- a/Components/STMPE1600/stmpe1600_class.h Mon Aug 07 14:30:21 2017 +0000 +++ b/Components/STMPE1600/stmpe1600_class.h Tue Aug 08 14:41:03 2017 +0000 @@ -103,18 +103,18 @@ * @param[in] lvl the default ot pin level */ Stmpe1600DigiOut(DevI2C &i2c, ExpGpioPinName out_pin_name, uint8_t dev_addr = STMPE1600_DEF_DEVICE_ADDRESS, - bool lvl = STMPE1600_DEF_DIGIOUT_LVL) : dev_i2c(i2c), exp_dev_addr(dev_addr), exp_pin_name(out_pin_name) + bool lvl = STMPE1600_DEF_DIGIOUT_LVL) : dev_i2c(&i2c), exp_dev_addr(dev_addr), exp_pin_name(out_pin_name) { uint8_t data[2]; if (exp_pin_name == NOT_CON) return; /* set the exp_pin_name as output */ - dev_i2c.i2c_read(data, exp_dev_addr, GPDR_0_7, 1); - dev_i2c.i2c_read(&data[1], exp_dev_addr, GPDR_8_15, 1); - * (uint16_t *) data = * (uint16_t *) data | (1 << (uint16_t) exp_pin_name); // set gpio as out - dev_i2c.i2c_write(data, exp_dev_addr, GPDR_0_7, 1); - dev_i2c.i2c_write(&data[1], exp_dev_addr, GPDR_8_15, 1); + dev_i2c->i2c_read(data, exp_dev_addr, GPDR_0_7, 1); + dev_i2c->i2c_read(&data[1], exp_dev_addr, GPDR_8_15, 1); + *(uint16_t *)data = *(uint16_t *)data | (1 << (uint16_t)exp_pin_name); // set gpio as out + dev_i2c->i2c_write(data, exp_dev_addr, GPDR_0_7, 1); + dev_i2c->i2c_write(&data[1], exp_dev_addr, GPDR_8_15, 1); write(lvl); } @@ -130,11 +130,11 @@ if (exp_pin_name == NOT_CON) return; /* set the exp_pin_name state to lvl */ - dev_i2c.i2c_read(data, exp_dev_addr, GPSR_0_7, 2); - * (uint16_t *) data = * (uint16_t *) data & (uint16_t)(~(1 << (uint16_t) exp_pin_name)); // set pin mask + dev_i2c->i2c_read(data, exp_dev_addr, GPSR_0_7, 2); + *(uint16_t *)data = *(uint16_t *)data & (uint16_t)(~(1 << (uint16_t)exp_pin_name)); // set pin mask if (lvl) - * (uint16_t *) data = * (uint16_t *) data | (uint16_t)(1 << (uint16_t) exp_pin_name); - dev_i2c.i2c_write(data, exp_dev_addr, GPSR_0_7, 2); + *(uint16_t *)data = *(uint16_t *)data | (uint16_t)(1 << (uint16_t)exp_pin_name); + dev_i2c->i2c_write(data, exp_dev_addr, GPSR_0_7, 2); } /** @@ -147,7 +147,7 @@ } private: - DevI2C &dev_i2c; + DevI2C *dev_i2c; uint8_t exp_dev_addr; ExpGpioPinName exp_pin_name; }; @@ -164,7 +164,7 @@ * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS) */ Stmpe1600DigiIn(DevI2C &i2c, ExpGpioPinName in_pin_name, - uint8_t dev_addr = STMPE1600_DEF_DEVICE_ADDRESS) : dev_i2c(i2c), exp_dev_addr(dev_addr), + uint8_t dev_addr = STMPE1600_DEF_DEVICE_ADDRESS) : dev_i2c(&i2c), exp_dev_addr(dev_addr), exp_pin_name(in_pin_name) { uint8_t data[2]; @@ -172,9 +172,9 @@ if (exp_pin_name == NOT_CON) return; /* set the exp_pin_name as input pin direction */ - dev_i2c.i2c_read(data, exp_dev_addr, GPDR_0_7, 2); - * (uint16_t *) data = * (uint16_t *) data & (uint16_t)(~(1 << (uint16_t) exp_pin_name)); // set gpio as in - dev_i2c.i2c_write(data, exp_dev_addr, GPDR_0_7, 2); + dev_i2c->i2c_read(data, exp_dev_addr, GPDR_0_7, 2); + *(uint16_t *)data = *(uint16_t *)data & (uint16_t)(~(1 << (uint16_t)exp_pin_name)); // set gpio as in + dev_i2c->i2c_write(data, exp_dev_addr, GPDR_0_7, 2); } /** @@ -188,8 +188,8 @@ if (exp_pin_name == NOT_CON) return false; /* read the exp_pin_name */ - dev_i2c.i2c_read(data, exp_dev_addr, GPMR_0_7, 2); - * (uint16_t *) data = * (uint16_t *) data & (uint16_t)(1 << (uint16_t) exp_pin_name); // mask the in gpio + dev_i2c->i2c_read(data, exp_dev_addr, GPMR_0_7, 2); + *(uint16_t *)data = *(uint16_t *)data & (uint16_t)(1 << (uint16_t)exp_pin_name); // mask the in gpio if (data[0] || data[1]) return true; return false; @@ -201,7 +201,7 @@ } private: - DevI2C &dev_i2c; + DevI2C *dev_i2c; uint8_t exp_dev_addr; ExpGpioPinName exp_pin_name; }; @@ -217,9 +217,8 @@ * @param[in] &i2c device I2C to be used for communication * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS) */ - Stmpe1600(DevI2C &i2c, uint8_t dev_addr = STMPE1600_DEF_DEVICE_ADDRESS) : dev_i2c(i2c) + Stmpe1600(DevI2C &i2c, uint8_t dev_addr = STMPE1600_DEF_DEVICE_ADDRESS) : dev_i2c(&i2c) { - dev_i2c = i2c; exp_dev_addr = dev_addr; write_sys_ctrl(SOFT_RESET); @@ -235,7 +234,7 @@ */ void write_sys_ctrl(uint8_t data) // data = SOFT_RESET reset the device { - dev_i2c.i2c_write(&data, exp_dev_addr, SYS_CTRL, 1); + dev_i2c->i2c_write(&data, exp_dev_addr, SYS_CTRL, 1); } /** @@ -306,7 +305,7 @@ */ void read_16bit_reg(uint8_t reg16_addr, uint16_t *reg16_data) { - dev_i2c.i2c_read((uint8_t *) reg16_data, exp_dev_addr, reg16_addr, 2); + dev_i2c->i2c_read((uint8_t *) reg16_data, exp_dev_addr, reg16_addr, 2); } /** @@ -316,11 +315,11 @@ */ void write_16bit_reg(uint8_t reg16_addr, uint16_t *reg16_data) { - dev_i2c.i2c_write((uint8_t *) reg16_data, exp_dev_addr, reg16_addr, 2); + dev_i2c->i2c_write((uint8_t *) reg16_data, exp_dev_addr, reg16_addr, 2); } private: - DevI2C &dev_i2c; + DevI2C *dev_i2c; uint16_t gpdr0_15; // local copy of bit direction reg uint16_t gpsr0_15; // local copy of bit status reg uint8_t exp_dev_addr; // expander device i2c addr