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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。+ {/ x8 }( g. Q2 j
#include <linux/init.h>
8 L/ V$ d/ \" Y#include <linux/module.h>8 o+ W3 J( H+ m; s! H& D( f, [9 D
#include <linux/kernel.h>5 `1 c* E2 R# m( g! Z( w# w/ l- g
#include <linux/types.h>
3 ^! Y! i' r) f2 t2 t' ?7 k9 P#include <linux/gpio.h>1 O+ s9 `6 y2 H/ I/ W' D: g' d
#include <linux/leds.h>
) [7 D6 m; i, Q: ]6 B#include <linux/platform_device.h>3 O& u# U4 `8 L$ H9 a' r

2 `& q8 }. Y; N, S0 {3 Q! g#include <asm/mach-types.h>, r* ^; o$ i, h  o  x( c
#include <asm/mach/arch.h>
/ `6 W* j3 G9 T1 g  \' z#include <mach/da8xx.h>- H2 R6 v2 ?2 L- x8 v
#include <mach/mux.h>+ R$ d7 {! ]3 U, D& ^" {

& ^* L5 P+ ]. r* Y* D9 S( Y" L' e* L#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
+ h7 m; f4 T$ h7 z4 D; \" o; ]#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
2 M6 X3 s& K; J5 O6 g: J, [  `#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)3 a# V) Q' }. R8 T& J! {; H+ H
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)- h! l: T" X( D
5 |+ m$ A% A$ S! i
/* assign the tl som board LED-GPIOs*/7 D6 O5 B3 ~$ W0 U7 }( h$ {+ N
static const short da850_evm_tl_user_led_pins[] = {
* j; q. n! w9 W* ^& @, E" P        /* These pins are definition at <mach/mux.h> file */% n5 o! h7 u, E+ C2 `; f
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 }( {7 F4 x7 d" I# [/ F        -19 a1 A' r4 B4 z( k. l1 F
};
# ~0 N0 e: L5 Y- n% O2 E, B* F
$ t$ {+ T/ }7 `" s0 ?$ Estatic struct gpio_led da850_evm_tl_leds[] = {
# E0 |4 K; S% ?6 o: C6 }        {& M0 Y3 ]) o5 B( Y1 t* K* o
                .active_low = 0,' V5 J! v% g- v
                .gpio = DA850_USER_LED0,
. F2 [4 B4 _) l! u2 G% A- H                .name = "user_led0",
5 r1 b% l6 M. S" ~" [* r                .default_trigger = "default-on",, ?. c1 Y& O& q
        },1 C  j) [0 B! a9 }# C
        {1 E: o* h5 ~) j
                .active_low = 0,* j1 E  X; g% [/ P2 H
                .gpio = DA850_USER_LED1,+ E5 @" F! s5 d& i
                .name = "user_led1",
3 H3 R) x% Q8 g3 c1 k( c- v                .default_trigger = "default-on",- q9 C5 f7 b& y: J: {  Z
        },
" l* {3 D5 J; _. r& w( R        {7 h1 H' d' x  n  l& X) j
                .active_low = 0,) Y3 R8 m/ ]7 Y' v2 b
                .gpio = DA850_USER_LED2,
4 f2 \  H4 f1 o8 s                .name = "user_led2",
0 \% I9 j/ l# ^4 ]* M3 T3 r$ b9 V                .default_trigger = "default-on",
4 C. J+ n7 V1 E        },
. Z! x4 t; b4 h% k        {
& M# M+ A. ~+ A+ B% [$ Y# P                .active_low = 0,
( |' J4 ]% B* W* ~) g                .gpio = DA850_USER_LED3,
/ T4 `9 w, h2 y0 _                .name = "user_led3",
% f) e) S  F) F7 I                .default_trigger = "default-on",% T* Q' W5 V0 Q. ^! i9 m
        },
1 t0 U6 g, y& _  H  f. f};/ q6 r0 r, K7 c" G* b

. i' X* Z3 j3 \& k7 e: ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 Q8 D* S% j+ ^: b6 Y* j: t6 M        .leds = da850_evm_tl_leds,. O1 p1 o, [- b) N
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," C& p4 n; k6 W* ~# d; Z) T1 J: T
};/ q6 Q( Q4 H+ f, m( Y4 g  h' \

0 e. d7 F# X/ q& g8 S* _3 |static void led_dev_release(struct device *dev)
  o' e: H0 {# q! a* d6 n{
, r: `: A2 b, _- X6 T# `};
! s1 I. l: o2 K. p' l' q$ T% W7 e- p* e' T0 t/ q& Z
static struct platform_device da850_evm_tl_leds_device = {. J, ]4 k. B* }: r2 T. C
        .name                = "leds-gpio",
) u+ S1 ]+ d* O; x, _. d* r/ n/ g( M        .id                = 1,2 T1 U7 }: y, N  e3 \4 f2 V
        .dev = {
" V+ n1 ^/ o/ X7 G! _: A* B                .platform_data = &da850_evm_tl_leds_pdata,& y& D7 D: B. m; }! A. H0 ~
                .release = led_dev_release,% [8 {1 q4 I" Z  @2 Y& Q, p3 I) J
        }% Y' l1 k; v( h; v. g$ ]% K
};
5 ?  _' k7 f4 x1 B! K8 K7 `$ H* u& o6 \9 \: H, @
static int __init led_platform_init(void)
# I& ^% e  K9 h3 T* T+ F, @{; V' y5 }! J) E3 j- ]- d
        int ret;
4 u- n, u! `( B0 |0 k2 U- i5 M#if 0: x. f* p4 l; g) G. y
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# B2 d6 M, w* u) R/ T- E9 }
        if (ret), U6 D, _3 D, E  U9 Y
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 Q0 G$ v  H) a5 R+ ^
                                "%d\n", ret);; e& n- l8 o  ~) G0 z: ^) K
#endif& N9 b* L, s/ }' o3 q7 I; k
        ret = platform_device_register(&da850_evm_tl_leds_device);
$ Y: ~# g# {+ x        if (ret)
7 b+ P# W& N7 r" k. H                pr_warning("Could not register som GPIO expander LEDS");
- s* J5 M% }+ Y        else  L! S. }9 X1 O: C$ e& n7 U
                printk(KERN_INFO "LED register sucessful!\n");
) o5 C1 \5 T+ q; [+ a  I$ C+ a: ~( D) h5 G
        return ret;
, b; Q" o. n; J( V/ ~) W}- C4 m) \6 J7 M0 a# ~

$ g& V& Y0 {% J6 z% {; Bstatic void __exit led_platform_exit(void)( V. |( I+ n' s: V
{7 P2 s$ t. r! X# g
        platform_device_unregister(&da850_evm_tl_leds_device);
1 m2 B- N: }# F& D/ H& R
6 S/ n$ p% C- T. ^        printk(KERN_INFO "LED unregister!\n");
9 G- b" x7 C! e( V9 O. \}
$ C. a& J5 f# q$ B5 m: n+ Z9 S) F- ^" a/ E& H: P; k5 h: F5 I7 ^, P
module_init(led_platform_init);
" ?0 _. M! _% k! Ymodule_exit(led_platform_exit);
1 Y9 |. `# V1 g9 g' s( Z/ f+ x
) B% S2 p' Y3 ?, j  d: QMODULE_DESCRIPTION("Led platform driver");
. a* s  r) Y/ @3 B4 yMODULE_AUTHOR("Tronlong");
0 _, [. G  W$ m. \0 {  \* _4 cMODULE_LICENSE("GPL");" ~: \* f( `- K* W1 F: G

7 ?) G, d$ j' n, w( n
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-27 14:31 , Processed in 0.044266 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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