程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站
点击跳转“创龙科技服务通”

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。. _( N0 U" L/ E. _  r
#include <linux/init.h>
& u; H# W. y  U' N" v#include <linux/module.h>
7 M& p' s4 F6 @" ]8 |# l, |) w#include <linux/kernel.h>
+ }1 p" H+ G* ]9 P2 v/ Y$ m/ q; b#include <linux/types.h>' A: A* W4 f3 y4 n/ U# e0 _
#include <linux/gpio.h>4 W1 ^9 H+ X. J. S: i! w1 Y, j4 a
#include <linux/leds.h>* H# c' |. `9 J) f+ Q$ F
#include <linux/platform_device.h>
  a& |  D, u! F7 Z6 J, s5 Q
3 j3 A7 K/ _0 ^# ?8 H9 J) X+ I, U#include <asm/mach-types.h>- E% J- u5 j7 Z9 t- c$ o: e3 F7 ?
#include <asm/mach/arch.h>( G/ z4 C2 ]+ _. ~7 z
#include <mach/da8xx.h>/ C' [+ \: X1 a2 Z1 c
#include <mach/mux.h>
+ I; [! K, H$ D+ G; G+ k1 j1 z) C0 T( s* B1 K4 x0 P; ?
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
3 ?! K* p3 M7 y, Q* q#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)! j0 U; J" ?" G0 |% f
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
$ Y* l  x4 T9 g1 q9 a( T+ ?( Q& h#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
& [9 V9 v3 G: S, Z
' g. W6 R7 D2 A3 t+ b* v" P# H8 a/* assign the tl som board LED-GPIOs*/* Q' g( U4 Z* k4 S) x
static const short da850_evm_tl_user_led_pins[] = {* f, t( B, n* w+ O) ~0 g$ v
        /* These pins are definition at <mach/mux.h> file */$ \/ m1 E/ [6 X
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 {2 i6 P* v' \/ E" A        -11 m5 R3 @' m8 F
};+ A8 r' [4 x: \7 g, K
. U  [: i$ y" r
static struct gpio_led da850_evm_tl_leds[] = {
# J% W/ H. x; o+ U9 }/ X7 h        {
3 z' d6 ~$ M- `! G. A, J+ P                .active_low = 0,
+ i- k  o! d# S" f  d! e                .gpio = DA850_USER_LED0,7 r+ Y0 U1 L- O2 D$ z3 v" ]. |
                .name = "user_led0",2 s3 J. V/ n0 k# r
                .default_trigger = "default-on",
) U# R7 Z8 f" h1 `4 X        },; a" b3 [; j8 G6 H% X, s
        {' ^  y2 W: A7 h3 v1 M. M, M
                .active_low = 0,, ^( U6 k% C* I) S* t4 ?2 N( X
                .gpio = DA850_USER_LED1,1 M" `3 a' a0 ]: j/ t0 E
                .name = "user_led1",
# O0 d# h2 \7 A. D% t                .default_trigger = "default-on",! B1 ^% g' P5 D& F/ L* L% D6 A& E
        },
. c# I1 J9 O) ~% `) _" ]+ N. u. k        {4 Q! l0 M6 i3 a2 [3 X7 P
                .active_low = 0,0 Z: e5 \" H$ ^8 A0 s
                .gpio = DA850_USER_LED2,
9 Q( b% {) L' y, r7 |7 P$ f$ K                .name = "user_led2",
9 y1 a7 F, |- A) ?$ @- L                .default_trigger = "default-on",
- K4 o" o4 U$ a8 r6 S$ p        },1 f% V% v7 b- I/ r$ [9 p3 T
        {% Y; X2 R2 \. _8 V: y+ \
                .active_low = 0,
4 U; T) T' W' R- K8 m8 W6 h3 V+ v                .gpio = DA850_USER_LED3,
* U& U2 _5 l" P  W, M# ~                .name = "user_led3",
$ i8 u7 {1 z+ |1 H0 M, v4 A1 y$ P                .default_trigger = "default-on",1 {* R" ?+ z" M6 o3 W; C+ j
        },
+ L$ r6 q& X. N6 _! b1 a$ Z) Y: B  g! i};2 R6 h: b6 H/ ^- w- {5 f! f
8 [+ U: K3 X$ c2 ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! U6 K: g8 }! S# ^8 D
        .leds = da850_evm_tl_leds,5 V/ U3 a+ W6 e) {
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& d! x9 l: ^4 F9 |
};
5 P9 R; G( u- x
) g9 Y5 }' V# m" Pstatic void led_dev_release(struct device *dev)% G+ A6 k* w( N6 Y1 _
{
' i# o+ D; M: f& t' k};% w: y5 R6 M" B; g" B

- u4 ?/ L( g4 M) k+ H) s$ |, N/ {static struct platform_device da850_evm_tl_leds_device = {
1 D  t) @& a. W" }4 h3 k        .name                = "leds-gpio",
; P3 H  Z6 ^. R$ _3 I' _        .id                = 1,! ]* p# }% u3 Z% P6 R& E
        .dev = {0 T0 I" s$ e  F- c: ^
                .platform_data = &da850_evm_tl_leds_pdata,% [" y: E+ w7 Y4 \! U+ _
                .release = led_dev_release,9 P3 F8 o) R# m: t  c
        }" Y+ M0 A3 z9 H8 i& ?
};
5 l/ x* @7 ?+ _! l+ ?' M" I; E! q$ D& }; ?$ U  q; W" j
static int __init led_platform_init(void)
. e2 A/ `$ E6 \0 T3 y, R{9 o) {8 U$ c+ n; ?
        int ret;
; ?! g- }# W) l0 a7 P% |  R/ a#if 09 F0 i  e) X: p, `
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; S, ^/ p! l$ t5 B6 E
        if (ret)' i4 i" O/ }. n6 K+ l2 W% v2 _
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& E2 G" k2 ~- t" v8 H
                                "%d\n", ret);
$ a+ d6 g/ H8 g5 V2 G+ G#endif
& [8 F& m) V5 s        ret = platform_device_register(&da850_evm_tl_leds_device);
) d0 T6 Z* u. x* F        if (ret)
5 U# K4 F  D! b                pr_warning("Could not register som GPIO expander LEDS");
% a' K8 F  i  i( F/ Y  `        else* o2 P; U4 K) G' [2 L& a* F) I
                printk(KERN_INFO "LED register sucessful!\n");
6 j$ h2 ]) L( n! R2 ^
: [- y; {" }1 |  h* s8 b        return ret;
# X1 y3 p# y  f3 @}- l; h( E( _* Q6 m% Z& V3 _% |0 S
# }& L; o9 T% B$ K  P4 X
static void __exit led_platform_exit(void)
9 b5 e% B/ O  Q! E{
+ m4 N( k. x0 G        platform_device_unregister(&da850_evm_tl_leds_device);2 v# x# x, p- G5 K

( o* t. z* q$ Z2 D% r/ H        printk(KERN_INFO "LED unregister!\n");
. \9 |& Z  O# {, Z}( `( O' l8 u6 H

) }1 n% B: ?  b9 Umodule_init(led_platform_init);4 V# [' g7 A2 `( L5 ?: F
module_exit(led_platform_exit);
% {7 M' m3 w; H& @; p" t# R
; p1 w2 I4 `" ]: OMODULE_DESCRIPTION("Led platform driver");$ y6 E5 a, b& C; M
MODULE_AUTHOR("Tronlong");/ v' ^9 {: g7 G$ s  C+ f" U& b
MODULE_LICENSE("GPL");( }( |6 Y1 y( s
* ?% ?5 D7 s8 [5 S; ~& c
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

点击跳转“创龙科技服务通”

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

GMT+8, 2026-1-28 11:41 , Processed in 0.041365 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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