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: X_NUCLEO_6180XA1 mbed
Fork of HelloWorld_6180XA1 by
Diff: main.cpp
- Revision:
- 5:fa65d931bd96
- Parent:
- 4:ccd62fd7e137
- Child:
- 6:f253ca7919af
diff -r ccd62fd7e137 -r fa65d931bd96 main.cpp
--- a/main.cpp Thu Sep 17 10:43:27 2015 +0200
+++ b/main.cpp Fri Sep 25 12:14:00 2015 +0200
@@ -1,18 +1,92 @@
#include "mbed.h"
#include "vl6180x_class.h"
+#include "STMPE1600_class.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
+#define VL6180X_I2C_SDA I2C_SDA
+#define VL6180X_I2C_SCL I2C_SCL
+
+
+/* Enable e disable function -------------------------------------------------------*/
+#define EXPANDER_I2C_ADDRESS (0x42*2)
+#define GPMR 0x10
+#define GPSR 0x12
+#define GPDR 0x14
+
+#define V2_CHIPEN (1<<12)
+#define V2_CHIPEN_B (1<<13)
+#define V2_CHIPEN_L (1<<14)
+#define V2_CHIPEN_R (1<<15)
+
+/*----------------------------------------------------------------------------------*/
+
void OnErrLog(void){};
+void DISP_ExecLoopBody(void){};
int main()
-{
- DevI2C device_i2c(I2C_SDA, I2C_SCL);
- VL6180X *sensor1 = new VL6180X(device_i2c);
-
-
- sensor1->Init();
- sensor1->ReadID();
+{
+ uint8_t buf[8]={1,1,0,0,0,0,0,0};
+
+
+ uint8_t x=0xFF;
+ uint8_t y=0xF7;
+ uint8_t z=0x80;
+ uint8_t k=0x17;
+ uint8_t g=0xE7;
+
+ DevI2C device_i2c(VL6180X_I2C_SDA, VL6180X_I2C_SCL);
+ STMPE1600DigiOut exp(device_i2c, GPIO_12, STMPE1600_DEF_DEVICE_ADDRESS);
+ VL6180X sensor1(device_i2c, exp);
+
+
+ //imposto GPIO di input e output
+ device_i2c.i2c_write(&x, 0x42*2, 0x14, 1);
+ device_i2c.i2c_write(&y, 0x42*2, 0x15, 1);
+ //disabilito i display e abilito il GPIO0 del sensore top
+ device_i2c.i2c_write(&z, 0x42*2, 0x12, 1);
+ device_i2c.i2c_write(&g, 0x42*2, 0x13, 1); //spengo gpio0
+ device_i2c.i2c_write(&k, 0x42*2, 0x13, 1); //accendo gpio0
+
+ //VL6180x_I2CRead(0x29, (uint16_t)0x000, buf, 2);
+ //VL6180x_I2CRead(0x29, (uint16_t)0x212, buf+1, 2);
+ //buf[2]=0x32;
+ //VL6180x_I2CWrite(0x29, (uint16_t)0x0212, buf+2, 1);
+ //VL6180x_I2CRead(0x32, (uint16_t)0x212, buf+3, 2);
+
+ buf[0]=sensor1.Init();
+ buf[1]=sensor1.ReadID();
+ //buf[2]=sensor1.Prepare();
+ //sensor1.~VL6180X();
+
+
+ /*
+ X_NUCLEO_6180XA1 board;
+
+ status=board.vl6180x_top.RdByte(IDENTIFICATION_MODEL_ID, &buffer);
+ if(!status)
+ {
+ board.vl6180x_top.SetPresent();
+ board.vl6180x_top.SetDeviceID(i);
+ if(!(board.vl6180x_top.Init()||board.vl6180x_top.Prepare()))
+ {
+ board.vl6180x_top.SetReady();
+ status=board.vl6180x_top.SetI2CAddress(final_i2c_address);
+ if(status)
+ errore su scrittura indirizzo i2c
+ }
+ else
+ errore su init o prepare
+ }
+ i++;
+
+ //stessa cosa per gli altri sensori (left, bottom e right)
+
+ */
+
}
+
+
+
