move globals to ecat_slv

pull/52/head
Hans-Erik Floryd 2019-04-02 12:30:27 +02:00
parent aa811ae2f4
commit e27b6bcbb1
5 changed files with 24 additions and 47 deletions

View File

@ -10,20 +10,9 @@
#include "config.h"
#include "utypes.h"
/* Global variables used by the stack */
uint8_t MBX[MBXBUFFERS * MAX(MBXSIZE,MBXSIZEBOOT)];
_MBXcontrol MBXcontrol[MBXBUFFERS];
_ESCvar ESCvar;
_SMmap SMmap2[MAX_MAPPINGS_SM2];
_SMmap SMmap3[MAX_MAPPINGS_SM3];
/* Application variables */
_Objects Obj;
/* Private variables */
static uint8_t inputs[MAX_INPUT_SIZE] __attribute__((aligned (8)));
static uint8_t outputs[MAX_OUTPUT_SIZE] __attribute__((aligned (8)));
void cb_get_inputs (void)
{
Obj.IN1 = 1;
@ -36,7 +25,6 @@ void cb_set_outputs (void)
{
}
/* Setup of DC */
uint16_t dc_checker (void)
{
@ -57,10 +45,6 @@ int main (void)
.mbxsize = MBXSIZE,
.mbxsizeboot = MBXSIZEBOOT,
.mbxbuffers = MBXBUFFERS,
.rxpdos_address = outputs,
.rxpdos_mappings = MAX_SM_MAPPINGS,
.txpdos_address = inputs,
.txpdos_mappings = MAX_SM_MAPPINGS,
.mb[0] = {MBX0_sma, MBX0_sml, MBX0_sme, MBX0_smc, 0},
.mb[1] = {MBX1_sma, MBX1_sml, MBX1_sme, MBX1_smc, 0},
.mb_boot[0] = {MBX0_sma_b, MBX0_sml_b, MBX0_sme_b, MBX0_smc_b, 0},

View File

@ -1,5 +1,7 @@
#ifndef SOES_V1
/*
* Licensed under the GNU General Public License version 2 with exceptions. See
* LICENSE file in the project root for full license information
*/
#include <stddef.h>
#include "esc.h"
#include "esc_coe.h"
@ -10,12 +12,16 @@
#define IS_TXPDO(index) ((index) >= 0x1A00 && (index) < 0x1C00)
/* Global variables used by the stack */
extern _ESCvar ESCvar;
extern _SMmap SMmap2[];
extern _SMmap SMmap3[];
uint8_t MBX[MBXBUFFERS * MAX(MBXSIZE,MBXSIZEBOOT)];
_MBXcontrol MBXcontrol[MBXBUFFERS];
_SMmap SMmap2[MAX_MAPPINGS_SM2];
_SMmap SMmap3[MAX_MAPPINGS_SM3];
_ESCvar ESCvar;
/* Private variables */
static volatile int watchdog;
static uint8_t rxpdo[MAX_RXPDO_SIZE] __attribute__((aligned (8)));
static uint8_t txpdo[MAX_TXPDO_SIZE] __attribute__((aligned (8)));
/** Mandatory: Function to pre-qualify the incoming SDO download.
*
@ -92,8 +98,8 @@ void TXPDO_update (void)
}
else
{
COE_pdoPack (ESCvar.txpdos_address, ESCvar.sm3mappings, SMmap3);
ESC_write (ESC_SM3_sma, ESCvar.txpdos_address , ESCvar.ESC_SM3_sml);
COE_pdoPack (txpdo, ESCvar.sm3mappings, SMmap3);
ESC_write (ESC_SM3_sma, txpdo, ESCvar.ESC_SM3_sml);
}
}
@ -107,8 +113,8 @@ void RXPDO_update (void)
}
else
{
ESC_read (ESC_SM2_sma, ESCvar.rxpdos_address, ESCvar.ESC_SM2_sml);
COE_pdoUnpack (ESCvar.rxpdos_address, ESCvar.sm2mappings, SMmap2);
ESC_read (ESC_SM2_sma, rxpdo, ESCvar.ESC_SM2_sml);
COE_pdoUnpack (rxpdo, ESCvar.sm2mappings, SMmap2);
}
}
@ -305,4 +311,3 @@ void ecat_slv_init (esc_cfg_t * config)
ESC_stopinput();
ESC_stopoutput();
}
#endif

View File

@ -7,6 +7,7 @@
#include "esc.h"
#include "esc_coe.h"
#include "esc_foe.h"
#include "options.h"
/** \file
* \brief
@ -1037,7 +1038,7 @@ void ESC_state (void)
case SAFEOP_TO_SAFEOP:
{
ESCvar.ESC_SM2_sml = sizeOfPDO (RX_PDO_OBJIDX, &ESCvar.sm2mappings,
SMmap2, ESCvar.rxpdos_mappings);
SMmap2, MAX_MAPPINGS_SM2);
if (ESCvar.sm2mappings < 0)
{
an = ESCpreop | ESCerror;
@ -1046,7 +1047,7 @@ void ESC_state (void)
}
ESCvar.ESC_SM3_sml = sizeOfPDO (TX_PDO_OBJIDX, &ESCvar.sm3mappings,
SMmap3, ESCvar.txpdos_mappings);
SMmap3, MAX_MAPPINGS_SM3);
if (ESCvar.sm3mappings < 0)
{
an = ESCpreop | ESCerror;
@ -1151,11 +1152,6 @@ void ESC_config (esc_cfg_t * cfg)
ESCvar.mbxsizeboot = cfg->mbxsizeboot;
ESCvar.mbxbuffers = cfg->mbxbuffers;
ESCvar.rxpdos_address = cfg->rxpdos_address;
ESCvar.rxpdos_mappings = cfg->rxpdos_mappings;
ESCvar.txpdos_address = cfg->txpdos_address;
ESCvar.txpdos_mappings = cfg->txpdos_mappings;
ESCvar.mb[0] = cfg->mb[0];
ESCvar.mb[1] = cfg->mb[1];
ESCvar.mbboot[0] = cfg->mb_boot[0];

View File

@ -240,10 +240,6 @@ typedef struct esc_cfg
size_t mbxsize;
size_t mbxsizeboot;
int mbxbuffers;
void * rxpdos_address;
int rxpdos_mappings;
void * txpdos_address;
int txpdos_mappings;
sm_cfg_t mb[2];
sm_cfg_t mb_boot[2];
sm_cfg_t pdosm[2];
@ -362,10 +358,6 @@ typedef struct
size_t mbxsize;
size_t mbxsizeboot;
int mbxbuffers;
void * rxpdos_address;
int rxpdos_mappings;
void * txpdos_address;
int txpdos_mappings;
sm_cfg_t mb[2];
sm_cfg_t mbboot[2];
sm_cfg_t pdosm[2];

View File

@ -119,14 +119,14 @@
#define SM3_act 1
#endif
/* Max processdata size (inputs) */
#ifndef MAX_INPUT_SIZE
#define MAX_INPUT_SIZE 128
/* Max processdata size (outputs) */
#ifndef MAX_RXPDO_SIZE
#define MAX_RXPDO_SIZE 128
#endif
/* Max processdata size (outputs) */
#ifndef MAX_OUTPUT_SIZE
#define MAX_OUTPUT_SIZE 128
/* Max processdata size (inputs) */
#ifndef MAX_TXPDO_SIZE
#define MAX_TXPDO_SIZE 128
#endif
/* Max number of mapped objects in SM2 */