diff --git a/hal_api.h b/hal_api.h index f53efcb..222c989 100644 --- a/hal_api.h +++ b/hal_api.h @@ -119,6 +119,7 @@ extern "C" { uint16_t channels[18]; uint8_t seq; + uint8_t id; uint8_t valid; } HAL_sbus_in_t; @@ -232,5 +233,4 @@ extern "C" } #endif -#endif // _HAL_H_ - +#endif // _HAL_H_ \ No newline at end of file diff --git a/hal_api.sldd b/hal_api.sldd index b34cc6f..d08b705 100644 Binary files a/hal_api.sldd and b/hal_api.sldd differ diff --git a/hal_api_busdef.m b/hal_api_busdef.m index e378af8..575fa2c 100644 --- a/hal_api_busdef.m +++ b/hal_api_busdef.m @@ -140,6 +140,7 @@ cellInfo = { ... '-1', {... {'channels', 18, 'uint16', -1, 'real', 'Sample', 'Fixed', [], [], sprintf('us'), ''}; ... {'seq', 1, 'uint8', -1, 'real', 'Sample', 'Fixed', [], [], '', ''}; ... +{'id', 1, 'uint8', -1, 'real', 'Sample', 'Fixed', [], [], '', ''}; ... {'valid', 1, 'boolean', -1, 'real', 'Sample', 'Fixed', [], [], '', ''}; ... } ... } ... diff --git a/hal_api_ctrls_bld.slx b/hal_api_ctrls_bld.slx index 77f63ee..cfbab24 100644 Binary files a/hal_api_ctrls_bld.slx and b/hal_api_ctrls_bld.slx differ diff --git a/hal_sbus_in.c b/hal_sbus_in.c index 021cfdd..5031d6b 100644 --- a/hal_sbus_in.c +++ b/hal_sbus_in.c @@ -26,7 +26,7 @@ * | See matlabroot/simulink/src/sfuntmpl_doc.c for a more detailed template | * ------------------------------------------------------------------------- * - * Created: Tue Mar 24 14:55:05 2020 + * Created: Wed Jun 03 15:45:18 2020 */ #define S_FUNCTION_LEVEL 2 @@ -320,7 +320,7 @@ static void mdlStart(SimStruct *S) const char *bpath = ssGetPath(S); DTypeId HAL_sbus_in_tId = ssGetDataTypeId(S, "HAL_sbus_in_t"); - busInfoStruct *busInfo = (busInfoStruct *)malloc(6*sizeof(busInfoStruct)); + busInfoStruct *busInfo = (busInfoStruct *)malloc(8*sizeof(busInfoStruct)); if(busInfo==NULL) { ssSetErrorStatus(S, "Memory allocation failure"); return; @@ -335,8 +335,11 @@ static void mdlStart(SimStruct *S) busInfo[1].elemSize = dtaGetDataTypeSize(dta, bpath, ssGetDataTypeId(S, "uint8")); busInfo[1].numElems = 1; busInfo[2].offset = dtaGetDataTypeElementOffset(dta, bpath, HAL_sbus_in_tId, 2); - busInfo[2].elemSize = dtaGetDataTypeSize(dta, bpath, ssGetDataTypeId(S, "boolean")); + busInfo[2].elemSize = dtaGetDataTypeSize(dta, bpath, ssGetDataTypeId(S, "uint8")); busInfo[2].numElems = 1; + busInfo[3].offset = dtaGetDataTypeElementOffset(dta, bpath, HAL_sbus_in_tId, 3); + busInfo[3].elemSize = dtaGetDataTypeSize(dta, bpath, ssGetDataTypeId(S, "boolean")); + busInfo[3].numElems = 1; ssSetUserData(S, busInfo); const int_T p_width0 = mxGetNumberOfElements(PARAM_DEF0(S)); const uint8_T *id = (const uint8_T *) mxGetData(PARAM_DEF0(S)); @@ -367,7 +370,8 @@ static void mdlOutputs(SimStruct *S, int_T tid) /* Copy temporary structure into output bus */ (void) memcpy(sbus + busInfo[0].offset, _sbusBUS.channels, busInfo[0].elemSize * busInfo[0].numElems); (void) memcpy(sbus + busInfo[1].offset, &_sbusBUS.seq, busInfo[1].elemSize * busInfo[1].numElems); - (void) memcpy(sbus + busInfo[2].offset, &_sbusBUS.valid, busInfo[2].elemSize * busInfo[2].numElems); + (void) memcpy(sbus + busInfo[2].offset, &_sbusBUS.id, busInfo[2].elemSize * busInfo[2].numElems); + (void) memcpy(sbus + busInfo[3].offset, &_sbusBUS.valid, busInfo[3].elemSize * busInfo[3].numElems); } diff --git a/hal_sbus_in.mexw64 b/hal_sbus_in.mexw64 index 3760a7f..8b13b86 100644 Binary files a/hal_sbus_in.mexw64 and b/hal_sbus_in.mexw64 differ diff --git a/hal_sbus_in.tlc b/hal_sbus_in.tlc index a7cd97a..1bc2ac8 100644 --- a/hal_sbus_in.tlc +++ b/hal_sbus_in.tlc @@ -1,5 +1,5 @@ %% File : hal_sbus_in.tlc -%% Created : Tue Mar 24 14:55:05 2020 +%% Created : Wed Jun 03 15:45:18 2020 %% %% Description: %% Simulink Coder wrapper functions interface generated for diff --git a/template/hal_sbus_in_wrapper.c b/template/hal_sbus_in_wrapper.c index c61f4ae..97dfa57 100644 --- a/template/hal_sbus_in_wrapper.c +++ b/template/hal_sbus_in_wrapper.c @@ -12,6 +12,7 @@ #include "hal_api.h" + /* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */ #ifdef HAL_IMPL //#include "param_mgr.h" @@ -49,20 +50,20 @@ void sbus_input_init(uint8_t id) */ void hal_sbus_in_Start_wrapper(const uint8_T *id, const int_T p_width0) { - /* %%%-SFUNWIZ_wrapper_Start_Changes_BEGIN --- EDIT HERE TO _END */ - sbus_input_init(id[0]); - /* %%%-SFUNWIZ_wrapper_Start_Changes_END --- EDIT HERE TO _BEGIN */ +/* %%%-SFUNWIZ_wrapper_Start_Changes_BEGIN --- EDIT HERE TO _END */ +sbus_input_init(id[0]); +/* %%%-SFUNWIZ_wrapper_Start_Changes_END --- EDIT HERE TO _BEGIN */ } /* * Output function * */ void hal_sbus_in_Outputs_wrapper(HAL_sbus_in_t *sbus, - int32_T *ErrorCode, - const uint8_T *id, const int_T p_width0) + int32_T *ErrorCode, + const uint8_T *id, const int_T p_width0) { - /* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */ - ErrorCode[0] = -1; +/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */ +ErrorCode[0] = -1; /* * input *AI* from ADC channels from *start_idx* to *start_idx*+y_width-1. * @@ -74,11 +75,14 @@ void hal_sbus_in_Outputs_wrapper(HAL_sbus_in_t *sbus, if (is_sbus_in_init[0]) { #ifdef HAL_IMPL + // TODO set sbus outputs ErrorCode[0] = 0; #endif } break; } - /* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */ +/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */ } + +