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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。* D- J* j- k6 [6 Y  t4 X( l( {
#include <linux/init.h>
8 u) t) K* c' R% n; s  b#include <linux/module.h>5 x* Y" A. U, U, c) p2 ~
#include <linux/kernel.h>8 m) ~7 |+ T! n1 u; I
#include <linux/types.h>
0 ^9 h8 O/ q, D( N" D" }: `0 _#include <linux/gpio.h>6 D2 F1 @3 L' [; C, _0 }: q+ p
#include <linux/leds.h>
( s" Z% Y; ^: p5 V* g* K- B! }#include <linux/platform_device.h>5 p) J, ]0 i- ~8 V
; _9 i! |# z  {
#include <asm/mach-types.h>
; [: F5 \- |: s% l% J8 |# S3 l- Y* X/ {#include <asm/mach/arch.h>
8 N9 q4 i- T/ D: b' N#include <mach/da8xx.h>
+ B. b7 m2 g* Z#include <mach/mux.h>
& `) O, k. o4 A8 n) p  Z; v
1 @( g4 _3 s, w  y+ h#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
& S% l7 @% {3 ]3 \/ G#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)9 W3 Y; {9 b" N  G$ ?$ H
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
( f3 J% p$ u$ E5 r#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
& o# Y4 H# Z" n# J, `/ u3 Y# f0 \' E$ F! m* D
/* assign the tl som board LED-GPIOs*/
) F5 p2 g. R% C  A: R: Pstatic const short da850_evm_tl_user_led_pins[] = {  r0 g8 y# {/ B2 h% D& s/ e6 `
        /* These pins are definition at <mach/mux.h> file */
( M5 V2 P; q$ L7 R+ {# ^/ S+ F        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 C& K# g3 z: f) g        -17 L& \% ]8 a+ L) M
};1 x5 R0 Y/ T: Z
3 Y  b$ a4 b+ t; n
static struct gpio_led da850_evm_tl_leds[] = {
# ~. \, P- g! `5 m        {
) C6 |: U# c$ F) z                .active_low = 0,% ~; Y: Z: e. D' H- j: W! @
                .gpio = DA850_USER_LED0,1 U% q2 O6 w) r6 m3 d% e
                .name = "user_led0",; f; H' p+ w) i6 R" i
                .default_trigger = "default-on",1 X" `7 ?( w8 Y! X0 v: @( i
        },
' C+ I& I& `1 x9 r; r( S7 j  J* H        {
0 ~% [. l4 ]2 l$ [' t; @& w% O                .active_low = 0,  `) i% \8 q8 @. W8 H! o
                .gpio = DA850_USER_LED1,
! X' n* Z! R4 Q- ~) _6 D  K, A                .name = "user_led1",
) P1 a# E# C8 u9 e% N" K% U% y0 j5 [                .default_trigger = "default-on",) `7 q7 m$ I4 l9 J1 ^. ~
        },! I/ M( N( {2 Q6 K8 d
        {
9 ^& A; @8 S# k  `' z2 p                .active_low = 0,7 ], `; l  j+ j3 h9 d
                .gpio = DA850_USER_LED2,
3 r6 }- R/ v8 l' U2 L( t                .name = "user_led2",: g- k# J' S* x4 Z
                .default_trigger = "default-on",# ^. z. k+ m" O) h/ k
        },5 l& [3 O4 p, [& x* Z6 F* {5 l
        {
% ~' V  Y& X" P                .active_low = 0,2 z* V& Z- Y% g! k% h
                .gpio = DA850_USER_LED3,; p! V6 l$ R1 W1 K, x2 {, _& y
                .name = "user_led3",* s! M% `5 ^. ~* ?+ c
                .default_trigger = "default-on",
9 e  X! W! R# f7 W! j! A, p; E        },; ^$ k7 u* K$ j  j
};
% Q4 D- ?  q% ^" S: C0 |# T
$ q+ P) J5 e" Q! s2 k& a* _' \2 vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ l& J# w" R) K, [& p        .leds = da850_evm_tl_leds,0 x3 p5 O4 T8 [9 ?7 {- n/ C9 i% d
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 a: [5 `  Y2 r& ?, ~8 R# ^/ ]6 z
};
: ~9 B0 G6 a3 I9 z5 u6 V0 x+ r* _7 b
static void led_dev_release(struct device *dev)
7 B! m$ t( {( P/ f+ K{
. M5 K( v! d7 D+ g6 b4 N4 Q};. Z/ p: ~! R0 i

8 Y* V+ Y/ W7 s- ]static struct platform_device da850_evm_tl_leds_device = {
9 m3 t) I% P& e0 f% O3 O9 F        .name                = "leds-gpio",
; u, G3 x& o. w( R* T2 y        .id                = 1,$ F+ O8 X7 u) _; y3 L7 w
        .dev = {+ X& _2 q" f' c4 c3 W
                .platform_data = &da850_evm_tl_leds_pdata,* k4 z7 z/ B( ], C3 ?
                .release = led_dev_release,
; ^1 |  Y4 h9 d, y& A; U        }0 `; h1 A( M" y- m: o) U* G& H
};$ e+ q2 g7 ~! }: o
# U& i! O9 o4 j! k- U
static int __init led_platform_init(void)8 s% g; q" V! k: J8 D# c4 x2 l6 |
{
: v) \# T; E0 d/ M: ~        int ret;7 @, u% e. E4 L4 `
#if 0! O9 V4 K- b( G) g( j, Y' M
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& r3 N, G( |# Y- ?: ^$ b7 ]& v' C5 ^        if (ret). {' e5 i# n9 w7 g7 B( x8 w
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ o* Y  |- ?$ n$ R
                                "%d\n", ret);1 {1 k; ^" `* V& C6 [7 `8 H/ M
#endif' o: S/ H% W) L2 J+ x+ D$ g1 c9 _
        ret = platform_device_register(&da850_evm_tl_leds_device);+ r$ C1 k2 q- {% x. {! f2 Z
        if (ret)
  ^* b7 [$ X* ~0 g3 h* u: h& |                pr_warning("Could not register som GPIO expander LEDS");
- @+ S* H" s" i. T" Q- g! y) G        else
) L8 d! h7 b" ?9 x, v4 V9 a                printk(KERN_INFO "LED register sucessful!\n");
: l( N# x; P& ~. ~) Q  @7 {! \# h5 T7 p4 r. }
        return ret;7 @  z9 @" R6 @( \) f
}
! A) o, `2 N2 G0 C; R& ^% G" ^: Z3 N: x1 v+ T. P) y% i1 L
static void __exit led_platform_exit(void)2 T- y3 N' \& D1 v
{
9 L, o2 n# e9 _8 R" A        platform_device_unregister(&da850_evm_tl_leds_device);
  b& x- r  u( Y; `1 h6 Y
+ Q! _3 g  e* m: ~8 d        printk(KERN_INFO "LED unregister!\n");# i) |" I3 X" s
}
2 @* k/ M$ `7 [( T. {9 {; _& r2 d& k! Y7 l
module_init(led_platform_init);
7 B% Y/ j+ a! K7 E, lmodule_exit(led_platform_exit);6 N: |' E0 e% L9 U9 R! w0 J

3 v. ~/ {; I4 W1 `# @MODULE_DESCRIPTION("Led platform driver");
+ B) q' a& F- ?, L9 m0 GMODULE_AUTHOR("Tronlong");
  J2 L( X# @8 C& ?7 ~! UMODULE_LICENSE("GPL");
/ A' N& C6 Z, M/ {: b3 j' j
2 S8 P- L( c8 x# @
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-7 10:29 , Processed in 0.039235 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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