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