linux I2CÇý¶¯·ÖÎö
I2CÊÇPhillips¿ª·¢µÄ2ÏߵĴ®ÐÐ×ÜÏßÐÒ顣ͨ³£Ó¦ÓÃÔÚǶÈëʽϵͳÖÐÈò»Í¬µÄ×é¼þͨÐÅ£¬PCÖ÷°å¿ÉÒÔͨ¹ýI2CÀ´Ó벻ͬµÄ´«¸ÐÆ÷ͨÐÅ¡£ÕâЩ´«¸ÐÆ÷ͨ³£±¨¸æ·çÉÈËٶȣ¬´¦ÀíÆ÷ζȺÍÕû¸öÓ²¼þϵͳµÄÐÅÏ¢£¬Õâ¸öÐÒéÒ²¿ÉÒÔÓÃÔÚRAM chipsÉÏ£¬Ïò²Ù×÷ϵͳÌṩDIMMµÄÐÅÏ¢¡£
ÔÚ2.0ʱI2CµÄkernelÔ´Âë²»ÔÚÄÚºËÀïµÄ£¬2.4Äں˰üÀ¨ÁËÒ»µã¶ÔI2CµÄÖ§³Ö£¬Ö÷ÒªÊÇÊÓƵÇý¶¯¡£
ÔÚ2.6ÄÚºËÀ´óÁ¿µÄI2C´úÂë¼ÓÈëµ½ÁËÄÚºËÀï¡£¸ÐлºÜ¶àÄں˿ª·¢ÕßµÄŬÁ¦£¬ËûÃÇÈýӿڸüÈÝÒ×±»ÄÚºËÉçÇø½ÓÊÜ¡£ÓÐЩÇý¶¯ÈÔÔÚÍⲿµÄCVSÊ÷ÀûÓзÅÈëkernel.orgÀµ«ÊÇËûÃDZ»ÒÆÖ²Ö»ÊÇʱ¼äµÄÎÊÌâ¡£
I2CµÄkernelÔ´Âë±»·Ö³É¼¸¸ö²¿·Ö£ºthe I2C core, I2C bus drivers£¬I2C algorithm drivers and I2C chip drivers¡£ÎÒÃǽ«ºöÂÔI2C core²¿·Ö£¬¶øÊǹØ×¢ÈçºÎ±àдa bus and algorithm Çý¶¯¡£
I2C Bus Drivers ×ÜÏßÇý¶¯
I2C×ÜÏßÇý¶¯ÓÃÒ»¸ö½á¹¹i2c_adapterÀ´ÃèÊö£¬¸Ã½á¹¹ÔÚÎļþinclude/linux/i2c.hÀﶨÒå¡£
ÒÔϵÄ×Ö¶ÎÐèÒªÔÚ×ÜÏßÇý¶¯ÀïÉèÖãº
struct module *owner; -set to the value (THIS_MODULE) that allows the proper module reference counting.
unsigned int class; -the type of I2C class devices that this driver supports. Usually this is set to the value I2C_ADAP_CLASS_SMBUS.
struct i2c_algorithm *algo; -a pointer to the struct i2c_algorithm structure that describes the way data is transferred through this I2C bus controller. More information on this structure is provided below.
char name[I2C_NAME_SIZE]; -set to a descriptive name of the I2C bus driver. This value shows up in the sysfs filename associated with this I2C adapter.
ÒÔϵĴúÂëÀ´×ÔÒ»¸öI2C adapterÇý¶¯µÄÀý×Ótiny_i2c_adap.c£¬
¿ÉÒÔÔÚthe Linux Journal FTP site [ftp.ssc.com/pub/lj/listings/issue116/7136.tgz [1]] »ñµÃ¡£
À´¿´¿´struct i2c_adapter ÈçºÎ±»ÉèÖãº
static struct i2c_adapter tiny_adapter = {
.owner = THIS_MODULE,
.class = I2C_ADAP_CLASS_SMBUS,
.algo = &tiny_algorithm,
.name = "tiny adapter",
};
Ҫע²áI2C adapter£¬Çý¶¯µ
Ïà¹ØÎĵµ£º
ÒòΪÏîÄ¿ÒªÇó£¬ÖÆ×÷µÄÒ»¸ö¶àÎļþÉÏ´«£¬²¢ÏÔʾ½ø¶ÈÌõÒ»¶Î´úÂë(vs2005»·¾³)¡£
(ֻΪ´ÖÂÔµÄʵÏÖ£¬´úÂë²¢²»¹æ·¶)
µ±¶à¸öÎļþÉÏ´«µÄʱºò£¬ÐèÒªÒÀ´Î¶ÓÁÐÐÎʽһ¸ö¸öÉÏ´«£¬µ±ÉÏ´«Ä³¸öÎļþµÄʱºò£¬Ëø¶¨½ø³Ì£¬ÉÏ´«Íê±ÏÔÙ¿ªÆôËø¡£
ÔÚÖ÷ÀàÖеÄÉÏ´«°´Å¥Ê¼þ´úÂë:
//
»ñÈ¡openFileDialog¿Ø¼þÑ¡ÔñµÄÎļþÃûÊý×é(openFileDialog¿É ......
#include <iostream>
#include <cstdlib>
using namespace std;
class Foo
{
public:
Foo(int ii):i(ii){}
int getInt(){return i;}
private:
int i;
};
class Bar
{
public:
static int FooVal(){c++; return f.getInt();}
int callsFooVal(){return c;}
private:
s ......
#include<stdio.h>
int cubeByValue(int n);
int main(){
int number = 5 ;
printf("The original value of number is %d\n",number);
number = cubeByValue(number);
printf("The new  ......
ÔÚCÖпÉÒÔ¶¨ÒåÈ«¾Ö±äÁ¿£¬È«¾Ö±äÁ¿ÊÇÔÚ³ÌÐò¼ÓÔسõʼ»¯Ê±·ÖÅä¿Õ¼ä²¢½øÐгõʼ»¯¡£ÔÚc´úÂëÖж¨Òå/ÉùÃ÷È«¾Ö±äÁ¿µÄ·½Ê½ÈçÏÂ
1. int n;
¶¨Òå»òÕßÉùÃ÷£¨Èç¹ûÔÚÆäËûÎļþÖÐÒѶ¨Ò壩ȫ¾Ö±äÁ¿¡£
2. int n = 10;
¶¨ÒåÈ«¾Ö±äÁ¿²¢³õʼ»¯¡£
3. extern int n;
ÉùÃ÷ÔÚÍⲿ¶¨Ò ......
CÖеĿɱä²ÎÊýÑо¿
Ò»£® ºÎν¿É±ä²ÎÊý
int
printf( const char* format, ...);
ÕâÊÇʹÓùýCÓïÑÔµÄÈËËùÔÙÊìϤ²»¹ýµÄprintfº¯ÊýÔÐÍ£¬ËüµÄ²ÎÊýÖÐ
¾ÍÓй̶¨²ÎÊýformatºÍ¿É±ä²ÎÊý£¨ÓÔ…”±íʾ£©. ¶øÎÒÃÇÓÖ¿ÉÒÔÓø÷ÖÖ·½Ê½À´µ÷ÓÃprintf,Èç:
printf("%d",value);
printf("%s",s ......