Skip to content

Commit 8574206

Browse files
authored
Merge pull request #3 from X2Cscope/feature/dynamic_scope_size
Feature/dynamic scope size
2 parents 95909c7 + 5285902 commit 8574206

30 files changed

+180
-112
lines changed

X2CScope/inc/CommonFcts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ typedef struct {
185185
uint32 trgCount; /** Absolute value of trgDelay, for comparison if trigger delay values have been sampled */
186186
uint32 maxUsedLength; /** Maximum used length of data array */
187187
tTrgEdgeType trgEdge; /** Trigger edge (rising, falling) */
188+
uint16 scopeSize; /** Scope block size */
188189
} SCOPE_MAIN;
189190

190191
/** DSP states */

X2CScope/inc/Scope_Main.h

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,6 @@
1616

1717
#define SCOPE_MAIN_ID ((uint16)65535)
1818

19-
#if defined(SCOPE_SIZE)
20-
/* Scope array size maximum size = 2^31-1 due to int32 variable types */
21-
#if SCOPE_SIZE > 2147483647
22-
#error SCOPE ARRAY SIZE MUST NOT EXCEED 2147483647 (2^31-1)
23-
#endif
24-
25-
#else
26-
27-
#if defined(__TMS320F28XX__) || defined(__TMS320F2833X__) || \
28-
defined(__TMS320F2803X__) || defined(__TMS320F280X__) || \
29-
defined(__TMS320F2806X__) || defined(__TMS320F281X__) || defined(__SERIES_TM4C__)
30-
#define SCOPE_SIZE ((uint16)4900)
31-
32-
#elif defined(__TMS320F2802X__)
33-
#define SCOPE_SIZE ((uint16)512)
34-
35-
#elif defined(__STM32F10X__) || defined(__STM32F10XXX__) || defined(__SERIES_STM32F1__)
36-
#define SCOPE_SIZE ((uint16)490)
37-
38-
#elif defined(__SERIES_STM32F4__) || defined(__SERIES_MPC5__)
39-
#define SCOPE_SIZE ((uint16)4900)
40-
41-
#elif defined(__SERIES_DSPIC33F__) || defined(__SERIES_DSPIC33E__)
42-
#define SCOPE_SIZE ((uint16)4900)
43-
44-
#elif defined(__SERIES_PIC32MZ__)
45-
#define SCOPE_SIZE ((uint16)8192)
46-
47-
#elif defined(__RX6XX__)
48-
#define SCOPE_SIZE ((uint16)4900)
49-
#else
50-
#error SCOPE ARRAY SIZE NOT DEFINED FOR CURRENT PROCESSOR
51-
#endif
52-
53-
#endif
54-
5519
#if defined(__DATA_WIDTH_8BIT__)
5620
#define ALIGNTYPE int8
5721
#define ALIGNCASTPTR (int8*)
@@ -64,14 +28,14 @@
6428

6529
#define SCOPE_MAIN_FUNCTIONS { SCOPE_MAIN_ID, \
6630
(void (*)(void*))Scope_Main_Update, \
67-
(void (*)(void*))Scope_Main_Init, \
31+
(void (*)(void*, void*, uint16))Scope_Main_Init, \
6832
(uint8 (*)(void*, uint8*))Scope_Main_Load, \
6933
(uint8 (*)(void*, uint8*, uint8))Scope_Main_Save, \
7034
(void* (*)(void*, uint16))Scope_Main_GetAddress }
7135

7236
/* public prototypes */
7337
void Scope_Main_Update(SCOPE_MAIN *pTScope);
74-
void Scope_Main_Init(SCOPE_MAIN *pTScope);
38+
void Scope_Main_Init(SCOPE_MAIN *pTScope,void *scopeArray, uint16 scope_size);
7539
uint8 Scope_Main_Load(SCOPE_MAIN *pTScope,uint8 *ucData);
7640
uint8 Scope_Main_Save(SCOPE_MAIN *pTScope,uint8 *ucData, uint8 ucFRMlen);
7741
void* Scope_Main_GetAddress(const SCOPE_MAIN* block, uint16 elementId);

X2CScope/inc/VersionInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#define __VERSIONINFO_H__
1111

1212
#include "CommonFcts.h"
13-
13+
#include "../../interface/X2Cscope.h"
1414
/* public prototypes */
15-
void initVersionInfo(volatile tTableStruct* tblStruct, uint16 appVersion);
15+
void initVersionInfo(volatile tTableStruct* tblStruct, const uint16 appVersion, compilationDate_t compilationDate);
1616

1717
#endif

X2CScope/inc/X2C.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* This file is derived from am X2C generated file, modified for use with the X2CScope Plugin */
1+
/* This file is derived from am X2C generated file, modified for use with the X2Cscope Plugin */
22
/* This file is part of X2C. http://www.mechatronic-simulation.org/ */
33

44
#ifndef __X2C_H__
@@ -27,7 +27,7 @@ extern const tParameterTable parameterIdTable[];
2727
/**********************************************************************************************************************/
2828
/** Prototypes **/
2929
/**********************************************************************************************************************/
30-
void X2C_Init(void);
30+
void X2C_Init(void* scopeArray, uint16 scopeSize);
3131
void X2C_Update(void);
3232

3333
#endif
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#ifndef __X2CSCOPEWRAPPER_H__
2+
#define __X2CSCOPEWRAPPER_H__
3+
14
#include "TableStruct.h"
25
#include "LNet.h"
36
#include "Services.h"
@@ -7,9 +10,6 @@
710
#include "X2C.h"
811
#include "VersionInfo.h"
912

10-
#ifndef __X2CSCOPEWRAPPER_H__
11-
#define __X2CSCOPEWRAPPER_H__
12-
1313
/* generated X2C parameter identifier & block function table */
1414
extern const tBlockFunctions blockFunctionTable[];
1515
extern const tParameterTable parameterIdTable[];
@@ -26,8 +26,8 @@ static tSerial interface;
2626
static tLNet protocol;
2727
static uint8 bufferLNet[LNET_BUFFERSIZE];
2828

29-
void X2CScope_Initialise();
30-
void X2CScope_Communicate();
31-
void X2CScope_Update();
29+
void X2Cscope_Initialise(void* scopeArray, uint16_t scopeSize, const uint16_t appVersion, compilationDate_t compilationDate);
30+
void X2Cscope_Communicate();
31+
void X2Cscope_Update();
3232

3333
#endif

X2CScope/src/Scope_Main.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ static uint8 isTriggerEvent(SCOPE_MAIN *pTScope, uint64 curTrgValue);
1313
static uint64 getTriggerValue(SCOPE_MAIN *pTScope);
1414
static void sampleData(SCOPE_MAIN *pTScope);
1515

16-
ALIGNTYPE ScopeArray[SCOPE_SIZE];
16+
//extern ALIGNTYPE ScopeArray[];
1717

1818
#if defined(__COMPILER_CODEWARRIOR_ECLIPSE__)
1919
#pragma push
@@ -44,7 +44,7 @@ static tBlockFunctions* getBlockFunction(const tBlockFunctions* blockFuncTable,
4444
/************************************************/
4545
/* Scope_Main_Init */
4646
/************************************************/
47-
void Scope_Main_Init(SCOPE_MAIN *pTScope)
47+
void Scope_Main_Init(SCOPE_MAIN *pTScope, void* scopeArray, uint16_t scope_size)
4848
{
4949
uint8 i;
5050

@@ -55,7 +55,7 @@ void Scope_Main_Init(SCOPE_MAIN *pTScope)
5555
pTScope->dataSize[i] = (uint8)0;
5656
}
5757

58-
pTScope->arrayAddr = (void*)ScopeArray;
58+
pTScope->arrayAddr = (void*)scopeArray;
5959
pTScope->trgLevel = (int32)0;
6060
pTScope->trgLastValue = (int32)0;
6161
pTScope->trgAddr = (void*)0;
@@ -72,9 +72,10 @@ void Scope_Main_Init(SCOPE_MAIN *pTScope)
7272
pTScope->trgEventPos = (int32)0;
7373
pTScope->trgCountReached = (uint8)0;
7474
pTScope->trgCount = (uint32)0;
75-
pTScope->maxUsedLength = SCOPE_SIZE;
75+
pTScope->maxUsedLength = (uint32)scope_size;
7676
pTScope->trgEdge = EDGE_RISING;
77-
pTScope->arraySize = SCOPE_SIZE;
77+
pTScope->arraySize = (uint32)scope_size;
78+
pTScope->scopeSize = (uint32)scope_size;
7879

7980
TableStruct->piScope = pTScope;
8081
}
@@ -107,7 +108,7 @@ void Scope_Main_Update(SCOPE_MAIN *pTScope)
107108

108109
/* if size of next data size would exceed SCOPE_SIZE, the */
109110
/* offline sampling mode will be stopped (change to idle state) */
110-
if ((pTScope->offlinePtr + pTScope->dataSizeTotal) > SCOPE_SIZE)
111+
if ((pTScope->offlinePtr + pTScope->dataSizeTotal) > pTScope->scopeSize)
111112
{
112113
pTScope->state = SCOPE_IDLE;
113114
}
@@ -134,7 +135,7 @@ void Scope_Main_Update(SCOPE_MAIN *pTScope)
134135
{
135136
pTScope->stfCnt = (uint16)0;
136137
/* reset array ptr if next dataset would exceed scope buffer size */
137-
if (pTScope->offlinePtr + pTScope->dataSizeTotal > SCOPE_SIZE)
138+
if (pTScope->offlinePtr + pTScope->dataSizeTotal > pTScope->scopeSize)
138139
{
139140
pTScope->offlinePtr = (int32)0;
140141
}
@@ -223,7 +224,7 @@ void Scope_Main_Update(SCOPE_MAIN *pTScope)
223224
{
224225
pTScope->stfCnt = (uint16)0;
225226

226-
if ((pTScope->offlinePtr + pTScope->dataSizeTotal) > SCOPE_SIZE)
227+
if ((pTScope->offlinePtr + pTScope->dataSizeTotal) > pTScope->scopeSize)
227228
{
228229
pTScope->offlinePtr = (uint32)0;
229230
}
@@ -417,8 +418,8 @@ uint8 Scope_Main_Save(SCOPE_MAIN *pTScope, uint8 *ucData, uint8 ucFRMlen)
417418
#error DATA WIDTH NOT DEFINED
418419
#endif
419420

420-
pTScope->maxUsedLength = SCOPE_SIZE - \
421-
(SCOPE_SIZE % pTScope->dataSizeTotal);
421+
pTScope->maxUsedLength = pTScope->scopeSize - \
422+
(pTScope->scopeSize % pTScope->dataSizeTotal);
422423

423424
ptr += (uint8)5;
424425
i++;

X2CScope/src/VersionInfo.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
*/
99
#include "VersionInfo.h"
1010

11-
const struct {
12-
uint8 date[11];
13-
uint8 time[8];
14-
} compilationDate = { __DATE__, __TIME__ };
15-
16-
void initVersionInfo(volatile tTableStruct* tblStruct, uint16 appVersion)
11+
void initVersionInfo(volatile tTableStruct* tblStruct, const uint16 appVersion, compilationDate_t compilationDate)
1712
{
1813
tblStruct->framePrgVersion = appVersion;
1914
tblStruct->framePrgCompDateTime = (uint8*)&compilationDate;

X2CScope/src/X2C.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* This file is derived from am X2C generated file, modified for use with the X2CScope Plugin */
1+
/* This file is derived from am X2C generated file, modified for use with the X2Cscope Plugin */
22
/* This file is part of X2C. http://www.mechatronic-simulation.org/ */
33

44
#include "X2C.h"
@@ -26,9 +26,9 @@ const tParameterTable parameterIdTable[] = {
2626
};
2727

2828

29-
void X2C_Init()
29+
void X2C_Init(void* scopeArray, uint16 scopeSize)
3030
{
31-
Scope_Main_Init(&TScope);
31+
Scope_Main_Init(&TScope, scopeArray, scopeSize);
3232
}
3333

3434
void X2C_Update(void)

X2CScope/src/X2CScopeWrapper.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "X2CScopeWrapper.h"
1+
#include "X2CscopeWrapper.h"
22

3-
void X2CScope_Initialise() {
3+
void X2Cscope_Initialise(void* scopeArray, uint16_t scopeSize, const uint16_t appVersion, compilationDate_t compilationDate) {
44
//X2C
55
initTableStruct();
66
initSerialGeneric(&interface);
@@ -13,20 +13,20 @@ void X2CScope_Initialise() {
1313
linkSerial((tProtocol*)&protocol, &interface);
1414
TableStruct->DSPState = PRG_LOADED_STATE;
1515

16-
initVersionInfo(TableStruct, (uint16)0x0001);
16+
initVersionInfo(TableStruct, appVersion, compilationDate);
1717
TableStruct->TFncTable = blockFunctionTable;
1818
TableStruct->TParamTable = parameterIdTable;
1919

2020
initSerial(&interface);
2121

22-
X2C_Init();
22+
X2C_Init(scopeArray,scopeSize);
2323
}
2424

25-
void X2CScope_Communicate() {
25+
void X2Cscope_Communicate() {
2626
protocol.pCommunicate((tProtocol*)&protocol);
2727
}
2828

29-
void X2CScope_Update() {
29+
void X2Cscope_Update() {
3030
X2C_Update();
3131
}
3232

@@ -35,7 +35,7 @@ static uint8_t (*receiveSerialFcn)();
3535
static uint8_t (*isReceiveDataAvailableFcn)();
3636
static uint8_t (*isSendReadyFcn)();
3737

38-
void X2CScope_HookUARTFunctions(void (*sendSerialFcnPntr)(uint8_t), uint8_t (*receiveSerialFcnPntr)(),
38+
void X2Cscope_HookUARTFunctions(void (*sendSerialFcnPntr)(uint8_t), uint8_t (*receiveSerialFcnPntr)(),
3939
uint8_t (*isReceiveDataAvailableFcnPntr)(), uint8_t (*isSendReadyFcnPntr)()) {
4040
sendSerialFcn = sendSerialFcnPntr;
4141
receiveSerialFcn = receiveSerialFcnPntr;

cm0_samd21.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#Change the following according the target MCU family
22
#---------------------------------------------
33
#TARGET_FILENAME and OBJDIR must not be the same in target mk files.
4-
TARGET_FILENAME := libx2cscope-cm0-elf.a
4+
TARGET_FILENAME := libx2cscope2-cm0-elf.a
55

66
# Object dir must start with underscore!
77
OBJDIR := _CM0

0 commit comments

Comments
 (0)