can.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef __CAN_H
  2. #define __CAN_H
  3. #include "stm32f4xx.h"
  4. #define CAN_Send_Flash_ID 0x1f4e5201
  5. #define CAN_Send_Speed_ID 0x1f4e5301
  6. #define CAN_RecDataMax 12
  7. #define TRACK_P 1
  8. #define TRACK_I 2
  9. #define TRACK_D 3
  10. #define BRUSH_P 4
  11. #define BRUSH_I 5
  12. #define BRUSH_D 6
  13. #define LOWSPEED 7
  14. #define HIGHSPEED 8
  15. #define DIVIDI_RPM 9
  16. #define MAXCURRENT 10
  17. #define MAXTIME 11
  18. #define REST_STM32 12
  19. #define LEFT_TRACK 13
  20. #define RIGHT_TRACK 14
  21. #define PIXHAWK_REQURE 0xFF
  22. #define SET_PARME 0xF0
  23. #define RESPOND 0xF1
  24. extern u8 CAN_DATA_CNT;
  25. extern u32 Init_Flash_Data;
  26. extern u8 CAN_RecData[CAN_RecDataMax];
  27. extern u8 CAN_RecData_i;
  28. extern u8 CAN_RecData_Toggle;
  29. extern u8 CAN_RecData_TID;
  30. void CAN_Config(void);
  31. void Send_Flash_Set(u8 num, u8 flag, float value);
  32. float Rec_Flash_Set(u8 data[]);
  33. void Send_CAN_DATA1(void);
  34. void Send_CAN_DATA2(void);
  35. void Send_CAN_DATA3(void);
  36. void Send_CAN_DATA4(void);
  37. void Send_CAN_DATA5(void);
  38. void Send_CAN_DATA6(void);
  39. //CAN1接收RX0中断使能
  40. #define CAN1_RX0_INT_ENABLE 1 //0,不使能;1,使能.
  41. u8 CAN1_Send_Msg(u8* msg,u32 Can_ID,u8 len); //发送数据
  42. u8 CAN1_Receive_Msg(u8 *buf, u32 *id);
  43. void CAN_NVIC_Config(u8 NVIC_IRQChannel, u8 pre, u8 sub);
  44. void CAN_GPIO_Config(u32 RCC_APBnPeriphn, GPIO_TypeDef* GPIOx, u16 GPIO_Pin, u16 GPIO_PinSource, u8 GPIO_AF);
  45. void CAN_Mod_Config(u32 RCC_APB1Periph, CAN_TypeDef* CANx, u32 EXTID, u32 MaskID);
  46. void Send_Flash_Set(u8 num, u8 flag, float value);
  47. void Send_CAN_MOTOR1DATA(void);
  48. void Send_CAN_MOTOR2DATA(void);
  49. void Send_CAN_MOTOR3DATA(void);
  50. #endif