Importing custom S32 target code into MBDT projects

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Importing custom S32 target code into MBDT projects

540 Views
Henrik-Wires
Contributor IV

We have a custom S32K3 FlexIO driver (C code) that we want to use from a MBDT project, but it's not entirely obvious how to import this code into the project.

The driver code is developed in S32 Design Studio, and works fine on target. But when using the Simulink Code Importer wizard to package the code as a simulink library it halts on not finding the relevant RTD and hardware headers.

I am guessing the the code need to support being built both for the S32 target and as generic hardware-independent version for simulation for the code import to work.

Is there any guidance on how this is best done?

Is there for example any standard define we can use in the code allowing the code to build different depending on the current target (generic x86_64 vs s32)? Or any way to tell Simulink to use different sets of C files during simulation and on target?

0 Kudos
Reply
1 Reply

493 Views
Henrik-Wires
Contributor IV

I have now wrapped the hardware dependent parts in
#if defined(CPU_S32K396)
#endif

with in some cases an #else with generic code.

which should solve the issue.  But is this the recommended method for adding S32K RTD dependent code to an MBDT project?

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2317918%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EImporting%20custom%20S32%20target%20code%20into%20MBDT%20projects%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2317918%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EWe%20have%20a%20custom%20S32K3%20FlexIO%20driver%20(C%20code)%20that%20we%20want%20to%20use%20from%20a%20MBDT%20project%2C%20but%20it's%20not%20entirely%20obvious%20how%20to%20import%20this%20code%20into%20the%20project.%3C%2FP%3E%3CP%3EThe%20driver%20code%20is%20developed%20in%20S32%20Design%20Studio%2C%20and%20works%20fine%20on%20target.%20But%20when%20using%20the%20Simulink%20Code%20Importer%20wizard%20to%20package%20the%20code%20as%20a%20simulink%20library%20it%20halts%20on%20not%20finding%20the%20relevant%20RTD%20and%20hardware%20headers.%3C%2FP%3E%3CP%3EI%20am%20guessing%20the%20the%20code%20need%20to%20support%20being%20built%20both%20for%20the%20S32%20target%20and%20as%20generic%20hardware-independent%20version%20for%20simulation%20for%20the%20code%20import%20to%20work.%3C%2FP%3E%3CP%3EIs%20there%20any%20guidance%20on%20how%20this%20is%20best%20done%3F%3C%2FP%3E%3CP%3EIs%20there%20for%20example%20any%20standard%20define%20we%20can%20use%20in%20the%20code%20allowing%20the%20code%20to%20build%20different%20depending%20on%20the%20current%20target%20(generic%20x86_64%20vs%20s32)%3F%20Or%20any%20way%20to%20tell%20Simulink%20to%20use%20different%20sets%20of%20C%20files%20during%20simulation%20and%20on%20target%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2318570%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Importing%20custom%20S32%20target%20code%20into%20MBDT%20projects%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2318570%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20have%20now%20wrapped%20the%20hardware%20dependent%20parts%20in%3CBR%20%2F%3E%23if%20defined(CPU_S32K396)%3CBR%20%2F%3E%23endif%3C%2FP%3E%3CP%3Ewith%20in%20some%20cases%20an%20%23else%20with%20generic%20code.%3C%2FP%3E%3CP%3Ewhich%20should%20solve%20the%20issue.%26nbsp%3B%20But%20is%20this%20the%20recommended%20method%20for%20adding%20S32K%20RTD%20dependent%20code%20to%20an%20MBDT%20project%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E