Difference between revisions of "Component: SPI Master (EB013) (Comms: Interface)"
(XML import) |
(XML import BR) |
||
(One intermediate revision by the same user not shown) | |||
Line 23: | Line 23: | ||
==Examples== | ==Examples== | ||
− | + | Example program to test the FRAM and DAC functions of the EB013 hardware. | |
+ | {{Fcfile|SPI_EB013.fcfx|SPI EB013}} | ||
+ | The test program will do various things based on the last switch that is pressed. | ||
+ | |||
+ | SW0 - Output a sine wave on the DAC | ||
+ | |||
+ | SW1 - Output a high frequency triangle wave on the DAC | ||
+ | |||
+ | SW2 - Output a low frequency triangle wave on the DAC | ||
+ | |||
+ | SW3 - Output a full resolution triangle wave on the DAC | ||
+ | |||
+ | SW4 - Turn off the DAC output | ||
==Downloadable macro reference== | ==Downloadable macro reference== |
Latest revision as of 15:46, 16 February 2017
Author | Matrix Ltd |
Version | 1.3 (Release) |
Category | Comms: Interface |
Contents
SPI Master (EB013) component
Low level routines for controlling or interacting with an SPI interface. SPI or Serial Peripheral Interface is a bus used for board level communications between devices. A target microcontroller will usually have at least one hardware SPI peripheral built in. If the hardware SPI pins are in use or more SPI channels are required then there is also a software mode available. Has additional functions to work with the E-blocks EB013 SPI hardware.
Examples
Example program to test the FRAM and DAC functions of the EB013 hardware.
SPI EB013
The test program will do various things based on the last switch that is pressed.
SW0 - Output a sine wave on the DAC
SW1 - Output a high frequency triangle wave on the DAC
SW2 - Output a low frequency triangle wave on the DAC
SW3 - Output a full resolution triangle wave on the DAC
SW4 - Turn off the DAC output
Downloadable macro reference
SendString
Sends a string of bytes to the SPI bus
Parameters
- <- STRING Str
- This parameter may be returned back to the caller
Return value
- This call does not return a value
NVMSendChar
Send a byte to the non-volatile memory device on the EB013 SPI E-block.
Parameters
- UINT hi_addr
- BYTE lo_addr
- BYTE char
Return value
- This call does not return a value
GetString
Attempts to read a string of bytes from the SPI bus.
Parameters
- BYTE NumBytes
- BYTE Ch
Return value
DACSendChar
Send a byte to the digital to analogue device on the EB013 SPI E-block.
Parameters
- BYTE Char
Return value
- This call does not return a value
SendChar
General purpose SPI send byte macro
Parameters
- BYTE Char
Return value
- This call does not return a value
NVMGetChar
Reads a byte from the non-volatile memory device on the EB013 SPI E-block.
Parameters
- UINT hi_addr
- BYTE lo_addr
Return value
EnableFram
Enable the SPI RAM chip on the EB013 SPI E-block.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
FramOutput
Send a value to the RAM on the EB013 SPI E-block.
Parameters
- BYTE Char
Return value
DisableFram
Disable the SPI RAM chip on the EB013 SPI E-block.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
GetChar
General purpose SPI get byte macro
Parameters
- This macro has no parameters
Return value
UnInitialise
Deactivates the SPI peripheral leaving the I/O pins in a state where they can be used for general purpose I/O.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Initialise
Activates the SPI peripheral and claims control over the I/O pins.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Simulation macro reference
GetConsoleHandle
Gets the handle to the console allowing data displaying on the panel etc.
Parameters
- This macro has no parameters
Return value
Property reference
SPI Channel
This property is of type Fixed list of ints and can be referenced with the variable name CHANNEL.
SPI peripher onboard the target microcontroller to use.
Prescale
This property is of type Fixed list of ints and can be referenced with the variable name PR_SCALE.
Rate by which the master oscillator is reduced before clocking the SPI peripheral.
Clock Polarity
This property is of type Fixed list of ints and can be referenced with the variable name CKP.
The polarity of the clock signal
Clock Phase
This property is of type Fixed list of ints and can be referenced with the variable name CKE.
The phase of the clock signal related to the data signal.
Sample Point
This property is of type Fixed list of ints and can be referenced with the variable name SMP.
Point in the clock period to sample the data signal.
Version
This property is of type Fixed list of ints and can be referenced with the variable name Version.
No additional information
DAC En
This property is of type Single digital pin and can be referenced with the variable name DAC_En.
DAC enable pin - only used with the EB013 SPI E-block
NVM En
This property is of type Single digital pin and can be referenced with the variable name NVM_En.
NVM enable pin - only used with the EB013 SPI E-block
MOSI (SDO)
This property is of type Single digital pin and can be referenced with the variable name MOSI.
Data Out Pin - Micro Out Serial In
MISO (SDI)
This property is of type Single digital pin and can be referenced with the variable name MISO.
Data In Pin - Micro In Serial Out
CLK
This property is of type Single digital pin and can be referenced with the variable name CLK.
Clock Pin
Label
This property is of type Line of text and can be referenced with the variable name label.
Label used to identify the component on the panel.
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.
Injector component to allow the data in simulation to be passed to something meaningful.