For coursework of group 3 in SOFT564Z
Dependencies: Motordriver ros_lib_kinetic
VL6180.hpp
- Committer:
- Jonathan738
- Date:
- 2019-12-17
- Revision:
- 10:c752a8d76ee2
- Child:
- 12:82b8fe254222
File content as of revision 10:c752a8d76ee2:
#include "mbed.h" #include "General.hpp" #include "rtos.h" #include "Pins.h" #ifndef Define_ONCE_VL6180 #define Define_ONCE_VL6180 #define num_VL6180 1 #define SHDN_Pins_Cell {PC_9} //, PC_11, PD_2, PG_3} #define TOF_Addresses {0x29} //, 0x2A, 0x2B, 0x2C} #define Shifted_TOF_Addresses {0x82} //, 0x84, 0x86, 0x88} // Thread that runs TOF sensors int TOF_Thread(); // Class Terminal expects tx and rx pins and is used for controlling a serialy conected terminal class VL6180 { public: VL6180(I2C& comm_bus, PinName SHDWN, char Address) : shutdown(SHDWN), i2c(comm_bus){addr = Address;}; bool Init(void); bool TOF_PWR(bool State); void WriteByte(wchar_t reg, char data); void WriteByte_Uninitialized(wchar_t reg, char data, char Uninitialized_Address); int Start_Range(void); int Poll_Range(void); int Read_Range(void); int Clear_Interrupts(void); private: // I2C Bus TOF is connected to I2C& i2c; // Private functions char ReadByte(wchar_t reg); char ReadByte_Uninitialized(wchar_t reg, char Uninitialized_Address); void WriteByte_Uninitialized(wchar_t reg, char data); // Private Variables char addr; // IOs DigitalOut shutdown; }; // TypeDef for pointer to the TOF class (needed for dynamic creation of objects) typedef VL6180* TOFsPtr; // Function to Initialise all TOF sensors bool Init_All_TOFs(TOFsPtr *tof); #endif