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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
1 w. Z4 x$ _: U' `+ R2 S+ a#include <linux/init.h>
% M+ b5 t2 Y4 d#include <linux/module.h>( s; i! E  X% w
#include <linux/kernel.h>) L! k0 t" ?1 g8 |+ k
#include <linux/types.h>
0 s; i/ Y5 ]9 ]: v! w9 b" j#include <linux/gpio.h>
# Q" B3 g* M: x* o1 a9 B0 l#include <linux/leds.h>9 J1 [+ O- g4 T5 S/ i# Z# E
#include <linux/platform_device.h>+ A- k4 x$ _- _4 r" R' \
- D/ A  W8 f" I$ L, G
#include <asm/mach-types.h>9 a; ^  i7 c) o6 I& Z- b
#include <asm/mach/arch.h>% R/ e& W0 o  _% y- d1 w# d" O
#include <mach/da8xx.h>& N2 Q- }2 Q" J( o1 T* J
#include <mach/mux.h>
+ u3 ?- o/ e+ G* w4 t. h+ Y6 h( k2 R- G8 n' G6 O& q& Y
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)' g" f; j; Q2 X4 r! c, A
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)* `* D/ [3 }7 G# [. H- I0 q
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)3 D+ P8 G# H0 U3 L) D9 N
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
8 {$ B8 }+ @8 [2 B5 G. V
2 @  |1 Q/ f+ u+ }( b/* assign the tl som board LED-GPIOs*/7 Z/ i: v7 N' c; h
static const short da850_evm_tl_user_led_pins[] = {
; W, h" r) N- Q        /* These pins are definition at <mach/mux.h> file */6 ^& R; ]. g8 b9 ]$ A  \/ h
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- v" U# C. c% {- E, I9 X( V        -1
( ^; y1 E/ L  j( h9 c3 X! P9 S1 L9 p};
+ ^$ _* y$ S# M: X2 z3 a
3 y8 H! @+ _" A3 q* bstatic struct gpio_led da850_evm_tl_leds[] = {  ?5 d9 o; g$ w1 x- \& i
        {
, \$ H; M0 {7 l  b1 c                .active_low = 0,
  w. {5 O9 S( d$ N# g                .gpio = DA850_USER_LED0,0 w  g0 k) y3 G  ^! z# W
                .name = "user_led0",$ R- q2 A9 y; ?+ R
                .default_trigger = "default-on",
/ Z$ B8 f- K6 s7 w        },
' |+ G4 h, |* ~0 K        {- W( p& u/ K) T8 }2 ?6 o& D
                .active_low = 0,, r; c; d6 O% X% I6 M: r1 ^
                .gpio = DA850_USER_LED1,
8 S9 Y. }: q' J3 o* |                .name = "user_led1",
5 }7 ^  Q1 f+ W; }$ Y' m                .default_trigger = "default-on",
4 B1 F$ r+ O& X! @        },
$ A3 z  a" u  |) ]& d( ]        {
7 f# @- P0 ]+ i: w% f0 l                .active_low = 0,
2 o5 f! Q$ M* w+ K$ S' }, n                .gpio = DA850_USER_LED2,
1 E% _- a" E' d                .name = "user_led2",
* L  I8 |7 B" s4 o2 v" s0 j                .default_trigger = "default-on",
5 Z* }  m2 ], V" [6 p- K        },
2 }% ~& J) D9 i! h7 B        {
% u3 s$ \: l" \8 Y$ [1 v$ h- J- x                .active_low = 0,' P. _" E7 p$ H9 u7 m
                .gpio = DA850_USER_LED3,
( }* P; E0 _5 t5 p                .name = "user_led3",
0 e( C& o3 @% \8 e) I' q/ s                .default_trigger = "default-on",  u" W+ W5 v7 I+ j
        },6 k# J2 u" e+ G
};! n! R! W# f' B9 }

- O$ ~) W1 v7 m: Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ D& l& H9 d) @  S, a, Y  c
        .leds = da850_evm_tl_leds,
* t, x* T; W: }' F5 V        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 D  A, M+ }! k$ ^- y
};) d5 Q2 L' R! ?* q
5 c' O* ~5 I. A
static void led_dev_release(struct device *dev)
0 ]( V* `% S8 r. S- x6 p{
* O* i0 p3 O; P# B$ c4 X# L};
# c$ ?7 a, m* A8 ^
! W( B. p! V( e0 z) ]3 u2 q, Mstatic struct platform_device da850_evm_tl_leds_device = {
" _2 i- z4 J/ b6 B) ?        .name                = "leds-gpio",! H! ~! b  O0 S: J+ ?
        .id                = 1,. P0 g& D+ g* S" t6 y
        .dev = {& l5 R7 w& W* q7 U
                .platform_data = &da850_evm_tl_leds_pdata,$ l5 N7 U8 o, D8 T
                .release = led_dev_release,
7 [5 f, g( G* L* f- R( U: j        }
8 X/ Q* F: I$ O};; `7 }8 F3 d% ~4 O3 `/ c
: @0 z. G: X( p. ^3 f; `
static int __init led_platform_init(void)
. `, i$ f' L! ?4 ^% V{# K9 x. h/ [  R9 u6 H. A
        int ret;4 E3 p) E7 g( @! K$ s0 d
#if 0' [* ^3 k5 d9 Y; v% K
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ m7 G# x% w% g' R4 U& a
        if (ret)
) x9 f* y6 i0 d4 U1 T2 ?2 c                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! L$ f# Z* b+ _' c* {6 R/ ~9 o; B                                "%d\n", ret);/ c' U# Y: e" ~+ D0 i# I4 a1 l* L
#endif6 V+ z+ w! n. a+ U  ]0 j
        ret = platform_device_register(&da850_evm_tl_leds_device);
0 R0 ~8 ~$ K' I1 a, Z0 W        if (ret)
; ]( A+ c. J' `# X" ?, r                pr_warning("Could not register som GPIO expander LEDS");
2 f2 {" q, E" V5 h: e) V        else1 x' S2 ^- O. H) k7 s( t; }7 H% P) B
                printk(KERN_INFO "LED register sucessful!\n");
  P, y8 ^4 e3 N: i& W" L
5 W# W* u1 W$ _' V) D8 R0 ~7 e8 C        return ret;
2 B/ }6 Q; I/ r9 Y+ u}
+ ~, d1 M- V# u- p8 @
! `$ `9 _7 Q5 `( G( estatic void __exit led_platform_exit(void)
; p& c) H) V# ^{
+ e5 B! Z4 O: h4 i8 O" i7 s        platform_device_unregister(&da850_evm_tl_leds_device);
  u! i+ x0 b2 e& T% e3 [
5 C$ X$ V& T3 O5 u9 U2 ?        printk(KERN_INFO "LED unregister!\n");
" |- r; K9 B) e+ _; E, N5 M3 J}# E9 }) b0 n0 a
+ B1 }6 ^3 J+ X/ K- @0 |+ R; r
module_init(led_platform_init);
1 R6 b4 L6 o# n+ u/ u; B6 Emodule_exit(led_platform_exit);, C0 ]: J+ ^" C0 U; r

% }* C0 w4 D' f% S4 N  j* OMODULE_DESCRIPTION("Led platform driver");
/ P3 ^; G7 c6 l) Q3 x/ NMODULE_AUTHOR("Tronlong");
) U- Q3 Z( `, g6 yMODULE_LICENSE("GPL");0 V7 m7 c/ @$ e6 U7 P9 x- R

9 o6 K, ^4 k4 m: A5 D
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-9 14:02 , Processed in 0.042545 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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