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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。$ T" ?  ^: T" H1 C" N0 _1 _! e
#include <linux/init.h>$ N9 `" O/ }3 ?- z1 K
#include <linux/module.h>
1 [, t9 G  u  J' B#include <linux/kernel.h>
9 b0 d2 l! o1 J) o* j8 r5 V#include <linux/types.h>+ n+ c" n, \2 y" y4 u1 B
#include <linux/gpio.h>
" y5 z( p( C! O#include <linux/leds.h>4 G% k* N$ g* D. q* C- r& m- ?8 X
#include <linux/platform_device.h>
8 b/ v8 y- y! ~: \8 x
' V' M3 s" J* D" P& P#include <asm/mach-types.h>" [" l' _  N, u) p
#include <asm/mach/arch.h>
, b) X. }4 n7 t; t9 j# Z) @! ^" ~#include <mach/da8xx.h>
$ ]3 G  {8 p/ @0 ^#include <mach/mux.h>
0 h" H. D2 e* b7 M) M- `( n4 y3 e4 l4 {6 ~2 L  a' h3 p: I+ _
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)3 z7 w) c" h+ I
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)# K/ C$ Q- L( q7 Q
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
8 K8 w- f4 z$ s" O+ z/ f* p#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)& O& T/ g  k4 s- e; a1 m8 U
# a1 ^" g( V% _0 ^, W
/* assign the tl som board LED-GPIOs*/
# W. U! Z2 X1 \- S% qstatic const short da850_evm_tl_user_led_pins[] = {
( k) Y. c3 P7 \4 S  W8 n  c, Q        /* These pins are definition at <mach/mux.h> file */
3 I- p+ e! b' T! O+ f& c& S% @        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 M( ]% F  I) }( ^        -1! h( n5 J& p5 H% h' E2 q3 c" X# O* f& C
};+ e( `/ V; P/ u# @# N- \

% A6 K" c; N/ @% M! Sstatic struct gpio_led da850_evm_tl_leds[] = {# s. ~  s$ `' Y# K
        {( h8 [1 L9 S+ U( _9 C. t( d4 Y
                .active_low = 0,! v0 a) X9 i' P5 Z& e
                .gpio = DA850_USER_LED0,
% Z& f; m, V& c3 ^( q4 @9 t/ |                .name = "user_led0",$ ^7 i: @3 [; z( i* Y: `& J5 o; L
                .default_trigger = "default-on",1 \0 T6 s0 `, m
        }," C3 x; x6 ~' E. }. w7 X* K+ ^
        {
# H; N0 \" T  p, L                .active_low = 0,& d* b6 _# _9 t0 @# a$ C) J
                .gpio = DA850_USER_LED1,0 y* e. K, T) h+ o+ K& N- Q" k1 y
                .name = "user_led1",$ L8 h0 z. \. O/ _' u" x- }
                .default_trigger = "default-on",  {: k( n2 g( [. L( W8 j6 v  q
        },
' k* r# Z' o& g, G3 T( @, N  w! m        {
. D% M( X+ U. p                .active_low = 0,
) X* f: y  O9 f                .gpio = DA850_USER_LED2,
/ X" ^( c2 O$ v  e3 i! l. K$ C                .name = "user_led2",. l3 Y2 j# Y& p1 F
                .default_trigger = "default-on",9 ~. L3 U0 }" W; _, n+ d; A
        },
0 U+ g8 t) A* g        {( n. y2 [* O1 L4 r# _
                .active_low = 0,
6 O. x: @3 Q7 ]' m                .gpio = DA850_USER_LED3,  O: x; F0 C+ _8 S
                .name = "user_led3",
( A  q* @) K" _/ c7 l1 ~7 G4 l                .default_trigger = "default-on",
( `1 O# {1 Z" y4 ]$ v% r        },
  |/ w8 `/ V) P" N& o};
+ I# ~. ?$ ]2 b' w) k: S6 A  t1 {) X. s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. X5 t1 E. R# g        .leds = da850_evm_tl_leds,1 e% {0 }% N8 i6 T4 }& d  s- T
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. d2 i- N# P. Z: d: X};
$ X. M# T* }5 D: c# U4 y- Z1 C% G8 K& z/ w' q
static void led_dev_release(struct device *dev)
& W9 Y% ?) t/ f: W, n- _{2 k: X# J2 H2 \, N  f
};2 x  r7 {) N5 [* T4 H- U1 e, k9 N
/ D( _" p" X& x! x
static struct platform_device da850_evm_tl_leds_device = {
* l1 q/ i; h8 X; o  s  }        .name                = "leds-gpio",5 o' c/ z4 }/ ^/ P9 ~: b% j" ]
        .id                = 1,
- k2 E) m4 [1 W# Y        .dev = {
9 R& a% P2 C) r1 P0 y) \                .platform_data = &da850_evm_tl_leds_pdata,
, Y$ d% i' c  p5 H+ O- v                .release = led_dev_release,+ D, ^4 M6 K; z5 z! }* {
        }6 k/ P( ~* T- R/ c) S/ \
};
, E( [. K  ^! H1 b4 Z/ [" z$ x3 v( y" W5 m) f! e
static int __init led_platform_init(void)
/ X, u9 Y4 u( H" Z{
$ I! _+ K2 @* C, h; L; B7 C1 h* F0 M        int ret;
% @6 T1 O* j  i9 y- I) L#if 0
1 F% }& B. m9 Q        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ O- ?5 V1 o! a; b( J& _0 F        if (ret)2 ^# n# x6 ~% |; N  K- s2 K/ m
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, W" S+ O5 T5 e5 n                                "%d\n", ret);
  F: l5 b4 n& M, j& c8 u# l8 j: J#endif
, _& A0 k7 `$ z: X% [        ret = platform_device_register(&da850_evm_tl_leds_device);1 t) u" \8 O) E
        if (ret)
- G) R# t/ d" h0 `                pr_warning("Could not register som GPIO expander LEDS");  A0 }" O6 ?) M3 w
        else
% }4 Y; g1 r: P                printk(KERN_INFO "LED register sucessful!\n");
# G0 Y& q3 T1 u; P8 ^! h+ j5 H; }  m
        return ret;: l% ~, `' x$ \) Q" l
}
6 p$ v1 y4 ?! k- Q0 ~9 ]* h3 }; J, R" l' K
static void __exit led_platform_exit(void)3 ?) T1 g$ R- l% S* L
{
! f, b4 N  K4 H3 `  a, D        platform_device_unregister(&da850_evm_tl_leds_device);
/ ?8 Z2 o4 J9 v  w$ o+ S
4 B1 b) ?+ F* e) \! z        printk(KERN_INFO "LED unregister!\n");. W# a# T' u9 K& X0 y
}
/ A. I3 Y% F' @/ c' \8 r, n5 u0 h# ]
: _0 }/ q1 Q& B* X2 cmodule_init(led_platform_init);
; `+ D5 E) p  L! T- O# vmodule_exit(led_platform_exit);
  i- W9 g7 L2 ^& s2 `3 {2 n0 [9 {6 c9 A; q, n/ }- R  e- D! d
MODULE_DESCRIPTION("Led platform driver");, P# D  A5 z3 _
MODULE_AUTHOR("Tronlong");2 H6 B/ _8 i+ Z5 U& m9 @) Q5 ?
MODULE_LICENSE("GPL");- N1 Z1 Y* k! w) m$ G

& k) ?- A# K$ G: w
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-23 19:03 , Processed in 0.042264 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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