1
0
Fork 0

Configuration for LSS updated.

This commit is contained in:
Janez 2020-05-29 09:56:05 +02:00
parent cb9b2cce42
commit ae220f9115
11 changed files with 98 additions and 59 deletions

View file

@ -280,17 +280,22 @@ extern "C" {
#define CO_CONFIG_TIME (CO_CONFIG_FLAG_CALLBACK_PRE)
#endif
/**
* Configuration of LSS master object
* Configuration of LSS objects
*
* Possible flags, can be ORed:
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
* received SDO CAN message.
* Callback is configured by CO_LSSmaster_initCallbackPre().
* - CO_CONFIG_LSS_SLAVE - Enable LSS slave
* - CO_CONFIG_LSS_MASTER - Enable LSS master
*/
#ifdef CO_DOXYGEN
#define CO_CONFIG_LSS_MST (CO_CONFIG_FLAG_CALLBACK_PRE)
#define CO_CONFIG_LSS (CO_CONFIG_FLAG_CALLBACK_PRE | CO_CONFIG_LSS_SLAVE | CO_CONFIG_LSS_MASTER)
#endif
#define CO_CONFIG_LSS_SLAVE 0x01
#define CO_CONFIG_LSS_MASTER 0x02
/**

View file

@ -74,8 +74,8 @@ extern "C" {
#define CO_CONFIG_SDO_CLI_BUFFER_SIZE 32
#endif
#ifndef CO_CONFIG_LSS_MST
#define CO_CONFIG_LSS_MST (0)
#ifndef CO_CONFIG_LSS
#define CO_CONFIG_LSS (0)
#endif
#ifndef CO_CONFIG_GTW

View file

@ -91,7 +91,7 @@ static void CO_LSSmaster_receive(void *object, void *msg)
CO_FLAG_SET(LSSmaster->CANrxNew);
#if (CO_CONFIG_LSS_MST) & CO_CONFIG_FLAG_CALLBACK_PRE
#if (CO_CONFIG_LSS) & CO_CONFIG_FLAG_CALLBACK_PRE
/* Optional signal to RTOS, which can resume task, which handles further processing. */
if(LSSmaster->pFunctSignal != NULL) {
LSSmaster->pFunctSignal(LSSmaster->functSignalObject);
@ -147,7 +147,7 @@ CO_ReturnError_t CO_LSSmaster_init(
LSSmaster->timeoutTimer = 0;
CO_FLAG_CLEAR(LSSmaster->CANrxNew);
memset(LSSmaster->CANrxData, 0, sizeof(LSSmaster->CANrxData));
#if (CO_CONFIG_LSS_MST) & CO_CONFIG_FLAG_CALLBACK_PRE
#if (CO_CONFIG_LSS) & CO_CONFIG_FLAG_CALLBACK_PRE
LSSmaster->pFunctSignal = NULL;
LSSmaster->functSignalObject = NULL;
#endif
@ -191,7 +191,7 @@ void CO_LSSmaster_changeTimeout(
}
#if (CO_CONFIG_LSS_MST) & CO_CONFIG_FLAG_CALLBACK_PRE
#if (CO_CONFIG_LSS) & CO_CONFIG_FLAG_CALLBACK_PRE
/******************************************************************************/
void CO_LSSmaster_initCallbackPre(
CO_LSSmaster_t *LSSmaster,

View file

@ -118,7 +118,7 @@ typedef struct{
volatile void *CANrxNew; /**< Indication if new LSS message is received from CAN bus. It needs to be cleared when received message is completely processed. */
uint8_t CANrxData[8]; /**< 8 data bytes of the received message */
#if ((CO_CONFIG_LSS_MST) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
#if ((CO_CONFIG_LSS) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
void (*pFunctSignal)(void *object); /**< From CO_LSSmaster_initCallbackPre() or NULL */
void *functSignalObject;/**< Pointer to object */
#endif
@ -184,7 +184,7 @@ void CO_LSSmaster_changeTimeout(
uint16_t timeout_ms);
#if ((CO_CONFIG_LSS_MST) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
#if ((CO_CONFIG_LSS) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
/**
* Initialize LSSmasterRx callback function.
*

View file

@ -36,7 +36,8 @@ CO_ReturnError_t CO_GTWA_init(CO_GTWA_t* gtwa,
void* SDO_C,
uint16_t SDOtimeoutTimeDefault,
bool_t SDOblockTransferEnableDefault,
void *NMT)
void *NMT,
void *LSS)
{
/* verify arguments */
if (gtwa == NULL
@ -45,6 +46,9 @@ CO_ReturnError_t CO_GTWA_init(CO_GTWA_t* gtwa,
#endif
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_NMT
|| NMT == NULL
#endif
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LSS
|| LSS == NULL
#endif
) {
return CO_ERROR_ILLEGAL_ARGUMENT;
@ -60,6 +64,9 @@ CO_ReturnError_t CO_GTWA_init(CO_GTWA_t* gtwa,
#endif
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_NMT
gtwa->NMT = (CO_NMT_t *)NMT;
#endif
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LSS
gtwa->LSS = (CO_LSSmaster_t *)LSS;
#endif
gtwa->net_default = -1;
gtwa->node_default = -1;

View file

@ -36,6 +36,9 @@
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_NMT
#include "301/CO_NMT_Heartbeat.h"
#endif
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LSS
#include "305/CO_LSSmaster.h"
#endif
#ifdef __cplusplus
extern "C" {
@ -308,6 +311,10 @@ typedef struct {
/** NMT object from CO_GTWA_init() */
CO_NMT_t *NMT;
#endif
#if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LSS) || defined CO_DOXYGEN
/** LSS object from CO_GTWA_init() */
CO_LSSmaster_t *LSS;
#endif
#if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LOG) || defined CO_DOXYGEN
/** Message log buffer of usable size @ref CO_CONFIG_GTWA_LOG_BUF_SIZE */
char logBuf[CO_CONFIG_GTWA_LOG_BUF_SIZE + 1];
@ -329,6 +336,7 @@ typedef struct {
* @param SDOtimeoutTimeDefault in milliseconds, 500 typically
* @param SDOblockTransferEnableDefault true or false
* @param NMT NMT object
* @param LSS LSS master object
*
* @return #CO_ReturnError_t: CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT
*/
@ -336,7 +344,8 @@ CO_ReturnError_t CO_GTWA_init(CO_GTWA_t* gtwa,
void* SDO_C,
uint16_t SDOtimeoutTimeDefault,
bool_t SDOblockTransferEnableDefault,
void *NMT);
void *NMT,
void *LSS);
/**

View file

@ -62,9 +62,9 @@ static uint32_t CO_traceBufferSize[CO_NO_TRACE];
|| (CO_NO_TPDO < 1 || CO_NO_TPDO > 0x200) \
|| ODL_consumerHeartbeatTime_arrayLength == 0 \
|| ODL_errorStatusBits_stringLength < 10 \
|| CO_NO_LSS_SERVER > 1 \
|| CO_NO_LSS_CLIENT > 1 \
|| (CO_NO_LSS_SERVER > 0 && CO_NO_LSS_CLIENT > 0)
|| CO_NO_LSS_SLAVE > 1 \
|| CO_NO_LSS_MASTER > 1 \
|| (CO_NO_LSS_SLAVE > 0 && CO_NO_LSS_MASTER > 0)
#error Features from CO_OD.h file are not corectly configured for this project!
#endif
@ -86,8 +86,8 @@ static uint32_t CO_traceBufferSize[CO_NO_TRACE];
CO_NO_SDO_SERVER + \
CO_NO_SDO_CLIENT + \
CO_NO_HB_CONS + \
CO_NO_LSS_SERVER + \
CO_NO_LSS_CLIENT)
CO_NO_LSS_SLAVE + \
CO_NO_LSS_MASTER)
/* Indexes of CO_CANtx_t objects in CO_CANmodule_t and total number of them. **/
#define CO_TXCAN_NMT 0
@ -107,8 +107,8 @@ static uint32_t CO_traceBufferSize[CO_NO_TRACE];
CO_NO_SDO_SERVER + \
CO_NO_SDO_CLIENT + \
CO_NO_HB_PROD + \
CO_NO_LSS_SERVER + \
CO_NO_LSS_CLIENT)
CO_NO_LSS_SLAVE + \
CO_NO_LSS_MASTER)
/* Create objects from heap ***************************************************/
@ -213,14 +213,14 @@ CO_ReturnError_t CO_new(uint32_t *heapMemoryUsed) {
CO_memoryUsed += sizeof(CO_SDOclient_t) * CO_NO_SDO_CLIENT;
#endif
#if CO_NO_LSS_SERVER == 1
#if CO_NO_LSS_SLAVE == 1
/* LSSslave */
CO->LSSslave = (CO_LSSslave_t *)calloc(1, sizeof(CO_LSSslave_t));
if (CO->LSSslave == NULL) errCnt++;
CO_memoryUsed += sizeof(CO_LSSslave_t);
#endif
#if CO_NO_LSS_CLIENT == 1
#if CO_NO_LSS_MASTER == 1
/* LSSmaster */
CO->LSSmaster = (CO_LSSmaster_t *)calloc(1, sizeof(CO_LSSmaster_t));
if (CO->LSSmaster == NULL) errCnt++;
@ -291,12 +291,12 @@ void CO_delete(void *CANptr) {
free(CO->gtwa);
#endif
#if CO_NO_LSS_CLIENT == 1
#if CO_NO_LSS_MASTER == 1
/* LSSmaster */
free(CO->LSSmaster);
#endif
#if CO_NO_LSS_SERVER == 1
#if CO_NO_LSS_SLAVE == 1
/* LSSslave */
free(CO->LSSslave);
#endif
@ -379,10 +379,10 @@ void CO_delete(void *CANptr) {
#if CO_NO_SDO_CLIENT != 0
static CO_SDOclient_t COO_SDOclient[CO_NO_SDO_CLIENT];
#endif
#if CO_NO_LSS_SERVER == 1
#if CO_NO_LSS_SLAVE == 1
static CO_LSSslave_t COO_LSSslave;
#endif
#if CO_NO_LSS_CLIENT == 1
#if CO_NO_LSS_MASTER == 1
static CO_LSSmaster_t COO_LSSmaster;
#endif
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII
@ -461,12 +461,12 @@ CO_ReturnError_t CO_new(uint32_t *heapMemoryUsed) {
}
#endif
#if CO_NO_LSS_SERVER == 1
#if CO_NO_LSS_SLAVE == 1
/* LSSslave */
CO->LSSslave = &COO_LSSslave;
#endif
#if CO_NO_LSS_CLIENT == 1
#if CO_NO_LSS_MASTER == 1
/* LSSmaster */
CO->LSSmaster = &COO_LSSmaster;
#endif
@ -523,7 +523,7 @@ CO_ReturnError_t CO_CANinit(void *CANptr,
/******************************************************************************/
#if CO_NO_LSS_SERVER == 1
#if CO_NO_LSS_SLAVE == 1
CO_ReturnError_t CO_LSSinit(uint8_t nodeId,
uint16_t bitRate)
{
@ -549,7 +549,7 @@ CO_ReturnError_t CO_LSSinit(uint8_t nodeId,
return err;
}
#endif /* CO_NO_LSS_SERVER == 1 */
#endif /* CO_NO_LSS_SLAVE == 1 */
/******************************************************************************/
@ -748,7 +748,7 @@ CO_ReturnError_t CO_CANopenInit(uint8_t nodeId) {
}
#endif
#if CO_NO_LSS_CLIENT == 1
#if CO_NO_LSS_MASTER == 1
/* LSSmaster */
err = CO_LSSmaster_init(CO->LSSmaster,
CO_LSSmaster_DEFAULT_TIMEOUT,
@ -768,7 +768,8 @@ CO_ReturnError_t CO_CANopenInit(uint8_t nodeId) {
(void *)CO->SDOclient[0],
500,
false,
(void *)CO->NMT);
(void *)CO->NMT,
(void *)CO->LSSmaster);
if (err) return err;
#endif

View file

@ -127,21 +127,6 @@ extern "C" {
#include "301/CO_TIME.h"
#include "301/CO_PDO.h"
#include "301/CO_HBconsumer.h"
#if CO_NO_SDO_CLIENT != 0
#include "301/CO_SDOclient.h"
#endif
#if CO_NO_LSS_SERVER != 0
#include "305/CO_LSSslave.h"
#endif
#if CO_NO_LSS_CLIENT != 0
#include "305/CO_LSSmaster.h"
#endif
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII
#include "309/CO_gateway_ascii.h"
#endif
#if CO_NO_TRACE != 0
#include "extra/CO_trace.h"
#endif
#include "CO_OD.h"
@ -158,7 +143,7 @@ extern "C" {
/** Number of NMT objects, fixed to 1 slave(CANrx) */
#define CO_NO_NMT (1)
/** Number of NMT master objects, 0 or 1 master(CANtx). It depends on
* @ref CO_CONFIG_EM setting. */
* @ref CO_CONFIG_NMT setting. */
#define CO_NO_NMT_MST (0...1)
/** Number of SYNC objects, 0 or 1 (consumer(CANrx) + producer(CANtx)) */
#define CO_NO_SYNC (0...1)
@ -181,9 +166,11 @@ extern "C" {
#define CO_NO_HB_PROD (1)
/** Number of HB consumer objects, from 0 to 127 consumers(CANrx) */
#define CO_NO_HB_CONS (0...127)
/** Number of LSS slave objects, 0 or 1 (CANrx + CANtx) */
/** Number of LSS slave objects, 0 or 1 (CANrx + CANtx). It depends on
* @ref CO_CONFIG_LSS setting. */
#define CO_NO_LSS_SLAVE (0...1)
/** Number of LSS master objects, 0 or 1 (CANrx + CANtx) */
/** Number of LSS master objects, 0 or 1 (CANrx + CANtx). It depends on
* @ref CO_CONFIG_LSS setting. */
#define CO_NO_LSS_MASTER (0...1)
/** Number of Trace objects, 0 to many */
#define CO_NO_TRACE (0...)
@ -218,9 +205,40 @@ extern "C" {
#else
#define CO_NO_HB_CONS 0
#endif
/* LSS slave count depends on stack configuration */
#if (CO_CONFIG_LSS) & CO_CONFIG_LSS_SLAVE
#define CO_NO_LSS_SLAVE 1
#else
#define CO_NO_LSS_SLAVE 0
#endif
/* LSS master count depends on stack configuration */
#if (CO_CONFIG_LSS) & CO_CONFIG_LSS_MASTER
#define CO_NO_LSS_MASTER 1
#else
#define CO_NO_LSS_MASTER 0
#endif
#endif /* CO_DOXYGEN */
#if CO_NO_SDO_CLIENT != 0
#include "301/CO_SDOclient.h"
#endif
#if CO_NO_LSS_SLAVE != 0
#include "305/CO_LSSslave.h"
#endif
#if CO_NO_LSS_MASTER != 0
#include "305/CO_LSSmaster.h"
#endif
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII
#include "309/CO_gateway_ascii.h"
#endif
#if CO_NO_TRACE != 0
#include "extra/CO_trace.h"
#endif
/**
* CANopen object with pointers to all CANopenNode objects.
*/
@ -238,10 +256,10 @@ typedef struct {
#if CO_NO_SDO_CLIENT != 0
CO_SDOclient_t *SDOclient[CO_NO_SDO_CLIENT]; /**< SDO client object */
#endif
#if CO_NO_LSS_SERVER == 1
#if CO_NO_LSS_SLAVE == 1
CO_LSSslave_t *LSSslave; /**< LSS slave object */
#endif
#if CO_NO_LSS_CLIENT == 1
#if CO_NO_LSS_MASTER == 1
CO_LSSmaster_t *LSSmaster; /**< LSS master object */
#endif
#if ((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII) || defined CO_DOXYGEN
@ -299,7 +317,7 @@ CO_ReturnError_t CO_CANinit(void *CANptr,
uint16_t bitRate);
#if CO_NO_LSS_SERVER == 1
#if CO_NO_LSS_SLAVE == 1
/**
* Initialize CANopen LSS slave
*
@ -312,7 +330,7 @@ CO_ReturnError_t CO_CANinit(void *CANptr,
*/
CO_ReturnError_t CO_LSSinit(uint8_t nodeId,
uint16_t bitRate);
#endif /* CO_NO_LSS_SERVER == 1 */
#endif /* CO_NO_LSS_SLAVE == 1 */
/**

View file

@ -96,10 +96,7 @@
#define CO_NO_SDO_CLIENT 1 //Associated objects: 1280
#define CO_NO_RPDO 4 //Associated objects: 1400, 1401, 1402, 1403, 1600, 1601, 1602, 1603
#define CO_NO_TPDO 4 //Associated objects: 1800, 1801, 1802, 1803, 1A00, 1A01, 1A02, 1A03
#define CO_NO_NMT_MASTER 0
#define CO_NO_TRACE 0
#define CO_NO_LSS_SERVER 0
#define CO_NO_LSS_CLIENT 0
/*******************************************************************************
OBJECT DICTIONARY

View file

@ -106,8 +106,9 @@ extern "C" {
#define CO_CONFIG_TIME (CO_CONFIG_FLAG_CALLBACK_PRE)
#endif
#ifndef CO_CONFIG_LSS_MST
#define CO_CONFIG_LSS_MST (CO_CONFIG_FLAG_CALLBACK_PRE)
#ifndef CO_CONFIG_LSS
#define CO_CONFIG_LSS (CO_CONFIG_FLAG_CALLBACK_PRE | \
CO_CONFIG_LSS_MASTER)
#endif
#ifndef CO_CONFIG_GTW

View file

@ -112,8 +112,9 @@ extern "C" {
#define CO_CONFIG_TIME (CO_CONFIG_FLAG_CALLBACK_PRE)
#endif
#ifndef CO_CONFIG_LSS_MST
#define CO_CONFIG_LSS_MST (CO_CONFIG_FLAG_CALLBACK_PRE)
#ifndef CO_CONFIG_LSS
#define CO_CONFIG_LSS (CO_CONFIG_FLAG_CALLBACK_PRE | \
CO_CONFIG_LSS_MASTER)
#endif
#ifndef CO_CONFIG_GTW