mikroC

mikroC - C Compiler for Microchip PIC microcontrollers

making it simple...

CANSPISetOperationMode

Prototype

void CANSPISetOperationMode(char mode, char wait_flag);

 

 

Description

Sets CAN to requested mode, i.e. copies mode to CANSTAT. Parameter mode needs to

 

be one of CAN_OP_MODE constants (see CAN constants, page 145).

 

Parameter wait_flag needs to be either 0 or 0xFF: If set to 0xFF, this is a blocking

 

call – the function won’t “return” until the requested mode is set. If 0, this is a non-

 

blocking call. It does not verify if CAN module is switched to requested mode or not.

 

Caller must use function CANSPIGetOperationMode to verify correct operation mode

 

before performing mode specific operation.

 

 

Requires

CANSPI functions are supported by any PIC MCU that has SPI interface on PORTC.

 

Also, CS pin of MCP2510 or MCP2515 must be connected to RC0.

 

 

Example

CANSPISetOperationMode(CAN_MODE_CONFIG, 0xFF);

 

 

CANSPIGetOperationMode

Prototype

char CANSPIGetOperationMode(void);

 

 

Returns

Current opmode.

 

 

Description

Function returns current operational mode of CAN module.

 

 

Example

if (CANSPIGetOperationMode() == CAN_MODE_NORMAL) { ... };

 

 

page

 

154

MikroElektronika: Development tools - Books - Compilers