Since all implementations simply return 0 and most drivers do not check the return value, it is better to return void and use an assert to ensure that the given device identifier and given device parameters are correct.
The default driver type is just an index into a device array defined
by the board.
If a platform wants to encode additional information in the device type,
it can define a custom type.
This means we can just set the default type to whatever fits the target
CPU best.
On ARM this will still be a 32 bit word, but on AVR it will by a 8 bit byte.
It is often desireable to re-configure the pins of a bus back to GPIO mode,
either to save power when an external peripheral is turned off and current
would leak, or because a device may need a non-standard in-band signal to
be generated on the bus lines.
To serve those use cases, this patch introduces four new functions to the
I2C API:
- `i2c_init_pins()` equivalent to spi_init_pins(), restores I2C pin configuration
- `i2c_deinit_pins()` to switch the configuration of the I2C pins back to GPIO
mode and block access to the bus.
- `i2c_pin_sda()` to get the data pin for a given bus
- `i2c_pin_scl()` to get the clock pin for a given bus
Since it's unreasonable to expect having implementations for all platforms
already, those functions are only availiable when the periph_i2c_reconfigure
feature is availiable.
Applications should use FEATURES_REQUIRED += periph_i2c_reconfigure or
FEATURES_OPTIONAL if they want to make use of those functions.
i2c_release() should not have a return value, as:
- There is no reasonable error handling possible by the caller, so there is no
value in indicating success/failure via the return value to the caller
- There is no legitimate reason to fail *unless* an invalid I2C bus was released
or an I2C bus that was not previously acquired was released
--> This would indicate a bug in the code and should be tackled by an
assert()
The write_reg/s states a repeated start write is used but that is not how the i2c is implemeneted.
Most devices also only use a continuous write so the API should be changed to match implementation and the majority of sensors.
- added SPI_DEV and SPI_UNDEF macros
- made types and speed values overritable by CPU
- moved old device enum to dev_enums.h
- reformatted a little bit to comply to 80 char line length
- unify file/module @brief
- distinct @file section more visibly in source
- provide missing @brief's
- move module details/notes from file to module sections
- provide missing macro definition for building