uTL
micro Template library
utl::_1wire_i< virtual_tag > Class Template Referenceabstract

A virtual base class implementation. More...

#include <_1wire.h>

Inheritance diagram for utl::_1wire_i< virtual_tag >:
utl::_1wire_uart_i< virtual_tag >

Public Types

enum  Speed { Speed::STD =0, Speed::OVDR }
 1-wire bus speed More...
 
using type = _1wire_i< virtual_tag >
 Export type as identity meta-function. More...
 

Public Member Functions

User functionality provided by the interface
bool reset (Speed s=Speed::STD)
 Generate a 1-wire reset. More...
 
byte_t tx_data (byte_t out, Speed s=Speed::STD)
 
size_t tx_data (const byte_t *out, byte_t *in, size_t n, Speed s=Speed::STD)
 
byte_t rx_data (Speed s=Speed::STD)
 
size_t rx_data (byte_t *in, size_t n, Speed s=Speed::STD)
 
void match (_1wire_id_t &id, Speed s=Speed::STD)
 
void match_n_ovdr (_1wire_id_t &id)
 
void skip (Speed s=Speed::STD)
 
void skip_n_ovdr ()
 
_1wire_id_t first (Speed s=Speed::STD, bool alarm=false)
 'first' operation, to search on the 1-Wire for the first device. This is performed by setting dec_, pos_ and cur_ to zero and then doing the search. More...
 
_1wire_id_t next (Speed s=Speed::STD, bool alarm=false)
 'next' operation, to search on the 1-Wire for the next device. This search is usually performed after a 'first' operation or another 'next' operation. Based on maxim-ic application note 187. More...
 

Private Member Functions

Implementation requirements
virtual Speed speed () const =0
 Get the 1-wire bus speed. More...
 
virtual void speed (Speed)=0
 Set the 1-wire bus speed. More...
 
virtual bool bit ()=0
 Read a bit from the 1-Wire bus, return it and provide the recovery time. More...
 
virtual bool bit (bool)=0
 Write a bit to the 1-Wire bus, return write status and provide the recovery time. More...
 
virtual bool _reset (Speed)=0
 

Private Attributes

_1wire_id_t dec_ {_1wire_id_t::nullDev()}
 
_1wire_id_t pos_ {_1wire_id_t::nullDev()}
 
_1wire_id_t cur_ {_1wire_id_t::nullDev()}
 

Object lifetime

 _1wire_i ()=default
 Allow constructor from derived only. More...
 
 _1wire_i (const type &)=delete
 No copies. More...
 
typeoperator= (const type &)=delete
 
virtual ~_1wire_i ()=default
 

Friends api to provide functionality to all class specializations

enum  Command {
  CMD_READ_ROM = 0x33, CMD_OVDR_SKIP = 0x3C, CMD_MATCH = 0x55, CMD_OVDR_MATCH = 0x69,
  CMD_SKIP = 0xCC, CMD_ALARM_SEARCH = 0xEC, CMD_SEARCH_ROM = 0xF0
}
 
template<typename _T >
byte_t _1wire_i_det::_touch (_T &, byte_t, typename _T::Speed)
 
template<typename _T >
void _1wire_i_det::_match (_T &obj, _1wire_id_t &id, typename _T::Speed s)
 
template<typename _T >
void _1wire_i_det::_match_n_ovdr (_T &obj, _1wire_id_t &id)
 
template<typename _T >
void _1wire_i_det::_skip (_T &obj, typename _T::Speed s)
 
template<typename _T >
void _1wire_i_det::_skip_n_ovdr (_T &obj)
 
template<typename _T >
_1wire_id_t _1wire_i_det::_first (_T &, typename _T::Speed, bool)
 
template<typename _T >
_1wire_id_t _1wire_i_det::_next (_T &, typename _T::Speed, bool)
 

Detailed Description

template<>
class utl::_1wire_i< virtual_tag >

A virtual base class implementation.

Parameters
impl_t= virtual_tag

Definition at line 260 of file _1wire.h.

Member Typedef Documentation

◆ type

Export type as identity meta-function.

Definition at line 262 of file _1wire.h.

Member Enumeration Documentation

◆ Command

enum utl::_1wire_i< virtual_tag >::Command
private
Enumerator
CMD_READ_ROM 
CMD_OVDR_SKIP 
CMD_MATCH 
CMD_OVDR_MATCH 
CMD_SKIP 
CMD_ALARM_SEARCH 
CMD_SEARCH_ROM 

Definition at line 296 of file _1wire.h.

◆ Speed

enum utl::_1wire_i< virtual_tag >::Speed
strong

1-wire bus speed

Enumerator
STD 
OVDR 

Definition at line 265 of file _1wire.h.

Constructor & Destructor Documentation

◆ _1wire_i() [1/2]

utl::_1wire_i< virtual_tag >::_1wire_i ( )
protecteddefault

Allow constructor from derived only.

◆ _1wire_i() [2/2]

utl::_1wire_i< virtual_tag >::_1wire_i ( const type )
protecteddelete

No copies.

◆ ~_1wire_i()

virtual utl::_1wire_i< virtual_tag >::~_1wire_i ( )
virtualdefault

Virtual default destructor

Member Function Documentation

◆ _reset()

virtual bool utl::_1wire_i< virtual_tag >::_reset ( Speed  )
privatepure virtual

Generate a 1-wire reset and return the operation status

Implemented in utl::_1wire_uart_i< virtual_tag >.

◆ bit() [1/2]

virtual bool utl::_1wire_i< virtual_tag >::bit ( )
privatepure virtual

Read a bit from the 1-Wire bus, return it and provide the recovery time.

◆ bit() [2/2]

virtual bool utl::_1wire_i< virtual_tag >::bit ( bool  )
privatepure virtual

Write a bit to the 1-Wire bus, return write status and provide the recovery time.

Implemented in utl::_1wire_uart_i< virtual_tag >.

◆ first()

_1wire_id_t utl::_1wire_i< virtual_tag >::first ( Speed  s = Speed::STD,
bool  alarm = false 
)
inline

'first' operation, to search on the 1-Wire for the first device. This is performed by setting dec_, pos_ and cur_ to zero and then doing the search.

Parameters
sThe bus speed
alarmIf set, search for alarm devices
Returns
ID The romID
  • nullDev Indicate no [more] device[s]

Definition at line 406 of file _1wire.h.

◆ match()

void utl::_1wire_i< virtual_tag >::match ( _1wire_id_t id,
Speed  s = Speed::STD 
)
inline

Send match rom command

Parameters
idThe ID to select on the bus
sThe speed to use for the command

Definition at line 372 of file _1wire.h.

◆ match_n_ovdr()

void utl::_1wire_i< virtual_tag >::match_n_ovdr ( _1wire_id_t id)
inline

Match and overdrive sequence

Parameters
objThe object from which we call private members
idThe ID to select on the bus

Definition at line 380 of file _1wire.h.

◆ next()

_1wire_id_t utl::_1wire_i< virtual_tag >::next ( Speed  s = Speed::STD,
bool  alarm = false 
)
inline

'next' operation, to search on the 1-Wire for the next device. This search is usually performed after a 'first' operation or another 'next' operation. Based on maxim-ic application note 187.

Parameters
sThe bus speed
alarmIf set, search for alarm devices
Returns
ID The romID
  • nullDev Indicate no [more] device[s]

Definition at line 419 of file _1wire.h.

◆ operator=()

type& utl::_1wire_i< virtual_tag >::operator= ( const type )
protecteddelete

◆ reset()

bool utl::_1wire_i< virtual_tag >::reset ( Speed  s = Speed::STD)
inline

Generate a 1-wire reset.

Parameters
sBus speed
Returns
The status of the operation
  • 0 Fail
  • 1 Success

Definition at line 327 of file _1wire.h.

◆ rx_data() [1/2]

byte_t utl::_1wire_i< virtual_tag >::rx_data ( Speed  s = Speed::STD)
inline

Receive a byte from 1-Wire bus while transmitting 0xFF

Parameters
sBus speed to use
Returns
The byte received.

Definition at line 355 of file _1wire.h.

◆ rx_data() [2/2]

size_t utl::_1wire_i< virtual_tag >::rx_data ( byte_t in,
size_t  n,
Speed  s = Speed::STD 
)

Receive a number of bytes from 1-wire bus while transmitting 0xFFs

Parameters
inPointer to data to store
nNumber of bytes
sSpeed to use
Returns
The number of transmitted bytes

Definition at line 446 of file _1wire.h.

◆ skip()

void utl::_1wire_i< virtual_tag >::skip ( Speed  s = Speed::STD)
inline

Send skip command to the bus

Parameters
idThe ID to select on the bus

Definition at line 387 of file _1wire.h.

◆ skip_n_ovdr()

void utl::_1wire_i< virtual_tag >::skip_n_ovdr ( )
inline

Send the Skip and Overdrive sequence

Definition at line 393 of file _1wire.h.

◆ speed() [1/2]

virtual Speed utl::_1wire_i< virtual_tag >::speed ( ) const
privatepure virtual

Get the 1-wire bus speed.

Implemented in utl::_1wire_uart_i< virtual_tag >.

◆ speed() [2/2]

virtual void utl::_1wire_i< virtual_tag >::speed ( Speed  )
privatepure virtual

Set the 1-wire bus speed.

Implemented in utl::_1wire_uart_i< virtual_tag >.

◆ tx_data() [1/2]

byte_t utl::_1wire_i< virtual_tag >::tx_data ( byte_t  out,
Speed  s = Speed::STD 
)
inline

Transmit a byte to 1-Wire bus and read the response

Parameters
outThe byte to write
sBus speed to use
Returns
The byte received.

Definition at line 337 of file _1wire.h.

◆ tx_data() [2/2]

size_t utl::_1wire_i< virtual_tag >::tx_data ( const byte_t out,
byte_t in,
size_t  n,
Speed  s = Speed::STD 
)

Transmit a number of bytes to 1-wire bus and read the response

Parameters
outPointer to data to transmit
inPointer to data to store
nNumber of bytes
sSpeed to use
Returns
The number of transmitted bytes

Definition at line 440 of file _1wire.h.

Friends And Related Function Documentation

◆ _1wire_i_det::_first

template<typename _T >
_1wire_id_t _1wire_i_det::_first ( _T &  ,
typename _T::Speed  ,
bool   
)
friend

◆ _1wire_i_det::_match

template<typename _T >
void _1wire_i_det::_match ( _T &  obj,
_1wire_id_t id,
typename _T::Speed  s 
)
friend

◆ _1wire_i_det::_match_n_ovdr

template<typename _T >
void _1wire_i_det::_match_n_ovdr ( _T &  obj,
_1wire_id_t id 
)
friend

◆ _1wire_i_det::_next

template<typename _T >
_1wire_id_t _1wire_i_det::_next ( _T &  ,
typename _T::Speed  ,
bool   
)
friend

◆ _1wire_i_det::_skip

template<typename _T >
void _1wire_i_det::_skip ( _T &  obj,
typename _T::Speed  s 
)
friend

◆ _1wire_i_det::_skip_n_ovdr

template<typename _T >
void _1wire_i_det::_skip_n_ovdr ( _T &  obj)
friend

◆ _1wire_i_det::_touch

template<typename _T >
byte_t _1wire_i_det::_touch ( _T &  ,
byte_t  ,
typename _T::Speed   
)
friend

Member Data Documentation

◆ cur_

Definition at line 436 of file _1wire.h.

◆ dec_

Hold the algorithm's select bit when a discrepancy is detected. We use this variable to navigate to the ROM tree as we store the path we take each time (0-1). Each bit represent a bit position in the ROM ID.

Definition at line 425 of file _1wire.h.

◆ pos_

Hold the discrepancy position. We use this variable to navigate to the ROM tree as we store the crossroads(1) we encounter. Each bit represent a bit position in the ROM ID.

Definition at line 431 of file _1wire.h.


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