程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
8 {) ^% X/ a& B3 g1 Y# O" ^#include <linux/init.h>
; L5 c+ }' L* r8 d7 k6 s#include <linux/module.h>
3 R' q# P( v# i4 n/ g) e9 {5 b#include <linux/kernel.h>5 j% M% K6 `) s& F) n7 F: ?" }, M# ~0 i
#include <linux/types.h>
. n! s; C( S! ?( t' p  J( \+ f4 e) A#include <linux/gpio.h>
* z! l2 o. g7 s#include <linux/leds.h>% h0 x+ t; M, L+ u$ C
#include <linux/platform_device.h>
' P6 t2 [$ G) O- o
( B5 k9 M7 q0 E. s6 n5 S5 m* e8 T; A#include <asm/mach-types.h>
- g. z5 ?* y9 I- w- G! n0 H  ~#include <asm/mach/arch.h>! L+ Z5 E7 @/ H) p8 B: c5 t3 d) n
#include <mach/da8xx.h>
" ?0 B+ y5 _- C% Y4 v#include <mach/mux.h>) R8 P; B/ W3 ]. H
' Q) [! p' X# [
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)7 C8 p; }0 A. j
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
, L6 [* x2 f9 A9 z" D4 K#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)& N8 ?! l6 E9 x, s' _; s) O
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)2 D. i3 [8 _: m/ j  ?
8 M3 f( U$ h. S* l
/* assign the tl som board LED-GPIOs*/
  M3 A' F3 t5 D# Z1 ^9 [! tstatic const short da850_evm_tl_user_led_pins[] = {' A5 y7 J7 |3 t+ a$ L
        /* These pins are definition at <mach/mux.h> file */; d2 s4 u4 g) c" C
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 v* d. y+ q4 y6 O        -1
2 `6 {2 F; Z2 w4 y2 I+ ~2 g};4 @$ k! }+ s1 M% n- L

9 ?2 j' K8 l. G6 \% Lstatic struct gpio_led da850_evm_tl_leds[] = {
+ c/ a% p' S: `: [        {
. X: X' _7 Z% P                .active_low = 0,( x! @* g5 Z( x3 S- G- b( y
                .gpio = DA850_USER_LED0,
2 `, e2 J) |! ?0 ]. Z                .name = "user_led0",& @$ V+ h3 m# I+ Q; f5 q1 m& M+ w
                .default_trigger = "default-on",
0 R# j, S  e- U" W7 H0 r$ w! L' F. u        }," m6 M' b; b: d% `
        {
& V- G. j: X& q4 k7 U* M/ ^                .active_low = 0,# d  k4 v2 `; C( P# w$ @8 m' X
                .gpio = DA850_USER_LED1,, |6 ?2 j' s  \) K0 r7 h
                .name = "user_led1",& T6 G; ^7 b7 X: f5 h
                .default_trigger = "default-on",- Z" G7 [3 \: m. e+ f
        },
9 G. x1 m$ _. L' U% I        {9 y: E1 L  z  r  t& p! [" _6 W, W9 y
                .active_low = 0,
; `7 v; ^3 f/ h% w( G5 ]! F. m                .gpio = DA850_USER_LED2,& x( M: V' e% t5 P5 a' `4 \) W4 u
                .name = "user_led2",/ j! T- g/ C# }5 b, L
                .default_trigger = "default-on",6 z1 n- o( N) o% ?( i
        },0 b+ k) ^! u0 T) t3 {5 o
        {
/ `  V& c" |; K. d9 D                .active_low = 0,/ Z1 b- z# y1 t& L  l, {1 Y4 s
                .gpio = DA850_USER_LED3,
5 t% X2 C+ h& \4 p5 n2 y                .name = "user_led3",2 q) G6 R5 I' z# a) L
                .default_trigger = "default-on",
/ r' ]& s! U: O  f& Q. i9 ?: v        },
8 q, M4 l1 u: q6 ?2 s# A};
" h/ u+ ~! D0 m+ _; m3 q, K
5 i1 F4 P! @% y- r3 Z/ w& Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 s: d  W; B9 j; f' @
        .leds = da850_evm_tl_leds,; W8 K2 P3 Q: ^6 Q  N; m
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 V' H( i" u" _; c6 s+ `
};
9 x2 D! e9 H8 z2 _* j8 R. ]
  G4 N8 u% E" H# z" A% J8 C8 @, astatic void led_dev_release(struct device *dev)
) G/ L: P) z& d* ^# m{
# ]9 r7 M0 @- ^};
' P" I/ z1 I4 a2 |. R2 I1 P, P2 I, O+ p8 w3 M
static struct platform_device da850_evm_tl_leds_device = {
( F% I0 v! S, a        .name                = "leds-gpio",
) L! ]; J' b' c, t1 T$ Q        .id                = 1,
, L" |( W" h  g0 ^) G. O  ?5 j        .dev = {& l, R1 L1 k5 R9 |: d  A; f# F7 }
                .platform_data = &da850_evm_tl_leds_pdata,! [. t  O/ P7 ~$ n) Y  V
                .release = led_dev_release,  ?5 S* X( ]1 H3 t  M
        }
: g, I* G' [+ w8 W2 q1 r};( b3 F8 N3 n0 A4 D6 f$ T2 ^4 N

. N" e* Q3 b3 u+ q5 ystatic int __init led_platform_init(void)
* q9 \: ~# W) X3 y' R( H/ P{
& F* ?. F0 z! {4 [( Z        int ret;. D' i0 E2 l! z) e! c, ^
#if 05 K( W+ \5 a# Z: |/ q
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ C# L; y, Z$ ^+ {
        if (ret)! |6 [* t, g- N) S1 O
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :": y+ X6 [6 L+ Q# A7 L
                                "%d\n", ret);
; f- ~: i. C# D# Z- z4 w3 [1 y#endif
( U5 f3 N6 B7 S8 ~  c. m1 a3 N        ret = platform_device_register(&da850_evm_tl_leds_device);. R# n- D+ y' @) s$ i
        if (ret)
3 @' _" Y* k# ]9 k                pr_warning("Could not register som GPIO expander LEDS");6 K" b4 O  P# N7 s. I7 q8 p  X0 K% h
        else
8 s( T- r- m; G, b' m1 y7 K                printk(KERN_INFO "LED register sucessful!\n");
6 r# n' d6 k+ P( m5 [
, Z6 S0 ^) O9 {& I0 m7 @- ~7 |9 B& V# r        return ret;
- g) L4 G5 `# P9 K' j$ K}: H7 p4 S& `5 V% ]1 }& X% g7 j0 }

7 r; k7 Q$ R) J+ qstatic void __exit led_platform_exit(void)
& R$ O5 Q4 J: E$ G8 P8 i! _* l{
* m# ?) T6 t+ h        platform_device_unregister(&da850_evm_tl_leds_device);
$ a- z2 t3 R) V1 ^
9 {7 C+ ^  K+ L8 [        printk(KERN_INFO "LED unregister!\n");8 D" ]3 Y* k* o$ f2 Y6 |, L& X
}
/ Y9 _$ Z3 ?$ x$ K) D6 ^$ ^# \4 N9 h! e, m; k! a6 `  `* q0 N1 U
module_init(led_platform_init);
6 s) C8 t& j9 J" ]6 Z- `module_exit(led_platform_exit);  e1 z" ~: D, z  A  L8 G* I6 d; d3 {

' B: C: W. B6 CMODULE_DESCRIPTION("Led platform driver");
" I2 Q* v& S* [5 V* I, d3 w4 H( w0 IMODULE_AUTHOR("Tronlong");8 l( p; [3 ?& x+ }9 _
MODULE_LICENSE("GPL");# V8 ]; Q8 N, @, D% ~' l

6 B% z8 a0 D# u, b: Z7 l
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-23 17:09 , Processed in 0.037999 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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