CO_LSSmaster.h
Go to the documentation of this file.
#ifndef CO_LSSmaster_H
#define CO_LSSmaster_H
#include "305/CO_LSS.h"
#if ((CO_CONFIG_LSS) & CO_CONFIG_LSS_MASTER) || defined CO_DOXYGEN
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
CO_LSSmaster_SCAN_FINISHED = 2,
CO_LSSmaster_WAIT_SLAVE = 1,
CO_LSSmaster_OK = 0,
CO_LSSmaster_TIMEOUT = -1,
CO_LSSmaster_ILLEGAL_ARGUMENT = -2,
CO_LSSmaster_INVALID_STATE = -3,
CO_LSSmaster_SCAN_NOACK = -4,
CO_LSSmaster_SCAN_FAILED = -5,
CO_LSSmaster_OK_ILLEGAL_ARGUMENT = -101,
CO_LSSmaster_OK_MANUFACTURER = -102,
} CO_LSSmaster_return_t;
typedef struct{
uint32_t timeout_us;
uint8_t state;
uint8_t command;
uint32_t timeoutTimer;
uint8_t fsState;
uint8_t fsLssSub;
uint8_t fsBitChecked;
uint32_t fsIdNumber;
volatile void *CANrxNew;
uint8_t CANrxData[8];
#if ((CO_CONFIG_LSS) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
void (*pFunctSignal)(void *object);
void *functSignalObject;
#endif
CO_CANmodule_t *CANdevTx;
CO_CANtx_t *TXbuff;
}CO_LSSmaster_t;
#ifndef CO_LSSmaster_DEFAULT_TIMEOUT
#define CO_LSSmaster_DEFAULT_TIMEOUT 1000U /* ms */
#endif
CO_ReturnError_t CO_LSSmaster_init(
CO_LSSmaster_t *LSSmaster,
uint16_t timeout_ms,
CO_CANmodule_t *CANdevRx,
uint16_t CANdevRxIdx,
uint32_t CANidLssSlave,
CO_CANmodule_t *CANdevTx,
uint16_t CANdevTxIdx,
uint32_t CANidLssMaster);
void CO_LSSmaster_changeTimeout(
CO_LSSmaster_t *LSSmaster,
uint16_t timeout_ms);
#if ((CO_CONFIG_LSS) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
void CO_LSSmaster_initCallbackPre(
CO_LSSmaster_t *LSSmaster,
void *object,
void (*pFunctSignal)(void *object));
#endif
CO_LSSmaster_return_t CO_LSSmaster_switchStateSelect(
CO_LSSmaster_t *LSSmaster,
uint32_t timeDifference_us,
CO_LSS_address_t *lssAddress);
CO_LSSmaster_return_t CO_LSSmaster_switchStateDeselect(
CO_LSSmaster_t *LSSmaster);
CO_LSSmaster_return_t CO_LSSmaster_configureBitTiming(
CO_LSSmaster_t *LSSmaster,
uint32_t timeDifference_us,
uint16_t bit);
CO_LSSmaster_return_t CO_LSSmaster_configureNodeId(
CO_LSSmaster_t *LSSmaster,
uint32_t timeDifference_us,
uint8_t nodeId);
CO_LSSmaster_return_t CO_LSSmaster_configureStore(
CO_LSSmaster_t *LSSmaster,
uint32_t timeDifference_us);
CO_LSSmaster_return_t CO_LSSmaster_ActivateBit(
CO_LSSmaster_t *LSSmaster,
uint16_t switchDelay_ms);
CO_LSSmaster_return_t CO_LSSmaster_InquireLssAddress(
CO_LSSmaster_t *LSSmaster,
uint32_t timeDifference_us,
CO_LSS_address_t *lssAddress);
CO_LSSmaster_return_t CO_LSSmaster_Inquire(
CO_LSSmaster_t *LSSmaster,
uint32_t timeDifference_us,
CO_LSS_cs_t lssInquireCs,
uint32_t *value);
typedef enum {
CO_LSSmaster_FS_SCAN = 0,
CO_LSSmaster_FS_SKIP = 1,
CO_LSSmaster_FS_MATCH = 2,
} CO_LSSmaster_scantype_t;
typedef struct{
CO_LSSmaster_scantype_t scan[4];
CO_LSS_address_t match;
CO_LSS_address_t found;
} CO_LSSmaster_fastscan_t;
CO_LSSmaster_return_t CO_LSSmaster_IdentifyFastscan(
CO_LSSmaster_t *LSSmaster,
uint32_t timeDifference_us,
CO_LSSmaster_fastscan_t *fastscan);
/*@defgroup CO_LSSmaster*/
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /* (CO_CONFIG_LSS) & CO_CONFIG_LSS_MASTER */
#endif /*CO_LSSmaster_H*/
CO_LSSmaster_OK_MANUFACTURER
@ CO_LSSmaster_OK_MANUFACTURER
LSS success, node rejected argument with manufacturer error code.
Definition: CO_LSSmaster.h:101
uint32_t
unsigned long int uint32_t
UNSIGNED32 in CANopen (0007h), 32-bit unsigned integer.
Definition: CO_driver.h:155
CO_LSSmaster_t::fsLssSub
uint8_t fsLssSub
Current state of node state machine.
Definition: CO_LSSmaster.h:116
CO_LSSmaster_SCAN_NOACK
@ CO_LSSmaster_SCAN_NOACK
No node found that matches scan request.
Definition: CO_LSSmaster.h:98
CO_LSSmaster_fastscan_t::found
CO_LSS_address_t found
Scan result.
Definition: CO_LSSmaster.h:410
CO_LSS.h
CANopen Layer Setting Services protocol (common).
uint16_t
unsigned int uint16_t
UNSIGNED16 in CANopen (0006h), 16-bit unsigned integer.
Definition: CO_driver.h:153
CO_LSSmaster_InquireLssAddress
CO_LSSmaster_return_t CO_LSSmaster_InquireLssAddress(CO_LSSmaster_t *LSSmaster, uint32_t timeDifference_us, CO_LSS_address_t *lssAddress)
Request LSS inquire LSS address.
CO_LSSmaster_t::fsBitChecked
uint8_t fsBitChecked
Current scan bit position.
Definition: CO_LSSmaster.h:117
CO_LSSmaster_ActivateBit
CO_LSSmaster_return_t CO_LSSmaster_ActivateBit(CO_LSSmaster_t *LSSmaster, uint16_t switchDelay_ms)
Request LSS activate bit timing.
CO_ReturnError_t
CO_ReturnError_t
Return values of some CANopen functions.
Definition: CO_driver.h:488
CO_LSSmaster_t::CANdevTx
CO_CANmodule_t * CANdevTx
From CO_LSSmaster_init()
Definition: CO_LSSmaster.h:126
CO_LSSmaster_IdentifyFastscan
CO_LSSmaster_return_t CO_LSSmaster_IdentifyFastscan(CO_LSSmaster_t *LSSmaster, uint32_t timeDifference_us, CO_LSSmaster_fastscan_t *fastscan)
Select a node by LSS identify fastscan.
CO_LSS_cs_t
CO_LSS_cs_t
LSS protocol command specifiers.
Definition: CO_LSS.h:86
CO_LSSmaster_switchStateDeselect
CO_LSSmaster_return_t CO_LSSmaster_switchStateDeselect(CO_LSSmaster_t *LSSmaster)
Request LSS switch state deselect.
CO_LSSmaster_switchStateSelect
CO_LSSmaster_return_t CO_LSSmaster_switchStateSelect(CO_LSSmaster_t *LSSmaster, uint32_t timeDifference_us, CO_LSS_address_t *lssAddress)
Request LSS switch state select.
CO_LSSmaster_t::functSignalObject
void * functSignalObject
Pointer to object.
Definition: CO_LSSmaster.h:124
CO_LSSmaster_OK
@ CO_LSSmaster_OK
Success, end of communication.
Definition: CO_LSSmaster.h:94
CO_LSSmaster_initCallbackPre
void CO_LSSmaster_initCallbackPre(CO_LSSmaster_t *LSSmaster, void *object, void(*pFunctSignal)(void *object))
Initialize LSSmasterRx callback function.
CO_LSSmaster_configureNodeId
CO_LSSmaster_return_t CO_LSSmaster_configureNodeId(CO_LSSmaster_t *LSSmaster, uint32_t timeDifference_us, uint8_t nodeId)
Request LSS configure node ID.
CO_LSSmaster_SCAN_FAILED
@ CO_LSSmaster_SCAN_FAILED
An error occurred while scanning.
Definition: CO_LSSmaster.h:99
CO_LSSmaster_t::fsState
uint8_t fsState
Current state of fastscan master state machine.
Definition: CO_LSSmaster.h:115
CO_LSSmaster_Inquire
CO_LSSmaster_return_t CO_LSSmaster_Inquire(CO_LSSmaster_t *LSSmaster, uint32_t timeDifference_us, CO_LSS_cs_t lssInquireCs, uint32_t *value)
Request LSS inquire node ID or part of LSS address.
CO_LSSmaster_WAIT_SLAVE
@ CO_LSSmaster_WAIT_SLAVE
No response arrived from slave yet.
Definition: CO_LSSmaster.h:93
CO_LSSmaster_t::timeout_us
uint32_t timeout_us
LSS response timeout in us.
Definition: CO_LSSmaster.h:109
CO_LSSmaster_t::state
uint8_t state
Node is currently selected.
Definition: CO_LSSmaster.h:111
CO_LSSmaster_t::fsIdNumber
uint32_t fsIdNumber
Current scan result.
Definition: CO_LSSmaster.h:118
CO_LSSmaster_scantype_t
CO_LSSmaster_scantype_t
Scan type for CO_LSSmaster_fastscan_t scan.
Definition: CO_LSSmaster.h:398
CO_LSSmaster_fastscan_t
Parameters for LSS fastscan CO_LSSmaster_IdentifyFastscan.
Definition: CO_LSSmaster.h:407
CO_LSSmaster_t
LSS master object.
Definition: CO_LSSmaster.h:108
CO_LSSmaster_return_t
CO_LSSmaster_return_t
Return values of LSS master functions.
Definition: CO_LSSmaster.h:91
CO_LSSmaster_FS_SKIP
@ CO_LSSmaster_FS_SKIP
Skip this value.
Definition: CO_LSSmaster.h:400
CO_LSSmaster_changeTimeout
void CO_LSSmaster_changeTimeout(CO_LSSmaster_t *LSSmaster, uint16_t timeout_ms)
Change LSS master timeout.
CO_LSSmaster_ILLEGAL_ARGUMENT
@ CO_LSSmaster_ILLEGAL_ARGUMENT
Invalid argument.
Definition: CO_LSSmaster.h:96
CO_LSSmaster_t::TXbuff
CO_CANtx_t * TXbuff
CAN transmit buffer.
Definition: CO_LSSmaster.h:127
CO_LSSmaster_FS_MATCH
@ CO_LSSmaster_FS_MATCH
Full 32 bit value is given as argument, just verify.
Definition: CO_LSSmaster.h:401
CO_LSSmaster_FS_SCAN
@ CO_LSSmaster_FS_SCAN
Do full 32 bit scan.
Definition: CO_LSSmaster.h:399
CO_LSSmaster_SCAN_FINISHED
@ CO_LSSmaster_SCAN_FINISHED
Scanning finished successful.
Definition: CO_LSSmaster.h:92
CO_LSSmaster_TIMEOUT
@ CO_LSSmaster_TIMEOUT
No reply received.
Definition: CO_LSSmaster.h:95
CO_LSSmaster_fastscan_t::match
CO_LSS_address_t match
Value to match in case of CO_LSSmaster_FS_MATCH.
Definition: CO_LSSmaster.h:409
CO_CANmodule_t
Complete CAN module object.
Definition: CO_driver.h:319
CO_LSSmaster_OK_ILLEGAL_ARGUMENT
@ CO_LSSmaster_OK_ILLEGAL_ARGUMENT
LSS success, node rejected argument because of non-supported value.
Definition: CO_LSSmaster.h:100
CO_LSSmaster_configureStore
CO_LSSmaster_return_t CO_LSSmaster_configureStore(CO_LSSmaster_t *LSSmaster, uint32_t timeDifference_us)
Request LSS store configuration.
CO_LSSmaster_t::timeoutTimer
uint32_t timeoutTimer
Timeout timer for LSS communication.
Definition: CO_LSSmaster.h:113
CO_LSSmaster_INVALID_STATE
@ CO_LSSmaster_INVALID_STATE
State machine not ready or already processing a request.
Definition: CO_LSSmaster.h:97
CO_LSS_address_t
The LSS address is a 128 bit number, uniquely identifying each node.
Definition: CO_LSS.h:162
CO_LSSmaster_configureBitTiming
CO_LSSmaster_return_t CO_LSSmaster_configureBitTiming(CO_LSSmaster_t *LSSmaster, uint32_t timeDifference_us, uint16_t bit)
Request LSS configure Bit Timing.
CO_CANtx_t
Configuration object for CAN transmit message for specific CANopenNode Object.
Definition: CO_driver.h:299
CO_LSSmaster_t::command
uint8_t command
Active command.
Definition: CO_LSSmaster.h:112
CO_LSSmaster_t::CANrxNew
volatile void * CANrxNew
Indication if new LSS message is received from CAN bus.
Definition: CO_LSSmaster.h:120
CO_LSSmaster_init
CO_ReturnError_t CO_LSSmaster_init(CO_LSSmaster_t *LSSmaster, uint16_t timeout_ms, CO_CANmodule_t *CANdevRx, uint16_t CANdevRxIdx, uint32_t CANidLssSlave, CO_CANmodule_t *CANdevTx, uint16_t CANdevTxIdx, uint32_t CANidLssMaster)
Initialize LSS object.
uint8_t
unsigned char uint8_t
UNSIGNED8 in CANopen (0005h), 8-bit unsigned integer.
Definition: CO_driver.h:151