Unit W1

From Ultibo.org
Jump to: navigation, search

Return to Unit Reference


Description


Ultibo 1-Wire Interface unit

1-Wire is a communications bus designed by Dallas Semiconductor Corp that combines low speed signalling, data and power over a single signal line. It is often used for small devices such as digital thermometers.

Devices can actually be powered over the 1-Wire interface allowing the use of just data and ground lines.

Note: Because FreePascal does not permit the use of functions or variables that begin with a numeric value such as 1WIRE we use the term W1 throughout this unit to refer to a 1-Wire device. This is the same terminology as used in Linux and other systems.

Constants



[Expand]
W1 specific constants W1_*


[Expand]
W1 device types W1_TYPE_*


[Expand]
W1 device states W1_STATE_*


[Expand]
W1 device flags W1_FLAG_*


[Expand]
W1 logging W1_LOG_*


Type definitions



W1 properties

[Expand]

PW1Properties = ^TW1Properties;

TW1Properties = record

W1 enumeration callback

TW1Enumerate = function(W1:PW1Device; Data:Pointer):LongWord;

W1 notification callback

TW1Notification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;

W1 device get properties

TW1DeviceGetProperties = function(W1:PW1Device; Properties:PW1Properties):LongWord;

W1 device

[Expand]

PW1Device = ^TW1Device;

TW1Device = record


Public variables



W1 logging

W1_DEFAULT_LOG_LEVEL:LongWord = W1_LOG_LEVEL_DEBUG; Minimum level for W1 messages. Only messages with level greater than or equal to this will be printed.
W1_LOG_ENABLED:Boolean;


Function declarations



Initialization functions

[Expand]
procedure W1Init;
Description: Initialize the W1 unit and W1 device table


W1 functions

[Expand]
function W1DeviceGetProperties(W1:PW1Device; Properties:PW1Properties):LongWord;
Description: Get the properties for the specified W1 device


[Expand]
function W1DeviceCreate:PW1Device;
Description: Create a new W1 entry


[Expand]
function W1DeviceCreateEx(Size:LongWord):PW1Device;
Description: Create a new W1 entry


[Expand]
function W1DeviceDestroy(W1:PW1Device):LongWord;
Description: Destroy an existing W1 entry


[Expand]
function W1DeviceRegister(W1:PW1Device):LongWord;
Description: Register a new W1 in the W1 table


[Expand]
function W1DeviceDeregister(W1:PW1Device):LongWord;
Description: Deregister a W1 from the W1 table


[Expand]
function W1DeviceFind(W1Id:LongWord):PW1Device;
Description: To be documented


[Expand]
function W1DeviceFindByName(const Name:String):PW1Device; inline;
Description: To be documented


[Expand]
function W1DeviceFindByDescription(const Description:String):PW1Device; inline;
Description: To be documented


[Expand]
function W1DeviceEnumerate(Callback:TW1Enumerate; Data:Pointer):LongWord;
Description: To be documented


[Expand]
function W1DeviceNotification(W1:PW1Device; Callback:TW1Notification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: To be documented


W1 helper functions

[Expand]
function W1GetCount:LongWord;
Description: Get the current W1 count


[Expand]
function W1DeviceGetDefault:PW1Device;
Description: Get the current default W1 device


[Expand]
function W1DeviceSetDefault(W1:PW1Device):LongWord;
Description: Set the current default W1 device


[Expand]
function W1DeviceCheck(W1:PW1Device):PW1Device;
Description: Check if the supplied W1 is in the W1 table


[Expand]
procedure W1Log(Level:LongWord; W1:PW1Device; const AText:String);
Description: To be documented


[Expand]
procedure W1LogInfo(W1:PW1Device; const AText:String); inline;
Description: To be documented


[Expand]
procedure W1LogWarn(W1:PW1Device; const AText:String); inline;
Description: To be documented


[Expand]
procedure W1LogError(W1:PW1Device; const AText:String); inline;
Description: To be documented


[Expand]
procedure W1LogDebug(W1:PW1Device; const AText:String); inline;
Description: To be documented


Return to Unit Reference