@@ -0,0 +1,2238 @@
+/*%0A * Copyright 2011 - 2022 NTB University of Applied Sciences in Technology%0A * Buchs, Switzerland, http://www.ntb.ch/inf%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %0A * http://www.apache.org/licenses/LICENSE-2.0%0A *   %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A * %0A */%0A%0Apackage org.deepjava.runtime.zynq7000.microzed.driver;%0A%0Aimport org.deepjava.runtime.zynq7000.Izynq7000;%0Aimport org.deepjava.unsafe.arm.US;%0A%0A/**%0A * Driver to use the MIO pins on the MicroZed board as digital input or outputs.%3Cbr%3E%0A * %0A * The driver supports digital functions on MIO0, MIO9 .. MIO15.%3Cbr%3E%0A * Please make sure, that no other driver uses the same pins for alternative functions.%0A */%0Apublic class MIO_DIO implements Izynq7000 %7B%0A%09%0A%09/**%0A%09 * Initialize a MIO pin as digital I/O.%0A%09 * %0A%09 * @param channel Select pin 0, 9 .. 15%0A%09 * @param out Set I/O direction,%3Ccode%3Etrue%3C/code%3E =&gt;output, %3Ccode%3Efalse%3C/code%3E =&gt; input%0A%09 */%0A%09public static void init(int channel, boolean out) %7B%0A%09%09int reg = US.GET4(GPIO_DIR0);%0A%09%09if (out) reg %7C= (1 %3C%3C channel); else reg &= ~(1 %3C%3C channel); %0A%09%09US.PUT4(GPIO_DIR0, reg);%0A%09%09if (out) %7B%0A%09%09%09reg = US.GET4(GPIO_OUT_EN0);%0A%09%09%09reg %7C= (1 %3C%3C channel);%0A%09%09%09US.PUT4(GPIO_OUT_EN0, reg);%0A%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 * Read the digital value of the corresponding %3Ccode%3Echannel%3C/code%3E%0A%09 * %0A%09 * @param channel Select pin 0, 9 .. 15%0A%09 * @return Logical level of %3Ccode%3Echannel%3C/code%3E%0A%09 */%0A%09public static boolean in(int channel) %7B%0A%09%09int reg = US.GET4(GPIO_IN0);%0A%09%09return (reg & (1 %3C%3C channel)) == (1 %3C%3C channel);%0A%09%7D%0A%0A%09/**%0A%09 * Set the logical level %3Ccode%3Eval%3C/code%3E of the corresponding %3Ccode%3Echannel%3C/code%3E%0A%09 *  %0A%09 * @param channel Select pin 0, 9 .. 15%0A%09 * @param val Logical level%0A%09 */%0A%09public static void out(int channel, boolean val) %7B%0A%09%09int reg = ~(1 %3C%3C (16 + channel));%0A%09%09if (!val) reg &= 0xffff0000;%0A%09%09US.PUT4(GPIO_MASK_LSW0, reg);%0A%09%7D%0A%0A%7D%0A

Add support for digital IO on MIO pins