Brainstorming

Vorlage

Transitor

Bezugsquelle

eBay-Profil von http://www.digitaliontechnologies.com/shop/

Kühlung

Lehrfilm zum Kühlkörber Berechnung: http://www.alutronic.de/service/alutronic-lehrfilm-1988

Kühlkörper für 120mm-Lüfter

SK 320 - 240 Hochleistungskühlkörper

Abmasse 320 x 240 x 85, fertig bearbeitet

Breite [mm] 300, Höhe [mm] 84, Länge Kundenwunsch, Nachbearbeitung erforderlich

Kühlkörper für 120mm-Lüfter

Breite [mm] 240, Höhe [mm] 121, Länge Kundenwunsch, Nachbearbeitung erforderlich

Heatspreader

Silber

Der Vorteil von Silber ist nicht so deutlich wie persönlich erhofft. DC8WAN => http://www.ledstyles.de/index.php/Attachment/24782-W%C3%A4rmeleitf%C3%A4higkeit-von-Metall-pdf/

Netzteil 50V und Umbauanleitung

Umbauten

 Erste Test haben gezeigt, dass die Spannung vom Netzteil pro 150 Watt mehr Leistungsentnahme um 0,01V fällt.
  • Bei DC8WAN einen Festwiderstand 2K2 verbaut = 48,8V

E-Bay

Gehäuse für die PA und Netzteil

Steckverbinder

Nato

NEUTRIK Stecker

Buchse

Nettes Zubehör

Betriebsstunden-Zählermodule Volt- und Amperemeter

Betrieb

Volt

Ampere

Intelligente Anzeige

Arduino

Quellcode Arduino (test)

#include "i2cmaster.h" 

// I2C Library, mit Erweiterung 
// Arduino analog input 4 = I2C SDA
// Arduino analog input 5 = I2C SCL 
/*
 Testfragen
 Ist die CPU I2C Adresse ok, sonst mal mit Broadcast und mal mit EEPROM probieren
 Wenn das Lesen nicht geht dann mal das Ctrl Register setzen, mit der CMD ID 0x01 und 0x02 probieren
 (denn dies kann unterschiedlich sein)
 
*/

/*
  Convert a HP 3kW Powersupply to a Battery Charger
 
  I2C Access Test 
  
  There are two I2C addresses, FRU EEPROM and Microcontroller
  Default Address (if A0,A1,A2 is open or connectet to High)
  FRU: 0xAE --> B10101110
  CPU: 0x3E --> B00111110
  
  Also Broadcast Address is possible
  Broadcast: 0x00  --> B00000000
  
  I2C Clock Frequency
  10 to 100 kHz is possible (Standard I2C)
  
  I2C Delay Time between two I2C Messages
  Minimum 50ms
*/

#define I2C_CPU_ADDR         B0011111 // Highes 7Bit for the Address, the last bit is R/W Flag and added by the lib 
#define I2C_FRU_EEPROM_ADDR  B1010111 // Highest 7Bit of the Address, the last bit is R/W Flag and added by the lib
#define I2C_BROADCAST_ADDR   B0000000 // Broadcast Adresse
#define I2C_MESSAGE_DELAY    50       // minimum delay time between i2c requests

int slaveAddress;
int commandByte;
int valueByte;
int checksumm;
int readByte1;
int readByte2;
byte bVal;


int majorVersion;
int minorVersion; 
int controlStatusRegister;
int analogSensor[18];

void setup() {

  //Serial.begin(115200);
  Serial.begin(250000);
  
  initI2C(); //Initialise the i2c bus mit verbindung zu HP Netzteil
  digitalWrite(7, HIGH);
  digitalWrite(6, HIGH);
 
}

#define OUTPUT_DISABLE_BIT 3
#define FAN_HI_BIT 5



void loop() {
  //Serial.println("readVersion");  
  //readFirmwareRevision();
 
  Serial.println("readCtrlReg");  
  readControlStatusRegister();
  
  delay(I2C_MESSAGE_DELAY);
  
  // Mit Input 7 kann der Powerausgang aktiviert und deaktivert werden
  int val = digitalRead(7);
  if (val) {
    controlStatusRegister &= ~(1 << OUTPUT_DISABLE_BIT);
  } else {
    controlStatusRegister |= (1 << OUTPUT_DISABLE_BIT);
  }
  // Mit Input 6 kann der Lüfter auf Vollspeed gesetzt werden
  val = digitalRead(6);
  if (val) {
    controlStatusRegister |= (1 << FAN_HI_BIT);
  } else {
    controlStatusRegister &= ~(1 << FAN_HI_BIT);
  }

  setControlStatusRegister(controlStatusRegister); // Enable Power Output
  delay(I2C_MESSAGE_DELAY);
  
  Serial.println("readAnalogSensors");
  readAnalogSensors();
  delay(1000);
  
}

/*
// CommandsIDs for HPS3KW only
#define HP3KWPS_SCRC  0x02 // (Set_Control_Register_Command)
#define HP3KWPS_RSRC  0x03 // (Read_Status_Register_Command)
#define HP3KWPS_RASDC 0x01 // (Read_Analog_Sensor_Data_Command)
*/

// CommandIDs for AA21970
#define HP3KWPS_SCRC  0x01 // (Set_Control_Register_Command)
#define HP3KWPS_RSRC  0x02 // (Read_Status_Register_Command)
#define HP3KWPS_RASDC 0x03 // (Read_Analog_Sensor_Data_Command)


// CommandIDs for AA21970 and HP3KW
#define HP3KWPS_TMC   0x04 //(Test_Mode_Command)
#define HP3KWPS_FDC   0x05 // (Firmware_Debug_Command)
#define HP3KWPS_FRNC  0x06 // (Firmware_Revision_Number_Command)
#define HP3KWPS_STMC  0x07 // (System_Test_Mode_Command)
#define HP3KWPS_STDFC 0x08 // (System_Test_Data_Format_Command)
#define HP3KWPS RRAMC 0x09 // (Read_RAM_Command)
#define HP3KWPS_RSFRC 0x0A // (Read_SFR_Command)


void initI2C() {
  i2c_init();          // join i2c bus
  slaveAddress = I2C_CPU_ADDR<<1;  // Prepare Slave Adressbyte 
}

void reinitI2C() {
  i2c_disableTWI();
  delay(1);
  i2c_init();          // join i2c bus
  slaveAddress = I2C_CPU_ADDR<<1;  // Prepare Slave Adressbyte 
}

/*
Lesen der Firmware Revision 
 
Firmware Revision Number Command (Command #6)
  Firmware Revision Number will be hard coded into the Firmware itself. This command will return the revision
  number of the Firmware. The Firmware Revision Number Command will respond to the following two
  formats:
  
MCU Command Syntax and Packet Length:
  Command 6:   Firmware Revision Number
  Writes:      1 byte
  Syntax:      CMD#6
  Reads:       2 bytes
               1. Major Revision Number
               2. Minor Revision Number
I2C Frameaufbau
  |Start|Slave Address+W|A|0x06|A|Repeated Start|Slave Address+R|A|Major Revision|A|Minor Revision|NA|Stop|

*/
void readFirmwareRevision() {
    commandByte  = HP3KWPS_FRNC;
    bVal = i2c_start(slaveAddress+I2C_WRITE); // set device address and write mode
    if (bVal) {
      reinitI2C();
      Serial.println("start: dev not ready");
      return;
    }
    i2c_write(commandByte);                 // write a databyte to i2c device (command)
    bVal = i2c_rep_start(slaveAddress+I2C_READ);   // set same device address and define read mode
    if (bVal) {
      reinitI2C();
      Serial.println("repstart: dev not ready");
      return;
    }
    majorVersion = i2c_readAck();              // first read is with commandid defined port, readAck define that we will read more bytes from the device
    minorVersion = i2c_readNak();              // next read is the lower port (see documentation), readNak say we are finished with reading
    i2c_stop();
  
    Serial.print("Version ");
    Serial.print(majorVersion);
    Serial.print("/ ");
    Serial.println(minorVersion);  
}

/*
Lesen und Schreiben des Control Status Register
  
Schreiben mit CommandID #1 HP3KWPS_SCRC (???)
Lesen mit CommandID #2 HP3KWPS_RSRC (????)
  
  
Control Status Register
   BIT 7      BIT 6    BIT 5   BIT 4          BIT 3         BIT 2    BIT 1    BIT 0
   PSON_STAT  BAD_CAL  FAN_HI  SELFTEST_FAIL  ROUT_DISABLE  OC_TRIP  OV_TRIP  OT_TRIP
   R          R        R/W     R              R/W           R        R        R
  
* PSON_STAT: This bit is an image of the PSON# signal coming into the power supply from the system.
* BAD_CAL: This bit will be set to indicate a corrupted calibration table. Under this condition the response
to a request for analog data shall be all zeros.
* FAN_HI: Setting this bit will cause the fan run full speed. Reading this bit will tell if the fan is running at
full speed due to internal temperatures or in response to an I2C command.
* SELFTEST_FAIL: This bit will be set to indicate a power supply self-test failure. Under this condition the
response to a request for analog data shall be all zeros.
* ROUT_DISBLE: Remote Output Disable. Setting this bit will disable the main outputs and clearing this bit
will enable the main output.
* OC_TRIP: Over current trip status. This bit is set when the power supply output has been disabled due to
an over current event. In this condition, the Inlet Air temperature will be sensed only when the Amber LED is
off (Every other second) and the ADC update flag will be set according to the other three ADC channel
reading status.
* OV_TRIP: Over voltage trip status. This bit will be set when the power supply outputs have been
disabled and the power supply temperature has not reached the trip limits. This is not a direct sensing of the
over voltage trip circuit.
* OT_TRIP: Over temperature status. This bit will be set when the power supply outputs have been
disabled and the power supply temperature is past the trip limit. This is not a direct sensing of the over
temperature trip circuit.

*/
void readControlStatusRegister() {
    commandByte  = HP3KWPS_RSRC;
    bVal = i2c_start(slaveAddress+I2C_WRITE); // set device address and write mode
    if (bVal) {
      reinitI2C();
      Serial.println("start: dev not ready");
      return;
    }
    i2c_write(commandByte);                 // write a databyte to i2c device (command)
    
    bVal = i2c_rep_start(slaveAddress+I2C_READ);   // set same device address and define read mode
    if (bVal) {
      reinitI2C();
      Serial.println("repstart: dev not ready");
      return;
    }
    controlStatusRegister = i2c_readNak();              // read one byte
    i2c_stop();
  
    Serial.print("CtrlReg:\t");
    Serial.println(controlStatusRegister,BIN);
}

void setControlStatusRegister(int valueByte) {
    commandByte  = HP3KWPS_SCRC;
    checksumm    = valueByte + valueByte;
    bVal = i2c_start(slaveAddress+I2C_WRITE); // set device address and write mode
    if (bVal) {
      reinitI2C();
      Serial.println("start: dev not ready");
      return;
    }
    i2c_write(commandByte);                 // write a databyte to i2c device (command)
    i2c_write(valueByte);                  // write a databyte to i2c device (command)
    i2c_write(valueByte);                  // write a databyte to i2c device (command)
    i2c_write(checksumm);                  // write a databyte to i2c device (command)
    i2c_stop();    
}

/*
  Read Analog Sensor Data
  
  
*/

void readAnalogSensors() {
    commandByte  = HP3KWPS_RASDC;
    bVal = i2c_start(slaveAddress+I2C_WRITE); // set device address and write mode
    if (bVal) {
      reinitI2C();
      Serial.println("start: dev not ready");
      return;
    }
    i2c_write(commandByte);                 // write a databyte to i2c device (command)
    bVal = i2c_rep_start(slaveAddress+I2C_READ);   // set same device address and define read mode
    if (bVal) {
      reinitI2C();
      Serial.println("repstart: dev not ready");
      return;
    }
    for (int i=0; i<17; i++) {
      analogSensor[i] = i2c_readAck();
    }
    analogSensor[17] = i2c_readNak();
    i2c_stop();
      Serial.print("Strom:\t");
      Serial.println(((int)analogSensor[0]+analogSensor[1]*256+analogSensor[2]*65335),DEC);
      Serial.print("max Strom:\t");
      Serial.println(((unsigned int)analogSensor[3]+analogSensor[4]*256+analogSensor[5]*65335),DEC);
      Serial.print("min Strom:\t");
      Serial.println(((int)analogSensor[6]+analogSensor[7]*256+analogSensor[8]*65335),DEC);
      Serial.print("Line Spannung:\t");
      Serial.println(((float)analogSensor[9]+analogSensor[10]*256)/100,2);
      Serial.print("Temperature 1:\t");
      Serial.println(analogSensor[11],DEC);
      Serial.print("Temperature 1 Fehler:\t");
      Serial.println(analogSensor[12],DEC);
      Serial.print("Temperature 1 failed:\t");
      Serial.println(analogSensor[13],DEC);
      Serial.print("Temperature 2:\t");
      Serial.println(analogSensor[14],DEC);
      Serial.print("Temperature 2 Fehler:\t");
      Serial.println(analogSensor[15],DEC);
      Serial.print("Temperature 2 failed:\t");
      Serial.println(analogSensor[16],DEC);
      Serial.print("Temperature updated\t");
      Serial.println(analogSensor[17],DEC);
      Serial.println("\n\r");
      Serial.println("\n\r");
  
//    Serial.print("ReadValues ");
//    for (int i=0; i<18; i++) {
//      Serial.print(i+1);
//      Serial.print(" ");
//      Serial.println(analogSensor[i]);
//    }
//   while(1){;}
}


/*************************************************************************
* Title:    I2C master library using hardware TWI interface
* Author:   Peter Fleury <pfleury@gmx.ch>  http://jump.to/fleury
* File:     $Id: twimaster.c,v 1.3 2005/07/02 11:14:21 Peter Exp $
* Software: AVR-GCC 3.4.3 / avr-libc 1.2.3
* Target:   any AVR device with hardware TWI 
* Usage:    API compatible with I2C Software Library i2cmaster.h
**************************************************************************/

/*************************************************************************
* Patch:    Lukas Simma / 30.04.2001
*           changes in i2c_start if not transmission completed flag 
*           is detected during 1ms then exit function with returncode 1
**************************************************************************/

#include <inttypes.h>
#include <compat/twi.h>

#include "i2cmaster.h"

/* define CPU frequency in Mhz here if not defined in Makefile */
#ifndef F_CPU
#define F_CPU 16000000UL
#endif

/* I2C clock in Hz */
//#define SCL_CLOCK  100000L
#define SCL_CLOCK  50000L


/*************************************************************************
 Initialization of the I2C bus interface. Need to be called only once
*************************************************************************/
void i2c_init(void)
{
  /* initialize TWI clock: 100 kHz clock, TWPS = 0 => prescaler = 1 */
  TWSR = 0;                         /* no prescaler */
  TWBR = ((F_CPU/SCL_CLOCK)-16)/2;  /* must be > 10 for stable operation */

}/* i2c_init */

/*************************************************************************
 Disable TWI Interface, sometimes useful to do a compelete restart if
 the start condition fails permanently
*************************************************************************/
void i2c_disableTWI(void)
{
  TWCR = 0;
}

/*************************************************************************  
  Issues a start condition and sends address and transfer direction.
  return 0 = device accessible, 1= failed to access device
*************************************************************************/
unsigned char i2c_start(unsigned char address)
{
    uint8_t   twst;
    uint8_t   errcnt;
    
  // send START condition
  TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);

  // wait until transmission completed
        errcnt = 0;
  while(!(TWCR & (1<<TWINT))) {
            if (errcnt > 100) {
              return 1;
            }
            errcnt++;
            delay(10);
        }

  // check value of TWI Status Register. Mask prescaler bits.
  twst = TW_STATUS & 0xF8;
  if ( (twst != TW_START) && (twst != TW_REP_START)) return 1;

  // send device address
  TWDR = address;
  TWCR = (1<<TWINT) | (1<<TWEN);

  // wail until transmission completed and ACK/NACK has been received
        errcnt = 0;
  while(!(TWCR & (1<<TWINT))) {
            if (errcnt > 100) {
              return 1;
            }
            errcnt++;
            delay(10);
        }

  // check value of TWI Status Register. Mask prescaler bits.
  twst = TW_STATUS & 0xF8;
  if ( (twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK) ) return 1;

  return 0;

}/* i2c_start */


/*************************************************************************
 Issues a start condition and sends address and transfer direction.
 If device is busy, use ack polling to wait until device is ready
 
 Input:   address and transfer direction of I2C device
*************************************************************************/
void i2c_start_wait(unsigned char address)
{
    uint8_t   twst;


    while ( 1 )
    {
      // send START condition
      TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);
    
      // wait until transmission completed
      while(!(TWCR & (1<<TWINT)));
    
      // check value of TWI Status Register. Mask prescaler bits.
      twst = TW_STATUS & 0xF8;
      if ( (twst != TW_START) && (twst != TW_REP_START)) continue;
    
      // send device address
      TWDR = address;
      TWCR = (1<<TWINT) | (1<<TWEN);
    
      // wail until transmission completed
      while(!(TWCR & (1<<TWINT)));
    
      // check value of TWI Status Register. Mask prescaler bits.
      twst = TW_STATUS & 0xF8;
      if ( (twst == TW_MT_SLA_NACK )||(twst ==TW_MR_DATA_NACK) ) 
      {         
          /* device busy, send stop condition to terminate write operation */
          TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
          
          // wait until stop condition is executed and bus released
          while(TWCR & (1<<TWSTO));
          
          continue;
      }
      //if( twst != TW_MT_SLA_ACK) return 1;
      break;
     }

}/* i2c_start_wait */


/*************************************************************************
 Issues a repeated start condition and sends address and transfer direction 

 Input:   address and transfer direction of I2C device
 
 Return:  0 device accessible
          1 failed to access device
*************************************************************************/
unsigned char i2c_rep_start(unsigned char address)
{
    return i2c_start( address );

}/* i2c_rep_start */


/*************************************************************************
 Terminates the data transfer and releases the I2C bus
*************************************************************************/
void i2c_stop(void)
{
    /* send stop condition */
  TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
  
  // wait until stop condition is executed and bus released
  while(TWCR & (1<<TWSTO));

}/* i2c_stop */


/*************************************************************************
  Send one byte to I2C device
  
  Input:    byte to be transfered
  Return:   0 write successful 
            1 write failed
*************************************************************************/
unsigned char i2c_write( unsigned char data )
{ 
    uint8_t   twst;
    
  // send data to the previously addressed device
  TWDR = data;
  TWCR = (1<<TWINT) | (1<<TWEN);

  // wait until transmission completed
  while(!(TWCR & (1<<TWINT)));

  // check value of TWI Status Register. Mask prescaler bits
  twst = TW_STATUS & 0xF8;
  if( twst != TW_MT_DATA_ACK) return 1;
  return 0;

}/* i2c_write */


/*************************************************************************
 Read one byte from the I2C device, request more data from device 
 
 Return:  byte read from I2C device
*************************************************************************/
unsigned char i2c_readAck(void)
{
  TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWEA);
  while(!(TWCR & (1<<TWINT)));    

    return TWDR;

}/* i2c_readAck */


/*************************************************************************
 Read one byte from the I2C device, read is followed by a stop condition 
 
 Return:  byte read from I2C device
*************************************************************************/
unsigned char i2c_readNak(void)
{
  TWCR = (1<<TWINT) | (1<<TWEN);
  while(!(TWCR & (1<<TWINT)));
  
    return TWDR;

}/* i2c_readNak */

i2cmaster.h

#ifndef _I2CMASTER_H
#define _I2CMASTER_H   1
/************************************************************************* 
* Title:    C include file for the I2C master interface 
*           (i2cmaster.S or twimaster.c)
* Author:   Peter Fleury <pfleury@gmx.ch>  http://jump.to/fleury
* File:     $Id: i2cmaster.h,v 1.10 2005/03/06 22:39:57 Peter Exp $
* Software: AVR-GCC 3.4.3 / avr-libc 1.2.3
* Target:   any AVR device
* Usage:    see Doxygen manual
**************************************************************************/

#ifdef DOXYGEN
/**
 @defgroup pfleury_ic2master I2C Master library
 @code #include <i2cmaster.h> @endcode
  
 @brief I2C (TWI) Master Software Library

 Basic routines for communicating with I2C slave devices. This single master 
 implementation is limited to one bus master on the I2C bus. 

 This I2c library is implemented as a compact assembler software implementation of the I2C protocol 
 which runs on any AVR (i2cmaster.S) and as a TWI hardware interface for all AVR with built-in TWI hardware (twimaster.c).
 Since the API for these two implementations is exactly the same, an application can be linked either against the
 software I2C implementation or the hardware I2C implementation.

 Use 4.7k pull-up resistor on the SDA and SCL pin.
 
 Adapt the SCL and SDA port and pin definitions and eventually the delay routine in the module 
 i2cmaster.S to your target when using the software I2C implementation ! 
 
 Adjust the  CPU clock frequence F_CPU in twimaster.c or in the Makfile when using the TWI hardware implementaion.

 @note 
    The module i2cmaster.S is based on the Atmel Application Note AVR300, corrected and adapted 
    to GNU assembler and AVR-GCC C call interface.
    Replaced the incorrect quarter period delays found in AVR300 with 
    half period delays. 
    
 @author Peter Fleury pfleury@gmx.ch  http://jump.to/fleury

 @par API Usage Example
  The following code shows typical usage of this library, see example test_i2cmaster.c

 @code

 #include <i2cmaster.h>


 #define Dev24C02  0xA2      // device address of EEPROM 24C02, see datasheet

 int main(void)
 {
     unsigned char ret;

     i2c_init();                             // initialize I2C library

     // write 0x75 to EEPROM address 5 (Byte Write) 
     i2c_start_wait(Dev24C02+I2C_WRITE);     // set device address and write mode
     i2c_write(0x05);                        // write address = 5
     i2c_write(0x75);                        // write value 0x75 to EEPROM
     i2c_stop();                             // set stop conditon = release bus


     // read previously written value back from EEPROM address 5 
     i2c_start_wait(Dev24C02+I2C_WRITE);     // set device address and write mode

     i2c_write(0x05);                        // write address = 5
     i2c_rep_start(Dev24C02+I2C_READ);       // set device address and read mode

     ret = i2c_readNak();                    // read one byte from EEPROM
     i2c_stop();

     for(;;);
 }
 @endcode

*/
#endif /* DOXYGEN */

/**@{*/

#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304
#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !"
#endif

#include <avr/io.h>

/** defines the data direction (reading from I2C device) in i2c_start(),i2c_rep_start() */
#define I2C_READ    1

/** defines the data direction (writing to I2C device) in i2c_start(),i2c_rep_start() */
#define I2C_WRITE   0


/**
 @brief initialize the I2C master interace. Need to be called only once 
 @param  void
 @return none
 */
extern void i2c_init(void);

/**
 @brief disalble the I2C master interace, afterwards i2c_init() must be called before any other i2c command is possible  
 @param  void
 @return none
 */
extern void i2c_disableTWI(void);

/** 
 @brief Terminates the data transfer and releases the I2C bus 
 @param void
 @return none
 */
extern void i2c_stop(void);


/** 
 @brief Issues a start condition and sends address and transfer direction 
  
 @param    addr address and transfer direction of I2C device
 @retval   0   device accessible 
 @retval   1   failed to access device 
 */
extern unsigned char i2c_start(unsigned char addr);


/**
 @brief Issues a repeated start condition and sends address and transfer direction 

 @param   addr address and transfer direction of I2C device
 @retval  0 device accessible
 @retval  1 failed to access device
 */
extern unsigned char i2c_rep_start(unsigned char addr);


/**
 @brief Issues a start condition and sends address and transfer direction 
   
 If device is busy, use ack polling to wait until device ready 
 @param    addr address and transfer direction of I2C device
 @return   none
 */
extern void i2c_start_wait(unsigned char addr);

 
/**
 @brief Send one byte to I2C device
 @param    data  byte to be transfered
 @retval   0 write successful
 @retval   1 write failed
 */
extern unsigned char i2c_write(unsigned char data);


/**
 @brief    read one byte from the I2C device, request more data from device 
 @return   byte read from I2C device
 */
extern unsigned char i2c_readAck(void);

/**
 @brief    read one byte from the I2C device, read is followed by a stop condition 
 @return   byte read from I2C device
 */
extern unsigned char i2c_readNak(void);

/** 
 @brief    read one byte from the I2C device
 
 Implemented as a macro, which calls either i2c_readAck or i2c_readNak
 
 @param    ack 1 send ack, request more data from device<br>
               0 send nak, read is followed by a stop condition 
 @return   byte read from I2C device
 */
extern unsigned char i2c_read(unsigned char ack);
#define i2c_read(ack)  (ack) ? i2c_readAck() : i2c_readNak();