1/*
2 * File: ObstacleDetection_demo_ec.c
3 *
4 * Code generated for Simulink model 'ObstacleDetection_demo_ec'.
5 *
6 * Model version : 1.27
7 * Simulink Coder version : 9.0 (R2018b) 24-May-2018
8 * C/C++ source code generated on : Tue Oct 29 09:31:30 2019
9 *
10 * Target selection: ert.tlc
11 * Embedded hardware selection: Intel->x86-64 (Windows64)
12 * Code generation objectives:
13 * 1. Execution efficiency
14 * 2. RAM efficiency
15 * Validation result: Not run
16 */
17
18#include "ObstacleDetection_demo_ec.h"
19
20/* Macros for accessing real-time model data structure */
21#ifndef rtmGetErrorStatus
22# define rtmGetErrorStatus(rtm) (*((rtm)->errorStatus))
23#endif
24
25#ifndef rtmSetErrorStatus
26# define rtmSetErrorStatus(rtm, val) (*((rtm)->errorStatus) = (val))
27#endif
28
29#ifndef rtmGetErrorStatusPointer
30# define rtmGetErrorStatusPointer(rtm) (rtm)->errorStatus
31#endif
32
33#ifndef rtmSetErrorStatusPointer
34# define rtmSetErrorStatusPointer(rtm, val) ((rtm)->errorStatus = (val))
35#endif
36
37P_ObstacleDetection_demo_ec_T ObstacleDetection_demo_ec_P = {
38 /* Mask Parameter: S_R_Flip_Flop_initial_condition
39 * Referenced by: '<S4>/Memory'
40 */
41 0,
42
43 /* Computed Parameter: Logic_table
44 * Referenced by: '<S4>/Logic'
45 */
46 { 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0 }
47};
48
49/* System initialize for referenced model: 'ObstacleDetection_demo_ec' */
50void ObstacleDetection_demo_ec_Init(DW_ObstacleDetection_demo_e_f_T *localDW)
51{
52 /* InitializeConditions for Memory: '<S4>/Memory' */
53 localDW->Memory_PreviousInput =
54 ObstacleDetection_demo_ec_P.S_R_Flip_Flop_initial_condition;
55}
56
57/* Output and update for referenced model: 'ObstacleDetection_demo_ec' */
58void ObstacleDetection_demo_ec(const int8_T *rtu_remoteCtrlCmd, const int8_T
59 *rtu_usSensorFront, boolean_T *rty_emergencyStopObstacle, boolean_T
60 *rty_obstacleDetection, DW_ObstacleDetection_demo_e_f_T *localDW)
61{
62 int32_T rowIdx;
63 boolean_T rtb_RelationalOperator;
64
65 /* RelationalOperator: '<S2>/Relational Operator' incorporates:
66 * Constant: '<S2>/Constant1'
67 */
68 rtb_RelationalOperator = (*rtu_usSensorFront <= rtP_DIST_OBSTACLE_STOP);
69
70 /* RelationalOperator: '<S2>/Relational Operator1' incorporates:
71 * Constant: '<S2>/Constant2'
72 */
73 *rty_obstacleDetection = (*rtu_usSensorFront <= rtP_DIST_OBSTACLE_EVADE);
74
75 /* CombinatorialLogic: '<S4>/Logic' incorporates:
76 * Constant: '<S2>/Constant3'
77 * Logic: '<S2>/Logical Operator'
78 * Logic: '<S2>/Logical Operator1'
79 * Memory: '<S4>/Memory'
80 * RelationalOperator: '<S2>/Relational Operator2'
81 */
82 rowIdx = (int32_T)(((((!rtb_RelationalOperator) || (*rtu_remoteCtrlCmd ==
83 rtP_REMOTE_DRIVE_REV)) + ((uint32_T)rtb_RelationalOperator << 1)) << 1) +
84 localDW->Memory_PreviousInput);
85
86 /* SignalConversion: '<Root>/TmpSignal ConversionAtemergencyStopObstacleInport1' incorporates:
87 * CombinatorialLogic: '<S4>/Logic'
88 */
89 *rty_emergencyStopObstacle = ObstacleDetection_demo_ec_P.Logic_table[(uint32_T)
90 rowIdx];
91
92 /* Update for Memory: '<S4>/Memory' incorporates:
93 * CombinatorialLogic: '<S4>/Logic'
94 */
95 localDW->Memory_PreviousInput = ObstacleDetection_demo_ec_P.Logic_table
96 [(uint32_T)rowIdx];
97}
98
99/* Model initialize function */
100void ObstacleDetection_de_initialize(const char_T **rt_errorStatus,
101 RT_MODEL_ObstacleDetection_de_T *const ObstacleDetection_demo_ec_M)
102{
103 /* Registration code */
104
105 /* initialize error status */
106 rtmSetErrorStatusPointer(ObstacleDetection_demo_ec_M, rt_errorStatus);
107}
108
109/*
110 * File trailer for generated code.
111 *
112 * [EOF]
113 */
114