MCP2515 CAN library

Fork of mcp2515 by Jason Engelman

CAN3.h

Committer:
nimig
Date:
2017-07-27
Revision:
15:5a3fdb039965
Parent:
13:ff12c7f532f9

File content as of revision 15:5a3fdb039965:


#ifndef _CAN3_H_
#define _CAN3_H_

#include "mbed.h"
#include "mcp2515.h"
#include "mcp2515_defs.h"
#include "mcp2515_can.h"
#include "SPI.h"

#define BFPCTRL        0x0C
#define TXRTSCTRL       0x0D


class CAN3  {
    SPI& spi;
    //InterruptIn _itr;
    mcp2515 _mcp;
public:
    CAN3(SPI& _spi, PinName ncs);//, PinName itr);
    
    uint8_t read(CANMessage *msg); //    int read(CANMessage&    msg);
    void write(CANMessage* test);   //int write(CANMessage     msg);
    int frequency( int canSpeed); //Set the frequency of the CAN interface hz    The bus frequency in hertz


    void reset(); //Reset CAN interface. To use after error overflow.
    unsigned char rderror(); //Returns number of read errors to detect read overflow errors.
    unsigned char tderror(); //Returns number of write errors to detect write overflow errors.

    void rise(void (*fptr)(void));
    void fall(void (*fptr2)(void));

    // Private functions
private :
    uint8_t checkReceive(void);


};

#endif // _CAN3_H_