Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C C++ ¶¨Ê±Æ÷ setitime

         setitimer()ΪLinuxµÄAPI£¬²¢·ÇCÓïÑÔµÄStandard Library£¬setitimer()ÓÐÁ½¸ö¹¦ÄÜ£¬Ò»ÊÇÖ¸¶¨Ò»¶Îʱ¼äºó£¬²ÅÖ´ÐÐij¸öfunction£¬¶þÊÇÿ¼ä¸ñÒ»¶Îʱ¼ä¾ÍÖ´ÐÐij¸öfunction£¬ÒÔϳÌÐòdemoÈçºÎʹÓÃsetitimer()¡£
         /*



Filename : timer.cpp

Compiler : gcc 4.1.0 on Fedora Core 5

Description : setitimer() set the interval to run function

Synopsis : #include <sys/time.h>

int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue);

struct itimerval {

struct timerval it_interval;

struct timerval it_value;

};



struct timeval {

long tv_sec;

long tv_usec;

}

Release : 11/25/2006

*/

#include <stdio.h> // for printf()

#include <unistd.h> // for pause()

#include <signal.h> // for signal()

#include <string.h> // for memset()

#include <sys/time.h> // struct itimeral. setitimer()



void printMsg(int);



int main() {

// Get system call result to determine successful or failed

int res = 0;

// Register printMsg to SIGALRM

signal(SIGALRM, printMsg);



struct itimerval tick;

// Initialize struct

memset(&tick, 0, sizeof(tick));

// Timeout to run function first time

tick.it_value.tv_sec = 1; // sec

tick.it_value.tv_usec = 0; // micro sec.

// Interval time to run function

tick.it_interval.tv_sec = 1;

tick.it_interval.tv_usec = 0;

// Set timer, ITIMER_REAL : real-time to decrease timer,

// send SIGALRM when timeout

res = setitimer(ITIMER_REAL,


Ïà¹ØÎĵµ£º

C/C++:³ÌÐòµÄÄÚ´æ·ÖÅ䷽ʽ Alvin

1.ÄÚ´æ·ÖÅ䷽ʽ
¡¡¡¡ÄÚ´æ·ÖÅ䷽ʽÓÐÈýÖÖ£º
¡¡¡¡[1]´Ó¾²Ì¬´æ´¢ÇøÓò·ÖÅä¡£ÄÚ´æÔÚ³ÌÐò±àÒëµÄʱºò¾ÍÒѾ­·ÖÅäºÃ£¬Õâ¿éÄÚ´æÔÚ³ÌÐòµÄÕû¸öÔËÐÐÆڼ䶼´æÔÚ¡£ÀýÈçÈ«¾Ö±äÁ¿£¬static±äÁ¿¡£
¡¡¡¡[2]ÔÚÕ»ÉÏ´´½¨¡£ÔÚÖ´Ðк¯Êýʱ£¬º¯ÊýÄÚ¾Ö²¿±äÁ¿µÄ´æ´¢µ¥Ôª¶¼¿ÉÒÔÔÚÕ»ÉÏ´´½¨£¬º¯ÊýÖ´ÐнáÊøʱÕâЩ´æ´¢µ¥Ôª×Ô¶¯±»ÊÍ·Å¡£Õ»ÄÚ´æ·ÖÅäÔËËãÄÚÖÃÓÚ ......

C/C++µ¥Ôª²âÊÔÀíÂÛ¾«Òª£¨Æߣ©

2.2 ½â¾ö¿É²âÐÔÎÊÌâ
    ÉÏÒ»½Ú¾ßÌå·ÖÎöÁ˿ɲâÐÔÎÊÌ⣬½ÓÏÂÀ´£¬ÎÒÃÇÀ´¿´¿´ÈçºÎ½â¾öÕâЩÎÊÌâ¡£ÏÂͼÖУ¬²ÊÉ«µÄ²¿·ÖÊÇÐèÒª½â¾öµÄ¿É²âÐԵľßÌåµÄÎÊÌâ¡£
   
ÓëÆäËû´úÂë¸ôÀë
    ΪÁËÌá¸ßЧÂÊ£¬Ó¦¸ÃÒ»´ÎÐÔ½«Ò»Î»¹¤³Ìʦ¸ºÔðµÄ²âÊÔÈÎÎñ¸ôÀë³öÀ´¡£¸ôÀëʱ£¬Ó¦°ÑÔ´Îļþ·ÖΪÈýÀࣺ± ......

LinuxÏÂI2CÉ豸Çý¶¯¿ª·¢ºÍʵÏÖ

¡¡I2C×ÜÏß¾ßÓнṹ¼òµ¥Ê¹Ó÷½±ãµÄÌص㡣±¾ÎÄÃèÊöÁËlinuxÏÂI2CÇý¶¯µÄ½á¹¹£¬²¢ÔÚ´Ë»ù´¡Éϸø³öÁËI2CÉ豸Çý¶¯ºÍÓ¦ÓõÄʵÏÖ¡£
¡¡¡¡1  ÒýÑÔ
¡¡¡¡I2C (Inter£­Integrated Circuit)×ÜÏßÊÇÒ»ÖÖÓÉPHILIPS¹«Ë¾¿ª·¢µÄÁ½Ïßʽ´®ÐÐ×ÜÏߣ¬ÓÃÓÚÁ¬½Ó΢¿ØÖÆÆ÷¼°ÆäÍâΧÉ豸¡£I2C×ÜÏß×îÖ÷ÒªµÄÓŵãÊÇÆä¼òµ¥ÐÔºÍÓÐЧÐÔ¡£ÓÉÓÚ½Ó¿ÚÖ±½ÓÔÚ×é¼þÖ ......

LinuxÖÐI2C×ÜÏßÇý¶¯Ìåϵ½á¹¹

×î½üÔÚ¿´Linux 2.6.21Äں˵ÄI2CÇý¶¯£¬Ò²ÔÚÍøÉϲéÁËÒ»ÏÂ×ÊÁÏ£¬ÓдíÒ²Óжԣ¬ÓÐЩÐĵ㬼ǼÏÂÀ´°É¡£ÀïÃæÈÏʶ»òÐí¶àÓв»µ±Ö®´¦£¬»¹¿ÒÇëÖ¸Õý¡£
 
1. I2C ЭÒé
 
 1.1  I2C×ÜÏß¹¤×÷Ô­Àí
      I2C×ÜÏßÊÇÓÉÊý¾ÝÏßSDAºÍʱÖÓSCL¹¹³ÉµÄ´®ÐÐ×ÜÏߣ¬¸÷ÖÖ±»¿ØÖÆÆ÷¼þ¾ù²¢ÁªÔÚÕâÌõ×ÜÏ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ