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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
# d7 p8 O- A2 D8 ^. w7 z, Q. U#include <linux/init.h>8 K6 `0 O) v1 H# `: G7 j4 F
#include <linux/module.h>9 a# L: b% {! m9 b8 f: p
#include <linux/kernel.h>
  ^3 L: X% z2 J#include <linux/types.h>' \; j( O8 L( U& T. V5 z7 l, d
#include <linux/gpio.h>
% u0 D$ [0 w: \#include <linux/leds.h>7 x, a8 l/ B2 l* T7 ^0 J' e
#include <linux/platform_device.h>
* X5 B. A* b, H7 c& D% V
: ]( _  A6 ^5 X" b7 J#include <asm/mach-types.h>
$ x6 [8 D7 p# a" p0 k/ c#include <asm/mach/arch.h>' }2 h: b  b; k* r
#include <mach/da8xx.h>
* U2 a# u5 f8 w, `" y9 E3 j5 M#include <mach/mux.h>
# W7 J2 Q) S4 s2 J! d+ z' y  X; y
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
* z8 B. t- ~' _#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)4 s. \; Q3 l9 s& Y- u" w
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)" V4 e! _- \( D; D0 Q& x& n
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ T' H" x, }2 q( F

! E5 _9 ?/ i0 f4 m' y8 B* h) L  b7 O/* assign the tl som board LED-GPIOs*/  S! @7 H3 o& L% Y8 o: _5 S
static const short da850_evm_tl_user_led_pins[] = {, f* S- @  }! f0 p% M
        /* These pins are definition at <mach/mux.h> file */5 Z/ A* J6 A- e2 x5 d5 F$ J
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 J9 a9 H! e1 B5 j        -1
& Q0 j7 U3 j% Y};
! J7 m+ q6 C( D& C- b' ^1 A" Q6 \) \. }2 E* t. j
static struct gpio_led da850_evm_tl_leds[] = {
4 Q  I% y$ v, e: z2 G5 I  M        {; Q1 r1 L, O0 L
                .active_low = 0,0 o/ V. U- |9 X0 Q3 q8 R$ T) A. [' P
                .gpio = DA850_USER_LED0,
1 K# j3 C4 Z' e: t; B& T1 Y5 B                .name = "user_led0",( d, l" ]9 _& l! u( a, S
                .default_trigger = "default-on",
( N3 [6 a  q- L1 Q$ o/ V* E! |9 w        },
" V9 l! {( H8 b! s  ]* R8 v) R7 z        {
" n" m8 J9 G+ m/ v. r" z                .active_low = 0,* W, \' {! W0 n4 q3 H' x
                .gpio = DA850_USER_LED1,
. }  b5 N# N. `) c8 Y& y" g: z+ ~                .name = "user_led1",$ I+ }0 r, ?0 F5 `3 H
                .default_trigger = "default-on",* c4 b  `, G, K8 M, Z, o3 l) Z" C, A
        },2 c5 W" q* J# f" Z4 E
        {
2 ^  I$ W& o% h) J8 W# s                .active_low = 0,
; X+ u8 l% W- ]& a' @& ?9 W                .gpio = DA850_USER_LED2,2 Y# w, w  A: D7 K; n; j
                .name = "user_led2",. X  a/ A# `( W& f9 j  o
                .default_trigger = "default-on",
5 s- G" d  q+ E- S# Z5 G1 e  E        },
: B/ w4 J3 B9 J        {6 @. S, y3 U5 f
                .active_low = 0,# s0 p+ [- L. U+ P6 W3 {' O0 U9 D2 ~6 d
                .gpio = DA850_USER_LED3,
4 `0 s# ^1 @( n. z9 K2 q& \9 T$ p                .name = "user_led3",
/ o' E8 k0 }$ L. h$ X/ I                .default_trigger = "default-on",
! `+ k8 u, E" M; U  ]) Q& E        },
. G1 I8 N" f; a1 U};3 M$ H$ d3 @# _* I" J4 u/ e) s

1 n1 ]3 s/ R, Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 T5 M  t; J7 ~% V* l1 f
        .leds = da850_evm_tl_leds,
3 P! D  c! ^3 H! z1 x) h        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' K4 y- Q2 {8 a: ]. i4 C8 d};
8 b5 E+ h: u8 I6 ^1 O. @, d
; S9 l2 M4 Q# ?static void led_dev_release(struct device *dev)3 ]5 ~2 `) ~4 O$ `/ Z- a  |
{
# o4 p; P2 J" m" ]" z1 ?};
$ o/ r) F( p) o2 [, Y8 d
* M$ T( a9 K9 ~6 L  S& jstatic struct platform_device da850_evm_tl_leds_device = {9 p0 U) D' B: x/ ~1 H4 y
        .name                = "leds-gpio",& y+ _  X  O: x
        .id                = 1,
# N7 {) |4 V- z9 ?# ^        .dev = {
8 a' Z" d' ]( b6 S                .platform_data = &da850_evm_tl_leds_pdata,
- E. k- }! |% ]* A3 q                .release = led_dev_release,
, Y- N  z2 l) Y* P# N        }# M2 y9 N3 q, P7 K4 d
};
* H" T7 A; F. G6 q* g8 B- T$ [" I' B, c* A& U
static int __init led_platform_init(void)+ n* t$ V  g% u/ U( T( l
{
* @* x( E( j# S% @5 T        int ret;+ U6 [6 ^7 }) K# T- a
#if 07 x+ O" S: C0 a- }
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" Y, b& X* i( o7 m  Q$ i3 b        if (ret): H5 i* m1 Q7 N4 a7 F  j' f  Q3 X
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 {$ R$ R$ O4 |! i& J
                                "%d\n", ret);+ i$ n( V1 K6 l+ {
#endif
9 {+ t* e5 E! |3 `3 m  \/ C        ret = platform_device_register(&da850_evm_tl_leds_device);
7 S- h2 g4 `3 U& I/ m2 D        if (ret)
5 f4 Z) a  g2 F4 q! t5 d0 \6 j                pr_warning("Could not register som GPIO expander LEDS");
. n9 Q1 ~9 S' F$ F, d$ a) l( J/ n        else
  h5 o. _: m! B) e( o7 v! I                printk(KERN_INFO "LED register sucessful!\n");% e+ h1 U9 n* O9 Z3 G

2 k( C2 h" |6 A, G9 a        return ret;. |6 f! G! G4 S% ~: D" [( A
}" N4 `  j( z* l4 o+ b9 \& }$ j# A
+ W' [/ z2 ]6 @" Y* C/ o
static void __exit led_platform_exit(void)# p3 \- ]* h0 N
{. m; ?2 B+ q6 H
        platform_device_unregister(&da850_evm_tl_leds_device);
# X* K$ D& f/ ~' P
4 N+ b' n( C  C        printk(KERN_INFO "LED unregister!\n");" D6 T  @) {) t% w
}/ A$ Y* J$ N, p
* [, d# j- a) Q$ {  ?, |$ O. @7 N  a
module_init(led_platform_init);4 R/ b* Z6 X) m
module_exit(led_platform_exit);( v5 v+ G) T' d2 U/ v

. z; X3 U, u' j+ {3 `) zMODULE_DESCRIPTION("Led platform driver");; o- W+ q! t4 X0 }. P
MODULE_AUTHOR("Tronlong");! C( B+ i- ^  E: E6 w% E' f" g; Y% H" ^
MODULE_LICENSE("GPL");; e% Z  @* X+ |) T
* W; a& A# p8 p3 ~; I, t  {
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-16 15:44 , Processed in 0.040886 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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