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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。2 Z; M* X: o% C' F: `
#include <linux/init.h>
: e% `  z& H% o/ Y, b#include <linux/module.h>' ~1 H* \) |0 F2 M% k% R( @* O8 D
#include <linux/kernel.h>2 E) B  L: X, ~7 C, ?( u
#include <linux/types.h>  }) }0 s, i# V
#include <linux/gpio.h>
! O& D7 u1 `+ A- W#include <linux/leds.h>
- ]7 \+ {" R- l- D! o0 v#include <linux/platform_device.h>
- \8 f3 k/ L, [) w1 g3 Z  e) ~6 R6 P! [3 z0 K/ ?3 k, E' v% S5 B
#include <asm/mach-types.h>
: i! G; r/ N- e7 G1 `#include <asm/mach/arch.h>9 r2 Q! {  N2 m/ D! q# Y
#include <mach/da8xx.h>
  o0 {( K5 ]* w#include <mach/mux.h>4 I: O! L4 B3 n5 Q& S% f
) f- r  M( z  t  k
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)  D3 t- \! C3 V+ J6 x# d) x& L
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5): r6 m/ ^+ Y. `! s4 Z- t. X
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)- K/ b# g) l" p% o' v( ?/ K6 l
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)) Q+ r- S) k/ k; I3 |- d) G  u

3 r+ m; `" I5 L# ^; l/* assign the tl som board LED-GPIOs*/! X4 m" `8 m5 N
static const short da850_evm_tl_user_led_pins[] = {
! {7 `" N- d- `" [! V2 ~& ]        /* These pins are definition at <mach/mux.h> file */, M5 ^4 L  P( |, ^& o
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' n5 w6 o/ q4 R2 D9 P        -1" O( L7 j3 l" Q- t
};
0 T! p3 J$ r. n7 l% S3 l" S; J& E! V3 B& w4 n  |: M
static struct gpio_led da850_evm_tl_leds[] = {
; r; _2 p/ T& {        {
! K6 t; I) J( N* L4 v6 V% k                .active_low = 0,! C' `5 Y' T2 a5 r1 }
                .gpio = DA850_USER_LED0,
6 G4 t0 [2 O1 q3 k                .name = "user_led0",
. b( v- ]6 N: E3 A# ~2 A                .default_trigger = "default-on",8 g' p! g7 E9 A4 c% j
        },
  F6 }& ~9 E  L% i0 r3 N4 d        {* @2 ]6 U3 @  A' K( V& n
                .active_low = 0,
) l9 L& M, ~+ C. b* I3 S& {; R+ [                .gpio = DA850_USER_LED1,
; U5 w5 l9 ~" T$ b, Q' t+ e2 C                .name = "user_led1",
! W' r7 {; x5 j  R                .default_trigger = "default-on",
/ H3 H5 C8 {( Q1 w        },7 z( F9 R. N, T  v; a
        {
, t( ?2 }* n1 y4 V; s" [( e                .active_low = 0,' h/ K5 S; W6 b6 R$ S' x: {
                .gpio = DA850_USER_LED2,
" p: T7 A, S8 x+ @! x0 L                .name = "user_led2",
0 S+ l+ N' L+ a9 h* \: H, ]4 q# a                .default_trigger = "default-on",% o% D5 l6 m5 n& t0 ~$ g. L
        }," J: s' v( u# V% r
        {
; s9 ?' f; }3 t; ~                .active_low = 0,
6 q! ~' ]+ r9 G1 }8 O( k$ m                .gpio = DA850_USER_LED3,
  C4 ~6 d" p/ K- _% V0 h* B                .name = "user_led3",7 b' N% H. |: }; ]; m; v
                .default_trigger = "default-on",
& U' ~6 r8 V% ~" t$ y        },
4 l1 x1 s6 f/ u5 W% j/ Q};
$ j" H! h, ~0 Y
+ _4 {2 x7 F, hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: b9 q4 U) p$ P2 O! L* @$ A
        .leds = da850_evm_tl_leds,
- d% Y$ {0 @. h8 U4 ?9 C        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 E! Y8 \  @5 i1 n9 b, r3 H};8 C3 ]- X' F" M) {

% e$ t1 \" V; M" Y; O9 l6 f$ U2 dstatic void led_dev_release(struct device *dev)
& O! }! ]  M+ h1 n{/ X3 B, @* c. q
};+ ^8 Y* k2 Z2 [! L: D2 |
3 U* h2 B3 t- S1 r3 t) k
static struct platform_device da850_evm_tl_leds_device = {
8 r4 ^) R: s: [- x        .name                = "leds-gpio",+ W1 a  {0 ~9 q2 S. ^. w4 L
        .id                = 1,
6 Y( H4 a* [: j% j7 o% W! M- W        .dev = {' R( p( F: @/ F0 G% L; u& y
                .platform_data = &da850_evm_tl_leds_pdata,% H7 V4 c. d/ `' _1 j9 x
                .release = led_dev_release,3 ~/ t( z7 H: @
        }
( o5 g3 k$ O8 ], h};& [; n. k  H: O& u2 [$ k! s8 h

+ l4 f4 [$ S& ~1 Y' Y4 g- w9 }static int __init led_platform_init(void)
; L5 O+ z$ c  W: u" f: _{
2 h4 n1 F# p( w1 q. ]* i- r: O        int ret;
# r4 G& e, F0 i#if 0
. Q7 C7 I5 {  t        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# c% }8 z, q& I! B/ k7 j3 g2 z9 X  G        if (ret)' E: p. H6 m" G- l# `8 B. V; \
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* N9 \; u9 K$ o/ ?                                "%d\n", ret);
  O9 e9 `/ F& j7 {) \: r) d#endif
2 @' w" k7 S8 h' L8 Y& z        ret = platform_device_register(&da850_evm_tl_leds_device);; O4 X; z* B0 t1 v( P( F% p- T, k
        if (ret)
  J( N8 [8 o% w" }) q% P1 }* ^( d                pr_warning("Could not register som GPIO expander LEDS");  ?% r3 n+ U* d3 e, B1 Z
        else
( k9 T+ R$ d) u0 @2 {; U. h                printk(KERN_INFO "LED register sucessful!\n");
1 d- ~* l* c! B2 ^! z1 K9 y& r6 t; {) ?! q$ g. T; _
        return ret;. h, r6 s: ?3 _
}
; d1 i  x3 g$ |0 A: g* Z2 ^% x( f2 p  g3 x( f& i
static void __exit led_platform_exit(void)- y* S) I6 I3 ?% A0 r: k
{3 i+ T0 E* E( R, e) I
        platform_device_unregister(&da850_evm_tl_leds_device);
! S; H) o% a# G* A2 x
5 d5 \' M& c% E- w        printk(KERN_INFO "LED unregister!\n");% {: N3 r, s- q" |
}) b; K; _  j; [* P' J2 i& b
; u! Q4 R* `5 U% b5 ]1 ^
module_init(led_platform_init);4 J& m, v1 a  X2 G
module_exit(led_platform_exit);4 t% V" Y& S. ~" K

' ^! e2 A$ `0 G3 F) K0 H+ nMODULE_DESCRIPTION("Led platform driver");) N9 B6 w( c$ \$ ]- f5 B
MODULE_AUTHOR("Tronlong");5 I- |; Y+ N5 a8 L; |4 U
MODULE_LICENSE("GPL");
+ A9 c+ d4 F( b, v) E: y9 g2 k: s( p1 [  S. I
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-27 15:41 , Processed in 0.039641 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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