1 // 2 // Copyright (c) 2010-2018 Antmicro 3 // Copyright (c) 2011-2015 Realtime Embedded 4 // 5 // This file is licensed under the MIT License. 6 // Full license text is available in 'licenses/MIT.txt'. 7 // 8 using System.Collections.Generic; 9 10 namespace Antmicro.Renode.Core 11 { 12 public interface IGPIO 13 { 14 bool IsSet { get; } Set(bool value)15 void Set(bool value); 16 // TODO: this method could be simulated by calling <<Set(!IsSet)>>, but this requires locking ... Toggle()17 void Toggle(); 18 19 bool IsConnected { get; } Connect(IGPIOReceiver destination, int destinationNumber)20 void Connect(IGPIOReceiver destination, int destinationNumber); Disconnect()21 void Disconnect(); Disconnect(GPIOEndpoint endpoint)22 void Disconnect(GPIOEndpoint endpoint); 23 24 IList<GPIOEndpoint> Endpoints { get; } 25 } 26 27 public static class IGPIOExtensions 28 { Set(this IGPIO gpio)29 public static void Set(this IGPIO gpio) 30 { 31 gpio.Set(true); 32 } 33 Unset(this IGPIO gpio)34 public static void Unset(this IGPIO gpio) 35 { 36 gpio.Set(false); 37 } 38 Blink(this IGPIO gpio)39 public static void Blink(this IGPIO gpio) 40 { 41 gpio.Set(); 42 gpio.Unset(); 43 } 44 } 45 } 46 47