/*
 * @brief I2C example
 * This example show how to use the I2C interface
 *
 * @note
 * Copyright(C) NXP Semiconductors, 2013
 * All rights reserved.
 *
 * @par
 * Software that is described herein is for illustrative purposes only
 * which provides customers with programming information regarding the
 * LPC products.  This software is supplied "AS IS" without any warranties of
 * any kind, and NXP Semiconductors and its licensor disclaim any and
 * all warranties, express or implied, including all implied warranties of
 * merchantability, fitness for a particular purpose and non-infringement of
 * intellectual property rights.  NXP Semiconductors assumes no responsibility
 * or liability for the use of the software, conveys no license or rights under any
 * patent, copyright, mask work right, or any other intellectual property rights in
 * or to any products. NXP Semiconductors reserves the right to make changes
 * in the software without notification. NXP Semiconductors also makes no
 * representation or warranty that such application will be suitable for the
 * specified use without further testing or modification.
 *
 * @par
 * Permission to use, copy, modify, and distribute this software and its
 * documentation is hereby granted, under NXP Semiconductors' and its
 * licensor's relevant copyrights in the software, without fee, provided that it
 * is used in conjunction with NXP Semiconductors microcontrollers.  This
 * copyright, permission, and disclaimer notice must appear in all copies of
 * this code.
 */

/** @defgroup EXAMPLES_PERIPH_18XX43XX_I2C LPC18xx/43xx I2C example
 * @ingroup EXAMPLES_PERIPH_18XX43XX
 * <b>Example description</b><br>
 * The I2C example shows how to use I2C interface in master and slave mode using
 * POLLING/INTERRUPT method.<br>
 *
 * To use the example, connect a serial cable to the board's RS232/UART port and
 * start a terminal program to monitor the port. The terminal program on the host
 * PC should be setup for 115K8N1.<br>
 *
 * For boards that does not have default UART, the user can enable debugging and
 * connect FTDI UART cable to the board and use the example or see the section
 * below for using the example without uart, others can skip the following paragraph.<br>
 *
 * For boards like NGX Xplorer where there exist not default UART, do the connections
 * as specified in the  "Special connection requirements" section. Press the button in
 * one board and see the LED in the other board glow (Button press is sensed by the board
 * and it will act as the master and will send data to the slave board).<br><br>
 *
 * After a Main menu is displayed via UART, I2C0 and I2C1 are configured with
 * 100KHz speed.<br>
 *
 * User can access any I2C slave device (probe all devices by selecting option 3 from
 * main menu) connected to the bus using this example,
 * i.e, operations like WRITE/READ/WRITE&READ can be carried out by using any I2C
 * I2C0/I2C1 as master. The input from UART could be decimal, hexadecimal (prefixed
 * with 0x), or octal (prefixed with 0) and can be edited using backspace. User must
 * press enter key to complete the input.<br><br>
 * This example simulates two slave devices (default by I2C0), an EEPROM (0x5A) and
 * an IO Extension device (0x5B). The EEPROM simulation is just to show how the I2C
 * can be used as a device (it will not retain contents across power cycles). IO
 * extention device have 2 ports, any single byte read will read 8 bit data from IN
 * port (8 bit input reg0), any single byte write will write to OUT port (8 bit output
 * reg1). Multibyte reads will read (IN REG, OUT REG) repeatedly, multi byte writes will
 * write to OUT REG repeatedly. OUT REG represent LEDS in the board set/reset them will
 * turn LED0-LED7 (If present) to ON/OFF, IN REG represent key press (KEY0 to KEY7).
 *
 * To turn on LED1 and LED2 using IOX Slave, follow the steps given below <br>
 * 1. Select I2C1 as default device by selecting option 1 and 1<br>
 * 2. Select option 5 to write data to slave<br>
 * 3. Enter 0x5B as the slave device address<br>
 * 4. Enter 1 as the number of bytes to write<br>
 * 6. Enter 6 as the data [Turn ON LED1 and LED2]<br>
 *
 * The EEPROM slave (simulation) device will work as any standard I2C EEPROM. To write
 * data 0xDE, 0xAD, 0xBE, 0xEF to address 0x10, 0x11, 0x12 & 0x13 respectively and to
 * read back the full content of the EEPROM follow the steps
 * 1.  Select I2C1 as default device by choosing option 1 and give input 1<br>
 * 2.  Select option 5 to write data to slave<br>
 * 3.  Enter 0x5A as the slave device address<br>
 * 4.  Enter 5 as the number of bytes to write<br>
 * 5.  Enter 0x10 as the address to write<br>
 * <blockquote> First byte written to device is always considered as the address
 * from/to which read/write to be performed, the EEPROM uses 64 byte memory hence
 * BIT0 to BIT5 will have address A0-A5 and BIT6 & BIT7 are don't cares. For every
 * read/write the address will auto increment upon reaching the end of the device
 * the address will automatically roll back to location 0.</blockquote>
 * 6.  Enter data 0xDE,0xAD,0xBE,0xEF one by one<br>
 * 7.  Select option 6 to write/read the data from EEPROM<br>
 * 8.  Enter 0x5A as the slave address<br>
 * 9.  Enter 64 as the number of bytes to read<br>
 * 10. Enter 1 as the number of bytes to write<br>
 * 11. Enter 0 as the address from which read must start<br>
 * 12. Full content of EEPROM will be displayed on UART terminal with address
 * 0x10 to 0x13 showing the data written in previous operation.
 *
 * <b>Special connection requirements</b><br>
 *  - Hitex LPC1850EVA-A4-2 and LPC4350EVA-A4-2 boards (using UART0)<br>
 *    - I2C1_SDA (X20 pin 5) connected to I2C0_SDA (SV19 pin 4) <br>
 *    - I2C1_SCL (X20 pin 3) connected to I2C0_SCL (SV19 pin 6) <br>
 *    - Remove the jumpers from SV19 if required and place back once example is done <br>
 *  - Keil MCB1857 and MCB4357 boards (using UART3)<br>
 *    - PE.13 : I2C1_SDA be connected to J8(SDA) (RFID Board connector)<br>
 *    - PE.15 : I2C1_SCL be connected to J9(SCL) (RFID Board connector)<br>
 *    - I2C1 pins are muxed with DMQ lines of EMC hence SDRAM might not be usable when running this example.
 *  - NGX Xplorer 1830 and 4330 boards<br>
 *    - Two boards must be used to test this example (as I2C0 is not connected to any jumper)
 *    - (J10 PIN13) I2C1_SDA must be connected between boards [P2.3]<br>
 *    - (J10 PIN14) I2C1_SCL must be connected between boards [P2.4]<br>
 *    - (J10 PIN27) GND must be connected between boards<br>
 *
 * <b>Build procedures:</b><br>
 * Visit the <a href="http://www.lpcware.com/content/project/lpcopen-platform-nxp-lpc-microcontrollers/lpcopen-v200-quickstart-guides">LPCOpen quickstart guides</a>
 * to get started building LPCOpen projects.
 *
 * <b>Supported boards and board setup:</b><br>
 * @ref LPCOPEN_18XX_BOARD_HITEX1850<br>
 * @ref LPCOPEN_43XX_BOARD_HITEX4350<br>
 * @ref LPCOPEN_18XX_BOARD_KEIL1857<br>
 * @ref LPCOPEN_43XX_BOARD_KEIL4357<br>
 * @ref LPCOPEN_18XX_BOARD_NGX1830<br>
 * @ref LPCOPEN_43XX_BOARD_NGX4330<br>
 *
 * <b>Submitting LPCOpen issues:</b><br>
 * @ref LPCOPEN_COMMUNITY
 * @{
 */

/**
 * @}
 */
