@@ -33,14 +33,21 @@ import {
3333 view_str$flasher$resetMode ,
3434 view_str$flasher$other_cmds ,
3535 view_str$flasher$stcgalOptions ,
36- view_str$compile$archExtensions
36+ view_str$compile$archExtensions ,
37+ view_str$flasher$eraseAll
3738} from "./StringTable" ;
3839import { ResManager } from "./ResManager" ;
3940import { ArrayDelRepetition } from "../lib/node-utility/Utility" ;
4041import { GlobalEvent } from "./GlobalEvents" ;
4142import { ExceptionToMessage , newMessage } from "./Message" ;
4243import { ToolchainName , IToolchian , ToolchainManager } from './ToolchainManager' ;
43- import { HexUploaderType , STLinkOptions , STVPFlasherOptions , StcgalFlashOption , JLinkOptions , JLinkProtocolType , PyOCDFlashOptions , OpenOCDFlashOptions , STLinkProtocolType , CustomFlashOptions } from "./HexUploader" ;
44+ import {
45+ HexUploaderType , STLinkOptions , STVPFlasherOptions ,
46+ StcgalFlashOption , JLinkOptions , JLinkProtocolType ,
47+ PyOCDFlashOptions , OpenOCDFlashOptions , STLinkProtocolType ,
48+ ProbeRSFlashOptions ,
49+ CustomFlashOptions
50+ } from "./HexUploader" ;
4451import { AbstractProject } from "./EIDEProject" ;
4552import { SettingManager } from "./SettingManager" ;
4653import { WorkspaceManager } from "./WorkspaceManager" ;
@@ -1932,6 +1939,8 @@ export abstract class UploadConfigModel<T> extends ConfigModel<T> {
19321939 return new OpenOCDUploadModel ( api ) ;
19331940 case 'Custom' :
19341941 return new CustomUploadModel ( api ) ;
1942+ case 'probe-rs' :
1943+ return new ProbeRSUploadModel ( api ) ;
19351944 default :
19361945 throw new Error ( 'Invalid uploader type !' ) ;
19371946 }
@@ -1955,6 +1964,9 @@ export abstract class UploadConfigModel<T> extends ConfigModel<T> {
19551964 }
19561965 }
19571966
1967+ /**
1968+ * @description 用于获取该选项的值(仅用于在UI中进行可读性显示)
1969+ */
19581970 getKeyValue ( key : string ) : string {
19591971 switch ( key ) {
19601972 case 'bin' :
@@ -2841,6 +2853,135 @@ class OpenOCDUploadModel extends UploadConfigModel<OpenOCDFlashOptions> {
28412853 }
28422854}
28432855
2856+ class ProbeRSUploadModel extends UploadConfigModel < ProbeRSFlashOptions > {
2857+
2858+ uploader : HexUploaderType = 'probe-rs' ;
2859+
2860+ GetKeyDescription ( key : string ) : string {
2861+ switch ( key ) {
2862+ case 'target' :
2863+ return view_str$flasher$targetName ;
2864+ case 'protocol' :
2865+ return view_str$flasher$interfaceType ;
2866+ case 'baseAddr' :
2867+ return view_str$flasher$baseAddr ;
2868+ case 'speed' :
2869+ return view_str$flasher$downloadSpeed ;
2870+ case 'allowEraseAll' :
2871+ return view_str$flasher$eraseAll ;
2872+ case 'otherOptions' :
2873+ return view_str$flasher$other_cmds ;
2874+ default :
2875+ return super . GetKeyDescription ( key ) ;
2876+ }
2877+ }
2878+
2879+ getKeyValue ( key : string ) : string {
2880+ switch ( key ) {
2881+ case 'bin' :
2882+ return ( < any > this . data ) [ key ] || '${ExecutableName}.elf' ;
2883+ case 'speed' :
2884+ return ( < any > this . data ) [ key ] > 0 ? `${ ( < any > this . data ) [ key ] } KHz` : 'default' ;
2885+ case 'allowEraseAll' :
2886+ return `${ ( < any > this . data ) [ key ] } ` ;
2887+ default :
2888+ return super . getKeyValue ( key ) ;
2889+ }
2890+ }
2891+
2892+ isKeyEnable ( key : string ) : boolean {
2893+ switch ( key ) {
2894+ case 'baseAddr' :
2895+ return / \. b i n \b / i. test ( this . data . bin ) ;
2896+ case 'allowEraseAll' :
2897+ return false ;
2898+ default :
2899+ return true ;
2900+ }
2901+ }
2902+
2903+ getKeyIcon ( key : string ) : KeyIcon | undefined {
2904+ switch ( key ) {
2905+ case 'target' :
2906+ return 'CPU_16x.svg' ;
2907+ case 'protocol' :
2908+ return 'ConnectUnplugged_16x.svg' ;
2909+ case 'baseAddr' :
2910+ return 'Property_16x.svg' ;
2911+ case 'otherOptions' :
2912+ return 'ImmediateWindow_16x.svg' ;
2913+ default :
2914+ return super . getKeyIcon ( key ) ;
2915+ }
2916+ }
2917+
2918+ protected GetKeyType ( key : string ) : FieldType {
2919+ switch ( key ) {
2920+ case 'target' :
2921+ case 'protocol' :
2922+ case 'allowEraseAll' :
2923+ return 'SELECTION' ;
2924+ case 'baseAddr' :
2925+ case 'otherOptions' :
2926+ return 'INPUT' ;
2927+ case 'speed' :
2928+ return 'INPUT_INTEGER' ;
2929+ default :
2930+ return super . GetKeyType ( key ) ;
2931+ }
2932+ }
2933+
2934+ protected VerifyString ( key : string , input : string ) : string | undefined {
2935+ switch ( key ) {
2936+ case 'baseAddr' :
2937+ return / ^ 0 x [ 0 - 9 a - f ] { 1 , 8 } $ / i. test ( input ) ? undefined : 'must be a hex number, like: 0x08000000' ;
2938+ default :
2939+ return super . VerifyString ( key , input ) ;
2940+ }
2941+ }
2942+
2943+ protected GetSelectionList ( key : string ) : CompileConfigPickItem [ ] | undefined {
2944+ switch ( key ) {
2945+ case 'target' :
2946+ return utility . probers_listchips ( ) . map ( inf => {
2947+ return {
2948+ label : inf . name ,
2949+ description : inf . series
2950+ }
2951+ } ) ;
2952+ case 'protocol' :
2953+ return [
2954+ { label : 'SWD' , val : 'swd' } ,
2955+ { label : 'JTAG' , val : 'jtag' }
2956+ ] ;
2957+ case 'allowEraseAll' :
2958+ return [
2959+ { label : 'true' , val : true } ,
2960+ { label : 'false' , val : false }
2961+ ] ;
2962+ default :
2963+ return super . GetSelectionList ( key ) ;
2964+ }
2965+ }
2966+
2967+ protected getEventData ( key : string ) : EventData | undefined {
2968+ return super . getEventData ( key ) ;
2969+ }
2970+
2971+ GetDefault ( ) : ProbeRSFlashOptions {
2972+ return {
2973+ bin : '' ,
2974+ target : 'STM32F103C8' ,
2975+ protocol : 'swd' ,
2976+ speed : 0 ,
2977+ baseAddr : '0x08000000' ,
2978+ allowEraseAll : false ,
2979+ otherOptions : ''
2980+ } ;
2981+ }
2982+ }
2983+
2984+
28442985class CustomUploadModel extends UploadConfigModel < CustomFlashOptions > {
28452986
28462987 uploader : HexUploaderType = 'Custom' ;
0 commit comments