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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。8 N* Z! r: G8 Z
#include <linux/init.h>0 E# s  K$ T" k- \% j
#include <linux/module.h>
3 c9 M$ P+ t3 v: @#include <linux/kernel.h>
$ r3 z  H7 W! q+ N#include <linux/types.h>
- ^) t4 G$ B0 w* h#include <linux/gpio.h>2 b/ c3 N& H* p
#include <linux/leds.h>
4 f) |' U) l- Y( u9 D) s) c#include <linux/platform_device.h>! G* V3 g6 z& c9 p( c$ a
$ e9 S3 H- Y. m) e1 u4 S: {* g
#include <asm/mach-types.h>2 f- D6 k5 s# R5 s: I- n; g! z
#include <asm/mach/arch.h>
7 c# N2 k+ z1 r" z#include <mach/da8xx.h>
6 w  s: s6 J1 Y- ^7 J7 i#include <mach/mux.h>; x; u' q# s3 _/ t

" [5 B. z$ k4 O#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
+ }4 j9 C. }  F% e8 `2 i- ~#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
7 D4 i5 M$ A; c#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)! l' d8 U" M) \, z" N+ l& q
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
6 ^. w" K' y* A$ y6 h
9 H4 v, s$ _7 {: \4 q6 J/* assign the tl som board LED-GPIOs*/0 {; a/ F  i- K- s" ~  C
static const short da850_evm_tl_user_led_pins[] = {; n6 Z. M* U1 E  @; F1 V* T; F9 U
        /* These pins are definition at <mach/mux.h> file */# Y  ^) N4 ~! U8 s- D) Z1 ]  x
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; J  U+ T; `. l        -1
! T; J9 _" g8 s, S* Y};3 Q  O5 k" Z. V% r. t
! l1 _, A- k! ]9 _+ Q! U
static struct gpio_led da850_evm_tl_leds[] = {
1 }, W. y. o* G% j        {6 P7 \' I9 P3 \0 M% [0 T, P
                .active_low = 0,
0 E: q* z* i+ @1 X                .gpio = DA850_USER_LED0,
+ s5 K) S0 z3 W9 o/ ~                .name = "user_led0",
' s; ^. R% g) C" _, p' m& T% ]                .default_trigger = "default-on",& M" l2 X' f) I  n, @2 X
        },2 B2 k! n) L: F4 c' w
        {6 Z4 T" ^5 o4 w) J
                .active_low = 0,7 z" P0 }% L2 m1 W3 ?
                .gpio = DA850_USER_LED1,
" p1 j4 j; N: u) \+ e                .name = "user_led1",# u0 h: U* K( m# ]
                .default_trigger = "default-on",
4 b' X9 a% S6 a$ Q: O( D& a        },$ V+ t, a! K: b9 _! b! w
        {/ v$ S' O  Q# K8 a2 c
                .active_low = 0,
# @2 c; w. t! X3 |6 I( w                .gpio = DA850_USER_LED2,
" P7 \4 D! P" a3 q. k                .name = "user_led2",6 }3 J' H* ?' ?* R5 }& O* a( `
                .default_trigger = "default-on",9 g5 ^1 d, ]% h7 Y# C3 S7 m; a
        },
, ]: X: ~0 ]# W6 T        {
' j8 A# L& w1 i- M" d) ^; V* b) X                .active_low = 0,  j0 S9 R! C, k3 H0 F& [; r2 g
                .gpio = DA850_USER_LED3,
! W8 J1 G% }9 g1 w                .name = "user_led3",
5 ^& v0 X, F9 _; c2 n6 ?                .default_trigger = "default-on",: U. Z4 q( Y3 H$ ~& S/ y
        },2 l" h; c& T* E( i
};4 J5 _9 n: q8 R3 N0 u

( B, x$ L1 c: M2 E( {6 \! h) d0 ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# S* u# V; _. G) H
        .leds = da850_evm_tl_leds,
" x" g4 d& x; F3 k! x8 T        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, p1 r, W; g0 E9 C" l& D% e1 i* |};# F5 G: N0 k- @; x
: q" O# B3 @% u+ \
static void led_dev_release(struct device *dev)
) C, t0 r* z$ B" `$ {{
, l3 D1 T* Z# V) y; I};
2 N; G) `! p' ]: t8 }* C% O% W* s9 ~! G0 j/ l+ V$ ^
static struct platform_device da850_evm_tl_leds_device = {
! M5 N2 G$ P) r# F& w        .name                = "leds-gpio",) B8 N- D5 h& F# \  M
        .id                = 1,+ K! \6 m2 q% }8 X9 t( b$ A
        .dev = {! T; A+ O2 P7 R! i8 o6 l
                .platform_data = &da850_evm_tl_leds_pdata,  {  \/ A6 T: l2 j0 J
                .release = led_dev_release,
* K% d! _$ o# {) w0 u0 x) d- N* P7 P        }7 i! u7 \: Q8 a# m- Y
};) N7 O; b% i) H+ \* C6 v' R7 O$ h+ t

0 w# D2 ]" F/ G( @static int __init led_platform_init(void)
% W6 [1 g% q" K% E1 P4 q% X{6 ]9 ~$ s" d3 x! X) z  o
        int ret;# z$ O" }1 k% ?
#if 0  `; c* q/ }) q/ s
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 S8 T# D& b* ?' \) A
        if (ret)
0 S4 T$ k: Q) `% ?                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 f% \" {$ ]" U8 e
                                "%d\n", ret);; p1 Q, I! j* s1 b
#endif( c2 d0 V$ F7 D1 \& I' ]$ y
        ret = platform_device_register(&da850_evm_tl_leds_device);$ Y  A( c7 N8 G" Z. [9 g
        if (ret)" G# w7 u: z! a0 y9 I5 b5 E7 r
                pr_warning("Could not register som GPIO expander LEDS");' k. [+ \& J6 {6 F- I
        else8 w8 z- D# ?# H7 N) b0 e* _
                printk(KERN_INFO "LED register sucessful!\n");5 O) ], c  X) w

9 A- y* t$ A& Z1 u+ |5 E/ t8 \' X        return ret;3 z9 e: y! t5 y6 `6 a; U
}
" \) Q, v: v2 U2 P& f6 f' Y9 ~4 a4 v$ B
static void __exit led_platform_exit(void)4 R" v$ E  Z0 R, u# o. Z8 o1 W' |
{, Z6 A* ]$ t8 k$ e+ z$ q
        platform_device_unregister(&da850_evm_tl_leds_device);
% I/ p1 }; I/ m% \
2 e3 w, V' f3 v2 b        printk(KERN_INFO "LED unregister!\n");
4 Y0 c- x7 M; m" d, G/ }( c9 q}; w+ `( v7 S/ f1 D( i  e2 f

, `( T7 ]' H# y+ C1 g; dmodule_init(led_platform_init);/ w$ B2 G" o! a$ R5 g$ |7 l
module_exit(led_platform_exit);
' K- e9 Q3 K/ o* N% J; A8 V& V- ]* h3 \1 p
MODULE_DESCRIPTION("Led platform driver");; x9 j! J2 q! W
MODULE_AUTHOR("Tronlong");
& J+ y" _% ~( ^: [% j9 Z- cMODULE_LICENSE("GPL");1 W$ p' V' z# t% P5 u1 \
, b: ~1 {  ]' n
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-24 10:21 , Processed in 0.038123 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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