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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
( [0 s0 v2 d( T9 S7 L( @; w- X+ q! \#include <linux/init.h>$ x! I% v5 B& q' u# s: c$ H
#include <linux/module.h>
; H( t, X" w% x& g9 G5 p( g#include <linux/kernel.h>* i& j( d6 N: A* Q
#include <linux/types.h>
. K5 G  l" }3 P6 W5 `# U1 ]#include <linux/gpio.h>
* J0 e9 j6 P0 x$ o#include <linux/leds.h>
6 z( l2 V8 i% \* ?/ W#include <linux/platform_device.h>
" C9 b' A8 l- Z4 d+ Q9 a* H" Y' z  y" j3 A  G9 j
#include <asm/mach-types.h>
5 S: g# s9 ~- w3 _6 P8 s#include <asm/mach/arch.h>
* P( F4 j; {# Q, J$ g#include <mach/da8xx.h>
% A, k) O" X( I3 p2 D; I#include <mach/mux.h>
% g) @1 }1 j8 e- A9 ?" o+ Y' t6 Y" y3 V2 ~1 S; h
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
' v9 S! S! f: t' S" v- B#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)# }+ S" F' ~1 Y# B5 G4 a4 g
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)& U, X( @, e0 K& e, ~+ o$ R
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
9 J$ ?5 t- R- t
+ \; D# b+ q4 F. R3 F2 _/* assign the tl som board LED-GPIOs*/: ^# x* G  h& H9 ^% _
static const short da850_evm_tl_user_led_pins[] = {9 E6 w* N6 I) K+ k) G( C
        /* These pins are definition at <mach/mux.h> file */& b& v' W. y: m! T) x+ W
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,  V7 A. O+ i7 F) y
        -1
6 v- ?2 W/ [4 G};5 Q6 V* W+ B1 i8 S4 ^

; G' G; Q( l; i0 v& [static struct gpio_led da850_evm_tl_leds[] = {- a6 x/ n- N0 x
        {
( Y2 O% ?4 a5 e0 n# Z                .active_low = 0,
( W0 F" o: k# M% N                .gpio = DA850_USER_LED0,+ |6 j* g2 X7 j" C
                .name = "user_led0",# V. z) |) M$ y" Q) W" U& ^
                .default_trigger = "default-on",
) h) [9 Y' ^7 `  f7 z' [        },
2 d9 T* V" x) y) Y/ C' h, X        {
9 j2 D  P* k( G. U, K  i7 T                .active_low = 0,- d* x1 [2 |" a2 [4 v4 ?  n- i
                .gpio = DA850_USER_LED1,
2 h) P5 H  Y' _9 I0 M2 ]5 ?                .name = "user_led1",2 p; _0 f7 u% x9 E9 z9 z
                .default_trigger = "default-on",+ E) J1 ^% @6 ^$ ^, y
        },
  f# R  B( S, d        {5 W6 Z- k- t) d) u- ]
                .active_low = 0,
$ I/ Y+ c5 `9 Z$ g% f4 ^  u                .gpio = DA850_USER_LED2,# F  s( Y2 e5 F# F4 x2 S4 @
                .name = "user_led2",; w! w! P9 S1 Z) e1 \. q1 f+ s- }
                .default_trigger = "default-on",* h7 L! q6 v" h# L
        },
# `* l0 M2 _1 @( y+ D        {
( y- j0 g5 S8 C4 v$ J! x                .active_low = 0,
6 A2 q2 o  n1 F  Y                .gpio = DA850_USER_LED3,
: H% j5 M0 s$ P$ i: \; M                .name = "user_led3",( t3 |% d1 \" E6 z& S
                .default_trigger = "default-on"," ~2 s3 x$ l! `0 K3 s5 ]7 _
        },
2 e, `# i( w2 ?! J& ]};
/ r6 C# f! C( m! ]* b" X3 M# O& B2 L! [0 |# b0 a
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
  _/ J1 O% x7 G0 F. c" Y* Q        .leds = da850_evm_tl_leds,' f' K4 r# m7 K7 _" G/ @+ I) }
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 e0 E( w0 t4 n+ g- j; I};( @/ n' G/ V8 ]# \

, X* B- a! F& v, i. M; Estatic void led_dev_release(struct device *dev), Z2 u$ a. W0 Q" d* |( U( Y
{
4 h+ W: P' }# y};
" i) ]2 Z$ K* c. V
# a0 `1 ?/ {; e; C# o3 dstatic struct platform_device da850_evm_tl_leds_device = {
/ l, H; d( p8 q* n6 S% j' g2 w        .name                = "leds-gpio",
1 L3 a- Y; T1 _7 V7 P( ^4 d% L        .id                = 1,
& G& p% K% H9 c9 S        .dev = {
2 g; \$ t/ p* y* v8 o. V8 S$ h/ K                .platform_data = &da850_evm_tl_leds_pdata,3 @) k$ u" @! n  ?% x& E
                .release = led_dev_release,4 D# n4 S  c4 m6 P) Z6 l
        }
& ]+ e$ E( z/ p: ~! n* y# @};" G1 S+ L1 r& ?6 D3 b& w* m

" L; A/ ?# t/ F* C4 Ostatic int __init led_platform_init(void)
: }6 w+ U3 \& G6 ?2 H- J{
6 h" o6 e0 a* K6 N( W/ h+ i        int ret;# c  v6 T, ]2 p4 e6 @( v
#if 09 c6 H6 d: w- b! Z3 \
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 l; z; q9 ?) t9 q- q
        if (ret)
+ m7 j5 S1 ~5 S8 E7 r                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# N8 |; N# E/ H+ p
                                "%d\n", ret);
4 e* y. p# j9 g/ b#endif
- J- r+ \3 y$ [) f# g; j; U        ret = platform_device_register(&da850_evm_tl_leds_device);- ~3 D1 B0 S3 z2 z1 {
        if (ret)2 C: X% r& A# K3 H/ o' H
                pr_warning("Could not register som GPIO expander LEDS");
: s1 P5 q1 j5 x" |  u6 U- Y$ T% u        else
( Y2 z! M: [. f& \1 m3 s$ C9 q                printk(KERN_INFO "LED register sucessful!\n");
' [5 u- K/ O5 c' z
' J$ ^; \' V8 c# h. c- Y        return ret;
8 h/ O" `- O" i" [: s}+ z( q% t* P& [3 i3 Y
* e2 h! V7 s' m7 ~
static void __exit led_platform_exit(void)7 g2 |5 _2 k- T
{
$ S: [' F  a! L! m' o3 Y0 u# o        platform_device_unregister(&da850_evm_tl_leds_device);9 |% r& k; l8 e, e$ A' m

6 \0 [* b0 p* E+ _2 Z9 @        printk(KERN_INFO "LED unregister!\n");
# b# ?! H9 E3 `9 \  v}2 t$ t; W9 C2 @3 h7 N' E

/ a6 e5 o; o. l2 u8 G5 W2 t3 nmodule_init(led_platform_init);
5 `7 W- t; g8 imodule_exit(led_platform_exit);
5 p! h. \9 M9 C3 j! l0 D9 x; U* g9 e* N: h/ {+ N* _% l4 p8 Y3 d
MODULE_DESCRIPTION("Led platform driver");" X( t% g/ L0 ]( ~0 d- l
MODULE_AUTHOR("Tronlong");/ m" f. e% L( R" ]/ \) b
MODULE_LICENSE("GPL");: x) M$ @6 |' }9 \
) h- g7 P/ b/ Q  j, q% A7 b
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-12 23:38 , Processed in 0.037016 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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