how to define my own function in my block.tlc?

2 views (last 30 days)
hello,everyone,i am developing blocks with S-function and tlc files, i need to write my own function in the block.tlc file. i don't know how to write it,can anybody help me ? thanks in advance The block.tlc file is like this:
%implements mpc5634_sci "C"
%function BlockTypeSetup(block, system) void
%assign scia_dfm_idx = CAST("Number",SFcnParamSettings.scia_dfm)
%assign scib_dfm_idx = CAST("Number",SFcnParamSettings.scib_dfm)
%switch scia_dfm_idx
%case 1
%assign scia_dfm = 8
%break
%case 2
%assign scia_dfm = 9
%break
%case 3
%assign scia_dfm = 12
%break
%case 4
%assign scia_dfm = 13
%break
%endswitch
%switch scib_dfm_idx
%case 1
%assign scib_dfm = 8
%break
%case 2
%assign scib_dfm = 9
%break
%case 3
%assign scib_dfm = 12
%break
%case 4
%assign scib_dfm = 13
%break
%endswitch
%openfile tmp
/************************SCI***************************************************/
#define SCIA_FORMATMODE_MD (U08)%<scia_dfm>
#define SCIB_FORMATMODE_MD (U08)%<scib_dfm>
%closefile tmp
%assign cFile = LibCreateSourceFile("Header", "Custom", "interfunc_cfg")
%<LibSetSourceFileSection(cFile, "Defines", tmp)>\
%endfunction
i want to take the following part out of this function,and define a new function for it. how should i write the function? i've searched it for several times, but i still can't get it.
%switch scia_dfm_idx
%case 1
%assign scia_dfm = 8
%break
%case 2
%assign scia_dfm = 9
%break
%case 3
%assign scia_dfm = 12
%break
%case 4
%assign scia_dfm = 13
%break
%endswitch

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!