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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
. g. W% Z4 C1 k5 i+ c* I+ w#include <linux/init.h>+ `/ |8 `9 L+ A+ \' |2 Q( V
#include <linux/module.h>8 y3 `5 F3 H+ n8 E9 a3 d' t
#include <linux/kernel.h>2 X) L7 \; P0 }: Y
#include <linux/types.h>- q$ E6 H$ C7 {/ W
#include <linux/gpio.h>
$ r" T1 x# }! j" a& n; T3 y#include <linux/leds.h>. X4 J; k8 T3 n
#include <linux/platform_device.h>
4 k. v* C4 u. B4 w3 v' J* b. p' o/ A) Y3 w2 v4 S6 `
#include <asm/mach-types.h>) X$ e# ]5 @, x3 e8 o
#include <asm/mach/arch.h>, S* L) X0 G& L. S
#include <mach/da8xx.h>
% F6 p0 t7 i; F+ L( t; ]1 i#include <mach/mux.h>
% F; @. `# m- b( @4 W! o' V8 J9 |& m3 k
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
* u7 h7 R- ?9 e+ H#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
0 J" j6 Y" t" T6 _" @#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)' O9 g# a0 D7 s. u1 k- {# N, W/ y
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 y  _) C  ]/ R! j; I# Y0 _/ C

8 N  U2 r4 x+ `, B6 S! O- h. k/* assign the tl som board LED-GPIOs*/* A, ]$ Q+ p( W, c! v$ N
static const short da850_evm_tl_user_led_pins[] = {
6 f: H4 J6 X& S        /* These pins are definition at <mach/mux.h> file */
  u8 v$ b; R6 X& w        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 |" u4 W: R& n0 b" I4 b, s& G
        -1
" T  Q# T6 n% U};
1 }% G* b' d5 C" m6 F* h/ H1 w4 b' e, J: @' K. \
static struct gpio_led da850_evm_tl_leds[] = {
4 h; `' {& Y/ M$ h% B# I        {
  ^) O2 t- ?& l/ ~* _* o- f9 i; z                .active_low = 0,
/ _' d5 V6 q, Q" B) ]/ _                .gpio = DA850_USER_LED0,4 B) U' q3 x% }# t( Z% F
                .name = "user_led0",9 ]* T4 r, c. k( {+ @0 O9 E. j
                .default_trigger = "default-on",
' n' k7 x' h* c5 P# ~        },
$ d  `- ~# {, d8 h  O. m        {) c# K( P; g  h# P1 N: g, {
                .active_low = 0,
5 g8 g0 b2 p) }7 y$ Y& X                .gpio = DA850_USER_LED1,
0 P* p' d) F. G, V- Z* I. J1 m' L& i                .name = "user_led1",! x8 C: ~) @" i* e1 S( ^+ [
                .default_trigger = "default-on",
$ J8 M2 G" A7 V2 S0 f8 ~, e* W        },0 A, z7 ^4 m8 S! C* h
        {
# k( O$ ^7 R3 U" C                .active_low = 0,! Z+ \. F9 u; k4 l: f9 j8 a
                .gpio = DA850_USER_LED2,
% Y) s; _: U% ]& V& K/ r                .name = "user_led2",
$ I! m2 W( C* u) H                .default_trigger = "default-on",  l* w) C' }) b
        },
! q, Z9 m2 c8 ]7 B7 P5 `4 k        {- b0 n4 I% j' z1 Y3 |
                .active_low = 0,
  Q+ z1 J5 c1 x8 b+ X. P$ I                .gpio = DA850_USER_LED3,2 Y0 p4 L4 @7 `
                .name = "user_led3",
' Y0 q5 f) \4 V) T                .default_trigger = "default-on",
6 s" v' Z3 a  }" n4 U7 e# K; X9 V        },, l5 I5 }7 y; a. b' f% D2 R
};% D( [" _6 `8 N. f. J
3 j+ ?; b/ Q# i& \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ Z( ~2 c, P! X# E) k. H2 F        .leds = da850_evm_tl_leds,: O  p% O. C8 k4 w
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( P) I# @, ~" v* C};
: E/ j4 e/ Q& R( B4 q+ {. R8 w! k! q$ {# r; e
static void led_dev_release(struct device *dev)
8 p+ r8 ^9 e2 J( C& J0 ?5 s: S{
2 D  [. V' S; P% i/ |  a};; K4 @* ^, b) R

- N" ?7 {& W: k  Xstatic struct platform_device da850_evm_tl_leds_device = {6 D- v9 @+ w6 U4 L
        .name                = "leds-gpio",
: Z0 s6 [7 P% J) n& G5 |/ Q, x        .id                = 1,% ?" o+ B7 u! K7 M* K
        .dev = {7 B2 O7 L4 I- b8 A* X8 A) p
                .platform_data = &da850_evm_tl_leds_pdata,* V+ ]/ W1 Z/ W$ I+ d; f% s- _7 I
                .release = led_dev_release,
4 v9 N3 i0 r5 I- x1 U5 P        }
4 f0 ?/ F1 A2 o% f- @& C# m/ {};
' R+ w* t- @, `
  P5 b6 @% G6 U7 t/ z; xstatic int __init led_platform_init(void)
9 \% ^. k8 o" b; g& M{3 B* v4 H0 D1 ?% |* Z
        int ret;
6 w! s. S' i. b( Q#if 0
: ?! a' f0 l4 D( y2 x) W        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: @/ F0 q% S' s# c
        if (ret)2 _7 P) T+ Y) h. [1 u! T7 G- O
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* B: ?4 q- p) z  ^$ \5 w6 v
                                "%d\n", ret);
( y% o; v3 m0 w$ S0 [1 l% o#endif# _8 ?2 L4 t( C
        ret = platform_device_register(&da850_evm_tl_leds_device);
( M5 ^; ]( A3 V! n9 o        if (ret)9 I7 V9 D' W3 x& `: H: ^2 f$ b# d
                pr_warning("Could not register som GPIO expander LEDS");$ Y, m/ N* [3 j; y& s4 `, C( i
        else
0 K4 j5 f$ a4 l                printk(KERN_INFO "LED register sucessful!\n");9 e/ I7 A* V. |1 ]$ l

2 {6 y- E% ^! m6 n        return ret;7 _( @8 r; i1 j: |" t! T
}0 ?2 u- \, E$ g$ k# A
/ F  p3 M5 t0 H) `7 G
static void __exit led_platform_exit(void)
2 [7 `& H$ i$ }{
6 O; s* r  n2 _+ p% {  C8 c        platform_device_unregister(&da850_evm_tl_leds_device);
! N$ r- T3 |* x5 ~/ p# b
. i$ s- w) v$ p        printk(KERN_INFO "LED unregister!\n");
1 U. _+ e) b# g' F}: q+ G% P9 {  J5 l; h
- w, B* p  o  l
module_init(led_platform_init);
+ A- L3 l6 U% \module_exit(led_platform_exit);8 c* Q& t6 x, a) v% g( Q" m# A
* v" Y% @0 w( S; D6 X
MODULE_DESCRIPTION("Led platform driver");% {6 v2 i, ]# p+ w
MODULE_AUTHOR("Tronlong");
0 }6 e  t3 p, N% {+ qMODULE_LICENSE("GPL");) G( r5 V& x! h; ?9 W4 N$ p
* r# D9 n0 a/ C6 R% w
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-28 22:30 , Processed in 0.036818 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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