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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
3 P# q+ V7 A$ y( r" A#include <linux/init.h>
& Y2 K* r( B; e: m& O( l* [0 }#include <linux/module.h>
. t+ ^" u8 R, r& j0 r$ Y# H#include <linux/kernel.h>7 i( X8 I( W% O4 Y4 Y  z7 `
#include <linux/types.h>
+ g5 A" U5 R* I7 [#include <linux/gpio.h>, i4 G! S, N, X1 N$ q/ G( l
#include <linux/leds.h>8 E. ?7 g  x6 t# N! u
#include <linux/platform_device.h>/ @# g$ |  A, y& W$ _- b

! i+ ]) l: f% c; a$ V$ `7 q$ B#include <asm/mach-types.h>) ~$ M8 i0 W* ^. G) {  M# u
#include <asm/mach/arch.h>
3 ^3 I+ K/ r( v9 a* s3 u7 t; A$ g#include <mach/da8xx.h>1 x# b. c( y0 |! i5 g6 B& m5 T
#include <mach/mux.h>
9 m# U+ f2 M- l  @. e
# L, m# c* x" h#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)+ u6 X: Y4 k. h. D8 U4 r2 K! N
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)1 z  q* t1 m- d
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
- W, s- V% @0 Y: O5 H" M#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
" U+ m, u! ?. I4 O; ^
! V1 y8 D$ u7 X! \5 H3 ^7 |9 R/* assign the tl som board LED-GPIOs*/
& }; [; N, v5 L+ Q- e2 Pstatic const short da850_evm_tl_user_led_pins[] = {4 Y! J: S; H, Q- e! n% i
        /* These pins are definition at <mach/mux.h> file */
% z- x5 T0 T3 e3 M% {# t& p# C; H        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& j; U& g+ e! q* ]" L
        -1
9 v# o- s. D3 `: Z' @  `};
: s, f2 }$ Y7 H' \% n  v& T  v$ I. J
static struct gpio_led da850_evm_tl_leds[] = {
; l. w) ~5 c* K- t        {
4 W2 w9 |0 i! h+ V; x6 C                .active_low = 0,
0 K% Z( Z" N- W+ F# D                .gpio = DA850_USER_LED0,7 W: s7 X0 _. [# h% T
                .name = "user_led0",4 L3 a* H( P) m" }
                .default_trigger = "default-on",
3 f2 f0 z; e" y        },. ^- M7 i) s) v
        {3 x- P% Z% @6 x5 l; L9 i% U
                .active_low = 0,
! U( N7 b" A% A1 S( R$ C6 H6 K- S                .gpio = DA850_USER_LED1,& \; d9 j$ V6 b! Y# p6 q  r. g- L
                .name = "user_led1",
1 U: J. v6 ~' ^+ {                .default_trigger = "default-on",; j0 i  ~1 c; W% S2 f
        },7 i! s. t- r' d: Z1 o* G" k" B' b1 j
        {# U* r. @: D1 J: ^  ]
                .active_low = 0,
# T; k1 u+ C8 J8 }: l3 c, j                .gpio = DA850_USER_LED2,
6 ~7 {% `1 D  K& b, ~                .name = "user_led2",
' C; n, O) O8 A$ v. @9 N                .default_trigger = "default-on",+ H6 ^3 ~" x, S4 c5 w
        }," a( A" e% q: r9 X9 x% V+ u
        {
( K2 ]# t' Y5 h* ~" a2 A                .active_low = 0,
! _' _% U: S7 h% F! c0 x0 O                .gpio = DA850_USER_LED3," L+ `2 B6 E  p. ~' ]7 d
                .name = "user_led3",
0 u* f+ N' E0 L: D+ ]7 t6 m                .default_trigger = "default-on",- a9 \: [' d9 c2 N4 u
        },
9 L; \* S. S; P5 L};
+ O2 Z- L+ }+ U% f: M
; ~/ z. I% S( f( I  C# c% M. Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; s4 R  I5 d, O7 E6 ]4 F8 S: q        .leds = da850_evm_tl_leds,; Z; Q; ~2 x$ g( v& o
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% Y2 o9 }+ @# S. d4 ^3 |2 D0 M
};
0 \# h8 _2 O  |+ n# P9 }. V3 J( Z7 H% ^! s
static void led_dev_release(struct device *dev)" A  H. t) I* N
{
5 X+ h% G6 s: Z& I2 S& y) E3 t};3 @5 ~% v, k' h, R# j4 V
- W) M/ N2 k) X: s, I) E
static struct platform_device da850_evm_tl_leds_device = {0 g" D5 c" M4 g$ g# C
        .name                = "leds-gpio",# U% E5 h" s0 x
        .id                = 1,
2 M3 J, A* e! o! G* r        .dev = {
/ Q; k' b' H  }8 Y7 f& p                .platform_data = &da850_evm_tl_leds_pdata,
# k) k$ A5 V# E                .release = led_dev_release,
2 F' s8 w4 h7 U( h/ J- q        }' J$ U$ I: Y  W# r, K; L: e9 l
};  ]$ x) w& K: A. H+ Y3 w# R

4 j, R/ K3 n* s, P  A& D1 Xstatic int __init led_platform_init(void)
3 x; A! s6 z$ I; ]7 E0 r{' G/ ~1 ~' X. M8 B
        int ret;
5 c; W! N, Y' N8 J9 l2 i#if 0
# L1 e6 C2 g3 |; |5 U) ?. z        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( P* D. z- `, t' l! l        if (ret)& ]6 K* G: L0 F. l8 l( P# a) ~
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 U' Z0 D" @# R' {                                "%d\n", ret);
5 M" M. ?8 O, U* g7 n8 F, t( Q#endif
+ ?& t$ V, A- w; h        ret = platform_device_register(&da850_evm_tl_leds_device);# S1 ]+ j  k' h. T* |
        if (ret)% k$ i- [. B" M6 I2 V5 ?& Y
                pr_warning("Could not register som GPIO expander LEDS");1 W- ]8 S+ M$ n7 K7 E$ F! k/ d8 F! v
        else: D$ s3 n4 k- A1 c" Y5 d
                printk(KERN_INFO "LED register sucessful!\n");
  h/ u! j4 ^' ?- k
% n  L' i+ z9 p5 V$ ~$ a: J        return ret;0 F  [. X' \1 L% l, R0 p
}: w) ~  ^* w* t! X
0 K: H& V1 s+ w8 f+ C$ w. w% n
static void __exit led_platform_exit(void)
3 M- o6 v% }& B- }{
& r+ B; b. y2 x1 S/ x& F        platform_device_unregister(&da850_evm_tl_leds_device);. q2 b  o( n$ M& ^, r) j5 {

. U; a& x! [7 I# Q1 w3 I# x& o, F. h        printk(KERN_INFO "LED unregister!\n");
" S1 K- i5 R1 {$ n0 L2 g}# x9 T1 U! t! a# s
# G) S, w: v' i7 _8 y  R; R5 M) z0 C
module_init(led_platform_init);
2 N0 {! R6 x- {) O+ I. s) r  jmodule_exit(led_platform_exit);
4 _1 i5 l8 }: V. d0 z/ D. |4 m8 p: }* L
MODULE_DESCRIPTION("Led platform driver");
( |! J# E0 I5 d0 IMODULE_AUTHOR("Tronlong");
3 W' m; Z2 ^( m# h/ cMODULE_LICENSE("GPL");
& b4 K( E. \9 A5 L
7 a7 q2 H9 ?- j% e2 B, x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-11 02:42 , Processed in 0.042253 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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