Accessing port in interface extension function

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
User avatar
ahenshaw
Experienced Member
Posts: 91
Joined: Mon Mar 22, 2010 8:55 pm

Accessing port in interface extension function

Postby ahenshaw » Wed Jan 23, 2019 7:03 pm

I am trying to extend the spi_master_if interface. My particular interface needs an additional data/command hardware port (dc_port), so I've added a sendCommand interface. Unfortunately, I can't seem to make the dc_port available to the interface extension.

I'm sure that I had this working in the past with a movable pointer, but the compiler is warning:
Taking the address of a resource handle, not the actual resource. Passing by (unsafe) value may be a better option [-Wunusual-code] and an exception is thrown at run-time.

Here's how I try to capture the port in the interface:

Code: Select all

extends client interface spi_master_if  : {
    void init(client spi_master_if self, DisplayContext & dc,
            out port * movable dc_port_ptr,
            out port reset) {
        dc.dc_port = move(dc_port_ptr);
    }

    // sendCommand uses the dc_port like so
    void sendCommand(client spi_master_if self,
                     DisplayContext & dc,
                     uint8_t command)
    {
        *dc.dc_port <: 0;
        self.transfer8(command);
        *dc.dc_port <: 1;
    }
}


and here is how I try to pass the port:

Code: Select all

void demo(client spi_master_if epd) {
    out port * movable dcport_ptr = &dcport;
    epd.init(dc, move(dcport_ptr), reset);

}

Who is online

Users browsing this forum: No registered users and 1 guest