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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。9 _0 K, w0 Y) ?& B7 i
#include <linux/init.h>
/ Z* v( u% y$ z5 H& |/ P- A* J#include <linux/module.h>
0 a6 V9 U$ _5 ?7 b, Q# i/ u. K#include <linux/kernel.h>3 G3 z- A" y, Y# E" P1 a; E
#include <linux/types.h>" I$ W5 e6 A* p" p$ |2 m" ~
#include <linux/gpio.h>& K6 y6 h1 e0 k6 g% i( d3 D
#include <linux/leds.h>3 x1 {$ G* }/ I
#include <linux/platform_device.h>
3 B! ^9 \$ x! _
7 r' b$ P. c& Y. M0 L8 f#include <asm/mach-types.h>
- H3 I. r: G- o% \4 a5 o! h+ x#include <asm/mach/arch.h>
* J5 T5 z( ~, F6 K  h  D9 M- N#include <mach/da8xx.h>
" ]% w1 T, `) M: ?6 k% M#include <mach/mux.h>
% a2 J! }( D4 l7 `1 d4 U$ q# N; u) u+ \
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
7 f8 x6 @. |# x: j#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
" E4 J+ M2 q, T" E0 \#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
) V* l( E" o% z4 R0 [#define DA850_USER_LED3        GPIO_TO_PIN(0, 2): y% S) L/ e; B6 d
6 a" L) @6 e1 w7 D) c" g, w, j
/* assign the tl som board LED-GPIOs*/5 ^/ U( l* n1 D/ r, P1 g- n* R
static const short da850_evm_tl_user_led_pins[] = {. O. }  Y$ f+ U" O: g0 a- n
        /* These pins are definition at <mach/mux.h> file */9 ?1 U3 L( B9 E2 x4 o& S
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ V) u# X3 J* p* h        -1
6 Q, {1 C: R6 |( X  R" n};
: r; J# q$ w5 F% |$ A% B5 E
2 |: S$ q/ p/ [2 b. v4 @9 ustatic struct gpio_led da850_evm_tl_leds[] = {- a6 y5 d0 \3 m. V8 c
        {) N' ~; ^0 m3 W* s+ ~8 r$ o
                .active_low = 0,/ v" |3 M  b" t/ {2 |2 ?4 v
                .gpio = DA850_USER_LED0,
: q/ a" G/ _0 d( J( w                .name = "user_led0",
2 k9 T! d$ z7 v1 g7 _! e                .default_trigger = "default-on",: w4 E$ s: u: W4 g) g3 @* T0 g
        },# ^% y7 m* n5 ~( C- j/ J8 _
        {
7 g& O" c0 B' t                .active_low = 0,1 `& ], a* H  ~" y; B
                .gpio = DA850_USER_LED1,# h' n# Q) G2 H3 M& u( z6 B
                .name = "user_led1",
7 I% j# {( \# G" b2 T                .default_trigger = "default-on",$ H# U1 ^2 o( e
        },4 q. [9 @/ |, q1 H  o$ a2 g
        {
% n' A4 z# C2 f1 s" q+ q) v7 p" q7 x                .active_low = 0,2 y& s3 R1 F3 U# |2 }
                .gpio = DA850_USER_LED2,: e" t0 ?8 n" Y
                .name = "user_led2",. b" z3 R" \0 w6 g
                .default_trigger = "default-on",
, g$ y" Y& n# V" k0 O# f7 U' b9 K        },
+ P, A; Q, k- i9 _        {
8 l8 _/ |( Z; N6 w: x9 a3 e, o                .active_low = 0,/ L$ ]1 k/ A: f7 c
                .gpio = DA850_USER_LED3,
/ Q8 z! J1 e8 U/ H1 V& y. b0 [                .name = "user_led3",8 J+ B0 Z, z1 I( _  m, d8 V0 e
                .default_trigger = "default-on",
" s; s! q* _% x' c& |- E: ?4 Q        },
6 G4 N7 d7 q6 E! g2 u! ?+ y- ^};
( q0 j) L3 H: A9 Z/ e* X0 @
8 f: ^3 o1 s; L' j3 H  D. tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& Y7 h& j/ h5 T4 B: d- y        .leds = da850_evm_tl_leds,6 H$ {( {: {. I. c* @  ?
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 W4 q: H4 ~% |$ I" W};* L, t# X( q4 O* @

% m) I8 `7 v- N$ m  D* hstatic void led_dev_release(struct device *dev)
  l# I  x8 i$ K- U: M% \{8 {( F) L0 m" U
};5 Z2 U8 V+ u' \4 o3 g* x/ k
7 R- X; N, [* v5 t1 E& p1 u! Z" R
static struct platform_device da850_evm_tl_leds_device = {. T) T* W% x# d
        .name                = "leds-gpio",* u: ~' ]$ R8 ?
        .id                = 1,  Q! F- ~9 Q" C
        .dev = {
8 f# i3 E8 w/ \; t                .platform_data = &da850_evm_tl_leds_pdata,
" y2 y- Y* e* m2 a4 v, W$ J                .release = led_dev_release,6 ~9 V# i) I! |2 `9 e
        }- W6 w$ c. S. ]( H  x) v
};
  G. b/ m% w- C* ^  j5 v& v5 m4 M! f; v; s/ f, Y/ z
static int __init led_platform_init(void)
8 |5 \7 g) J* s: Y# Y2 L0 f/ H8 X{* _3 F# O: I% }( U3 e9 c
        int ret;
2 s% k. x6 l4 r3 a#if 0
) t+ [: ?% }) V0 e0 N" O        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 |/ ]6 S4 [' R  S
        if (ret)
3 @: Z9 P5 D% Z+ e                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 K3 o% m. X* w* h: [
                                "%d\n", ret);
- J( a: B- Y4 V2 H, y8 O#endif, g$ {$ i* Y1 g1 j; A, d
        ret = platform_device_register(&da850_evm_tl_leds_device);8 O! X2 j! R& |
        if (ret)5 l* W3 ~' g8 N: O' R) l
                pr_warning("Could not register som GPIO expander LEDS");( V2 @- `6 j7 V' {7 A
        else
0 K4 z6 M* T3 u5 h; I* h' E                printk(KERN_INFO "LED register sucessful!\n");1 k% J  @/ L2 V' h: V, a

/ t7 t& J1 v( T9 U& L9 Y8 g        return ret;
! d1 a5 v, W8 z- w+ @}/ m  _5 }! V4 l5 ^% S- w

8 W0 v4 ~$ j' t' u& d% ?% Kstatic void __exit led_platform_exit(void)7 s" f( m# t, g
{5 g; H7 y) @1 Z( e& ]
        platform_device_unregister(&da850_evm_tl_leds_device);
& |6 F7 y( Q$ `$ G* E- U; ]6 l: m0 G$ d; l4 d8 _
        printk(KERN_INFO "LED unregister!\n");
# ]" T7 u4 w7 @! h& m! X2 X}2 A& I- X# S- V# R
# \) ?2 }8 Y# \4 G, {5 ]: u# W& c
module_init(led_platform_init);
# i! x: a, V4 }% S$ N! X$ cmodule_exit(led_platform_exit);6 M" w0 Y5 g; G6 r9 a+ \

: w3 G6 Q% t8 j% F- RMODULE_DESCRIPTION("Led platform driver");, ^+ p' z" R1 L, L) W, L
MODULE_AUTHOR("Tronlong");2 q. A" J* ~( Y. `
MODULE_LICENSE("GPL");
1 V  z$ d$ l2 A5 k  R  g' D/ z) t# `$ n# c
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-26 14:46 , Processed in 0.036945 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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