Adding STM Code Modules : Sample Code Module : my_main.c

my_main.c

The following shows a sample .c file that you would have to write. It contains the main for example.

 

/* my_main.c */
 
#include <stdio.h>
#include “types.h”
#include “example.h”
 
main()
 
{
int CONTINUE=0;
int ACTUAL_DI=0;
int COUNTER_INIT=0;
 
sw_module_ptr MODULE_HANDLE=0;
sw_module_status MODULE_STATUS;
 
 
example_init_module(
&MODULE_HANDLE,
&CONTINUE,
&ACTUAL_DI,
&COUNTER_INIT);
 
while (MODULE_STATUS != module_terminated)
{
 
printf(“Enter value to initialize counter (99=quit)\n”);
scanf (“%d”, &COUNTER_INIT );
CONTINUE=1;
 
 
while ((MODULE_STATUS == module_working) || CONTINUE)
{
 
 
 
 
MODULE_STATUS = example_exec(MODULE_HANDLE, 1);
 
 
printf (“Counter value = %d \n”, ACTUAL_DI);
printf (“Module Status - %d \n\n”, MODULE_STATUS);
}
}
 
printf(“ Statemate module has terminated \n”);
}