Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 770 → Rev 771

/C-OSD/C-Strom/trunk/README.TXT
0,0 → 1,48
/****************************************************************************
* Copyright (C) 2009-2010 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-strom/ *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
****************************************************************************/
 
Console listens at 8n1 19200... Commands are explained there...
 
 
#############################################################################
i2c/twi Sample snipplet
// i2c master libary by Peter Fleury used in this example
// http://homepage.hispeed.ch/peterfleury/avr-software.html#libs
 
#define CSTROM_I2C 0x20
i2c_init();
sei();
union SPI_buffer_t SPI_buffer;
// @see http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=Projects&path=%2FC-OSD%2Ftrunk%2Fspi.h
 
if(!(i2c_start(CSTROM_I2C+I2C_WRITE))) { // check for slave ready
i2c_write(0x00); // start with buffer address 0
i2c_rep_start(CSTROM_I2C+I2C_READ); // start reading
for (uint8_t i = 0; i < 9; i++) { // loop through first 9 positions
SPI_buffer.buffer.c[i] = i2c_readAck();
}
SPI_buffer.buffer.c[9] = i2c_readNak(); // last position does not take ACK
i2c_stop();
}
uart_puts(itoa(SPI_buffer.data.volt, s, 10));
uart_puts_pgm(PSTR("V\r\n"));
#############################################################################