Difference between revisions of "Unit SPI"
(7 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
---- | ---- | ||
− | '''Ultibo SPI | + | '''Ultibo SPI Interface unit''' |
SPI (Serial Peripheral Interface) is a synchronous serial bus for communication with peripheral components. | SPI (Serial Peripheral Interface) is a synchronous serial bus for communication with peripheral components. | ||
Line 26: | Line 26: | ||
| <code>SPI_NAME_PREFIX = 'SPI';</code> | | <code>SPI_NAME_PREFIX = 'SPI';</code> | ||
| Name prefix for SPI Devices | | Name prefix for SPI Devices | ||
+ | |- | ||
+ | | <code>SPISLAVE_NAME_PREFIX = 'SPISlave';</code> | ||
+ | | Name prefix for SPI Slave Devices | ||
|- | |- | ||
|} | |} | ||
Line 37: | Line 40: | ||
| <code>SPI_TYPE_NONE = 0;</code> | | <code>SPI_TYPE_NONE = 0;</code> | ||
| style="width: 50%;"| | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>SPI_TYPE_MASTER = 1;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>SPI_TYPE_SLAVE = 2;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>SPI_TYPE_MAX = 2;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | |colspan="2"|SPI Type Names | ||
+ | |- | ||
+ | |colspan="2"|<code>SPI_TYPE_NAMES:array[SPI_TYPE_NONE..SPI_TYPE_MAX] of String = ('SPI_TYPE_NONE', 'SPI_TYPE_MASTER', 'SPI_TYPE_SLAVE');</code> | ||
|- | |- | ||
|} | |} | ||
Line 50: | Line 70: | ||
|- | |- | ||
| <code>SPI_STATE_ENABLED = 1;</code> | | <code>SPI_STATE_ENABLED = 1;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>SPI_STATE_MAX = 1;</code> | ||
| | | | ||
|- | |- | ||
Line 106: | Line 131: | ||
| <code>SPI_TRANSFER_PIO = $00000002;</code> | | <code>SPI_TRANSFER_PIO = $00000002;</code> | ||
| Use PIO (Polling) for transfer (Write/Read) | | Use PIO (Polling) for transfer (Write/Read) | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>SPI_TRANSFER_DELAY = $00000004;</code> | ||
+ | | Add a delay after each byte written (Write/Read) Note: Only available with PIO transfer unless provided directly by hardware | ||
|- | |- | ||
|} | |} | ||
Line 176: | Line 206: | ||
| <code>SelectPolarity:LongWord;</code> | | <code>SelectPolarity:LongWord;</code> | ||
| Default chip select polarity (eg SPI_CS_POLARITY_LOW) | | Default chip select polarity (eg SPI_CS_POLARITY_LOW) | ||
+ | |- | ||
+ | | <code>ByteDelay:LongWord;</code> | ||
+ | | Delay between bytes written (Microseconds) | ||
|- | |- | ||
|} | |} | ||
Line 209: | Line 242: | ||
| <code>SelectPolarity:LongWord;</code> | | <code>SelectPolarity:LongWord;</code> | ||
| The chip select polarity for this chip select (eg SPI_CS_POLARITY_LOW) | | The chip select polarity for this chip select (eg SPI_CS_POLARITY_LOW) | ||
+ | |- | ||
+ | | <code>ByteDelay:LongWord;</code> | ||
+ | | Delay between bytes written for this chip select (Microseconds) | ||
|- | |- | ||
|} | |} | ||
Line 362: | Line 398: | ||
|- | |- | ||
| <code>TSPIDeviceSetSelectPolarity = function(SPI:PSPIDevice; ChipSelect:Word; SelectPolarity:LongWord):LongWord;</code> | | <code>TSPIDeviceSetSelectPolarity = function(SPI:PSPIDevice; ChipSelect:Word; SelectPolarity:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''SPI device get byte delay''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TSPIDeviceGetByteDelay = function(SPI:PSPIDevice):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''SPI device set byte delay''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TSPIDeviceSetByteDelay = function(SPI:PSPIDevice; Delay:LongWord):LongWord;</code> | ||
| style="width: 40%;"| | | style="width: 40%;"| | ||
|- | |- | ||
Line 444: | Line 498: | ||
| <code>DeviceSetSelectPolarity:TSPIDeviceSetSelectPolarity;</code> | | <code>DeviceSetSelectPolarity:TSPIDeviceSetSelectPolarity;</code> | ||
| A Device specific DeviceSetSelectPolarity method implementing the standard SPI device interface (Or nil if the default method is suitable) | | A Device specific DeviceSetSelectPolarity method implementing the standard SPI device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | | <code>DeviceGetByteDelay:TSPIDeviceGetByteDelay;</code> | ||
+ | | A Device specific DeviceGetByteDelay method implementing the standard SPI device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | | <code>DeviceSetByteDelay:TSPIDeviceSetByteDelay;</code> | ||
+ | | A Device specific DeviceSetByteDelay method implementing the standard SPI device interface (Or nil if the default method is suitable) | ||
|- | |- | ||
| <code>DeviceGetProperties:TSPIDeviceGetProperties;</code> | | <code>DeviceGetProperties:TSPIDeviceGetProperties;</code> | ||
Line 641: | Line 701: | ||
|- | |- | ||
! Note | ! Note | ||
− | | Because SPI writes and then reads for each byte, received data will be discarded for each | + | | Because SPI writes and then reads for each byte, received data will be discarded for each byte written. |
|- | |- | ||
|} | |} | ||
Line 964: | Line 1,024: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! SPI |
− | | | + | | The SPI device to destroy |
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 976: | Line 1,039: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! SPI |
− | | | + | | The SPI device to register |
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 984: | Line 1,050: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SPIDeviceDeregister(SPI:PSPIDevice):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SPIDeviceDeregister(SPI:PSPIDevice):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Deregister | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Deregister an SPI from the SPI table</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! SPI |
− | | | + | | The SPI device to deregister |
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 996: | Line 1,065: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SPIDeviceFind(SPIId:LongWord):PSPIDevice;</pre> | <pre style="border: 0; padding-bottom:0px;">function SPIDeviceFind(SPIId:LongWord):PSPIDevice;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' ERROR_SUCCESS if completed or another error code on failure</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! SPIId |
− | | | + | | The ID number of the SPI device to find |
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to SPI device entry or nil if not found | ||
|- | |- | ||
|} | |} | ||
Line 1,008: | Line 1,080: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SPIDeviceFindByName(const Name:String):PSPIDevice; inline;</pre> | <pre style="border: 0; padding-bottom:0px;">function SPIDeviceFindByName(const Name:String):PSPIDevice; inline;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find an SPI device by name in the device table</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Name |
− | | | + | | The name of the SPI device to find (eg SPI0) |
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to SPI device entry or nil if not found | ||
|- | |- | ||
|} | |} | ||
Line 1,020: | Line 1,095: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SPIDeviceFindByDescription(const Description:String):PSPIDevice; inline;</pre> | <pre style="border: 0; padding-bottom:0px;">function SPIDeviceFindByDescription(const Description:String):PSPIDevice; inline;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find an SPI device by description in the device table</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Description |
− | | | + | | The description of the SPI to find (eg BCM2837 SPI0 Master) |
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to SPI device entry or nil if not found | ||
|- | |- | ||
|} | |} | ||
Line 1,032: | Line 1,110: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SPIDeviceEnumerate(Callback:TSPIEnumerate; Data:Pointer):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SPIDeviceEnumerate(Callback:TSPIEnumerate; Data:Pointer):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Enumerate all SPI devices in the SPI table</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Callback |
− | | | + | | The callback function to call for each SPI device in the table |
+ | |- | ||
+ | ! Data | ||
+ | | A private data pointer to pass to callback for each SPI device in the table | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 1,044: | Line 1,128: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SPIDeviceNotification(SPI:PSPIDevice; Callback:TSPINotification; Data:Pointer; Notification,Flags:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SPIDeviceNotification(SPI:PSPIDevice; Callback:TSPINotification; Data:Pointer; Notification,Flags:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Register a notification for SPI device changes</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Device |
− | | | + | | The SPI device to notify changes for (Optional, pass nil for all SPI devices) |
+ | |- | ||
+ | ! Callback | ||
+ | | The function to call when a notification event occurs | ||
+ | |- | ||
+ | ! Data | ||
+ | | A private data pointer to pass to callback when a notification event occurs | ||
+ | |- | ||
+ | ! Notification | ||
+ | | The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER) | ||
+ | |- | ||
+ | ! Flags | ||
+ | | The flags to control the notification (eg NOTIFIER_FLAG_WORKER) | ||
|- | |- | ||
|} | |} | ||
Line 1,154: | Line 1,250: | ||
|- | |- | ||
! Note | ! Note | ||
− | | Because SPI writes and then reads for each byte, received data will be discarded for each | + | | Because SPI writes and then reads for each byte, received data will be discarded for each byte written. |
|- | |- | ||
|} | |} | ||
Line 1,340: | Line 1,436: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">function SPIGetCount:LongWord | + | <pre style="border: 0; padding-bottom:0px;">function SPIGetCount:LongWord;</pre> |
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current SPI count</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current SPI count</div> | ||
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
Line 1,352: | Line 1,448: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">function SPIDeviceGetDefault:PSPIDevice | + | <pre style="border: 0; padding-bottom:0px;">function SPIDeviceGetDefault:PSPIDevice;</pre> |
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current default SPI device</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current default SPI device</div> | ||
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> |
Latest revision as of 04:41, 10 October 2023
Return to Unit Reference
Contents
[hide]Description
Ultibo SPI Interface unit
SPI (Serial Peripheral Interface) is a synchronous serial bus for communication with peripheral components.
The SPI protocol is not defined by any actual standard but some pseudo standards exist with all of the available devices. SPI is a master-slave protocol where the master asserts the chip select line (CS) to select the slave device before sending data one byte at a time. For every byte written to the bus by the master the selected slave returns a byte as well so for every write there is an equivalent read. SPI can also operate in either 4 wire (standard) or 3 wire(bidirectional) modes.
Due to the lack of formal standards and the range of devices that exist various options are provided to allow setting clock phase and polarity as well chip select polarity.
For the purpose of this interface a device is the SPI controller attached to the local system and may be either a master or a slave. Since the protocol does not include any form of enumeration or identification the interface does not attempt to represent the devices connected to the bus, any driver written to communicate with a connected SPI device should know (or allow configuration of) the chip select for the for the device and the specific message format required for that device.
Constants
SPI_*
SPI_TYPE_*
SPI_STATE_*
SPI_FLAG_*
SPI_TRANSFER_*
SPI_LOG_*
Type definitions
SPI properties
SPI chip select
SPI enumeration callback
TSPIEnumerate = function(SPI:PSPIDevice; Data:Pointer):LongWord;
|
SPI notification callback
TSPINotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;
|
SPI device start
TSPIDeviceStart = function(SPI:PSPIDevice; Mode,ClockRate,ClockPhase,ClockPolarity:LongWord):LongWord;
|
SPI device stop
TSPIDeviceStop = function(SPI:PSPIDevice):LongWord;
|
SPI device read
TSPIDeviceRead = function(SPI:PSPIDevice; ChipSelect:Word; Dest:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
|
SPI device write
TSPIDeviceWrite = function(SPI:PSPIDevice; ChipSelect:Word; Source:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
|
SPI device write read
TSPIDeviceWriteRead = function(SPI:PSPIDevice; ChipSelect:Word; Source,Dest:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
|
SPI device get mode
TSPIDeviceGetMode = function(SPI:PSPIDevice):LongWord;
|
SPI device set mode
TSPIDeviceSetMode = function(SPI:PSPIDevice; Mode:LongWord):LongWord;
|
SPI device get clock rate
TSPIDeviceGetClockRate = function(SPI:PSPIDevice; ChipSelect:Word):LongWord;
|
SPI device set clock rate
TSPIDeviceSetClockRate = function(SPI:PSPIDevice; ChipSelect:Word; ClockRate:LongWord):LongWord;
|
SPI device get clock phase
TSPIDeviceGetClockPhase = function(SPI:PSPIDevice):LongWord;
|
SPI device set clock phase
TSPIDeviceSetClockPhase = function(SPI:PSPIDevice; ClockPhase:LongWord):LongWord;
|
SPI device get clock polarity
TSPIDeviceGetClockPolarity = function(SPI:PSPIDevice):LongWord;
|
SPI device set clock polarity
TSPIDeviceSetClockPolarity = function(SPI:PSPIDevice; ClockPolarity:LongWord):LongWord;
|
SPI device get select polarity
TSPIDeviceGetSelectPolarity = function(SPI:PSPIDevice; ChipSelect:Word):LongWord;
|
SPI device set select polarity
TSPIDeviceSetSelectPolarity = function(SPI:PSPIDevice; ChipSelect:Word; SelectPolarity:LongWord):LongWord;
|
SPI device get byte delay
TSPIDeviceGetByteDelay = function(SPI:PSPIDevice):LongWord;
|
SPI device set byte delay
TSPIDeviceSetByteDelay = function(SPI:PSPIDevice; Delay:LongWord):LongWord;
|
SPI device get properties
TSPIDeviceGetProperties = function(SPI:PSPIDevice; Properties:PSPIProperties):LongWord;
|
SPI device
Public variables
SPI logging
SPI_DEFAULT_LOG_LEVEL:LongWord = SPI_LOG_LEVEL_DEBUG;
|
Minimum level for SPI messages. Only messages with level greater than or equal to this will be printed. |
SPI_LOG_ENABLED:Boolean;
|
Function declarations
Initialization functions
SPI functions
function SPIDeviceStart(SPI:PSPIDevice; Mode,ClockRate,ClockPhase,ClockPolarity:LongWord):LongWord;
function SPIDeviceStop(SPI:PSPIDevice):LongWord;
function SPIDeviceRead(SPI:PSPIDevice; ChipSelect:Word; Dest:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
function SPIDeviceWrite(SPI:PSPIDevice; ChipSelect:Word; Source:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
function SPIDeviceWriteRead(SPI:PSPIDevice; ChipSelect:Word; Source,Dest:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
function SPIDeviceGetMode(SPI:PSPIDevice):LongWord;
function SPIDeviceSetMode(SPI:PSPIDevice; Mode:LongWord):LongWord;
function SPIDeviceGetClockRate(SPI:PSPIDevice; ChipSelect:Word):LongWord;
function SPIDeviceSetClockRate(SPI:PSPIDevice; ChipSelect:Word; ClockRate:LongWord):LongWord;
function SPIDeviceGetClockPhase(SPI:PSPIDevice):LongWord;
function SPIDeviceSetClockPhase(SPI:PSPIDevice; ClockPhase:LongWord):LongWord;
function SPIDeviceGetClockPolarity(SPI:PSPIDevice):LongWord;
function SPIDeviceSetClockPolarity(SPI:PSPIDevice; ClockPolarity:LongWord):LongWord;
function SPIDeviceGetSelectPolarity(SPI:PSPIDevice; ChipSelect:Word):LongWord;
function SPIDeviceSetSelectPolarity(SPI:PSPIDevice; ChipSelect:Word; SelectPolarity:LongWord):LongWord;
function SPIDeviceGetByteDelay(SPI:PSPIDevice):LongWord;
function SPIDeviceSetByteDelay(SPI:PSPIDevice; Delay:LongWord):LongWord;
function SPIDeviceProperties(SPI:PSPIDevice; Properties:PSPIProperties):LongWord; inline;
function SPIDeviceGetProperties(SPI:PSPIDevice;Properties:PSPIProperties):LongWord;
function SPIDeviceDestroy(SPI:PSPIDevice):LongWord;
function SPIDeviceRegister(SPI:PSPIDevice):LongWord;
function SPIDeviceDeregister(SPI:PSPIDevice):LongWord;
function SPIDeviceFind(SPIId:LongWord):PSPIDevice;
function SPIDeviceFindByName(const Name:String):PSPIDevice; inline;
function SPIDeviceFindByDescription(const Description:String):PSPIDevice; inline;
function SPIDeviceEnumerate(Callback:TSPIEnumerate; Data:Pointer):LongWord;
function SPIDeviceNotification(SPI:PSPIDevice; Callback:TSPINotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
RTL SPI functions
function SysSPIStart(Mode,ClockRate,ClockPhase,ClockPolarity:LongWord):LongWord;
function SysSPIStop:LongWord;
function SysSPIRead(ChipSelect:Word; Dest:Pointer; Size:LongWord; var Count:LongWord):LongWord;
function SysSPIWrite(ChipSelect:Word; Source:Pointer; Size:LongWord; var Count:LongWord):LongWord;
function SysSPIWriteRead(ChipSelect:Word; Source,Dest:Pointer; Size:LongWord; var Count:LongWord):LongWord;
function SysSPIGetMode:LongWord;
function SysSPISetMode(Mode:LongWord):LongWord;
function SysSPIGetClockRate(ChipSelect:Word):LongWord;
function SysSPISetClockRate(ChipSelect:Word; ClockRate:LongWord):LongWord;
function SysSPIGetClockPhase:LongWord;
function SysSPISetClockPhase(ClockPhase:LongWord):LongWord;
function SysSPIGetClockPolarity:LongWord;
function SysSPISetClockPolarity(ClockPolarity:LongWord):LongWord;
function SysSPIGetSelectPolarity(ChipSelect:Word):LongWord;
function SysSPISetSelectPolarity(ChipSelect:Word; SelectPolarity:LongWord):LongWord;
SPI helper functions
function SPIDeviceSetDefault(SPI:PSPIDevice):LongWord;
function SPIDeviceCheck(SPI:PSPIDevice):PSPIDevice;
function SPITypeToString(SPIType:LongWord):String;
function SPIStateToString(SPIState:LongWord):String;
procedure SPILog(Level:LongWord; SPI:PSPIDevice; const AText:String);
procedure SPILogInfo(SPI:PSPIDevice; const AText:String); inline;
procedure SPILogWarn(SPI:PSPIDevice; const AText:String); inline;
procedure SPILogError(SPI:PSPIDevice; const AText:String); inline;
procedure SPILogDebug(SPI:PSPIDevice; const AText:String); inline;
function SPISelectPolarityToString(Polarity:LongWord):String;
Return to Unit Reference