1 | #ifndef CAN_INTERFACE_H_
|
2 | #define CAN_INTERFACE_H_
|
3 |
|
4 | #include <can2515.h>
|
5 | #include <avr/boot.h>
|
6 | #include <string.h>
|
7 | #include "Bootloader.h"
|
8 |
|
9 | #define DEVICE_ID 2
|
10 |
|
11 | #define FLASHED_LINE_SUCCESSFUL 1
|
12 | #define CHECKSUM_FAILURE 0
|
13 | //#define FLASH_COMPLETE 2
|
14 |
|
15 |
|
16 | enum Can_Bootloader_State {AWAITING_REQUEST, AWAITING_DATA, WRITING_TO_FLASH, WRITING_TO_CAN};
|
17 |
|
18 |
|
19 | void switch_active_data_buffer();
|
20 | void switch_active_page_buffer();
|
21 | int8_t buffer_can_message_data(uint8_t length, char *data);
|
22 | int8_t buffer_page_data(uint8_t length, char *data);
|
23 | uint8_t handle_can_message(Message *message);
|
24 | void handle_can_request(Message *message);
|
25 | void handle_can_data(Message *message);
|
26 | void handle_can_flash_complete(Message *message);
|
27 | uint8_t parse_hex_line(uint8_t buffer);
|
28 | void write_bootloader_message_buffered_to_can(uint16_t length, char *input);
|
29 |
|
30 | #endif
|