Tom N / LidarSpi

Dependents:   MLX75320_API

Embed: (wiki syntax)

« Back to documentation index

LidarSpi Class Reference

LidarSpi Class Reference

LidarSpi class This class defines methods and structs to interface with the MLX75320 lidar sensing product. More...

#include <LidarSpi.h>

Public Types

enum  eASICREG
 

Lists all registers.

More...
enum  PackType {
  PACK_RREG = 0, PACK_WREG, PACK_RFIRM, PACK_WFIRM,
  PACK_STATUS_S, PACK_STATUS_L, PACK_RDATA_RESP_S, PACK_RDATA_RESP_L,
  PACK_WDATA_L
}

Public Member Functions

 LidarSpi (PinName mosi, PinName miso, PinName clk, PinName chipSelect, PinName dr, PinName rs, PinName tr, PinName smpl)
 Constructor.
int SpiSetting (long freq, int mode, Serial *pc)
 SpiSetting Change frequency and SPI mode(clock phase and polarity)
int ReadReg (uint32_t reg, uint32_t *val)
 ReadReg Read register at address.
int WriteReg (uint32_t reg, uint32_t val)
 WriteReg Write register to address.
int GetEchoes (Echo *ech, uint16_t maxN)
 GetEchoes Perform measurement and read processed data.
int GetEchoes (Echo *ech, uint16_t maxN, Serial *pc)
 GetEchoes Perform measurement and read processed data.
int GetTrace (uint16_t *buf, uint16_t maxN, Serial *pc)
 GetTrace Perform measurement and read raw trace buffer.
int LoadPatch (const char *patch, Serial *pc)
 LoadPatch Load patch stored on mbed Flash memory in MLX75320 and enable patch.
int setTrace (void)
 SetTrace Set a variety of registers according to the preset values for a raw data measurement.
int setEcho (void)
 SetTrace Set a variety of registers according to the preset values for a processed data measurement.
int setLed (bool state)
 SetLed Set a variety of registers according to the preset values to either fire or don't fire the LEDs during a measurement.
int ReadReg (uint32_t reg, uint32_t *val, Serial *pc)
 ReadReg (overloaded) Read register at address.
int WriteReg (uint32_t reg, uint32_t val, Serial *pc)
 WriteReg Write register to address.
int GetTraceOne (uint16_t *buf, uint16_t maxN, uint16_t nSam, uint16_t idx, int index, Serial *pc)
 GetTraceOne Perform measurement and read raw trace buffer, this method only reads back a single SPI packet.
void Trigger (int level)
 Trigger Change pin to high or low to use as trigger point for oscilloscope.

Detailed Description

LidarSpi class This class defines methods and structs to interface with the MLX75320 lidar sensing product.

Definition at line 13 of file LidarSpi.h.


Member Enumeration Documentation

enum eASICREG

Lists all registers.

Enum value is directly the register address. Naming convention: REG_ + <name> + <L/H> + <#> <name> = name of register <L/H> = optional low or high register part <#> = optional number, either for acquisition source 0/1 or index

Definition at line 62 of file LidarSpi.h.

enum PackType
Enumerator:
PACK_RREG 

Read register request.

PACK_WREG 

Write register request.

PACK_RFIRM 

Read firmware request.

PACK_WFIRM 

Write firmware request.

PACK_STATUS_S 

Status short.

PACK_STATUS_L 

Status long.

PACK_RDATA_RESP_S 

Read data response short.

PACK_RDATA_RESP_L 

Read data response long.

PACK_WDATA_L 

Write data long.

Definition at line 130 of file LidarSpi.h.


Constructor & Destructor Documentation

LidarSpi ( PinName  mosi,
PinName  miso,
PinName  clk,
PinName  chipSelect,
PinName  dr,
PinName  rs,
PinName  tr,
PinName  smpl 
)

Constructor.

Parameters:
pin names for mosi, miso, clk, chipselect, dataready, reset, trigger and sample

Definition at line 18 of file LidarSpi.cpp.


Member Function Documentation

int GetEchoes ( Echo *  ech,
uint16_t  maxN 
)

GetEchoes Perform measurement and read processed data.

Parameters:
pointer to Echo structure array to store measurement, structure array size (must be >=64)
Returns:
: 0 on success

Definition at line 351 of file LidarSpi.cpp.

int GetEchoes ( Echo *  ech,
uint16_t  maxN,
Serial *  pc 
)

GetEchoes Perform measurement and read processed data.

Parameters:
pointer to Echo structure array to store measurement, structure array size (must be >=64), pointer to serial interface for debugging
Returns:
: 0 on success

Definition at line 492 of file LidarSpi.cpp.

int GetTrace ( uint16_t *  buf,
uint16_t  maxN,
Serial *  pc 
)

GetTrace Perform measurement and read raw trace buffer.

Parameters:
pointer to int array to store trace buffer, structure array size (must be >=9472*2), pointer to serial interface for debugging
Returns:
: 0 on success

Definition at line 703 of file LidarSpi.cpp.

int GetTraceOne ( uint16_t *  buf,
uint16_t  maxN,
uint16_t  nSam,
uint16_t  idx,
int  index,
Serial *  pc 
)

GetTraceOne Perform measurement and read raw trace buffer, this method only reads back a single SPI packet.

Parameters:
pointer to int array to store trace buffer, structure array size (must be >=9472*2), pointer to serial interface for debugging
Returns:
: 0 on success

Definition at line 896 of file LidarSpi.cpp.

int LoadPatch ( const char *  patch,
Serial *  pc 
)

LoadPatch Load patch stored on mbed Flash memory in MLX75320 and enable patch.

Parameters:
path of patch.hex location, , pointer to serial interface for debugging
Returns:
: 0 on success

Definition at line 1110 of file LidarSpi.cpp.

int ReadReg ( uint32_t  reg,
uint32_t *  val 
)

ReadReg Read register at address.

Parameters:
register address, pointer to variable to register valueresult
Returns:
: 0 on success

Definition at line 126 of file LidarSpi.cpp.

int ReadReg ( uint32_t  reg,
uint32_t *  val,
Serial *  pc 
)

ReadReg (overloaded) Read register at address.

Parameters:
register address, pointer to variable to register valueresult, pointer to serial interface for debugging
Returns:
: 0 on success

Definition at line 161 of file LidarSpi.cpp.

int setEcho ( void   )

SetTrace Set a variety of registers according to the preset values for a processed data measurement.

Returns:
: 0 on success

Definition at line 1563 of file LidarSpi.cpp.

int setLed ( bool  state )

SetLed Set a variety of registers according to the preset values to either fire or don't fire the LEDs during a measurement.

Parameters:
True to enable LEDs, False to disable

Definition at line 1635 of file LidarSpi.cpp.

int setTrace ( void   )

SetTrace Set a variety of registers according to the preset values for a raw data measurement.

Returns:
: 0 on success

Definition at line 1468 of file LidarSpi.cpp.

int SpiSetting ( long  freq,
int  mode,
Serial *  pc 
)

SpiSetting Change frequency and SPI mode(clock phase and polarity)

Parameters:
frequency in Hz, mode ranging from 0 to 3, pointer to Serial interface for debugging
Returns:
: 0 on success

Definition at line 43 of file LidarSpi.cpp.

void Trigger ( int  level )

Trigger Change pin to high or low to use as trigger point for oscilloscope.

Parameters:
1 or 0 to set voltage level

Definition at line 1330 of file LidarSpi.cpp.

int WriteReg ( uint32_t  reg,
uint32_t  val 
)

WriteReg Write register to address.

Parameters:
register address, value to write
Returns:
: 0 on success

Definition at line 234 of file LidarSpi.cpp.

int WriteReg ( uint32_t  reg,
uint32_t  val,
Serial *  pc 
)

WriteReg Write register to address.

Parameters:
register address, value to write, pointer to serial interface for debugging
Returns:
: 0 on success

Definition at line 275 of file LidarSpi.cpp.