Hi, All,
I am wrting a programe to control a group of stepper motors and each motor requires 4 wires (CLK, ENaBle, DIRection, FULlstep).
Now I havev to define the DigitalOut pins as follows:
DigitalOut clk1(p21);
DigitalOut enb1(p23);
DigitalOut dir1(p25); / / 0 clockwise, 1 anti-clockwise
DigitalOut ful1(p27);
DigitalOut clk2(p22);
DigitalOut enb2(p24);
DigitalOut dir2(p26); / / 0 clockwise, 1 anti-clockwise
DigitalOut ful3(p28);
In the program, I have to repeat the samilar codes several times.
I wonder if it is allowed to define an array of DigitalOut, something like
DigitalOut clk[2](p21,p22);
DigitalOut enb[2](p23, p24);
Thus I can reuse the codes by access the I/O pins by index, rather by the name. e.g. clk[0] will be p21, clk[1] will be p22.
However, compiling the codes above reports errors:
'A value of type "PinName" cannot be used to initilize an entity of type mbed::DigitalOut[2]'
Is there any construction function of DigitalOut to get this job done? Any comments are apprecaited indeed.
Dan
Hi, All,
I am wrting a programe to control a group of stepper motors and each motor requires 4 wires (CLK, ENaBle, DIRection, FULlstep).
Now I havev to define the DigitalOut pins as follows:
In the program, I have to repeat the samilar codes several times.
I wonder if it is allowed to define an array of DigitalOut, something like
Thus I can reuse the codes by access the I/O pins by index, rather by the name. e.g. clk[0] will be p21, clk[1] will be p22.
However, compiling the codes above reports errors:
'A value of type "PinName" cannot be used to initilize an entity of type mbed::DigitalOut[2]'
Is there any construction function of DigitalOut to get this job done? Any comments are apprecaited indeed.
Dan