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

linuxÖÕ¶ËÉ豸uartÇý¶¯·ÖÎö

ÎÄÕÂÀ´Ô´£ºhttp://blog.chinaunix.net/u3/94284/showart_1982227.html
Ò»:Ç°ÑÔ
½Ó×ÅÇ°ÃæµÄÖն˿ØÖÆ̨·ÖÎö,½ÓÏÂÀ´·ÖÎöserialµÄÇý¶¯.ÔÚlinuxÖÐ,serialÒ²¶ÔÓ¦×ÅÖÕ¶Ë,ͨ³£±»³ÆΪ´®¿ÚÖÕ¶Ë.ÔÚshellÉÏ,ÎÒÃÇ¿´µ½µÄ/dev/ttyS*¾ÍÊÇ´®¿ÚÖÕ¶ËËù¶ÔÓ¦µÄÉ豸½Úµã.
ÔÚ·ÖÎö¾ßÌåµÄserialÇý¶¯Ö®Ç°.ÓбØÒªÏÈ·ÖÎöuartÇý¶¯¼Ü¹¹.uartÊÇUniversal Asynchronous Receiver and TransmitterµÄËõд.·­Òë³ÉÖÐÎļ´Îª”ͨÓÃÒì²½ÊÕ·¢Æ÷”.ËüÊÇ´®¿ÚÉ豸Çý¶¯µÄ·â×°²ã.
¶þ:uartÇý¶¯¼Ü¹¹¸Åò
ÈçÏÂͼËùʾ:
 
 
ÉÏͼÖкìÉ«²¿·Ý±êʶ¼´Îªuart²¿·ÝµÄ²Ù×÷.
´ÓÉÏͼ¿ÉÒÔ¿´µ½,uartÉ豸ÊǼÌtty_driverµÄÓÖÒ»²ã·â×°.ʵ¼ÊÉÏuart_driver¾ÍÊǶÔÓ¦tty_driver.ÔÚËüµÄ²Ù×÷º¯ÊýÖÐ,½«²Ù×÷תÈëuart_port.
ÔÚд²Ù×÷µÄʱºò,ÏȽ«Êý¾Ý·ÅÈëÒ»¸ö½Ð×öcirc_bufµÄ»·Ðλº´æÇø.È»ºóuart_port´Ó»º´æÇøÖÐÈ¡Êý¾Ý,½«ÆäдÈëµ½´®¿ÚÉ豸ÖÐ.
µ±uart_port´ÓserialÉ豸½ÓÊÕµ½Êý¾Ýʱ,»á½«É豸·ÅÈë¶ÔÓ¦line disciplineµÄ»º´æÇøÖÐ.
ÕâÑù.Óû§ÔÚ±àд´®¿ÚÇý¶¯µÄʱºò,Ö»ÏÈҪע²áÒ»¸öuart_driver.ËüµÄÖ÷Òª×÷ÓÃÊǶ¨ÒåÉ豸½ÚµãºÅ.È»ºó½«¶ÔÉ豸µÄ¸÷Ïî²Ù×÷·â×°ÔÚuart_port.Çý¶¯¹¤³Ìʦû±ØÒª¹ØÐÄÉϲãµÄÁ÷³Ì,Ö»Ðè°´Ó²¼þ¹æ·¶½«uart_portÖеĽӿں¯ÊýÍê³É¾Í¿ÉÒÔÁË.
 
Èý:uartÇý¶¯ÖÐÖØÒªµÄÊý¾Ý½á¹¹¼°Æä¹ØÁª
ÎÒÃÇ¿ÉÒÔ×Ô¼º¿¼ÂÇÏÂ,»ùÓÚÉÏÃæµÄ¼Ü¹¹´úÂëÓ¦¸ÃÒªÔõôд.Ê×ÏÈ¿¼ÂÇÒÔϼ¸µã:
1: Ò»¸öuart_driverͨ³£»á×¢²áÒ»¶ÎÉ豸ºÅ.¼´ÔÚÓû§¿Õ¼ä»á¿´µ½uart_driver¶ÔÓ¦Óжà¸öÉ豸½Úµã.ÀýÈç:
/dev/ttyS0  /dev/ttyS1
ÿ¸öÉ豸½ÚµãÊǶÔÓ¦Ò»¸ö¾ßÌåÓ²¼þµÄ,´ÓÉÏÃæµÄ¼Ü¹¹À´¿´,ÿ¸öÉ豸ÎļþÓ¦¸Ã¶ÔÓ¦Ò»¸öuart_port.
Ò²¾ÍÊÇ˵:uart_deviceÔõôͬ¶à¸öuart_port¹ØϵÆðÀ´?ÔõôȥÇø·Ö²Ù×÷µÄÊÇÄÄÒ»¸öÉ豸Îļþ?
 
2:ÿ¸öuart_port¶ÔÓ¦Ò»¸öcirc_buf,ËùÒÔuart_port±ØÐëÒªºÍÕâ¸ö»º´æÇø¹ØϵÆðÀ´
 
»ØÒättyÇý¶¯¼Ü¹¹ÖÐ.tty_driverÓÐÒ»¸ö½Ð³ÉÔ±Ö¸ÏòÒ»¸öÊý×é,¼´tty->ttys.ÿ¸öÉ豸Îļþ¶ÔÓ¦ÉèÊý×éÖеÄÒ»Ïî.¶øÕâ¸öÊý×éËù´úÂëµÄÊý¾Ý½á¹¹Îªtty_struct. ÏàÓ¦µÄtty_struct»á½«tty_driverºÍldisc¹ØÁªÆðÀ´.
ÄÇÔÚuartÇý¶¯ÖÐ,ÊÇ·ñÒ²¿ÉÓÃÏàͬµÄ·½Ê½À´´¦ÀíÄØ?
½«uartÇý¶¯³£ÓõÄÊý¾Ý½á¹¹±íʾÈçÏÂ:
 
 
½áºÏÉÏÃæÌá³öµÄÒÉÎÊ.¿ÉÒÔºÜÇå³þµÄ¿´¶®ÕâЩ½á¹¹µÄÉè¼Æ.
 
ËÄ:uart_driverµÄ×¢²á²Ù×÷
Uart_driver×¢²á¶ÔÓ¦µÄº¯ÊýΪ: uart_register_driver()´úÂëÈçÏÂ:
int uart_register_driver(struct uart_driver *drv)


Ïà¹ØÎĵµ£º

Linux NAND FLASHÇý¶¯´úÂë·ÖÎö

FLASHÇý¶¯ÔÚǶÈëʽϵͳÖÐÓÐמÙ×ãÇáÖصÄλÖ㬶øÄ¿Ç°Êг¡ÉÏNAND FLASHµÄ¼Û¸ñÓÖÒª±ãÒËÓëNOR
FLASH,Ëæ×ÅÔ½À´Ô½¶àµÄƽ̨֧³Ö´ÓNAND FLASHÖÐÆô¶¯£¬ÕÆÎÕNAND
flashµÄÇý¶¯±àдÓÐ×ÅÖØÒªµÄÏÖʵÒâÒ壬ÓÉÓÚÄÚºËÒѾ­Íê³ÉÁ˴󲿷ֵŤ×÷£¬Êµ¼Ê¹¤×÷Öд󲿷ֹ¤³Ìʦ¶ÔNAND
FLASHÇý¶¯Ö»ÊǼòµ¥µÄÐ޸ģ¬¶ÔÆ乤×÷Ô­Àí²¢²»Ì«Çå³þ£¬ÏÂÃæÎÒà ......

LinuxÏà¹ØÃüÁһ£©

linuxÃüÁî´óÈ« cat cd
chmod chown
cp cut
Ãû³Æ£ºcat
ʹÓÃȨÏÞ£ºËùÓÐʹÓÃÕß
ʹÓ÷½Ê½£ºcat [-AbeEnstTuv] [--help] [--version] fileName
˵Ã÷£º°Ñµµ°¸´®Á¬½Óºó´«µ½»ù±¾Êä³ö£¨Ó©Ä»»ò¼Ó > fileName µ½ÁíÒ»¸öµµ°¸£©
²ÎÊý£º
-n »ò --number ÓÉ 1 ¿ªÊ¼¶ÔËùÓÐÊä³öµÄÐÐÊý±àºÅ
-b »ò --number-nonblank ºÍ -n ......

LinuxÏÂÀûÓÃÌõ¼þ±äÁ¿ÊµÏÖ¶ÁдËø

Ê×ÏȽéÉÜÏÂpthread_cond_t¡£ ÔÚLinuxϳÆ֮Ϊ״̬±äÁ¿£¬ÓëÖ®Ïà¹ØµÄÓÐÏÂÃ漸¸öAPI:
    int pthread_cond_init (pthread_cond_t *COND,pthread_condattr_t *cond_ATTR);
    int pthread_cond_signal (pthread_cond_t *COND);
    int pthread_cond_broadcast (pthread_con ......

linuxÉ豸Çý¶¯³ÌÐò±àÒë

ºÜÏë½Ó´¥Ò»ÏÂLinuxµÄÄںˣ¬×î½ü¼ÓÈëÁËLKML£¨Linux Kernel Mailing List£©£¬ÓÌÈ糱ˮ°ãµÄmailÓ¿ÈëÁËÎÒµÄGmail>_<
Ò»¿ªÊ¼ºÜÃÔ㣬Èç´ËÅÓ´óÁËLinuxÄں˴úÂ룬´ÓºÎ¿ªÊ¼£¿ÍøÉÏ¿´µ½ÁËÒ»Ìõ½¨Ò飺´ÓLinuxÉ豸Çý¶¯µÄ±àд¿ªÊ¼¡£
ÓÚÊÇÕÒµ½ÁËÒ»±¾Õâ·½Ãæ±È½ÏºÃµÄ½Ì²Ä£ºLinux Device Drivers, 3rd Edition£¨LDD3£©
²»¹ýÕâ±¾ÊéÀïà ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ