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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。& p! W; P' M5 V* K* |  P* s0 ^! L
#include <linux/init.h>
/ |: D$ e- r% a) F5 q#include <linux/module.h>
  {; b7 s( _' ^; }  T( F#include <linux/kernel.h>
7 G3 Q, F  X1 v: f# T2 B#include <linux/types.h>% }" {7 [1 X) m& y( N/ o
#include <linux/gpio.h>% v: C5 y. F1 V7 ~$ ~! z
#include <linux/leds.h>) {( Q2 h2 f5 M
#include <linux/platform_device.h>* @) }; ~* {# F; U1 H; A
3 U6 F* \1 I8 t1 d6 E; @
#include <asm/mach-types.h>
! P3 n+ I) Z3 r8 Y#include <asm/mach/arch.h>
) i$ O7 m6 Z! _6 j" z$ Q: a#include <mach/da8xx.h>- ], U1 \' p' ]4 c1 B
#include <mach/mux.h>' q1 ^1 Y5 K9 G. A( x) j/ V0 d) w
+ K' D3 p9 k  N; P
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
+ m# q: m% M3 I  X/ M# L( v8 }#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
) `. Z; M# o6 r$ H) Y( H; q#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)( X0 ?9 U  [. o0 T" J- l
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
" X7 [9 T* T9 R) V0 P) R8 T0 a: J( {4 Z" j4 d3 P0 V! a
/* assign the tl som board LED-GPIOs*/
! K, A  c5 ~: J. K% q1 L8 b' gstatic const short da850_evm_tl_user_led_pins[] = {
( n) S& [% s3 @" S6 g6 |# c        /* These pins are definition at <mach/mux.h> file */% U% T2 W1 l( }0 w8 d: U6 h2 u
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. I, ~+ O. p) e" w9 @
        -1" A( ~' n1 b; `; D
};% w/ {# @. ~+ Q

; J  E9 T; f+ a% Kstatic struct gpio_led da850_evm_tl_leds[] = {
) W/ _: I0 z! b        {. {3 o5 l3 L  z7 L3 F
                .active_low = 0,
* @5 g: l9 ]7 Y  G                .gpio = DA850_USER_LED0,
& C; `% s% ^/ V6 |/ h# h4 U5 m                .name = "user_led0",3 w& t( m* Y0 Z( Q* M
                .default_trigger = "default-on",
! ]% o! }4 S; H        },, s; T3 @' {5 a
        {
' B3 ?; k+ x3 b# T6 `9 r5 R                .active_low = 0,
* r0 V. N' ]; ?+ y( u" v; G                .gpio = DA850_USER_LED1,
5 _5 `2 u( ?7 e7 _: Z4 G                .name = "user_led1",1 t5 M& s* l% `# X
                .default_trigger = "default-on",
  M1 L9 k4 j# o3 A3 v" _6 U1 N        },8 U& u+ p2 B" X7 t& _5 i/ ?
        {7 T/ V: v9 D8 f- Z. ^* x/ G
                .active_low = 0,: q% U4 v) |* U, E1 H
                .gpio = DA850_USER_LED2,
  {* \' r' N0 v2 g                .name = "user_led2",
. k3 C- d& W  G3 X                .default_trigger = "default-on",
4 _, S6 V5 s4 e7 M! w- J: }' a        },: p1 g# U& t* L% f/ `
        {
7 V5 W8 ?9 r) V  w                .active_low = 0,
) m% b7 R( u5 V8 U9 ]3 Z7 }0 M/ T                .gpio = DA850_USER_LED3,- E( o5 J1 W6 X0 E/ D: D9 r
                .name = "user_led3",
3 Z# J; \) T  m9 q) f1 x; K                .default_trigger = "default-on",5 g" i4 T+ |, R2 P
        },
' G0 h( Z# ~8 k1 D$ N( }};. u7 ]/ X8 K& c& k

* F' H' q, Q. g. ~) rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. h4 z2 v7 p1 @/ u
        .leds = da850_evm_tl_leds,
; `( H" E3 a) N0 k& N        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- g' ~7 Z  y& v: }+ f0 B
};
* Z5 K: j( h8 `: `4 Z1 S6 H5 {. h8 ~3 W) d3 h( x* S
static void led_dev_release(struct device *dev)
3 c  k/ h' T+ T& }. @% v{
  N1 D' b5 V2 h$ Z3 A: G! g};
1 W! }* Z8 ^+ q6 K1 e; _& e( p
' Y3 u/ G: l. H% `static struct platform_device da850_evm_tl_leds_device = {; m/ {! Y' q- v9 I
        .name                = "leds-gpio",3 y- N0 K/ F* @6 o! h+ P
        .id                = 1,
3 \8 K: v! C5 }0 V, z: \: H8 r        .dev = {
' }2 D9 c! |1 N8 [) W. S- U9 E4 L  Y                .platform_data = &da850_evm_tl_leds_pdata,7 p2 c" g. W, B% F0 ?
                .release = led_dev_release,; Z0 v, n0 z8 U) u6 h9 {5 Y
        }% \0 H; ~9 |2 N/ r# J2 o, Z* J
};
4 o3 L( p. d' Z8 T1 }: s+ V& |( p4 q& S- p( h# v
static int __init led_platform_init(void)5 L: t, \8 Q: h! G9 c$ j
{
' N2 H) A4 w: r% w4 U- x4 S1 S        int ret;2 \/ R4 G+ A# R2 _' I& ?; ?
#if 0
8 N  N# U1 A' }4 J0 r4 H        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" k) e( R6 s3 z4 R' M( E, f# T, L
        if (ret)" V# A- z. ~$ C  V1 U
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' R. R, G: O, Z. h4 H' U                                "%d\n", ret);
/ z4 K7 a. x% u#endif3 g0 D! Z7 `8 M! {& h  n
        ret = platform_device_register(&da850_evm_tl_leds_device);& h, q6 L9 N; d9 z
        if (ret)
& N2 U, f. c9 S                pr_warning("Could not register som GPIO expander LEDS");4 U6 g" w+ `8 Z5 @3 ~2 k" |
        else# e3 C5 h5 _# M! n1 A
                printk(KERN_INFO "LED register sucessful!\n");
) L) j; Y, o) V8 G6 n. N1 A2 M! C  Z& n% k2 T
        return ret;  e9 y# Z" W; Y! T3 V4 G
}
( d7 I) S; R4 K. m* I3 f
* N. X/ @8 K" E, h# t; Estatic void __exit led_platform_exit(void); a& h7 b; w2 Z2 y: o
{" ]5 t- K+ C; e- d3 S
        platform_device_unregister(&da850_evm_tl_leds_device);  ~+ N% l' M" Z. n8 y; d/ H, X) k/ g% Q
8 f' ^" ]+ C6 U* Y3 G
        printk(KERN_INFO "LED unregister!\n");
6 D; c/ M! ^" p! @5 m% k. Z4 r4 S}4 _7 S1 C. ?+ Z* j/ V1 q
# G- f" f3 O. ?3 }! d$ r
module_init(led_platform_init);
# ]7 w4 N- m" kmodule_exit(led_platform_exit);4 w) d4 E* K! C. |% W) @

5 m! P, ]& m) F9 M1 i; i/ pMODULE_DESCRIPTION("Led platform driver");8 Z  i/ j7 v  r4 k4 f" K
MODULE_AUTHOR("Tronlong");; y: n% f' i: d1 y
MODULE_LICENSE("GPL");
' `# {" X( |' `; F% ~. w: L9 c, @) {& d4 p
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-27 08:55 , Processed in 0.040766 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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