added c code interface

This commit is contained in:
jacky 2024-06-26 16:46:34 +08:00
parent 21784e1b24
commit c07905c0ad
25 changed files with 282 additions and 37 deletions

Binary file not shown.

View File

@ -6,10 +6,10 @@
/*********************************************************************************
* Includes
*********************************************************************************/
#include "Rte_App.h"
#include "PassiveStart.h"
// #include "Rte_App.h"
// #include "PassiveStart.h"
#include "FrntWiperCtrl.h"
#include "Eeprom_Ctl.h"
// #include "Eeprom_Ctl.h"
/*********************************************************************************
* Local Macros
@ -36,6 +36,137 @@
#define FWIPER_REQ_STS_LOW 0x03
#define FWIPER_REQ_STS_HIGH 0x04
/* added macros */
#define PWRMODE_OFF 0x00
/* added dummy signal for MATLAB */
uint8_t Rte_Read_AppPs_PwrMod_Matlab;
uint8_t Rte_Write_ComCan_FrntWiprParkStsSwt_Matlab;
uint8_t Rte_Read_AppVfmm_RefrshModRestrntFctCmd_Matlab;
uint8_t Rte_Read_ComCan_ICC_BCMWipeLevel_Matlab;
uint8_t Rte_Write_ComCan_WipeLevelFB_Matlab;
uint8_t Rte_Read_Input_FrontWiperParkSts_Matlab;
uint8_t Rte_Read_ComCan_CIM_FWiperSwtFault_Matlab;
uint8_t Rte_Read_ComCan_CIM_FWiperSwtReq_Matlab;
uint8_t Rte_Read_ComCan_CIM_FWiperMistReq_Matlab;
uint8_t Rte_Write_ComCan_FrnWiprOutpSts_Matlab;
uint8_t Rte_Read_ComCan_VehSpdVld_Matlab;
uint8_t Rte_Read_ComCan_VehSpd_Matlab;
uint8_t Rte_Read_AppPm_VoltMode_Matlab;
uint8_t Rte_Read_ComCan_ICC_WiprMntnModSwt_Matlab;
uint8_t Rte_Read_ComCan_CIM_FWiperWashReq_Matlab;
uint8_t Rte_Write_ComCan_FrntWiprMntnSts_Matlab;
uint8_t Rte_Read_ComLin_RLS_SplashReq_Matlab;
uint8_t Rte_Read_ComLin_RLS_WIPRSPDREQ_Matlab;
uint8_t Rte_Write_ComCan_FrntWshrCmd_Matlab;
uint8_t Rte_Read_Input_HoodAjarSts_Matlab;
uint16_t debug_signal_Matlab = 0; //for debug
uint8_t CFG_RAIN_LIGHT_SENSOR_ENABLED;
uint8_t CFG_FRONT_WIPER_INT;
uint8_t PAR_FW_MAINTENANCE_MODE_RUNNING_TIMER;
/* wiper control */
uint8_t WP_Front_Wiper_Enable_CMD;
uint8_t WP_Front_Wiper_Speed_CMD;
uint8_t WP_Front_Washer_CMD;
/* added dummy function TODO need to verify the function signature */
uint8_t Rte_Read_AppPs_PwrMod(void){
return Rte_Read_AppPs_PwrMod_Matlab;
}
void Rte_Write_ComCan_FrntWiprParkStsSwt(uint8_t status){
Rte_Write_ComCan_FrntWiprParkStsSwt_Matlab = status;
}
uint8_t Rte_Read_AppVfmm_RefrshModRestrntFctCmd(void){
return Rte_Read_AppVfmm_RefrshModRestrntFctCmd_Matlab;
}
uint8_t Rte_Read_ComCan_ICC_BCMWipeLevel(void){
return Rte_Read_ComCan_ICC_BCMWipeLevel_Matlab;
}
void Rte_Write_ComCan_WipeLevelFB(uint8_t fWipeLevel){
Rte_Write_ComCan_WipeLevelFB_Matlab = fWipeLevel;
}
uint8_t Rte_Read_Input_FrontWiperParkSts(void){
return Rte_Read_Input_FrontWiperParkSts_Matlab;
}
uint8_t Rte_Read_ComCan_CIM_FWiperSwtFault(void){
return Rte_Read_ComCan_CIM_FWiperSwtFault_Matlab;
}
uint8_t Rte_Read_ComCan_CIM_FWiperSwtReq(void){
return Rte_Read_ComCan_CIM_FWiperSwtReq_Matlab;
}
uint8_t Rte_Read_ComCan_CIM_FWiperMistReq(void){
return Rte_Read_ComCan_CIM_FWiperMistReq_Matlab;
}
void Rte_Write_ComCan_FrnWiprOutpSts(uint8_t wiper_status){
Rte_Write_ComCan_FrnWiprOutpSts_Matlab = wiper_status;
}
uint8_t Rte_Read_ComCan_VehSpdVld(void){
return Rte_Read_ComCan_VehSpdVld_Matlab;
}
uint8_t Rte_Read_ComCan_VehSpd(void){
return Rte_Read_ComCan_VehSpd_Matlab;
}
uint8_t Rte_Read_AppPm_VoltMode(void){
return Rte_Read_AppPm_VoltMode_Matlab;
}
uint8_t Rte_Read_ComCan_ICC_WiprMntnModSwt(void){
return Rte_Read_ComCan_ICC_WiprMntnModSwt_Matlab;
}
uint8_t Rte_Read_ComCan_CIM_FWiperWashReq(void){
return Rte_Read_ComCan_CIM_FWiperWashReq_Matlab;
}
void Rte_Write_ComCan_FrntWiprMntnSts(uint8_t status){
Rte_Write_ComCan_FrntWiprMntnSts_Matlab = status;
}
uint8_t Rte_Read_ComLin_RLS_SplashReq(void){
return Rte_Read_ComLin_RLS_SplashReq_Matlab;
}
uint8_t Rte_Read_ComLin_RLS_WIPRSPDREQ(void){
return Rte_Read_ComLin_RLS_WIPRSPDREQ_Matlab;
}
void Rte_Write_ComCan_FrntWshrCmd(uint8_t WshrCmd){
Rte_Write_ComCan_FrntWshrCmd_Matlab = WshrCmd;
}
uint8_t Rte_Read_Input_HoodAjarSts(void){
return Rte_Read_Input_HoodAjarSts_Matlab;
}
uint8_t Rte_Read_EepCfg_RAIN_LIGHT_SENSOR_ENABLED(void){
return CFG_RAIN_LIGHT_SENSOR_ENABLED;
}
uint8_t Rte_Read_EepCfg_FRONT_WIPER_INT(void){
return CFG_FRONT_WIPER_INT;
}
uint8_t Rte_Read_Did_FWipeMntnRuningTime(void){
return PAR_FW_MAINTENANCE_MODE_RUNNING_TIMER;
}
/* added function implementation with MATLAB */
void Rte_Write_Output_FrontWiperEnableOUT(uint8_t enable){
WP_Front_Wiper_Enable_CMD = enable;
}
void Rte_Write_Output_FrontWiperSpeedOUT(uint8_t speed){
WP_Front_Wiper_Speed_CMD = speed;
}
void Rte_Write_Output_FrontWasherOUT(uint8_t wash){
WP_Front_Washer_CMD = wash;
}
// TODO the value returned should be relating to the step time of solver of the matlab model
// assuming it is 1ms
uint16_t t1ms(uint16_t ms){
return ms;
}
uint16_t t1s(uint16_t s){
return s*1000;
}
// TODO it should be renamed for MATLAB case
uint16_t Delay_Base5ms(uint16_t v){
return v;
}
/*********************************************************************************
* Local Struct
*********************************************************************************/

View File

@ -38,6 +38,37 @@
#define FWIPER_STS_INT 0x04
#define FWIPER_STS_AUTO 0x05
/*********************************************************************************
* Additional Macros
*********************************************************************************/
#define uint8_t unsigned char
#define uint16_t unsigned int
#define uint32_t unsigned long
/*********************************************************************************
* TODO verify these values
*********************************************************************************/
#define PWRMODE_OFF 0x00
#define PWRMODE_ON 0x01
//hood
#define DOOR_AJAR_CLOSE 0x00
#define DOOR_AJAR_OPEN 0x01
//VehSpdVld
#define VEH_SPEED_INITIALIZING 0x00
#define VEH_SPEED_VALID 0x01
#define VEH_SPEED_INVALID 0x02
#define VEH_SPEED_RESERVED 0x03
//VehSpd
#define VEH_SPEED_2KM 2
#define VEH_SPEED_8KM 8
#define VEH_SPEED_32KM 32
#define VEH_SPEED_64KM 64
#define VEH_SPEED_96KM 96
#define VEH_SPEED_128KM 128
//VoltageMode
#define VOLT_MODE_NORMAL 0x00
#define VOLT_MODE_HIGH 0x03
/*********************************************************************************
* Global Struct
*********************************************************************************/
@ -127,6 +158,42 @@ typedef enum /*Maintain Mode Control Step */
/*********************************************************************************
* Global Variables
*********************************************************************************/
// added dummy signal for MATLAB
// input
extern uint8_t Rte_Read_AppPs_PwrMod_Matlab;
extern uint8_t Rte_Read_AppVfmm_RefrshModRestrntFctCmd_Matlab;
extern uint8_t Rte_Read_ComCan_ICC_BCMWipeLevel_Matlab;
extern uint8_t Rte_Read_Input_FrontWiperParkSts_Matlab;
extern uint8_t Rte_Read_ComCan_CIM_FWiperSwtFault_Matlab;
extern uint8_t Rte_Read_ComCan_CIM_FWiperSwtReq_Matlab;
extern uint8_t Rte_Read_ComCan_CIM_FWiperMistReq_Matlab;
extern uint8_t Rte_Read_ComCan_VehSpdVld_Matlab;
extern uint8_t Rte_Read_ComCan_VehSpd_Matlab;
extern uint8_t Rte_Read_AppPm_VoltMode_Matlab;
extern uint8_t Rte_Read_ComCan_ICC_WiprMntnModSwt_Matlab;
extern uint8_t Rte_Read_ComCan_CIM_FWiperWashReq_Matlab;
extern uint8_t Rte_Read_ComLin_RLS_SplashReq_Matlab;
extern uint8_t Rte_Read_ComLin_RLS_WIPRSPDREQ_Matlab;
extern uint8_t Rte_Read_Input_HoodAjarSts_Matlab;
// output
extern uint8_t Rte_Write_ComCan_FrntWiprParkStsSwt_Matlab;
extern uint8_t Rte_Write_ComCan_WipeLevelFB_Matlab;
extern uint8_t Rte_Write_ComCan_FrnWiprOutpSts_Matlab;
extern uint8_t Rte_Write_ComCan_FrntWiprMntnSts_Matlab;
extern uint8_t Rte_Write_ComCan_FrntWshrCmd_Matlab;
extern uint16_t debug_signal_Matlab;
/* wiper control */
extern uint8_t WP_Front_Wiper_Enable_CMD;
extern uint8_t WP_Front_Wiper_Speed_CMD;
extern uint8_t WP_Front_Washer_CMD;
// configuration
extern uint8_t CFG_RAIN_LIGHT_SENSOR_ENABLED;
extern uint8_t CFG_FRONT_WIPER_INT;
extern uint8_t PAR_FW_MAINTENANCE_MODE_RUNNING_TIMER;
/*********************************************************************************
* Global Functions

View File

@ -1,23 +0,0 @@
When start up, it will load the following files
1. constant.mat for setting the constant value
2. configuration.mat, simulating the configuration value stored in the flash/eeprom
Files information:
------------------
Wiper_controller.slx - the main part for handling HI, LOW, INT_AUTO request
wiper.slx - model for demo the main part
wiper_model.slx - the overall model
wiper_model_sim.slx - model for demo
wiper_model_test.slx - model for running test case
test_case.mat - holding the test cases
test_case.xlsx - export from test_case.mat
test.mldatx - holding the mapping
constant.mat - storing the system constant
configuration.mat - storing the configuration from eeprom/flash
Note:
There is no SWIF_BdcOtaMod for checking the OTA mode
Program Note:
in INT mode, the model output WP_Front_Wiper_Enable_CMD the same as Front Wiper Motor in Figure 3 Front Wiper INT Mode in the specification. As not sure how to simulate the Front wiper motor.

46
wiper/README.txt Normal file
View File

@ -0,0 +1,46 @@
When start up, it will load the following files
1. constant.mat for setting the constant value
2. configuration.mat, simulating the configuration value stored in the flash/eeprom
Files information:
------------------
Wiper_controller.slx - the main part for handling HI, LOW, INT_AUTO request
wiper.slx - model for demo the main part
wiper_model.slx - the overall model
wiper_model_sim.slx - model for demo
wiper_model_test.slx - model for running test case
test_case.mat - holding the test cases
test_case.xlsx - export from test_case.mat
test.mldatx - holding the mapping
constant.mat - storing the system constant
configuration.mat - storing the configuration from eeprom/flash
Note:
There is no SWIF_BdcOtaMod for checking the OTA mode
============================================
New design base on C code from FrntWiperCtrl
============================================
added interface in FrntWiperCtrl.c and FrntWiperCtrl.h for interacting with Matlab, all the logic is based on the c code (use the C caller block)
purpose: Matlab can help to verify the logic in the c code without (or miniziing) creating new bug due to problem in the Matlab model.
[files lists]
configuration.mat
- storing all the eeprom/flash configuration/parameters
wiper_from_c.slx
- use C caller to call the C code from FrntWiperCtrl
FrntWiperCtrl_test.mldatx
- the test file of the model, requirement 5.5.1
requirement 5.5.1
- testing input: wiper\test_files\FrntWiperCtrl_test\input_5_5_1
- tested with input against "logical and temporal assesments"
requirement 5.5.2, 5.5.3
- testing input: wiper\test_files\FrntWiperCtrl_test\input_5_5_2
- tested with input against "logical and temporal assesments"
added delay of 18ms for the home position of the wiper as indicated in the c code.
requirement 5.7.7
- testing input: wiper\test_files\FrntWiperCtrl_test\input_5_7_7
- tested with input against "logical and temporal assesments"
setting the speed to 130, INT position to 1 -> dwell time 10.1s
Dummy_Wiper_Sim.slx
- simulating the controlled wiper, generating the park position for testing

View File

@ -1,2 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="1e70434a-10d1-4b5f-b1d5-078224a66607" type="EntryPoint"/>

View File

@ -0,0 +1,4 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info File="wiper_from_c.slx" GroupUUID="" Icon="" Name="wiper_from_c" Type="StartUp" Visible="0">
<Extension Name="StartUpPrev" Value="0ee60014-b475-420b-9c9d-b1ec9fb050ea"/>
</Info>

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="7385a820-6a88-4960-94fd-b9cf3698be77" type="EntryPoint"/>

View File

@ -1,4 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info File="wiper_model_sim.slx" GroupUUID="" Icon="" Name="wiper_model_sim" Type="StartUp" Visible="0">
<Extension Name="StartUpPrev" Value="1e70434a-10d1-4b5f-b1d5-078224a66607"/>
</Info>

View File

@ -1,2 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="b9ac66b8-0e46-4bc5-b482-e29cde4d4e30" type="EntryPoint"/>

View File

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info File="test_files/unit test/unit_tests.mldatx" GroupUUID="" Icon="" Name="unit_tests" Type="StartUp" Visible="0">
<Info File="test_files/FrntWiperCtrl_test.mldatx" GroupUUID="" Icon="" Name="FrntWiperCtrl_test" Type="StartUp" Visible="0">
<Extension Name="StartUpPrev" Value="228207ba-df4f-4e8a-a8e9-c6dc81bd188b"/>
</Info>

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="0ee60014-b475-420b-9c9d-b1ec9fb050ea" type="EntryPoint"/>

View File

@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="test"/>
</Category>
</Info>

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="FrntWiperCtrl_test.mldatx" type="File"/>

View File

@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="FrntWiperCtrl_test_input.mat" type="File"/>

View File

@ -1,2 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="README.md" type="File"/>

View File

@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="wiper_from_c.slx" type="File"/>

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="README.txt" type="File"/>

Binary file not shown.

Binary file not shown.

BIN
wiper/wiper_from_c.slx Normal file

Binary file not shown.