
CY3240 USB-I2C Bridge Guide, Doc. # 001-66660 Rev.*B 33
5. Code Examples
All code examples are available in the CY3240 USB-I2C Bridge kit CD or at the following location:
<Install_Directory>:\Cypress\CY3240 USB-I2C Bridge Kit\<version>\Firm-
ware.
5.1 My First Code Example
5.1.1 Project Objective
This code example demonstrates data transfer between the demo board and the host using I2C
communication. The demo board outputs temperature and light data to the host whenever the host
requests this data. Similarly, the host board sends commands to the demo board to control the LEDs
on the board.
The demo board has a photo diode to measure the light intensity. The voltage value analogous to
the die temperature is available on a PSoC analog block array. This temperature input can be used
in applications such as battery chargers and data acquisition without any external components. In
this code example, this temperature input is used to read the die temperature value. See the Techni-
cal Reference Manual available in Help > Documentation for more details.
The following user modules are used in the design to achieve the objective of this project:
ADC10: Used to obtain the digital values for light intensity and temperature. Input to the ADC mod-
ule is switched between light input and temperature input once every 551 scan cycles.
EzI2C: Used to configure the PSoC on the demo board as I2C slave and to transfer data to the
bridge board where the PSoC is configured as I2C master.
PWM8: Used to handle the LED command from the host and vary the LED intensity accordingly.
When data is requested by the I2C master, the ADC values analogous to the die temperature and
light intensity incident on the board are output.
Comentários a estes Manuais