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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。  l8 P5 B7 D  R& t5 p3 j5 T% K
#include <linux/init.h>9 g+ A# f7 W6 n8 b% b0 L
#include <linux/module.h>
  N$ i" `  g/ D$ g, ^#include <linux/kernel.h>
5 R" s) _+ I' \3 f! v#include <linux/types.h>4 V. x9 z( k) H" _5 b) ]) g
#include <linux/gpio.h>
- F% k2 W) z8 E# O2 \#include <linux/leds.h>
. t0 _% n( R" G; s7 B  l. T. ]#include <linux/platform_device.h>
: T; o  {3 z: ?
' R8 ~+ ^4 T4 M$ O. n#include <asm/mach-types.h>
! ^9 x# c* [4 d6 h#include <asm/mach/arch.h>
1 b6 H+ N4 O/ b* b#include <mach/da8xx.h>
: r7 l( T/ a; [; I' ?#include <mach/mux.h>4 l0 L) H: B' `4 V6 b1 s
0 _! D* T7 t& L: R) y6 ~
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0). g5 i! L5 m- A" t; d0 D: H
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)$ P% U( N: ]2 \
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)1 @7 M$ [. @& ?* X6 c3 ^! X% N3 B5 l
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
/ z' q, D% y3 Q- y- x5 p5 \. i* f$ Y9 z5 W  B- I  F. \$ W
/* assign the tl som board LED-GPIOs*/+ I1 v1 x1 i. d
static const short da850_evm_tl_user_led_pins[] = {
, h$ G1 S9 u6 w( {        /* These pins are definition at <mach/mux.h> file */
7 O  ]. `7 \% W2 |; n$ T) Y) r        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; y  i" Y- P+ \/ Q$ f
        -1
# |6 ]7 G. ~3 `4 m! U4 b0 T' m+ {};
0 F# C7 C) e( t& Q$ k% ^1 {  r
+ T# r: d3 v* h* d0 ?9 A5 Dstatic struct gpio_led da850_evm_tl_leds[] = {
) L6 ~0 M: n+ c* H9 q        {2 j0 s4 a% M4 q2 ~/ |# x
                .active_low = 0,
. j0 k  K! x* E1 ?2 K) v                .gpio = DA850_USER_LED0,( {- @2 b- w+ m, Z7 ?
                .name = "user_led0",
6 \& j8 n. g1 k$ m                .default_trigger = "default-on",# ?. j% D8 W& F) x/ {
        },
+ t) l+ `9 ?. w! v+ ]3 b        {- _* ^" L8 F, ?# z+ T1 N0 |# c: I- Z
                .active_low = 0,# o, V) x& b5 x! b0 V
                .gpio = DA850_USER_LED1,' O, H+ V* O3 y! e3 Q
                .name = "user_led1",+ j$ f' B, M2 B3 |1 ?9 v$ o) f- a
                .default_trigger = "default-on",. H! L( U6 _+ ?% A
        },6 q1 @3 D1 m- M+ d$ `" Z: E' F  \. U3 B
        {  |& H" ~! B# [8 `# _% n
                .active_low = 0,
9 M/ @% C2 x. j( w. s                .gpio = DA850_USER_LED2,. H$ w# d! |* d7 _8 |; V
                .name = "user_led2",
/ V/ w8 v5 S0 g% d                .default_trigger = "default-on",' T! @- M; G0 c/ e: \  \5 v; E2 P
        },$ Q% S) v) U# A4 {" r
        {
- ^; p. Y9 P) O+ ]                .active_low = 0,, t6 ?9 q  }% j# i+ N
                .gpio = DA850_USER_LED3,
/ W' o0 x# B( |" `* ?                .name = "user_led3",
2 @8 ]0 }* C0 \; m: L0 ]. J                .default_trigger = "default-on",7 D/ N3 K, b5 S" F5 J0 k8 N! ^
        },6 ~0 F3 |: p( E. `/ p% S
};
  u0 G! r* Y1 v7 S
8 ]! h  y8 K* L/ \: G" e' astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 [0 T8 z. Y% A$ |! o% U4 V        .leds = da850_evm_tl_leds,0 z9 o" d: p9 `: ]4 S) L
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 j  K/ D4 A) d/ O2 ]};" R' N# A& J( F/ g; m" I

7 M* O1 [% U+ N% tstatic void led_dev_release(struct device *dev)
+ @* r) N# Z4 z{/ k  K" x& h% M  V# ~1 Q( }
};
5 s$ S0 ^, s+ ^9 b7 p7 O& q  h7 v5 V% C6 X) q. ]$ A$ c
static struct platform_device da850_evm_tl_leds_device = {! B+ A7 o: g1 i2 U
        .name                = "leds-gpio",
" @6 g' Z7 m- R, e2 V/ ~* f; X        .id                = 1,
4 C5 f: [2 ?, [0 ^* S3 v, ^: Y        .dev = {; g1 b3 t9 k# d
                .platform_data = &da850_evm_tl_leds_pdata,
% ]4 k/ _7 g- o  Z2 u, y6 `                .release = led_dev_release,
. w4 n3 l4 P9 a4 }( C        }
) E/ a& w. I* N# X. W: m+ N2 X! g};
4 P8 Z/ f. W" c* b, M: W( a, I5 w
1 Z* y! x* }: tstatic int __init led_platform_init(void)# J; t4 r& A( g& {1 O
{
5 l$ N: R6 ?" w: c        int ret;
+ U& H7 B% d. ]) G1 X8 B#if 0
9 _, t% b1 p+ `# f" r0 t        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# g6 F% y& Y1 [9 ^; e0 B
        if (ret)) B" j# I2 r* q! M5 e3 z! M
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. s; R( e6 j7 M0 X4 u                                "%d\n", ret);
8 H- o" t  {- \1 B+ ]% y#endif
1 \! y" B, E1 R; M8 s4 ^; b' B        ret = platform_device_register(&da850_evm_tl_leds_device);( z6 ~) u( I2 S! J0 U
        if (ret)2 f- C* `: P# C
                pr_warning("Could not register som GPIO expander LEDS");
, u6 t) q# V2 X# C5 l/ {        else3 U) ]6 O) a- h% b. Z, k0 ]
                printk(KERN_INFO "LED register sucessful!\n");/ X6 a  D. V$ D. O+ V, Y$ V, f

0 R1 H, X: n  ?; E        return ret;0 a" e5 E1 |- z* x, {
}
( z! q8 x* V8 }- {6 A
* }% F! N) |4 R: j& N8 [; \static void __exit led_platform_exit(void)
, n) q' ~1 R/ I{
5 g2 w1 v2 e. l9 B# x# E        platform_device_unregister(&da850_evm_tl_leds_device);
4 U! z) w! e7 _) Z+ W$ N
9 Z1 ]! G$ Q- S" u5 X        printk(KERN_INFO "LED unregister!\n");4 S! l8 y/ n* G# ]( E
}5 T+ O* f( f5 a: J  v9 W" D
6 T0 I/ b6 v$ C- p
module_init(led_platform_init);' M( \6 }! J! i1 d8 ~$ G
module_exit(led_platform_exit);
' Y1 w4 c7 i/ _' v$ M" j0 n  t! {/ Q
MODULE_DESCRIPTION("Led platform driver");( U( J0 k6 j; [; ?" Y
MODULE_AUTHOR("Tronlong");$ y( m: z2 ^9 [3 _4 _3 \
MODULE_LICENSE("GPL");8 `& }' [( W3 X* h9 D$ S# K& F4 X; a9 |

. b0 `( [1 t4 T2 A
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-18 23:21 , Processed in 0.039213 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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