function eCANSAMCallback(hObj, hDlg, tag, ~)
%ECANSAMCALLBACK Callback to check I2C Own address register validity

% Copyright 2013 The MathWorks, Inc.


if codertarget.target.isCoderTarget(hObj.getConfigSet())
    cs = hObj.getConfigSet();
    ud = hDlg.getUserData(tag);
    fieldName = ud.Storage;
    if isempty(fieldName)
        fieldName = strrep(tag, 'Tag_ConfigSet_CoderTarget_', '');
    end
    curVal = codertarget.data.getParameterValue(cs, fieldName);
    newVal = hDlg.getComboBoxText(tag);   
    periphName = strtok(ud.Storage,'.');
    data = codertarget.data.getParameterValue(hObj, periphName);
    BRP = data.BaudRatePrescaler;
    
    if (strcmp(newVal, 'Sample_three_times') && BRP <= 4)
        hDlg.setWidgetValue(tag, find(strcmpi(ud.Entries, curVal))-1);
        msg = DAStudio.message('TIC2000:blocks:tgtPrefsPeripheralCANSAMSample');
        dp = DAStudio.DialogProvider;
        dp.errordlg(msg, 'Error: Coder Target', true);
        return;
    else
        codertarget.data.setParameterValue(cs, fieldName, newVal);
        hDlg.setWidgetValue(tag, find(strcmpi(ud.Entries,newVal))-1); 
    end
end

end