]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/Driver/src/Driver_I2C.c
Corrected Signal event Bit in function ARM_I2C_SignelEvent
[cmsis] / CMSIS / DoxyGen / Driver / src / Driver_I2C.c
1 /* -----------------------------------------------------------------------------
2  * Copyright (c) 2013-2014 ARM Limited. All rights reserved.
3  *  
4  * $Date:        2. January 2014
5  * $Revision:    V2.00
6  *  
7  * Project:      I2C Driver API
8  * -------------------------------------------------------------------------- */
9
10
11 /**
12 \defgroup i2c_interface_gr I2C Interface
13 \brief    Driver API for I2C Bus Peripheral (%Driver_I2C.h)
14 \details
15
16 I<sup>2</sup>C (Inter-Integrated Circuit, referred to as I-squared-C, I-two-C, or IIC) is a multi-master serial single-ended bus and is mostly used 
17 on single boards, but can also connect to components which are linked via cable. 
18
19 Most significant features of the I<sup>2</sup>C bus include:
20  - Only two bus lines are required
21  - I<sup>2</sup>C is a true multi-master bus. Simple master/slave relationships exist between all components
22  - A baud rate is not required; the master device determines a bus clock
23  - Each connected device is addressable by a unique address
24  - Providing arbitration and collision detection
25
26 For more information about I<sup>2</sup>C refer to the following web pages:
27   - Wikipedia: <a href="http://en.wikipedia.org/wiki/I%C2%B2C" target="_blank">I<sup>2</sup>C</a>
28   - <a href="http://www.i2c-bus.org" target="_blank">www.i2c-bus.org</a>.
29
30 Devices can operation in Master or Slave mode:
31
32  - To operate in Master mode call the functions \ref ARM_I2C_MasterTransmit or \ref ARM_I2C_MasterReceive. These functions get as argument a <em>slave address</em>. 
33  
34  - To operate in Slave mode set the <em>slave address</em> using the function \ref ARM_I2C_Control. The functions \ref ARM_I2C_SlaveTransmit or \ref ARM_I2C_SlaveReceive are used to transfer data in Slave mode.
35
36 **I<sup>2</sup>C Slave Address**
37  
38 Depending on the device, I<sup>2</sup>C supports 7-bit and 10-bit Slaves addresses. 
39 The element <em>address_10_bit</em> in \ref ARM_I2C_CAPABILITIES indicates that the driver is able to handle 10-bit addresses.
40 A 10-bit Slave address is ORed with \ref ARM_I2C_ADDRESS_10BIT.
41  
42 I<sup>2</sup>C also supports a General Call to all Slaves by using the slave address value \token{0}.
43 A General Call is recognized by Slaves have a slave address value \ref ARM_I2C_ADDRESS_GC registered with the 
44 function \ref ARM_I2C_Control.
45
46 **Block Diagram**
47
48 The I2C driver allows you to connect low-speed peripherals to a motherboard, embedded system, cellphone, or other electronic device. 
49
50 \image html I2C_BlockDiagram.png  "Master/Slave connected via I2C interface"
51
52
53 **I<sup>2</sup>C API**
54
55 The following header files define the Application Programming Interface (API) for the I<sup>2</sup>C interface:
56   - \b %Driver_I2C.h : Driver API for I2C Bus Peripheral
57
58 The driver implementation is a typical part of the Device Family Pack (DFP) that supports the 
59 peripherals of the microcontroller family.
60
61
62 **Driver Functions**
63
64 The driver functions are published in the access struct as explained in \ref DriverFunctions
65   - \ref ARM_DRIVER_I2C : access struct for I2C driver functions
66
67
68 \anchor example **Example Code**
69
70 The following example code shows the usage of the I<sup>2</sup>C interface in Master mode.
71
72 \include I2C_Demo.c
73
74 \if TODO_later
75 The following example code shows the usage of the I<sup>2</sup>C interface in Slave mode.
76
77 Add: Code example that shows usage of slave mode.
78 \endif
79
80
81 @{
82 */
83
84
85 /**
86 \struct     ARM_DRIVER_I2C
87 \details
88 The functions of the I2C interface are accessed by function pointers exposed by this structure. Refer to \ref DriverFunctions for 
89 overview information.
90
91 Each instance of an I2C provides such an access structure. The instance is indicated by
92 a postfix in the symbol name of the access structure, for example:
93  - \b Driver_I2C0 is the name of the access struct of the first instance (no. 0).
94  - \b Driver_I2C1 is the name of the access struct of the second instance (no. 1).
95
96
97 A configuration setting in the middleware allows connecting the middleware to a specific driver instance <b>%Driver_I2C<i>n</i></b>.
98 The default is \token{0}, which connects a middleware to the first instance of a driver.
99 *******************************************************************************************************************/
100
101 /**
102 \struct     ARM_I2C_CAPABILITIES
103 \details
104 An I2C driver can be implemented with different capabilities.
105 The data fields of this struct encode the capabilities implemented by this driver.
106
107 The element \em address_10_bit indicates that the driver is able to handle 10-bit addressing natively.
108 User can still emulate the 10-bit addressing in software if the driver does not support it.
109
110 <b>Returned by:</b>
111   - \ref ARM_I2C_GetCapabilities
112 *******************************************************************************************************************/
113
114 /**
115 \struct     ARM_I2C_STATUS
116 \details
117 Structure with information about the status of the I2C.
118
119 The flag \em busy indicates that the driver is busy executing Master/Slave Transmit/Receive operation.
120
121 It is set:
122  - when Master operation starts: after calling \ref ARM_I2C_MasterTransmit or \ref ARM_I2C_MasterReceive
123  - when Slave operation starts: after calling \ref ARM_I2C_SlaveTransmit or \ref ARM_I2C_SlaveReceive and after being addressed by a Master as the Slave
124
125 It is cleared when Master/Slave operation has finished.
126
127 The flag \em mode indicates the current mode which is Master when Master Transmit/Receive is active or Slave otherwise.
128
129 The flag \em direction indicates either Transmitter or Receiver mode. It is updated during Master/Slave operation when the Slave is addressed by a Master.
130
131 The flag \em general_call indicates a General call (address \token{0}) when in Slave mode.
132
133 The flag \em arbitration_lost indicates that the Master has lost arbitration. The current Master operation is aborted.
134
135 The flag \em bus_error indicates that a bus error has been detected. The current Master/Slave operation is aborted.
136
137 <b>Returned by:</b>
138   - \ref ARM_I2C_GetStatus
139 *******************************************************************************************************************/
140
141 /**
142 \typedef    ARM_I2C_SignalEvent_t
143 \details
144 Provides the typedef for the callback function \ref ARM_I2C_SignalEvent.
145
146 <b>Parameter for:</b>
147   - \ref ARM_I2C_Initialize
148 *******************************************************************************************************************/
149
150 /**
151 \defgroup I2C_events I2C Events
152 \ingroup i2c_interface_gr
153 \brief The I2C driver generates call back events that are notified via the function \ref ARM_I2C_SignalEvent.
154 \details 
155 This section provides the event values for the \ref ARM_I2C_SignalEvent callback function.
156
157 The following call back notification events are generated:
158 @{
159 \def  ARM_I2C_EVENT_TRANSFER_DONE
160 \def  ARM_I2C_EVENT_TRANSFER_INCOMPLETE
161 \def  ARM_I2C_EVENT_SLAVE_TRANSMIT
162 \def  ARM_I2C_EVENT_SLAVE_RECEIVE
163 \def  ARM_I2C_EVENT_ADDRESS_NACK
164 \def  ARM_I2C_EVENT_GENERAL_CALL
165 \def  ARM_I2C_EVENT_ARBITRATION_LOST
166 \def  ARM_I2C_EVENT_BUS_ERROR
167 \def  ARM_I2C_EVENT_BUS_CLEAR
168 @}
169 */
170
171
172 //
173 //  Functions
174 //
175
176 ARM_DRIVER_VERSION ARM_I2C_GetVersion (void)  {
177   return { 0, 0 };
178 };
179 /**
180 \fn       ARM_DRIVER_VERSION ARM_I2C_GetVersion (void)
181 \details
182 The function \b ARM_I2C_GetVersion returns version information of the driver implementation in \ref ARM_DRIVER_VERSION
183  - API version is the version of the CMSIS-Driver specification used to implement this driver.
184  - Driver version is source code version of the actual driver implementation.
185
186 Example:
187 \code
188 extern ARM_DRIVER_I2C Driver_I2C0;
189 ARM_DRIVER_I2C *drv_info;
190  
191 void setup_i2c (void)  {
192   ARM_DRIVER_VERSION  version;
193  
194   drv_info = &Driver_I2C0;  
195   version = drv_info->GetVersion ();
196   if (version.api < 0x10A)   {      // requires at minimum API version 1.10 or higher
197     // error handling
198     return;
199   }
200 }
201 \endcode
202 *******************************************************************************************************************/
203
204 ARM_I2C_CAPABILITIES ARM_I2C_GetCapabilities (void)  {
205   return { 0 };
206 };
207 /**
208 \fn       ARM_I2C_CAPABILITIES ARM_I2C_GetCapabilities (void)
209 \details
210 The function \b ARM_I2C_GetCapabilities returns information about capabilities of this driver implementation.
211 The data fields of the struct \ref ARM_I2C_CAPABILITIES encodes the driver capabilities.
212  
213 Example:
214 \code
215 extern ARM_DRIVER_I2C Driver_I2C0;
216 ARM_DRIVER_I2C *drv_info;
217   
218 void read_capabilities (void)  {
219   ARM_I2C_CAPABILITIES drv_capabilities;
220  
221   drv_info = &Driver_I2C0;  
222   drv_capabilities = drv_info->GetCapabilities ();
223   // interrogate capabilities
224  
225 }
226 \endcode
227 *******************************************************************************************************************/
228
229 int32_t ARM_I2C_Initialize (ARM_I2C_SignalEvent_t cb_event) {
230   return ARM_DRIVER_OK;
231 };
232 /**
233 \fn       int32_t ARM_I2C_Initialize (ARM_I2C_SignalEvent_t cb_event)
234 \details 
235 The function \b ARM_I2C_Initialize initializes the I2C interface. 
236 It is called when the middleware component starts operation.
237
238 The function performs the following operations:
239   - Initializes and the I/O resources for the I2C interface.
240   - Registers the \ref ARM_I2C_SignalEvent callback function.
241
242 The parameter \em cb_event is a pointer to the \ref ARM_I2C_SignalEvent callback function.
243 Use a NULL pointer when no callback events are required.
244
245 Can be called multiple times. If the peripheral is already initialized the function performs no operation and 
246 returns with \ref ARM_DRIVER_OK. Refer to \ref CallSequence for more information.
247
248 \sa ARM_I2C_PowerControl
249 \sa ARM_I2C_Uninitialize
250
251 \b Example:
252  - refer to \ref example "Example Code"
253  
254 *******************************************************************************************************************/
255
256 int32_t ARM_I2C_Uninitialize (void)  {
257   return ARM_DRIVER_OK;
258 };
259 /**
260 \fn       int32_t ARM_I2C_Uninitialize (void)
261 \details
262 The function \b ARM_I2C_Uninitialize releases the I/O resources of I2C interface.
263
264 It is called when the middleware component stops operation and releases the I/O resources used by the I2C interface.
265 Refer to \ref CallSequence for more information.
266
267 \sa ARM_I2C_Initialize
268 \sa ARM_I2C_PowerControl
269
270 *******************************************************************************************************************/
271
272 int32_t ARM_I2C_PowerControl (ARM_POWER_STATE state)  {
273   return ARM_DRIVER_OK;
274 };
275 /**
276 \fn int32_t ARM_I2C_PowerControl (ARM_POWER_STATE state)
277 \details
278 The function \b ARM_I2C_PowerControl operates the power modes of the I2C interface.
279
280 The parameter \em state can have the following values:
281   - \ref ARM_POWER_FULL : set-up peripheral for data transfers, enable interrupts (NVIC) and optionally DMA. 
282                           Can be called multiple times. If the peripheral is already in this mode, 
283                                                   then the function performs no operation and returns with \ref ARM_DRIVER_OK.
284   - \ref ARM_POWER_LOW : may use power saving. Returns \ref ARM_DRIVER_ERROR_UNSUPPORTED when not implemented.
285   - \ref ARM_POWER_OFF : terminates any pending data transfers, disables peripheral, disables related interrupts and DMA.
286       
287 Refer to \ref CallSequence for more information.
288
289 \sa ARM_I2C_Initialize
290 \sa ARM_I2C_Uninitialize
291
292 *******************************************************************************************************************/
293
294 int32_t ARM_I2C_MasterTransmit (uint32_t addr, const uint8_t *data, uint32_t num, bool xfer_pending)  {
295   return ARM_DRIVER_OK;
296 };
297 /**
298 \fn int32_t ARM_I2C_MasterTransmit (uint32_t addr, const uint8_t *data, uint32_t num, bool xfer_pending)
299 \details
300 This function \b ARM_I2C_MasterTransmit transmits data as Master to the selected Slave.
301
302 The operation consists of:
303  - Master generates START condition
304  - Master addresses the Slave as Master Transmitter
305  - Master transmits data to the addressed Slave
306  - Master generates STOP condition (if \em xfer_pending is "false")
307
308 The parameter \em addr is the address of the slave to transmit the data to. The value can be ORed with \ref ARM_I2C_ADDRESS_10BIT to 
309 identify a 10-bit address value. \n
310 The parameter \em data and \em num specify the address of a data buffer and the number of bytes to transmit. \n
311 Set the parameter \em xfer_pending to 'true' if another transfer operation follows. With \em xfer_pending set to 'false' a STOP condition is generated.
312
313 The function is non-blocking and returns as soon as the driver has started the operation.
314 During the operation it is not allowed to call any Master function again. Also the data buffer must stay allocated and the contents of data must not be modified. 
315 When transmit operation has finished the \ref ARM_I2C_EVENT_TRANSFER_DONE event is generated.
316 When not all the data is transferred then the \ref ARM_I2C_EVENT_TRANSFER_INCOMPLETE flag is set at the same time.
317
318 Number of data bytes transmitted and acknowledged is returned by the function \ref ARM_I2C_GetDataCount during and after the operation has finished.
319
320 The operation is aborted in the following cases (\ref ARM_I2C_EVENT_TRANSFER_DONE event is generated together with):
321  - selected slave has not acknowledged the address: \ref ARM_I2C_EVENT_ADDRESS_NACK event
322  - arbitration has been lost: \ref ARM_I2C_EVENT_ARBITRATION_LOST event
323  - bus error has been detected: \ref ARM_I2C_EVENT_BUS_ERROR event
324
325 Status can be monitored by calling the \ref ARM_I2C_GetStatus and checking the flags.
326
327 Transmit operation can be aborted also by calling \ref ARM_I2C_Control with the parameter \em control \ref ARM_I2C_ABORT_TRANSFER.
328 *******************************************************************************************************************/
329
330 int32_t ARM_I2C_MasterReceive (uint32_t addr, uint8_t *data, uint32_t num, bool xfer_pending)  {
331   return ARM_DRIVER_OK;
332 };
333 /**
334 \fn int32_t ARM_I2C_MasterReceive (uint32_t addr, uint8_t *data, uint32_t num, bool xfer_pending)
335 \details
336 This function \b ARM_I2C_MasterReceive is used to receive data as Master from the selected Slave.
337
338 The operation consists of:
339  - Master generates START condition
340  - Master addresses the Slave as Master Receiver
341  - Master receives data from the addressed Slave
342  - Master generates STOP condition (if \em xfer_pending is "false")
343
344 The parameter \em addr is the address of the slave to receive the data from. The value can be ORed with \ref ARM_I2C_ADDRESS_10BIT to 
345 identify a 10-bit address value. \n
346 The parameter \em data and \em num specify the address of a data buffer and the number of bytes to receive. \n
347 Set the parameter \em xfer_pending to 'true' if another transfer operation follows. With \em xfer_pending set to 'false' a STOP condition is generated.
348
349 The function is non-blocking and returns as soon as the driver has started the operation.
350 During the operation it is not allowed to call any Master function again. Also the data buffer must stay allocated. 
351 When receive operation has finished the \ref ARM_I2C_EVENT_TRANSFER_DONE event is generated.
352 When not all the data is transferred then the \ref ARM_I2C_EVENT_TRANSFER_INCOMPLETE flag is set at the same time.
353
354 Number of data bytes received is returned by the function \ref ARM_I2C_GetDataCount during and after the operation has finished.
355
356 The operation is aborted in the following cases (\ref ARM_I2C_EVENT_TRANSFER_DONE event is generated together with):
357  - selected slave has not acknowledged the address: \ref ARM_I2C_EVENT_ADDRESS_NACK event
358  - arbitration has been lost: \ref ARM_I2C_EVENT_ARBITRATION_LOST event
359  - bus error has been detected: \ref ARM_I2C_EVENT_BUS_ERROR event
360
361 Status can be monitored by calling the \ref ARM_I2C_GetStatus and checking the flags.
362
363 Receive operation can be aborted also by calling \ref ARM_I2C_Control with the parameter \em control = \ref ARM_I2C_ABORT_TRANSFER.
364 *******************************************************************************************************************/
365
366 int32_t ARM_I2C_SlaveTransmit (const uint8_t *data, uint32_t num)  {
367   return ARM_DRIVER_OK;
368 };
369 /**
370 \fn int32_t ARM_I2C_SlaveTransmit (const uint8_t *data, uint32_t num)
371 \details
372 This function \b ARM_I2C_SlaveTransmit is used to transmit data as Slave to the Master.
373
374 The parameter \em data is a pointer to the data to transmit. \n
375 The parameter \em num specifies the number of bytes to transmit.
376
377 The function is non-blocking and returns as soon as the driver has registered the operation.
378 The actual operation will start after being addressed by the master as a Slave Transmitter. If the operation has not been registered at that point the \ref ARM_I2C_EVENT_SLAVE_TRANSMIT event is generated.
379 The same event is also generated if the operation has finished (specified number of bytes transmitted) but more data is requested by the master.
380
381 It is not allowed to call this function again if the operation has started until it finishes. Also the data buffer must stay allocated and the contents of data must not be modified. 
382 When transmit operation has finished the \ref ARM_I2C_EVENT_TRANSFER_DONE event is generated.
383 When not all the data is transferred then the \ref ARM_I2C_EVENT_TRANSFER_INCOMPLETE flag is set at the same time.
384
385 Number of data bytes transmitted is returned by the function \ref ARM_I2C_GetDataCount during and after the operation has finished.
386
387 In case that a General call has been detected the \ref ARM_I2C_EVENT_GENERAL_CALL flag is indicated together with the \ref ARM_I2C_EVENT_TRANSFER_DONE event (also with \ref ARM_I2C_EVENT_SLAVE_TRANSMIT event).
388
389 In case that bus error has been detected then the operation is aborted and the \ref ARM_I2C_EVENT_BUS_ERROR event is generated together with \ref ARM_I2C_EVENT_TRANSFER_DONE.
390
391 Slave will only respond to its own address (or General call if enabled) that is specified by calling \ref ARM_I2C_Control with \ref ARM_I2C_OWN_ADDRESS as control parameter. 
392 Using address \token{0} disables the slave.
393
394 Status can be monitored by calling the \ref ARM_I2C_GetStatus and checking the flags.
395
396 Transmit operation can be canceled or aborted by calling \ref ARM_I2C_Control with the parameter \em control = \ref ARM_I2C_ABORT_TRANSFER.
397 *******************************************************************************************************************/
398
399 int32_t ARM_I2C_SlaveReceive (uint8_t *data, uint32_t num)  {
400   return ARM_DRIVER_OK;
401 };
402 /**
403 \fn int32_t ARM_I2C_SlaveReceive (uint8_t *data, uint32_t num)
404 \details
405 This function \b ARM_I2C_SlaveReceive receives data as Slave from the Master.
406
407 The parameter \em data is a pointer to the data to receive. \n
408 The parameter \em num specifies the number of bytes to receive.
409
410 The function is non-blocking and returns as soon as the driver has registered the operation.
411 The actual operation will start after being addressed by the master as a Slave Receiver. If the operation has not been registered at that point the \ref ARM_I2C_EVENT_SLAVE_RECEIVE event is generated.
412
413 It is not allowed to call this function again if the operation has started until it finishes. Also the data buffer must stay allocated. 
414 When receive operation has finished the \ref ARM_I2C_EVENT_TRANSFER_DONE event is generated.
415 When not all the data is transferred then the \ref ARM_I2C_EVENT_TRANSFER_INCOMPLETE flag is set at the same time.
416
417 Number of data bytes received and acknowledged is returned by the function \ref ARM_I2C_GetDataCount during and after the operation has finished.
418
419 In case that a General call has been detected the \ref ARM_I2C_EVENT_GENERAL_CALL flag is indicated together with the \ref ARM_I2C_EVENT_TRANSFER_DONE event (also with \ref ARM_I2C_EVENT_SLAVE_RECEIVE event).
420
421 In case that bus error has been detected then the operation is aborted and the \ref ARM_I2C_EVENT_BUS_ERROR event is generated together with \ref ARM_I2C_EVENT_TRANSFER_DONE.
422
423 Slave will only respond to its own address (or General call if enabled) that is specified by calling \ref ARM_I2C_Control with \ref ARM_I2C_OWN_ADDRESS as control parameter. 
424 Using address \token{0} disables the slave.
425
426 Status can be monitored by calling the \ref ARM_I2C_GetStatus and checking the flags.
427
428 Receive operation can be canceled or aborted by calling \ref ARM_I2C_Control with the parameter \em control = \ref ARM_I2C_ABORT_TRANSFER.
429 *******************************************************************************************************************/
430
431 int32_t ARM_I2C_GetDataCount (void)  {
432   return 0;
433 }
434 /**
435 \fn int32_t ARM_I2C_GetDataCount (void)
436 \details
437 The function \b ARM_I2C_GetDataCount returns the number of currently transferred data bytes during and after:
438  - \ref ARM_I2C_MasterTransmit : number of data bytes transmitted and acknowledged
439  - \ref ARM_I2C_MasterReceive : number of data bytes received
440  - \ref ARM_I2C_SlaveTransmit : number of data bytes transmitted
441  - \ref ARM_I2C_SlaveReceive : number of data bytes received and acknowledged
442
443 When the Slave is not yet addressed by the Master then \token{-1} is returned.
444 *****************************************************************************************************************/
445
446 int32_t ARM_I2C_Control (uint32_t control, uint32_t arg)  {
447   return ARM_DRIVER_OK;
448 }
449 /**
450 \fn int32_t ARM_I2C_Control (uint32_t control, uint32_t arg)
451 \details
452 The function \b ARM_I2C_Control operates the I2C interface and executes various operations. 
453
454 The parameter \em control specifies various operations as listed in the table below.  \n
455 The parameter \em arg provides, depending on the operation,  additional information. \n
456
457 Parameter \em control            | Operation
458 :--------------------------------|:--------------------------------------------
459 \ref ARM_I2C_OWN_ADDRESS         | Set Own Slave Address; \em arg = slave address
460 \ref ARM_I2C_BUS_SPEED           | Set Bus Speed; \em arg = bus speed
461 \ref ARM_I2C_BUS_CLEAR           | Clear the bus by sending nine clock pulses
462 \ref ARM_I2C_ABORT_TRANSFER      | Aborts the data transfer between Master and Slave for Transmit or Receive 
463
464 <b>Set Own Slave Address</b>
465
466 After initialization, the I2C Device has no slave address assigned and does not accept any requests from 
467 an I2C Master.
468
469 The \em control operation \ref ARM_I2C_OWN_ADDRESS sets the slave address with the parameter \em arg.
470 The slave address can be ORed with \ref ARM_I2C_ADDRESS_10BIT to indicate a 10-bit address.  
471
472 The slave address can be ORed with \ref ARM_I2C_ADDRESS_GC to indicate that the slave accepts a General Call.
473 If the slave address value is only \ref ARM_I2C_ADDRESS_GC, then the slave only accepts a General Call.
474
475 The slave address value \token{0} disables Slave mode and clears any assigned slave address.
476
477 **Examples:**
478
479 Set the Slave address value \token{0x45} as 7-bit address.
480 \code
481   I2Cdrv->Control      (ARM_I2C_OWN_ADDRESS, 0x45);
482 \endcode
483
484 Set the Slave address value \token{0x135} as 10-bit address and accept a General Call.
485 \code
486   I2Cdrv->Control      (ARM_I2C_OWN_ADDRESS, 0x135 | ARM_I2C_ADDRESS_10BIT | ARM_I2C_ADDRESS_GC);
487 \endcode
488
489 <b>Bus Speed</b>
490
491 The \em control operation \ref ARM_I2C_BUS_SPEED sets the bus speed using the parameter \em arg.
492
493 Parameter \em arg                | Bus Speed
494 :--------------------------------|:--------------------------------------------
495 \ref ARM_I2C_BUS_SPEED_STANDARD  | Standard Speed to (\token{100 kHz})
496 \ref ARM_I2C_BUS_SPEED_FAST      | Fast Speed  (\token{400kHz})
497 \ref ARM_I2C_BUS_SPEED_FAST_PLUS | Fast + Speed (\token{1MHz})
498 \ref ARM_I2C_BUS_SPEED_HIGH      | High Speed  (\token{3.4MHz})
499
500 **Example:**
501
502 \code
503   I2Cdrv->Control      (ARM_I2C_BUS_SPEED, I2C_BUS_SPEED_FAST);
504 \endcode
505 *****************************************************************************************************************/
506
507 ARM_I2C_STATUS ARM_I2C_GetStatus (void)  {
508   return { 0 };
509 }
510 /**
511 \fn ARM_I2C_STATUS ARM_I2C_GetStatus (void)
512 \details
513 The function \b ARM_I2C_GetStatus returns the current I2C interface status.
514
515 Refer to \ref ARM_I2C_STATUS for details.
516 *****************************************************************************************************************/
517
518 void ARM_I2C_SignalEvent (uint32_t event)  {
519   // function body
520 }
521 /**
522 \fn void ARM_I2C_SignalEvent (uint32_t event)
523 \details
524 The function \b ARM_I2C_SignalEvent is a callback function registered by the function \ref ARM_I2C_Initialize..
525 It is called by the I2C driver to notify the application about \ref I2C_events occured during operation.
526
527 The parameter \a event indicates one or more events that occurred during driver operation.
528 Each event is encoded in a separate bit and therefore it is possible to signal multiple events within the same call. 
529
530 The following events can be generated:
531
532 Parameter \em event                       |     Bit   | Description 
533 :---------------------------------------- |:---------:|:----------------------------------------------------------
534 \ref ARM_I2C_EVENT_TRANSFER_DONE          | 1UL&nbsp;<<&nbsp;0  | Occurs after Master/Slave Transmit/Receive operation has finished.
535 \ref ARM_I2C_EVENT_TRANSFER_INCOMPLETE    | 1UL << 1  | Occurs together with \ref ARM_I2C_EVENT_TRANSFER_DONE when less data is transferred then requested.
536 \ref ARM_I2C_EVENT_SLAVE_TRANSMIT         | 1UL << 2  | Occurs when addressed as Slave Transmitter and \ref ARM_I2C_SlaveTransmit has not been started.
537 \ref ARM_I2C_EVENT_SLAVE_RECEIVE          | 1UL << 3  | Occurs when addressed as Slave Receiver and \ref ARM_I2C_SlaveReceive has not been started.
538 \ref ARM_I2C_EVENT_ADDRESS_NACK           | 1UL << 4  | Occurs in master mode when address is not acknowledged from slave.
539 \ref ARM_I2C_EVENT_GENERAL_CALL           | 1UL << 5  | Indicates General Call in slave mode together with \ref ARM_I2C_EVENT_TRANSFER_DONE, \ref ARM_I2C_EVENT_SLAVE_TRANSMIT and \ref ARM_I2C_EVENT_SLAVE_RECEIVE.
540 \ref ARM_I2C_EVENT_ARBITRATION_LOST       | 1UL << 6  | Occurs in master mode when arbitration is lost.
541 \ref ARM_I2C_EVENT_BUS_ERROR              | 1UL << 7  | Occurs when bus error is detected.
542 \ref ARM_I2C_EVENT_BUS_CLEAR              | 1UL << 8  | Occurs after \ref ARM_I2C_BUS_CLEAR Control operation has finished.
543
544 **************************************************************************************************************************/
545
546
547 /**
548 \defgroup i2c_control_gr I2C Control Codes
549 \ingroup i2c_interface_gr
550 \brief Many parameters of the I2C driver are configured using the \ref ARM_I2C_Control function.
551 @{
552 \details 
553 The various I2C control codes define:
554   - \ref i2c_control_codes           specify operation parameters and various controls
555   - \ref i2c_bus_speed_ctrls         specify the I2C bus speed
556   
557 Refer to the \ref ARM_I2C_Control function for further details.
558 */
559
560 /**
561 \defgroup i2c_control_codes I2C Control Codes
562 \ingroup i2c_control_gr
563 \brief Specify operation parameters and various controls.
564 \details
565 @{
566 \def ARM_I2C_OWN_ADDRESS
567 \sa ARM_I2C_Control
568 \def ARM_I2C_BUS_SPEED
569 Speed is specified using the following values: \ref i2c_bus_speed_ctrls
570 \sa ARM_I2C_Control
571 \def ARM_I2C_BUS_CLEAR
572 \sa ARM_I2C_Control
573 \def ARM_I2C_ABORT_TRANSFER
574 \sa ARM_I2C_Control
575 @}
576 */
577
578 /**
579 \defgroup i2c_bus_speed_ctrls I2C Bus Speed
580 \ingroup i2c_control_gr
581 \brief Specify the I2C bus speed.
582 \details
583 @{
584 \def ARM_I2C_BUS_SPEED_STANDARD
585 \sa ARM_I2C_Control
586 \def ARM_I2C_BUS_SPEED_FAST
587 \sa ARM_I2C_Control
588 \def ARM_I2C_BUS_SPEED_FAST_PLUS
589 \sa ARM_I2C_Control
590 \def ARM_I2C_BUS_SPEED_HIGH
591 \sa ARM_I2C_Control
592 @}
593 */
594 /**
595 @}
596 */ 
597
598 /**
599 \defgroup i2c_address_flags I2C Address Flags
600 \ingroup i2c_interface_gr
601 \brief Specify address flags
602 \details
603 Specifies the address type for the functions \ref ARM_I2C_MasterReceive, \ref ARM_I2C_MasterTransmit and \ref ARM_I2C_OWN_ADDRESS.
604 @{
605 \def ARM_I2C_ADDRESS_10BIT
606 \sa ARM_I2C_OWN_ADDRESS
607 \sa ARM_I2C_MasterTransmit
608 \sa ARM_I2C_MasterReceive
609 \def ARM_I2C_ADDRESS_GC     
610 \sa ARM_I2C_OWN_ADDRESS
611 @}
612 */
613
614
615 /**
616 @}
617 */ 
618 // End I2C Interface