程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 7515|回复: 0
打印 上一主题 下一主题

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
2 R& l; x" o: k( K#include <linux/init.h>
  W: G' c7 a9 |) o6 y#include <linux/module.h>6 g$ I4 o' {1 u1 X. N
#include <linux/kernel.h>
4 _* n. M, H- i, j#include <linux/types.h>. S' Q5 z7 x: U5 C! }( E. G
#include <linux/gpio.h>" }9 {4 h1 ^9 h# A& j( [9 S" ~
#include <linux/leds.h>
3 e- R. a& _: z+ U1 B5 Q#include <linux/platform_device.h>
. @# e- E" o& m* r! [( f
2 ~) d6 b6 C' m# V0 F1 z% q#include <asm/mach-types.h>
6 j# X$ d8 J# ^" `; Z" w#include <asm/mach/arch.h>
* S3 y. G. j5 G' y5 A/ k) v#include <mach/da8xx.h>
: H8 ^% x+ v% O" h5 a  w#include <mach/mux.h>
$ v2 j* r3 O$ E( p* A
3 V, `2 K- y7 E$ p#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
+ f- r+ ^$ Y3 c#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
' ?- Z0 ?( b/ S#define DA850_USER_LED2        GPIO_TO_PIN(0, 1); V8 M1 m# X8 {7 _7 z  ]: q# C
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
" A8 W. `% @  X& D2 I/ q. `- j
5 Q5 I. @" H9 j! l9 w5 v0 x/* assign the tl som board LED-GPIOs*/
  I' Z6 B; f" a- f2 Gstatic const short da850_evm_tl_user_led_pins[] = {
+ f( Z$ L7 M5 K2 b. ^5 \        /* These pins are definition at <mach/mux.h> file */$ s* F% ^6 k5 k8 @
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, o: \8 q4 f" Z$ U4 A
        -1/ k! N+ W1 N+ W. I+ E& h
};
7 F+ B8 I- o/ \0 t5 y  \9 y
8 u% J( S. }8 w8 K& `static struct gpio_led da850_evm_tl_leds[] = {" Z% U! y1 p- o  k. r
        {
' C5 x9 j9 q% V; [+ o1 C  H7 O                .active_low = 0,
2 {2 X+ ]( f8 T5 `; Z1 _5 a# Z                .gpio = DA850_USER_LED0,
, D' D+ P5 P; ?4 B( K                .name = "user_led0",
4 t0 n% @4 `; q# X8 x$ n) i                .default_trigger = "default-on",
. T3 Y" g' @. {, ?& ]7 ?3 c        },
! {  n7 q# m  ~+ ^- k" d) X' K        {
- x% J+ P$ }$ n# \# p                .active_low = 0,
; `8 H0 U. S- X/ B- {8 \2 a                .gpio = DA850_USER_LED1,: y  V9 I% u% x0 M
                .name = "user_led1",& Y# ~. S$ V* X  h& ?, Z
                .default_trigger = "default-on",% b: C) {( x. Q$ x' T+ o
        },  |' l9 P  x6 I3 g# O; s, J# s: r
        {  A3 G8 H/ W( M" V, X
                .active_low = 0,
5 k. _4 I: P1 X0 R2 g                .gpio = DA850_USER_LED2,0 L# R; ]. ~, N$ P3 {4 |- b9 E$ s! n
                .name = "user_led2",
: Y7 N8 F) X8 g- Q: f( y6 l                .default_trigger = "default-on",/ L& y* C1 D) L; C/ q- u
        },: W- ^( y( y) ~+ a- v8 X0 Q8 ?
        {
* J* y. I9 C& H4 M                .active_low = 0,, ?2 C/ D: k; [4 u$ w1 l  J0 k
                .gpio = DA850_USER_LED3,
+ w% `" O  S8 g9 r9 M: R" `1 n                .name = "user_led3",
& n5 `7 @. |8 ]# a                .default_trigger = "default-on",. \& D! w1 b3 M% ~2 Z
        },
& C& |6 O0 G5 t/ |0 J; M};
- T+ e( S& S1 k4 U4 Z6 y/ S& N& ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& y2 @  D( U7 R/ U6 ~        .leds = da850_evm_tl_leds,
( n' @! r) O' Z: N( p0 J- H        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 c7 h7 {+ \, N" Z; j  F};
6 a" M$ J$ z& |* ^/ `$ T
/ W! R1 V% Q" Y( D1 ystatic void led_dev_release(struct device *dev)4 U9 p1 c3 s$ G% E0 M* z
{  N; k+ }1 Q" X- v! I- l4 j: w
};. d; K; x& _! x$ B6 h& B

% i' p, a" x8 H& I. H# R3 ]7 mstatic struct platform_device da850_evm_tl_leds_device = {
* E; Y. U3 K& {" i2 ?# |; t( ~1 o        .name                = "leds-gpio",
8 ~" q+ X' V# c- X  }        .id                = 1,: `6 h. @7 S$ D8 @% Q
        .dev = {
: ?: D  I0 J( A7 N/ }1 M4 N" l3 ?6 Q                .platform_data = &da850_evm_tl_leds_pdata,
4 D: t3 K2 W* [' _" A( H% b( K                .release = led_dev_release,
3 q& W( Z4 F& |2 o        }  M) c6 U4 F' M! l
};' d. o5 K: Y  n( X8 R  Q
9 d$ a6 T' }$ i% c( q; Z. Y
static int __init led_platform_init(void)8 f( |; ?6 D& Y
{
6 A. a* C! q! F        int ret;
1 I7 l# k! ~9 W( \! a6 m; z2 `#if 0
: E  K9 U. J2 I% e6 b        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; Z. J' K9 n+ ~: T: k        if (ret)
/ g: D  Q- k' q9 n. z; Y                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ F2 G, I& ~+ i) s+ h
                                "%d\n", ret);
; ]/ d/ B9 W5 y. n& H; o2 E  ~#endif/ @0 q2 k) w5 l/ ]; C5 V
        ret = platform_device_register(&da850_evm_tl_leds_device);; j4 L6 k+ f2 a3 Q3 _2 i
        if (ret)) W& _4 x2 f; z  t7 u7 I+ |
                pr_warning("Could not register som GPIO expander LEDS");
4 T$ g* s: G. z1 x- B, p* W        else- o' o7 Q7 K& x4 S
                printk(KERN_INFO "LED register sucessful!\n");
; Q' h; \& l! p5 s, y- a2 s: c8 \9 |; d- j5 B" w
        return ret;
* f/ W! t) `4 y) g5 D9 J1 q}, A& U( Y. ?6 @
( K7 h6 P! H7 N% A) J$ i. S; Y% M8 [
static void __exit led_platform_exit(void)- s7 s6 r2 S7 s! X8 h7 c
{2 L( e" ?. l% j/ |+ f3 V; L# e
        platform_device_unregister(&da850_evm_tl_leds_device);/ W; ?" H3 S& B5 _$ h

+ j3 f$ O0 k+ o. Y+ ^, ?1 d        printk(KERN_INFO "LED unregister!\n");
1 w% h1 u/ n) E3 B/ }' g( c}6 a, G: J2 ~0 X8 j. m: ~
; z, y6 E3 ], N1 ?' z' n
module_init(led_platform_init);
- ?4 D( P: y/ l, s# Dmodule_exit(led_platform_exit);  o1 ~9 R5 _+ |" Q, o3 U1 P" F$ f7 E; J
- `$ ?* B6 C1 {& r$ t, h2 v
MODULE_DESCRIPTION("Led platform driver");
: N7 |) c) ~! R6 E, gMODULE_AUTHOR("Tronlong");/ j9 F" z1 J4 A
MODULE_LICENSE("GPL");
9 t7 F0 V, j* Q2 e
& P3 {  o! F2 r0 W
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|嵌入式开发者社区 ( 粤ICP备15055271号

GMT+8, 2025-12-28 11:49 , Processed in 0.043637 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

快速回复 返回顶部 返回列表