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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。) n" A: T8 m- A# a0 y
#include <linux/init.h>) a8 D/ e, q; n. k+ X
#include <linux/module.h>
* ~% H4 r; V5 v- c#include <linux/kernel.h>) `; t, Q. p; O6 |- m% X
#include <linux/types.h>. H3 Y3 i) u3 q$ V% y2 ]" j
#include <linux/gpio.h># [/ ?! }6 W& A# I& Z/ x0 I* s' I
#include <linux/leds.h>
; }% w$ c! U# g  Q9 i) B5 t4 L  P#include <linux/platform_device.h>7 O# }0 [, t# N, S8 d- `: s% C
( a' o& B! l* g5 r( B3 M7 o: x
#include <asm/mach-types.h>
3 o1 x: h9 _9 J# E  l" j#include <asm/mach/arch.h># t+ g0 o) [. r$ N# K3 h( X2 R
#include <mach/da8xx.h>
# t7 }4 |& K6 K- j#include <mach/mux.h>
, e' m+ [! t. ]
1 e/ q7 w3 N$ S& x* m1 [#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
; y/ @, k4 A" h7 `7 c; B#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)  K7 z( |& {( A' V5 f9 j% Q5 h  y: c
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)/ f' `( N9 [4 k1 P  K- y. {2 O
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
) m' D1 b& x9 l1 m
$ o& ~  p7 |* ?/ e, ^% z7 S/* assign the tl som board LED-GPIOs*/
- k9 J" ~# V& a7 @- ?: ~% n/ l; istatic const short da850_evm_tl_user_led_pins[] = {$ g. o2 q% F6 f
        /* These pins are definition at <mach/mux.h> file */3 ]) ]- K' V8 S/ I
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' t' `6 V0 d6 d& V" X
        -14 c; Q) C8 g& p- I; @; {; ~! Q
};
5 o% V3 B: s/ z: H8 R( z3 t4 ^  B  ^- v( g
static struct gpio_led da850_evm_tl_leds[] = {; m2 f) k2 J/ x' s- _
        {7 _/ |$ Q; i8 g( A* W
                .active_low = 0,6 k' o* \" m# r4 Y0 }  N0 p6 n
                .gpio = DA850_USER_LED0,2 W' o$ n/ f' o/ }3 v  o3 h
                .name = "user_led0",
# a8 ?4 }* ^! {8 C1 J! J+ E                .default_trigger = "default-on",. r' |; a, W! N1 }& _, G
        },* {- P3 r. B. N9 P7 X1 }
        {' h3 [& c% g, h2 d$ C$ G* n
                .active_low = 0,
0 m. w4 w' x) @                .gpio = DA850_USER_LED1,
% u: N  I2 ]- ]& F0 I, L% C                .name = "user_led1",
1 M/ T6 D% N* r! r: v, y  O                .default_trigger = "default-on",/ K4 N# P3 g6 M' H! A/ L( t7 l
        },. y! D; N2 r) G. d0 Z9 {  E# G. |
        {/ j. D* P0 o5 s" L+ C& C! |
                .active_low = 0,
: j6 r# \8 \& S2 t7 ?: N0 i                .gpio = DA850_USER_LED2,
/ w$ @: V9 U' w                .name = "user_led2",
7 ?- r" r: W' [4 A6 n7 B2 ?  d                .default_trigger = "default-on",
0 n$ @+ o- ^9 n$ v5 F/ T0 N. U        },
/ k$ ?1 M' U5 ~. Y        {5 l" H$ l% X/ f1 k
                .active_low = 0,) h4 O* a) M4 M1 S
                .gpio = DA850_USER_LED3,
* v* \8 F* T1 _3 c  j; f4 B" v# o                .name = "user_led3",9 o  j+ U8 r6 B, Z0 @
                .default_trigger = "default-on",' l7 U! k4 q! M" ?: R3 a: d  O
        },
' c4 ?" [5 Z2 R) K. ?% M};
8 z3 b2 _% L: x; `) R% G) X# A- J* H- V! K# h6 W5 P- D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' s- Z3 H4 [2 g2 V        .leds = da850_evm_tl_leds,
! W/ ~. `# n$ r) C) P! w3 J        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ F4 M6 y# S/ U# v& r
};! s7 n' A5 `; e/ i: E* l- i4 G
. _  z+ {# Q9 d- y+ h
static void led_dev_release(struct device *dev)" ?9 I  ], o% J1 V
{
* ~3 _. l" X9 W};  H; n; H2 r  L; k3 A
5 ?2 Z, H3 W9 t8 K2 ~
static struct platform_device da850_evm_tl_leds_device = {
5 F/ B4 V( ?( ]  T# W5 L: v- C        .name                = "leds-gpio",  Z( p+ V; h$ J
        .id                = 1,
# r. c9 G9 j8 z) T        .dev = {" N$ R' P" g5 @6 j" M/ P0 O
                .platform_data = &da850_evm_tl_leds_pdata,
0 }, p2 E* `" A2 e' f                .release = led_dev_release,
5 @3 _& |) d7 l; j5 B% ^        }
5 [3 |; V! u& P1 P- F};9 E$ f2 V8 f, t0 [0 d

0 Y: H$ f, Z' a) w2 lstatic int __init led_platform_init(void)
! X. n+ I, o$ ?7 a{
7 r4 {8 X4 [# V8 h        int ret;
; T0 B" k4 T/ I. X#if 0. v% \2 y+ T6 U1 [  m& w- ?
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 O+ v/ v) A' e8 z+ m$ V# W        if (ret)4 n( w& Z* w# \' W* ]$ _
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 @9 z8 M0 x; V# V% }( Y+ l- \                                "%d\n", ret);
- ~, f% F8 L7 b9 q3 p* {#endif) R0 _& p) L# d( ~. g
        ret = platform_device_register(&da850_evm_tl_leds_device);
+ T! M" d  S+ K5 ^% j        if (ret)4 E& [' r2 c4 x  }  K
                pr_warning("Could not register som GPIO expander LEDS");
2 F: k8 F" ]" e) G: l, t$ ~; t        else' G! Z" |4 `6 L" t8 S1 U% T7 V
                printk(KERN_INFO "LED register sucessful!\n");
+ w+ @0 w" F' w1 j5 a' B9 {% ?; ~  |! l8 {
        return ret;
3 Z2 W* g, S! m+ }}5 \, Y% n) N  T5 G* }2 R
9 r) R- @& h- U, Q" x! _; ?
static void __exit led_platform_exit(void)
. y  y6 d* z% }* p/ f' ]{
1 r+ a6 T- R- S. P        platform_device_unregister(&da850_evm_tl_leds_device);
- @, F& g9 a0 |- j* V8 i$ w7 g1 z: W2 Y, `5 O1 }* s
        printk(KERN_INFO "LED unregister!\n");
; L: N6 J, @6 i  G8 C  u}
1 ?0 k& l3 D6 `: X
" [5 a$ ^1 B1 J8 ^' R, l9 hmodule_init(led_platform_init);% s% [' g9 T3 t# k7 v' f
module_exit(led_platform_exit);
/ g5 E* @6 X2 J8 G: W5 A1 a( \  a, j
MODULE_DESCRIPTION("Led platform driver");  {* I5 a" x& Z* U2 e7 g( J3 c; x2 ^) W8 s
MODULE_AUTHOR("Tronlong");
  e5 d! u. U! y' @' x  dMODULE_LICENSE("GPL");
% p4 E6 \  ~- o& j# O' T1 q! w7 F3 }+ y# G6 f
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-12 14:23 , Processed in 0.056153 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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