// BeaglePlay I/O resource definitions // Copyright (C)2025, Philip Munts dba Munts Technologies. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. using IO.Objects.SimpleIO.Device; using System.Data; namespace IO.Objects.SimpleIO.Platforms { /// /// This class defines identifiers for the devices provided by the /// BeaglePlay hardware platform. /// public static class BeaglePlay { private static readonly string OSNAME = System.Environment.GetEnvironmentVariable("OSNAME"); private static readonly bool MuntsOS = OSNAME is null ? false : OSNAME.Equals("MuntsOS"); /// /// User LED device pathname. /// /// USER_LED and LED_USR0 refer to the same LED. /// /// public const string USER_LED = "/dev/userled"; /// /// User LED 0 device pathname. /// /// LED_USR0 and USER_LED refer to the same LED. /// /// public const string LED_USR0 = "/dev/userled0"; /// /// User LED 1 device pathname. /// public const string LED_USR1 = "/dev/userled1"; /// /// User LED 2 device pathname. /// public const string LED_USR2 = "/dev/userled2"; /// /// User LED 3 device node. /// public const string LED_USR3 = "/dev/userled3"; /// /// User LED 4 device pathname. /// public const string LED_USR4 = "/dev/userled4"; /// /// User button GPIO input. /// /// The user button input is active low (pulled to ground when the /// button is pressed). /// /// public static readonly Designator USER_BUTTON = new Designator(2, 18); /// /// GPIO pin designator for mikroBUS socket AN pin. /// public static readonly Designator AN = new Designator(3, 10); /// /// GPIO pin designator for mikroBUS socket RST pin. /// public static readonly Designator RST = new Designator(3, 12); /// /// GPIO pin designator for mikroBUS socket CS pin. /// /// CS can only be used for GPIO if either the /// mikrobus-gpio.dtbo or the mikrobus-spi-gpio.dtbo /// device tree overlay has been applied. /// /// public static readonly Designator CS = new Designator(3, 13); /// /// GPIO pin designator for mikroBUS socket SCK pin. /// /// SCK can only be used for GPIO if either the /// mikrobus-gpio.dtbo or the mikrobus-spi-gpio.dtbo /// device tree overlay has been applied. /// /// public static readonly Designator SCK = new Designator(3, 14); /// /// GPIO pin designator for mikroBUS socket MISO pin. /// /// MISO can only be used for GPIO if either the /// mikrobus-gpio.dtbo or the mikrobus-spi-gpio.dtbo /// device tree overlay has been applied. /// /// public static readonly Designator MISO = new Designator(3, 7); /// /// GPIO pin designator for mikroBUS socket MOSI pin. /// /// MOSI can only be used for GPIO if either the /// mikrobus-gpio.dtbo or the mikrobus-spi-gpio.dtbo /// device tree overlay has been applied. /// /// public static readonly Designator MOSI = new Designator(3, 8); /// /// GPIO pin designator for mikroBUS socket PWM pin. /// /// PWM can only be used for GPIO if either the /// mikrobus-gpio.dtbo or the mikrobus-pwm-gpio.dtbo /// device tree overlay has been applied. /// /// public static readonly Designator PWM = new Designator(3, 11); /// /// GPIO pin designator for mikroBUS socket INT pin. /// public static readonly Designator INT = new Designator(3, 9); /// /// GPIO pin designator for mikroBUS socket RX pin. /// /// RX can only be used for GPIO if either the /// mikrobus-gpio.dtbo or the mikrobus-uart-gpio.dtbo /// device tree overlay has been applied. /// /// public static readonly Designator RX = new Designator(3, 24); /// /// GPIO pin designator for mikroBUS socket TX pin. /// /// TX can only be used for GPIO if either the /// mikrobus-gpio.dtbo or the mikrobus-uart-gpio.dtbo /// device tree overlay has been applied. /// /// public static readonly Designator TX = new Designator(3, 25); /// /// GPIO pin designator for mikroBUS socket SCL pin. /// /// SCL can only be used for GPIO if either the /// mikrobus-gpio.dtbo or the mikrobus-i2c-gpio.dtbo /// device tree overlay has been applied. /// /// public static readonly Designator SCL = new Designator(3, 22); /// /// GPIO pin designator for mikroBUS socket SDA pin. /// /// SDA can only be used for GPIO if either the /// mikrobus-gpio.dtbo or the mikrobus-i2c-gpio.dtbo /// device tree overlay has been applied. /// /// public static readonly Designator SDA = new Designator(3, 23); // Grove GPIO pins /// /// GPIO pin designator for Grove socket pin 1 (D0). /// /// D0 can only be used for GPIO if the grove-gpio.dtbio /// device tree overlay has been applied. /// /// public static readonly Designator D0 = new Designator(3, 28); /// /// GPIO pin designator for Grove socket pin 2 (D1). /// /// D1 can only be used for GPIO if the grove-gpio.dtbio /// device tree overlay has been applied. /// /// public static readonly Designator D1 = new Designator(3, 29); /// /// I2C bus designator for Grove socket I2C bus. /// public static readonly Designator I2C_GROVE = new Designator(0, 1); /// /// I2C bus designator for mikroBUS socket I2C bus. /// public static readonly Designator I2C_MIKROBUS = new Designator(0, 3); /// /// I2C bus designator for QWIIC socket I2C bus. /// public static readonly Designator I2C_QWIIC = new Designator(0, 5); // PWM outputs /// /// PWM output designator for Grove socket D0 pin. /// /// D0 can only be used for PWM if either the /// grove-motor1.dtbo or the grove-motor2.dtbo /// device tree overlay is applied. /// /// public static readonly Designator PWM_GROVE_D0 = new Designator(1, 0); /// /// PWM output designator for Grove socket D1 pin. /// /// D1 can only be used for PWM if either the /// grove-motor2.dtbo or the grove-motor3.dtbo /// device tree overlay is applied. /// /// public static readonly Designator PWM_GROVE_D1 = new Designator(1, 1); /// /// PWM output designator for mikroBUS socket PWM pin. /// public static readonly Designator PWM_MIKROBUS = new Designator(0, 0); /// /// SPI slave device designator for mikroBUS socket SPI bus. /// public static readonly Designator SPI_MIKROBUS = new Designator(0, 0); /// /// Console serial port (header J6) device pathname. /// /// The Debian Linux kernel enumerates serial ports differently /// than MuntsOS Embedded Linux. /// /// public static readonly string UART_CONSOLE = MuntsOS ? "/dev/ttyS0" : "/dev/ttyS2"; /// /// Grove socket serial port device pathname. /// /// Switching the Grove socket from I2C to a serial port /// requires applying the grove-serial.dtbo device tree overlay. /// Debian Linux for the BeaglePlay does not allow this because its /// kernel reserves the UART1 hardware subsystem for boot /// loader debugging. /// /// public static readonly string UART_GROVE = MuntsOS ? "/dev/ttyS1" : "/dev/nonexistent"; /// /// mikroBUS socket serial port device pathname. /// /// The Debian Linux kernel enumerates serial ports differently /// than MuntsOS Embedded Linux. /// /// public static readonly string UART_MIKROBUS = MuntsOS ? "/dev/ttyS5" : "/dev/ttyS0"; /// /// CC1352 Wireless Microcontroller serial port device pathname. /// /// The Debian Linux kernel enumerates serial ports differently /// than MuntsOS Embedded Linux. /// /// public static readonly string UART_CC1352 = MuntsOS ? "/dev/ttyS6" : "/dev/ttyS1"; } }