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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
2 N3 M. G0 L' {8 Z#include <linux/init.h>
& p+ e3 w; u( C7 m7 L2 \#include <linux/module.h>! O, O. B, w' a6 k! g8 J6 \
#include <linux/kernel.h>7 w+ Y5 C& K. p7 U8 I, V
#include <linux/types.h>
: e/ ]" X. I: l  j#include <linux/gpio.h>" i2 v5 {# w% e* h* e, H1 P
#include <linux/leds.h>
7 R  O7 v- O* _1 g) p) U#include <linux/platform_device.h>
! C2 X$ H+ b3 P, w3 |. D( L9 }) F: e5 P- @2 o$ k9 Q9 n+ M
#include <asm/mach-types.h>8 a. k! d% m: e( X: c' h+ j
#include <asm/mach/arch.h>8 ?: \  _( L; C5 B
#include <mach/da8xx.h>
9 k7 V9 X; v# M2 B+ x5 }7 e, [#include <mach/mux.h>
! g: K7 x; r  f6 W+ E- {, k" c  y6 w
0 ^  _& z: s  e" d& U& X/ i#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)" Q+ @1 M% S, S) G' y# m
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
( m  r9 ^2 U) x! i( H. w9 \; x1 l#define DA850_USER_LED2        GPIO_TO_PIN(0, 1); _! U. ]' K( W. [+ Z5 q: }( _( @
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
$ T& `& f, T' k* l# l, p* C( A+ b- {) |/ D: U
/* assign the tl som board LED-GPIOs*/( Z' L. _6 E; x6 D1 A
static const short da850_evm_tl_user_led_pins[] = {
+ g% Q% L5 E+ x7 t" g        /* These pins are definition at <mach/mux.h> file */% a' e; a2 b0 n  X6 N
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& ]# t$ e: G$ v) B8 w- C. \8 H* a4 ]
        -1) o" d1 i6 ^% _( J% |
};
9 Z- s9 A& I, v3 k/ F/ H/ g  c+ x! \6 h* S- f6 K  u
static struct gpio_led da850_evm_tl_leds[] = {
) |+ [; b2 t. n. O        {
; T3 o  U& V8 [" k' N                .active_low = 0,
7 ]+ q1 s- `1 s7 Q9 q) x" f                .gpio = DA850_USER_LED0,
! z8 p# H& W+ H" l                .name = "user_led0",: j, S) M. f. A3 ?9 V1 V/ O" U
                .default_trigger = "default-on",9 v' j6 A- H. Z- ^/ C
        },
& R& x6 k5 ]6 I        {
' s& i' i+ c6 a  V; a5 i                .active_low = 0,
+ A- |- N( n+ l; G* s8 [3 W0 @                .gpio = DA850_USER_LED1,5 X  J! Z% P, a. H9 T
                .name = "user_led1",+ Z6 Y( B+ J- w5 T, x% L# c# Y
                .default_trigger = "default-on",
' s- t  b% J3 y3 W$ K: K* b        },
4 u% ?8 A9 M+ _2 o! Y  b: z% P        {" ^/ x% h! F; Z$ C
                .active_low = 0,
6 v( ]3 ^) w3 V+ w                .gpio = DA850_USER_LED2,
5 [7 L; W: E1 `' ?! ^; e                .name = "user_led2",5 ~  Y0 ]9 A9 ~/ v
                .default_trigger = "default-on",: R2 o; J  F% q4 }$ j. D
        },; }, ~$ l$ Z8 S2 W7 U- j
        {. a' X" \, R6 N
                .active_low = 0,8 s( _6 E- v* V, W9 |* ]
                .gpio = DA850_USER_LED3,
* x( A6 D9 w$ X, `. z0 u8 Y                .name = "user_led3",2 _& W* a7 q1 \- C# I# w
                .default_trigger = "default-on",2 g  L8 G; v: O, n7 J$ Z9 I
        },
+ y- n2 V1 \% p" N& R};
- m, T# l* m* S6 L5 j! [; V! y& j/ `( [' H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' ~) d! |8 ]* S2 p
        .leds = da850_evm_tl_leds,
6 O: Z5 a' X7 W$ q# A        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ X" ]  ]; p) |7 ?
};
4 i* C1 W5 }' M1 l! j) w3 s6 }- B) F: |) Z! A
static void led_dev_release(struct device *dev)
  h5 L) P; D! |- [, o{
) G! E: m3 ^# _: R+ f+ I$ P};
2 E& x' ^1 N, j& X0 V
5 ~0 Y' J5 h6 V+ Y9 kstatic struct platform_device da850_evm_tl_leds_device = {
3 c$ s, G8 F* O2 d2 \$ f* t- j        .name                = "leds-gpio",& o' S1 T, o8 U; \
        .id                = 1,
# F* T/ v  J- t7 K8 K1 M* }        .dev = {
2 U2 f0 Y$ Q& Y+ w3 P: c8 [. i                .platform_data = &da850_evm_tl_leds_pdata,
) q0 j8 I: {  o                .release = led_dev_release,5 m6 F$ L: ]$ d" ]
        }2 j  S0 g* T8 v+ Z: ^! K- S
};; _  l8 K# O: @
# L% j1 L0 F' v2 x$ ^
static int __init led_platform_init(void)
( \: M; G# D4 p$ H{
2 M8 g7 z( ^, r  k8 A        int ret;8 P% D+ h* K1 U3 j
#if 06 r0 z" ~% X0 N/ r  o" X
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% Y) C& S: ~$ }' p
        if (ret)2 V2 k; j3 U( X! d; _
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 h$ {, _8 [0 i5 A
                                "%d\n", ret);. Y% ~7 G5 k  O1 T$ m0 f  A6 H, E& n
#endif9 O1 r% [& c1 k1 k6 b: `" i
        ret = platform_device_register(&da850_evm_tl_leds_device);  r% Q: N* \. W# [. Q2 r) I$ Q/ n6 E
        if (ret)
, H3 m: j* y* e& ~* Y5 m& Q                pr_warning("Could not register som GPIO expander LEDS");* G- _# k7 i( ]# A
        else
& D7 A* w' r, ]" a# \) N* s                printk(KERN_INFO "LED register sucessful!\n");
* u% J1 ^, H8 x) m& n1 B5 {! `; i$ a/ A( o! j; E! n
        return ret;- K% v1 l4 `- k/ N
}
3 s& Y% F& ^" N' C% z! g4 F% F' ^4 l
static void __exit led_platform_exit(void)
3 ?8 q. n4 {/ F* R: k: Y" d9 Y{
! G/ P9 Q2 D" R/ z0 r: m        platform_device_unregister(&da850_evm_tl_leds_device);( G/ L% J1 a, E$ Z: o' @+ E; n

4 f8 L5 b8 M7 N        printk(KERN_INFO "LED unregister!\n");8 u* {2 c; v4 w9 I/ K; [' n: ~
}
1 }* W& E8 H7 k+ E% T! R; |; f/ e
module_init(led_platform_init);
% l+ V3 U0 i. fmodule_exit(led_platform_exit);1 ~1 T" y/ G/ T: S  R- ]8 t

- g2 @0 t" R4 u5 N/ z% ^  U/ rMODULE_DESCRIPTION("Led platform driver");
0 q0 u% r3 `  P& I3 l+ z+ `4 GMODULE_AUTHOR("Tronlong");
9 I- z9 j) a0 e- p2 `" u( r# rMODULE_LICENSE("GPL");
5 A! n3 h8 y! V# g1 e  `8 u3 r7 G$ X: R. a2 D9 x4 V! |; w
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-23 22:45 , Processed in 0.038027 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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