|
IoT-MBBR (masterthesis)
Masterthesis upgrading a Moving Bed BioReactor with extra sensors and cloud connectivity.
|
Platform-specific implementation for using the VL53L1X API on the EFM32HG322. More...
#include "vl53l1_platform.h"#include <string.h>#include <time.h>#include <math.h>#include "em_cmu.h"#include "em_gpio.h"#include "em_i2c.h"#include "debug_dbprint.h"#include "i2c.h"Go to the source code of this file.
Functions | |
| int8_t | VL53L1_WriteMulti (uint16_t dev, uint16_t index, uint8_t *pdata, uint32_t count) |
| This method is not used by the API and thereby not implemented. More... | |
| int8_t | VL53L1_ReadMulti (uint16_t dev, uint16_t index, uint8_t *pdata, uint32_t count) |
| TODO. More... | |
| int8_t | VL53L1_WrByte (uint16_t dev, uint16_t index, uint8_t data) |
| Write a byte (8 bits) to the I2C bus. More... | |
| int8_t | VL53L1_WrWord (uint16_t dev, uint16_t index, uint16_t data) |
| Write a word (16 bits) to the I2C bus. More... | |
| int8_t | VL53L1_WrDWord (uint16_t dev, uint16_t index, uint32_t data) |
| Write a double word (32 bits) to the I2C bus. More... | |
| int8_t | VL53L1_RdByte (uint16_t dev, uint16_t index, uint8_t *data) |
| Read a byte (8 bits) from the I2C bus. More... | |
| int8_t | VL53L1_RdWord (uint16_t dev, uint16_t index, uint16_t *data) |
| Read a word (16 bits) from the I2C bus. More... | |
| int8_t | VL53L1_RdDWord (uint16_t dev, uint16_t index, uint32_t *data) |
| Read a double word (32 bits) from the I2C bus. More... | |
| int8_t | VL53L1_WaitMs (uint16_t dev, int32_t wait_ms) |
| This method is not used by the API and thereby not implemented. More... | |
Platform-specific implementation for using the VL53L1X API on the EFM32HG322.
Copyright (C) 2019 - Brecht Van Eeckhoudt
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A copy of the GNU General Public License can be found in the LICENSE file along with this source code.
Some methods use code obtained from examples from Silicon Labs' GitHub. These sections are licensed under the Silabs License Agreement. See the file "Silabs_License_Agreement.txt" for details. Before using this software for any purpose, you must agree to the terms of that agreement.
This file is part of VL53L1 Platform, the method names remained but they were filled in with code by Brecht Van Eeckhoudt.
Copyright (c) 2016, STMicroelectronics - All Rights Reserved
License terms: BSD 3-clause "New" or "Revised" License.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file vl53l1_platform.c.
Read a byte (8 bits) from the I2C bus.
VL53L1_RdByte() definition.
To be implemented by the developer.
This method also initializes i2C if necessary.
| [in] | dev | Device ID (uint16_t). |
| [in] | index | Index (uint16_t). |
| [in] | data | Pointer to the data (uint8_t) to put the read byte in. |
0 - Byte read correctly. -1 - i2cTransferNack, NACK received during transfer. -2 - i2cTransferBusErr, Bus error during transfer (misplaced START/STOP). -3 - i2cTransferArbLost, Arbitration lost during transfer. -4 - i2cTransferUsageFault, Usage fault. -5 - i2cTransferSwFault, SW fault. -6 - Coudldn't configure I2C. Definition at line 341 of file vl53l1_platform.c.
Read a double word (32 bits) from the I2C bus.
VL53L1_RdDWord() definition.
To be implemented by the developer.
This method also initializes i2C if necessary.
| [in] | dev | Device ID (uint16_t). |
| [in] | index | Index (uint16_t). |
| [in] | data | Pointer to the data (uint32_t) to put the read double word in. |
0 - Double word read correctly. -1 - i2cTransferNack, NACK received during transfer. -2 - i2cTransferBusErr, Bus error during transfer (misplaced START/STOP). -3 - i2cTransferArbLost, Arbitration lost during transfer. -4 - i2cTransferUsageFault, Usage fault. -5 - i2cTransferSwFault, SW fault. -6 - Coudldn't configure I2C. Definition at line 453 of file vl53l1_platform.c.
Read a word (16 bits) from the I2C bus.
VL53L1_RdWord() definition.
To be implemented by the developer.
This method also initializes i2C if necessary.
| [in] | dev | Device ID (uint16_t). |
| [in] | index | Index (uint16_t). |
| [in] | data | Pointer to the data (uint16_t) to put the read word in. |
0 - Word read correctly. -1 - i2cTransferNack, NACK received during transfer. -2 - i2cTransferBusErr, Bus error during transfer (misplaced START/STOP). -3 - i2cTransferArbLost, Arbitration lost during transfer. -4 - i2cTransferUsageFault, Usage fault. -5 - i2cTransferSwFault, SW fault. -6 - Coudldn't configure I2C. Definition at line 394 of file vl53l1_platform.c.
TODO.
VL53L1_ReadMulti() definition.
To be implemented by the developer.
This method also initializes i2C if necessary.
This method is only used in VL53L1X_GetResult.
| [in] | dev | Device ID (uint16_t). |
| [in] | index | Index (uint16_t). |
| [in] | pdata | Pointer to the data (uint8_t) to put the read bytes in. |
| [in] | count | Counter (uint32_t). |
0 - TODO -1 - i2cTransferNack, NACK received during transfer. -2 - i2cTransferBusErr, Bus error during transfer (misplaced START/STOP). -3 - i2cTransferArbLost, Arbitration lost during transfer. -4 - i2cTransferUsageFault, Usage fault. -5 - i2cTransferSwFault, SW fault. -6 - Coudldn't configure I2C. Definition at line 134 of file vl53l1_platform.c.
This method is not used by the API and thereby not implemented.
VL53L1_WaitMs() definition.
To be implemented by the developer.
Definition at line 491 of file vl53l1_platform.c.
Write a byte (8 bits) to the I2C bus.
VL53L1_WrByte() definition.
To be implemented by the developer.
This method also initializes i2C if necessary.
| [in] | dev | Device ID (uint16_t). |
| [in] | index | Index (uint16_t). |
| [in] | data | The data (uint8_t) to put on the I2C bus. |
0 - Byte written correctly. -1 - i2cTransferNack, NACK received during transfer. -2 - i2cTransferBusErr, Bus error during transfer (misplaced START/STOP). -3 - i2cTransferArbLost, Arbitration lost during transfer. -4 - i2cTransferUsageFault, Usage fault. -5 - i2cTransferSwFault, SW fault. -6 - Coudldn't configure I2C. Definition at line 173 of file vl53l1_platform.c.
Write a double word (32 bits) to the I2C bus.
VL53L1_WrDWord() definition.
To be implemented by the developer.
This method also initializes i2C if necessary.
| [in] | dev | Device ID (uint16_t). |
| [in] | index | Index (uint16_t). |
| [in] | data | The data (uint32_t) to put on the I2C bus. |
0 - Double word written correctly. -1 - i2cTransferNack, NACK received during transfer. -2 - i2cTransferBusErr, Bus error during transfer (misplaced START/STOP). -3 - i2cTransferArbLost, Arbitration lost during transfer. -4 - i2cTransferUsageFault, Usage fault. -5 - i2cTransferSwFault, SW fault. -6 - Coudldn't configure I2C. Definition at line 285 of file vl53l1_platform.c.
This method is not used by the API and thereby not implemented.
VL53L1_WriteMulti() definition.
To be implemented by the developer.
Definition at line 93 of file vl53l1_platform.c.
Write a word (16 bits) to the I2C bus.
VL53L1_WrWord() definition.
To be implemented by the developer.
This method also initializes i2C if necessary.
| [in] | dev | Device ID (uint16_t). |
| [in] | index | Index (uint16_t). |
| [in] | data | The data (uint16_t) to put on the I2C bus. |
0 - Word written correctly. -1 - i2cTransferNack, NACK received during transfer. -2 - i2cTransferBusErr, Bus error during transfer (misplaced START/STOP). -3 - i2cTransferArbLost, Arbitration lost during transfer. -4 - i2cTransferUsageFault, Usage fault. -5 - i2cTransferSwFault, SW fault. -6 - Coudldn't configure I2C. Definition at line 229 of file vl53l1_platform.c.