-
Notifications
You must be signed in to change notification settings - Fork 8
/
commands.h
73 lines (59 loc) · 1.74 KB
/
commands.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef __COMMANDS_H
#define __COMMANDS_H
#include "messages.h"
#include "main.h"
#include "75x_lib.h"
#include "stdio.h"
#include "main.h"
#include "lists.h"
#include "string.h"
#include "leds.h"
#include "i2c_ee.h"
//USB includes
#include "usb_lib.h"
#include "usb_desc.h"
#include "hw_config.h"
/// Status codes /returned by status request)
#define CANAL_STATUS_NONE 0x00000000
#define CANAL_STATUS_ACTIVE 0x10000000
#define CANAL_STATUS_PASSIVE 0x40000000
#define CANAL_STATUS_BUS_OFF 0x80000000
#define CANAL_STATUS_BUS_WARN 0x20000000
#define CANAL_STATUS_PHY_FAULT 0x08000000
#define CANAL_STATUS_PHY_H 0x04000000
#define CANAL_STATUS_PHY_L 0x02000000
#define CANAL_STATUS_SLEEPING 0x01000000
#define CANAL_STATUS_STOPPED 0x00800000
#define CANAL_STATUS_RECIVE_BUFFER_FULL 0x00400000 // Drivers buffer
#define CANAL_STATUS_TRANSMIT_BUFFER_FULL 0x00200000 // Drivers buffer
enum CAN_BAUD_RATE
{
CAN_BAUD_1000 = 0,
CAN_BAUD_800,
CAN_BAUD_500,
CAN_BAUD_250,
CAN_BAUD_125,
CAN_BAUD_100,
CAN_BAUD_50,
CAN_BAUD_20,
CAN_BAUD_10,
CAN_BAUD_MANUAL
};
#define CAN_MODE_NORMAL 0
#define CAN_MODE_SILENT 1
#define CAN_MODE_LOOPBACK 2
#define CAN_MODE_SILENT_LOOPBACK 3
typedef struct
{
u8 tseg1;
u8 tseg2;
u8 sjw;
u16 brp;
}CAN_TIMINGS;
extern void USB2CAN_reset(void);
extern void USB2CAN_open(u32 speed,u32 flags,CAN_TIMINGS *CanTimings);
extern void USB2CAN_close(void);
extern void USB2CAN_set_speed(u8 speed,CAN_TIMINGS *CanTimings);
extern bool USB2CAN_get_status(u32 *res);
extern bool USB2CAN_get_statistics( u8 num, u32 *res );
#endif