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.
Dependencies: VL6180_Board
spi_interface.cpp
00001 #include "vl6180_I2c.h" 00002 #include "spi_interface.h" 00003 00004 int vl6180_i2c_write_if(uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, 00005 uint16_t NumByteToWrite) 00006 { 00007 00008 static vl6180_DevI2C *dev_I2C = new vl6180_DevI2C(D14, D15); 00009 00010 // dev_I2C->frequency(400000); 00011 00012 00013 int status = dev_I2C->vl6180_i2c_write(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite); 00014 00015 if(status) 00016 { 00017 printf("vl6180_i2c_write_if fail %d \n",DeviceAddr); 00018 00019 return -1; 00020 } 00021 // printf("vl6180_i2c_write_if %d %d %d %d \n",DeviceAddr,RegisterAddr,NumByteToWrite,status); 00022 00023 return status; 00024 } 00025 00026 int vl6180_i2c_write_stmpe1600(uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, 00027 uint16_t NumByteToWrite) 00028 { 00029 00030 static vl6180_DevI2C *dev_I2C = new vl6180_DevI2C(D14, D15); 00031 00032 // dev_I2C->frequency(400000); 00033 00034 00035 int status = dev_I2C->vl6180_i2c_write_stmpe(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite); 00036 00037 if(status) 00038 { 00039 printf("vl6180_i2c_write_stmpe1600 fail %d\n",DeviceAddr); 00040 00041 return -1; 00042 } 00043 // printf("vl6180_i2c_write_stmpe1600 %d %d %d %d \n",DeviceAddr,RegisterAddr,NumByteToWrite,status); 00044 00045 return status; 00046 } 00047 00048 00049 00050 int vl6180_i2c_read_if(uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, 00051 uint16_t NumByteToRead) 00052 { 00053 00054 00055 static vl6180_DevI2C *dev_I2C = new vl6180_DevI2C(D14, D15); 00056 if (dev_I2C == NULL) 00057 { 00058 printf("vl6180_i2c_read_if no pointer%d\n",NumByteToRead); 00059 } 00060 dev_I2C->frequency(400000); 00061 // printf("vl6180_i2c_read_if %d\n",NumByteToRead); 00062 int status = dev_I2C->vl6180_i2c_read(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead); 00063 // printf("vl6180_i2c_read_if %d %d %d %d %d\n",status, DeviceAddr, RegisterAddr,NumByteToRead ,pBuffer[0]); 00064 // delete dev_I2C; 00065 00066 return status; 00067 } 00068 00069 00070 00071 int vl6180_i2c_read_stmpe(uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, 00072 uint16_t NumByteToRead) 00073 { 00074 00075 00076 static vl6180_DevI2C *dev_I2C = new vl6180_DevI2C(D14, D15); 00077 if (dev_I2C == NULL) 00078 { 00079 printf("vl6180_i2c_read_if no pointer%d\n",NumByteToRead); 00080 } 00081 dev_I2C->frequency(400000); 00082 // printf("vl6180_i2c_read_if %d\n",NumByteToRead); 00083 int status = dev_I2C->vl6180_i2c_read_stmpe(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead); 00084 // printf("vl6180_i2c_read_if %d %d %d %d %d\n",status, DeviceAddr, RegisterAddr,NumByteToRead ,pBuffer[0]); 00085 // delete dev_I2C; 00086 00087 return status; 00088 }
Generated on Tue Nov 29 2022 20:47:36 by
1.7.2