OpenCores
URL https://opencores.org/ocsvn/usb_fpga_2_16/usb_fpga_2_16/trunk

Subversion Repositories usb_fpga_2_16

[/] [usb_fpga_2_16/] [trunk/] [include/] [ztex-temp1.h] - Diff between revs 2 and 3

Only display areas with differences | Details | Blame | View Log

Rev 2 Rev 3
/*!
/*!
   ZTEX Firmware Kit for EZ-USB FX2 Microcontrollers
   ZTEX Firmware Kit for EZ-USB FX2 Microcontrollers
   Copyright (C) 2009-2011 ZTEX GmbH.
   Copyright (C) 2009-2014 ZTEX GmbH.
   http://www.ztex.de
   http://www.ztex.de
 
 
   This program is free software; you can redistribute it and/or modify
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License version 3 as
   it under the terms of the GNU General Public License version 3 as
   published by the Free Software Foundation.
   published by the Free Software Foundation.
 
 
   This program is distributed in the hope that it will be useful, but
   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   General Public License for more details.
   General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program; if not, see http://www.gnu.org/licenses/.
   along with this program; if not, see http://www.gnu.org/licenses/.
!*/
!*/
 
 
/*
/*
    Temperature sensor support for USB-FPGA Modules 1.15y
    Temperature sensor support for USB-FPGA Modules 1.15y
*/
*/
 
 
#ifndef[ZTEX_TEMP1_H]
#ifndef[ZTEX_TEMP1_H]
#define[ZTEX_TEMP1_H]
#define[ZTEX_TEMP1_H]
 
 
#define[TEMP1_ENABLED][1]
#define[TEMP1_ENABLED][1]
 
 
#define[PCA9691_ADDR][0x90]
#define[PCA9691_ADDR][0x90]
 
 
void temp1_init() {
void temp1_init() {
    I2CS |= bmBIT7;             // start bit
    I2CS |= bmBIT7;             // start bit
    i2c_waitStart();
    i2c_waitStart();
    I2DAT = PCA9691_ADDR;               // select device for writing
    I2DAT = PCA9691_ADDR;               // select device for writing
    if ( i2c_waitWrite() ) return;
    if ( i2c_waitWrite() ) return;
    I2DAT = bmBIT2 | bmBIT6;    // control byte
    I2DAT = bmBIT2 | bmBIT6;    // control byte
    if ( i2c_waitWrite() ) return;
    if ( i2c_waitWrite() ) return;
    I2DAT = 20;                 // DAC output
    I2DAT = 20;                 // DAC output
    I2CS |= bmBIT6;             // stop bit
    I2CS |= bmBIT6;             // stop bit
    if ( i2c_waitStop() ) return;
    if ( i2c_waitStop() ) return;
    INTERFACE_CAPABILITIES[1] |= bmBIT0;
    INTERFACE_CAPABILITIES[1] |= bmBIT0;
}
}
 
 
 
 
ADD_EP0_VENDOR_REQUEST((0x58,,
ADD_EP0_VENDOR_REQUEST((0x58,,
    I2CS |= bmBIT7;             // start bit
    I2CS |= bmBIT7;             // start bit
    i2c_waitStart();
    i2c_waitStart();
    I2DAT = PCA9691_ADDR | 1;   // select device for reading
    I2DAT = PCA9691_ADDR | 1;   // select device for reading
    i2c_waitWrite();
    i2c_waitWrite();
 
 
    EP0BUF[0] = 1;               // protocol #1
    EP0BUF[0] = 1;               // protocol #1
 
 
    EP0BUF[1] = I2DAT;          // dummy read
    EP0BUF[1] = I2DAT;          // dummy read
    i2c_waitRead();
    i2c_waitRead();
    EP0BUF[1] = I2DAT;          // BYTE 0
    EP0BUF[1] = I2DAT;          // BYTE 0
    i2c_waitRead();
    i2c_waitRead();
    EP0BUF[2] = I2DAT;          // BYTE 1
    EP0BUF[2] = I2DAT;          // BYTE 1
    i2c_waitRead();
    i2c_waitRead();
    EP0BUF[3] = I2DAT;          // BYTE 2
    EP0BUF[3] = I2DAT;          // BYTE 2
    i2c_waitRead();
    i2c_waitRead();
    EP0BUF[4] = I2DAT;          // BYTE 3
    EP0BUF[4] = I2DAT;          // BYTE 3
    i2c_waitRead();
    i2c_waitRead();
    EP0BUF[1] = I2DAT;          // BYTE 4
    EP0BUF[1] = I2DAT;          // BYTE 4
    i2c_waitRead();
    i2c_waitRead();
    EP0BUF[2] = I2DAT;          // BYTE 5
    EP0BUF[2] = I2DAT;          // BYTE 5
    i2c_waitRead();
    i2c_waitRead();
    I2CS |= bmBIT5;             // no ACK
    I2CS |= bmBIT5;             // no ACK
    EP0BUF[3] = I2DAT;          // BYTE 6
    EP0BUF[3] = I2DAT;          // BYTE 6
    i2c_waitRead();
    i2c_waitRead();
    I2CS |= bmBIT6;             // stop bit
    I2CS |= bmBIT6;             // stop bit
    EP0BUF[4] = I2DAT;          // BYTE 7
    EP0BUF[4] = I2DAT;          // BYTE 7
    i2c_waitStop();
    i2c_waitStop();
 
 
    EP0BCH = 0;
    EP0BCH = 0;
    EP0BCL = 5;
    EP0BCL = 5;
,,
,,
));;
));;
 
 
 
 
#endif  /*ZTEX_TEMP1_H*/
#endif  /*ZTEX_TEMP1_H*/
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.