Datasheet
CANSPIGetOperationMode
CANSPIInitialize
189
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Prototype
function CANSPIGetOperationMode(): byte;
Returns Current operation mode.
Description
The function returns current operation mode of the CANSPI module. Check
CANSPI_OP_MODE constants (see CANSPI constants) or device datasheet for
operation mode codes.
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
// check whether the CANSPI module is in Normal mode and if it
is do something.
if (CANSPIGetOperationMode() = CANSPI_MODE_NORMAL) then
begin
...
end;
Prototype
procedure CANSPIInitialize(SJW: byte; BRP: byte; PHSEG1: byte;
PHSEG2: byte; PROPSEG: byte; CAN_CONFIG_FLAGS: byte);
Returns Nothing.
Description
Initializes the CANSPI module.
Stand-Alone CAN controller in the CANSPI module is set to:
- Disable CAN capture
- Continue CAN operation in Idle mode
- Do not abort pending transmissions
- Fcan clock: 4*Tcy (Fosc)
- Baud rate is set according to given parameters
- CAN mode: Normal
- Filter and mask registers IDs are set to zero
- Filter and mask message frame type is set according to
CAN_CONFIG_FLAGS value
SAM, SEG2PHTS, WAKFIL and DBEN bits are set according toCAN_CONFIG_FLAGS value.
Parameters:
-
SJW as defined in CAN controller's datasheet
- BRP as defined in CAN controller's datasheet
-
PHSEG1 as defined in CAN controller's datasheet
- PHSEG2 as defined in CAN controller's datasheet
- PROPSEG as defined in CAN controller's datasheet
-
CAN_CONFIG_FLAGS is formed from predefined constants (see CANSPI constants)