ʵÀý½âÎölinuxÄÚºËI2CÌåϵ½á¹¹
Ò»¡¢¸ÅÊö
̸µ½ÔÚlinuxϵͳϱàдI2CÇý¶¯£¬Ä¿Ç°Ö÷ÒªÓÐÁ½ÖÖ·½Ê½£¬Ò»ÖÖÊÇ°ÑI2CÉ豸µ±×÷Ò»¸ö
ÆÕͨµÄ×Ö·ûÉ豸À´´¦Àí£¬ÁíÒ»ÖÖÊÇÀûÓÃlinux I2CÇý¶¯Ìåϵ½á¹¹À´Íê³É¡£ÏÂÃæ±È½ÏÏÂÕâÁ½ÖÖÇý¶¯¡£
µÚÒ»ÖÖ·½·¨µÄºÃ´¦£¨¶ÔÓ¦µÚ¶þÖÖ·½·¨µÄÁÓÊÆ£©ÓУº
¡ñ ˼·±È½ÏÖ±½Ó£¬²»ÐèÒª»¨Ê±¼äÈ¥Á˽âlinuxÄÚºËÖи´ÔÓµÄI2C×ÓϵͳµÄ²Ù×÷·½·¨¡£
µÚÒ»ÖÖ·½·¨ÎÊÌ⣨¶ÔÓ¦µÚ¶þÖÖ·½·¨µÄºÃ´¦£©ÓУº
¡ñ ÒªÇ󹤳Ìʦ²»½öÒª¶ÔI2CÉ豸µÄ²Ù×÷ÊìϤ£¬¶øÇÒÒªÊìϤI2CµÄÊÊÅäÆ÷²Ù×÷£»
¡ñ ÒªÇ󹤳Ìʦ¶ÔI2CµÄÉ豸Æ÷¼°I2CµÄÉ豸²Ù×÷·½·¨¶¼±È½ÏÊìϤ£¬×îÖØÒªµÄÊÇд³öµÄ³ÌÐò¿ÉÒÆÖ²ÐԲ
¡ñ ¶ÔÄں˵Ä×ÊÔ´ÎÞ·¨Ö±½ÓʹÓá£ÒòΪÄÚºËÌṩµÄËùÓÐI2CÉ豸Æ÷¼°É豸Çý¶¯¶¼ÊÇ»ùÓÚI2C×ÓϵͳµÄ¸ñʽ¡£I2CÊÊÅäÆ÷µÄ²Ù×÷¼òµ¥»¹
ºÃ£¬Èç¹ûÓöµ½¸´ÔÓµÄI2CÊÊÅäÆ÷£¨È磺»ùÓÚPCIµÄI2CÊÊÅäÆ÷£©£¬¹¤×÷Á¿¾Í»á´óºÜ¶à¡£
±¾ÎÄÕë¶ÔµÄ¶ÔÏóÊÇÊìϤI2CÐÒ飬²¢ÇÒÏëʹÓÃlinuxÄÚºË×ÓϵͳµÄ¿ª·¢ÈËÔ±¡£
ÍøÂçºÍһЩÊé¼®ÉÏÓнéÉÜI2C×ÓϵͳµÄÔ´Âë½á¹¹¡£µ«·¢Ïֺܶ࿪·¢ÈËÔ±¿´ÁËÕâЩÎÄÕº󣬻¹ÊÇ
²»Çå³þ×Ô¼º¾¿¾¹¸Ã×öЩʲô¡£¾¿ÆäÔÒò»¹ÊÇûŪÇå³þI2C×ÓϵͳΪÎÒÃÇ×öÁËЩʲô£¬ÒÔ¼°ÎÒÃÇÔõÑùÀûÓÃI2C×Óϵͳ¡£±¾ÎÄÊ×ÏÈÒª½â¾öÊÇÈçºÎÀûÓÃÏÖÓÐÄÚºËÖ§³ÖµÄ
I2CÊÊÅäÆ÷£¬Íê³É¶ÔI2CÉ豸µÄ²Ù×÷£¬È»ºóÔÙ¹ý¶Èµ½ÊÊÅäÆ÷´úÂëµÄ±àд¡£±¾ÎÄÖ÷Òª´Ó½â¾öÎÊÌâµÄ½Ç¶Èȥд£¬²»»áÉæ¼°ÌرðÏêϸµÄ´úÂë¸ú×Ù¡£
¶þ¡¢I2CÉ豸Çý¶¯³ÌÐò±àд
Ê×ÏÈÒªÃ÷È·ÊÊÅäÆ÷Çý¶¯µÄ×÷ÓÃÊÇÈÃÎÒÃÇÄܹ»Í¨¹ýËü·¢³ö·ûºÏI2C±ê×¼ÐÒéµÄʱÐò¡£
ÔÚLinuxÄÚºËÔ´´úÂëÖеÄdrivers/i2c/bussesĿ¼Ï°üº¬×ÅһЩÊÊÅäÆ÷
µÄÇý¶¯¡£ÈçS3C2410µÄÇý¶¯i2c-s3c2410.c¡£µ±ÊÊÅäÆ÷¼ÓÔص½Äں˺󣬽ÓÏÂÀ´µÄ¹¤×÷¾ÍÒªÕë¶Ô¾ßÌåµÄÉ豸±àдÉ豸Çý¶¯ÁË¡£
±àдI2CÉ豸Çý¶¯Ò²ÓÐÁ½ÖÖ·½·¨¡£Ò»ÖÖÊÇÀûÓÃϵͳ¸øÎÒÃÇÌṩµÄi2c-dev.cÀ´ÊµÏÖÒ»
¸öi2cÊÊÅäÆ÷µÄÉ豸Îļþ¡£È»ºóͨ¹ýÔÚÓ¦Óòã²Ù×÷i2cÊÊÅäÆ÷À´¿ØÖÆi2cÉ豸¡£ÁíÒ»ÖÖÊÇΪi2cÉ豸£¬¶ÀÁ¢±àдһ¸öÉ豸Çý¶¯¡£×¢Ò⣺ÔÚºóÒ»ÖÖÇé¿öÏ£¬ÊÇ
²»ÐèҪʹÓÃi2c-dev.cµÄ¡£
1¡¢ÀûÓÃi2c-dev.c²Ù×÷ÊÊÅäÆ÷£¬½ø¶ø¿ØÖÆi2cÉ豸
i2c-dev.c²¢Ã»Ó
Ïà¹ØÎĵµ£º
ÔÚ32λƽ̨ÉϱàÒ붯̬¿âûÓÐɶÎÊÌ⣬Äõ½x86_64λƽ̨ÉϱàÒëʱ³öÏÖÁËÎÊÌâ¡£
relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
ÕÕ×ÅÌáʾ±àÒë´úÂëµÄʱºò¼ÓÈë -fPICÑ¡Ïî¾Íok.
......
linux²¢²»ÊÇʵʱ²Ù×÷ϵͳ£¬°ÑÏÂÃæµÄ´úÂëÔËÐÐÒ»±é¾ÍÄܹ»Àí½âÁË£¬´úÂëÓкÜÏêϸµÄ×¢ÊÍ¡£
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <string.h>
void * thr_fun(void *arg)
{
int policy, ret;
str ......
Ò»¡¢Linux device driver µÄ¸ÅÄî
ϵͳµ÷ÓÃÊDzÙ×÷ϵͳÄں˺ÍÓ¦ÓóÌÐòÖ®¼äµÄ½Ó¿Ú£¬É豸Çý¶¯³ÌÐòÊDzÙ×÷ϵͳÄں˺ͻúÆ÷Ó²¼þÖ®¼äµÄ½Ó¿Ú¡£É豸Çý¶¯³ÌÐòΪӦÓóÌÐòÆÁ±ÎÁËÓ²¼þµÄϸ½Ú£¬ÕâÑùÔÚÓ¦ÓóÌ
Ðò¿´À´£¬Ó²¼þÉ豸ֻÊÇÒ»¸öÉ豸Îļþ£¬Ó¦ÓóÌÐò¿ÉÒÔÏó²Ù×÷ÆÕͨÎļþÒ»Ñù¶ÔÓ²¼þÉ豸½øÐвÙ×÷¡£Éè±¸Ç ......
ÔÚ½øÐÐǶÈëʽ¿ª·¢Ö®Ç°£¬Ê×ÏÈÒª½¨Á¢Ò»¸ö½»²æ±àÒë»·¾³£¬ÕâÊÇÒ»Ì×±àÒëÆ÷¡¢Á¬½ÓÆ÷ºÍlibc¿âµÈ×é³ÉµÄ¿ª·¢»·¾³¡£±¾ÎľßÌå˵Ã÷ÁËǶÈëʽ½»²æ±àÒë»·¾³µÄ½¨Á¢¹ý³Ì
ºÍ¾ßÌåµÄ²Ù×÷²½Ö裬ϣÍûÄܹ»¶Ô¸÷λÅóÓѴ¶ÔÓ¦µÄ½»²æ±àÒë»·¾³ÓÐËù°ïÖú¡£
Ò»¡¢ËùÐèÈíÓ²¼þ»·¾³
¡ö Ö÷»ú»·¾³
½¨Á¢½»²æ±àÒ빤¾ßÁ´µÄÖ÷»ú»·¾³£º
Ubuntu 8.10£¬gcc-4.3 ......
poweroff
shutdown -h Á¢¿Ì¹Ø»ú
shutdown -h 10 10·Öºó¹Ø»ú
shutdown -h 20:25 ʲôʱºò¶¨Ê±¹Ø»ú
shutdown -r now
reboot
pwd ÏÔʾµ±Ç°Â·¾¶
cd .. ·µ»ØÉÏÒ»¼¶
mkdir -p animal/dog Ç¿ÖÆ´´½¨animalĿ¼ÒÔ¼°×ÓĿ¼dog
rm * ɾ³ýÎļþ»òÕßĿ¼
rm -f * Ç¿ÖÆɾ³ý
cat a.txt>>b.ini ½«a.txtÏÔʾ²¢×·¼Óµ½b.iniµÄÄ ......