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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
: L- M/ `, S" J5 c/ m2 I9 _8 ~#include <linux/init.h>
( N# L! D3 o9 g8 V# T1 |5 X#include <linux/module.h>% {3 k0 F: J, ~: y; l
#include <linux/kernel.h>/ c7 M' M! x2 d' ~% w) @0 ~
#include <linux/types.h>
& B" r( n% A* x' Q' l6 v9 C% ~#include <linux/gpio.h>5 c( j  `$ L/ w  g& J* t4 |- X$ `
#include <linux/leds.h>7 K6 Z7 R, R. P6 \" \$ I) m
#include <linux/platform_device.h>
+ S7 [2 O- J1 F9 N* y
' T8 {* t( m6 _9 J( n2 {* O#include <asm/mach-types.h>7 g- S4 B6 U- d) `8 P% q0 `4 X
#include <asm/mach/arch.h>- K& I& z3 ]; G: q" M( |3 Z+ S; I
#include <mach/da8xx.h>% a9 j0 D0 R7 g' o! q! d
#include <mach/mux.h>
( Z+ b; J6 U: L; U* w
' h) V9 n* P" h0 M9 ]% @#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
6 a3 V& \1 w7 a/ j% D$ \, f#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)+ b7 V& y$ \7 K4 S2 h# @
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
! }, V% ]7 h+ ]" u+ }- l6 n; m+ C#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)2 k3 s; b9 B1 I( K  Y" e, D
* ]4 ]6 P" S! B
/* assign the tl som board LED-GPIOs*/
' }7 l& P; d9 ^$ {/ f. E+ {& [static const short da850_evm_tl_user_led_pins[] = {! z$ g5 Y+ ]+ r( @
        /* These pins are definition at <mach/mux.h> file */
4 _5 a6 l% T  ^& v& z6 j4 h        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# b- v* n( n. C9 `. ?        -1
4 Z+ ^' H, a0 y  t( u1 I};1 x# O7 r# ]. p( @
' \9 f* {2 V5 A& W) A1 u
static struct gpio_led da850_evm_tl_leds[] = {' B. }) g: \2 N+ X" A4 K
        {5 D* B3 B4 J- f  ~7 M; B; O
                .active_low = 0,! ^9 w0 x$ b1 ?" W$ @
                .gpio = DA850_USER_LED0,
" V4 I; i! w- ^! O, i                .name = "user_led0",
0 O/ j6 l9 }& c0 H; t                .default_trigger = "default-on",
9 O4 |/ ~5 b8 v        },  }! K' w( X, }- R
        {' I6 O) s4 y9 L5 o" X/ S' }
                .active_low = 0,
+ i( N! y+ F) t                .gpio = DA850_USER_LED1,
/ R4 E) t6 I5 k. ?/ T                .name = "user_led1",
' a4 j& }: v) `1 L                .default_trigger = "default-on",0 f+ |# a: e: Y% e6 O
        },: D5 k1 e: t- o; u$ N
        {
* {' ~7 q. e$ L: Q$ t6 o- e9 e                .active_low = 0,' }7 ?  g& W+ j
                .gpio = DA850_USER_LED2,: N  n- h2 X& ^1 _3 N2 z7 `) M6 m
                .name = "user_led2",/ X  V4 [8 ], o6 b5 M! F9 h
                .default_trigger = "default-on",
; s/ ?7 x* B8 Y* \) y        },
6 L. y6 c% l4 s; \5 f        {
# i) E7 f( X5 B                .active_low = 0,
+ f8 a) w/ s' U' u4 d) o                .gpio = DA850_USER_LED3,
- Q3 G. _, U$ x1 g5 m                .name = "user_led3",- R$ ~  ]7 m7 Q* z
                .default_trigger = "default-on",* @" ?5 T' u: [8 D: m9 R+ {
        },
* |. B: _/ O- h1 c) k, ]/ ]};
5 j9 \! L# c' M; u
, J' P  c) x+ T9 f( }) wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 b! F/ G& R- p' s' b0 S
        .leds = da850_evm_tl_leds,- [( c1 V. P" B2 A4 e$ P8 X
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( Y6 b0 n, y! P+ Q" B" o: P& |};0 X% o& Y9 Y# r8 N
9 d- X! K) j" y" ^. `! Y
static void led_dev_release(struct device *dev)
+ K) A+ U/ N5 M! p5 d+ c. M7 \{) a% g+ p3 x+ ]' {
};
9 ^' l2 h7 ?$ d' Y6 ]. a* y: w5 g' N. I5 x- c0 s1 C
static struct platform_device da850_evm_tl_leds_device = {* C7 h+ G) K5 P0 k- m6 L2 M
        .name                = "leds-gpio",' t7 X* G/ W5 ]* D* n  Y/ j! d; Q) ]. \
        .id                = 1,% v0 \% X* I* m6 t! V
        .dev = {/ l7 L, b& ?4 q0 K
                .platform_data = &da850_evm_tl_leds_pdata,
8 _( s0 h, G5 U5 p" L( V7 ?                .release = led_dev_release,
- m% R+ w% s& |- A. |0 o        }7 E; b" b) w8 W/ H2 g+ H5 ^0 Z
};
# h8 q7 K5 N8 k8 M0 p+ o
+ O# N/ M7 H4 v; f7 U8 T0 [5 Sstatic int __init led_platform_init(void)
# Y1 x' u! m' V3 J8 Z2 g6 h{
  B+ h+ \( a- J        int ret;
, R8 w! [( M* o" V- ?# Y#if 08 ^7 q% k' h3 F0 x
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- X/ `* w# c1 ]+ |+ k5 m        if (ret)$ A  y3 S( g. c& A" @! z* w0 x$ s
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# v5 f9 P% p* Y
                                "%d\n", ret);6 w9 O2 e/ o8 f! m
#endif
  ~" P  n$ ^! z' V. ~  I        ret = platform_device_register(&da850_evm_tl_leds_device);! }8 m/ Y9 p' B+ _: N* ?
        if (ret), v1 @+ N- P' J3 q
                pr_warning("Could not register som GPIO expander LEDS");8 E% `5 Z  w3 n1 L& A# g
        else
2 P1 o* ^2 R( }, {% x4 b                printk(KERN_INFO "LED register sucessful!\n");
. A8 z/ V. b) m( u$ C) H4 |$ {3 s. U( ^" c+ c4 I7 I
        return ret;) o( `" u2 t, i6 v
}; e) m& l! O& d$ K4 v% t
0 w% u. f& }2 Q* G; D# x. F
static void __exit led_platform_exit(void)
- o2 _3 L. V7 b6 d- H. d{* K( I( W/ D1 v. o! q
        platform_device_unregister(&da850_evm_tl_leds_device);
; v9 @9 Y# P5 H) `( y" d
5 ^# G  r; |. ?! v4 F' @5 L6 o& H# \        printk(KERN_INFO "LED unregister!\n");* ~+ v. X" u/ J3 b
}  x+ U; I) G/ T- a# E
2 r& T% o( y) D/ K- l+ v4 d
module_init(led_platform_init);
0 I, i; J0 K3 `3 E( Umodule_exit(led_platform_exit);
4 b2 g8 J  D' _* N8 D! b2 _& q7 K1 u3 K! Y
MODULE_DESCRIPTION("Led platform driver");
8 Z; J% _5 r+ EMODULE_AUTHOR("Tronlong");: f3 e) L, H8 O9 t, Y/ \2 C
MODULE_LICENSE("GPL");- O% k4 t. b: h1 k: m" S

% A  f. u8 A' b$ k6 j5 `
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-13 21:50 , Processed in 0.040238 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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