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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。* T$ h  E4 A% e: O6 r
#include <linux/init.h>6 U7 A6 ?3 q1 G& G
#include <linux/module.h>
1 r& u; E5 Y% C) _# c#include <linux/kernel.h>3 f: z/ V+ Z* k* G
#include <linux/types.h>
* L1 D- [5 j4 _) N! V#include <linux/gpio.h>
* d4 O' ~" k. t2 T#include <linux/leds.h>. e7 }" H: u, i5 m$ T
#include <linux/platform_device.h>
- a# L0 D2 _3 \
8 Y1 s4 u7 D8 M4 C: v( F" @#include <asm/mach-types.h>8 i0 Y6 n7 G3 M3 ~
#include <asm/mach/arch.h>7 W8 _4 ^( Y. _- y4 e  [0 X
#include <mach/da8xx.h>; Y5 p" K; t) b9 h
#include <mach/mux.h>( w( q# e- h. v( p5 `$ d
6 ?2 O7 K. F+ Z, o9 R
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)7 {2 r# }9 g0 E3 ?8 N( w
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
2 s6 ?+ w9 U" a- {  n3 h, [#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)% K) f. p: K2 R& j/ Y5 q# J. P: ], p
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
; n0 k) n. G9 y. c% W8 {6 d9 D8 n
/* assign the tl som board LED-GPIOs*/
- j- l, S, f* H+ |) Y1 fstatic const short da850_evm_tl_user_led_pins[] = {- e9 A. \& m- i8 ^7 i% k
        /* These pins are definition at <mach/mux.h> file */
2 m& c) Z& u5 \& l( s, N' \4 @        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! K5 E, d; e' |        -1
" r8 C5 v1 H  Q$ l7 i: }, C4 l& f};3 m$ S8 `4 b6 b4 o

8 x1 M8 u  |3 j0 L) U, u( e' xstatic struct gpio_led da850_evm_tl_leds[] = {6 |1 _4 [7 N& n% d) a
        {" W( X3 `& T( _+ z- I. M
                .active_low = 0,
( k/ }# _+ s- f1 j8 j8 p                .gpio = DA850_USER_LED0,2 M& V0 [5 U2 m3 n4 E1 e. [
                .name = "user_led0",! w" G& v  y$ [# ], |& B( z
                .default_trigger = "default-on",
1 D3 [" e% O, v5 Q, P0 y: U        },$ ]3 E, K8 o, `6 _: K' C) J& \
        {
5 q2 k9 u3 g8 `$ `& u                .active_low = 0,
0 D8 j: \) a/ w* N" n2 c, r. s                .gpio = DA850_USER_LED1,8 C: x/ z- S3 Y1 U0 [8 l5 _9 Q
                .name = "user_led1",
( n* T6 c' G2 ^6 D; ?8 P  y                .default_trigger = "default-on",/ [% W% x& o  E
        },
5 h/ w# B) y% ^9 C        {, U4 o$ U9 s5 b* i
                .active_low = 0,
: b; M* C) y/ q( @' w8 f                .gpio = DA850_USER_LED2,4 k6 Q7 ^+ y/ z( v
                .name = "user_led2",5 F# ^& r# l& t5 u8 V6 ]4 `. d! v
                .default_trigger = "default-on",2 t4 `8 `; ~1 P9 l& H5 f
        },! q: ]) v) Z, c! U& r( u8 j- ~
        {( w6 g: y( d0 X8 ]2 p
                .active_low = 0,; ?6 o1 x' d! Y5 I
                .gpio = DA850_USER_LED3,
9 j1 p- F1 z1 T4 Z  j) i                .name = "user_led3",
6 l2 G. ]0 R- W2 L6 c$ S2 l                .default_trigger = "default-on",
! F$ Q0 [- w1 x4 D5 k        },! V! K; Y1 d+ {8 U* T1 g) ~
};
, i2 ^" k6 g4 f* R; T
' {, E2 [$ r1 V$ Q1 N; h, ^% ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 u& ~$ C+ w6 f) P( o: c! e; M8 @
        .leds = da850_evm_tl_leds,
9 f$ s- J5 z5 U2 m# n" V* A" S        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" y8 _- B% Q# t& I7 I, K};+ y( _! L' W% E

3 `7 w; c: s4 J6 r0 ?5 ^2 e; {; Ystatic void led_dev_release(struct device *dev)
' H% o; M7 K" ]  r" n{
4 T8 J0 k0 [$ k$ p. b; Z' |: \  n};
. q3 ?/ z/ J% R* O3 x
; B  }# ^0 E/ K4 Nstatic struct platform_device da850_evm_tl_leds_device = {
- U2 b1 A/ @6 I% J2 R9 u        .name                = "leds-gpio",
8 s" }- G9 R& D. \& d- R/ z. G1 f        .id                = 1,
$ @) Q4 O  t) j3 g: n& d2 q        .dev = {- f* B+ s1 ~! Y5 f, W
                .platform_data = &da850_evm_tl_leds_pdata,
/ c: c: f4 P) c3 Z" ]4 ^# g                .release = led_dev_release,& x. G2 y1 X6 `
        }
; }* i& A7 J% {};
) K$ M/ O8 ^( f) L; K
- d; ]( n7 w" b5 B$ K& F: Bstatic int __init led_platform_init(void)+ l$ S3 L5 l9 O- p
{* A5 E7 D& G& a' u$ Y* e
        int ret;
. E3 h$ `' U# P4 |/ ]: n#if 0( t  f1 \; T. N6 I; M& f
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
  ^$ B' N5 J4 p+ `1 j: M' \        if (ret)
5 ~' \* k5 K; p5 b0 n3 w  k2 f5 k                pr_warning("da850_evm_tl_leds_init : User LED mux failed :", P5 [6 k2 d, Q; m7 q0 w2 O
                                "%d\n", ret);
% x. t( ?& O* W; t) r#endif; k* o3 m& E8 w7 L
        ret = platform_device_register(&da850_evm_tl_leds_device);" V2 u  l3 b" M* f0 ~; t. m
        if (ret)
3 H6 s' m2 k% l9 Q' B                pr_warning("Could not register som GPIO expander LEDS");7 i8 P" {# ~9 ?! Q
        else- ]8 a5 @$ m) `3 t
                printk(KERN_INFO "LED register sucessful!\n");" N! n& J) r- C  E0 l; r
# I0 a9 [( K4 L+ _
        return ret;3 ?; Y! g+ ]' X1 T" x3 J
}6 t! F: ]% y- P+ u0 G
* b: Z6 m9 g1 x; Q& o& i
static void __exit led_platform_exit(void); r! X: U) V$ g
{8 ?- V( L* h' ~! J8 Y: G; U
        platform_device_unregister(&da850_evm_tl_leds_device);
# p! M; p/ Y4 |( K6 J+ S7 f* u/ T; d
        printk(KERN_INFO "LED unregister!\n");# S/ I# O: w$ e8 S0 _
}
" @- t* N" M% q% T3 L" z2 s9 z, K, u( G' ]
$ x  ]! [5 S0 p5 o+ G$ zmodule_init(led_platform_init);3 T: D8 x# U$ n6 p# e  \
module_exit(led_platform_exit);0 u, p8 f4 ]. V4 F

2 F, C# [5 ?2 F% Z) g1 nMODULE_DESCRIPTION("Led platform driver");
0 E; f& l- E, d0 @! WMODULE_AUTHOR("Tronlong");# R5 A; ~8 |# i2 C" X/ F
MODULE_LICENSE("GPL");; j: Y; z# j0 V4 I  l% X% a( H8 I

& ^4 L; P. Z2 b" S# I! K
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-11 08:16 , Processed in 0.041292 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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