TFmini(Micro LiDAR Module) library tested on mbedos5.x

Dependents:   2018NHK_gakugaku_robo 2018NHK_gaku_ver2 2019NHK_A_sensor

Committer:
highfieldsnj
Date:
Mon Jun 24 08:59:14 2019 +0000
Revision:
7:81f9d1372c45
Parent:
6:3651a37efd0e
fix

Who changed what in which revision?

UserRevisionLine numberNew contents of line
UCHITAKE 0:fe2031b62770 1 #ifndef TFMINI_H
UCHITAKE 0:fe2031b62770 2 #define TFMINI_H
UCHITAKE 0:fe2031b62770 3
UCHITAKE 0:fe2031b62770 4 #include "mbed.h"
UCHITAKE 0:fe2031b62770 5
takeuchi 1:12f2bfb3577a 6 #define TF_SERIAL_BUFFER_SIZE 9
takeuchi 1:12f2bfb3577a 7 #define TF_HEADER_FIRST_BYTE 0x59
takeuchi 1:12f2bfb3577a 8 #define TF_HEADER_SECOND_BYTE 0x59
takeuchi 1:12f2bfb3577a 9 #define TF_DEFAULT_BAUD 115200
UCHITAKE 0:fe2031b62770 10
highfieldsnj 7:81f9d1372c45 11 class TFmini : public RawSerial
highfieldsnj 7:81f9d1372c45 12 {
highfieldsnj 7:81f9d1372c45 13 public :
highfieldsnj 7:81f9d1372c45 14 TFmini(PinName serialTX, PinName serialRX);
UCHITAKE 0:fe2031b62770 15
highfieldsnj 7:81f9d1372c45 16 int getDistance();
highfieldsnj 7:81f9d1372c45 17 int getStrength();
UCHITAKE 6:3651a37efd0e 18
highfieldsnj 7:81f9d1372c45 19 private :
highfieldsnj 7:81f9d1372c45 20 void receiveByte();
highfieldsnj 7:81f9d1372c45 21 void checkData();
highfieldsnj 7:81f9d1372c45 22 void assemble();
highfieldsnj 7:81f9d1372c45 23
highfieldsnj 7:81f9d1372c45 24 int distance;
highfieldsnj 7:81f9d1372c45 25 int strength;
highfieldsnj 7:81f9d1372c45 26 uint8_t reserved;
highfieldsnj 7:81f9d1372c45 27 uint8_t rawQual;
UCHITAKE 6:3651a37efd0e 28
highfieldsnj 7:81f9d1372c45 29 uint8_t buffer[TF_SERIAL_BUFFER_SIZE];
highfieldsnj 7:81f9d1372c45 30 uint8_t data[TF_SERIAL_BUFFER_SIZE - 3];
highfieldsnj 7:81f9d1372c45 31 //uint8_t mask;
highfieldsnj 7:81f9d1372c45 32 uint8_t bufferPoint;
highfieldsnj 7:81f9d1372c45 33 uint8_t receivedBytes;
highfieldsnj 7:81f9d1372c45 34
UCHITAKE 0:fe2031b62770 35 };
UCHITAKE 0:fe2031b62770 36
takeuchi 1:12f2bfb3577a 37 #endif