User manual
262
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
Library Routines
- CANSPISetOperationMode
- CANSPIGetOperationMode
- CANSPIInit
- CANSPISetBaudRate
- CANSPISetMask
- CANSPISetFilter
- CANSPIRead
- CANSPIWrite
CANSPISetOperationMode
Prototype
procedure CANSPISetOperationMode(mode : byte; WAIT: byte);
Description Sets the CANSPI module to requested mode.
Parameters mode: CANSPI module operation mode. Valid values: CANSPI_OP_MODE constants. See CANSPI_
OP_MODE constants.
WAIT: CANSPI mode switching verication request. If WAIT == 0, the call is non-blocking. The
function does not verify if the CANSPI module is switched to requested mode or not. Caller must
use CANSPIGetOperationMode to verify correct operation mode before performing mode specic
operation. If WAIT != 0, the call is blocking – the function won’t “return” until the requested mode is
set.
Returns Nothing.
Requires The CANSPI routines are supported only by MCUs with the SPI module.
MCU has to be properly connected to mikroElektronika’s CANSPI Extra Board or similar hardware.
See connection example at the bottom of this page.
Example
// set the CANSPI module into conguration mode (wait inside
CANSPISetOperationMode until this mode is set)
CANSPISetOperationMode(_CANSPI_MODE_CONFIG, 0xFF);
Notes None.
External dependencies of CANSPI Library
The following variables must be dened
in all projects using CANSPI Library:
Description: Example:
var CanSpi_CS : sbit; sfr;
external;
Chip Select line.
var CanSpi_CS : sbit at LATF0_bit;
var CanSpi_Rst : sbit; sfr;
external;
Reset line.
var CanSpi_Rst : sbit at LATF1_
bit;
var CanSpi_CS_Direction : sbit;
sfr; external;
Direction of the Chip Select
pin.
var CanSpi_CS_Direction : sbit at
TRISF0_bit;
var CanSpi_Rst_Direction : sbit;
sfr; external;
Direction of the Reset pin.
var CanSpi_Rst_Direction : sbit at
TRISF1_bit;