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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
* B8 A% l0 e9 t#include <linux/init.h># f- e* T( @: A* K/ P% U5 w
#include <linux/module.h>* \  a+ O* ?; V! j* {8 |7 u' i
#include <linux/kernel.h>* R9 \) u6 v, A- o- {4 k; c1 l
#include <linux/types.h>4 _, D0 H' H% ]4 x- u8 N+ W$ T
#include <linux/gpio.h>
! E2 ?8 m9 y! y. _: M#include <linux/leds.h>' I$ s+ F1 [& ^& m
#include <linux/platform_device.h>! J9 y1 ^( R' ^' q* M, `
$ J5 `& ~2 s' _4 G) n1 }4 W" {5 d6 A
#include <asm/mach-types.h># r4 I  B6 z* a2 W* L
#include <asm/mach/arch.h>
  L- B% Z( C; S5 P; g6 G6 @#include <mach/da8xx.h>
, B5 p& U' B' X7 q  u  N#include <mach/mux.h>
) x5 G+ `" Q3 P# `7 D7 _
8 Z- V; R/ e' o; Z#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)/ K& u! F# I) H) I+ Z
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5), `; Y/ E. T+ j. h2 C- Q( b
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
! }! _8 `6 r% p& u: M) x#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)$ G$ m/ a, h. Y* }6 \
: a8 l2 g" \. W8 k& ?
/* assign the tl som board LED-GPIOs*/* u9 U) U% X4 V: ]$ v
static const short da850_evm_tl_user_led_pins[] = {5 u- F7 y  d. }% o: W1 Q' v8 `* e
        /* These pins are definition at <mach/mux.h> file */
6 t' \$ C" C3 U        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 {$ J5 r; v, |  A
        -1+ O5 T9 E/ d$ x& R# A& [. J0 [
};' g- y2 n) n6 V+ ]3 }

5 p$ M" r1 f- S0 y/ J5 _$ f" @static struct gpio_led da850_evm_tl_leds[] = {' {! E4 ^* I2 P- U
        {
; z$ H, I, B. _2 ^1 l                .active_low = 0,  J: I/ ^% {  M7 n% J
                .gpio = DA850_USER_LED0,5 x: P( V" {, f
                .name = "user_led0",
5 ?9 Q7 z, }9 ]) R( Y                .default_trigger = "default-on",/ I& h# [# j( z. j9 @
        },
4 `' g# A& e1 Q9 v: V4 r        {
; A9 `6 d+ ~. V! a$ Z( l" C/ d                .active_low = 0,
# Q2 f. z, Z7 q4 S6 j                .gpio = DA850_USER_LED1,
6 a, ~- p9 G7 o7 y& [( l0 W$ l- L7 K                .name = "user_led1",6 @: O. x! N, @& j; o# o( |; i4 \
                .default_trigger = "default-on",3 a8 o$ ~5 M' E
        },
/ z; b# Z/ }; k% Z( x        {
7 q7 \% l8 F3 |# [# Z; f                .active_low = 0,& F$ C; c5 n; Z4 L" }5 _# F
                .gpio = DA850_USER_LED2,
* {; T9 w  D& N. Z  x                .name = "user_led2",
6 G4 t3 @# L3 {$ ~8 _% d                .default_trigger = "default-on",( p' V% X6 o7 K
        },$ r; u5 f) \) g
        {
8 n; O# Q( X$ J                .active_low = 0,& O* u. m" i6 O0 V; }
                .gpio = DA850_USER_LED3,
! w7 n1 {7 V9 [                .name = "user_led3",. K: R& \. e* R8 o) t" F
                .default_trigger = "default-on",
, O' e* w- g8 A& r$ K        },/ j: y# D7 E/ |% R/ e' t: [
};
& x, k/ Z- ?, m6 y& Q- ]9 J3 Q4 M5 Z! y! f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% b7 t$ ?" M) o1 b$ T% Q
        .leds = da850_evm_tl_leds,
5 f3 M1 B/ w/ N) S" ~5 p' M1 c        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 S# P- m0 w- ~% g
};
+ a  C0 u2 c0 N' S& l! k
% t$ J* K$ G0 ~( h+ t% D4 \static void led_dev_release(struct device *dev)2 m0 T6 j+ T# S
{
, g' d- t: W) o( [};
2 N, Z. H7 G( U* O5 w9 ?' H7 U
6 `8 W! |6 G) N( x4 \9 }1 a% S: gstatic struct platform_device da850_evm_tl_leds_device = {" v6 o6 f& d+ _$ d+ {# j
        .name                = "leds-gpio",, S6 ^; ^" Q% b2 i. g* F
        .id                = 1,
4 l. a( m; o# H  u& I/ ^        .dev = {
% c$ G9 e; L& g" @6 e                .platform_data = &da850_evm_tl_leds_pdata,% X5 J# \. }' v6 R% U7 V
                .release = led_dev_release,
, N, L; S- H8 U" u        }: G, O. k4 ^8 I  l+ w" Y$ U+ O
};
5 L& g. ]8 i9 |; s7 `+ O  G2 ~/ M" \
static int __init led_platform_init(void)
3 g( n& b) ]9 A. N% C{( ^8 h- |3 X1 _7 Z& G
        int ret;
9 S  g1 w' _1 P#if 0
1 Y* r2 m0 |  c. K8 A" ~/ \        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 M+ o. z/ E* i9 u0 c        if (ret)3 ?. n( H  C7 Z7 _. x& P
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- T. F$ K; U! J2 G4 r                                "%d\n", ret);: y4 D/ \& l3 q2 G% ?1 q
#endif
1 K2 D- h8 c) n        ret = platform_device_register(&da850_evm_tl_leds_device);* t/ ^; n" ~" c9 j: n( q8 r  z% [; P
        if (ret)
6 T, F0 {. S  H6 ?2 }% D: W                pr_warning("Could not register som GPIO expander LEDS");
% y) I: k1 F8 F. E0 M8 ^( `        else
8 E/ U5 V4 ?4 z" i% u8 D; l                printk(KERN_INFO "LED register sucessful!\n");0 h& U: x, q1 |* y. a1 f& E

. ~+ |& g# ?- i/ m( \3 D9 j        return ret;
* |- y2 X( A7 i- `* X' d: d}6 x" Z" g8 Y5 ^% ?0 {3 D" p
4 n1 J4 N( e8 _/ j1 @7 X
static void __exit led_platform_exit(void)  E( O* Q- @7 j# Z2 b8 m3 _
{1 m  B! @; T- W3 a7 d
        platform_device_unregister(&da850_evm_tl_leds_device);
  Y: X/ S, {5 M3 l* \8 F8 v: G
. }) D9 {: q" x5 g% n        printk(KERN_INFO "LED unregister!\n");
9 E; y% C& P: R}- ?: i4 U- |/ `( N
/ l* K: r+ U9 v9 I* i
module_init(led_platform_init);
4 ^8 E) _( U0 _  I4 \module_exit(led_platform_exit);
9 |$ B7 V# ^; [$ V& P6 i1 b4 c, p/ O6 x# W$ Y6 t  c
MODULE_DESCRIPTION("Led platform driver");
* E9 I7 o, Q# z# R* l: H- o* O) x8 qMODULE_AUTHOR("Tronlong");4 g( E! I" I5 ]- k" ^
MODULE_LICENSE("GPL");
% i/ V3 K# T0 z& p# y, h, |- }; t8 P# D2 P  ]" \
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-15 16:17 , Processed in 0.036254 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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