Subversion Repositories HomeAutomation

Rev

Rev 319 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 319 Rev 324
Line 261... Line 261...
261
                // Calculate crc on written data.
261
                // Calculate crc on written data.
262
                //TODO: This will not work if data is not sent sequentially without
262
                //TODO: This will not work if data is not sent sequentially without
263
                // holes, starting with offset=0. We might want to send a NACK if the
263
                // holes, starting with offset=0. We might want to send a NACK if the
264
                // offset in a CAN_NMT_PGM_DATA msg differs from the expected offset.
264
                // offset in a CAN_NMT_PGM_DATA msg differs from the expected offset.
265
                uint16_t loc, crc = 0;
265
                uint16_t loc, crc = 0;
266
                for (loc = base_addr; loc < addr - 2; loc++) { // addr will be last location written + 2.
266
                for (loc = base_addr; loc < addr; loc++) { // addr will be last location written + 2.
267
                    crc = _crc16_update(crc, pgm_read_byte(loc));
267
                    crc = _crc16_update(crc, pgm_read_byte(loc));
268
                }
268
                }
269
               
269
               
270
                tx_msg.Data.words[0] = crc;
270
                tx_msg.Data.words[0] = crc;
271
                send_msg = 1;
271
                send_msg = 1;