Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Externalizing data arrays in C (for arduino basic interpreter)

Status
Not open for further replies.

RodionGork

Newbie level 6
Joined
Jul 16, 2008
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,392
Hi Friends!

In my project firmware is supposed to be compiled from C for several platforms (now Arduino, STM32 and javascript emulator). I want to figure out the convenient way to allow two arrays have different size on different platforms. :-?

Here are details (sorry for many letters below) - it is a basic language interpreter, so here are two "large" byte arrays - one for storing program and variables (as lines are entered or variables/arrays created) - and another for entering current line. Say, Arduino may have only 800+300 bytes for program+vars while for STM32 this could be 5kb+10kb.

Currently this is done awkwardly. Project has its "core" set of files and few files specific to each platform in folders "core", "ardubasic", "stm32" and "js". The arrays are declared in these "specific" files, like this for arduino. Then they are then "extern"-ed in the "core" files - and sizes are passed to init function at beginning.

Every time I forget how exactly it is done, I understand it is a completely wrong way. However I seem to lack professional experience with C (though I used it since school and work with other languages for years) and can't understand if there is a way to declare these sizes as defines in "specific" part - and then use these defines in "core" files... The problem is that core files don't know anything about specific ones - on contrary they are used like a library attached to specific ones.

And also I sometimes think that at least division between program and data should be made runtime-configurable... But this makes me even more lost then ever... :-( So thank you in advance for hints!
 

Why don't you create a new header file which have all the required new defines and then include this header files in core files of all the different compilers like Arduino, STM32, etc,... ?
 

Why don't you create a new header file which have all the required new defines and then include this header files in core files of all the different compilers like Arduino, STM32, etc,... ?

It seems I failed to make it clear. This header file obviously should be different for different compilers, while "core files" are the same. I can't include 3-4 platform-dependent header files there...
 

> use #ifdef, #ifndef, #endif, #elif, #else ant e.t.c.

Sorry, this don't sound good. If a new target is added, say LPC21xx controllers - then I'll need to add another #ifdef to core files... This don't sound better than existing mess...
 

When new device is added then header files has to be updated to support the new device. This is how compiler manufacturers do when new devices are added to the Compiler. For eg:, for every new device added to a Compiler they have to create #defines or a separate header file for that device to support its registers.

Your problem is only data type size variations between different Compilers for different targets ?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top