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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。, r  e9 L* l2 B
#include <linux/init.h>2 ^7 P( Z" V" p$ F) K1 g- I
#include <linux/module.h>! c1 |, h8 R3 R  [: V
#include <linux/kernel.h>! D9 o. t7 \* ~/ F9 D" B$ x
#include <linux/types.h>6 V& i2 t" y# m
#include <linux/gpio.h>3 T1 C; q8 O* |( c! a$ H: J
#include <linux/leds.h>' n4 S+ F0 p3 K1 V  S" L& ^! @
#include <linux/platform_device.h>% v+ ~/ i4 s! \, N

( n5 v7 h+ v7 y0 N: ~; B+ |* V6 C#include <asm/mach-types.h>% w' ^$ L3 T* p
#include <asm/mach/arch.h>
* u6 T" a' f/ k( b+ }$ D, M#include <mach/da8xx.h>
9 ]! F3 d) F6 X$ y5 g#include <mach/mux.h>: U2 o. L4 a9 R* Z# H1 f" N

/ ?8 j& d' }7 H- S' r& G7 n9 x' `#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)6 U- H$ t* G9 n& N
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
5 r: K$ S3 g9 Y$ p7 d! ^% b6 p#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)3 J+ s0 G& |; F2 c. a. z
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)7 v1 @* @" D9 E/ g) a

, w2 T4 g! d3 V8 e4 r6 o/* assign the tl som board LED-GPIOs*/( q/ T/ Y+ j2 q* s. J* P
static const short da850_evm_tl_user_led_pins[] = {; k! A0 Q7 j, m$ [
        /* These pins are definition at <mach/mux.h> file */
  S" k% ?! b1 U( H) K  j4 o        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,  D: z  F) v/ |+ r
        -15 z) e" F  R- t  _
};) ?! g7 \$ x* x
2 u# z2 G& g) p$ N+ h0 M, ]  V
static struct gpio_led da850_evm_tl_leds[] = {2 S( X+ D7 {" ?3 X+ L' ~- \
        {
0 ]+ ]$ r+ F4 q) a( _  N- V! ]                .active_low = 0,
5 G: ?9 U& \5 v5 v: @                .gpio = DA850_USER_LED0,% H% o) G- \7 l
                .name = "user_led0",
& @9 M5 n! g; p& T( P                .default_trigger = "default-on",, ?6 M; d) C0 F0 g% @: i" u  V3 m3 s
        },! c5 q  r) N5 E
        {% u" \5 x# k/ u0 R* \
                .active_low = 0,* q" R' b/ _: E0 q/ F! E! D
                .gpio = DA850_USER_LED1,
- A8 T" n) b) _; N7 t- O                .name = "user_led1",* m$ G- e5 q  a) b, S
                .default_trigger = "default-on",
! @: R3 i! j$ M; s, I        },
7 G5 ?* s; ^! J' D5 [        {
& U% F3 Q' H& a: D6 G) m, r7 y% i                .active_low = 0,& D2 V7 g* b4 D& o$ A$ N
                .gpio = DA850_USER_LED2,
( h7 E  x9 w( b' G* y                .name = "user_led2",& d8 `9 ]9 f- ~
                .default_trigger = "default-on",
4 d1 H8 ?  J3 q0 v( @$ T        },
' C, ~5 K. y  R3 U- i: g3 J        {
8 _9 F8 F! V4 j' l, i7 `& l: c+ w4 Z                .active_low = 0,, }+ F7 S( B2 l/ K+ c
                .gpio = DA850_USER_LED3,6 B( x& y# d9 ?' T4 V9 ~! W4 L9 O
                .name = "user_led3",) l9 ?4 Z6 g; |( @! w
                .default_trigger = "default-on",
. ~% q) G% W9 N2 p& _: D        },3 y1 J# }& V( g/ r
};; p- u# Y: [: `% \

* i& n, `, Z1 \' m! O7 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. |, ~% Q6 @! w! _. Z3 a
        .leds = da850_evm_tl_leds,$ w6 D6 i0 A+ [$ L0 R& g
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: h3 a9 g- w8 v, ]* c& X9 a};
1 z* Q' ~1 s( n( `1 s; U( O
1 a' v; E- C- ^0 X$ L7 `2 O- _static void led_dev_release(struct device *dev), K3 o8 C3 V) h7 z
{$ y2 `- q1 U1 T% J9 D
};
8 W+ z+ U1 s% R- r6 E6 k
% ?5 ]; n+ R# K7 Tstatic struct platform_device da850_evm_tl_leds_device = {# P4 ?2 v' D( u
        .name                = "leds-gpio",
+ |  \$ _  P6 E7 S6 z        .id                = 1,
5 l, i; ~' F$ I- ~# t4 G- K2 l7 e        .dev = {, V7 @. V' r/ T2 @# w( H
                .platform_data = &da850_evm_tl_leds_pdata,
( J- A: e! [3 T0 |2 s* G                .release = led_dev_release,1 q; D" }5 i) P* D) \. k* e
        }0 g% d9 M# n3 H& H7 r" L% _4 d
};  n! N) W! d$ U0 G

; R7 ]/ {- ^7 `' Jstatic int __init led_platform_init(void)
; E! M; `. z' q8 }! n{* b8 l! D+ G- ^( {! |
        int ret;7 h4 \/ c5 d* b" ]5 }
#if 0
" s1 Z- ~6 f' Q        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* Y9 Y+ ~+ |7 c* z
        if (ret)
; c) Y. I. C, ?, e$ {                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 Q' Y7 C) A. T/ s3 u                                "%d\n", ret);7 d9 c" J! f/ Z, u! v0 B/ @
#endif
% I2 V$ ]+ s) s        ret = platform_device_register(&da850_evm_tl_leds_device);
5 N' V; V8 g9 s: f$ T        if (ret)
4 {6 Z% E. Y' r5 j                pr_warning("Could not register som GPIO expander LEDS");1 e  ]& k# o7 ~- \" [' z
        else8 P8 M0 p" n; M6 d" F
                printk(KERN_INFO "LED register sucessful!\n");! Y7 Q* U) _- c% e
0 I/ ^9 K+ M5 a# }# i; N' E5 h
        return ret;) _  M) {# J) d% K& |
}; T5 b( \; P5 v! Z, L/ m3 v; S

' g0 g0 U$ r, `3 G" v$ N6 tstatic void __exit led_platform_exit(void)5 F  ^' @0 O( j& h" h$ k% U4 `
{, n" P/ h+ `6 S) Z( D
        platform_device_unregister(&da850_evm_tl_leds_device);
, v7 s* x. u: F) p% S: y$ i) I1 X+ t! Y3 G
        printk(KERN_INFO "LED unregister!\n");8 d$ Y2 z3 k5 G( S5 k
}% G* d# W9 s9 f/ z" A5 `! f
# [1 ^9 G0 I+ e- `9 `
module_init(led_platform_init);
( S  O6 Y1 v: `; z/ ^module_exit(led_platform_exit);
/ ?. `/ C, k0 Y" [
, e" `. I# {' k. m9 Y2 ^MODULE_DESCRIPTION("Led platform driver");0 r( M- B) J# ]9 s) `
MODULE_AUTHOR("Tronlong");2 Z6 k# L& \# Y% g9 D
MODULE_LICENSE("GPL");
/ b& M( e2 E. O1 S* [- g- w& @. e. `4 C! E
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-11 10:50 , Processed in 0.039145 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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