Common message types, result codes and payload data types for the Task-based TLV/INM (TTLV) communication module (task_tlv.h). Also declares a standard set of logical registers for TLV/INM nodes, as well as helper macros that simplify implementation of the logical register interface. Finally, there are some convenience functions for transmission of INM response messages.
CAUTION: The current logical register specification has bothersome and unnecessary limitations (e.g. all registers being one byte large) and is therefore being considered for compatibility-breaking replacement in a future release of libavr.
std_tlv.h | Common message types, result codes and payload data types for the Task-based TLV/INM (TTLV) communication module (task_tlv.h). |
Message Types | |
Enumerations | |
TTLV Message Type Identifiers | NOTE: Application-specific message type identifiers SHOULD be greater than or equal to TTLV_MSG_T_APPLICATION. |
Result Codes | |
Enumerations | |
TTLV Operation Result Codes | NOTE: Application-specific result codes SHOULD be greater than or equal to TTLV_RES_APPLICATION and not equal to TTLV_RES_NONE. |
Variables | |
ttlv_result | The type of TTLV result codes. |
ttlv_msg_inm_result | Specifies the format of a generic INM response message. |
Variables | |
result_code | Identifies the result of the requested operation. |
request_id | Identifies the request message. |
Logical Registers | |
Variables | |
ttlv_reg_index | The type of TTLV logical register identifiers. |
ttlv_reg_value | The type of TTLV logical register values. |
ttlv_regpair_value | The type of TTLV logical register pair values. |
ttlv_msg_reg | Specifies the format of an identifier-value pair for a logical register. |
Variables | |
index | Register identifier. |
value | Register value. |
ttlv_msg_inm_reg | Specifies the format of an identifier-value pair for a logical register, with an INM message ID appended. |
Variables | |
index | Register identifier. |
value | Register value. |
request_id | Identifies the request message. |
ttlv_msg_regpair | Specifies the format of an identifier-value pair for a logical register pair. |
Variables | |
index | Register identifier. |
value | Register pair value. |
ttlv_msg_inm_regpair | Specifies the format of an identifier-value pair for a logical register pair, with an INM message ID appended. |
Variables | |
index | Register identifier. |
value | Register pair value. |
request_id | Identifies the request message. |
Message Lengths and Type Checking | |
Enumerations | |
Standard TTLV Message Lengths | |
Macros | |
TTLV_CHECK_RESULT | True if and only if the current ttlv_recv_header matches a RESULT message with a ttlv_result payload. |
TTLV_CHECK_INM_RESULT | True if and only if the current ttlv_recv_header matches an INM_RESULT message with a ttlv_msg_inm_result payload. |
TTLV_CHECK_REG_READ | True if and only if the current ttlv_recv_header matches a REG_READ message with a ttlv_reg_index payload. |
TTLV_CHECK_REG_WRITE | True if and only if the current ttlv_recv_header matches a REG_WRITE message with a ttlv_msg_reg payload. |
TTLV_CHECK_REG_TOGGLE | True if and only if the current ttlv_recv_header matches a REG_TOGGLE message with a ttlv_msg_reg payload. |
TTLV_CHECK_REG_RW_EXCH | True if and only if the current ttlv_recv_header matches a REG_RW_EXCH message with a ttlv_msg_reg payload. |
TTLV_CHECK_REG_WR_EXCH | True if and only if the current ttlv_recv_header matches a REG_WR_EXCH message with a ttlv_msg_reg payload. |
TTLV_CHECK_REGPAIR_READ | True if and only if the current ttlv_recv_header matches a REGPAIR_READ message with a ttlv_reg_index payload. |
TTLV_CHECK_REGPAIR_WRITE | True if and only if the current ttlv_recv_header matches a REGPAIR_WRITE message with a ttlv_msg_regpair payload. |
TTLV_CHECK_REGPAIR_TOGGLE | True if and only if the current ttlv_recv_header matches a REGPAIR_TOGGLE message with a ttlv_msg_regpair payload. |
TTLV_CHECK_REGPAIR_RW_EXCH | True if and only if the current ttlv_recv_header matches a REGPAIR_RW_EXCH message with a ttlv_msg_regpair payload. |
TTLV_CHECK_REGPAIR_WR_EXCH | True if and only if the current ttlv_recv_header matches a REGPAIR_WR_EXCH message with a ttlv_msg_regpair payload. |
Function Definition Macros | |
Functions | |
ttlv_reg_setter | The type of pointers to functions that set the value of a specified logical register. |
ttlv_reg_manipulator | The type of pointers to functions that perform some update operation on a specified logical register. |
ttlv_regpair_setter | The type of pointers to functions that set the value of a specified logical register pair. |
ttlv_regpair_manipulator | The type of pointers to functions that perform some update operation on a specified logical register pair. |
Macros | |
TTLV_STD_REG_TOGGLE | Defines a static function that uses specified logical register read and write functions to implement the register toggle operation (R ^= V; ret R). |
TTLV_STD_REG_RW_EXCH | Defines a static function that uses specified logical register read and write functions to implement the register read-write operation (X = R; R = V; ret X). |
TTLV_STD_REG_WR_EXCH | Defines a static function that uses specified logical register read and write functions to implement the register write-read operation (R = V; ret R). |
TTLV_STD_REGPAIR_READ | Defines a static function that uses a specified logical register read function to implement the register pair read operation (ret R). |
TTLV_STD_REGPAIR_WRITE | Defines a static function that uses a specified logical register write function to implement the register pair write operation (R = V). |
TTLV_STD_REGPAIR_TOGGLE | Defines a static function that uses specified logical register pair read and write functions to implement the register pair toggle operation (R ^= V; ret R). |
TTLV_STD_REGPAIR_RW_EXCH | Defines a static function that uses specified logical register pair read and write functions to implement the register pair read-write operation (X = R; R = V; ret X). |
TTLV_STD_REGPAIR_WR_EXCH | Defines a static function that uses specified logical register pair read and write functions to implement the register pair write-read operation (R = V; ret R). |
API Functions | |
Functions | |
ttlv_xmit_response | Convenience function that uses ttlv_xmit to transmit a message. |
ttlv_xmit_result | Convenience function that uses ttlv_xmit to transmit a TTLV_MSG_T_RESULT message. |
ttlv_xmit_inm_result | Convenience function that uses ttlv_xmit to transmit a TTLV_MSG_T_INM_RESULT message. |
Enumerations | |
TTLV Message Type Identifiers | NOTE: Application-specific message type identifiers SHOULD be greater than or equal to TTLV_MSG_T_APPLICATION. |
NOTE: Application-specific message type identifiers SHOULD be greater than or equal to TTLV_MSG_T_APPLICATION.
Enumerations | |
TTLV Operation Result Codes | NOTE: Application-specific result codes SHOULD be greater than or equal to TTLV_RES_APPLICATION and not equal to TTLV_RES_NONE. |
Variables | |
ttlv_result | The type of TTLV result codes. |
NOTE: Application-specific result codes SHOULD be greater than or equal to TTLV_RES_APPLICATION and not equal to TTLV_RES_NONE.
typedef struct __attribute__ ( (__packed__) ) ttlv_msg_inm_result
Specifies the format of a generic INM response message.
Variables | |
result_code | Identifies the result of the requested operation. |
request_id | Identifies the request message. |
Variables | |
ttlv_reg_index | The type of TTLV logical register identifiers. |
ttlv_reg_value | The type of TTLV logical register values. |
ttlv_regpair_value | The type of TTLV logical register pair values. |
typedef struct __attribute__ ( (__packed__) ) ttlv_msg_inm_reg
Specifies the format of an identifier-value pair for a logical register, with an INM message ID appended. Such triples are the payloads of register read responses in INM applications.
Variables | |
index | Register identifier. |
value | Register value. |
request_id | Identifies the request message. |
typedef struct __attribute__ ( (__packed__) ) ttlv_msg_inm_regpair
Specifies the format of an identifier-value pair for a logical register pair, with an INM message ID appended. Such triples are the payloads of register pair read responses in INM applications.
Variables | |
index | Register identifier. |
value | Register pair value. |
request_id | Identifies the request message. |
Enumerations | |
Standard TTLV Message Lengths | |
Macros | |
TTLV_CHECK_RESULT | True if and only if the current ttlv_recv_header matches a RESULT message with a ttlv_result payload. |
TTLV_CHECK_INM_RESULT | True if and only if the current ttlv_recv_header matches an INM_RESULT message with a ttlv_msg_inm_result payload. |
TTLV_CHECK_REG_READ | True if and only if the current ttlv_recv_header matches a REG_READ message with a ttlv_reg_index payload. |
TTLV_CHECK_REG_WRITE | True if and only if the current ttlv_recv_header matches a REG_WRITE message with a ttlv_msg_reg payload. |
TTLV_CHECK_REG_TOGGLE | True if and only if the current ttlv_recv_header matches a REG_TOGGLE message with a ttlv_msg_reg payload. |
TTLV_CHECK_REG_RW_EXCH | True if and only if the current ttlv_recv_header matches a REG_RW_EXCH message with a ttlv_msg_reg payload. |
TTLV_CHECK_REG_WR_EXCH | True if and only if the current ttlv_recv_header matches a REG_WR_EXCH message with a ttlv_msg_reg payload. |
TTLV_CHECK_REGPAIR_READ | True if and only if the current ttlv_recv_header matches a REGPAIR_READ message with a ttlv_reg_index payload. |
TTLV_CHECK_REGPAIR_WRITE | True if and only if the current ttlv_recv_header matches a REGPAIR_WRITE message with a ttlv_msg_regpair payload. |
TTLV_CHECK_REGPAIR_TOGGLE | True if and only if the current ttlv_recv_header matches a REGPAIR_TOGGLE message with a ttlv_msg_regpair payload. |
TTLV_CHECK_REGPAIR_RW_EXCH | True if and only if the current ttlv_recv_header matches a REGPAIR_RW_EXCH message with a ttlv_msg_regpair payload. |
TTLV_CHECK_REGPAIR_WR_EXCH | True if and only if the current ttlv_recv_header matches a REGPAIR_WR_EXCH message with a ttlv_msg_regpair payload. |
TTLV_MSG_L_RESULT | TLV length of a TTLV_MSG_T_RESULT message. |
TTLV_MSG_L_INM_RESULT | TLV length of a TTLV_MSG_T_INM_RESULT message. |
TTLV_MSG_L_REG_READ | TLV length of a TTLV_MSG_T_REG_READ message. |
TTLV_MSG_L_REG_READ_RES | TLV length of a TTLV_MSG_T_REG_READ_RES message. |
TTLV_MSG_L_INM_REG_READ_RES | TLV length of a TTLV_MSG_T_INM_REG_READ_RES message. |
TTLV_MSG_L_REG_WRITE | TLV length of a TTLV_MSG_T_REG_WRITE message. |
TTLV_MSG_L_REG_TOGGLE | TLV length of a TTLV_MSG_T_REG_TOGGLE message. |
TTLV_MSG_L_REG_RW_EXCH | TLV length of a TTLV_MSG_T_REG_RW_EXCH message. |
TTLV_MSG_L_REG_WR_EXCH | TLV length of a TTLV_MSG_T_REG_WR_EXCH message. |
TTLV_MSG_L_REGPAIR_READ | TLV length of a TTLV_MSG_T_REGPAIR_READ message. |
TTLV_MSG_L_REGPAIR_READ_RES | TLV length of a TTLV_MSG_T_REGPAIR_READ_RES message. |
TTLV_MSG_L_INM_REGPAIR_READ_RES | TLV length of a TTLV_MSG_T_INM_REGPAIR_READ_RES message. |
TTLV_MSG_L_REGPAIR_WRITE | TLV length of a TTLV_MSG_T_REGPAIR_WRITE message. |
TTLV_MSG_L_REGPAIR_TOGGLE | TLV length of a TTLV_MSG_T_REGPAIR_TOGGLE message. |
TTLV_MSG_L_REGPAIR_RW_EXCH | TLV length of a TTLV_MSG_T_REGPAIR_RW_EXCH message. |
TTLV_MSG_L_REGPAIR_WR_EXCH | TLV length of a TTLV_MSG_T_REGPAIR_WR_EXCH message. |
True if and only if the current ttlv_recv_header matches a RESULT message with a ttlv_result payload. Expression macro.
True if and only if the current ttlv_recv_header matches an INM_RESULT message with a ttlv_msg_inm_result payload. Expression macro.
True if and only if the current ttlv_recv_header matches a REG_READ message with a ttlv_reg_index payload. Expression macro.
True if and only if the current ttlv_recv_header matches a REG_WRITE message with a ttlv_msg_reg payload. Expression macro.
True if and only if the current ttlv_recv_header matches a REG_TOGGLE message with a ttlv_msg_reg payload. Expression macro.
True if and only if the current ttlv_recv_header matches a REG_RW_EXCH message with a ttlv_msg_reg payload. Expression macro.
True if and only if the current ttlv_recv_header matches a REG_WR_EXCH message with a ttlv_msg_reg payload. Expression macro.
True if and only if the current ttlv_recv_header matches a REGPAIR_READ message with a ttlv_reg_index payload. Expression macro.
True if and only if the current ttlv_recv_header matches a REGPAIR_WRITE message with a ttlv_msg_regpair payload. Expression macro.
True if and only if the current ttlv_recv_header matches a REGPAIR_TOGGLE message with a ttlv_msg_regpair payload. Expression macro.
True if and only if the current ttlv_recv_header matches a REGPAIR_RW_EXCH message with a ttlv_msg_regpair payload. Expression macro.
True if and only if the current ttlv_recv_header matches a REGPAIR_WR_EXCH message with a ttlv_msg_regpair payload. Expression macro.
Functions | |
ttlv_reg_setter | The type of pointers to functions that set the value of a specified logical register. |
ttlv_reg_manipulator | The type of pointers to functions that perform some update operation on a specified logical register. |
ttlv_regpair_setter | The type of pointers to functions that set the value of a specified logical register pair. |
ttlv_regpair_manipulator | The type of pointers to functions that perform some update operation on a specified logical register pair. |
Macros | |
TTLV_STD_REG_TOGGLE | Defines a static function that uses specified logical register read and write functions to implement the register toggle operation (R ^= V; ret R). |
TTLV_STD_REG_RW_EXCH | Defines a static function that uses specified logical register read and write functions to implement the register read-write operation (X = R; R = V; ret X). |
TTLV_STD_REG_WR_EXCH | Defines a static function that uses specified logical register read and write functions to implement the register write-read operation (R = V; ret R). |
TTLV_STD_REGPAIR_READ | Defines a static function that uses a specified logical register read function to implement the register pair read operation (ret R). |
TTLV_STD_REGPAIR_WRITE | Defines a static function that uses a specified logical register write function to implement the register pair write operation (R = V). |
TTLV_STD_REGPAIR_TOGGLE | Defines a static function that uses specified logical register pair read and write functions to implement the register pair toggle operation (R ^= V; ret R). |
TTLV_STD_REGPAIR_RW_EXCH | Defines a static function that uses specified logical register pair read and write functions to implement the register pair read-write operation (X = R; R = V; ret X). |
TTLV_STD_REGPAIR_WR_EXCH | Defines a static function that uses specified logical register pair read and write functions to implement the register pair write-read operation (R = V; ret R). |
typedef ttlv_result ( * ttlv_reg_setter )(ttlv_reg_index index, ttlv_reg_value value)
The type of pointers to functions that set the value of a specified logical register.
index | Identifier of the target logical register. |
value | The new register value. |
A ttlv_result indicating the outcome of the attempted register operation.
typedef ttlv_result ( * ttlv_reg_manipulator )(ttlv_reg_index index, ttlv_reg_value *value_p)
The type of pointers to functions that perform some update operation on a specified logical register.
index | Identifier of the target logical register. |
value_p | Pointer to a register value. Used both to receive the input value and to return the output value. |
A ttlv_result indicating the outcome of the attempted register operation.
typedef ttlv_result ( * ttlv_regpair_setter )(ttlv_reg_index index, ttlv_regpair_value value)
The type of pointers to functions that set the value of a specified logical register pair.
index | Identifier of the lower half of the target logical register pair. |
value | The new register pair value. |
A ttlv_result indicating the outcome of the attempted register operation.
typedef ttlv_result ( * ttlv_regpair_manipulator )(ttlv_reg_index index, ttlv_regpair_value *value_p)
The type of pointers to functions that perform some update operation on a specified logical register pair.
index | Identifier of the lower half of the target logical register pair. |
value_p | Pointer to a register pair value. Used both to receive the input value and to return the output value. |
A ttlv_result indicating the outcome of the attempted register operation.
Defines a static function that uses specified logical register read and write functions to implement the register toggle operation (R ^= V; ret R). Function definition macro.
RF | Name of a ttlv_reg_manipulator that implements the read operation. |
WF | Name of a ttlv_reg_setter that implements the write operation. |
DF | Name of the emitted register toggle function. |
Emits a definition of a static ttlv_reg_manipulator function that implements the register toggle operation.
Defines a static function that uses specified logical register read and write functions to implement the register read-write operation (X = R; R = V; ret X). Function definition macro.
RF | Name of a ttlv_reg_manipulator that implements the read operation. |
WF | Name of a ttlv_reg_setter that implements the write operation. |
DF | Name of the emitted register read-write function. |
Emits a definition of a ttlv_reg_manipulator function that implements the register read-write operation.
Defines a static function that uses specified logical register read and write functions to implement the register write-read operation (R = V; ret R). Function definition macro.
RF | Name of a ttlv_reg_manipulator that implements the read operation. |
WF | Name of a ttlv_reg_setter that implements the write operation. |
DF | Name of the emitted register write-read function. |
Emits a definition of a static ttlv_reg_manipulator function that implements the register write-read operation.
Defines a static function that uses a specified logical register read function to implement the register pair read operation (ret R). Function definition macro.
RF | Name of a ttlv_reg_manipulator that implements the read operation. |
DF | Name of the emitted register pair read function. |
Emits a definition of a static ttlv_regpair_manipulator function that implements the register pair read operation.
Defines a static function that uses a specified logical register write function to implement the register pair write operation (R = V). Function definition macro.
WF | Name of a ttlv_reg_setter that implements the write operation. |
DF | Name of the emitted register pair write function. |
Emits a definition of a static ttlv_regpair_setter function that implements the register pair write operation.
Defines a static function that uses specified logical register pair read and write functions to implement the register pair toggle operation (R ^= V; ret R). Function definition macro.
RF | Name of a ttlv_regpair_manipulator that implements the read operation. |
WF | Name of a ttlv_regpair_setter that implements the write operation. |
DF | Name of the emitted register pair toggle function. |
Emits a definition of a static ttlv_regpair_manipulator function that implements the register pair toggle operation.
Defines a static function that uses specified logical register pair read and write functions to implement the register pair read-write operation (X = R; R = V; ret X). Function definition macro.
RF | Name of a ttlv_regpair_manipulator that implements the read operation. |
WF | Name of a ttlv_regpair_setter that implements the write operation. |
DF | Name of the emitted register pair read-write function. |
Emits a definition of a static ttlv_regpair_manipulator function that implements the register pair read-write operation.
Defines a static function that uses specified logical register pair read and write functions to implement the register pair write-read operation (R = V; ret R). Function definition macro.
RF | Name of a ttlv_regpair_manipulator that implements the read operation. |
WF | Name of a ttlv_regpair_setter that implements the write operation. |
DF | Name of the emitted register pair write-read function. |
Emits a definition of a static ttlv_regpair_manipulator function that implements the register pair write-read operation.
Functions | |
ttlv_xmit_response | Convenience function that uses ttlv_xmit to transmit a message. |
ttlv_xmit_result | Convenience function that uses ttlv_xmit to transmit a TTLV_MSG_T_RESULT message. |
ttlv_xmit_inm_result | Convenience function that uses ttlv_xmit to transmit a TTLV_MSG_T_INM_RESULT message. |
ttlv_state ttlv_xmit_response( uint8_t type, uint8_t length, const uint8_t * data_p )
Convenience function that uses ttlv_xmit to transmit a message. The INM destination address will be copied from the srcadr field of ttlv_recv_inm_header (assumed to contain the address of the source of the most recently received request).
type | TLV type identifier of the message to transmit. |
length | TLV length of the message to transmit. |
data_p | Pointer to the data bytes (TLV value) of the message to transmit. |
An integer result code, which will be an error code if and only if the attempt to initiate transmission failed.
ttlv_state ttlv_xmit_result( ttlv_result res )
Convenience function that uses ttlv_xmit to transmit a TTLV_MSG_T_RESULT message. The INM destination address will be copied from the srcadr field of ttlv_recv_inm_header (assumed to contain the address of the source of the most recently received request).
res | The result code to send in the TTLV_MSG_T_RESULT message. |
An integer result code, which will be an error code if and only if the attempt to initiate transmission failed.
ttlv_state ttlv_xmit_inm_result( ttlv_result res )
Convenience function that uses ttlv_xmit to transmit a TTLV_MSG_T_INM_RESULT message. The INM destination address and request ID in the transmitted message will be copied from the srcadr and msg_id fields of ttlv_recv_inm_header (assumed to contain the source address and message ID of the most recently received request).
res | The result code to send in the TTLV_MSG_T_INM_RESULT message. |
An integer result code, which will be an error code if and only if the attempt to initiate transmission failed.
The type of TTLV result codes.
typedef uint8_t ttlv_result
Specifies the format of a generic INM response message.
typedef struct __attribute__ ( (__packed__) ) ttlv_msg_inm_result
Identifies the result of the requested operation.
ttlv_result result_code
Identifies the request message.
uint16_t request_id
The type of TTLV logical register identifiers.
typedef uint8_t ttlv_reg_index
The type of TTLV logical register values.
typedef uint8_t ttlv_reg_value
The type of TTLV logical register pair values.
typedef uint16_t ttlv_regpair_value
Specifies the format of an identifier-value pair for a logical register.
typedef struct __attribute__ ( (__packed__) ) ttlv_msg_reg
Register identifier.
ttlv_reg_index index
Register value.
ttlv_reg_value value
Specifies the format of an identifier-value pair for a logical register, with an INM message ID appended.
typedef struct __attribute__ ( (__packed__) ) ttlv_msg_inm_reg
Register identifier.
ttlv_reg_index index
Register value.
ttlv_reg_value value
Identifies the request message.
uint16_t request_id
Specifies the format of an identifier-value pair for a logical register pair.
typedef struct __attribute__ ( (__packed__) ) ttlv_msg_regpair
Register identifier.
ttlv_reg_index index
Register pair value.
ttlv_regpair_value value
Specifies the format of an identifier-value pair for a logical register pair, with an INM message ID appended.
typedef struct __attribute__ ( (__packed__) ) ttlv_msg_inm_regpair
Register identifier.
ttlv_reg_index index
Register pair value.
ttlv_regpair_value value
Identifies the request message.
uint16_t request_id
Contains the most recently received ttlv_header.
extern ttlv_header ttlv_recv_header
The type of pointers to functions that set the value of a specified logical register.
typedef ttlv_result ( * ttlv_reg_setter )(ttlv_reg_index index, ttlv_reg_value value)
The type of pointers to functions that perform some update operation on a specified logical register.
typedef ttlv_result ( * ttlv_reg_manipulator )(ttlv_reg_index index, ttlv_reg_value *value_p)
The type of pointers to functions that set the value of a specified logical register pair.
typedef ttlv_result ( * ttlv_regpair_setter )(ttlv_reg_index index, ttlv_regpair_value value)
The type of pointers to functions that perform some update operation on a specified logical register pair.
typedef ttlv_result ( * ttlv_regpair_manipulator )(ttlv_reg_index index, ttlv_regpair_value *value_p)
Convenience function that uses ttlv_xmit to transmit a message.
ttlv_state ttlv_xmit_response( uint8_t type, uint8_t length, const uint8_t * data_p )
Initiates transmission of a specified message or clears the transmit buffer.
ttlv_state ttlv_xmit( uint8_t dstadr, uint8_t type, uint8_t length, const uint8_t * data_p )
Convenience function that uses ttlv_xmit to transmit a TTLV_MSG_T_RESULT message.
ttlv_state ttlv_xmit_result( ttlv_result res )
Convenience function that uses ttlv_xmit to transmit a TTLV_MSG_T_INM_RESULT message.
ttlv_state ttlv_xmit_inm_result( ttlv_result res )
Contains the most recently received ttlv_inm_header.
extern ttlv_inm_header ttlv_recv_inm_header