92 lines
3.1 KiB
C
92 lines
3.1 KiB
C
/**
|
||
****************************(C) COPYRIGHT 2019 DJI****************************
|
||
* @file can_receive.c/h
|
||
* @brief there is CAN interrupt function to receive motor data,
|
||
* and CAN send function to send motor current to control motor.
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN<41>жϽ<D0B6><CFBD>պ<EFBFBD><D5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,CAN<41><4E><EFBFBD>ͺ<EFBFBD><CDBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>.
|
||
* @note
|
||
* @history
|
||
* Version Date Author Modification
|
||
* V1.0.0 Dec-26-2018 RM 1. done
|
||
*
|
||
@verbatim
|
||
==============================================================================
|
||
|
||
==============================================================================
|
||
@endverbatim
|
||
****************************(C) COPYRIGHT 2019 DJI****************************
|
||
*/
|
||
|
||
#ifndef CAN_RECEIVE_H
|
||
#define CAN_RECEIVE_H
|
||
|
||
#include "main.h"
|
||
|
||
#define CHASSIS_CAN hcan1
|
||
|
||
/* CAN send and receive ID */
|
||
typedef enum
|
||
{
|
||
CAN_CHASSIS_ALL_ID = 0x200,
|
||
CAN_3508_M1_ID = 0x201,
|
||
CAN_3508_M2_ID = 0x202,
|
||
CAN_3508_M3_ID = 0x203,
|
||
CAN_3508_M4_ID = 0x204,
|
||
|
||
} can_msg_id_e;
|
||
|
||
//rm motor data
|
||
typedef struct
|
||
{
|
||
uint16_t ecd;
|
||
int16_t speed_rpm;
|
||
int16_t given_current;
|
||
uint8_t temperate;
|
||
int16_t last_ecd;
|
||
} motor_measure_t;
|
||
|
||
|
||
/**
|
||
* @brief send CAN packet of ID 0x700, it will set chassis motor 3508 to quick ID setting
|
||
* @param[in] none
|
||
* @retval none
|
||
*/
|
||
/**
|
||
* @brief <20><><EFBFBD><EFBFBD>IDΪ0x700<30><30>CAN<41><4E>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3508<30><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID
|
||
* @param[in] none
|
||
* @retval none
|
||
*/
|
||
extern void CAN_cmd_chassis_reset_ID(void);
|
||
|
||
/**
|
||
* @brief send control current of motor (0x201, 0x202, 0x203, 0x204)
|
||
* @param[in] motor1: (0x201) 3508 motor control current, range [-16384,16384]
|
||
* @param[in] motor2: (0x202) 3508 motor control current, range [-16384,16384]
|
||
* @param[in] motor3: (0x203) 3508 motor control current, range [-16384,16384]
|
||
* @param[in] motor4: (0x204) 3508 motor control current, range [-16384,16384]
|
||
* @retval none
|
||
*/
|
||
/**
|
||
* @brief <20><><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>(0x201,0x202,0x203,0x204)
|
||
* @param[in] motor1: (0x201) 3508<30><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>, <20><>Χ [-16384,16384]
|
||
* @param[in] motor2: (0x202) 3508<30><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>, <20><>Χ [-16384,16384]
|
||
* @param[in] motor3: (0x203) 3508<30><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>, <20><>Χ [-16384,16384]
|
||
* @param[in] motor4: (0x204) 3508<30><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>, <20><>Χ [-16384,16384]
|
||
* @retval none
|
||
*/
|
||
extern void CAN_cmd_chassis(int16_t motor1, int16_t motor2, int16_t motor3, int16_t motor4);
|
||
|
||
/**
|
||
* @brief return the chassis 3508 motor data point
|
||
* @param[in] i: motor number,range [0,3]
|
||
* @retval motor data point
|
||
*/
|
||
/**
|
||
* @brief <20><><EFBFBD>ص<EFBFBD><D8B5>̵<EFBFBD><CCB5> 3508<30><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||
* @param[in] i: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>Χ[0,3]
|
||
* @retval <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||
*/
|
||
extern const motor_measure_t *get_chassis_motor_measure_point(uint8_t i);
|
||
|
||
|
||
#endif |