/***************************************************************************
 *                                                                         *
 *                   SiRF Technology, Inc. GPS Software                    *
 *                                                                         *
 *    Copyright (c) 1996-2015 by SiRF Technology, Inc. a CSR plc Company   *
 *                          All rights reserved.                           *
 *                                                                         *
 *    This Software is protected by United States copyright laws and       *
 *    international treaties.  You may not reverse engineer, decompile     *
 *    or disassemble this Software.                                        *
 *                                                                         *
 *    WARNING:                                                             *
 *    This Software contains SiRF Technology Inc.s confidential and        *
 *    proprietary information. UNAUTHORIZED COPYING, USE, DISTRIBUTION,    *
 *    PUBLICATION, TRANSFER, SALE, RENTAL OR DISCLOSURE IS PROHIBITED      *
 *    AND MAY RESULT IN SERIOUS LEGAL CONSEQUENCES.  Do not copy this      *
 *    Software without SiRF Technology, Inc.s  express written             *
 *    permission.   Use of any portion of the contents of this Software    *
 *    is subject to and restricted by your signed written agreement with   *
 *    SiRF Technology, Inc.                                                *
 *                                                                         *
 ***************************************************************************/

This example program uses Linux I2C driver to interface to GSD5 Receiver through the "/dev/i2c" interface.

(There is another port for Linux x86 using Aardvark I2C Host Adapter - All information on Aardvark is 
the property of Total Phase, Inc. ("Total Phase").).

Requirement:
1. Currently the Linux I2C device driver supports I2C master feature but may not provide for slave or multimaster features.
   The GSD5 receiver's I2C bus interface requires host master transmit and host slave receive.
   So the Linux I2C device driver must support subset "multi-master" mode for a single I2C port or alternative
   requires two I2C port (one port to support master transmit and the other port to support I2C slave receive).
2. This was tested with Beaglebone Black kit with modified i2c device driver supporting subset "multi-master" mode
   (master transmit/slave receive) using "/dev/i2c-2".
   (Alternatively this was also tested with the "/dev/i2c-1" supporting master mode and 
    "/dev/i2c-2" supporting slave receive).
3. This program was built and tested with Beaglebone Black kit using gcc-linaro-arm-linux-gnueabihf toolchain. 
   in Ubuntu x86 PC. Change the CC variable in makefile to the path of desired toolchain used.
   (This program was also built and tested in Beaglebone Black Linux host by changing CC=gcc and AR=ar).

how to build:
1. Build the SiRFFlashEngineEP library by running "make" at
   ..../sw/host/library/builds/linux_gcc/SiRFflashEngineEP/i2c_via_kernel_driver/
2. Build this program by running "make"

how to test:

prgflash_i2c <binary_image_name> <i2c_dev_name> <speed> [-e] -x

 - Flash image should be binary image (not S-record)
 - You can find i2c_dev_name under /dev/i2c-*.
 - The program doesn't handle control signal (on/off, reset, boot mode pin,..), 
   so GSD5 should be in the boot mode before executing program
 - By default, only the necessary sectors are erased prior to flashing.
   To erase the whole flash prior to flashing use the -e option
 - The speed should be either 100000 or 400000.
 
Limitations:
With our current implementation of the Beaglebbone Black device driver using the Device Tree:
1. the speed is set (either 100000 or 400000) in the device tree overlay
2. the host I2c address is set (to 0x62) in the device tree overlay


   
