Mikroelektronika MIKROE-724 データシート

ページ / 726
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
265
CANSPIGetOperationMode
CANSPIInit
Prototype
sub function CANSPIGetOperationMode() as byte
Description The  function  returns  current  operation  mode  of  the  CANSPI  module.  Check  CANSPI_OP_MODE 
constants or device datasheet for operation mode codes.
Parameters None.
Returns
Current operation mode.
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
  ...
end if
Notes
None.
Prototype
sub  procedure  CANSPIInit(dim  SJW,  BRP,  PHSEG1,  PHSEG2,  PROPSEG,  CANSPI_
CONFIG_FLAGS as char)
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 CANSPI_CONFIG_FLAGS value 
SAM
SEG2PHTS
WAKFIL
 and 
DBEN
 bits are set according to CANSPI_CONFIG_FLAGS value.
Parameters 
SJW
 as defined in MCU’s datasheet (CAN Module) 
BRP
 as defined in MCU’s datasheet (CAN Module) 
PHSEG1
 as defined in MCU’s datasheet (CAN Module) 
PHSEG2
 as defined in MCU’s datasheet (CAN Module) 
PROPSEG
 as defined in MCU’s datasheet (CAN Module) 
CANSPI_CONFIG_FLAGS
  is  formed  from  predefined  constants.  See  CANSPI_CONFIG_FLAGS 
constants. 
Returns
Nothing.