Skip to content

903 Pins, Ranges, And Indexed Names ​

903-pins-ranges-indexed-names.mc covers pin directions, physical pin ranges, and indexed pin names. Tutorial first use: 03-define-components-and-interfaces for directions and ranges; 05-dynamic-pins-and-conditions for indexed pin expansion.

Syntax synopsis:

text
pins = [
    io [1:4] = GPIO[0:3]
    psnk [5,6] = [VCC, GND]
]
bash
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 90-language-reference/903-pins-ranges-indexed-names.mc --lib mcode --pass1 --pass2

Source ​

text
// Reference: Pins, Ranges, And Indexed Names
// Focus: pin directions, physical pin ranges, and indexed pin names.

component REF_GPIO_HEADER
{
    name = "Reference GPIO Header"
    pins = [
        io [1:4] = GPIO[0:3]
        psnk [5,6] = [VCC, GND]
    ]
}

module main
{
    io GND
    io GPIO0
    io GPIO1
    io GPIO2
    io GPIO3
    io V3V3

    DC.SRC PWR(3.3V, 20mA)
    REF_GPIO_HEADER J_GPIO

    PWR.1 -> V3V3
    PWR.2 -> GND
    V3V3 -> J_GPIO.VCC
    J_GPIO.GND -> GND

    J_GPIO.GPIO0 -> GPIO0
    J_GPIO.GPIO1 -> GPIO1
    J_GPIO.GPIO2 -> GPIO2
    J_GPIO.GPIO3 -> GPIO3
}

MCode Bench is the public face of the MCode stack. Closed capabilities are served through the MCode gateway.