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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
7 i* {6 ~5 a- m6 _#include <linux/init.h>( T$ U- M' q* t2 V) b, l0 D4 q
#include <linux/module.h># X1 B! [; B8 \# B+ E
#include <linux/kernel.h>
: |$ @) t# T! w  g2 C/ K6 Q#include <linux/types.h>
5 {- P% i  _& s* y& M#include <linux/gpio.h>1 e) O% [& y: l: S" b
#include <linux/leds.h>: x" F/ x7 B* e% G# w
#include <linux/platform_device.h>
7 F1 X* r; q  N( n! C0 b' r% H* L8 d: R% B9 D& [/ h6 p
#include <asm/mach-types.h>) h3 o: F! _) v& E) J
#include <asm/mach/arch.h>
; b: [; K" C  @* @% j+ {#include <mach/da8xx.h>( q6 b  h. j8 `& K  \/ O3 ^/ s+ o
#include <mach/mux.h>4 X. D* a3 |) P1 ]& N6 b

1 A" |+ F; B2 g* E* S#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)3 T5 S' i# P5 h& J  E
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)) C9 N; K$ I& z" |! ]/ i1 U
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)& d& h6 g  ]9 o. \$ J
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
; X( A4 ~8 m6 w$ N$ b
- w/ B% Y; Y6 ~7 G- V/* assign the tl som board LED-GPIOs*/
4 k5 I0 S) F' F/ Fstatic const short da850_evm_tl_user_led_pins[] = {
) Q$ q' F+ R3 L  b        /* These pins are definition at <mach/mux.h> file */% g0 j& p7 t8 H8 a9 U. L2 W- G% ?* m
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ z7 {9 O+ l: I& f. n5 S* s
        -1
* a! U7 D- _0 {: _5 T; z) k2 J8 [};
9 a- X0 O/ r9 G' S# @
- t0 B+ e; j9 Zstatic struct gpio_led da850_evm_tl_leds[] = {
4 h8 g5 s' h4 C        {
& f1 ^# P2 j& h+ P9 g0 u. ?& h8 B                .active_low = 0," A6 c% t+ d" t# L
                .gpio = DA850_USER_LED0,* r# Y( j- y) t4 ^1 Z, B# E
                .name = "user_led0",# l# Q* ^/ R* W# S9 l) a
                .default_trigger = "default-on",3 z! ?3 c* Y  `
        },. |3 {3 y& ^+ g: M1 |
        {2 b, R0 Q4 P- Q7 b4 B9 S
                .active_low = 0,1 R( Z# x8 T% M5 C
                .gpio = DA850_USER_LED1,
# X4 d+ v7 T& e0 J% d+ M3 w                .name = "user_led1",& h; x) C3 w7 e' V# h) W) O$ F
                .default_trigger = "default-on",! z5 D, a( H8 i
        },
6 h- d# O1 Y/ `* p5 M; e        {
4 q6 ~+ I6 T0 F* I5 b2 y                .active_low = 0,: H7 B' J0 x: a1 }# }& w1 W# o
                .gpio = DA850_USER_LED2,) C! Q$ }7 D' F% i
                .name = "user_led2",! u; h" G  k& t- \3 ~
                .default_trigger = "default-on",
' W* s, r1 M7 h& p( X* s; x        },; x# x* p# ]9 D1 [4 A. b
        {
! c% n# A: ~3 K( A" U" P+ g1 a                .active_low = 0,
1 R) X0 w' D( O                .gpio = DA850_USER_LED3,
3 X) I! K  U5 Z! c                .name = "user_led3",
" S8 B. S  ~; v0 b5 s6 j                .default_trigger = "default-on",
; |6 V! d" n  W        },  |# a2 e8 Y0 P3 H% ~
};
( g- G% U6 ^# M3 {
9 U9 G9 b; [  L: g" ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 s4 M8 p  i/ w        .leds = da850_evm_tl_leds,
5 D4 o. g% F7 m. X* w        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) B) W' G, Y) A
};, b7 L: A& t$ ]

% C2 e8 \7 R. J% M8 Jstatic void led_dev_release(struct device *dev). m# y! E" S/ b' q6 x
{
5 Y1 y4 \- B$ l4 m# q};. Z! z; |- K' C+ E) R- V: J
$ {/ o9 N2 [, U9 j4 o# W( W
static struct platform_device da850_evm_tl_leds_device = {, s1 A8 p9 \, Q- |. k- g# _( S
        .name                = "leds-gpio",
8 d3 \8 B+ G+ L- a, J' n        .id                = 1,
2 ~* F8 \6 }, }% q, n0 T        .dev = {
, q$ U$ l  l2 |6 `7 |% n5 @                .platform_data = &da850_evm_tl_leds_pdata,
1 `- z' J! X6 m( K1 b                .release = led_dev_release,( f5 W$ ~$ C, |, C# y9 C- t
        }4 \3 K  v2 d0 J
};& w  v: Q3 V9 a3 N( L0 A5 {; A1 U
5 [1 H! |+ |! d7 y0 Y  x6 p1 i# ]
static int __init led_platform_init(void)8 t9 m3 H2 m3 J( T% ?
{
! H. i# Y9 e/ ?8 o        int ret;- q0 J( V: F) p8 z) m
#if 0
5 W( U; R' o# D! I        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 t, _3 V5 g' ]- L
        if (ret); h2 ?+ _' F# h9 e. |
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* m2 a0 x# @, z8 l: {: b
                                "%d\n", ret);; O: G, ]! V- `' y0 g$ B+ W5 d  S
#endif
6 e" ~. S6 h7 I5 K6 q        ret = platform_device_register(&da850_evm_tl_leds_device);
* p) }4 f* t0 F        if (ret)# |/ z) X& L1 y. g1 n- r
                pr_warning("Could not register som GPIO expander LEDS");
6 Z$ u% _4 |2 Z- @+ G6 b        else
/ w8 _, _) ]2 g3 U" e% Z( ~' j! r! S                printk(KERN_INFO "LED register sucessful!\n");4 i4 v& U5 g! f2 E: j0 H

4 O6 J/ B% D/ b5 f1 i  W0 A        return ret;8 ^5 x8 h" [$ @
}
0 S2 z* @8 r( j
2 D& v8 W3 \0 l/ y3 a6 L' ystatic void __exit led_platform_exit(void)  C- m4 L9 M) T" p
{: _1 _3 e8 C: c: I
        platform_device_unregister(&da850_evm_tl_leds_device);
  V( S+ \" `: d, v" ]: A
8 m4 y1 F# N. k( P        printk(KERN_INFO "LED unregister!\n");
$ i+ Y" F. S- N6 Y}0 Q/ [+ T7 ]" Q/ C' x: Q
' C! A; r- @% s2 N
module_init(led_platform_init);' t3 r' n% A* F# _7 A
module_exit(led_platform_exit);2 [$ X- I; U5 `0 V- w3 K
8 E8 T8 g3 z; Q- ^+ N
MODULE_DESCRIPTION("Led platform driver");
5 M: O5 E# N( C3 Z, @- \; w3 \0 fMODULE_AUTHOR("Tronlong");' I% C, ?: j8 C! \$ V: [* D, u+ [
MODULE_LICENSE("GPL");* h! l; P2 B1 [. W& q
1 i/ k8 m. z4 L1 W- @' ?% \
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-9 02:54 , Processed in 0.037969 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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