Class TCustomPortSPI

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TCustomPortSPI = class abstract(TCustomDataPort)

Description

Abstract SPI (Serial Peripheral Interface) communication manager.

Hierarchy

Overview

Fields

Protected FChipSelectMode: TChipSelectMode;

Methods

Public constructor Create(const AChipSelectMode: TChipSelectMode = TChipSelectMode.ActiveLow);
Public function Read(const Buffer: Pointer; const BufferSize: Cardinal): Cardinal; override;
Public function Transfer(const Buffer: Pointer; const BufferSize: Cardinal): Cardinal; overload; inline;
Public function Transfer(const ReadBuffer, WriteBuffer: Pointer; const BufferSize: Cardinal): Cardinal; overload; virtual; abstract;
Public function Write(const Buffer: Pointer; const BufferSize: Cardinal): Cardinal; override;
Protected function GetBitsPerWord: TBitsPerWord; virtual; abstract;
Protected function GetFrequency: Cardinal; virtual; abstract;
Protected function GetMode: TSPIMode; virtual; abstract;
Protected procedure SetBitsPerWord(const Value: TBitsPerWord); virtual; abstract;
Protected procedure SetFrequency(const Value: Cardinal); virtual; abstract;
Protected procedure SetMode(const Value: TSPIMode); virtual; abstract;

Properties

Public property BitsPerWord: TBitsPerWord read GetBitsPerWord write SetBitsPerWord;
Public property ChipSelectMode: TChipSelectMode read FChipSelectMode;
Public property Frequency: Cardinal read GetFrequency write SetFrequency;
Public property Mode: TSPIMode read GetMode write SetMode;

Description

Fields

Protected FChipSelectMode: TChipSelectMode;

Current Chip Select operation mode.

Methods

Public constructor Create(const AChipSelectMode: TChipSelectMode = TChipSelectMode.ActiveLow);

Creates instance of SPI port with the specified Chip Select (CS) mode.

Public function Read(const Buffer: Pointer; const BufferSize: Cardinal): Cardinal; override;

Reads specified number of bytes to buffer and returns actual number of bytes read.

Public function Transfer(const Buffer: Pointer; const BufferSize: Cardinal): Cardinal; overload; inline;

Transfers data through SPI port asynchronously - that is, reading and writing at the same time.

Parameters
Buffer
Pointer to data buffer where the data will be read from and at the same time written to, overwriting its contents.
BufferSize
The size of buffer in bytes.
Returns

Number of bytes that were actually transferred.

Public function Transfer(const ReadBuffer, WriteBuffer: Pointer; const BufferSize: Cardinal): Cardinal; overload; virtual; abstract;

Transfers data through SPI port asynchronously - that is, reading and writing at the same time.

Parameters
ReadBuffer
Pointer to data buffer where the data will be read from. If this parameter is set to Nil, then no reading will be done.
WriteBuffer
Pointer to data buffer where the data will be written to. If this parameter is set to Nil, then no writing will be done.
BufferSize
The size of read and write buffers in bytes.
Returns

Number of bytes that were actually transferred.

Public function Write(const Buffer: Pointer; const BufferSize: Cardinal): Cardinal; override;

Writes specified number of bytes from buffer and returns actual number of bytes written.

Protected function GetBitsPerWord: TBitsPerWord; virtual; abstract;

Returns current number of bits that each word occupies.

Protected function GetFrequency: Cardinal; virtual; abstract;

Returns current operating frequency.

Protected function GetMode: TSPIMode; virtual; abstract;

Returns currently active SPI mode.

Protected procedure SetBitsPerWord(const Value: TBitsPerWord); virtual; abstract;

Changes current number of bits each word occupies.

Protected procedure SetFrequency(const Value: Cardinal); virtual; abstract;

Changes current operating frequency.

Protected procedure SetMode(const Value: TSPIMode); virtual; abstract;

Changes current SPI mode to the specified value.

Properties

Public property BitsPerWord: TBitsPerWord read GetBitsPerWord write SetBitsPerWord;

Number of bits each word occupies, typically either 8 or 16 depending on hardware and support.

Public property ChipSelectMode: TChipSelectMode read FChipSelectMode;

Chip Select operation mode.

Public property Frequency: Cardinal read GetFrequency write SetFrequency;

SPI operating frequency in Hz.

Public property Mode: TSPIMode read GetMode write SetMode;

Mode of SPI operation, including Clock Polarity (CPOL) and Clock Edge (CPCHA). The actual meaning of this parameter depends on implementation and should be consulted from corresponding documentation.


Copyright © 2000 - 2017 Yuriy Kotsarenko. Help files generated by PasDoc.