@@ -228,3 +228,139 @@ int8_t FSMGoXYCommand(char const* Name, char const* Params, const size_t ParamsL
228228
229229 return (ParamsLen);
230230}
231+
232+ int8_t ControlRegisterCommand (char const * Name, char const * Params, const size_t ParamsLen, const void * Argument)
233+ {
234+ CGraphFSMHardwareControlRegister cr;
235+ char c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17;
236+ bool o1=false , o2=false , o3=false , o4=false , o5=false , o6=false , o7=false , o8=false , o9=false , o10=false , o11=false , o12=false , o13=false , o14=false , o15=false , o16=false , o17=false ;
237+
238+ if (NULL == FSM)
239+ {
240+ formatf (" \n ControlRegisterCommand: Fpga interface is not initialized!" );
241+ return (ParamsLen);
242+ }
243+
244+ int8_t numfound = sscanf (Params, " %c, %c, %c, %c, %c, %c, %c, %c, %c, %c, %c, %c, %c, %c, %c, %c, %c" , &c1, &c2, &c3, &c4, &c5, &c6, &c7, &c8, &c9, &c10, &c11, &c12, &c13, &c14, &c15, &c16, &c17);
245+ if (numfound >= 1 )
246+ {
247+ if ( (' Y' == c1) || (' y' == c1) || (' T' == c1) || (' t' == c1) || (' 1' == c1) ) { o1 = true ; }
248+ if ( (' Y' == c2) || (' y' == c2) || (' T' == c2) || (' t' == c2) || (' 1' == c2) ) { o2 = true ; }
249+ if ( (' Y' == c3) || (' y' == c3) || (' T' == c3) || (' t' == c3) || (' 1' == c3) ) { o3 = true ; }
250+ if ( (' Y' == c4) || (' y' == c4) || (' T' == c4) || (' t' == c4) || (' 1' == c4) ) { o4 = true ; }
251+ if ( (' Y' == c5) || (' y' == c5) || (' T' == c5) || (' t' == c5) || (' 1' == c5) ) { o5 = true ; }
252+ if ( (' Y' == c6) || (' y' == c6) || (' T' == c6) || (' t' == c6) || (' 1' == c6) ) { o6 = true ; }
253+ if ( (' Y' == c7) || (' y' == c7) || (' T' == c7) || (' t' == c7) || (' 1' == c7) ) { o7 = true ; }
254+ if ( (' Y' == c8) || (' y' == c8) || (' T' == c8) || (' t' == c8) || (' 1' == c8) ) { o8 = true ; }
255+ if ( (' Y' == c9) || (' y' == c9) || (' T' == c9) || (' t' == c9) || (' 1' == c9) ) { o9 = true ; }
256+ if ( (' Y' == c10) || (' y' == c10) || (' T' == c10) || (' t' == c10) || (' 1' == c10) ) { o10 = true ; }
257+ if ( (' Y' == c11) || (' y' == c11) || (' T' == c11) || (' t' == c11) || (' 1' == c11) ) { o11 = true ; }
258+ if ( (' Y' == c12) || (' y' == c12) || (' T' == c12) || (' t' == c12) || (' 1' == c12) ) { o12 = true ; }
259+ if ( (' Y' == c13) || (' y' == c13) || (' T' == c13) || (' t' == c13) || (' 1' == c13) ) { o13 = true ; }
260+ if ( (' Y' == c14) || (' y' == c14) || (' T' == c14) || (' t' == c14) || (' 1' == c14) ) { o14 = true ; }
261+ if ( (' Y' == c15) || (' y' == c15) || (' T' == c15) || (' t' == c15) || (' 1' == c15) ) { o15 = true ; }
262+ if ( (' Y' == c16) || (' y' == c16) || (' T' == c16) || (' t' == c16) || (' 1' == c16) ) { o16 = true ; }
263+ if ( (' Y' == c17) || (' y' == c17) || (' T' == c17) || (' t' == c17) || (' 1' == c17) ) { o17 = true ; }
264+
265+ cr.PowerCycdAndClr = o1;
266+ cr.PowernEn = o2;
267+ cr.ChopEn = o3;
268+ cr.ChopRefState = o4;
269+ cr.ChopAdcState = o5;
270+ cr.Uart0OE = o6;
271+ cr.Uart1OE = o7;
272+ cr.Uart2OE = o8;
273+ cr.Uart3OE = o9;
274+ cr.Ux1SelJmp = o10;
275+ cr.PPSDetectedAndRst = o11;
276+ cr.PowernEnHV = o12;
277+ cr.HVEn1 = o13;
278+ cr.HVEn2 = o14;
279+ cr.DacSelectMaxti = o15;
280+ cr.GlobalFaultInhibit = o16;
281+ cr.nFaultsClr = o17;
282+
283+ FSM->ControlRegister = cr;
284+ }
285+
286+ cr = FSM->ControlRegister ;
287+
288+ formatf (" \n ControlRegisterCommand: Current values: " );
289+ cr.formatf ();
290+
291+ return (strlen (Params));
292+ }
293+
294+ int8_t ConfigAdcCommand (char const * Name, char const * Params, const size_t ParamsLen, const void * Argument)
295+ {
296+ AdcConfigRegister cr;
297+ AccumulatorConfigRegister ar;
298+ unsigned long A = 0 , B = 0 , C, D;
299+
300+ if (NULL == FSM)
301+ {
302+ formatf (" \n\n ConfigAdc: Fpga interface is not initialized! Please call InitFpga first!." );
303+ return (ParamsLen);
304+ }
305+
306+ // Convert parameters
307+ int8_t numfound = sscanf (Params, " %lu,%lu,%lu,%lu" , &A, &B, &C, &D);
308+ if (numfound >= 2 )
309+ {
310+ cr.AdcClkDivider = A;
311+ cr.AdcSamplesToAverage = B;
312+ formatf (" \n\n ConfigAdc: setting AdcConfig to: " );
313+ cr.formatf ();
314+ formatf (" \n " );
315+ FSM->AdcConfig = cr;
316+ }
317+ if (numfound >= 4 )
318+ {
319+ ar.ControlAdcMaxAccums = C;
320+ ar.MonitorAdcMaxAccums = D;
321+ formatf (" \n\n ConfigAdc: setting AccumConfig to: " );
322+ ar.formatf ();
323+ formatf (" \n " );
324+ FSM->AccumConfig = ar;
325+ }
326+
327+ cr = FSM->AdcConfig ;
328+ ar = FSM->AccumConfig ;
329+ formatf (" \n\n ConfigAdc: current values: " );
330+ cr.formatf ();
331+ formatf (" ; " );
332+ ar.formatf ();
333+ formatf (" \n " );
334+
335+ return (ParamsLen);
336+ }
337+
338+ int8_t ConfigDacCommand (char const * Name, char const * Params, const size_t ParamsLen, const void * Argument)
339+ {
340+ DacConfigRegister cr;
341+ unsigned long A = 0 ;
342+
343+ if (NULL == FSM)
344+ {
345+ formatf (" \n\n ConfigDacCommand: Fpga interface is not initialized! Please call InitFpga first!." );
346+ return (ParamsLen);
347+ }
348+
349+ // Convert parameters
350+ int8_t numfound = sscanf (Params, " %lu" , &A);
351+ if (numfound >= 1 )
352+ {
353+ cr.DitherClkDivider = A;
354+ formatf (" \n\n ConfigDacCommand: setting DacConfig to: " );
355+ cr.formatf ();
356+ formatf (" \n " );
357+ FSM->DacConfig = cr;
358+ }
359+
360+ cr = FSM->DacConfig ;
361+ formatf (" \n\n ConfigDacCommand: current values: " );
362+ cr.formatf ();
363+ formatf (" \n " );
364+
365+ return (ParamsLen);
366+ }
0 commit comments