www.gusucode.com > ArmCortexMFastModelSupportPackage > ArmCortexMFastModelSupportPackage/ArmCortexM1FastModel/+matlabshared/+target/+m1/ConnectivityConfig.m
classdef ConnectivityConfig < rtw.connectivity.Config %CONNECTIVITYCONFIG PIL connectivity configuration class % % Copyright 2018 Arm Holdings methods % Constructor function this = ConnectivityConfig(componentArgs) % 1. Setup up target comunication % Creates BUILDINFO object with PIL-specific files. the % 'main.c' file will link with generated PIL files. targetApplicationFramework = matlabshared.target.armcortexmvirtualtarget.TargetApplicationFramework(componentArgs); % An executable framework specifies additional source files and libraries required for building the PIL executable % 2. Instantiate the builder. builder = rtw.connectivity.MakefileBuilder(componentArgs, targetApplicationFramework,'.elf'); % 3. Instantiate the launcher launcher = matlabshared.target.armcortexmvirtualtarget.Launcher(componentArgs, builder); % 4. Set up host communication sharedLibExt = system_dependent('GetSharedLibExt'); % File extention for shared libraries (such as .dll on Windows) rtiostreamLib = ['libmwrtiostreamtcpip' sharedLibExt]; % rtiostreamLib = ['rtiostreamserial' sharedLibExt]; serverhostname = '127.0.0.1'; rtIOStreamOpenArgs = {... '-hostname', serverhostname, ... % '-port', 'COM2', ... '-client', '1', ... % '-baud', '115200', ... '-blocking', '1' ... %'-port', '5000',... }; hostCommunicator = matlabshared.target.armcortexmvirtualtarget.VirtualPlatformCommunicator(componentArgs, launcher, rtiostreamLib); %Previously: hostCommunicator = rtw.connectivity.RtIOStreamHostCommunicator(componentArgs, launcher, rtiostreamLib); % Set timeouts hostCommunicator.setInitCommsTimeout(10); % Some targets may not respond to initial requests to setup comms, it could take a few seconds. Add in a buffer here to ensure an early timeout is not reached. hostCommunicator.setTimeoutRecvSecs(10); % Set timeout perioud for recieving data % Implement rtIOStreamOpenArgs hostCommunicator.setOpenRtIOStreamArgList(rtIOStreamOpenArgs); % 5. Call super class constructor to register all components this@rtw.connectivity.Config(componentArgs,... builder,... launcher,... hostCommunicator); % 6. Register timer for Profiling. % Find timer frequency for profiling the test ConfigInterface = componentArgs.getConfigInterface; ConfigSet = ConfigInterface.getConfig; if isa(ConfigSet, 'coder.EmbeddedCodeConfig') % MATLAB PIL % Get target hardware information hw = ConfigSet.Hardware; % Hardware's parameter info ParamsInfo = hw.ParameterInfo; clockRate = 1e6 * str2double(ParamsInfo.Parameter{1}{1}.Value); timerFreq = 1e6 * str2double(ParamsInfo.Parameter{1}{2}.Value); else % Simulink PIL coderTargetData = codertarget.data.getData(ConfigSet); clockRate = 1e6 * str2double(coderTargetData.Clocking.cpuClockRateMHz); timerFreq = 1e6 * str2double(coderTargetData.Clocking.SystickInterruptFreq); end % Ensure the clockrate is faster or equal to the timer frequency assert(clockRate>=timerFreq); % Timing details for profiling %timer = codertarget.arm_cortex_m.pil.Timer(timerFreq); timer = matlabshared.target.armcortexmvirtualtarget.Timer(timerFreq); this.setTimer(timer); end end end