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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
! b( e! y0 ?" N! L  p9 I#include <linux/init.h>
7 O' G$ f  p$ J1 U) S: }' i7 y#include <linux/module.h>
  b/ t6 B& n/ h9 U% K#include <linux/kernel.h>- }! W) ]1 o: U; y" R- I& u3 H
#include <linux/types.h>2 t5 O+ n" n% a% E0 t( w
#include <linux/gpio.h>
- S, |; h0 T9 z# K1 i3 e7 i) a1 B" ?#include <linux/leds.h>
) u8 ?1 s% o" y7 J1 O+ @#include <linux/platform_device.h>
) s- k) X% W7 L; L' C# P3 A6 ?. k, v
#include <asm/mach-types.h>* U+ ^6 F# g  x
#include <asm/mach/arch.h>% b7 h+ N6 i" u5 Y$ a: p) R
#include <mach/da8xx.h>
1 g5 Y1 {. ^7 g5 t, R1 y#include <mach/mux.h>6 A/ b' o. e: n) p- }" ~% n0 R: v- S
: t! x9 n4 u# Q! A  M% v
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)1 M" F" a. }; p, U. i, z& S
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- m; V$ c5 }7 g; y. C# |+ s#define DA850_USER_LED2        GPIO_TO_PIN(0, 1): W  J* O: L0 p) d
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
# Z* n* z& z$ _0 X7 b2 w2 T; S$ x$ `; m6 ]# l/ k
/* assign the tl som board LED-GPIOs*/
) I4 n2 @2 o. ]static const short da850_evm_tl_user_led_pins[] = {/ U4 n$ G) E& O4 d/ w' [. f
        /* These pins are definition at <mach/mux.h> file */
, b, e5 k( A3 o        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. a. |! y  g7 n5 Y+ V  ?2 t3 C7 ]        -1" W# ^( j: }% m- n4 Z% h/ Y
};
* a/ |1 E. w' H3 E! Y* z
# `) R' l% @. a6 D/ W9 D. a; `static struct gpio_led da850_evm_tl_leds[] = {
7 D  _' b/ G# D9 `- T        {
0 B- Z* |0 K4 B$ a  z' |% N+ H3 R                .active_low = 0,6 Y$ D% c/ a7 L) Q  `3 h" _. z
                .gpio = DA850_USER_LED0,; U7 j% h: e: Y: t7 C/ O/ e) e
                .name = "user_led0",% }( Y- U8 [. B( l9 H
                .default_trigger = "default-on",
6 l/ n) i6 b/ G; e& T% v  f        },4 {6 R9 Z) v1 G% l- u4 G0 i# m" ^! D. s
        {
' h$ ~# }' E& u) K5 Z* I                .active_low = 0,
2 N# i3 K' i, k2 \) l                .gpio = DA850_USER_LED1,
) S; N* W! ~& @. ^, l                .name = "user_led1",
( l0 ^" q4 `; J' x. R. n7 [) E* U$ M                .default_trigger = "default-on",
0 t( G7 c& Z& ~  u. T5 x1 D( N        },, ^& G9 R: l$ G  b( ^! l5 Y& d& h$ d
        {" v8 r' X" c* [! P+ v4 v8 c5 x, S
                .active_low = 0,
# @: H# x' V: H3 o6 ^                .gpio = DA850_USER_LED2,
# ?6 j4 }: {& h                .name = "user_led2",
- r4 D: A$ v) e7 Y                .default_trigger = "default-on",% i- n4 ~+ ~$ k: u- \
        },
7 _9 w. N5 S4 L4 @# G+ a0 s+ x% G# F        {
( o  r4 }2 y, t/ `9 @                .active_low = 0,- X- l( a5 S7 v
                .gpio = DA850_USER_LED3,, f" ~6 g( g; b' \( [6 S
                .name = "user_led3",, W- ^8 n. w6 h& G! _
                .default_trigger = "default-on",( M. l; V9 p% W' y
        },
: e- N1 U, A! B9 o& F& p" e. Y% I+ S};! S: `" [4 s8 x4 D4 x
7 D5 c8 l. t! k; n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; D6 g' w' A' f$ M/ }5 L" Z        .leds = da850_evm_tl_leds,
' ~, s: a6 E# w" b        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: S- d" S8 S: `, p7 m, d- `( s" r
};! s, d: d7 ]$ L8 Q& ^3 ]& M
+ w, i& Q6 Q* K# H; X: D0 Z
static void led_dev_release(struct device *dev)
" z3 j* S* K& ?2 A{9 \. f& L  _( J7 ]4 k, i, Q
};( l5 v4 M0 j+ |

# Q9 z' J3 d; q* ?% [1 P4 B( r9 fstatic struct platform_device da850_evm_tl_leds_device = {4 C9 \$ V9 C5 g+ E: O/ g- T
        .name                = "leds-gpio",( {' B: `1 O- n2 u$ N( c
        .id                = 1,
) e$ c5 z% `+ G" I& i  j% P& P- u        .dev = {
' n1 J4 Z/ Y( v. z/ \                .platform_data = &da850_evm_tl_leds_pdata,5 o. _& q2 Y. l* m- }) w  c: {; G
                .release = led_dev_release,/ e% j# @. \( Z9 m& L
        }
; m) L2 r( T# d" T% A4 m$ f9 I};
- I+ n% U/ O7 ], j8 U/ a2 {7 y7 V: a. W. O% ]8 [% d
static int __init led_platform_init(void)
! o3 t; a4 ?& o{$ |0 X! Y2 J- @
        int ret;; w; z$ n1 B6 t# m! ~4 I
#if 06 J9 ^* U+ x0 O2 `2 x% V
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* B' t: d, z$ X$ A" h
        if (ret)9 o" i5 n' \, L0 C
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' {, m3 K) X& [3 g& \5 n
                                "%d\n", ret);
$ g* F' f2 }7 z% j( E#endif" \! y" L/ w2 N% L
        ret = platform_device_register(&da850_evm_tl_leds_device);- s9 s3 E# ~# M$ [2 Z$ a
        if (ret)" `0 c* @5 i1 r. [8 b. j
                pr_warning("Could not register som GPIO expander LEDS");- g) `. `0 D  \
        else
" q' K  W  I% V- Q# E) c& k2 t                printk(KERN_INFO "LED register sucessful!\n");$ }0 V* P6 V8 S* o$ _6 k0 K1 ~

' Y4 ~8 {/ t1 ^* D* [  h        return ret;
) B# S  O0 J: ^) K1 o6 \3 ^% o}
2 T" i0 h4 p& v" j0 L
8 X3 `) m& @, o4 t9 [2 u7 O/ Nstatic void __exit led_platform_exit(void)1 B. F+ f, Y+ S1 a) ^
{* T# o* {' k! A! G
        platform_device_unregister(&da850_evm_tl_leds_device);
1 b8 U+ V: E! y9 d- _4 K) ]# K$ W
: }& M1 j. b5 k        printk(KERN_INFO "LED unregister!\n");
0 Q' o. ?8 X& @/ s! K- V0 b" ?2 Z2 L}
8 p$ T# R8 F; E* J# o; T3 i$ `! R7 c; t; X" B: y* t1 G9 _
module_init(led_platform_init);
/ x) F  G# n0 p! z3 Omodule_exit(led_platform_exit);  `9 m" ^6 N: v" @$ h

0 S6 `- Y0 l0 x0 ?MODULE_DESCRIPTION("Led platform driver");# [2 I; h8 D! [
MODULE_AUTHOR("Tronlong");0 z- i$ |7 g) Z; s6 R# u1 k/ o" _
MODULE_LICENSE("GPL");7 R& @( w/ u, q+ g% q- }

  g4 w" P  |8 ?4 W9 J& ?9 g- v
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-28 20:14 , Processed in 0.040157 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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