AtMega CAN Bootloader
Well documented CAN-based bootloader for AtMega processors
Macros
messagedefinitions.h File Reference

Go to the source code of this file.

Macros

#define NODE_ADDRESS_MASK   0x007F
 
#define MPOSCOMMANDBYTE   0x00
 
#define MPOSERRORDESCBYTE   0x01
 
Message types for protocol.

These define the two message types used by the CAN-bootloader to communicate.

#define MTYPESDOSLAVE   0x0580
 
#define MTYPESDOMASTER   0x0600
 
Message command types.
data[0] is always the command.
MACTYPERESETNODE 0x02
Data length: 1.
Response: N/A
Data length 1.
Response: 8 bytes
data[1] = BL_VERSION_MAJOR;
data[2] = BL_VERSION_MINOR;
data[3] = BL_VERSION_BUILD;
data[4] = boot_signature_byte_get(0x00);
data[5] = boot_signature_byte_get(0x02);
data[6] = boot_signature_byte_get(0x04);
data[7] = NODETYPEDEF;
Data length 3.
data[1] = Address to read (MSB)
data[2] = Address to read (LSB)
Response: 4 bytes.
data[1] = Address read (MSB)
data[2] = Address read (LSB)
data[3] = Data from address.
MACTYPEWRITEEEPROMBYTE 0x56
Data length 4.
data[1] = Address to write (MSB)
data[2] = Address to write (LSB)
data[3] = Data from address.
Response: 4 bytes.
data[1] = Address written (MSB)
data[2] = Address written (LSB)
data[3] = Data from address.
MACTYPEREADFLASHBYTE 0x5A
Same as MACTYPEREADEEPROM
Same as MACTYPEREADEEPROM
Same as MACTYPEWRITEEEPROM
Data length 2.
data[1] = Page to select
Response: 2 bytes.
data[1] = Selected page.
MACTYPEWRITEFLASHPAGE 0x5C
Data length 1.
Response: 2 bytes
#define MACTYPERESETNODE   0x02
 
#define MACTYPESENDBOOTLOADERVERSION   0x50
 
#define MACTYPEREADEEPROMBYTE   0x55
 
#define MACTYPEWRITEEEPROMBYTE   0x56
 
#define MACTYPEREADFLASHBYTE   0x5A
 
#define MACTYPESELECTFLASHPAGE   0x5B
 
#define MACTYPEWRITEFLASHPAGE   0x5C
 
#define MACTYPEREADBYTEFROMFLASHBUFFER   0x5D
 
#define MACTYPEWRITEBYTETOFLASHBUFFER   0x5E
 
Error codes and responses.

0xF0 is command error byte. Second byte is error code.

Note
See error code definitions (second data byte).
#define MACTYPESENDERROR   0xF0
 
#define ERRORBOOTLOADERSESSIONNOTOPEN   0x50
 
#define ERRORBOOTLOADERINVALIDDATA   0x51
 

Detailed Description

Bootloader protocol message definitions. (license: GPLv2 or LGPLv2.1)

Author
Tuomas Huuki tuoma.nosp@m.s.hu.nosp@m.uki@p.nosp@m.roxi.nosp@m.mia.f.nosp@m.i
See also
http://proximia.fi

Macro Definition Documentation

◆ ERRORBOOTLOADERINVALIDDATA

#define ERRORBOOTLOADERINVALIDDATA   0x51

Invalid data.

◆ ERRORBOOTLOADERSESSIONNOTOPEN

#define ERRORBOOTLOADERSESSIONNOTOPEN   0x50

Session not open (memory access requested without session).

◆ MACTYPEREADBYTEFROMFLASHBUFFER

#define MACTYPEREADBYTEFROMFLASHBUFFER   0x5D

Read byte from flash page buffer.

◆ MACTYPEREADEEPROMBYTE

#define MACTYPEREADEEPROMBYTE   0x55

Write byte to EEPROM.

◆ MACTYPEREADFLASHBYTE

#define MACTYPEREADFLASHBYTE   0x5A

Read byte from program memory.

◆ MACTYPERESETNODE

#define MACTYPERESETNODE   0x02

Reset node.

◆ MACTYPESELECTFLASHPAGE

#define MACTYPESELECTFLASHPAGE   0x5B

Select flash page.

◆ MACTYPESENDBOOTLOADERVERSION

#define MACTYPESENDBOOTLOADERVERSION   0x50

Request/Send bootloader version and ID information

◆ MACTYPESENDERROR

#define MACTYPESENDERROR   0xF0

Send error

◆ MACTYPEWRITEBYTETOFLASHBUFFER

#define MACTYPEWRITEBYTETOFLASHBUFFER   0x5E

Write byte to flash page buffer.

◆ MACTYPEWRITEEEPROMBYTE

#define MACTYPEWRITEEEPROMBYTE   0x56

Read byte from EEPROM.

◆ MACTYPEWRITEFLASHPAGE

#define MACTYPEWRITEFLASHPAGE   0x5C

Write flash page.

◆ MPOSCOMMANDBYTE

#define MPOSCOMMANDBYTE   0x00

Command byte position. Position of the command byte

◆ MPOSERRORDESCBYTE

#define MPOSERRORDESCBYTE   0x01

Error desctiption byte position. Position of the errpr byte

◆ MTYPESDOMASTER

#define MTYPESDOMASTER   0x0600

Communication from master(NMT) -> slave(node).

◆ MTYPESDOSLAVE

#define MTYPESDOSLAVE   0x0580

Communication from slave(node) -> master(NMT).

◆ NODE_ADDRESS_MASK

#define NODE_ADDRESS_MASK   0x007F

Mask for separating message TYPE and ID from CAN ID.