Nut/OS  5.0.5
API Reference
One-Wire Bus Controller
Collaboration diagram for One-Wire Bus Controller:

Data Structures

struct  _NUTOWIBUS
 The OWIBUS structure. More...

Modules

 One-Wire Bit-Banging Driver
 

Array of delay values for the different command phases.


 One-Wire UART Driver

Defines

#define OWI_READ_ROM   0x33
 One-Wire command codes for devices.
#define OWI_OVERDRIVE_SKIP_ROM   0x3c
 As OWI_SKIP_ROM, but with command phase in fast mode.
#define OWI_CONVERT_T   0x44
 DS18B20: Start conversion on selected device(s).
#define OWI_MATCH_ROM   0x55
 Qualify command to single device.
#define OWI_OVERDRIVE_MATCH_ROM   0x69
 As OWI_MATCH_ROM but with command phase in fast mode.
#define OWI_SKIP_ROM   0xCC
 Qualify command as broadcast.
#define OWI_READ   0xBE
 Read data from addressed device.
#define OWI_SEARCH_ROM   0xF0
 Prepare devices for ID search.
#define OWI_LAST_DEVICE   0x00
 Constanst used for OwiRomSearch.
#define OWI_SEARCH_FIRST   0xFF
 Start value for ID search.
#define OWI_OVERDRIVE   0x1
 OWI bus modes.
#define OWI_PULLUP   0x2
 Active pull-up for loaded buses.

Typedefs

typedef struct _NUTOWIBUS NUTOWIBUS

Enumerations

enum  OWI_ERRORS {
  OWI_SUCCESS = 0, OWI_PRESENCE_ERR = -1, OWI_INVALID_HW = -2, OWI_OUT_OF_MEM = -3,
  OWI_HW_ERROR = -4, OWI_DATA_ERROR = -5, OWI_NOT_IMPLEMENTED = -6
}
 OWI return codes. More...
enum  OWIBUS_MODE { OWI_MODE_NORMAL = 0, OWI_MODE_OVERDRIVE = 1, OWI_MODE_NONE = 2 }
 OWI speed modes. More...
enum  STM32_OWITIMER_COMMANDS { OWI_CMD_RESET = 0, OWI_CMD_RWBIT = 1, OWI_CMD_NONE = 2 }
 OWI transactions. More...
enum  STM32_OWITIMER_PHASES {
  OWI_PHASE_SETUP = 0, OWI_PHASE_SYNC_PULSE = 1, OWI_PHASE_RW = 2, OWI_PHASE_RELEASE = 3,
  OWI_PHASE_NONE = 4
}
 OWI transactions phases. More...

Functions

int OwiRomSearch (NUTOWIBUS *bus, uint8_t *diff, uint64_t *hid)
 Search the connected One-Wire bus for devices.
int OwiCommand (NUTOWIBUS *bus, uint8_t cmd, uint64_t *hid)
 Send a command to the connected devices.
int OwiReadBlock (NUTOWIBUS *bus, uint8_t *data, uint_fast8_t len)
 Read a block of data.
int OwiWriteBlock (NUTOWIBUS *bus, uint8_t *data, uint_fast8_t len)
 Write a block of data.
int OwiSetMode (NUTOWIBUS *bus, uint_fast8_t mode)
 Set/Reset One-Wire Mode(s)
int OwiGetMode (NUTOWIBUS *bus)
int OWIGetMode (NUTOWIBUS *bus)
 Set/Reset One-Wire Mode(s)

Variables

const uint16_t owi_timervalues_250ns [OWI_MODE_NONE][OWI_CMD_NONE][OWI_PHASE_NONE]

Define Documentation

#define OWI_READ_ROM   0x33

One-Wire command codes for devices.

Read 64-bit serial ID (single device only).

#define OWI_OVERDRIVE_SKIP_ROM   0x3c

As OWI_SKIP_ROM, but with command phase in fast mode.

Referenced by OwiSetMode().

#define OWI_CONVERT_T   0x44

DS18B20: Start conversion on selected device(s).

#define OWI_MATCH_ROM   0x55

Qualify command to single device.

Referenced by OwiCommand().

#define OWI_OVERDRIVE_MATCH_ROM   0x69

As OWI_MATCH_ROM but with command phase in fast mode.

#define OWI_SKIP_ROM   0xCC

Qualify command as broadcast.

Referenced by OwiCommand().

#define OWI_READ   0xBE

Read data from addressed device.

#define OWI_SEARCH_ROM   0xF0

Prepare devices for ID search.

Referenced by OwiRomSearch().

#define OWI_LAST_DEVICE   0x00

Constanst used for OwiRomSearch.

No more devices.

Referenced by OwiRomSearch().

#define OWI_SEARCH_FIRST   0xFF

Start value for ID search.

#define OWI_OVERDRIVE   0x1

OWI bus modes.

Overdrive capable devices on the bus.

Referenced by OwiSetMode().

#define OWI_PULLUP   0x2

Active pull-up for loaded buses.


Typedef Documentation

typedef struct _NUTOWIBUS NUTOWIBUS

Enumeration Type Documentation

enum OWI_ERRORS

OWI return codes.

Note:
The enum type itself is never used.
Enumerator:
OWI_SUCCESS 

All fine.

OWI_PRESENCE_ERR 

No device present.

OWI_INVALID_HW 

Selected Hardware can't do OWI transactions.

OWI_OUT_OF_MEM 

No more memory.

OWI_HW_ERROR 

Unexpected hardware behavior.

OWI_DATA_ERROR 

Unexpected data.

OWI_NOT_IMPLEMENTED 

No OWI implementation available.

OWI speed modes.

Note:
The enum type itself is never used.
Enumerator:
OWI_MODE_NORMAL 

Normal speed.

OWI_MODE_OVERDRIVE 

High speed (only some device types).

OWI_MODE_NONE 

List end marker.

OWI transactions.

Note:
The enum type itself is never used.
Enumerator:
OWI_CMD_RESET 

Presence pulse.

OWI_CMD_RWBIT 

Bit transaction.

OWI_CMD_NONE 

List end marker.

OWI transactions phases.

Note:
The enum type itself is never used.
Enumerator:
OWI_PHASE_SETUP 

Pull bus low.

OWI_PHASE_SYNC_PULSE 

Release bus high for presence pulse, read and write '1'.

OWI_PHASE_RW 

Pull read bus state for presence and read.

OWI_PHASE_RELEASE 

Unconditionally release bus.

OWI_PHASE_NONE 

List end marker.


Function Documentation

int OwiRomSearch ( NUTOWIBUS bus,
uint8_t diff,
uint64_t *  hid 
)

Search the connected One-Wire bus for devices.

Parameters:
busSpecifies the One-Wire bus.
diffOn entry, pointer to either OWI_SEARCH_FIRST or the device found in the last call. On exit, pointer to either OWI_LAST_DEVICE or the diff to use in the next call.
valuePointer to the Hardware ID found.
Returns:
OWI_SUCCESS on success, a negative value otherwise.

References OWI_DATA_ERROR, OWI_LAST_DEVICE, OWI_SEARCH_ROM, _NUTOWIBUS::OwiReadBlock, _NUTOWIBUS::OwiTouchReset, and _NUTOWIBUS::OwiWriteBlock.

int OwiCommand ( NUTOWIBUS bus,
uint8_t  cmd,
uint64_t *  hid 
)

Send a command to the connected devices.

Parameters:
busSpecifies the One-Wire bus.
cmdCommand to send.
hidDevice to select or NULL for broadcast.
Returns:
OWI_SUCCESS on success, a negative value otherwise.

References OWI_MATCH_ROM, OWI_SKIP_ROM, _NUTOWIBUS::OwiTouchReset, and _NUTOWIBUS::OwiWriteBlock.

int OwiReadBlock ( NUTOWIBUS bus,
uint8_t data,
uint_fast8_t  len 
)

Read a block of data.

Parameters:
busSpecifies the One-Wire bus.
dataData read.
lenNumber of bits to read.
Returns:
OWI_SUCCESS on success, a negative value otherwise.

References _NUTOWIBUS::OwiReadBlock.

int OwiWriteBlock ( NUTOWIBUS bus,
uint8_t data,
uint_fast8_t  len 
)

Write a block of data.

Parameters:
busSpecifies the One-Wire bus.
dataData to write.
lenNumber of bits to write.
Returns:
OWI_SUCCESS on success, a negative value otherwise.

References _NUTOWIBUS::OwiWriteBlock.

int OwiSetMode ( NUTOWIBUS bus,
uint_fast8_t  mode 
)

Set/Reset One-Wire Mode(s)

Parameters:
busSpecifies the One-Wire bus.
modeBitmask of mode to set, at present only OWI_OVERDRIVE
Returns:
OWI_SUCCESS on success, a negative value otherwise.

References _NUTOWIBUS::mode, OWI_OVERDRIVE, OWI_OVERDRIVE_SKIP_ROM, _NUTOWIBUS::OwiTouchReset, and _NUTOWIBUS::OwiWriteBlock.

int OwiGetMode ( NUTOWIBUS bus)
int OWIGetMode ( NUTOWIBUS bus)

Set/Reset One-Wire Mode(s)

Parameters:
busSpecifies the One-Wire bus.
Returns:
Mask of set modes

References _NUTOWIBUS::mode.


Variable Documentation

const uint16_t owi_timervalues_250ns[OWI_MODE_NONE][OWI_CMD_NONE][OWI_PHASE_NONE]
Initial value:
 {
    {
        {
            4 * 3,
            4 * (3 + 480),
            4 * (3 + 480 + 70),
            4 * (3 + 480 + 70 + 410)
        },
        {
            4 * 3,
            4 * (3 + 6),
            4 * (3 + 6 + 9),
            4 * (3 + 6 + 9 + 51)
        }
    },
    {
        {
            10,
            10 + 280,
            10 + 280 + 34,
            10 + 280 + 34 + 160
        },
        {
            10,
            10 + 4,
            10 + 4 + 30,
            10 + 4 + 30 + 30
        }
    }
}