Ted Grosch / Mbed 2 deprecated Nucleo_TOF_I2C

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

hostController Class Reference

hostController Class Reference

Generic implementation for host. More...

#include <hostController.h>

Public Member Functions

 hostController (void)
 constructor mostly used to initialize the host
uint32_t readI2C (uint8_t address)
 method to read data from I2C port
void writeI2C (uint8_t address, uint32_t data)
 method to write data from I2C port
void resetDevice ()
 send reset pulse to OPT3101 device Method used to send reset pulse to OPT3101 device
void sleep (uint32_t timeInMilliSeconds)
 sleep host Method used to sleep or make host wait for a particular amount of time specified in milliSeconds
void sleepDataReadyCounts (uint16_t dataReadyCounts)
 sleep host Method used to sleep or make host wait for a particular amount of time specified in number of data ready pulses from OPT3101
void pause ()
 pause host Method used to make host wait for user input or interrupt. Useful for debug
void initialize ()
 initialize host Method to initialize host. Especially for MSP like hosts.
void printf (const char *fmt,...)
 print message Method to print message on host to user
void printfSetColor (uint8_t color=0xFF)
 print Sets color for terminal Method sets colors for terminals

Detailed Description

Generic implementation for host.

As part of OPT3101SDK there are several host specific functions that need to be performed. Examples of such functions are writing or reading from I2C ports, sending reset pulse to OPT3101 device
These implementations are very specific to the host on which the SDK is ported and run.
This abstract class provides a template with self explanatory method names which the users can override and implement their own functions.
Example code is provided for OPT3101EVM with implementations for a windows 10 PC.

Definition at line 105 of file hostController.h.


Constructor & Destructor Documentation

hostController ( void   )

constructor mostly used to initialize the host

Method to mostly initialize host. Especially for MSP like hosts.

Returns:
Nothing

Definition at line 63 of file hostController.cpp.


Member Function Documentation

void initialize (  )

initialize host Method to initialize host. Especially for MSP like hosts.

Returns:
Nothing

Algorithm of the method is as follows

* Creates a command which specifies host to send RESET Pulse to OPT3101 h/w

* Send the RESET command to the h/w

Definition at line 215 of file hostController.cpp.

void pause (  )

pause host Method used to make host wait for user input or interrupt. Useful for debug

Returns:
Nothing

Algorithm of the method is as follows

Definition at line 137 of file hostController.cpp.

void printf ( const char *  fmt,
  ... 
)

print message Method to print message on host to user

Returns:
Nothing

Definition at line 245 of file hostController.cpp.

void printfSetColor ( uint8_t  color = 0xFF )

print Sets color for terminal Method sets colors for terminals

Returns:
Nothing

Definition at line 160 of file hostController.cpp.

uint32_t readI2C ( uint8_t  address )

method to read data from I2C port

Parameters:
[in]address;address is the I2C register address
Returns:
value; value read from I2C port for the address

Algorithm of the method is as follows

* Returns the data in uint32_t format

Definition at line 83 of file hostController.cpp.

void resetDevice (  )

send reset pulse to OPT3101 device Method used to send reset pulse to OPT3101 device

Returns:
Nothing

Algorithm of the method is as follows

* Creates a command which specifies host to send RESET Pulse to OPT3101 h/w

* Send the RESET command to the h/w

Definition at line 199 of file hostController.cpp.

void sleep ( uint32_t  timeInMilliSeconds )

sleep host Method used to sleep or make host wait for a particular amount of time specified in milliSeconds

Parameters:
[in]timeInMilliSeconds;Time for which the host needs to sleep specified in milliSeconds
Returns:
Nothing

Algorithm of the method is as follows

Definition at line 117 of file hostController.cpp.

void sleepDataReadyCounts ( uint16_t  dataReadyCounts )

sleep host Method used to sleep or make host wait for a particular amount of time specified in number of data ready pulses from OPT3101

Parameters:
[in]dataReadyCounts;Time for which the host needs to sleep specified data ready pulses from OPT3101
Returns:
Nothing

Algorithm of the method is as follows Currently empty function needs to be implemented by user. Based on interrupts from data ready signal from OPT3101, the host needs to count those pulses and wait until dataReadyCounts have reached.

Definition at line 132 of file hostController.cpp.

void writeI2C ( uint8_t  address,
uint32_t  data 
)

method to write data from I2C port

Parameters:
[in]address;address is the I2C register address
[in]data;data to write to I2C register
Returns:
Nothing

Algorithm of the method is as follows

Definition at line 69 of file hostController.cpp.