I gave in last night and installed a 2nd instance of the MinGW compiler to use in Matlab (in addition to the one in eclipse/Cygwin) as well as the 2 compilers for the same target processor for 2 instances of S32DS (one standalone and one embedded in MBDT).
As you can see from the script above, I have a single entry point, single function call with no parameters, but I want to access the data sets and Function calls (that will exist once the .p scripts have run and created sources, build is built) from the FlexPwm driver set, ideally using all the same definitions (as the build).

The problem I now have is that because of dependencies in the includes, and the S-function wishing to 'build' ahead of the .p scripts running, I cannot apparently satisfy this requirement.... without adding a (pre-built) version of all the dependent sources into my local build directory.

The examples you provide have basic 'standalone' functionality, or simple i/o functionality at the model... but I cant find an example that tries the level of 'symbolic' integration I want to achieve.Can it be done?
I assume I have to have more information declared to the S-Function builder, but its not clear what is needed.. as the S-Function builder appears to try and 'compile' the S-function BEFORE any of the model m scripts(p scripts) run to generate the build C sources.
(I obviously don't have a good mental model of how the libraries section of the S-Function builder is supposed to work!)
Can you point me to any example that does this... or do I just go through and re- define absolutely everything I need locally (in my build directory with a 'local' .h file?
pwm_mod.c - below
/* GD3000 initialisation ny manipulating FlexPWM configuration temporarily back to independent */
#include "flexpwm_driver.h"
#include <assert.h>
#include <stddef.h>
/* Function to allow us to alter all 3 PWM0 Submodules (0, 1 and 2) corresponding to PhA, B and C, duty cycles */
void Force_HS_LS_Drive(volatile uint16_t DutyA, volatile uint16_t DutyB)
{
FLEXPWM_DRV_UpdatePulseWidth (INST_FLEXPWM0, FlexPwmModule0, DutyA, DutyB, FlexPwmCentreAligned);
FLEXPWM_DRV_LoadCommands(INST_FLEXPWM0, (1 << FlexPwmModule0));
FLEXPWM_DRV_UpdatePulseWidth (INST_FLEXPWM0, FlexPwmModule1, DutyA, DutyB, FlexPwmCentreAligned);
FLEXPWM_DRV_LoadCommands(INST_FLEXPWM0, (1 << FlexPwmModule1));
FLEXPWM_DRV_UpdatePulseWidth (INST_FLEXPWM0, FlexPwmModule2, DutyA, DutyB, FlexPwmCentreAligned);
FLEXPWM_DRV_LoadCommands(INST_FLEXPWM0, (1 << FlexPwmModule2));
}
/* --------- */
/* Modify Channel Mode of Operation to Independent on submodules0, 1 and 2 of PWM0 */
void Modify_PWM_Op_Ind(void)
{
/* Modify the Channel Pair operation and re-init submodule */
flexPWM0_ModuleSetup0->chnlPairOper = FlexPwmIndependent;
flexPWM0_ModuleSetup1->chnlPairOper = FlexPwmIndependent;
flexPWM0_ModuleSetup2->chnlPairOper = FlexPwmIndependent;
/* Initializing the FLEXPWM0 */
FLEXPWM_DRV_SetupPwm(INST_FLEXPWM0, FlexPwmModule0, &flexPWM0_ModuleSetup0,
&flexPWM0_SignalSetup0);
/* Ripped out remainder of set-up as shouldn't need to re-assert */
/* flexPWM0_SignalSetup0_pwm_period_raw_value = 4000U;
PINS_DRV_Init(2U, pwm0_submodule0_pin_config); */
/* Counter start FLEXPWM0 */
/* FLEXPWM_DRV_CounterStart(INST_FLEXPWM0, FlexPwmModule0); */
/* Start for S-Function (flexpwm_mpc574x_config): '<S2>/FlexPWM_Config1' */
/* Initializing the FLEXPWM0 */
FLEXPWM_DRV_SetupPwm(INST_FLEXPWM0, FlexPwmModule1, &flexPWM0_ModuleSetup1,
&flexPWM0_SignalSetup1);
/*flexPWM0_SignalSetup1_pwm_period_raw_value = 4000U;
PINS_DRV_Init(2U, pwm0_submodule1_pin_config); */
/* Counter start FLEXPWM0 */
/* FLEXPWM_DRV_CounterStart(INST_FLEXPWM0, FlexPwmModule1); */
/* Start for S-Function (flexpwm_mpc574x_config): '<S2>/FlexPWM_Config2' */
/* Initializing the FLEXPWM0 */
FLEXPWM_DRV_SetupPwm(INST_FLEXPWM0, FlexPwmModule2, &flexPWM0_ModuleSetup2,
&flexPWM0_SignalSetup2);
/* flexPWM0_SignalSetup2_pwm_period_raw_value = 4000U;
PINS_DRV_Init(2U, pwm0_submodule2_pin_config); */
/* Counter start FLEXPWM0 */
/* FLEXPWM_DRV_CounterStart(INST_FLEXPWM0, FlexPwmModule2); */
}
/* --------- */
/* Modify Channel Mode of Operation to Complementary on submodules0, 1 and 2 of PWM0 */
void Modify_PWM_Op_Comp(void)
{
/* Modify the Channel Pair operation back to comlementary and re-init submodule */
flexPWM0_ModuleSetup0->chnlPairOper = FlexPwmComplementary;
flexPWM0_ModuleSetup1->chnlPairOper = FlexPwmComplementary;
flexPWM0_ModuleSetup2->chnlPairOper = FlexPwmComplementary;
/* Initializing the FLEXPWM0 */
FLEXPWM_DRV_SetupPwm(INST_FLEXPWM0, FlexPwmModule0, &flexPWM0_ModuleSetup0,
&flexPWM0_SignalSetup0);
/* flexPWM0_SignalSetup0_pwm_period_raw_value = 4000U;
PINS_DRV_Init(2U, pwm0_submodule0_pin_config); */
/* Counter start FLEXPWM0 */
/* FLEXPWM_DRV_CounterStart(INST_FLEXPWM0, FlexPwmModule0); */
/* Start for S-Function (flexpwm_mpc574x_config): '<S2>/FlexPWM_Config1' */
/* Initializing the FLEXPWM0 */
FLEXPWM_DRV_SetupPwm(INST_FLEXPWM0, FlexPwmModule1, &flexPWM0_ModuleSetup1,
&flexPWM0_SignalSetup1);
/*flexPWM0_SignalSetup1_pwm_period_raw_value = 4000U;
PINS_DRV_Init(2U, pwm0_submodule1_pin_config); */
/* Counter start FLEXPWM0 */
/* FLEXPWM_DRV_CounterStart(INST_FLEXPWM0, FlexPwmModule1); */
/* Start for S-Function (flexpwm_mpc574x_config): '<S2>/FlexPWM_Config2' */
/* Initializing the FLEXPWM0 */
FLEXPWM_DRV_SetupPwm(INST_FLEXPWM0, FlexPwmModule2, &flexPWM0_ModuleSetup2,
&flexPWM0_SignalSetup2);
/* flexPWM0_SignalSetup2_pwm_period_raw_value = 4000U;
PINS_DRV_Init(2U, pwm0_submodule2_pin_config); */
/* Counter start FLEXPWM0 */
/* FLEXPWM_DRV_CounterStart(INST_FLEXPWM0, FlexPwmModule2); */
}
/* Make simultaneous changes to HS and LS FET states on submodules0, 1 and 2 of PWM0 */
void HS_LS_action(void)
{
volatile uint16_t i; /* Make this volatile so compiler doesn't optimise loops out */
/* Modify Channel mode of operation to 'Independent' to allow us to specifiy HS and LS movements using PWM duty */
Modify_PWM_Op_Ind();
/* Start with Both HS and LS off */
Force_HS_LS_Drive(0,0);
for (i=0, i < 50, i++){
/* Do nothing for approx 2.5us */
}
/* Turn LS On */
Force_HS_LS_Drive(0,1);
/* Wait for at least 1us - assumes 50ns inst time - ish */
for (i=0, i < 20, i++){
/* Do nothing */
}
/* Then turn LS off again - execution time of function call ensures no overlap, FETS are quick! */
Force_HS_LS_Drive(0,0);
for (i=0, i < 50, i++){
/* Do nothing for approx 2.5us */
}
/* Turn HS on */
Force_HS_LS_Drive(1,0);
/* Wait for a minimilast time 100ns plus deadtime is required, so lets say 250ns */
for (i=0, i < 5, i++){
/* Do nothing */
}
/* Turn off HS drive again... and then ready to go immediately without further delay */
Force_HS_LS_Drive(0,0);
for (i=0, i < 50, i++){
/* Do nothing for approx 2.5us */
}
/* Put back the original 'Complementary' mode of Channel Operation */
Modify_PWM_Op_Comp();
}
Basically I want to re-use the FlexPWM driver data structure and function calls (which should be 'public' by virtue of the FlexPWM_driver.h)... but it doesn't exist when I have to tell the S-Function builder to build. If I copy (a previously produced FlexPWM_driver .c/.h) into my local build directory.. it then complains about other dependencies... and so on... as I drag in more and more previously built .c/.h sources to my local build directory.
Any pointers on how to call C-functions (that exist outside my local source/build directory) would be appreciated.
Regards,
Stuart