CloudSevenConsulting / DustyDuinoPro

ATAMO Dusty Project
MIT License
0 stars 0 forks source link

DuinoPro Module/Pin not functional #14

Open ghost opened 6 years ago

ghost commented 6 years ago

Issue

Can't get the Module.h and Pin.h pieces working

What I tried

Building on commit bfd7d0070a9568eb76d0be07c03f8a45a82c76eb; toggling Pin 3 on Module 7 (UART_RTS) in the main while(1) body alongside the Board's LED

What Happened

The LED stayed on the whole time when the pin toggle function port_rts_set() was used in the body. When the function was taken out, the LED blinked as expected

ghost commented 6 years ago

Basic Testing (Confirm Board is Working)

Did not use and DuinoPro code (relied on Arduino libraries)

void port_init(void)
{
    pinMode(A1, OUTPUT); // M6P1
}

void port_test_set(int value)
{

    if (value)
    {
        digitalWrite(A1, HIGH);
    }
    else
    {
        digitalWrite(A1, LOW);
    }
}

Worked as expected

ghost commented 6 years ago

Note that removing the port_init above does not do anything to the functionality of the above code.

ghost commented 6 years ago

Failure at Write

Continuing from the basic version (Basic Testing) in the above comments; when the pinMode setup in port_init() is replaced as follows:

Pin m6p1(6, 1);

void port_init(void)
{
    m6p1.mode(OUTPUT);
}

There is no issue.

But when we replace the digitalWrite in the set function;

void port_rts_set(int value)
{

    if (value)
    {
        m6p1.write(HIGH);
    }
    else
    {
        m6p1.write(LOW);
    }
}

No change on the pin can be detected (but during the loop, the on-board LED still flashes, indicating the program is not 'stuck')

ghost commented 6 years ago

Hypothesis: Incorrect Pin-Mapping

_id = moduleSignalToPin(6, 1);
_id = 6;//equivalent to above

Confirmed incorrect pin mapping;

In Pin.cpp, replaced all _id attribute occurrences with A1 (correct pin label for M6P1) and got correct feedback.

ghost commented 6 years ago

Amendments to Prev Comment

Turns out the DuinoPro library has been overloading the Arduino functions digitalWrite and pinMode with their own functions in wiring_digital.h....

Not sure if they handled scope resolution correctly (hence the ::digitalWrite etc.)