Rev 284 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 284 | Rev 292 | ||
|---|---|---|---|
| Line 124... | Line 124... | ||
| 124 | // This unneccessary initialization uses 8 bytes flash, just to make the compiler happy! |
124 | // This unneccessary initialization uses 8 bytes flash, just to make the compiler happy! |
| 125 | uint16_t base_addr = 0; |
125 | uint16_t base_addr = 0; |
| 126 | uint16_t offset = 0; |
126 | uint16_t offset = 0; |
| 127 | uint16_t addr; |
127 | uint16_t addr; |
| 128 | uint8_t len; |
128 | uint8_t len; |
| 129 |
|
129 | uint16_t i; |
| 130 | uint16_t data; |
130 | uint16_t data; |
| 131 | Can_Message_t tx_msg; |
131 | Can_Message_t tx_msg; |
| 132 | Can_Message_t bios_msg; |
132 | Can_Message_t bios_msg; |
| 133 | bios_msg_ptr = &bios_msg; |
133 | bios_msg_ptr = &bios_msg; |
| 134 | 134 | ||
| Line 237... | Line 237... | ||
| 237 | } |
237 | } |
| 238 | } |
238 | } |
| 239 | if (nmt_type == CAN_NMT_PGM_END) { |
239 | if (nmt_type == CAN_NMT_PGM_END) { |
| 240 | flash_flush_buffer(); |
240 | flash_flush_buffer(); |
| 241 | //check crc |
241 | //check crc |
| 242 | //data = bios_msg.Data.words[0]; |
- | |
| 243 |
|
242 | uint16_t calccrc = 0; |
| 244 |
|
243 | for (i=0; i < offset; i++) { |
| 245 |
|
244 | calccrc = _crc16_update(calccrc, pgm_read_byte(base_addr+i)); |
| 246 |
|
245 | } |
| 247 |
|
246 | tx_msg.Data.words[0] = calccrc; |
| 248 | //if (data == calccrc) { //crc ok |
- | |
| 249 | if (1) { //crc ok |
- | |
| 250 | //send CAN_NMT_PGM_ACK(crc) |
- | |
| 251 | tx_msg.Id = CAN_ID_NMT_PGM_ACK; |
247 | tx_msg.Id = CAN_ID_NMT_PGM_ACK; |
| 252 | } else { |
- | |
| 253 | //send CAN_NMT_PGM_NACK(crc) |
- | |
| 254 | tx_msg.Id = CAN_ID_NMT_PGM_NACK; |
- | |
| 255 | } |
- | |
| 256 | bios_state = BIOS_NOAPP; |
248 | bios_state = BIOS_NOAPP; |
| 257 | } |
249 | } |
| 258 | } |
250 | } |
| 259 | while (Can_Send(&tx_msg) != CAN_OK); |
251 | while (Can_Send(&tx_msg) != CAN_OK); |
| 260 | 252 | ||