Guest User

CAN_TEST_H

a guest
Apr 22nd, 2013
225
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ifndef CAN_TEST_H
  2. #define CAN_TEST_H
  3.  
  4. #define WRITE_COM     0x02
  5. #define READ_COM      0x03
  6. #define RESET_COM     0x0C
  7. #define STATUS_COM    0xA0
  8. #define STATUS_RX_COM 0xB0
  9.  
  10. #define SPI_READ_RX   0x90
  11. #define SPI_WRITE_TX  0x40
  12. #define SPI_RTS       0x80
  13.  
  14. #define CANINTE       0x2B
  15. #define CANINTF       0x2C
  16.  
  17. #define LOOPBACK_MODE 0x40
  18. #define NORMAL_MODE   0x00
  19. #define CONFIG_MODE   0x80
  20.  
  21. typedef struct {
  22.   int id;
  23.   int length;
  24.   int rtr;
  25.   char buff[22];
  26. }
  27. tCAN;
  28.  
  29. // set pin 10 as the slave select for the digital pot:
  30. const int slaveSelectPin = 53;
  31. int startupMode = NORMAL_MODE;//LOOPBACK_MODE;
  32.  
  33. void spiReset();
  34. void spiWrite(int address, int value);
  35. char spiWriteContInit(int address);
  36. char spiWriteCont(int data);
  37. int spiRead(int address, int verbose=0);
  38. char spiReadContInit(int address);
  39. char spiReadCont();
  40. char getStatus();
  41. int hasMessage(void);
  42. int recMessage(tCAN *msg);
  43. int sendMessage(tCAN *msg);
  44.  
  45. #endif
RAW Paste Data