CO_LSS.h
Go to the documentation of this file.
#ifndef CO_LSS_H
#define CO_LSS_H
#include "301/CO_driver.h"
/* default configuration, see CO_config.h */
#ifndef CO_CONFIG_LSS
#define CO_CONFIG_LSS (CO_CONFIG_LSS_SLAVE)
#endif
#if ((CO_CONFIG_LSS) & (CO_CONFIG_LSS_SLAVE | CO_CONFIG_LSS_MASTER)) || defined CO_DOXYGEN
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
CO_LSS_SWITCH_STATE_GLOBAL = 0x04U,
CO_LSS_SWITCH_STATE_SEL_VENDOR = 0x40U,
CO_LSS_SWITCH_STATE_SEL_PRODUCT = 0x41U,
CO_LSS_SWITCH_STATE_SEL_REV = 0x42U,
CO_LSS_SWITCH_STATE_SEL_SERIAL = 0x43U,
CO_LSS_SWITCH_STATE_SEL = 0x44U,
CO_LSS_CFG_NODE_ID = 0x11U,
CO_LSS_CFG_BIT_TIMING = 0x13U,
CO_LSS_CFG_ACTIVATE_BIT_TIMING = 0x15U,
CO_LSS_CFG_STORE = 0x17U,
CO_LSS_IDENT_SLAVE = 0x4FU,
CO_LSS_IDENT_FASTSCAN = 0x51U,
CO_LSS_INQUIRE_VENDOR = 0x5AU,
CO_LSS_INQUIRE_PRODUCT = 0x5BU,
CO_LSS_INQUIRE_REV = 0x5CU,
CO_LSS_INQUIRE_SERIAL = 0x5DU,
CO_LSS_INQUIRE_NODE_ID = 0x5EU,
} CO_LSS_cs_t;
typedef enum {
CO_LSS_CFG_NODE_ID_OK = 0x00U,
CO_LSS_CFG_NODE_ID_OUT_OF_RANGE = 0x01U,
CO_LSS_CFG_NODE_ID_MANUFACTURER = 0xFFU
} CO_LSS_cfgNodeId_t;
typedef enum {
CO_LSS_CFG_BIT_TIMING_OK = 0x00U,
CO_LSS_CFG_BIT_TIMING_OUT_OF_RANGE = 0x01U,
CO_LSS_CFG_BIT_TIMING_MANUFACTURER = 0xFFU
} CO_LSS_cfgBitTiming_t;
typedef enum {
CO_LSS_CFG_STORE_OK = 0x00U,
CO_LSS_CFG_STORE_NOT_SUPPORTED = 0x01U,
CO_LSS_CFG_STORE_FAILED = 0x02U,
CO_LSS_CFG_STORE_MANUFACTURER = 0xFFU
} CO_LSS_cfgStore_t;
typedef enum {
CO_LSS_FASTSCAN_BIT0 = 0x00U,
/* ... */
CO_LSS_FASTSCAN_BIT31 = 0x1FU,
CO_LSS_FASTSCAN_CONFIRM = 0x80U
} CO_LSS_fastscan_bitcheck;
#define CO_LSS_FASTSCAN_BITCHECK_VALID(bit) ((bit>=CO_LSS_FASTSCAN_BIT0 && bit<=CO_LSS_FASTSCAN_BIT31) || bit==CO_LSS_FASTSCAN_CONFIRM)
typedef enum {
CO_LSS_FASTSCAN_VENDOR_ID = 0,
CO_LSS_FASTSCAN_PRODUCT = 1,
CO_LSS_FASTSCAN_REV = 2,
CO_LSS_FASTSCAN_SERIAL = 3
} CO_LSS_fastscan_lss_sub_next;
#define CO_LSS_FASTSCAN_LSS_SUB_NEXT_VALID(index) (index>=CO_LSS_FASTSCAN_VENDOR_ID && index<=CO_LSS_FASTSCAN_SERIAL)
typedef union {
uint32_t addr[4];
struct {
uint32_t vendorID;
uint32_t productCode;
uint32_t revisionNumber;
uint32_t serialNumber;
} identity;
} CO_LSS_address_t;
typedef enum {
CO_LSS_STATE_WAITING = 0,
CO_LSS_STATE_CONFIGURATION = 1,
} CO_LSS_state_t;
typedef enum {
CO_LSS_BIT_TIMING_1000 = 0,
CO_LSS_BIT_TIMING_800 = 1,
CO_LSS_BIT_TIMING_500 = 2,
CO_LSS_BIT_TIMING_250 = 3,
CO_LSS_BIT_TIMING_125 = 4,
/* reserved = 5 */
CO_LSS_BIT_TIMING_50 = 6,
CO_LSS_BIT_TIMING_20 = 7,
CO_LSS_BIT_TIMING_10 = 8,
CO_LSS_BIT_TIMING_AUTO = 9,
} CO_LSS_bitTimingTable_t;
static const uint16_t CO_LSS_bitTimingTableLookup[] = {
1000,
800,
500,
250,
125,
0,
50,
20,
10,
0
};
#define CO_LSS_BIT_TIMING_VALID(index) (index != 5 && (index >= CO_LSS_BIT_TIMING_1000 && index <= CO_LSS_BIT_TIMING_AUTO))
#define CO_LSS_NODE_ID_ASSIGNMENT 0xFFU
#define CO_LSS_NODE_ID_VALID(nid) ((nid >= 1 && nid <= 0x7F) || nid == CO_LSS_NODE_ID_ASSIGNMENT)
#define CO_LSS_ADDRESS_EQUAL(/*CO_LSS_address_t*/ a1, /*CO_LSS_address_t*/ a2) \
(a1.identity.productCode == a2.identity.productCode && \
a1.identity.revisionNumber == a2.identity.revisionNumber && \
a1.identity.serialNumber == a2.identity.serialNumber && \
a1.identity.vendorID == a2.identity.vendorID)
/*@defgroup CO_LSS*/
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /* (CO_CONFIG_LSS) & (CO_CONFIG_LSS_SLAVE | CO_CONFIG_LSS_MASTER) */
#endif /*CO_LSS_H*/
uint32_t
unsigned long int uint32_t
UNSIGNED32 in CANopen (0007h), 32-bit unsigned integer.
Definition: CO_driver.h:155
CO_driver.h
Interface between CAN hardware and CANopenNode.
CO_LSS_FASTSCAN_BIT31
@ CO_LSS_FASTSCAN_BIT31
dito
Definition: CO_LSS.h:140
CO_LSS_INQUIRE_PRODUCT
@ CO_LSS_INQUIRE_PRODUCT
Inquire identity product-code protocol.
Definition: CO_LSS.h:100
CO_LSS_CFG_BIT_TIMING
@ CO_LSS_CFG_BIT_TIMING
Configure bit timing parameter protocol.
Definition: CO_LSS.h:94
CO_LSS_cfgBitTiming_t
CO_LSS_cfgBitTiming_t
Error codes for Configure bit timing parameters protocol.
Definition: CO_LSS.h:118
CO_LSS_BIT_TIMING_800
@ CO_LSS_BIT_TIMING_800
800kbit/s
Definition: CO_LSS.h:191
uint16_t
unsigned int uint16_t
UNSIGNED16 in CANopen (0006h), 16-bit unsigned integer.
Definition: CO_driver.h:153
CO_LSS_INQUIRE_SERIAL
@ CO_LSS_INQUIRE_SERIAL
Inquire identity serial-number protocol.
Definition: CO_LSS.h:102
CO_LSS_BIT_TIMING_50
@ CO_LSS_BIT_TIMING_50
50kbit/s
Definition: CO_LSS.h:196
CO_LSS_cs_t
CO_LSS_cs_t
LSS protocol command specifiers.
Definition: CO_LSS.h:86
CO_LSS_SWITCH_STATE_SEL_PRODUCT
@ CO_LSS_SWITCH_STATE_SEL_PRODUCT
Switch state selective protocol - Product code.
Definition: CO_LSS.h:89
CO_LSS_fastscan_lss_sub_next
CO_LSS_fastscan_lss_sub_next
Fastscan LSSsub, LSSnext.
Definition: CO_LSS.h:149
CO_LSS_CFG_STORE_FAILED
@ CO_LSS_CFG_STORE_FAILED
Storage media access error.
Definition: CO_LSS.h:130
CO_LSS_CFG_BIT_TIMING_MANUFACTURER
@ CO_LSS_CFG_BIT_TIMING_MANUFACTURER
Manufacturer specific error.
Definition: CO_LSS.h:121
CO_LSS_FASTSCAN_CONFIRM
@ CO_LSS_FASTSCAN_CONFIRM
All LSS slaves waiting for scan respond and previous scan is reset.
Definition: CO_LSS.h:141
CO_LSS_SWITCH_STATE_SEL_SERIAL
@ CO_LSS_SWITCH_STATE_SEL_SERIAL
Switch state selective protocol - Serial number.
Definition: CO_LSS.h:91
CO_LSS_STATE_WAITING
@ CO_LSS_STATE_WAITING
LSS FSA waiting for requests.
Definition: CO_LSS.h:182
CO_LSS_CFG_ACTIVATE_BIT_TIMING
@ CO_LSS_CFG_ACTIVATE_BIT_TIMING
Activate bit timing parameter protocol.
Definition: CO_LSS.h:95
CO_LSS_STATE_CONFIGURATION
@ CO_LSS_STATE_CONFIGURATION
LSS FSA waiting for configuration.
Definition: CO_LSS.h:183
CO_LSS_CFG_NODE_ID
@ CO_LSS_CFG_NODE_ID
Configure node ID protocol.
Definition: CO_LSS.h:93
CO_LSS_CFG_NODE_ID_OK
@ CO_LSS_CFG_NODE_ID_OK
Protocol successfully completed.
Definition: CO_LSS.h:110
CO_LSS_CFG_STORE_OK
@ CO_LSS_CFG_STORE_OK
Protocol successfully completed.
Definition: CO_LSS.h:128
CO_LSS_SWITCH_STATE_GLOBAL
@ CO_LSS_SWITCH_STATE_GLOBAL
Switch state global protocol.
Definition: CO_LSS.h:87
CO_LSS_state_t
CO_LSS_state_t
LSS finite state automaton.
Definition: CO_LSS.h:181
CO_LSS_cfgStore_t
CO_LSS_cfgStore_t
Error codes for Store configuration protocol.
Definition: CO_LSS.h:127
CO_LSS_SWITCH_STATE_SEL_REV
@ CO_LSS_SWITCH_STATE_SEL_REV
Switch state selective protocol - Revision number.
Definition: CO_LSS.h:90
CO_LSS_FASTSCAN_BIT0
@ CO_LSS_FASTSCAN_BIT0
Least significant bit of IDnumbners bit area to be checked.
Definition: CO_LSS.h:138
CO_LSS_INQUIRE_REV
@ CO_LSS_INQUIRE_REV
Inquire identity revision-number protocol.
Definition: CO_LSS.h:101
CO_LSS_BIT_TIMING_500
@ CO_LSS_BIT_TIMING_500
500kbit/s
Definition: CO_LSS.h:192
CO_LSS_FASTSCAN_SERIAL
@ CO_LSS_FASTSCAN_SERIAL
Serial number.
Definition: CO_LSS.h:153
CO_LSS_BIT_TIMING_125
@ CO_LSS_BIT_TIMING_125
125kbit/s
Definition: CO_LSS.h:194
CO_LSS_INQUIRE_VENDOR
@ CO_LSS_INQUIRE_VENDOR
Inquire identity vendor-ID protocol.
Definition: CO_LSS.h:99
CO_LSS_bitTimingTable_t
CO_LSS_bitTimingTable_t
Definition of table_index for /CiA301/ bit timing table.
Definition: CO_LSS.h:189
CO_LSS_CFG_BIT_TIMING_OK
@ CO_LSS_CFG_BIT_TIMING_OK
Protocol successfully completed.
Definition: CO_LSS.h:119
CO_LSS_BIT_TIMING_20
@ CO_LSS_BIT_TIMING_20
20kbit/s
Definition: CO_LSS.h:197
CO_LSS_CFG_STORE_NOT_SUPPORTED
@ CO_LSS_CFG_STORE_NOT_SUPPORTED
Store configuration not supported.
Definition: CO_LSS.h:129
CO_LSS_INQUIRE_NODE_ID
@ CO_LSS_INQUIRE_NODE_ID
Inquire node-ID protocol.
Definition: CO_LSS.h:103
CO_LSS_FASTSCAN_REV
@ CO_LSS_FASTSCAN_REV
Revision number.
Definition: CO_LSS.h:152
CO_LSS_BIT_TIMING_10
@ CO_LSS_BIT_TIMING_10
10kbit/s
Definition: CO_LSS.h:198
CO_LSS_CFG_STORE_MANUFACTURER
@ CO_LSS_CFG_STORE_MANUFACTURER
Manufacturer specific error.
Definition: CO_LSS.h:131
CO_LSS_IDENT_FASTSCAN
@ CO_LSS_IDENT_FASTSCAN
LSS Fastscan protocol.
Definition: CO_LSS.h:98
CO_LSS_CFG_NODE_ID_OUT_OF_RANGE
@ CO_LSS_CFG_NODE_ID_OUT_OF_RANGE
NID out of range.
Definition: CO_LSS.h:111
CO_LSS_FASTSCAN_PRODUCT
@ CO_LSS_FASTSCAN_PRODUCT
Product code.
Definition: CO_LSS.h:151
CO_LSS_BIT_TIMING_AUTO
@ CO_LSS_BIT_TIMING_AUTO
Automatic bit rate detection.
Definition: CO_LSS.h:199
CO_LSS_BIT_TIMING_1000
@ CO_LSS_BIT_TIMING_1000
1000kbit/s
Definition: CO_LSS.h:190
CO_LSS_BIT_TIMING_250
@ CO_LSS_BIT_TIMING_250
250kbit/s
Definition: CO_LSS.h:193
CO_LSS_cfgNodeId_t
CO_LSS_cfgNodeId_t
Error codes for Configure node ID protocol.
Definition: CO_LSS.h:109
CO_LSS_CFG_BIT_TIMING_OUT_OF_RANGE
@ CO_LSS_CFG_BIT_TIMING_OUT_OF_RANGE
Bit timing / Bit rate not supported.
Definition: CO_LSS.h:120
CO_LSS_CFG_STORE
@ CO_LSS_CFG_STORE
Store configuration protocol.
Definition: CO_LSS.h:96
CO_LSS_SWITCH_STATE_SEL_VENDOR
@ CO_LSS_SWITCH_STATE_SEL_VENDOR
Switch state selective protocol - Vendor ID.
Definition: CO_LSS.h:88
CO_LSS_fastscan_bitcheck
CO_LSS_fastscan_bitcheck
Fastscan BitCheck.
Definition: CO_LSS.h:137
CO_LSS_bitTimingTableLookup
static const uint16_t CO_LSS_bitTimingTableLookup[]
Lookup table for conversion between bit timing table and numerical bit rate.
Definition: CO_LSS.h:206
CO_LSS_CFG_NODE_ID_MANUFACTURER
@ CO_LSS_CFG_NODE_ID_MANUFACTURER
Manufacturer specific error.
Definition: CO_LSS.h:112
CO_LSS_address_t
The LSS address is a 128 bit number, uniquely identifying each node.
Definition: CO_LSS.h:162
CO_LSS_SWITCH_STATE_SEL
@ CO_LSS_SWITCH_STATE_SEL
Switch state selective protocol - Slave response.
Definition: CO_LSS.h:92
CO_LSS_IDENT_SLAVE
@ CO_LSS_IDENT_SLAVE
LSS Fastscan response.
Definition: CO_LSS.h:97
CO_LSS_FASTSCAN_VENDOR_ID
@ CO_LSS_FASTSCAN_VENDOR_ID
Vendor ID.
Definition: CO_LSS.h:150