88#include "psm.h"
99#include "hsm.h"
1010
11- #ifdef __cplusplus
12- extern "C" {
13- #endif
14-
1511/* The PSM user specific signal */
1612enum {
1713 PSM_SIGNAL_1 = PSM_SIGNAL_USER_DEFINE ,
2420 PSM_INST_0 = 0 ,
2521 PSM_INST_1 ,
2622 PSM_INST_2 ,
23+ PSM_INST_NUM ,
2724};
2825
2926/* The HSM user specific signal */
@@ -43,22 +40,23 @@ enum {
4340 HSM_INST_210 ,
4441 HSM_INST_10 ,
4542 HSM_INST_100 ,
43+ HSM_INST_NUM ,
4644};
4745
4846static void * psm_state_1 (psm_state_input_t input );
4947static void * psm_state_2 (psm_state_input_t input );
5048static void * psm_state_3 (psm_state_input_t input );
51- static i32_t psm_transducer_handler (const psm_state_t * pStateContext , psm_instance_t from , psm_instance_t to , psm_state_input_t input );
52-
53- static i32_t hsm_state_0 (hsm_state_input_t input );
54- static i32_t hsm_state_1 (hsm_state_input_t input );
55- static i32_t hsm_state_2 (hsm_state_input_t input );
56- static i32_t hsm_state_20 (hsm_state_input_t input );
57- static i32_t hsm_state_21 (hsm_state_input_t input );
58- static i32_t hsm_state_210 (hsm_state_input_t input );
59- static i32_t hsm_state_10 (hsm_state_input_t input );
60- static i32_t hsm_state_100 (hsm_state_input_t input );
61- static i32_t hsm_transducer_handler (const hsm_state_t * pStateContext , hsm_instance_t from , hsm_instance_t to , hsm_state_input_t input );
49+ static unsigned int psm_transducer_handler (const psm_state_t * pStateContext , psm_instance_t from , psm_instance_t to , psm_state_input_t input );
50+
51+ static unsigned int hsm_state_0 (hsm_state_input_t input );
52+ static unsigned int hsm_state_1 (hsm_state_input_t input );
53+ static unsigned int hsm_state_2 (hsm_state_input_t input );
54+ static unsigned int hsm_state_20 (hsm_state_input_t input );
55+ static unsigned int hsm_state_21 (hsm_state_input_t input );
56+ static unsigned int hsm_state_210 (hsm_state_input_t input );
57+ static unsigned int hsm_state_10 (hsm_state_input_t input );
58+ static unsigned int hsm_state_100 (hsm_state_input_t input );
59+ static unsigned int hsm_transducer_handler (const hsm_state_t * pStateContext , hsm_instance_t from , hsm_instance_t to , hsm_state_input_t input );
6260
6361/* The PSM states' init tables */
6462static psm_state_t g_psm_state_init [] = {
@@ -131,13 +129,13 @@ static hsm_state_manager_t g_hsm_mngr_context = {0u};
131129
132130int main (void )
133131{
134- psm_init (& g_psm_mngr_context , & g_psm_state_init [0 ], PSM_INST_0 , psm_transducer_handler );
132+ psm_init (& g_psm_mngr_context , & g_psm_state_init [0 ], PSM_INST_NUM , PSM_INST_0 , psm_transducer_handler );
135133
136134 psm_state_input_t data = {0 };
137135 data .signal = PSM_SIGNAL_1 ;
138136 psm_activities (& g_psm_mngr_context , data );
139137
140- hsm_init (& g_hsm_mngr_context , & g_hsm_state_init [0 ], HSM_INST_210 , hsm_transducer_handler );
138+ hsm_init (& g_hsm_mngr_context , & g_hsm_state_init [0 ], HSM_INST_NUM , HSM_INST_210 , hsm_transducer_handler );
141139
142140 hsm_state_input_t input = {0 };
143141 input .signal = HSM_SIGNAL_INIT ;
@@ -149,7 +147,7 @@ int main(void)
149147 while (1 ) {};
150148}
151149
152- static i32_t psm_transducer_handler (const psm_state_t * pStateContext , psm_instance_t from , psm_instance_t to , psm_state_input_t input )
150+ static unsigned int psm_transducer_handler (const psm_state_t * pStateContext , psm_instance_t from , psm_instance_t to , psm_state_input_t input )
153151{
154152 if (pStateContext ) {
155153 printf ("psm_transducer_handler: from %d to %d, signal: %d\n" , from , to , input .signal );
@@ -250,15 +248,15 @@ static void* psm_state_3(psm_state_input_t input)
250248 return PSM_ACTION_DONE ;
251249}
252250
253- static i32_t hsm_transducer_handler (const hsm_state_t * pStateContext , hsm_instance_t from , hsm_instance_t to , hsm_state_input_t input )
251+ static unsigned int hsm_transducer_handler (const hsm_state_t * pStateContext , hsm_instance_t from , hsm_instance_t to , hsm_state_input_t input )
254252{
255253 if (pStateContext ) {
256254 printf ("hsm_transducer_handler: from %d to %d, signal: %d\n" , from , to , input .signal );
257255 }
258256 return 0 ;
259257}
260258
261- static i32_t hsm_state_0 (hsm_state_input_t input )
259+ static unsigned int hsm_state_0 (hsm_state_input_t input )
262260{
263261 switch (input .signal )
264262 {
@@ -293,7 +291,7 @@ static i32_t hsm_state_0(hsm_state_input_t input)
293291 return 0 ;
294292}
295293
296- static i32_t hsm_state_1 (hsm_state_input_t input )
294+ static unsigned int hsm_state_1 (hsm_state_input_t input )
297295{
298296 switch (input .signal )
299297 {
@@ -328,7 +326,7 @@ static i32_t hsm_state_1(hsm_state_input_t input)
328326 return 0 ;
329327}
330328
331- static i32_t hsm_state_2 (hsm_state_input_t input )
329+ static unsigned int hsm_state_2 (hsm_state_input_t input )
332330{
333331 switch (input .signal )
334332 {
@@ -363,7 +361,7 @@ static i32_t hsm_state_2(hsm_state_input_t input)
363361 return 0 ;
364362}
365363
366- static i32_t hsm_state_20 (hsm_state_input_t input )
364+ static unsigned int hsm_state_20 (hsm_state_input_t input )
367365{
368366 switch (input .signal )
369367 {
@@ -398,7 +396,7 @@ static i32_t hsm_state_20(hsm_state_input_t input)
398396 return 0 ;
399397}
400398
401- static i32_t hsm_state_21 (hsm_state_input_t input )
399+ static unsigned int hsm_state_21 (hsm_state_input_t input )
402400{
403401 switch (input .signal )
404402 {
@@ -434,7 +432,7 @@ static i32_t hsm_state_21(hsm_state_input_t input)
434432 return 0 ;
435433}
436434
437- static i32_t hsm_state_210 (hsm_state_input_t input )
435+ static unsigned int hsm_state_210 (hsm_state_input_t input )
438436{
439437 switch (input .signal )
440438 {
@@ -469,7 +467,7 @@ static i32_t hsm_state_210(hsm_state_input_t input)
469467 return 0 ;
470468}
471469
472- static i32_t hsm_state_10 (hsm_state_input_t input )
470+ static unsigned int hsm_state_10 (hsm_state_input_t input )
473471{
474472 switch (input .signal )
475473 {
@@ -504,7 +502,7 @@ static i32_t hsm_state_10(hsm_state_input_t input)
504502 return 0 ;
505503}
506504
507- static i32_t hsm_state_100 (hsm_state_input_t input )
505+ static unsigned int hsm_state_100 (hsm_state_input_t input )
508506{
509507 switch (input .signal )
510508 {
@@ -538,7 +536,3 @@ static i32_t hsm_state_100(hsm_state_input_t input)
538536
539537 return 0 ;
540538}
541-
542- #ifdef __cplusplus
543- }
544- #endif
0 commit comments