Skip to content

spi/pin: how should we handle calls to Configure() inside drivers? #206

@deadprogram

Description

@deadprogram

In the case of the I2C interface, since no driver calls the I2C Configure() method, we did not have any troubles refactoring all the I2C drivers to use the interface.

However in the case of both the SPI and the Pin objects passed to the New() function , some of the drivers then go on to call the Configure() method.

For example: https://github.com/tinygo-org/drivers/blob/release/flash/transport_spi.go#L54

Since Confgure() expects a concrete type as param here, it becomes difficult to then replace the call with an interface that does not depend on the machine package.

What should we do about this?

One option would be to expect any configuration to already be done and hence to not allow any drivers to call Configure().

Another would be to refactor the machine package itself to expect a pointer so that we can define Configure(interface{}) in the drivers.SPI interface.

Any other ideas on how to handle this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions