Difference between revisions of "Component: SPI (CAL) (Peripheral CAL)"
(XML import - Pre 8.0 release) |
|||
Line 20: | Line 20: | ||
==Examples== | ==Examples== | ||
− | + | ||
+ | Example showing how to build a component using a CAL component [[Using_CAL_Components|Using CAL Components]]. | ||
Latest revision as of 11:27, 23 July 2018
Author | Matrix TSL |
Version | 2.0 (Release) |
Category | Peripheral CAL |
Contents
SPI (CAL) component
CAL = Code Abstraction Layer - Allows one code base to run on a wide range of chips. A low level implementation giving direct access to the Serial Peripheral Interface peripheral.
Examples
Example showing how to build a component using a CAL component Using CAL Components.
Downloadable macro reference
Master_Enable_CS
Outputs a low signal to the chip select pin to select the remote slave device.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Slave_Uninit
Uninitialise the Slave
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Master_Transaction
Sends and receives data bytes via the SPI channel.
The Buffer is to contain the data to be sent, and is overwritten by the retuning data from the device.
Returns 1 for success, 0 for failure
Parameters
- BYTE Buffer
- UINT Length
- Number of bytes to transfer
Return value
Slave_Init
Initialise the Slave
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Master_Disable_CS
Outputs a high signal to the chip select pin to deselect the remote slave device.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Master_Uninit
Uninitialise the Master
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Master_Byte
Sends and receives a data byte
Parameters
- BYTE DataOut
Return value
Slave_TxByte
Sets the data to be transmitted to the SPI master.
Parameters
- BYTE Data
Return value
- This call does not return a value
Slave_RxByte
Returns the data received from the SPI Master
Parameters
- This macro has no parameters
Return value
SetPrescaler
Sets the prescaler value for the clock divider chain
Parameters
- BYTE Prescaler
Return value
- This call does not return a value
Master_Init
Initialise the Master
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Simulation macro reference
Prv_TextConsole
Send text to the SPI console.
Exposed as part of the CAL_SPI component to allow none AutoCS pins and other.
Parameters
- <- STRING str
- This parameter may be returned back to the caller
- BYTE Colour
- 0=Default, 1=TX, 2=RX
- BYTE AppendTimestamp
- 0=Don't Append / 1=Do Append
Return value
- This call does not return a value
ChangeMode
No additional information
Parameters
- This macro has no parameters
Return value
- This call does not return a value
GetValue
Reads Named property Value.
Parameters
- <- STRING Name
- This parameter may be returned back to the caller
Return value
GetConsoleHandle
Returns a handle to the console used by this component
Parameters
- This macro has no parameters
Return value
SetValue
Change Named property to new Value.
Parameters
- <- STRING Name
- This parameter may be returned back to the caller
- <- STRING Value
- This parameter may be returned back to the caller
Return value
- This call does not return a value
GetList
returns Named property list
Parameters
- <- STRING Name
- This parameter may be returned back to the caller
Return value
Property reference
Component Enable
This property is of type True or false and can be referenced with the variable name ENABLED.
A global flag to enable or disable the SPI component from producing code.
Useful for generating components with multiple communications options.
Channel
This property is of type Fixed list of ints and can be referenced with the variable name CHANNEL.
SPI Channel selector
MOSI
This property is of type Single digital pin and can be referenced with the variable name MOSI.
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.
MISO
This property is of type Single digital pin and can be referenced with the variable name MISO.
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.
CLK
This property is of type Single digital pin and can be referenced with the variable name CLK.
SPI Clock Pin CLK - The Clock signal is driven by the SPI master.
Use Auto CS
This property is of type True or false and can be referenced with the variable name UseAutoCS.
Allow the SPI component to manage the CS pin for us in Master mode.
On initialise the CS pin is automatically set high to disable the remote SPI device.
Set to No if you want to create a component with multiple CS pins or if you want to manage the CS pin yourself.
CS / SS
This property is of type Single digital pin and can be referenced with the variable name SS.
Chip Select / Slave Select Pin
Master Mode: General purpose output pin used to select the remote SPI device.
Slave Mode: Hardware chip select pin input used to select the SPI device.
Mode
This property is of type Fixed list of ints and can be referenced with the variable name Mode.
Configures the mode of the SPI component.
Currently only Master mode is supported.
Prescale
This property is of type Fixed list of ints and can be referenced with the variable name PR_SCALE.
Prescale option selector
Clock Phase
This property is of type Fixed list of ints and can be referenced with the variable name CKE.
Clock Phase (data change edge) selection
Clock Polarity
This property is of type Fixed list of ints and can be referenced with the variable name CKP.
Clock Polarity setting, inactive (idle) state
Sample Point
This property is of type Fixed list of ints and can be referenced with the variable name SMP.
Data bit read sample point
Scope Traces
This property is of type True or false and can be referenced with the variable name ScopeTraces.
Selects if the scope traces are automatically generated or not
Console Data
This property is of type True or false and can be referenced with the variable name ConsoleData.
Selects if the console data is automatically generated or not
Injector
This property is of type Fixed list of ints and can be referenced with the variable name Injector.
No additional information