summaryrefslogtreecommitdiff
path: root/firmware/protocol.h
blob: af2c6fbb2ba4f8839c7aaaeeb1101eef8b614b8f (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
 * Protocol is under GNU/GPL2!
 * Author: Benedikt Sauter sauter@empronix.com, 2007-09-02
 * 
 * BYTE	      command
 * BYTE	      parameter
 * BYTE	      length body <x>
 * <x> BYTES  body
 *
 * max body length = 60 bytes
 */

/**
 * The first byte in the body of an response packet 
 * is always a value from the next table.
 */

#define RSP_OK                          0x01
#define RSP_ERROR                       0x02
#define RSP_UNKOWN_CMD                  0x03
#define RSP_UNKOWN_PIN                  0x04
#define RSP_UNKOWN_PORT                 0x05
#define RSP_WRONG_PIN_CONFIG            0x06
#define RSP_IMPOSSIBLE_PIN_CONFIG       0x07
#define RSP_TIMEOUT                     0x08


#define CMD_LATENCY_TIMER_SET           0x01
#define CMD_LATENCY_TIMER_GET           0x02
#define CMD_GET_HW_ID                   0x03
#define CMD_EXTERNAL_DEVICE             0x06

#define CMD_IO_INIT_PORT                0x10
#define CMD_IO_INIT_PIN                 0x11
#define CMD_IO_PORT_DIRECTION_IN        0x12
#define CMD_IO_PORT_DIRECTION_OUT       0x13
#define CMD_IO_PORT_DIRECTION_TRI       0x14
#define CMD_IO_PIN_DIRECTION_IN         0x15
#define CMD_IO_PIN_DIRECTION_OUT        0x16
#define CMD_IO_PIN_DIRECTION_TRI        0x17
#define CMD_IO_PORT_SET                 0x18
#define CMD_IO_PORT_GET                 0x19
#define CMD_IO_PIN_SET                  0x1A
#define CMD_IO_PIN_GET                  0x1B
#define CMD_IO_SET_STATUS_LED           0x1C

#define CMD_ADC_INIT_PIN                0x20
#define CMD_ADC_DEINIT_PIN              0x21
#define CMD_ADC_GET                     0x22
#define CMD_ADC_REF                     0x23

#define CMD_I2C_INIT                    0x30
#define CMD_I2C_DEINIT                  0x31
#define CMD_I2C_SET_BITRATE             0x32
#define CMD_I2C_SEND                    0x34
#define CMD_I2C_RECV                    0x35
#define CMD_I2C_SEND_START              0x36
#define CMD_I2C_SEND_STOP               0x37

#define CMD_SPI_INIT                    0x40
#define CMD_SPI_DEINIT                  0x41
#define CMD_SPI_SPEED                   0x42
#define CMD_SPI_SEND                    0x43
#define CMD_SPI_RECV                    0x44
#define CMD_SPI_SEND_AND_RECV           0x45


#define CMD_PWM_INIT_PIN                0x50
#define CMD_PWM_DEINIT_PIN              0x51
#define CMD_PWM_SPEED                   0x52
#define CMD_PWM_VALUE                   0x53


#define CMD_UART_INIT			0x60
#define CMD_UART_DEINIT			0x61
#define CMD_UART_BAUDRATE		0x62
#define CMD_UART_STOPBITS		0x63
#define CMD_UART_DATABITS		0x64
#define CMD_UART_PARITY			0x65
#define CMD_UART_RECV			0x67
#define CMD_UART_SEND			0x68

#define CMD_CAN_INIT                    0x70
#define CMD_CAN_DEINIT                  0x71
#define CMD_CAN_SEND_DATA               0x72
#define CMD_CAN_ENABLE_MOB              0x73
#define CMD_CAN_DISABLE_MOB             0x74
#define CMD_CAN_SEND_REMOTE             0x75
#define CMD_CAN_RECEIVE_DATA            0x76
#define CMD_CAN_SET_AUTOREPLY           0x77

#define CMD_EEPROM_READ_BYTES           0x80
#define CMD_EEPROM_WRITE_BYTES          0x81

#define PARAM_ADC_AREF                  0x01
#define PARAM_ADC_AVCC                  0x02
#define PARAM_ADC_INTERNAL              0x03


/* microwire eeprom */
#define CMD_EXTERNAL_93C46              0x01


#define CMD_93C46_INIT                  0x01
#define CMD_93C46_DEINIT                0x02
#define CMD_93C46_READ                  0x03
#define CMD_93C46_WRITE                 0x04