CAN Controller Driver function reference

pic18f26k83_can.h

Functions

void pic18f26k83_can_init(const can_timing_t *timing, void (*receive_callback)(const can_msg_t *message))

Initialize PIC18F26K83 CAN Controller.

Warning

Note that this function DOES NOT setup the inputs and outputs from the CAN module to the output pins, application code must do that. In order to do that, CANRXPPS must be set to the proper pin value for the CANRX pin, and ___PPS must be set to 0x33 to mark it as outputting from the CAN module. In addition, TRIS and ANSEL registers for whatever pin is being used must be set to the right values.

Parameters:
  • timing – Timing parameters generated by can_generate_timing_params function

  • receive_callback – CAN message receive handler, the function would be called when a CAN message is received

void pic18f26k83_can_send(const can_msg_t *message)

Send a CAN message.

Parameters:

message – CAN message to be sent

bool pic18f26k83_can_send_rdy(void)

Check if CAN controller is ready to send a message.

Returns:

return true if ready to send a message

void pic18f26k83_can_handle_interrupt(void)

Call this function in an interrupt context whenever PIR5 is nonzero.

Note

This function clears PIR5 interrupt flags