LinuxÖÐI2C×ÜÏßÇý¶¯Ìåϵ½á¹¹
×î½üÔÚ¿´Linux 2.6.21Äں˵ÄI2CÇý¶¯£¬Ò²ÔÚÍøÉϲéÁËÒ»ÏÂ×ÊÁÏ£¬ÓдíÒ²Óжԣ¬ÓÐЩÐĵ㬼ǼÏÂÀ´°É¡£ÀïÃæÈÏʶ»òÐí¶àÓв»µ±Ö®´¦£¬»¹¿ÒÇëÖ¸Õý¡£
1. I2C ÐÒé
1.1 I2C×ÜÏß¹¤×÷ÔÀí
I2C×ÜÏßÊÇÓÉÊý¾ÝÏßSDAºÍʱÖÓSCL¹¹³ÉµÄ´®ÐÐ×ÜÏߣ¬¸÷ÖÖ±»¿ØÖÆÆ÷¼þ¾ù²¢ÁªÔÚÕâÌõ×ÜÏßÉÏ£¬Ã¿¸öÆ÷¼þ¶¼ÓÐÒ»¸öΨһµÄµØַʶ±ð£¬¿ÉÒÔ×÷Ϊ×ÜÏßÉϵÄÒ»¸ö·¢ËÍÆ÷¼þ»ò½ÓÊÕÆ÷¼þ(¾ßÌåÓÉÆ÷¼þµÄ¹¦Äܾö¶¨)
1.2 I2C×ÜÏߵļ¸ÖÖÐźÅ״̬
1. ¿ÕÏÐ״̬£ºSDAºÍSCL¶¼Îª¸ßµçƽ¡£
2. ¿ªÊ¼Ìõ¼þ(S)£ºSCLΪ¸ßµçƽʱ£¬SDAÓɸߵçƽÏòµÍµçƽÌø±ä£¬¿ªÊ¼´«ËÍÊý¾Ý¡£
3. ½áÊøÌõ¼þ(P)£ºSCLΪµÍµçƽʱ£¬SDAÓɵ͵çƽÏò¸ßµçƽÌø±ä£¬½áÊø´«ËÍÊý¾Ý¡£
4. Êý¾ÝÓÐЧ£ºÔÚSCLµÄ¸ßµçƽÆڼ䣬 SDA±£³ÖÎȶ¨£¬Êý¾ÝÓÐЧ¡£SDAµÄ¸Ä±äÖ»ÄÜ·¢ÉúÔÚSCLµÄµ×µçƽÆڼ䡣
5. ACKÐźÅ: Êý¾Ý´«ÊäµÄ¹ý³ÌÖУ¬½ÓÊÕÆ÷¼þÿ½ÓÊÕÒ»¸ö×Ö½ÚÊý¾ÝÒª²úÉúÒ»¸öACKÐźţ¬Ïò·¢ËÍÆ÷¼þ·¢³öÌض¨µÄµÍµçƽÂö³å£¬±íʾÒѾÊÕµ½Êý¾Ý¡£
1.3 I2C×ÜÏß»ù±¾²Ù×÷
I2C×ÜÏß±ØÐëÓÉÖ÷Æ÷¼þ£¨Í¨³£ÎªÎ¢¿ØÖÆÆ÷£©¿ØÖÆ£¬Ö÷Æ÷¼þ²úÉú´®ÐÐʱÖÓ£¨SCL£©£¬Í¬Ê±¿ØÖÆ×ÜÏߵĴ«Êä·½Ïò£¬²¢²úÉú¿ªÊ¼ºÍÍ£Ö¹Ìõ¼þ¡£
Êý¾Ý´«ÊäÖУ¬Ê×ÏÈÖ÷Æ÷¼þ²úÉú¿ªÊ¼Ìõ¼þ£¬ËæºóÊÇÆ÷¼þµÄ¿ØÖÆ×Ö½Ú£¨Ç°ÆßλÊÇ´ÓÆ÷¼þµÄµØÖ·£¬×îºóһλΪ¶Áдλ £©¡£½ÓÏÂÀ´ÊǶÁд²Ù×÷µÄÊý¾Ý£¬ÒÔ¼° ACKÏìÓ¦Ðźš£Êý¾Ý´«Êä½áÊøʱ£¬Ö÷Æ÷¼þ²úÉúÍ£Ö¹Ìõ¼þ
2. Linux I2C ½á¹¹·ÖÎö
2.1 ²ã´Î·ÖÎö
1. I2C Core
I2C CoreÓÃÓÚά»¤LinuxµÄI2CºËÐIJ¿·Ö£¬ÆäÖÐά»¤ÁËÁ½¸ö¾²Ì¬µÄList£¬·Ö±ð¼Ç¼ϵͳÖеÄI2C driver½á¹¹ºÍI2C adapter½á¹¹¡£
static LIST_HEAD(adapters);
static LIST_HEAD(drivers);
I2C coreÌṩ½Ó¿Úº¯Êý£¬ÔÊÐíÒ»¸öI2C adatper£¬I2C driverºÍI2C client³õʼ»¯Ê±ÔÚI2C coreÖнøÐÐ×¢²á£¬ÒÔ¼°Í˳öʱ½øÐÐ×¢Ïú¡£¾ßÌå¿ÉÒԲμûi2c_core.c´úÂë¡£
ͬʱ»¹ÌṩÁËI2C×ÜÏ߶Áд·ÃÎʵÄÒ»°ã½Ó¿Ú£¨¾ßÌåµÄʵÏÖÔÚÓëI2C¿ØÖÆÆ÷Ïà¹ØµÄI2C adapterÖÐʵÏÖ£©£¬Ö÷ÒªÓ¦ÓÃÔÚI2CÉ豸Çý¶¯ÖС£
³£ÓõÄÖ÷ÒªÊÇ
i2c_master_send()
i2c_master_recv()
i2c_transfer()
2. I2C bu
Ïà¹ØÎĵµ£º
#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;
ÉùÃ÷ÔÚÍⲿ¶¨Ò ......
ÊÖ¶¯Í¨¹ýgrubÃüÁîÐÐÆô¶¯Linux»òÕßwinϵͳ
ǰЩÌìfedoraµÄÆô¶¯²Ëµ¥grub.conf¶ªÊ§£¬ÎÞ·¨½øÈëϵͳ
¡£²»¹ý£¬grubÆô¶¯¹ÜÀí
Æ÷»¹ºÃºÃµÄ£¬Ö»ºÃͨ¹ýgrubÃüÁî
ÐÐÀ´ÊÖ¶¯Òýµ¼Æô¶¯ÏµÍ³ÁË¡£
¡¡¡¡ÔÚ“´ÓÓ²ÅÌ
°²
×°fedora 8
”ÖÐÔø¾ÉÔ΢Ìáµ½¹ý£¬grubÊÇÒ»¸ö¶àϵͳµÄÆô¶¯¹ÜÀíÆ÷£¬²»µ«ÓÐlinux°æ±¾µÄgrub£¬Ò²ÓÐwindows°æ± ......
¡¡I2C×ÜÏß¾ßÓнṹ¼òµ¥Ê¹Ó÷½±ãµÄÌص㡣±¾ÎÄÃèÊöÁËlinuxÏÂI2CÇý¶¯µÄ½á¹¹£¬²¢ÔÚ´Ë»ù´¡Éϸø³öÁËI2CÉ豸Çý¶¯ºÍÓ¦ÓõÄʵÏÖ¡£
¡¡¡¡1 ÒýÑÔ
¡¡¡¡I2C (Inter£Integrated Circuit)×ÜÏßÊÇÒ»ÖÖÓÉPHILIPS¹«Ë¾¿ª·¢µÄÁ½Ïßʽ´®ÐÐ×ÜÏߣ¬ÓÃÓÚÁ¬½Ó΢¿ØÖÆÆ÷¼°ÆäÍâΧÉ豸¡£I2C×ÜÏß×îÖ÷ÒªµÄÓŵãÊÇÆä¼òµ¥ÐÔºÍÓÐЧÐÔ¡£ÓÉÓÚ½Ó¿ÚÖ±½ÓÔÚ×é¼þÖ ......
I2CÊÇPhillips¿ª·¢µÄ2ÏߵĴ®ÐÐ×ÜÏßÐÒ顣ͨ³£Ó¦ÓÃÔÚǶÈëʽϵͳÖÐÈò»Í¬µÄ×é¼þͨÐÅ£¬PCÖ÷°å¿ÉÒÔͨ¹ýI2CÀ´Ó벻ͬµÄ´«¸ÐÆ÷ͨÐÅ¡£ÕâЩ´«¸ÐÆ÷ͨ³£±¨¸æ·çÉÈËٶȣ¬´¦ÀíÆ÷ζȺÍÕû¸öÓ²¼þϵͳµÄÐÅÏ¢£¬Õâ¸öÐÒéÒ²¿ÉÒÔÓÃÔÚRAM chipsÉÏ£¬Ïò²Ù×÷ϵͳÌṩDIMMµÄÐÅÏ¢¡£
ÔÚ2.0ʱI2CµÄkernelÔ´Âë²»ÔÚÄÚºËÀïµÄ£¬2.4Äں˰üÀ¨ÁËÒ»µã¶ÔI2CµÄÖ§³Ö ......