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;
}
}
Code: Select all
void demo(client spi_master_if epd) {
out port * movable dcport_ptr = &dcport;
epd.init(dc, move(dcport_ptr), reset);
}