MakeBlock Drive Updated
Updated library for MakeBlock Ranger
Loading...
Searching...
No Matches
MeOneWire Class Reference

Driver for 1-wire protocol. More...

#include <src/MeOneWire.h>

Public Member Functions

 MeOneWire (void)
 
 MeOneWire (uint8_t pin)
 
bool readIO (void)
 
void reset (uint8_t pin)
 
uint8_t reset (void)
 
void select (const uint8_t rom[8])
 
void skip (void)
 
void write (uint8_t v, uint8_t power=0)
 
void write_bytes (const uint8_t *buf, uint16_t count, bool power=0)
 
uint8_t read (void)
 
void read_bytes (uint8_t *buf, uint16_t count)
 
void write_bit (uint8_t v)
 
uint8_t read_bit (void)
 
void depower (void)
 
void reset_search (void)
 
void target_search (uint8_t family_code)
 
uint8_t search (uint8_t *newAddr)
 

Detailed Description

Driver for 1-wire protocol.

Class: MeOneWire

Description
Declaration of Class MeOneWire.
Copyright (C), 2012-2016, MakeBlock

Constructor & Destructor Documentation

◆ MeOneWire() [1/2]

MeOneWire::MeOneWire ( void  )

Alternate Constructor which can call your own function to map the MeOneWire to arduino port, no pins are used or initialized here.

Parameters
[in]None

◆ MeOneWire() [2/2]

MeOneWire::MeOneWire ( uint8_t  pin)

Alternate Constructor which can call your own function to map the MeOneWire to arduino port, it will assigned the shot PIN and focus pin.

Parameters
[in]pin- arduino port for 1-wire(should digital pin)

Member Function Documentation

◆ depower()

void MeOneWire::depower ( void  )
Function
depower
Description
Stop forcing power onto the bus. You only need to do this if you used the 'power' flag to write() or used a write_bit() call and aren't about to do another read or write. You would rather not leave this powered if you don't have to, just in case someone shorts your bus.
Output
None
Returns
None
Others
None

◆ read()

uint8_t MeOneWire::read ( void  )
Function
read
Description
Read a byte of data
Output
None
Returns
The read data(8-bit data)
Others
None

◆ read_bit()

uint8_t MeOneWire::read_bit ( void  )
Function
read_bit
Description
Read a bit. Port and bit is used to cut lookup time and provide more certain timing
Output
None
Returns
return the bit value we read
Others
None

◆ read_bytes()

void MeOneWire::read_bytes ( uint8_t *  buf,
uint16_t  count 
)
Function
read_bytes
Description
Read certain number of data
Parameters
[out]buf- The buffer used to store the read data
[in]count- The count of the bytes we need to read
Output
None
Returns
None
Others
None

◆ readIO()

bool MeOneWire::readIO ( void  )
Function
readIO
Description
Read a bit from 1-wire data port
Output
None
Returns
return the bit value we read
Others
None

◆ reset() [1/2]

void MeOneWire::reset ( uint8_t  pin)
Function
reset
Description
Reset the available PIN for 1-wire
Parameters
[in]pin- arduino port(should digital pin)
Output
None
Returns
None
Others
None

◆ reset() [2/2]

uint8_t MeOneWire::reset ( void  )
Function
reset
Description
Perform the MeOneWire reset function. We will wait up to 250uS for the bus to come high, if it doesn't then it is broken or shorted.
Parameters
[in]v- The bit value need be written
Output
None
Returns
Returns 1 if a device asserted a presence pulse, 0 otherwise.
Others
None

◆ reset_search()

void MeOneWire::reset_search ( void  )
Function
reset_search
Description
If we need search a new device, we need call this function to clear the search state and all stored values
Output
Reset all stored values
Returns
None
Others
None

◆ search()

uint8_t MeOneWire::search ( uint8_t *  newAddr)
Function
search
Description
Perform a search. If this function returns a '1' then it has enumerated the next device and you may retrieve the ROM from the MeOneWire::address variable. If there are no devices, no further devices, or something horrible happens in the middle of the enumeration then a '0' is returned. If a new device is found then its address is copied to newAddr. Use MeOneWire::reset_search() to start over. you can get the algorithm from doc\Me_Temperature\Datasheet\1-Wire_Search_Algorithm.pdf
Parameters
[out]newAddr- The adrress to store the ROM data
Output
None
Returns
true - device found, ROM number in ROM_NO buffer\r
 *   false - device not found, end of search
Others
None

◆ select()

void MeOneWire::select ( const uint8_t  rom[8])
Function
select
Description
Issue a 1-Wire rom select command.
Parameters
[in]rom[8]- 64bit ROM code.
Output
None
Returns
None
Others
None

◆ skip()

void MeOneWire::skip ( void  )
Function
skip
Description
Issue a 1-Wire rom skip command.
Output
None
Returns
None
Others
None

◆ target_search()

void MeOneWire::target_search ( uint8_t  family_code)
Function
target_search
Description
Setup the search to find the device type 'family_code' on the next call of search(*newAddr) if it is present.
Parameters
[in]family_code- the device type we need search
Output
None
Returns
None
Others
None

◆ write()

void MeOneWire::write ( uint8_t  v,
uint8_t  power = 0 
)
Function
write
Description
Write a byte of data
Parameters
[in]v- The value need be written
[in]power- Should we need active drivers to raise the pin high
Output
None
Returns
None
Others
None

◆ write_bit()

void MeOneWire::write_bit ( uint8_t  v)
Function
write_bit
Description
Write a bit. The bus is always left powered at the end, see note in write() about that.
Parameters
[in]v- The bit value need be written
Output
None
Returns
None
Others
None

◆ write_bytes()

void MeOneWire::write_bytes ( const uint8_t *  buf,
uint16_t  count,
bool  power = 0 
)
Function
write_bytes
Description
Write certain number of data
Parameters
[in]buf- The buffer used to store the data that need be written
[in]count- The count of the bytes we need to write
[in]power- Should we need active drivers to raise the pin high
Output
None
Returns
None
Others
None

The documentation for this class was generated from the following files: