aboutsummaryrefslogtreecommitdiff
path: root/module/i2c/doc/module_i2c_architecture.md
blob: cca5ebd39491add5f3ac6d1a33ae2ae8e5c9c184 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
\ingroup GroupI2C
Module I2C Architecture
=======================

# Overview                                   {#module_i2c_architecture_overview}

This module implements a Hardware Abstraction Layer (HAL) API for I2C
transactions.

# Architecture                           {#module_i2c_architecture_architecture}

The I2C module provides an interface for modules to transmit data through an I2C
bus, to receive data from an I2C bus and to perform a transmission followed by a
reception on the I2C bus.

The I2C module defines a driver interface on which it relies to transfer/receive
data to/from the bus.

A response event notifies the caller of the transaction completion.

# Restriction                             {#module_i2c_architecture_restriction}

The following features are unsupported. Support may be added in the future.

- Acting like a slave.
- Concurrent accesses over the bus.
- 10-bit slave addressing.

# Flow                                           {#module_i2c_architecture_flow}

The following schematic describes the transaction flow for an I2C master
transmission. The flow for a reception is similar.

    Client             I2C         I2C Driver     I2C ISR (Driver)
      |                 |               |               |
      |    transmit_    |               |               |
     +-+   as_master    |               |               |
     | +-------------->+-+              |               |
     | |               | +- - +         |               |
     | +<--------------+-+    |process_ |               |
     +-+                |     |event E1 |               |
      |                 |     |         |               |
      |                +-+<- -+         |               |
      |                | |  transmit_   |               |
      |                | |  as_master   |               |
      |                | +------------>+-+              |
      |                | +<------------+-+              |
      |                +-+              |               |
      |                 |               |  transaction +-+
      |                 |               |  _completed  | |
      |                +-+<-------------+--------------+ |
      |            +- -+ |              |              | |
      |  process_  |   +-+--------------+------------->+ |
      |  event E2  |    |               |              | |
      |            +- >+-+              |              +-+
      |                | |              |               |
     +-+<- - - - - - - +-+              |               |
     +-+  process_      |               |               |
      |   event R1      |               |               |

    E1   : Request event
    E2   : Request completed event
    R1   : Response to the request event E1
    ---> : Function call/return
    - -> : Asynchronous call via the event/notification interface

The client calls *transmit_as_master* API of the I2C module.
This function creates and sends the targeted I2C device request event which
defines the targeted slave on the bus and the data to be transmitted. When
processing the request event, the I2C module initiates the transfer by
programming the I2C controller through the *transmit_as_master* API of the I2C
driver.

An interrupt is asserted when the I2C transaction either completes or encounters
an error. The I2C ISR calls the *transaction_completed* API of the I2C HAL
module which sends a response event to indicate that transaction completed to
the client.

In the case of *transmit_then_receive_as_master*, the I2C HAL does not send a
event at the end of the transmission. Instead it starts the reception by calling
*receive_as_master* driver function. The event is then sent when the reception
has completed.