├── CompileAlgorithm_walkAlg.m ├── Data ├── 100_Steps_Walking_Hand-Held_Flat_User2_1413935802633.csv ├── 100_Steps_Walking_Hand-held_reading_User1_1413929971238.csv ├── 100_Steps_Walking_Hand-held_reading_User2_1413936134896.csv ├── 100_Steps_Walking_Shoulder_bag_User1_1413930457929.csv ├── 100_Steps_Walking_Shoulder_bag_User2_1413926774223.csv ├── 100_Steps_Walking_fast_Front_pocket_fast_User1_1413923370517.csv ├── 100_Steps_Walking_slow_Front_pocket_slow_User1_1413921061935.csv ├── 100_Steps_Walking_slow_Front_pocket_slow_User2_1413925777053.csv ├── 56_steps_handheld.mat └── 57steps_worn_around_neck.mat ├── README.md ├── aTimeUnroll2 flow diagram.jpg ├── aTimeUnroll2.m ├── codegen └── lib │ └── walkAlg3 │ ├── aTimeUnroll2.c │ ├── aTimeUnroll2.h │ ├── abs.c │ ├── abs.h │ ├── buildInfo.mat │ ├── html │ ├── aTimeUnroll231_mcode.html │ ├── aTimeUnroll231_watch.html │ ├── aTimeUnroll2_c.html │ ├── aTimeUnroll2_h.html │ ├── abs_c.html │ ├── abs_h.html │ ├── coder_report.mat │ ├── contents_file.tmp │ ├── hilite_warning.png │ ├── index.css │ ├── index.html │ ├── inference.mat │ ├── isnan_c.html │ ├── isnan_h.html │ ├── rtGetInf_c.html │ ├── rtGetInf_h.html │ ├── rtGetNaN_c.html │ ├── rtGetNaN_h.html │ ├── rt_nonfinite_c.html │ ├── rt_nonfinite_h.html │ ├── rtwshrink.js │ ├── rtwtypes_h.html │ ├── stepCounter_struct_init30_mcode.html │ ├── stepCounter_struct_init30_watch.html │ ├── stepCounter_struct_init_c.html │ ├── stepCounter_struct_init_h.html │ ├── walkAlg31_mcode.html │ ├── walkAlg31_watch.html │ ├── walkAlg3_buildlog1.html │ ├── walkAlg3_c.html │ ├── walkAlg3_h.html │ ├── walkAlg3_initialize_c.html │ ├── walkAlg3_initialize_h.html │ ├── walkAlg3_terminate_c.html │ ├── walkAlg3_terminate_h.html │ └── walkAlg3_types_h.html │ ├── interface │ ├── _coder_walkAlg3_api.c │ ├── _coder_walkAlg3_api.h │ ├── _coder_walkAlg3_info.c │ ├── _coder_walkAlg3_info.h │ └── _coder_walkAlg3_mex.c │ ├── isnan.c │ ├── isnan.h │ ├── rtGetInf.c │ ├── rtGetInf.h │ ├── rtGetNaN.c │ ├── rtGetNaN.h │ ├── rt_nonfinite.c │ ├── rt_nonfinite.h │ ├── rtw_proj.tmw │ ├── rtwtypes.h │ ├── stepCounter_struct_init.c │ ├── stepCounter_struct_init.h │ ├── walkAlg3.c │ ├── walkAlg3.h │ ├── walkAlg3_initialize.c │ ├── walkAlg3_initialize.h │ ├── walkAlg3_ref.rsp │ ├── walkAlg3_rtw.bat │ ├── walkAlg3_rtw.mk │ ├── walkAlg3_terminate.c │ ├── walkAlg3_terminate.h │ └── walkAlg3_types.h ├── stepCounterScript.m ├── stepCounter_struct_init flow diagram.jpg ├── stepCounter_struct_init.m ├── walkAlg3 flow diagram.jpg └── walkAlg3.m /CompileAlgorithm_walkAlg.m: -------------------------------------------------------------------------------- 1 | %emlc CompileAlgorithm -eg {[0 0 0]',[0 0 0]',[0 0 0]',0} -c -report -T rtw:lib 2 | 3 | 4 | % Switch to current directory & restore default path 5 | p = mfilename('fullpath'); 6 | [pathstr, name, ext] = fileparts(p) 7 | cd(pathstr) 8 | restoredefaultpath 9 | % warning on 10 | 11 | close all 12 | clear all 13 | 14 | commandwindow 15 | 16 | fprintf('\nGenerating AutoCode...\n') 17 | warning off 18 | 19 | 20 | walkStruct = stepCounter_struct_init; 21 | 22 | % load 'SPwrap_sample_data.mat'; % load sample data variables 23 | % addpath('EMmatlab/em_overrides_direct'); % only add this path 24 | 25 | %%% real time workshop config object 26 | % rtwcfg = emlcoder.RTWConfig; 27 | % rtwcfg = emlcoder.RTWConfig('ert'); % Engineering Laptop ert setting 28 | cfg = coder.config('lib'); 29 | % cfg = coder.config('lib','ecoder',false); 30 | % rtwcfg.ObjectivePriorities = 'Efficiency'; 31 | cfg.FilePartitionMethod = 'MapMFileToCFile'; % MapMFileToCFile or SingleFile 32 | cfg.CCompilerOptimization = 'Off'; 33 | cfg.EnableVariableSizing = true; 34 | cfg.InlineThreshold = int32(0); 35 | cfg.HardwareImplementation.ProdHWDeviceType = 'ARM Compatible->ARM Cortex'; 36 | cfg.HardwareImplementation.TargetHWDeviceType = 'ARM Compatible->ARM Cortex'; 37 | cfg.GenCodeOnly = true; 38 | 39 | % set to tool chain configuration - to remove code gen warning 40 | cfg.GenerateMakefile = true; 41 | cfg.MakeCommand = 'make_rtw'; 42 | cfg.TemplateMakefile = 'default_tmf'; 43 | cfg.CCompilerOptimization = 'Off'; 44 | 45 | accDataIn = zeros(1,3,'single'); 46 | aRMSin = zeros(1,3,'single'); 47 | tDataIn = uint32(0); 48 | whichThr = single(0); 49 | resolution = single(1/32000); 50 | atime = uint16(0); 51 | 52 | 53 | codegen walkAlg3 -args {walkStruct,accDataIn,aRMSin,tDataIn,whichThr} ... 54 | stepCounter_struct_init -args {} ... 55 | aTimeUnroll2 -args {atime,resolution,walkStruct}... 56 | -config cfg -c -report 57 | 58 | 59 | 60 | % codegen App_Tracker -args {kSet,m,w,mtracker,walkStruct,steptrack,steptrack0,steptrack1,steptrackOut} -config cfg -c -report 61 | % % codegen SPAlgorithm_wrap1 -args {m,m2,magdef,accdef,gyrodef,kSet,mcalSet,w,k1,dataOut,mcalOut,mcalSIHI_in,gbias_in} -config cfg -c -report 62 | 63 | 64 | 65 | 66 | fprintf('\nCode Generation Complete!\n') 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /Data/56_steps_handheld.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memsindustrygroup/Matlab-Open-Source-Pedometer-Algorithm/ecc1dd70592aebba90b59af56f8cde9f9a06828a/Data/56_steps_handheld.mat -------------------------------------------------------------------------------- /Data/57steps_worn_around_neck.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memsindustrygroup/Matlab-Open-Source-Pedometer-Algorithm/ecc1dd70592aebba90b59af56f8cde9f9a06828a/Data/57steps_worn_around_neck.mat -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Matlab-Open-Source-Pedometer-Algorithm 2 | Example pedometer algorithm with sample test vectors 3 | -------------------------------------------------------------------------------- /aTimeUnroll2 flow diagram.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memsindustrygroup/Matlab-Open-Source-Pedometer-Algorithm/ecc1dd70592aebba90b59af56f8cde9f9a06828a/aTimeUnroll2 flow diagram.jpg -------------------------------------------------------------------------------- /aTimeUnroll2.m: -------------------------------------------------------------------------------- 1 | function [walkStruct] = aTimeUnroll2(atime,resolution,walkStruct) 2 | %#codegen 3 | if walkStruct.prevTime > atime %if previosu time is greater than current time, then increase count to note wrap 4 | % assumes no packets lost, and updates within 2 seconds of each other.. 5 | walkStruct.nWrap = walkStruct.nWrap + uint16(1); 6 | end 7 | % set in milliseconds for best storage method 8 | walkStruct.aTimeUnroll = uint32((single(walkStruct.nWrap)*65535+single(atime))*resolution*1000); % wrap corrected time scaled in milli seconds 9 | 10 | if walkStruct.aTimeUnroll > 4294967294 % max uint32 # 11 | walkStruct.nWrap = uint16(0); 12 | walkStruct.timerOverflow = uint8(1); % sets overflow flag to 1 13 | else 14 | walkStruct.timerOverflow = uint8(0); % resets wrapper back to 0 15 | end 16 | 17 | walkStruct.prevTime = atime; -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/aTimeUnroll2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * aTimeUnroll2.c 3 | * 4 | * Code generation for function 'aTimeUnroll2' 5 | * 6 | */ 7 | 8 | /* Include files */ 9 | #include "rt_nonfinite.h" 10 | #include "aTimeUnroll2.h" 11 | #include "stepCounter_struct_init.h" 12 | #include "walkAlg3.h" 13 | 14 | /* Function Declarations */ 15 | static float rt_roundf_snf(float u); 16 | 17 | /* Function Definitions */ 18 | static float rt_roundf_snf(float u) 19 | { 20 | float y; 21 | if ((real32_T)fabs(u) < 8.388608E+6F) { 22 | if (u >= 0.5F) { 23 | y = (real32_T)floor(u + 0.5F); 24 | } else if (u > -0.5F) { 25 | y = u * 0.0F; 26 | } else { 27 | y = (real32_T)ceil(u - 0.5F); 28 | } 29 | } else { 30 | y = u; 31 | } 32 | 33 | return y; 34 | } 35 | 36 | void aTimeUnroll2(unsigned short atime, float resolution, struct0_T *walkStruct) 37 | { 38 | unsigned int u0; 39 | float f0; 40 | if (walkStruct->prevTime > atime) { 41 | /* if previosu time is greater than current time, then increase count to note wrap */ 42 | /* assumes no packets lost, and updates within 2 seconds of each other.. */ 43 | u0 = walkStruct->nWrap + 1U; 44 | if (u0 > 65535U) { 45 | u0 = 65535U; 46 | } 47 | 48 | walkStruct->nWrap = (unsigned short)u0; 49 | } 50 | 51 | /* set in milliseconds for best storage method */ 52 | f0 = rt_roundf_snf((float)(walkStruct->nWrap * 65535U + atime) * resolution * 53 | 1000.0F); 54 | if (f0 < 4.2949673E+9F) { 55 | if (f0 >= 0.0F) { 56 | u0 = (unsigned int)f0; 57 | } else { 58 | u0 = 0U; 59 | } 60 | } else if (f0 >= 4.2949673E+9F) { 61 | u0 = MAX_uint32_T; 62 | } else { 63 | u0 = 0U; 64 | } 65 | 66 | walkStruct->aTimeUnroll = u0; 67 | 68 | /* wrap corrected time scaled in milli seconds */ 69 | if (walkStruct->aTimeUnroll > 4294967294U) { 70 | /* max uint32 # */ 71 | walkStruct->nWrap = 0; 72 | walkStruct->timerOverflow = 1; 73 | 74 | /* sets overflow flag to 1 */ 75 | } else { 76 | walkStruct->timerOverflow = 0; 77 | 78 | /* resets wrapper back to 0 */ 79 | } 80 | 81 | walkStruct->prevTime = atime; 82 | } 83 | 84 | /* End of code generation (aTimeUnroll2.c) */ 85 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/aTimeUnroll2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * aTimeUnroll2.h 3 | * 4 | * Code generation for function 'aTimeUnroll2' 5 | * 6 | */ 7 | 8 | #ifndef __ATIMEUNROLL2_H__ 9 | #define __ATIMEUNROLL2_H__ 10 | 11 | /* Include files */ 12 | #include 13 | #include 14 | #include 15 | #include "rt_nonfinite.h" 16 | #include "rtwtypes.h" 17 | #include "walkAlg3_types.h" 18 | 19 | /* Function Declarations */ 20 | extern void aTimeUnroll2(unsigned short atime, float resolution, struct0_T 21 | *walkStruct); 22 | 23 | #endif 24 | 25 | /* End of code generation (aTimeUnroll2.h) */ 26 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/abs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * abs.c 3 | * 4 | * Code generation for function 'abs' 5 | * 6 | */ 7 | 8 | /* Include files */ 9 | #include "rt_nonfinite.h" 10 | #include "aTimeUnroll2.h" 11 | #include "stepCounter_struct_init.h" 12 | #include "walkAlg3.h" 13 | #include "abs.h" 14 | 15 | /* Function Declarations */ 16 | static unsigned int b_eml_scalar_abs(unsigned int x); 17 | static float eml_scalar_abs(float x); 18 | 19 | /* Function Definitions */ 20 | static unsigned int b_eml_scalar_abs(unsigned int x) 21 | { 22 | return x; 23 | } 24 | 25 | static float eml_scalar_abs(float x) 26 | { 27 | return (real32_T)fabs(x); 28 | } 29 | 30 | void b_abs(const float x[3], float y[3]) 31 | { 32 | int k; 33 | for (k = 0; k < 3; k++) { 34 | y[k] = eml_scalar_abs(x[k]); 35 | } 36 | } 37 | 38 | unsigned int c_abs(unsigned int x) 39 | { 40 | return b_eml_scalar_abs(x); 41 | } 42 | 43 | /* End of code generation (abs.c) */ 44 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/abs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * abs.h 3 | * 4 | * Code generation for function 'abs' 5 | * 6 | */ 7 | 8 | #ifndef __ABS_H__ 9 | #define __ABS_H__ 10 | 11 | /* Include files */ 12 | #include 13 | #include 14 | #include 15 | #include "rt_nonfinite.h" 16 | #include "rtwtypes.h" 17 | #include "walkAlg3_types.h" 18 | 19 | /* Function Declarations */ 20 | extern void b_abs(const float x[3], float y[3]); 21 | extern unsigned int c_abs(unsigned int x); 22 | 23 | #endif 24 | 25 | /* End of code generation (abs.h) */ 26 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/buildInfo.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memsindustrygroup/Matlab-Open-Source-Pedometer-Algorithm/ecc1dd70592aebba90b59af56f8cde9f9a06828a/codegen/lib/walkAlg3/buildInfo.mat -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/aTimeUnroll231_mcode.html: -------------------------------------------------------------------------------- 1 | 2 |
 3 |  1function [walkStruct] = aTimeUnroll2(atime,resolution,walkStruct)
 4 |  2%#codegen
 5 |  3if walkStruct.prevTime > atime %if previosu time is greater than current time, then increase count to note wrap
 6 |  4    % assumes no packets lost, and updates within 2 seconds of each other..
 7 |  5    walkStruct.nWrap = walkStruct.nWrap + uint16(1);
 8 |  6end
 9 |  7% set in milliseconds for best storage method
10 |  8walkStruct.aTimeUnroll = uint32((single(walkStruct.nWrap)*65535+single(atime))*resolution*1000); % wrap corrected time scaled in milli seconds
11 |  9
12 | 10if walkStruct.aTimeUnroll > 4294967294 % max uint32 #
13 | 11    walkStruct.nWrap = uint16(0);
14 | 12    walkStruct.timerOverflow = uint8(1); % sets overflow flag to 1
15 | 13else
16 | 14    walkStruct.timerOverflow = uint8(0); % resets wrapper back to 0
17 | 15end
18 | 16
19 | 17walkStruct.prevTime = atime;
20 | 
21 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/aTimeUnroll231_watch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 |
 
1walkStructI/O1 x 1struct-
1.1walkStruct.HIthrAField1 x 1singleNo
1.2walkStruct.LIthrAField1 x 1singleNo
1.3walkStruct.HIthrWField1 x 1singleNo
1.4walkStruct.LIthrWField1 x 1singleNo
1.5walkStruct.timeThrField1 x 1singleNo
1.6walkStruct.HLIField1 x 1uint32No
1.7walkStruct.HItField1 x 1uint32No
1.8walkStruct.LItField1 x 1uint32No
1.9walkStruct.HIcntField1 x 1uint32No
1.10walkStruct.LIcntField1 x 1uint32No
1.11walkStruct.AcurField1 x 3singleNo
1.12walkStruct.AcurRMSField1 x 3singleNo
1.13walkStruct.AprevField1 x 3singleNo
1.14walkStruct.AprevRMSField1 x 3singleNo
1.15walkStruct.AcurtField1 x 1uint32No
1.16walkStruct.AprevtField1 x 1uint32No
1.17walkStruct.crossedField1 x 1uint8No
1.18walkStruct.addPointField1 x 1int8No
1.19walkStruct.resetField1 x 1uint8No
1.20walkStruct.aTimeUnrollField1 x 1uint32No
1.21walkStruct.prevTimeField1 x 1uint16No
1.22walkStruct.nWrapField1 x 1uint16No
1.23walkStruct.timerOverflowField1 x 1uint8No
1.24walkStruct.counterOverflowField1 x 1uint8No
2atimeInput1 x 1uint16No
3resolutionInput1 x 1singleNo
206 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/aTimeUnroll2_c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - aTimeUnroll2.c 6 | 7 | 8 | 9 |

10 |
11 |

File: aTimeUnroll2.c

12 |
 13 |     1   /*
 14 |     2    * aTimeUnroll2.c
 15 |     3    *
 16 |     4    * Code generation for function 'aTimeUnroll2'
 17 |     5    *
 18 |     6    */
 19 |     7   
 20 |     8   /* Include files */
 21 |     9   #include "rt_nonfinite.h"
 22 |    10   #include "aTimeUnroll2.h"
 23 |    11   #include "stepCounter_struct_init.h"
 24 |    12   #include "walkAlg3.h"
 25 |    13   
 26 |    14   /* Function Declarations */
 27 |    15   static float rt_roundf_snf(float u);
 28 |    16   
 29 |    17   /* Function Definitions */
 30 |    18   static float rt_roundf_snf(float u)
 31 |    19   {
 32 |    20     float y;
 33 |    21     if ((real32_T)fabs(u) < 8.388608E+6F) {
 34 |    22       if (u >= 0.5F) {
 35 |    23         y = (real32_T)floor(u + 0.5F);
 36 |    24       } else if (u > -0.5F) {
 37 |    25         y = u * 0.0F;
 38 |    26       } else {
 39 |    27         y = (real32_T)ceil(u - 0.5F);
 40 |    28       }
 41 |    29     } else {
 42 |    30       y = u;
 43 |    31     }
 44 |    32   
 45 |    33     return y;
 46 |    34   }
 47 |    35   
 48 |    36   void aTimeUnroll2(unsigned short atime, float resolution, struct0_T *walkStruct)
 49 |    37   {
 50 |    38     unsigned int u0;
 51 |    39     float f0;
 52 |    40     if (walkStruct->prevTime > atime) {
 53 |    41       /* if previosu time is greater than current time, then increase count to note wrap */
 54 |    42       /*  assumes no packets lost, and updates within 2 seconds of each other.. */
 55 |    43       u0 = walkStruct->nWrap + 1U;
 56 |    44       if (u0 > 65535U) {
 57 |    45         u0 = 65535U;
 58 |    46       }
 59 |    47   
 60 |    48       walkStruct->nWrap = (unsigned short)u0;
 61 |    49     }
 62 |    50   
 63 |    51     /*  set in milliseconds for best storage method */
 64 |    52     f0 = rt_roundf_snf((float)(walkStruct->nWrap * 65535U + atime) * resolution *
 65 |    53                        1000.0F);
 66 |    54     if (f0 < 4.2949673E+9F) {
 67 |    55       if (f0 >= 0.0F) {
 68 |    56         u0 = (unsigned int)f0;
 69 |    57       } else {
 70 |    58         u0 = 0U;
 71 |    59       }
 72 |    60     } else if (f0 >= 4.2949673E+9F) {
 73 |    61       u0 = MAX_uint32_T;
 74 |    62     } else {
 75 |    63       u0 = 0U;
 76 |    64     }
 77 |    65   
 78 |    66     walkStruct->aTimeUnroll = u0;
 79 |    67   
 80 |    68     /*  wrap corrected time scaled in milli seconds */
 81 |    69     if (walkStruct->aTimeUnroll > 4294967294U) {
 82 |    70       /*  max uint32 # */
 83 |    71       walkStruct->nWrap = 0;
 84 |    72       walkStruct->timerOverflow = 1;
 85 |    73   
 86 |    74       /*  sets overflow flag to 1 */
 87 |    75     } else {
 88 |    76       walkStruct->timerOverflow = 0;
 89 |    77   
 90 |    78       /*  resets wrapper back to 0 */
 91 |    79     }
 92 |    80   
 93 |    81     walkStruct->prevTime = atime;
 94 |    82   }
 95 |    83   
 96 |    84   /* End of code generation (aTimeUnroll2.c) */
 97 |    85   
98 |
99 |

100 | 101 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/aTimeUnroll2_h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - aTimeUnroll2.h 6 | 7 | 8 | 9 |

10 |
11 |

File: aTimeUnroll2.h

12 |
13 |     1   /*
14 |     2    * aTimeUnroll2.h
15 |     3    *
16 |     4    * Code generation for function 'aTimeUnroll2'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   #ifndef __ATIMEUNROLL2_H__
21 |     9   #define __ATIMEUNROLL2_H__
22 |    10   
23 |    11   /* Include files */
24 |    12   #include <math.h>
25 |    13   #include <stddef.h>
26 |    14   #include <stdlib.h>
27 |    15   #include "rt_nonfinite.h"
28 |    16   #include "rtwtypes.h"
29 |    17   #include "walkAlg3_types.h"
30 |    18   
31 |    19   /* Function Declarations */
32 |    20   extern void aTimeUnroll2(unsigned short atime, float resolution, struct0_T
33 |    21     *walkStruct);
34 |    22   
35 |    23   #endif
36 |    24   
37 |    25   /* End of code generation (aTimeUnroll2.h) */
38 |    26   
39 |
40 |

41 | 42 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/abs_c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - abs.c 6 | 7 | 8 | 9 |

10 |
11 |

File: abs.c

12 |
13 |     1   /*
14 |     2    * abs.c
15 |     3    *
16 |     4    * Code generation for function 'abs'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   /* Include files */
21 |     9   #include "rt_nonfinite.h"
22 |    10   #include "aTimeUnroll2.h"
23 |    11   #include "stepCounter_struct_init.h"
24 |    12   #include "walkAlg3.h"
25 |    13   #include "abs.h"
26 |    14   
27 |    15   /* Function Declarations */
28 |    16   static unsigned int b_eml_scalar_abs(unsigned int x);
29 |    17   static float eml_scalar_abs(float x);
30 |    18   
31 |    19   /* Function Definitions */
32 |    20   static unsigned int b_eml_scalar_abs(unsigned int x)
33 |    21   {
34 |    22     return x;
35 |    23   }
36 |    24   
37 |    25   static float eml_scalar_abs(float x)
38 |    26   {
39 |    27     return (real32_T)fabs(x);
40 |    28   }
41 |    29   
42 |    30   void b_abs(const float x[3], float y[3])
43 |    31   {
44 |    32     int k;
45 |    33     for (k = 0; k < 3; k++) {
46 |    34       y[k] = eml_scalar_abs(x[k]);
47 |    35     }
48 |    36   }
49 |    37   
50 |    38   unsigned int c_abs(unsigned int x)
51 |    39   {
52 |    40     return b_eml_scalar_abs(x);
53 |    41   }
54 |    42   
55 |    43   /* End of code generation (abs.c) */
56 |    44   
57 |
58 |

59 | 60 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/abs_h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - abs.h 6 | 7 | 8 | 9 |

10 |
11 |

File: abs.h

12 |
13 |     1   /*
14 |     2    * abs.h
15 |     3    *
16 |     4    * Code generation for function 'abs'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   #ifndef __ABS_H__
21 |     9   #define __ABS_H__
22 |    10   
23 |    11   /* Include files */
24 |    12   #include <math.h>
25 |    13   #include <stddef.h>
26 |    14   #include <stdlib.h>
27 |    15   #include "rt_nonfinite.h"
28 |    16   #include "rtwtypes.h"
29 |    17   #include "walkAlg3_types.h"
30 |    18   
31 |    19   /* Function Declarations */
32 |    20   extern void b_abs(const float x[3], float y[3]);
33 |    21   extern unsigned int c_abs(unsigned int x);
34 |    22   
35 |    23   #endif
36 |    24   
37 |    25   /* End of code generation (abs.h) */
38 |    26   
39 |
40 |

41 | 42 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/coder_report.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memsindustrygroup/Matlab-Open-Source-Pedometer-Algorithm/ecc1dd70592aebba90b59af56f8cde9f9a06828a/codegen/lib/walkAlg3/html/coder_report.mat -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/contents_file.tmp: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
2 | Generated Source Files 3 |
aTimeUnroll2.c
aTimeUnroll2.h
abs.c
abs.h
isnan.c
isnan.h
rtGetInf.c
rtGetInf.h
rtGetNaN.c
rtGetNaN.h
rt_nonfinite.c
rt_nonfinite.h
rtwtypes.h
stepCounter_struct_init.c
stepCounter_struct_init.h
walkAlg3.c
walkAlg3.h
walkAlg3_initialize.c
walkAlg3_initialize.h
walkAlg3_terminate.c
walkAlg3_terminate.h
walkAlg3_types.h
27 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/hilite_warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memsindustrygroup/Matlab-Open-Source-Pedometer-Algorithm/ecc1dd70592aebba90b59af56f8cde9f9a06828a/codegen/lib/walkAlg3/html/hilite_warning.png -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: sans-serif; 3 | font-size: 9pt; 4 | } 5 | pre.code, pre#RTWcode, .center .lineno { 6 | font:10pt/14pt Courier New; 7 | } 8 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/inference.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memsindustrygroup/Matlab-Open-Source-Pedometer-Algorithm/ecc1dd70592aebba90b59af56f8cde9f9a06828a/codegen/lib/walkAlg3/html/inference.mat -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/isnan_c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - isnan.c 6 | 7 | 8 | 9 |

10 |
11 |

File: isnan.c

12 |
13 |     1   /*
14 |     2    * isnan.c
15 |     3    *
16 |     4    * Code generation for function 'isnan'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   /* Include files */
21 |     9   #include "rt_nonfinite.h"
22 |    10   #include "aTimeUnroll2.h"
23 |    11   #include "stepCounter_struct_init.h"
24 |    12   #include "walkAlg3.h"
25 |    13   #include "isnan.h"
26 |    14   
27 |    15   /* Function Definitions */
28 |    16   boolean_T b_isnan(float x)
29 |    17   {
30 |    18     return rtIsNaNF(x);
31 |    19   }
32 |    20   
33 |    21   /* End of code generation (isnan.c) */
34 |    22   
35 |
36 |

37 | 38 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/isnan_h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - isnan.h 6 | 7 | 8 | 9 |

10 |
11 |

File: isnan.h

12 |
13 |     1   /*
14 |     2    * isnan.h
15 |     3    *
16 |     4    * Code generation for function 'isnan'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   #ifndef __ISNAN_H__
21 |     9   #define __ISNAN_H__
22 |    10   
23 |    11   /* Include files */
24 |    12   #include <math.h>
25 |    13   #include <stddef.h>
26 |    14   #include <stdlib.h>
27 |    15   #include "rt_nonfinite.h"
28 |    16   #include "rtwtypes.h"
29 |    17   #include "walkAlg3_types.h"
30 |    18   
31 |    19   /* Function Declarations */
32 |    20   extern boolean_T b_isnan(float x);
33 |    21   
34 |    22   #endif
35 |    23   
36 |    24   /* End of code generation (isnan.h) */
37 |    25   
38 |
39 |

40 | 41 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/rtGetInf_h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - rtGetInf.h 6 | 7 | 8 | 9 |

10 |
11 |

File: rtGetInf.h

12 |
13 |     1   /*
14 |     2    * rtGetInf.h
15 |     3    *
16 |     4    * Code generation for function 'walkAlg3'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   #ifndef __RTGETINF_H__
21 |     9   #define __RTGETINF_H__
22 |    10   
23 |    11   #include <stddef.h>
24 |    12   #include "rtwtypes.h"
25 |    13   #include "rt_nonfinite.h"
26 |    14   
27 |    15   extern real_T rtGetInf(void);
28 |    16   extern real32_T rtGetInfF(void);
29 |    17   extern real_T rtGetMinusInf(void);
30 |    18   extern real32_T rtGetMinusInfF(void);
31 |    19   
32 |    20   #endif
33 |    21   /* End of code generation (rtGetInf.h) */
34 |    22   
35 |
36 |

37 | 38 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/rtGetNaN_h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - rtGetNaN.h 6 | 7 | 8 | 9 |

10 |
11 |

File: rtGetNaN.h

12 |
13 |     1   /*
14 |     2    * rtGetNaN.h
15 |     3    *
16 |     4    * Code generation for function 'walkAlg3'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   #ifndef __RTGETNAN_H__
21 |     9   #define __RTGETNAN_H__
22 |    10   
23 |    11   #include <stddef.h>
24 |    12   #include "rtwtypes.h"
25 |    13   #include "rt_nonfinite.h"
26 |    14   
27 |    15   extern real_T rtGetNaN(void);
28 |    16   extern real32_T rtGetNaNF(void);
29 |    17   
30 |    18   #endif
31 |    19   /* End of code generation (rtGetNaN.h) */
32 |    20   
33 |
34 |

35 | 36 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/rt_nonfinite_h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - rt_nonfinite.h 6 | 7 | 8 | 9 |

10 |
11 |

File: rt_nonfinite.h

12 |
13 |     1   /*
14 |     2    * rt_nonfinite.h
15 |     3    *
16 |     4    * Code generation for function 'walkAlg3'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   #ifndef __RT_NONFINITE_H__
21 |     9   #define __RT_NONFINITE_H__
22 |    10   
23 |    11   #if defined(_MSC_VER) && (_MSC_VER <= 1200)
24 |    12   #include <float.h>
25 |    13   #endif
26 |    14   #include <stddef.h>
27 |    15   #include "rtwtypes.h"
28 |    16   
29 |    17   extern real_T rtInf;
30 |    18   extern real_T rtMinusInf;
31 |    19   extern real_T rtNaN;
32 |    20   extern real32_T rtInfF;
33 |    21   extern real32_T rtMinusInfF;
34 |    22   extern real32_T rtNaNF;
35 |    23   extern void rt_InitInfAndNaN(size_t realSize);
36 |    24   extern boolean_T rtIsInf(real_T value);
37 |    25   extern boolean_T rtIsInfF(real32_T value);
38 |    26   extern boolean_T rtIsNaN(real_T value);
39 |    27   extern boolean_T rtIsNaNF(real32_T value);
40 |    28   
41 |    29   typedef struct {
42 |    30     struct {
43 |    31       uint32_T wordH;
44 |    32       uint32_T wordL;
45 |    33     } words;
46 |    34   } BigEndianIEEEDouble;
47 |    35   
48 |    36   typedef struct {
49 |    37     struct {
50 |    38       uint32_T wordL;
51 |    39       uint32_T wordH;
52 |    40     } words;
53 |    41   } LittleEndianIEEEDouble;
54 |    42   
55 |    43   typedef struct {
56 |    44     union {
57 |    45       real32_T wordLreal;
58 |    46       uint32_T wordLuint;
59 |    47     } wordL;
60 |    48   } IEEESingle;
61 |    49   
62 |    50   #endif
63 |    51   /* End of code generation (rt_nonfinite.h) */
64 |    52   
65 |
66 |

67 | 68 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/rtwshrink.js: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2012 The MathWorks, Inc. 2 | 3 | function RTW_STRUCT(prop, value) { 4 | this.prop = prop; 5 | if (typeof(value) == 'undefined') 6 | this.value = ""; 7 | else 8 | this.value = value; 9 | } 10 | 11 | // initialize the cache when code generation report is first loaded 12 | function RTW_BOOK() 13 | { 14 | this.length = 0; 15 | this.rtw_pages = new Array(); 16 | this.getPage = function(file) { 17 | return this.rtw_pages[file]; 18 | } 19 | this.addPage = function(file) { 20 | var page; 21 | if (this.hasPage(file)) { 22 | page = this.rtw_pages[file]; 23 | } else { 24 | page = new RTW_PAGE(file); 25 | this.rtw_pages[file] = page; 26 | } 27 | return page; 28 | } 29 | this.hasPage = function(file) { 30 | return typeof(this.rtw_pages[file]) != 'undefined'; 31 | } 32 | this.removePage = function(file) 33 | { 34 | var tmp; 35 | if (typeof(this.rtw_pages[file]) != 'undefined') { 36 | tmp = this.rtw_pages[file]; 37 | delete this.rtw_pages[file]; 38 | this.length--; 39 | } 40 | return tmp; 41 | } 42 | } 43 | 44 | if (!RTW_BOOK.instance) { 45 | RTW_BOOK.instance = new RTW_BOOK(); 46 | } 47 | 48 | function RTW_PAGE() 49 | { 50 | this.length = 0; 51 | this.items = new Array(); 52 | this.pagename = ''; 53 | if (arguments.length > 0 && typeof(arguments[1])!='undefined') { 54 | this.pagename = arguments[1]; 55 | } 56 | 57 | this.getItem = function(id) { 58 | return this.items[id]; 59 | } 60 | this.getItems = function() { 61 | return this.items; 62 | } 63 | this.addItem = function(id, value) { 64 | var tmp; 65 | if (typeof(value) != 'undefined') { 66 | if (typeof(this.items[id]) != 'undefined') { 67 | this.length++; 68 | } else { 69 | tmp = this.items[id]; 70 | } 71 | this.items[id] = value; 72 | this.length++; 73 | } 74 | return tmp; 75 | } 76 | this.hasItem = function(id) { 77 | return typeof(this.items[id]) != 'undefined'; 78 | } 79 | this.removeItem = function(id) { 80 | var tmp; 81 | if (typeof(this.items[id]) != 'undefined') { 82 | tmp = this.items[id]; 83 | delete this.items[id]; 84 | this.length--; 85 | } 86 | return tmp; 87 | } 88 | } 89 | 90 | function rtwTableShrink(doc, obj, id, isSymbol){ 91 | if (isSymbol) { 92 | hide = "[-]"; 93 | hide_text = hide; 94 | show = "[+]"; 95 | show_text = show; 96 | } else { 97 | hide = "[hide]"; 98 | hide_text = "[hide]"; 99 | show = "[show]"; 100 | show_text = "[show]"; 101 | } 102 | hide = "" + hide + ""; 103 | show = "" + show + ""; 104 | if (doc.getElementsByName) { 105 | var o = doc.getElementsByName(id); 106 | for (var oid = 0; oid < o.length; ++oid) { 107 | if (o[oid].style.display == "none") { 108 | o[oid].style.display = ""; 109 | } else { 110 | o[oid].style.display = "none"; 111 | } 112 | } 113 | if (o.length >= 0 && top && top.addToPage) 114 | top.addToPage(doc, o[0], 'display'); 115 | } 116 | 117 | // IE supports innerText while other browsers support textContent 118 | if (obj.textContent) 119 | var objText = obj.textContent; 120 | else 121 | var objText = obj.innerText; 122 | 123 | if (objText.toLowerCase() == show_text.toLowerCase()) 124 | obj.innerHTML = hide; 125 | else 126 | obj.innerHTML = show; 127 | 128 | if (top && top.addToPage) 129 | top.addToPage(doc, obj, 'innerHTML'); 130 | } 131 | 132 | function rtwTableExpand(doc, controlObj, id) 133 | { 134 | if (doc.getElementById) { 135 | var obj = doc.getElementById(id); 136 | if (obj && obj.style.display == "none") { 137 | rtwTableShrink(doc, controlObj, id, false); 138 | } 139 | } 140 | } 141 | 142 | function restoreState(docObj) { 143 | var filename = docObj.location.href; 144 | if (RTW_BOOK.instance && RTW_BOOK.instance.hasPage(filename)) { 145 | var page = RTW_BOOK.instance.getPage(filename); 146 | var items = page.getItems(); 147 | var elem; 148 | if (docObj.getElementsByName) { 149 | for (var i in items) { 150 | o = docObj.getElementsByName(i); 151 | for (var oid = 0; oid < o.length; ++oid) { 152 | elem = o[oid]; 153 | if (items[i].prop == 'display') { 154 | if (elem.style.display == 'none') 155 | elem.style.display = ''; 156 | else 157 | elem.style.display = 'none'; 158 | } else if (items[i].prop == 'innerHTML') { 159 | elem.innerHTML = items[i].value; 160 | } 161 | } 162 | } 163 | } 164 | } 165 | } 166 | 167 | function addToPage(docObj, Obj, prop) { 168 | var filename = docObj.location.href; 169 | if (RTW_BOOK.instance) { 170 | var page; 171 | if (RTW_BOOK.instance.hasPage(filename)) 172 | page = RTW_BOOK.instance.getPage(filename); 173 | else 174 | page = RTW_BOOK.instance.addPage(filename); 175 | if (page.hasItem(Obj.id)) 176 | page.removeItem(Obj.id); 177 | else { 178 | if (prop == "display") 179 | my_struct = new RTW_STRUCT(prop, Obj.style.display); 180 | else 181 | my_struct = new RTW_STRUCT(prop, Obj.innerHTML); 182 | page.addItem(Obj.id, my_struct); 183 | } 184 | } 185 | } 186 | 187 | function rtwSwitchView(doc, obj1, obj2) { 188 | if (doc.getElementsByName) { 189 | var o = doc.getElementsByName(obj1); 190 | for (var oid = 0; oid < o.length; ++oid) { 191 | o[oid].style.display = "none"; 192 | } 193 | if (o.length >= 0 && top && top.addToPage) 194 | top.addToPage(doc, o[0], 'display'); 195 | var o = doc.getElementsByName(obj2); 196 | for (var oid = 0; oid < o.length; ++oid) { 197 | o[oid].style.display = ""; 198 | } 199 | if (o.length >= 0 && top && top.addToPage) 200 | top.addToPage(doc, o[0], 'display'); 201 | } 202 | } 203 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/stepCounter_struct_init30_mcode.html: -------------------------------------------------------------------------------- 1 | 2 |
 3 |  1function walkStruct = stepCounter_struct_init
 4 |  2%%% init of stepCounter structure
 5 |  3%
 6 |  4%#codegen
 7 |  5%
 8 |  6
 9 |  7% walkStruct
10 |  8walkStruct.HIthrA = single(2);
11 |  9walkStruct.LIthrA = single(0.7);
12 | 10walkStruct.HIthrW = single(1.7);
13 | 11walkStruct.LIthrW = single(1.05);
14 | 12walkStruct.timeThr = single(250); % made a single for real time updates
15 | 13walkStruct.HLI = uint32(0);
16 | 14walkStruct.HIt = uint32(0);
17 | 15walkStruct.LIt = uint32(0);
18 | 16walkStruct.HIcnt = uint32(0);
19 | 17walkStruct.LIcnt = uint32(0);
20 | 18walkStruct.Acur = zeros(1,3,'single'); %accel x y z time
21 | 19walkStruct.AcurRMS = zeros(1,3,'single');
22 | 20walkStruct.Aprev = zeros(1,3,'single');
23 | 21walkStruct.AprevRMS = zeros(1,3,'single');
24 | 22walkStruct.Acurt = uint32(0);
25 | 23walkStruct.Aprevt = uint32(0);
26 | 24walkStruct.crossed = uint8(0);
27 | 25walkStruct.addPoint = int8(0); % 1 to add point, 0 for nothing, -1 to lose point
28 | 26walkStruct.reset = uint8(0); % end of interval reset flag
29 | 27
30 | 28walkStruct.aTimeUnroll = uint32(0);
31 | 29walkStruct.prevTime = uint16(0);
32 | 30walkStruct.nWrap = uint16(0);
33 | 31
34 | 32walkStruct.timerOverflow = uint8(0);
35 | 33walkStruct.counterOverflow = uint8(0);
36 | 
37 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/stepCounter_struct_init30_watch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 |
 
1walkStructOutput1 x 1struct-
1.1walkStruct.HIthrAField1 x 1singleNo
1.2walkStruct.LIthrAField1 x 1singleNo
1.3walkStruct.HIthrWField1 x 1singleNo
1.4walkStruct.LIthrWField1 x 1singleNo
1.5walkStruct.timeThrField1 x 1singleNo
1.6walkStruct.HLIField1 x 1uint32No
1.7walkStruct.HItField1 x 1uint32No
1.8walkStruct.LItField1 x 1uint32No
1.9walkStruct.HIcntField1 x 1uint32No
1.10walkStruct.LIcntField1 x 1uint32No
1.11walkStruct.AcurField1 x 3singleNo
1.12walkStruct.AcurRMSField1 x 3singleNo
1.13walkStruct.AprevField1 x 3singleNo
1.14walkStruct.AprevRMSField1 x 3singleNo
1.15walkStruct.AcurtField1 x 1uint32No
1.16walkStruct.AprevtField1 x 1uint32No
1.17walkStruct.crossedField1 x 1uint8No
1.18walkStruct.addPointField1 x 1int8No
1.19walkStruct.resetField1 x 1uint8No
1.20walkStruct.aTimeUnrollField1 x 1uint32No
1.21walkStruct.prevTimeField1 x 1uint16No
1.22walkStruct.nWrapField1 x 1uint16No
1.23walkStruct.timerOverflowField1 x 1uint8No
1.24walkStruct.counterOverflowField1 x 1uint8No
192 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/stepCounter_struct_init_c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - stepCounter_struct_init.c 6 | 7 | 8 | 9 |

10 |
11 |

File: stepCounter_struct_init.c

12 |
13 |     1   /*
14 |     2    * stepCounter_struct_init.c
15 |     3    *
16 |     4    * Code generation for function 'stepCounter_struct_init'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   /* Include files */
21 |     9   #include "rt_nonfinite.h"
22 |    10   #include "aTimeUnroll2.h"
23 |    11   #include "stepCounter_struct_init.h"
24 |    12   #include "walkAlg3.h"
25 |    13   
26 |    14   /* Function Definitions */
27 |    15   struct0_T stepCounter_struct_init(void)
28 |    16   {
29 |    17     struct0_T walkStruct;
30 |    18     int i0;
31 |    19   
32 |    20     /* %% init of stepCounter structure */
33 |    21     /*  */
34 |    22     /*  */
35 |    23     /*  walkStruct */
36 |    24     walkStruct.HIthrA = 2.0F;
37 |    25     walkStruct.LIthrA = 0.7F;
38 |    26     walkStruct.HIthrW = 1.7F;
39 |    27     walkStruct.LIthrW = 1.05F;
40 |    28     walkStruct.timeThr = 250.0F;
41 |    29   
42 |    30     /*  made a single for real time updates */
43 |    31     walkStruct.HLI = 0U;
44 |    32     walkStruct.HIt = 0U;
45 |    33     walkStruct.LIt = 0U;
46 |    34     walkStruct.HIcnt = 0U;
47 |    35     walkStruct.LIcnt = 0U;
48 |    36     for (i0 = 0; i0 < 3; i0++) {
49 |    37       walkStruct.Acur[i0] = 0.0F;
50 |    38   
51 |    39       /* accel x y z time */
52 |    40       walkStruct.AcurRMS[i0] = 0.0F;
53 |    41       walkStruct.Aprev[i0] = 0.0F;
54 |    42       walkStruct.AprevRMS[i0] = 0.0F;
55 |    43     }
56 |    44   
57 |    45     walkStruct.Acurt = 0U;
58 |    46     walkStruct.Aprevt = 0U;
59 |    47     walkStruct.crossed = 0;
60 |    48     walkStruct.addPoint = 0;
61 |    49   
62 |    50     /*  1 to add point, 0 for nothing, -1 to lose point */
63 |    51     walkStruct.reset = 0;
64 |    52   
65 |    53     /*  end of interval reset flag */
66 |    54     walkStruct.aTimeUnroll = 0U;
67 |    55     walkStruct.prevTime = 0;
68 |    56     walkStruct.nWrap = 0;
69 |    57     walkStruct.timerOverflow = 0;
70 |    58     walkStruct.counterOverflow = 0;
71 |    59     return walkStruct;
72 |    60   }
73 |    61   
74 |    62   /* End of code generation (stepCounter_struct_init.c) */
75 |    63   
76 |
77 |

78 | 79 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/stepCounter_struct_init_h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - stepCounter_struct_init.h 6 | 7 | 8 | 9 |

10 |
11 |

File: stepCounter_struct_init.h

12 |
13 |     1   /*
14 |     2    * stepCounter_struct_init.h
15 |     3    *
16 |     4    * Code generation for function 'stepCounter_struct_init'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   #ifndef __STEPCOUNTER_STRUCT_INIT_H__
21 |     9   #define __STEPCOUNTER_STRUCT_INIT_H__
22 |    10   
23 |    11   /* Include files */
24 |    12   #include <math.h>
25 |    13   #include <stddef.h>
26 |    14   #include <stdlib.h>
27 |    15   #include "rt_nonfinite.h"
28 |    16   #include "rtwtypes.h"
29 |    17   #include "walkAlg3_types.h"
30 |    18   
31 |    19   /* Function Declarations */
32 |    20   extern struct0_T stepCounter_struct_init(void);
33 |    21   
34 |    22   #endif
35 |    23   
36 |    24   /* End of code generation (stepCounter_struct_init.h) */
37 |    25   
38 |
39 |

40 | 41 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/walkAlg31_watch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 |
 
1walkStructI/O1 x 1struct-
1.1walkStruct.HIthrAField1 x 1singleNo
1.2walkStruct.LIthrAField1 x 1singleNo
1.3walkStruct.HIthrWField1 x 1singleNo
1.4walkStruct.LIthrWField1 x 1singleNo
1.5walkStruct.timeThrField1 x 1singleNo
1.6walkStruct.HLIField1 x 1uint32No
1.7walkStruct.HItField1 x 1uint32No
1.8walkStruct.LItField1 x 1uint32No
1.9walkStruct.HIcntField1 x 1uint32No
1.10walkStruct.LIcntField1 x 1uint32No
1.11walkStruct.AcurField1 x 3singleNo
1.12walkStruct.AcurRMSField1 x 3singleNo
1.13walkStruct.AprevField1 x 3singleNo
1.14walkStruct.AprevRMSField1 x 3singleNo
1.15walkStruct.AcurtField1 x 1uint32No
1.16walkStruct.AprevtField1 x 1uint32No
1.17walkStruct.crossedField1 x 1uint8No
1.18walkStruct.addPointField1 x 1int8No
1.19walkStruct.resetField1 x 1uint8No
1.20walkStruct.aTimeUnrollField1 x 1uint32No
1.21walkStruct.prevTimeField1 x 1uint16No
1.22walkStruct.nWrapField1 x 1uint16No
1.23walkStruct.timerOverflowField1 x 1uint8No
1.24walkStruct.counterOverflowField1 x 1uint8No
2accDataInInput1 x 3singleNo
3aRMSinInput1 x 3singleNo
4tDataInInput1 x 1uint32No
5whichThrInput1 x 1singleNo
6LIthLocal1 x 1singleNo
7HIthLocal1 x 1singleNo
234 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/walkAlg3_buildlog1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 23 |
24 | Code Generation Report For 'walkAlg3' 25 | 26 | 27 |
MATLAB Coder Build Log

28 |

29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
Build Parameters
Build directory
Make wrapper
Make command
40 |
41 | 42 | 43 |
Build Log
44 |
45 |     1   Compilation suppressed: generating code only.
46 | 
47 |
48 |
49 | 50 | 51 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/walkAlg3_h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - walkAlg3.h 6 | 7 | 8 | 9 |

10 |
11 |

File: walkAlg3.h

12 |
13 |     1   /*
14 |     2    * walkAlg3.h
15 |     3    *
16 |     4    * Code generation for function 'walkAlg3'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   #ifndef __WALKALG3_H__
21 |     9   #define __WALKALG3_H__
22 |    10   
23 |    11   /* Include files */
24 |    12   #include <math.h>
25 |    13   #include <stddef.h>
26 |    14   #include <stdlib.h>
27 |    15   #include "rt_nonfinite.h"
28 |    16   #include "rtwtypes.h"
29 |    17   #include "walkAlg3_types.h"
30 |    18   
31 |    19   /* Function Declarations */
32 |    20   extern void walkAlg3(struct0_T *walkStruct, const float accDataIn[3], const
33 |    21                        float aRMSin[3], unsigned int tDataIn, float whichThr);
34 |    22   
35 |    23   #endif
36 |    24   
37 |    25   /* End of code generation (walkAlg3.h) */
38 |    26   
39 |
40 |

41 | 42 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/walkAlg3_initialize_c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - walkAlg3_initialize.c 6 | 7 | 8 | 9 |

10 |
11 |

File: walkAlg3_initialize.c

12 |
13 |     1   /*
14 |     2    * walkAlg3_initialize.c
15 |     3    *
16 |     4    * Code generation for function 'walkAlg3_initialize'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   /* Include files */
21 |     9   #include "rt_nonfinite.h"
22 |    10   #include "aTimeUnroll2.h"
23 |    11   #include "stepCounter_struct_init.h"
24 |    12   #include "walkAlg3.h"
25 |    13   #include "walkAlg3_initialize.h"
26 |    14   
27 |    15   /* Function Definitions */
28 |    16   void walkAlg3_initialize(void)
29 |    17   {
30 |    18     rt_InitInfAndNaN(8U);
31 |    19   }
32 |    20   
33 |    21   /* End of code generation (walkAlg3_initialize.c) */
34 |    22   
35 |
36 |

37 | 38 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/walkAlg3_initialize_h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - walkAlg3_initialize.h 6 | 7 | 8 | 9 |

10 |
11 |

File: walkAlg3_initialize.h

12 |
13 |     1   /*
14 |     2    * walkAlg3_initialize.h
15 |     3    *
16 |     4    * Code generation for function 'walkAlg3_initialize'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   #ifndef __WALKALG3_INITIALIZE_H__
21 |     9   #define __WALKALG3_INITIALIZE_H__
22 |    10   
23 |    11   /* Include files */
24 |    12   #include <math.h>
25 |    13   #include <stddef.h>
26 |    14   #include <stdlib.h>
27 |    15   #include "rt_nonfinite.h"
28 |    16   #include "rtwtypes.h"
29 |    17   #include "walkAlg3_types.h"
30 |    18   
31 |    19   /* Function Declarations */
32 |    20   extern void walkAlg3_initialize(void);
33 |    21   
34 |    22   #endif
35 |    23   
36 |    24   /* End of code generation (walkAlg3_initialize.h) */
37 |    25   
38 |
39 |

40 | 41 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/walkAlg3_terminate_c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - walkAlg3_terminate.c 6 | 7 | 8 | 9 |

10 |
11 |

File: walkAlg3_terminate.c

12 |
13 |     1   /*
14 |     2    * walkAlg3_terminate.c
15 |     3    *
16 |     4    * Code generation for function 'walkAlg3_terminate'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   /* Include files */
21 |     9   #include "rt_nonfinite.h"
22 |    10   #include "aTimeUnroll2.h"
23 |    11   #include "stepCounter_struct_init.h"
24 |    12   #include "walkAlg3.h"
25 |    13   #include "walkAlg3_terminate.h"
26 |    14   
27 |    15   /* Function Definitions */
28 |    16   void walkAlg3_terminate(void)
29 |    17   {
30 |    18     /* (no terminate code required) */
31 |    19   }
32 |    20   
33 |    21   /* End of code generation (walkAlg3_terminate.c) */
34 |    22   
35 |
36 |

37 | 38 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/walkAlg3_terminate_h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - walkAlg3_terminate.h 6 | 7 | 8 | 9 |

10 |
11 |

File: walkAlg3_terminate.h

12 |
13 |     1   /*
14 |     2    * walkAlg3_terminate.h
15 |     3    *
16 |     4    * Code generation for function 'walkAlg3_terminate'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   #ifndef __WALKALG3_TERMINATE_H__
21 |     9   #define __WALKALG3_TERMINATE_H__
22 |    10   
23 |    11   /* Include files */
24 |    12   #include <math.h>
25 |    13   #include <stddef.h>
26 |    14   #include <stdlib.h>
27 |    15   #include "rt_nonfinite.h"
28 |    16   #include "rtwtypes.h"
29 |    17   #include "walkAlg3_types.h"
30 |    18   
31 |    19   /* Function Declarations */
32 |    20   extern void walkAlg3_terminate(void);
33 |    21   
34 |    22   #endif
35 |    23   
36 |    24   /* End of code generation (walkAlg3_terminate.h) */
37 |    25   
38 |
39 |

40 | 41 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/html/walkAlg3_types_h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RTW Report - walkAlg3_types.h 6 | 7 | 8 | 9 |

10 |
11 |

File: walkAlg3_types.h

12 |
13 |     1   /*
14 |     2    * walkAlg3_types.h
15 |     3    *
16 |     4    * Code generation for function 'walkAlg3'
17 |     5    *
18 |     6    */
19 |     7   
20 |     8   #ifndef __WALKALG3_TYPES_H__
21 |     9   #define __WALKALG3_TYPES_H__
22 |    10   
23 |    11   /* Include files */
24 |    12   #include "rtwtypes.h"
25 |    13   
26 |    14   /* Type Definitions */
27 |    15   #ifndef typedef_struct0_T
28 |    16   #define typedef_struct0_T
29 |    17   typedef struct
30 |    18   {
31 |    19       float HIthrA;
32 |    20       float LIthrA;
33 |    21       float HIthrW;
34 |    22       float LIthrW;
35 |    23       float timeThr;
36 |    24       unsigned int HLI;
37 |    25       unsigned int HIt;
38 |    26       unsigned int LIt;
39 |    27       unsigned int HIcnt;
40 |    28       unsigned int LIcnt;
41 |    29       float Acur[3];
42 |    30       float AcurRMS[3];
43 |    31       float Aprev[3];
44 |    32       float AprevRMS[3];
45 |    33       unsigned int Acurt;
46 |    34       unsigned int Aprevt;
47 |    35       unsigned char crossed;
48 |    36       signed char addPoint;
49 |    37       unsigned char reset;
50 |    38       unsigned int aTimeUnroll;
51 |    39       unsigned short prevTime;
52 |    40       unsigned short nWrap;
53 |    41       unsigned char timerOverflow;
54 |    42       unsigned char counterOverflow;
55 |    43   } struct0_T;
56 |    44   #endif /*typedef_struct0_T*/
57 |    45   
58 |    46   #endif
59 |    47   /* End of code generation (walkAlg3_types.h) */
60 |    48   
61 |
62 |

63 | 64 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/interface/_coder_walkAlg3_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * _coder_walkAlg3_api.h 3 | * 4 | * Code generation for function 'walkAlg3' 5 | * 6 | */ 7 | 8 | #ifndef ___CODER_WALKALG3_API_H__ 9 | #define ___CODER_WALKALG3_API_H__ 10 | /* Include files */ 11 | #include 12 | #include 13 | #include 14 | 15 | #include "tmwtypes.h" 16 | #include "mex.h" 17 | #include "emlrt.h" 18 | 19 | /* Type Definitions */ 20 | #ifndef typedef_struct0_T 21 | #define typedef_struct0_T 22 | typedef struct 23 | { 24 | float HIthrA; 25 | float LIthrA; 26 | float HIthrW; 27 | float LIthrW; 28 | float timeThr; 29 | unsigned int HLI; 30 | unsigned int HIt; 31 | unsigned int LIt; 32 | unsigned int HIcnt; 33 | unsigned int LIcnt; 34 | float Acur[3]; 35 | float AcurRMS[3]; 36 | float Aprev[3]; 37 | float AprevRMS[3]; 38 | unsigned int Acurt; 39 | unsigned int Aprevt; 40 | unsigned char crossed; 41 | signed char addPoint; 42 | unsigned char reset; 43 | unsigned int aTimeUnroll; 44 | unsigned short prevTime; 45 | unsigned short nWrap; 46 | unsigned char timerOverflow; 47 | unsigned char counterOverflow; 48 | } struct0_T; 49 | #endif /*typedef_struct0_T*/ 50 | 51 | /* Function Declarations */ 52 | extern void walkAlg3_initialize(emlrtContext *aContext); 53 | extern void walkAlg3_terminate(void); 54 | extern void walkAlg3_atexit(void); 55 | extern void walkAlg3_api(const mxArray *prhs[5], const mxArray *plhs[1]); 56 | extern void stepCounter_struct_init_api(const mxArray *plhs[1]); 57 | extern struct0_T stepCounter_struct_init(void); 58 | extern void aTimeUnroll2_api(const mxArray * const prhs[3], const mxArray *plhs[1]); 59 | extern void walkAlg3_xil_terminate(void); 60 | extern void walkAlg3(struct0_T *walkStruct, float accDataIn[3], float aRMSin[3], unsigned int tDataIn, float whichThr); 61 | extern void aTimeUnroll2(unsigned short atime, float resolution, struct0_T *walkStruct); 62 | 63 | #endif 64 | /* End of code generation (_coder_walkAlg3_api.h) */ 65 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/interface/_coder_walkAlg3_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * _coder_walkAlg3_info.h 3 | * 4 | * Code generation for function 'walkAlg3' 5 | * 6 | */ 7 | 8 | #ifndef ___CODER_WALKALG3_INFO_H__ 9 | #define ___CODER_WALKALG3_INFO_H__ 10 | /* Include files */ 11 | #include "tmwtypes.h" 12 | #include "mex.h" 13 | #include "emlrt.h" 14 | 15 | 16 | /* Function Declarations */ 17 | extern const mxArray *emlrtMexFcnResolvedFunctionsInfo(void); 18 | 19 | #endif 20 | /* End of code generation (_coder_walkAlg3_info.h) */ 21 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/interface/_coder_walkAlg3_mex.c: -------------------------------------------------------------------------------- 1 | /* 2 | * _coder_walkAlg3_mex.c 3 | * 4 | * Code generation for function 'walkAlg3' 5 | * 6 | */ 7 | 8 | /* Include files */ 9 | #include "mex.h" 10 | #include "_coder_walkAlg3_api.h" 11 | 12 | /* Function Declarations */ 13 | static void aTimeUnroll2_mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]); 14 | static void stepCounter_struct_init_mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]); 15 | static void walkAlg3_mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]); 16 | 17 | /* Variable Definitions */ 18 | emlrtContext emlrtContextGlobal = { true, false, EMLRT_VERSION_INFO, NULL, "walkAlg3", NULL, false, {2045744189U,2170104910U,2743257031U,4284093946U}, NULL }; 19 | void *emlrtRootTLSGlobal = NULL; 20 | emlrtEntryPoint emlrtEntryPoints[3] = { 21 | { "aTimeUnroll2", aTimeUnroll2_mexFunction }, 22 | { "stepCounter_struct_init", stepCounter_struct_init_mexFunction }, 23 | { "walkAlg3", walkAlg3_mexFunction }, 24 | }; 25 | 26 | /* Function Definitions */ 27 | static void walkAlg3_mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) 28 | { 29 | const mxArray *outputs[1]; 30 | const mxArray *inputs[5]; 31 | int n = 0; 32 | int nOutputs = (nlhs < 1 ? 1 : nlhs); 33 | int nInputs = nrhs; 34 | emlrtStack st = { NULL, NULL, NULL }; 35 | /* Module initialization. */ 36 | walkAlg3_initialize(&emlrtContextGlobal); 37 | st.tls = emlrtRootTLSGlobal; 38 | /* Check for proper number of arguments. */ 39 | if (nrhs != 5) { 40 | emlrtErrMsgIdAndTxt(&st, "EMLRT:runTime:WrongNumberOfInputs", 5, mxINT32_CLASS, 5, mxCHAR_CLASS, 8, "walkAlg3"); 41 | } else if (nlhs > 1) { 42 | emlrtErrMsgIdAndTxt(&st, "EMLRT:runTime:TooManyOutputArguments", 3, mxCHAR_CLASS, 8, "walkAlg3"); 43 | } 44 | /* Temporary copy for mex inputs. */ 45 | for (n = 0; n < nInputs; ++n) { 46 | inputs[n] = prhs[n]; 47 | } 48 | /* Call the function. */ 49 | walkAlg3_api(inputs, outputs); 50 | /* Copy over outputs to the caller. */ 51 | for (n = 0; n < nOutputs; ++n) { 52 | plhs[n] = emlrtReturnArrayR2009a(outputs[n]); 53 | } 54 | /* Module finalization. */ 55 | walkAlg3_terminate(); 56 | } 57 | static void stepCounter_struct_init_mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) 58 | { 59 | const mxArray *outputs[1]; 60 | int n = 0; 61 | int nOutputs = (nlhs < 1 ? 1 : nlhs); 62 | emlrtStack st = { NULL, NULL, NULL }; 63 | /* Module initialization. */ 64 | walkAlg3_initialize(&emlrtContextGlobal); 65 | st.tls = emlrtRootTLSGlobal; 66 | /* Check for proper number of arguments. */ 67 | if (nrhs != 0) { 68 | emlrtErrMsgIdAndTxt(&st, "EMLRT:runTime:WrongNumberOfInputs", 5, mxINT32_CLASS, 0, mxCHAR_CLASS, 23, "stepCounter_struct_init"); 69 | } else if (nlhs > 1) { 70 | emlrtErrMsgIdAndTxt(&st, "EMLRT:runTime:TooManyOutputArguments", 3, mxCHAR_CLASS, 23, "stepCounter_struct_init"); 71 | } 72 | /* Call the function. */ 73 | stepCounter_struct_init_api(outputs); 74 | /* Copy over outputs to the caller. */ 75 | for (n = 0; n < nOutputs; ++n) { 76 | plhs[n] = emlrtReturnArrayR2009a(outputs[n]); 77 | } 78 | /* Module finalization. */ 79 | walkAlg3_terminate(); 80 | } 81 | static void aTimeUnroll2_mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) 82 | { 83 | const mxArray *outputs[1]; 84 | const mxArray *inputs[3]; 85 | int n = 0; 86 | int nOutputs = (nlhs < 1 ? 1 : nlhs); 87 | int nInputs = nrhs; 88 | emlrtStack st = { NULL, NULL, NULL }; 89 | /* Module initialization. */ 90 | walkAlg3_initialize(&emlrtContextGlobal); 91 | st.tls = emlrtRootTLSGlobal; 92 | /* Check for proper number of arguments. */ 93 | if (nrhs != 3) { 94 | emlrtErrMsgIdAndTxt(&st, "EMLRT:runTime:WrongNumberOfInputs", 5, mxINT32_CLASS, 3, mxCHAR_CLASS, 12, "aTimeUnroll2"); 95 | } else if (nlhs > 1) { 96 | emlrtErrMsgIdAndTxt(&st, "EMLRT:runTime:TooManyOutputArguments", 3, mxCHAR_CLASS, 12, "aTimeUnroll2"); 97 | } 98 | /* Temporary copy for mex inputs. */ 99 | for (n = 0; n < nInputs; ++n) { 100 | inputs[n] = prhs[n]; 101 | } 102 | /* Call the function. */ 103 | aTimeUnroll2_api(inputs, outputs); 104 | /* Copy over outputs to the caller. */ 105 | for (n = 0; n < nOutputs; ++n) { 106 | plhs[n] = emlrtReturnArrayR2009a(outputs[n]); 107 | } 108 | /* Module finalization. */ 109 | walkAlg3_terminate(); 110 | } 111 | 112 | void walkAlg3_atexit_wrapper(void) 113 | { 114 | walkAlg3_atexit(); 115 | } 116 | 117 | void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) 118 | { 119 | emlrtMexFunction method; 120 | method = emlrtGetMethod(nrhs, prhs, emlrtEntryPoints, 3); 121 | /* Initialize the memory manager. */ 122 | mexAtExit(walkAlg3_atexit_wrapper); 123 | /* Dispatch the entry-point. */ 124 | method(nlhs, plhs, nrhs-1, prhs+1); 125 | } 126 | /* End of code generation (_coder_walkAlg3_mex.c) */ 127 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/isnan.c: -------------------------------------------------------------------------------- 1 | /* 2 | * isnan.c 3 | * 4 | * Code generation for function 'isnan' 5 | * 6 | */ 7 | 8 | /* Include files */ 9 | #include "rt_nonfinite.h" 10 | #include "aTimeUnroll2.h" 11 | #include "stepCounter_struct_init.h" 12 | #include "walkAlg3.h" 13 | #include "isnan.h" 14 | 15 | /* Function Definitions */ 16 | boolean_T b_isnan(float x) 17 | { 18 | return rtIsNaNF(x); 19 | } 20 | 21 | /* End of code generation (isnan.c) */ 22 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/isnan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * isnan.h 3 | * 4 | * Code generation for function 'isnan' 5 | * 6 | */ 7 | 8 | #ifndef __ISNAN_H__ 9 | #define __ISNAN_H__ 10 | 11 | /* Include files */ 12 | #include 13 | #include 14 | #include 15 | #include "rt_nonfinite.h" 16 | #include "rtwtypes.h" 17 | #include "walkAlg3_types.h" 18 | 19 | /* Function Declarations */ 20 | extern boolean_T b_isnan(float x); 21 | 22 | #endif 23 | 24 | /* End of code generation (isnan.h) */ 25 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/rtGetInf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rtGetInf.c 3 | * 4 | * Code generation for function 'walkAlg3' 5 | * 6 | */ 7 | 8 | /* 9 | * Abstract: 10 | * MATLAB for code generation function to initialize non-finite, Inf and MinusInf 11 | */ 12 | #include "rtGetInf.h" 13 | #define NumBitsPerChar 8U 14 | 15 | /* Function: rtGetInf ================================================== 16 | * Abstract: 17 | * Initialize rtInf needed by the generated code. 18 | * Inf is initialized as non-signaling. Assumes IEEE. 19 | */ 20 | real_T rtGetInf(void) 21 | { 22 | size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar); 23 | real_T inf = 0.0; 24 | if (bitsPerReal == 32U) { 25 | inf = rtGetInfF(); 26 | } else { 27 | uint16_T one = 1U; 28 | enum { 29 | LittleEndian, 30 | BigEndian 31 | } machByteOrder = (*((uint8_T *) &one) == 1U) ? LittleEndian : BigEndian; 32 | switch (machByteOrder) { 33 | case LittleEndian: 34 | { 35 | union { 36 | LittleEndianIEEEDouble bitVal; 37 | real_T fltVal; 38 | } tmpVal; 39 | 40 | tmpVal.bitVal.words.wordH = 0x7FF00000U; 41 | tmpVal.bitVal.words.wordL = 0x00000000U; 42 | inf = tmpVal.fltVal; 43 | break; 44 | } 45 | 46 | case BigEndian: 47 | { 48 | union { 49 | BigEndianIEEEDouble bitVal; 50 | real_T fltVal; 51 | } tmpVal; 52 | 53 | tmpVal.bitVal.words.wordH = 0x7FF00000U; 54 | tmpVal.bitVal.words.wordL = 0x00000000U; 55 | inf = tmpVal.fltVal; 56 | break; 57 | } 58 | } 59 | } 60 | 61 | return inf; 62 | } 63 | 64 | /* Function: rtGetInfF ================================================== 65 | * Abstract: 66 | * Initialize rtInfF needed by the generated code. 67 | * Inf is initialized as non-signaling. Assumes IEEE. 68 | */ 69 | real32_T rtGetInfF(void) 70 | { 71 | IEEESingle infF; 72 | infF.wordL.wordLuint = 0x7F800000U; 73 | return infF.wordL.wordLreal; 74 | } 75 | 76 | /* Function: rtGetMinusInf ================================================== 77 | * Abstract: 78 | * Initialize rtMinusInf needed by the generated code. 79 | * Inf is initialized as non-signaling. Assumes IEEE. 80 | */ 81 | real_T rtGetMinusInf(void) 82 | { 83 | size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar); 84 | real_T minf = 0.0; 85 | if (bitsPerReal == 32U) { 86 | minf = rtGetMinusInfF(); 87 | } else { 88 | uint16_T one = 1U; 89 | enum { 90 | LittleEndian, 91 | BigEndian 92 | } machByteOrder = (*((uint8_T *) &one) == 1U) ? LittleEndian : BigEndian; 93 | switch (machByteOrder) { 94 | case LittleEndian: 95 | { 96 | union { 97 | LittleEndianIEEEDouble bitVal; 98 | real_T fltVal; 99 | } tmpVal; 100 | 101 | tmpVal.bitVal.words.wordH = 0xFFF00000U; 102 | tmpVal.bitVal.words.wordL = 0x00000000U; 103 | minf = tmpVal.fltVal; 104 | break; 105 | } 106 | 107 | case BigEndian: 108 | { 109 | union { 110 | BigEndianIEEEDouble bitVal; 111 | real_T fltVal; 112 | } tmpVal; 113 | 114 | tmpVal.bitVal.words.wordH = 0xFFF00000U; 115 | tmpVal.bitVal.words.wordL = 0x00000000U; 116 | minf = tmpVal.fltVal; 117 | break; 118 | } 119 | } 120 | } 121 | 122 | return minf; 123 | } 124 | 125 | /* Function: rtGetMinusInfF ================================================== 126 | * Abstract: 127 | * Initialize rtMinusInfF needed by the generated code. 128 | * Inf is initialized as non-signaling. Assumes IEEE. 129 | */ 130 | real32_T rtGetMinusInfF(void) 131 | { 132 | IEEESingle minfF; 133 | minfF.wordL.wordLuint = 0xFF800000U; 134 | return minfF.wordL.wordLreal; 135 | } 136 | 137 | /* End of code generation (rtGetInf.c) */ 138 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/rtGetInf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtGetInf.h 3 | * 4 | * Code generation for function 'walkAlg3' 5 | * 6 | */ 7 | 8 | #ifndef __RTGETINF_H__ 9 | #define __RTGETINF_H__ 10 | 11 | #include 12 | #include "rtwtypes.h" 13 | #include "rt_nonfinite.h" 14 | 15 | extern real_T rtGetInf(void); 16 | extern real32_T rtGetInfF(void); 17 | extern real_T rtGetMinusInf(void); 18 | extern real32_T rtGetMinusInfF(void); 19 | 20 | #endif 21 | /* End of code generation (rtGetInf.h) */ 22 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/rtGetNaN.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rtGetNaN.c 3 | * 4 | * Code generation for function 'walkAlg3' 5 | * 6 | */ 7 | 8 | /* 9 | * Abstract: 10 | * MATLAB for code generation function to initialize non-finite, NaN 11 | */ 12 | #include "rtGetNaN.h" 13 | #define NumBitsPerChar 8U 14 | 15 | /* Function: rtGetNaN ================================================== 16 | * Abstract: 17 | * Initialize rtNaN needed by the generated code. 18 | * NaN is initialized as non-signaling. Assumes IEEE. 19 | */ 20 | real_T rtGetNaN(void) 21 | { 22 | size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar); 23 | real_T nan = 0.0; 24 | if (bitsPerReal == 32U) { 25 | nan = rtGetNaNF(); 26 | } else { 27 | uint16_T one = 1U; 28 | enum { 29 | LittleEndian, 30 | BigEndian 31 | } machByteOrder = (*((uint8_T *) &one) == 1U) ? LittleEndian : BigEndian; 32 | switch (machByteOrder) { 33 | case LittleEndian: 34 | { 35 | union { 36 | LittleEndianIEEEDouble bitVal; 37 | real_T fltVal; 38 | } tmpVal; 39 | 40 | tmpVal.bitVal.words.wordH = 0xFFF80000U; 41 | tmpVal.bitVal.words.wordL = 0x00000000U; 42 | nan = tmpVal.fltVal; 43 | break; 44 | } 45 | 46 | case BigEndian: 47 | { 48 | union { 49 | BigEndianIEEEDouble bitVal; 50 | real_T fltVal; 51 | } tmpVal; 52 | 53 | tmpVal.bitVal.words.wordH = 0x7FFFFFFFU; 54 | tmpVal.bitVal.words.wordL = 0xFFFFFFFFU; 55 | nan = tmpVal.fltVal; 56 | break; 57 | } 58 | } 59 | } 60 | 61 | return nan; 62 | } 63 | 64 | /* Function: rtGetNaNF ================================================== 65 | * Abstract: 66 | * Initialize rtNaNF needed by the generated code. 67 | * NaN is initialized as non-signaling. Assumes IEEE. 68 | */ 69 | real32_T rtGetNaNF(void) 70 | { 71 | IEEESingle nanF = { { 0 } }; 72 | uint16_T one = 1U; 73 | enum { 74 | LittleEndian, 75 | BigEndian 76 | } machByteOrder = (*((uint8_T *) &one) == 1U) ? LittleEndian : BigEndian; 77 | switch (machByteOrder) { 78 | case LittleEndian: 79 | { 80 | nanF.wordL.wordLuint = 0xFFC00000U; 81 | break; 82 | } 83 | 84 | case BigEndian: 85 | { 86 | nanF.wordL.wordLuint = 0x7FFFFFFFU; 87 | break; 88 | } 89 | } 90 | 91 | return nanF.wordL.wordLreal; 92 | } 93 | 94 | /* End of code generation (rtGetNaN.c) */ 95 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/rtGetNaN.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtGetNaN.h 3 | * 4 | * Code generation for function 'walkAlg3' 5 | * 6 | */ 7 | 8 | #ifndef __RTGETNAN_H__ 9 | #define __RTGETNAN_H__ 10 | 11 | #include 12 | #include "rtwtypes.h" 13 | #include "rt_nonfinite.h" 14 | 15 | extern real_T rtGetNaN(void); 16 | extern real32_T rtGetNaNF(void); 17 | 18 | #endif 19 | /* End of code generation (rtGetNaN.h) */ 20 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/rt_nonfinite.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rt_nonfinite.c 3 | * 4 | * Code generation for function 'walkAlg3' 5 | * 6 | */ 7 | 8 | /* 9 | * Abstract: 10 | * MATLAB for code generation function to initialize non-finites, 11 | * (Inf, NaN and -Inf). 12 | */ 13 | #include "rt_nonfinite.h" 14 | #include "rtGetNaN.h" 15 | #include "rtGetInf.h" 16 | 17 | real_T rtInf; 18 | real_T rtMinusInf; 19 | real_T rtNaN; 20 | real32_T rtInfF; 21 | real32_T rtMinusInfF; 22 | real32_T rtNaNF; 23 | 24 | /* Function: rt_InitInfAndNaN ================================================== 25 | * Abstract: 26 | * Initialize the rtInf, rtMinusInf, and rtNaN needed by the 27 | * generated code. NaN is initialized as non-signaling. Assumes IEEE. 28 | */ 29 | void rt_InitInfAndNaN(size_t realSize) 30 | { 31 | (void) (realSize); 32 | rtNaN = rtGetNaN(); 33 | rtNaNF = rtGetNaNF(); 34 | rtInf = rtGetInf(); 35 | rtInfF = rtGetInfF(); 36 | rtMinusInf = rtGetMinusInf(); 37 | rtMinusInfF = rtGetMinusInfF(); 38 | } 39 | 40 | /* Function: rtIsInf ================================================== 41 | * Abstract: 42 | * Test if value is infinite 43 | */ 44 | boolean_T rtIsInf(real_T value) 45 | { 46 | return ((value==rtInf || value==rtMinusInf) ? 1U : 0U); 47 | } 48 | 49 | /* Function: rtIsInfF ================================================= 50 | * Abstract: 51 | * Test if single-precision value is infinite 52 | */ 53 | boolean_T rtIsInfF(real32_T value) 54 | { 55 | return(((value)==rtInfF || (value)==rtMinusInfF) ? 1U : 0U); 56 | } 57 | 58 | /* Function: rtIsNaN ================================================== 59 | * Abstract: 60 | * Test if value is not a number 61 | */ 62 | boolean_T rtIsNaN(real_T value) 63 | { 64 | #if defined(_MSC_VER) && (_MSC_VER <= 1200) 65 | return _isnan(value)? TRUE:FALSE; 66 | #else 67 | return (value!=value)? 1U:0U; 68 | #endif 69 | } 70 | 71 | /* Function: rtIsNaNF ================================================= 72 | * Abstract: 73 | * Test if single-precision value is not a number 74 | */ 75 | boolean_T rtIsNaNF(real32_T value) 76 | { 77 | #if defined(_MSC_VER) && (_MSC_VER <= 1200) 78 | return _isnan((real_T)value)? true:false; 79 | #else 80 | return (value!=value)? 1U:0U; 81 | #endif 82 | } 83 | 84 | 85 | /* End of code generation (rt_nonfinite.c) */ 86 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/rt_nonfinite.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rt_nonfinite.h 3 | * 4 | * Code generation for function 'walkAlg3' 5 | * 6 | */ 7 | 8 | #ifndef __RT_NONFINITE_H__ 9 | #define __RT_NONFINITE_H__ 10 | 11 | #if defined(_MSC_VER) && (_MSC_VER <= 1200) 12 | #include 13 | #endif 14 | #include 15 | #include "rtwtypes.h" 16 | 17 | extern real_T rtInf; 18 | extern real_T rtMinusInf; 19 | extern real_T rtNaN; 20 | extern real32_T rtInfF; 21 | extern real32_T rtMinusInfF; 22 | extern real32_T rtNaNF; 23 | extern void rt_InitInfAndNaN(size_t realSize); 24 | extern boolean_T rtIsInf(real_T value); 25 | extern boolean_T rtIsInfF(real32_T value); 26 | extern boolean_T rtIsNaN(real_T value); 27 | extern boolean_T rtIsNaNF(real32_T value); 28 | 29 | typedef struct { 30 | struct { 31 | uint32_T wordH; 32 | uint32_T wordL; 33 | } words; 34 | } BigEndianIEEEDouble; 35 | 36 | typedef struct { 37 | struct { 38 | uint32_T wordL; 39 | uint32_T wordH; 40 | } words; 41 | } LittleEndianIEEEDouble; 42 | 43 | typedef struct { 44 | union { 45 | real32_T wordLreal; 46 | uint32_T wordLuint; 47 | } wordL; 48 | } IEEESingle; 49 | 50 | #endif 51 | /* End of code generation (rt_nonfinite.h) */ 52 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/rtw_proj.tmw: -------------------------------------------------------------------------------- 1 | Code generation project for walkAlg3 using toolchain "LCC-win64 v2.4.1 | gmake (64-bit Windows)". MATLAB root = C:\Program Files\MATLAB\R2014a. 2 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/rtwtypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtwtypes.h 3 | * 4 | * Code generation for function 'walkAlg3' 5 | * 6 | */ 7 | 8 | #ifndef __RTWTYPES_H__ 9 | #define __RTWTYPES_H__ 10 | #ifndef __TMWTYPES__ 11 | #define __TMWTYPES__ 12 | 13 | /*=======================================================================* 14 | * Target hardware information 15 | * Device type: ARM Compatible->ARM Cortex 16 | * Number of bits: char: 8 short: 16 int: 32 17 | * long: 32 18 | * native word size: 32 19 | * Byte ordering: LittleEndian 20 | * Signed integer division rounds to: Undefined 21 | * Shift right on a signed integer as arithmetic shift: on 22 | *=======================================================================*/ 23 | 24 | /*=======================================================================* 25 | * Fixed width word size data types: * 26 | * int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers * 27 | * uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers * 28 | * real32_T, real64_T - 32 and 64 bit floating point numbers * 29 | *=======================================================================*/ 30 | 31 | typedef signed char int8_T; 32 | typedef unsigned char uint8_T; 33 | typedef short int16_T; 34 | typedef unsigned short uint16_T; 35 | typedef int int32_T; 36 | typedef unsigned int uint32_T; 37 | typedef float real32_T; 38 | typedef double real64_T; 39 | 40 | /*===========================================================================* 41 | * Generic type definitions: real_T, time_T, boolean_T, int_T, uint_T, * 42 | * ulong_T, char_T and byte_T. * 43 | *===========================================================================*/ 44 | 45 | typedef double real_T; 46 | typedef double time_T; 47 | typedef unsigned char boolean_T; 48 | typedef int int_T; 49 | typedef unsigned int uint_T; 50 | typedef unsigned long ulong_T; 51 | typedef char char_T; 52 | typedef char_T byte_T; 53 | 54 | /*===========================================================================* 55 | * Complex number type definitions * 56 | *===========================================================================*/ 57 | #define CREAL_T 58 | typedef struct { 59 | real32_T re; 60 | real32_T im; 61 | } creal32_T; 62 | 63 | typedef struct { 64 | real64_T re; 65 | real64_T im; 66 | } creal64_T; 67 | 68 | typedef struct { 69 | real_T re; 70 | real_T im; 71 | } creal_T; 72 | 73 | typedef struct { 74 | int8_T re; 75 | int8_T im; 76 | } cint8_T; 77 | 78 | typedef struct { 79 | uint8_T re; 80 | uint8_T im; 81 | } cuint8_T; 82 | 83 | typedef struct { 84 | int16_T re; 85 | int16_T im; 86 | } cint16_T; 87 | 88 | typedef struct { 89 | uint16_T re; 90 | uint16_T im; 91 | } cuint16_T; 92 | 93 | typedef struct { 94 | int32_T re; 95 | int32_T im; 96 | } cint32_T; 97 | 98 | typedef struct { 99 | uint32_T re; 100 | uint32_T im; 101 | } cuint32_T; 102 | 103 | 104 | /*=======================================================================* 105 | * Min and Max: * 106 | * int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers * 107 | * uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers * 108 | *=======================================================================*/ 109 | 110 | #define MAX_int8_T ((int8_T)(127)) 111 | #define MIN_int8_T ((int8_T)(-128)) 112 | #define MAX_uint8_T ((uint8_T)(255)) 113 | #define MIN_uint8_T ((uint8_T)(0)) 114 | #define MAX_int16_T ((int16_T)(32767)) 115 | #define MIN_int16_T ((int16_T)(-32768)) 116 | #define MAX_uint16_T ((uint16_T)(65535)) 117 | #define MIN_uint16_T ((uint16_T)(0)) 118 | #define MAX_int32_T ((int32_T)(2147483647)) 119 | #define MIN_int32_T ((int32_T)(-2147483647-1)) 120 | #define MAX_uint32_T ((uint32_T)(0xFFFFFFFFU)) 121 | #define MIN_uint32_T ((uint32_T)(0)) 122 | 123 | /* Logical type definitions */ 124 | #if !defined(__cplusplus) && !defined(__true_false_are_keywords) 125 | # ifndef false 126 | # define false (0U) 127 | # endif 128 | # ifndef true 129 | # define true (1U) 130 | # endif 131 | #endif 132 | 133 | /* 134 | * Maximum length of a MATLAB identifier (function/variable) 135 | * including the null-termination character. Referenced by 136 | * rt_logging.c and rt_matrx.c. 137 | */ 138 | #define TMW_NAME_LENGTH_MAX 64 139 | 140 | #endif 141 | #endif 142 | /* End of code generation (rtwtypes.h) */ 143 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/stepCounter_struct_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * stepCounter_struct_init.c 3 | * 4 | * Code generation for function 'stepCounter_struct_init' 5 | * 6 | */ 7 | 8 | /* Include files */ 9 | #include "rt_nonfinite.h" 10 | #include "aTimeUnroll2.h" 11 | #include "stepCounter_struct_init.h" 12 | #include "walkAlg3.h" 13 | 14 | /* Function Definitions */ 15 | struct0_T stepCounter_struct_init(void) 16 | { 17 | struct0_T walkStruct; 18 | int i0; 19 | 20 | /* %% init of stepCounter structure */ 21 | /* */ 22 | /* */ 23 | /* walkStruct */ 24 | walkStruct.HIthrA = 2.0F; 25 | walkStruct.LIthrA = 0.7F; 26 | walkStruct.HIthrW = 1.7F; 27 | walkStruct.LIthrW = 1.05F; 28 | walkStruct.timeThr = 250.0F; 29 | 30 | /* made a single for real time updates */ 31 | walkStruct.HLI = 0U; 32 | walkStruct.HIt = 0U; 33 | walkStruct.LIt = 0U; 34 | walkStruct.HIcnt = 0U; 35 | walkStruct.LIcnt = 0U; 36 | for (i0 = 0; i0 < 3; i0++) { 37 | walkStruct.Acur[i0] = 0.0F; 38 | 39 | /* accel x y z time */ 40 | walkStruct.AcurRMS[i0] = 0.0F; 41 | walkStruct.Aprev[i0] = 0.0F; 42 | walkStruct.AprevRMS[i0] = 0.0F; 43 | } 44 | 45 | walkStruct.Acurt = 0U; 46 | walkStruct.Aprevt = 0U; 47 | walkStruct.crossed = 0; 48 | walkStruct.addPoint = 0; 49 | 50 | /* 1 to add point, 0 for nothing, -1 to lose point */ 51 | walkStruct.reset = 0; 52 | 53 | /* end of interval reset flag */ 54 | walkStruct.aTimeUnroll = 0U; 55 | walkStruct.prevTime = 0; 56 | walkStruct.nWrap = 0; 57 | walkStruct.timerOverflow = 0; 58 | walkStruct.counterOverflow = 0; 59 | return walkStruct; 60 | } 61 | 62 | /* End of code generation (stepCounter_struct_init.c) */ 63 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/stepCounter_struct_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * stepCounter_struct_init.h 3 | * 4 | * Code generation for function 'stepCounter_struct_init' 5 | * 6 | */ 7 | 8 | #ifndef __STEPCOUNTER_STRUCT_INIT_H__ 9 | #define __STEPCOUNTER_STRUCT_INIT_H__ 10 | 11 | /* Include files */ 12 | #include 13 | #include 14 | #include 15 | #include "rt_nonfinite.h" 16 | #include "rtwtypes.h" 17 | #include "walkAlg3_types.h" 18 | 19 | /* Function Declarations */ 20 | extern struct0_T stepCounter_struct_init(void); 21 | 22 | #endif 23 | 24 | /* End of code generation (stepCounter_struct_init.h) */ 25 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/walkAlg3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * walkAlg3.c 3 | * 4 | * Code generation for function 'walkAlg3' 5 | * 6 | */ 7 | 8 | /* Include files */ 9 | #include "rt_nonfinite.h" 10 | #include "aTimeUnroll2.h" 11 | #include "stepCounter_struct_init.h" 12 | #include "walkAlg3.h" 13 | #include "isnan.h" 14 | #include "abs.h" 15 | 16 | /* Function Declarations */ 17 | static float eml_extremum(const float x[3]); 18 | 19 | /* Function Definitions */ 20 | static float eml_extremum(const float x[3]) 21 | { 22 | float extremum; 23 | int ixstart; 24 | int ix; 25 | boolean_T exitg1; 26 | ixstart = 1; 27 | extremum = x[0]; 28 | if (b_isnan(x[0])) { 29 | ix = 2; 30 | exitg1 = false; 31 | while ((!exitg1) && (ix < 4)) { 32 | ixstart = ix; 33 | if (!b_isnan(x[ix - 1])) { 34 | extremum = x[ix - 1]; 35 | exitg1 = true; 36 | } else { 37 | ix++; 38 | } 39 | } 40 | } 41 | 42 | if (ixstart < 3) { 43 | while (ixstart + 1 < 4) { 44 | if (x[ixstart] > extremum) { 45 | extremum = x[ixstart]; 46 | } 47 | 48 | ixstart++; 49 | } 50 | } 51 | 52 | return extremum; 53 | } 54 | 55 | void walkAlg3(struct0_T *walkStruct, const float accDataIn[3], const float 56 | aRMSin[3], unsigned int tDataIn, float whichThr) 57 | { 58 | float LIth; 59 | float HIth; 60 | float b_accDataIn[3]; 61 | int i1; 62 | float fv0[3]; 63 | unsigned int q0; 64 | unsigned int qY; 65 | float b_walkStruct[3]; 66 | float fv1[3]; 67 | float fv2[3]; 68 | float fv3[3]; 69 | float fv4[3]; 70 | float fv5[3]; 71 | float fv6[3]; 72 | float fv7[3]; 73 | 74 | /* %% walking algorithm. */ 75 | /* Performs step counting primarily targeted for the wrist mounting, uses */ 76 | /* maximum observed value for each. Could also be used for accel radii. */ 77 | /* Inputs: */ 78 | /* walkStruct = holds all persistent varibles as well as thresholds, see */ 79 | /* stepCounter_struct_init for definitions. */ 80 | /* accDataIn = accel data inputs, x, y, z; can be lowpass filtered */ 81 | /* if desired. */ 82 | /* aRMSin = moving average or rms data, subtracted from data. Can input */ 83 | /* zeros, or input RMS data as desired, will require different thresholds. */ 84 | /* tDataIn = time data, in milliseconds, relative timing between points is */ 85 | /* all that matters, but must be unwrapped before input to this function. */ 86 | /* whichThr = allows user to store two sets of thresholds and switch with */ 87 | /* this value. Example, could use different thresholds for 0 aRMSin vs moving */ 88 | /* standard deviation for aRMSin and switch depending on if data available. */ 89 | /* */ 90 | /* */ 91 | /* choose a thershold setting */ 92 | /* two threshold settings per to denote high acceleration or low */ 93 | /* acceleration amplitudes */ 94 | if (whichThr == 2.0F) { 95 | LIth = walkStruct->LIthrA; 96 | HIth = walkStruct->HIthrA; 97 | } else { 98 | LIth = walkStruct->LIthrW; 99 | HIth = walkStruct->HIthrW; 100 | } 101 | 102 | walkStruct->addPoint = 0; 103 | for (i1 = 0; i1 < 3; i1++) { 104 | b_accDataIn[i1] = accDataIn[i1] - aRMSin[i1]; 105 | } 106 | 107 | b_abs(b_accDataIn, fv0); 108 | if (eml_extremum(fv0) > LIth) { 109 | /* check if data has crossed minimum threshold */ 110 | if (!(walkStruct->crossed != 0)) { 111 | /* when it crosses a threshold incremement steps */ 112 | q0 = walkStruct->HLI; 113 | qY = q0 + 1U; 114 | if (qY < q0) { 115 | qY = MAX_uint32_T; 116 | } 117 | 118 | walkStruct->HLI = qY; 119 | 120 | /* step count */ 121 | walkStruct->crossed = 1; 122 | } 123 | 124 | /* if newest point is highest current point for this crossing, save */ 125 | /* it as the current peak data point */ 126 | for (i1 = 0; i1 < 3; i1++) { 127 | b_accDataIn[i1] = accDataIn[i1] - aRMSin[i1]; 128 | } 129 | 130 | for (i1 = 0; i1 < 3; i1++) { 131 | b_walkStruct[i1] = walkStruct->Acur[i1] - walkStruct->AcurRMS[i1]; 132 | } 133 | 134 | b_abs(b_accDataIn, fv1); 135 | b_abs(b_walkStruct, fv2); 136 | if (eml_extremum(fv1) > eml_extremum(fv2)) { 137 | for (i1 = 0; i1 < 3; i1++) { 138 | walkStruct->Acur[i1] = accDataIn[i1]; 139 | } 140 | 141 | for (i1 = 0; i1 < 3; i1++) { 142 | walkStruct->AcurRMS[i1] = aRMSin[i1]; 143 | } 144 | 145 | walkStruct->Acurt = tDataIn; 146 | 147 | /* time and value */ 148 | } 149 | } else { 150 | if (walkStruct->crossed != 0) { 151 | /* once data crosses back under threshold, perform calculations and determine step type */ 152 | walkStruct->addPoint = 1; 153 | for (i1 = 0; i1 < 3; i1++) { 154 | b_walkStruct[i1] = walkStruct->Acur[i1] - walkStruct->AcurRMS[i1]; 155 | } 156 | 157 | b_abs(b_walkStruct, fv3); 158 | if (eml_extremum(fv3) > HIth) { 159 | /* high impact point classification */ 160 | q0 = walkStruct->HIcnt; 161 | qY = q0 + 1U; 162 | if (qY < q0) { 163 | qY = MAX_uint32_T; 164 | } 165 | 166 | walkStruct->HIcnt = qY; 167 | q0 = walkStruct->HIt; 168 | qY = q0 + 1U; 169 | if (qY < q0) { 170 | qY = MAX_uint32_T; 171 | } 172 | 173 | walkStruct->HIt = qY; 174 | } else { 175 | /* low impact point classification */ 176 | q0 = walkStruct->LIcnt; 177 | qY = q0 + 1U; 178 | if (qY < q0) { 179 | qY = MAX_uint32_T; 180 | } 181 | 182 | walkStruct->LIcnt = qY; 183 | q0 = walkStruct->LIt; 184 | qY = q0 + 1U; 185 | if (qY < q0) { 186 | qY = MAX_uint32_T; 187 | } 188 | 189 | walkStruct->LIt = qY; 190 | } 191 | 192 | if (walkStruct->HLI > 1U) { 193 | /* remove data points that are too close together in time */ 194 | q0 = walkStruct->Acurt; 195 | qY = q0 - walkStruct->Aprevt; 196 | if (qY > q0) { 197 | qY = 0U; 198 | } 199 | 200 | if ((double)c_abs(qY) < walkStruct->timeThr) { 201 | q0 = walkStruct->HLI; 202 | qY = q0 - 1U; 203 | if (qY > q0) { 204 | qY = 0U; 205 | } 206 | 207 | walkStruct->HLI = qY; 208 | walkStruct->addPoint = -1; 209 | for (i1 = 0; i1 < 3; i1++) { 210 | b_walkStruct[i1] = walkStruct->Aprev[i1] - walkStruct->AprevRMS[i1]; 211 | } 212 | 213 | for (i1 = 0; i1 < 3; i1++) { 214 | b_accDataIn[i1] = walkStruct->Acur[i1] - walkStruct->AcurRMS[i1]; 215 | } 216 | 217 | b_abs(b_walkStruct, fv4); 218 | b_abs(b_accDataIn, fv5); 219 | if (eml_extremum(fv4) > eml_extremum(fv5)) { 220 | for (i1 = 0; i1 < 3; i1++) { 221 | b_walkStruct[i1] = walkStruct->Acur[i1] - walkStruct->AcurRMS[i1]; 222 | } 223 | 224 | b_abs(b_walkStruct, fv6); 225 | if (eml_extremum(fv6) > HIth) { 226 | q0 = walkStruct->HIcnt; 227 | qY = q0 - 1U; 228 | if (qY > q0) { 229 | qY = 0U; 230 | } 231 | 232 | walkStruct->HIcnt = qY; 233 | q0 = walkStruct->HIt; 234 | qY = q0 - 1U; 235 | if (qY > q0) { 236 | qY = 0U; 237 | } 238 | 239 | walkStruct->HIt = qY; 240 | } else { 241 | q0 = walkStruct->LIcnt; 242 | qY = q0 - 1U; 243 | if (qY > q0) { 244 | qY = 0U; 245 | } 246 | 247 | walkStruct->LIcnt = qY; 248 | q0 = walkStruct->LIt; 249 | qY = q0 - 1U; 250 | if (qY > q0) { 251 | qY = 0U; 252 | } 253 | 254 | walkStruct->LIt = qY; 255 | } 256 | 257 | for (i1 = 0; i1 < 3; i1++) { 258 | walkStruct->Acur[i1] = walkStruct->Aprev[i1]; 259 | } 260 | 261 | for (i1 = 0; i1 < 3; i1++) { 262 | walkStruct->AcurRMS[i1] = walkStruct->AprevRMS[i1]; 263 | } 264 | 265 | walkStruct->Acurt = walkStruct->Aprevt; 266 | } else { 267 | for (i1 = 0; i1 < 3; i1++) { 268 | b_walkStruct[i1] = walkStruct->Aprev[i1] - walkStruct->AprevRMS[i1]; 269 | } 270 | 271 | b_abs(b_walkStruct, fv7); 272 | if (eml_extremum(fv7) > HIth) { 273 | q0 = walkStruct->HIcnt; 274 | qY = q0 - 1U; 275 | if (qY > q0) { 276 | qY = 0U; 277 | } 278 | 279 | walkStruct->HIcnt = qY; 280 | q0 = walkStruct->HIt; 281 | qY = q0 - 1U; 282 | if (qY > q0) { 283 | qY = 0U; 284 | } 285 | 286 | walkStruct->HIt = qY; 287 | } else { 288 | q0 = walkStruct->LIcnt; 289 | qY = q0 - 1U; 290 | if (qY > q0) { 291 | qY = 0U; 292 | } 293 | 294 | walkStruct->LIcnt = qY; 295 | q0 = walkStruct->LIt; 296 | qY = q0 - 1U; 297 | if (qY > q0) { 298 | qY = 0U; 299 | } 300 | 301 | walkStruct->LIt = qY; 302 | } 303 | } 304 | } 305 | } 306 | 307 | /* set the current point as the previous point, and reset the */ 308 | /* current point for new steps. */ 309 | for (i1 = 0; i1 < 3; i1++) { 310 | walkStruct->Aprev[i1] = walkStruct->Acur[i1]; 311 | } 312 | 313 | for (i1 = 0; i1 < 3; i1++) { 314 | walkStruct->AprevRMS[i1] = walkStruct->AcurRMS[i1]; 315 | } 316 | 317 | walkStruct->Aprevt = walkStruct->Acurt; 318 | for (i1 = 0; i1 < 3; i1++) { 319 | walkStruct->Acur[i1] = 0.0F; 320 | } 321 | 322 | for (i1 = 0; i1 < 3; i1++) { 323 | walkStruct->AcurRMS[i1] = 0.0F; 324 | } 325 | 326 | walkStruct->Acurt = 0U; 327 | walkStruct->crossed = 0; 328 | } 329 | } 330 | 331 | /* end */ 332 | } 333 | 334 | /* End of code generation (walkAlg3.c) */ 335 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/walkAlg3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * walkAlg3.h 3 | * 4 | * Code generation for function 'walkAlg3' 5 | * 6 | */ 7 | 8 | #ifndef __WALKALG3_H__ 9 | #define __WALKALG3_H__ 10 | 11 | /* Include files */ 12 | #include 13 | #include 14 | #include 15 | #include "rt_nonfinite.h" 16 | #include "rtwtypes.h" 17 | #include "walkAlg3_types.h" 18 | 19 | /* Function Declarations */ 20 | extern void walkAlg3(struct0_T *walkStruct, const float accDataIn[3], const 21 | float aRMSin[3], unsigned int tDataIn, float whichThr); 22 | 23 | #endif 24 | 25 | /* End of code generation (walkAlg3.h) */ 26 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/walkAlg3_initialize.c: -------------------------------------------------------------------------------- 1 | /* 2 | * walkAlg3_initialize.c 3 | * 4 | * Code generation for function 'walkAlg3_initialize' 5 | * 6 | */ 7 | 8 | /* Include files */ 9 | #include "rt_nonfinite.h" 10 | #include "aTimeUnroll2.h" 11 | #include "stepCounter_struct_init.h" 12 | #include "walkAlg3.h" 13 | #include "walkAlg3_initialize.h" 14 | 15 | /* Function Definitions */ 16 | void walkAlg3_initialize(void) 17 | { 18 | rt_InitInfAndNaN(8U); 19 | } 20 | 21 | /* End of code generation (walkAlg3_initialize.c) */ 22 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/walkAlg3_initialize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * walkAlg3_initialize.h 3 | * 4 | * Code generation for function 'walkAlg3_initialize' 5 | * 6 | */ 7 | 8 | #ifndef __WALKALG3_INITIALIZE_H__ 9 | #define __WALKALG3_INITIALIZE_H__ 10 | 11 | /* Include files */ 12 | #include 13 | #include 14 | #include 15 | #include "rt_nonfinite.h" 16 | #include "rtwtypes.h" 17 | #include "walkAlg3_types.h" 18 | 19 | /* Function Declarations */ 20 | extern void walkAlg3_initialize(void); 21 | 22 | #endif 23 | 24 | /* End of code generation (walkAlg3_initialize.h) */ 25 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/walkAlg3_ref.rsp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memsindustrygroup/Matlab-Open-Source-Pedometer-Algorithm/ecc1dd70592aebba90b59af56f8cde9f9a06828a/codegen/lib/walkAlg3/walkAlg3_ref.rsp -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/walkAlg3_rtw.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set MATLAB=C:\Program Files\MATLAB\R2014a 4 | 5 | cd . 6 | 7 | if "%1"=="" (C:\PROGRA~1\MATLAB\R2014a\bin\win64\gmake -f walkAlg3_rtw.mk all) else (C:\PROGRA~1\MATLAB\R2014a\bin\win64\gmake -f walkAlg3_rtw.mk %1) 8 | @if errorlevel 1 goto error_exit 9 | 10 | exit /B 0 11 | 12 | :error_exit 13 | echo The make command returned an error of %errorlevel% 14 | An_error_occurred_during_the_call_to_make 15 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/walkAlg3_rtw.mk: -------------------------------------------------------------------------------- 1 | ########################################################################### 2 | ## Makefile generated for MATLAB file/project 'walkAlg3'. 3 | ## 4 | ## Makefile : walkAlg3_rtw.mk 5 | ## Generated on : Wed Nov 05 12:08:38 2014 6 | ## MATLAB Coder version: 2.6 (R2014a) 7 | ## 8 | ## Build Info: 9 | ## 10 | ## Final product: $(RELATIVE_PATH_TO_ANCHOR)/walkAlg3.lib 11 | ## Product type : static-library 12 | ## 13 | ########################################################################### 14 | 15 | ########################################################################### 16 | ## MACROS 17 | ########################################################################### 18 | 19 | # Macro Descriptions: 20 | # PRODUCT_NAME Name of the system to build 21 | # MAKEFILE Name of this makefile 22 | # COMPUTER Computer type. See the MATLAB "computer" command. 23 | # PERL PERL Tool 24 | # GEN_LNK_SCRIPT Perl script to generate the command file 25 | # CMD_FILE Command file 26 | 27 | PRODUCT_NAME = walkAlg3 28 | MAKEFILE = walkAlg3_rtw.mk 29 | COMPUTER = PCWIN64 30 | MATLAB_ROOT = C:/PROGRA~1/MATLAB/R2014a 31 | MATLAB_BIN = C:/PROGRA~1/MATLAB/R2014a/bin 32 | MATLAB_ARCH_BIN = C:/PROGRA~1/MATLAB/R2014a/bin/win64 33 | MASTER_ANCHOR_DIR = 34 | START_DIR = C:/Users/jtrojan/Desktop/stepCounterTester 35 | ARCH = win64 36 | RELATIVE_PATH_TO_ANCHOR = . 37 | PERL = $(MATLAB_ROOT)/sys/perl/win32/bin/perl.exe 38 | GEN_LNK_SCRIPT = $(MATLAB_ROOT)/rtw/c/tools/mkvc_lnk.pl 39 | CMD_FILE = $(PRODUCT_NAME).lnk 40 | 41 | ########################################################################### 42 | ## TOOLCHAIN SPECIFICATIONS 43 | ########################################################################### 44 | 45 | # Toolchain Name: LCC-win64 v2.4.1 | gmake (64-bit Windows) 46 | # Supported Version(s): 2.4.1 47 | # ToolchainInfo Version: R2014a 48 | # Specification Revision: 1.0 49 | # 50 | 51 | #----------- 52 | # MACROS 53 | #----------- 54 | 55 | SHELL = cmd 56 | LCC_ROOT = $(MATLAB_ROOT)/sys/lcc64/lcc64 57 | LCC_BUILDLIB = $(LCC_ROOT)/bin/buildlib 58 | LCC_LIB = $(LCC_ROOT)/lib64 59 | MW_EXTERNLIB_DIR = $(MATLAB_ROOT)/extern/lib/win64/microsoft 60 | MW_LIB_DIR = $(MATLAB_ROOT)/lib/win64 61 | TOOLCHAIN_INCLUDES = -I$(LCC_ROOT)/include64 62 | MEX_OPTS_FILE = $(MATLAB_ROOT/rtw/c/tools/lcc-win64.xml 63 | 64 | TOOLCHAIN_SRCS = 65 | TOOLCHAIN_INCS = 66 | TOOLCHAIN_LIBS = 67 | 68 | #------------------------ 69 | # BUILD TOOL COMMANDS 70 | #------------------------ 71 | 72 | # C Compiler: Lcc-win64 C Compiler 73 | CC_PATH = $(LCC_ROOT)/bin 74 | CC = $(CC_PATH)/lcc64 75 | 76 | # Linker: Lcc-win64 Linker 77 | LD_PATH = $(LCC_ROOT)/bin 78 | LD = $(LD_PATH)/lcclnk64 79 | 80 | # Archiver: Lcc-win64 Archiver 81 | AR_PATH = $(LCC_ROOT)/bin 82 | AR = $(AR_PATH)/lcclib64 83 | 84 | # MEX Tool: MEX Tool 85 | MEX_PATH = $(MATLAB_BIN) 86 | MEX = $(MEX_PATH)/mex 87 | 88 | # Download: Download 89 | DOWNLOAD = 90 | 91 | # Execute: Execute 92 | EXECUTE = $(PRODUCT) 93 | 94 | # Builder: GMAKE Utility 95 | MAKE_PATH = %MATLAB%\bin\win64 96 | MAKE = $(MAKE_PATH)/gmake 97 | 98 | 99 | #------------------------- 100 | # Directives/Utilities 101 | #------------------------- 102 | 103 | CDEBUG = -g 104 | C_OUTPUT_FLAG = -Fo 105 | LDDEBUG = 106 | OUTPUT_FLAG = -o 107 | ARDEBUG = 108 | STATICLIB_OUTPUT_FLAG = /out: 109 | MEX_DEBUG = -g 110 | RM = @del /F 111 | ECHO = @echo 112 | MV = @move 113 | RUN = 114 | 115 | #---------------------------------------- 116 | # "Faster Builds" Build Configuration 117 | #---------------------------------------- 118 | 119 | ARFLAGS = 120 | CFLAGS = -c -w -noregistrylookup -nodeclspec -I$(LCC_ROOT)/include64 121 | DOWNLOAD_FLAGS = 122 | EXECUTE_FLAGS = 123 | LDFLAGS = -s -L$(LCC_LIB) $(LDFLAGS_ADDITIONAL) 124 | MEX_CFLAGS = -win64 $(MEX_SRC) $(MEX_OPT_FILE)$(INCLUDES) -outdir $(RELATIVE_PATH_TO_ANCHOR) 125 | MEX_LDFLAGS = LINKFLAGS="$$LINKFLAGS $(LDFLAGS_ADDITIONAL)" 126 | MAKE_FLAGS = -f $(MAKEFILE) 127 | SHAREDLIB_LDFLAGS = -dll -entry LibMain -s -L$(LCC_LIB) $(LDFLAGS_ADDITIONAL) $(DEF_FILE) 128 | 129 | #-------------------- 130 | # File extensions 131 | #-------------------- 132 | 133 | H_EXT = .h 134 | OBJ_EXT = .obj 135 | C_EXT = .c 136 | EXE_EXT = .exe 137 | SHAREDLIB_EXT = .dll 138 | STATICLIB_EXT = .lib 139 | MEX_EXT = .mexw64 140 | MAKE_EXT = .mk 141 | 142 | 143 | ########################################################################### 144 | ## OUTPUT INFO 145 | ########################################################################### 146 | 147 | PRODUCT = $(RELATIVE_PATH_TO_ANCHOR)/walkAlg3.lib 148 | PRODUCT_TYPE = "static-library" 149 | BUILD_TYPE = "Static Library" 150 | 151 | ########################################################################### 152 | ## INCLUDE PATHS 153 | ########################################################################### 154 | 155 | INCLUDES_BUILDINFO = -I$(START_DIR) -I$(START_DIR)/codegen/lib/walkAlg3 -I$(MATLAB_ROOT)/extern/include -I$(MATLAB_ROOT)/simulink/include -I$(MATLAB_ROOT)/rtw/c/src -I$(MATLAB_ROOT)/rtw/c/src/ext_mode/common -I$(MATLAB_ROOT)/rtw/c/ert 156 | 157 | INCLUDES = $(INCLUDES_BUILDINFO) 158 | 159 | ########################################################################### 160 | ## DEFINES 161 | ########################################################################### 162 | 163 | DEFINES_STANDARD = -DMODEL=walkAlg3 -DHAVESTDIO -DUSE_RTMODEL 164 | 165 | DEFINES = $(DEFINES_STANDARD) 166 | 167 | ########################################################################### 168 | ## SOURCE FILES 169 | ########################################################################### 170 | 171 | SRCS = $(START_DIR)/codegen/lib/walkAlg3/walkAlg3_initialize.c $(START_DIR)/codegen/lib/walkAlg3/walkAlg3_terminate.c $(START_DIR)/codegen/lib/walkAlg3/walkAlg3.c $(START_DIR)/codegen/lib/walkAlg3/stepCounter_struct_init.c $(START_DIR)/codegen/lib/walkAlg3/aTimeUnroll2.c $(START_DIR)/codegen/lib/walkAlg3/abs.c $(START_DIR)/codegen/lib/walkAlg3/isnan.c $(START_DIR)/codegen/lib/walkAlg3/rt_nonfinite.c $(START_DIR)/codegen/lib/walkAlg3/rtGetNaN.c $(START_DIR)/codegen/lib/walkAlg3/rtGetInf.c 172 | 173 | ALL_SRCS = $(SRCS) 174 | 175 | ########################################################################### 176 | ## OBJECTS 177 | ########################################################################### 178 | 179 | OBJS = walkAlg3_initialize.obj walkAlg3_terminate.obj walkAlg3.obj stepCounter_struct_init.obj aTimeUnroll2.obj abs.obj isnan.obj rt_nonfinite.obj rtGetNaN.obj rtGetInf.obj 180 | 181 | ALL_OBJS = $(OBJS) 182 | 183 | ########################################################################### 184 | ## PREBUILT OBJECT FILES 185 | ########################################################################### 186 | 187 | PREBUILT_OBJS = 188 | 189 | ########################################################################### 190 | ## LIBRARIES 191 | ########################################################################### 192 | 193 | LIBS = 194 | 195 | ########################################################################### 196 | ## SYSTEM LIBRARIES 197 | ########################################################################### 198 | 199 | SYSTEM_LIBS = 200 | 201 | ########################################################################### 202 | ## ADDITIONAL TOOLCHAIN FLAGS 203 | ########################################################################### 204 | 205 | #--------------- 206 | # C Compiler 207 | #--------------- 208 | 209 | CFLAGS_BASIC = $(DEFINES) $(INCLUDES) 210 | 211 | CFLAGS += $(CFLAGS_BASIC) 212 | 213 | ########################################################################### 214 | ## PHONY TARGETS 215 | ########################################################################### 216 | 217 | .PHONY : all build clean info prebuild download execute 218 | 219 | 220 | all : build 221 | @echo "### Successfully generated all binary outputs." 222 | 223 | 224 | build : prebuild $(PRODUCT) 225 | 226 | 227 | prebuild : 228 | 229 | 230 | download : build 231 | 232 | 233 | execute : download 234 | 235 | 236 | ########################################################################### 237 | ## FINAL TARGET 238 | ########################################################################### 239 | 240 | #--------------------------------- 241 | # Create a static library 242 | #--------------------------------- 243 | 244 | $(PRODUCT) : $(OBJS) $(PREBUILT_OBJS) 245 | $(PERL) $(GEN_LNK_SCRIPT) $(CMD_FILE) $(subst /,\,$(OBJS)) 246 | @echo "### Creating static library "$(PRODUCT)" ..." 247 | $(AR) $(ARFLAGS) /out:$(PRODUCT) @$(CMD_FILE) 248 | @echo "### Created: $(PRODUCT)" 249 | $(RM) $(CMD_FILE) 250 | 251 | 252 | ########################################################################### 253 | ## INTERMEDIATE TARGETS 254 | ########################################################################### 255 | 256 | #--------------------- 257 | # SOURCE-TO-OBJECT 258 | #--------------------- 259 | 260 | %.obj : %.c 261 | $(CC) $(CFLAGS) -Fo"$@" "$<" 262 | 263 | 264 | %.obj : $(RELATIVE_PATH_TO_ANCHOR)/%.c 265 | $(CC) $(CFLAGS) -Fo"$@" "$<" 266 | 267 | 268 | %.obj : $(MATLAB_ROOT)/rtw/c/src/%.c 269 | $(CC) $(CFLAGS) -Fo"$@" "$<" 270 | 271 | 272 | %.obj : $(START_DIR)/%.c 273 | $(CC) $(CFLAGS) -Fo"$@" "$<" 274 | 275 | 276 | %.obj : $(START_DIR)/codegen/lib/walkAlg3/%.c 277 | $(CC) $(CFLAGS) -Fo"$@" "$<" 278 | 279 | 280 | ########################################################################### 281 | ## DEPENDENCIES 282 | ########################################################################### 283 | 284 | $(ALL_OBJS) : $(MAKEFILE) rtw_proj.tmw 285 | 286 | 287 | ########################################################################### 288 | ## MISCELLANEOUS TARGETS 289 | ########################################################################### 290 | 291 | info : 292 | @echo "### PRODUCT = $(PRODUCT)" 293 | @echo "### PRODUCT_TYPE = $(PRODUCT_TYPE)" 294 | @echo "### BUILD_TYPE = $(BUILD_TYPE)" 295 | @echo "### INCLUDES = $(INCLUDES)" 296 | @echo "### DEFINES = $(DEFINES)" 297 | @echo "### ALL_SRCS = $(ALL_SRCS)" 298 | @echo "### ALL_OBJS = $(ALL_OBJS)" 299 | @echo "### LIBS = $(LIBS)" 300 | @echo "### MODELREF_LIBS = $(MODELREF_LIBS)" 301 | @echo "### SYSTEM_LIBS = $(SYSTEM_LIBS)" 302 | @echo "### TOOLCHAIN_LIBS = $(TOOLCHAIN_LIBS)" 303 | @echo "### CFLAGS = $(CFLAGS)" 304 | @echo "### LDFLAGS = $(LDFLAGS)" 305 | @echo "### SHAREDLIB_LDFLAGS = $(SHAREDLIB_LDFLAGS)" 306 | @echo "### ARFLAGS = $(ARFLAGS)" 307 | @echo "### MEX_CFLAGS = $(MEX_CFLAGS)" 308 | @echo "### MEX_LDFLAGS = $(MEX_LDFLAGS)" 309 | @echo "### DOWNLOAD_FLAGS = $(DOWNLOAD_FLAGS)" 310 | @echo "### EXECUTE_FLAGS = $(EXECUTE_FLAGS)" 311 | @echo "### MAKE_FLAGS = $(MAKE_FLAGS)" 312 | 313 | 314 | clean : 315 | $(ECHO) "### Deleting all derived files..." 316 | $(RM) $(subst /,\,$(PRODUCT)) 317 | $(RM) $(subst /,\,$(ALL_OBJS)) 318 | $(ECHO) "### Deleted all derived files." 319 | 320 | 321 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/walkAlg3_terminate.c: -------------------------------------------------------------------------------- 1 | /* 2 | * walkAlg3_terminate.c 3 | * 4 | * Code generation for function 'walkAlg3_terminate' 5 | * 6 | */ 7 | 8 | /* Include files */ 9 | #include "rt_nonfinite.h" 10 | #include "aTimeUnroll2.h" 11 | #include "stepCounter_struct_init.h" 12 | #include "walkAlg3.h" 13 | #include "walkAlg3_terminate.h" 14 | 15 | /* Function Definitions */ 16 | void walkAlg3_terminate(void) 17 | { 18 | /* (no terminate code required) */ 19 | } 20 | 21 | /* End of code generation (walkAlg3_terminate.c) */ 22 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/walkAlg3_terminate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * walkAlg3_terminate.h 3 | * 4 | * Code generation for function 'walkAlg3_terminate' 5 | * 6 | */ 7 | 8 | #ifndef __WALKALG3_TERMINATE_H__ 9 | #define __WALKALG3_TERMINATE_H__ 10 | 11 | /* Include files */ 12 | #include 13 | #include 14 | #include 15 | #include "rt_nonfinite.h" 16 | #include "rtwtypes.h" 17 | #include "walkAlg3_types.h" 18 | 19 | /* Function Declarations */ 20 | extern void walkAlg3_terminate(void); 21 | 22 | #endif 23 | 24 | /* End of code generation (walkAlg3_terminate.h) */ 25 | -------------------------------------------------------------------------------- /codegen/lib/walkAlg3/walkAlg3_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * walkAlg3_types.h 3 | * 4 | * Code generation for function 'walkAlg3' 5 | * 6 | */ 7 | 8 | #ifndef __WALKALG3_TYPES_H__ 9 | #define __WALKALG3_TYPES_H__ 10 | 11 | /* Include files */ 12 | #include "rtwtypes.h" 13 | 14 | /* Type Definitions */ 15 | #ifndef typedef_struct0_T 16 | #define typedef_struct0_T 17 | typedef struct 18 | { 19 | float HIthrA; 20 | float LIthrA; 21 | float HIthrW; 22 | float LIthrW; 23 | float timeThr; 24 | unsigned int HLI; 25 | unsigned int HIt; 26 | unsigned int LIt; 27 | unsigned int HIcnt; 28 | unsigned int LIcnt; 29 | float Acur[3]; 30 | float AcurRMS[3]; 31 | float Aprev[3]; 32 | float AprevRMS[3]; 33 | unsigned int Acurt; 34 | unsigned int Aprevt; 35 | unsigned char crossed; 36 | signed char addPoint; 37 | unsigned char reset; 38 | unsigned int aTimeUnroll; 39 | unsigned short prevTime; 40 | unsigned short nWrap; 41 | unsigned char timerOverflow; 42 | unsigned char counterOverflow; 43 | } struct0_T; 44 | #endif /*typedef_struct0_T*/ 45 | 46 | #endif 47 | /* End of code generation (walkAlg3_types.h) */ 48 | -------------------------------------------------------------------------------- /stepCounterScript.m: -------------------------------------------------------------------------------- 1 | % Function to process a matlab data file and run it through the walking 2 | % algorithm 3 | clear all;close all 4 | 5 | addpath('Data') 6 | 7 | [FileName,PathName] = uigetfile({'Data/;*.mat;*.csv;*.xlsx'},'Choose Sentral Log File'); 8 | disp(FileName) 9 | 10 | newResP = 0;resampledHtData = newResP; %initialize in case file doesn't have said data 11 | trueSteps = 0;startTime = 1;endTime = 0; 12 | titles = [FileName]; 13 | 14 | if FileName(end) == 't' % process .mat file 15 | 16 | load([PathName FileName]) 17 | 18 | resultData = data_rec.dataSimRec.data_result_ay; 19 | 20 | timeAy = resultData(:,1); % in seconds 21 | accelAy = resultData(:,5:7); 22 | listValues = zeros(size(timeAy)); 23 | j = 1; 24 | listValues(j) = 1; 25 | % remove repeated samples 26 | for i = 2:length(listValues) 27 | if all(accelAy(i,:) == accelAy(i-1,:)) 28 | 29 | else 30 | listValues(j) = i; 31 | j = j + 1; 32 | end 33 | end 34 | % basic values 35 | listValues = listValues(1:(j-1)); 36 | time = uint32(timeAy(listValues)*1000); % scale to milliseconds 37 | acal = accelAy(listValues,:);% scaled in g's 38 | filetype = 1; 39 | elseif FileName(end) == 'x' || FileName(end) == 'v' 40 | [rawData,header] = xlsread(FileName); 41 | whichInds = rawData(:,4) == 1; 42 | aDataRaw = rawData(whichInds,[1 5 6 7]); 43 | acal = aDataRaw(:,2:4)/9.81;%convert m/s2 to g's 44 | tRaw = aDataRaw(:,1); 45 | t2 = tRaw - tRaw(1,:); % time from zero in counts 46 | time = t2/10^6; % go from picoseconds to microseconds 47 | filetype = 2; 48 | ssts = find(rawData(:,4) == 104); 49 | tts = rawData(:,4) == 103; 50 | try 51 | trueSteps = rawData(tts,8); 52 | if length(trueSteps) > 1 53 | trueSteps = max(trueSteps); 54 | end 55 | catch;end 56 | try 57 | indices = find(aDataRaw(:,1) <= rawData(ssts(1),1)); 58 | startTime = indices(end); 59 | if isempty(startTime);startTime=0;end 60 | catch;end 61 | try 62 | indices = find(aDataRaw(:,1) >= rawData(ssts(2),1)); 63 | endTime = indices(1); 64 | if isempty(endTime);startTime=0;end 65 | catch;end 66 | 67 | else 68 | disp('Invalid file selected. Exiting.') 69 | filetype = 0; 70 | return 71 | end 72 | 73 | aR = sqrt(acal(:,1).^2 + acal(:,2).^2 + acal(:,3).^2); %accel radius in g's 74 | 75 | walkStruct = stepCounter_struct_init; 76 | walkStruct.LIthrW = single(1.03); % change important threshold if needed 77 | 78 | for k = 1:length(time) 79 | % run with accel data 80 | walkStruct = walkAlg3(walkStruct,acal(k,:),[0 0 0],time(k),1); 81 | 82 | % run with accel radius 83 | % walkStruct = walkAlg3(walkStruct,aR(k,:),0,time(k),1); 84 | end 85 | 86 | stepcount= sprintf('detected steps = %d',walkStruct.HLI); 87 | 88 | disp('Total number of steps detected') 89 | disp(walkStruct.HLI) 90 | 91 | figure(1);plot(time/1000,acal);legend('Accel X','Accel Y', 'Accel Z', 'Location','Best');title(titles,'Interpreter','none');text(2,.75,stepcount);ylabel('g-force');xlabel('seconds'); 92 | 93 | 94 | 95 | figure(2);plot(time/1000,aR);title(titles,'Interpreter','none');legend('Accel Radius','Location','Best');ylabel('3-Axis Root-Sum-Square (g-force)');text(3,.75,stepcount);xlabel('seconds'); -------------------------------------------------------------------------------- /stepCounter_struct_init flow diagram.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memsindustrygroup/Matlab-Open-Source-Pedometer-Algorithm/ecc1dd70592aebba90b59af56f8cde9f9a06828a/stepCounter_struct_init flow diagram.jpg -------------------------------------------------------------------------------- /stepCounter_struct_init.m: -------------------------------------------------------------------------------- 1 | function walkStruct = stepCounter_struct_init 2 | %%% init of stepCounter structure 3 | % 4 | %#codegen 5 | % 6 | 7 | % walkStruct 8 | walkStruct.HIthrA = single(2); 9 | walkStruct.LIthrA = single(0.7); 10 | walkStruct.HIthrW = single(1.7); 11 | walkStruct.LIthrW = single(1.07); 12 | walkStruct.timeThr = single(325); % made a single for real time updates 13 | walkStruct.HLI = uint32(0); 14 | walkStruct.HIt = uint32(0); 15 | walkStruct.LIt = uint32(0); 16 | walkStruct.HIcnt = uint32(0); 17 | walkStruct.LIcnt = uint32(0); 18 | walkStruct.Acur = zeros(1,3,'single'); %accel x y z time 19 | walkStruct.AcurRMS = zeros(1,3,'single'); 20 | walkStruct.Aprev = zeros(1,3,'single'); 21 | walkStruct.AprevRMS = zeros(1,3,'single'); 22 | walkStruct.Acurt = uint32(0); 23 | walkStruct.Aprevt = uint32(0); 24 | walkStruct.crossed = uint8(0); 25 | walkStruct.addPoint = int8(0); % 1 to add point, 0 for nothing, -1 to lose point 26 | walkStruct.reset = uint8(0); % end of interval reset flag 27 | 28 | walkStruct.aTimeUnroll = uint32(0); 29 | walkStruct.prevTime = uint16(0); 30 | walkStruct.nWrap = uint16(0); 31 | 32 | walkStruct.timerOverflow = uint8(0); 33 | walkStruct.counterOverflow = uint8(0); 34 | -------------------------------------------------------------------------------- /walkAlg3 flow diagram.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memsindustrygroup/Matlab-Open-Source-Pedometer-Algorithm/ecc1dd70592aebba90b59af56f8cde9f9a06828a/walkAlg3 flow diagram.jpg -------------------------------------------------------------------------------- /walkAlg3.m: -------------------------------------------------------------------------------- 1 | function walkStruct = walkAlg3(walkStruct,accDataIn,aRMSin,tDataIn,whichThr) 2 | %%% walking algorithm. 3 | % Performs step counting primarily targeted for the wrist mounting, uses 4 | % maximum observed value for each. Could also be used for accel radii. 5 | % Inputs: 6 | % walkStruct = holds all persistent varibles as well as thresholds, see 7 | % stepCounter_struct_init for definitions. 8 | % accDataIn = accel data inputs, x, y, z; can be lowpass filtered 9 | % if desired. 10 | % aRMSin = moving average or rms data, subtracted from data. Can input 11 | % zeros, or input RMS data as desired, will require different thresholds. 12 | % tDataIn = time data, in milliseconds, relative timing between points is 13 | % all that matters, but must be unwrapped before input to this function. 14 | % whichThr = allows user to store two sets of thresholds and switch with 15 | % this value. Example, could use different thresholds for 0 aRMSin vs moving 16 | % standard deviation for aRMSin and switch depending on if data available. 17 | % 18 | %#codegen 19 | % 20 | 21 | % choose a thershold setting 22 | % two threshold settings per to denote high acceleration or low 23 | % acceleration amplitudes 24 | if whichThr == 2 25 | LIth = walkStruct.LIthrA; 26 | HIth = walkStruct.HIthrA; 27 | else 28 | LIth = walkStruct.LIthrW; 29 | HIth = walkStruct.HIthrW; 30 | end 31 | walkStruct.addPoint = int8(0); 32 | 33 | if max(abs(accDataIn-aRMSin))>LIth % check if data has crossed minimum threshold 34 | if ~walkStruct.crossed % when it crosses a threshold incremement steps 35 | walkStruct.HLI = walkStruct.HLI + uint32(1); % step count 36 | walkStruct.crossed = uint8(1); 37 | end 38 | % if newest point is highest current point for this crossing, save 39 | % it as the current peak data point 40 | if max(abs(accDataIn-aRMSin)) > max(abs(walkStruct.Acur-walkStruct.AcurRMS)) 41 | walkStruct.Acur = accDataIn; 42 | walkStruct.AcurRMS = aRMSin; 43 | walkStruct.Acurt = tDataIn;% time and value 44 | end 45 | else 46 | if walkStruct.crossed % once data crosses back under threshold, perform calculations and determine step type 47 | walkStruct.addPoint = int8(1); 48 | if max(abs(walkStruct.Acur-walkStruct.AcurRMS)) > HIth 49 | % high impact point classification 50 | walkStruct.HIcnt = walkStruct.HIcnt + uint32(1); 51 | walkStruct.HIt = walkStruct.HIt + uint32(1); 52 | else 53 | % low impact point classification 54 | walkStruct.LIcnt = walkStruct.LIcnt + uint32(1); 55 | walkStruct.LIt = walkStruct.LIt + uint32(1); 56 | end 57 | 58 | if walkStruct.HLI > 1 59 | % remove data points that are too close together in time 60 | if abs(walkStruct.Acurt-walkStruct.Aprevt) < walkStruct.timeThr 61 | walkStruct.HLI = walkStruct.HLI - uint32(1); 62 | walkStruct.addPoint = int8(-1); 63 | if max(abs(walkStruct.Aprev-walkStruct.AprevRMS)) > max(abs(walkStruct.Acur-walkStruct.AcurRMS)) 64 | if max(abs(walkStruct.Acur-walkStruct.AcurRMS)) > HIth 65 | walkStruct.HIcnt = walkStruct.HIcnt - uint32(1); 66 | walkStruct.HIt = walkStruct.HIt - uint32(1); 67 | else 68 | walkStruct.LIcnt = walkStruct.LIcnt - uint32(1); 69 | walkStruct.LIt = walkStruct.LIt - uint32(1); 70 | end 71 | walkStruct.Acur = walkStruct.Aprev; 72 | walkStruct.AcurRMS = walkStruct.AprevRMS; 73 | walkStruct.Acurt = walkStruct.Aprevt; 74 | else 75 | if max(abs(walkStruct.Aprev-walkStruct.AprevRMS)) > HIth 76 | walkStruct.HIcnt = walkStruct.HIcnt - uint32(1); 77 | walkStruct.HIt = walkStruct.HIt - uint32(1); 78 | else 79 | walkStruct.LIcnt = walkStruct.LIcnt - uint32(1); 80 | walkStruct.LIt = walkStruct.LIt - uint32(1); 81 | end 82 | end 83 | end 84 | end 85 | % set the current point as the previous point, and reset the 86 | % current point for new steps. 87 | walkStruct.Aprev = walkStruct.Acur; 88 | walkStruct.AprevRMS = walkStruct.AcurRMS; 89 | walkStruct.Aprevt = walkStruct.Acurt; 90 | walkStruct.Acur = zeros(size(walkStruct.Acur),'single'); 91 | walkStruct.AcurRMS = zeros(size(walkStruct.AcurRMS),'single'); 92 | walkStruct.Acurt = uint32(0); 93 | walkStruct.crossed = uint8(0); 94 | end 95 | end 96 | % end --------------------------------------------------------------------------------