Within a C++ file I include i2c.h and got 6 of the following errors:
zephyr/include/i2c.h:199:42: error: invalid conversion from
‘const void*’ to ‘const i2c_driver_api*’ [-fpermissive]
const struct i2c_driver_api *api = dev->driver_api;
~~~~~^~~~~~~~~~
I fixed it with a c style conversion for each instance, so
const struct i2c_driver_api *api = dev->driver_api;
becomes
const struct i2c_driver_api *api =
(const struct i2c_driver_api *)dev->driver_api;
I handled the instances for i2c_slave_driver_api alike.
I tested this with a one of my own boards and communication with a
I2C sensor.
Signed-off-by: Alexander Polleti <metapsycholo@gmail.com>
This commit adds I2C_MSG_ADDR_10_BITS flag, while keeping
I2C_ADDR_10_BITS for backward compatibility.
I2C_ADDR_10_BITS flag should be removed as soon as all drivers
are modified to use message flag.
Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This patchs adds new I2C Syscalls for :
- I2C controllers slave support
- I2C Slave drivers support
I2C Controllers slave support adds 2 new ops to :
- register new slave driver
- unregister slave driver
Slave funcs consists on all the I2C phases :
- read or write request once address matches
- read or write done once the byte has been received/sent
- stop when the trasmit stops
I2C Slave drivers syscall are also added to make new
"I2C Slave" drivers to :
- register them to their I2C controller
- unregister them to their I2C controller
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Type of num_bytes unnecessarily limits number of possible
bytes in the burst transmissions. Replace num_bytes type
u8_t with u32_t.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
i2c actually only has two entry points into the driver,
i2c_configure and i2c_transfer. All the other APIs are derived
from these.
All derived APIs now just call i2c_transfer() with appropriate args.
The handler for i2c_transfer() needs to examine the message array
and validate all the buffers involved depending on whether we are
reading or writing to them.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
There are several issues with the dev_config union used as a
convenience when calling the i2c_configure api. One, the union is well
name spaced protected and doesn't convey use with just i2c. Second
there are assumptions of how the bits might get packed by the union
which can't be guaranteed. Since the API takes a u32_t lets change in
tree uses to using the macros to setup a u32_t and make the union as
deprecated.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Cleanup I2C drivers to not use bitfield access for config information
and instead use accessor macros that use shifts & masks. This is
cleanup towards removing the bitfield access in the future.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Added a define to use in code that provides the amount we need to shift
the speed settings in the i2c config params.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
The I2C Slave Read support isn't well defined and not actually supported
by any i2c driver at this point. We can add this back when slave mode
is more thought out.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types. This handles the remaining includes and kernel, plus
touching up various points that we skipped because of include
dependancies. We also convert the PRI printf formatters in the arch
code over to normal formatters.
Jira: ZEP-2051
Change-Id: Iecbb12601a3ee4ea936fd7ddea37788a645b08b0
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t. This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.
We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.
We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.
Jira: ZEP-2051
Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
The current I2C API provides inline functions to access 1 byte
register addresses. This commit adds a set of I2C inline functions
as shortcuts to handle:
- 16 bit register addressing. A family of functions that allows to
handle 2 byte register addressing and can receive the address
parameter as a simple variable. This allows a developer to handle
the address as a C constant or macro.
- Multiple byte addressing. A family of functions to access
registers with a configurable register address size. This family
of functions handle register addressing of any size but receives
the address parameter as a byte array.
Change-Id: Id369ab9eaad7eea807554371d3a520f67dc2e0f2
Signed-off-by: Juan Manuel Cruz Alcaraz <juan.m.cruz.alcaraz@intel.com>
Elaborate the i2c API documentation with each of the errno codes that
can be returned on failure.
Change-Id: I28a690c06b94f724053238b5eba3142fcace23f6
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Remove stride[] definition from public API, this definition is not
used by any driver and appears to serve no purpose.
Change-Id: Ib7c9ad4a8e7e17884d150ee811b66db0279d0b33
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
The I2C drivers handle an empty list of I2C messages inconsistenty.
There are two different behaviours, one set of drivers dectects a
requests to transfer zero messages and return -EINVAL while the other
group simple transfer no data and return success.
Adopt the latter behaviour consistently across all drivers. Update
the i2c.h API documentation to reflect this behaviour.
Change-Id: I427fc1b0e18ddc04b7b59c294e0240b3d6ca4073
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.
Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.
Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file. Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.
Jira: ZEP-1457
Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
The i2c_burst_read function transfers two messages to the I2C device.
The first message writes the internal address of the device, the second
message then reads bytes. A repeated start (restart) is needed to change
the direction from write to read, but the restart flag should be set in
the second message rather than the first.
Change-Id: I7d48de2f4866e3b514f689f41ce5d28eba90c39f
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
Drivers that implement power management should use the preferred
device_pm_ops method instead.
Change-Id: I9ae06e26b77325265bbe46bdee82ba39dedb6b79
Signed-off-by: Iván Briano <ivan.briano@intel.com>
Add some macros that drivers and applications can use in describing I2C
clients.
Change-Id: Ic7af97804e88ed3b9d4f68f9ac358a425f4cc17c
Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
Fix with a workaround in unnamed unions / structs in bluetooth, i2c,
sensor and uart.
Current documentation parsers (sphinx under Doxygen) don't seem to
understand well unnamed structs / unions. They will not generate any
documentation for any documented members (see left side of
http://imgur.com/mcpBXWc).
A workaround is to make the parser think there is something like a
struct/union/enum name that is actually something with no effect to
the compiler.
Naming it with __unnamed_workaround__ ensures it is clear it is a
workaround while we wait for a final fix. It is #defined to be a NO-OP
to the compiler and rearrange the member documentation as *@param* so
we have some documentation that the non-worked around code fails to
document.
Anonymous structs/union that declare a variable are just given an
internal name.
Workarounds documented in the contribution guidelines.
Change-Id: I4d32cf444f3c5e7d2fb11581e4b41f80e93c9786
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
Swap order of mask and value parameters from i2c_reg_update_byte
function. This is needed make refactoring of sensor drivers that
would use this function easier, since all the register update
functions written for each driver have the mask before the value
in the parameter list.
Change-Id: I7bef7be73e904fca353a492ab9edd2a210df199e
Signed-off-by: Bogdan Davidoaia <bogdan.m.davidoaia@intel.com>
The device address must be given before the register address in the
parameter list of the i2c_reg_read_byte function.
Change-Id: I92afbbf83f76eeb58ec41a2a8c83dd909b78a23a
Signed-off-by: Bogdan Davidoaia <bogdan.m.davidoaia@intel.com>
Add API for reading, writing and updating internal registers of I2C
devices. This API is meant to be used as a simpler way of communicating
with I2C devices that have 8-bit internal registers.
Change-Id: I7280eb530039aa10ad9cc19c1c309c7a2f473eb4
Signed-off-by: Bogdan Davidoaia <bogdan.m.davidoaia@intel.com>
This patch fixes the remaining APIs documentation which have reference
to DEV_* codes.
Change-Id: I26dd971a4b5e492ce026892f6262b84f7bde6296
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
This patch replaces all occurences of the macro DEV_OK by the actual
value 0 at the driver level. So this patch touch the files under
drivers/, include/ and samples/drivers/.
This patch is part of the effort to transition from DEV_* codes to
errno.h codes.
Change-Id: I69980ecb9755f2fb026de5668ae9c21a4ae62d1e
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
() Add brief descriptions for #defines.
() Remove the callback enums as they are not being used.
() Hides internal only API typedefs and struct.
Change-Id: I62bc38890a7b49b3ec613064f7574e2f5b75b70c
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Edit public API details for clarity, grammar, punctuation found
on file i2c.h
Made consistent use of @retval to document return values.
Used imperative verbs for all @brief descriptions.
Change-Id: I87b262f6ab91a83f429b7f7d9152914b92e11c8a
Signed-off-by: Rodrigo Caballero <rodrigo.caballero.abraham@intel.com>
Looking at all structs as to where we can pack them a little better, and
calling out the padding/stride at the end for future expansion.
Change-Id: I4a651092e950dd3d915af9fa0ee0d7d59803e58f
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This patch changes i2c_write and i2c_read APIs so they explicitly set
the I2C_MSG_STOP flag to their message to ensure that the I2C operation
is actually terminated once that message is sent.
Change-Id: Iea4da35b49ed01bee906679dece8638057d509ff
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
Make the i2c_transfer() to transact messages through the I2C bus.
It is useful for I2C storage devices, as now we can send one message
containing the destination byte/block address, then send the data
in another message. There is no need to construct one continuous
data buffer to send both address and data anymore.
The drivers and sample apps have been updated to utilize updated
API when appropriate. For i2c_dw, only master mode has been updated.
Slave mode will be updated once we can adequately test it.
Change-Id: I0a811d60567367817fcc8d15f5454e5c933722e2
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Now that i2c is fully synchronous on top of an interrupt based
implementation, polling mode can be removed. Applying the API change
into the existing drivers.
Change-Id: I05d2a6089743b6b69f7c9da6312057134578e2f7
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Change all the Intel and Wind River code license from BSD-3 to Apache 2.
Change-Id: Id8be2c1c161a06ea8a0b9f38e17660e11dbb384b
Signed-off-by: Javier B Perez Hernandez <javier.b.perez.hernandez@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
With the introduction of generic transfer function, it is no longer
needed to specify read or write functions explicitly in drivers.
All read/write functions can now thus call the generic transfer
function to achieve the same result.
With this change, the transfer function becomes mandatory, and
should always be available.
Change-Id: Ia6fb98e58b84330a56a5d44ed3df9db42c3a5e88
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Add an API to I2C for generic transfer. This is for those data
transactions which are more complex than simple read or write.
One example use of this is to read register data from a slave
device. The master has to write the address of the register
to slave, then start reading from slave for register data.
In this situation, simple read or write is no longer
sufficient, as for some slave devices, they require RESTART
when data transfer direction changes. Doing a simple write via
i2c_write() results in STOP at end of transfer, which results
in the slave not responding to read request as it is not
expected to send anything back.
Change-Id: I22f9c5ba2f7a7c48a33b9cb1aaf559e596a85d39
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Thus the caller will be noticed once its read and/or write calls have
gone through.
Taking the opportunity to fix the documentation about return code.
Change-Id: Id3f588fab978cad4393583f26509a9e91dcc8be2
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Adding in documentation for the return values of the I2C functions.
Change-Id: I89d4a6918f860a0ac34f6905e6f9bba77158f1ff
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
There are instances where interrupts cannot be used for I2C transfer.
So add an API to do trasnfer in polling manner.
Change-Id: Ic030ef9469542aae9975aa7da55c578a2a6c5c93
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The public interface has been found to need a few additional
changes, and a few clean ups to functionally work with an IP block.
- Removing the faulty (0 << x) defines.
- Updating the write/read functions to take the destination address
- Adding in a union and struct for the dev_config access
Change-Id: I4820aa64a96180ca46daac94113b04a4ca1bc84a
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
When compiling with optimization level 0 (-O0), the linker complains
about missing references to uart functions. This is due to compiler
treating this functions as extern, since -O0 disables function inlining,
as described in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49653
So change the declaration to static inline.
Change-Id: I5963153dc1efd22083b6b91ae2b70c11d602c6c6
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Change all occurances of /*! to /** to match javadoc
style.
Change-Id: I3a759d34e0e928216f61252682266e64c5b875f8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This header defines the public API for I2C drivers and the I2C
driver interface.
Change-Id: I7ed19c0f2a13a34bbaf35b50b648b73b5570bbd7
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>