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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
( r* g1 o% L# w$ q  m. ~" R9 y#include <linux/init.h>
, `3 ?# Q& ^6 q6 v# c#include <linux/module.h># S) `! b, K0 O, p" B- w% _7 m
#include <linux/kernel.h>, n. b& F& z$ B1 i( D7 \# m# v
#include <linux/types.h>
1 ^0 R3 f: C6 @#include <linux/gpio.h>2 v! K* g' S1 U5 i* P
#include <linux/leds.h>; h$ _- N. ]1 y8 ~/ d
#include <linux/platform_device.h>5 A5 ]' p/ D/ o9 n0 H% O

6 a6 O& |: Z" h/ g) e4 ]+ Y: y#include <asm/mach-types.h>2 G/ B) R7 \( l: L9 L4 u  I3 C: n
#include <asm/mach/arch.h>9 \3 v; P$ D6 `- D$ u  C6 d( l9 p
#include <mach/da8xx.h>
/ o1 J, i4 ]+ @3 C$ @3 L5 C; Q#include <mach/mux.h>
/ w* F' @$ h* t1 B1 W0 m
' b3 w4 g: E6 E& @) v#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
: m8 e- x: I) s& N. b# w/ A( r5 R#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
' c: N( |9 g2 q) w3 ~5 ]+ i! L; q#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)- a" y+ Y! f9 _9 W/ ~/ k
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
9 @6 h' z; V/ ^. m4 `/ S4 s! s! u/ t) t, x! ~8 h) O4 i! B! `
/* assign the tl som board LED-GPIOs*/) o4 L. Z6 `$ l1 ?- T: ]
static const short da850_evm_tl_user_led_pins[] = {
- ^# l, @2 L' o7 Y4 e+ O        /* These pins are definition at <mach/mux.h> file */5 W5 @; \: f% D5 N& w: x3 q  G
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! H' t6 j* R1 [6 k4 x# d        -1
/ ?5 G4 r- j+ M$ @8 A" _- s1 {};
  b& A- |+ T! Z* C
; T& K" r$ G# f/ ^  d3 C. N# Z0 astatic struct gpio_led da850_evm_tl_leds[] = {% q# n% @. @" a+ z* K
        {
) d5 w1 O% {  _) g                .active_low = 0,
+ s" n/ ]& R+ P! X8 \                .gpio = DA850_USER_LED0,6 L9 H. R' B; m; k9 j. {5 Y! u7 X
                .name = "user_led0",' `; `: Q( G, c6 D# K3 H) \! p
                .default_trigger = "default-on",/ d9 n: t% T; v: }+ O/ @; B( _8 Z  x9 a
        },. |+ j; W* x( Q, a% D6 w' a7 F
        {' Q$ Q. V) `9 `  I' L& H
                .active_low = 0,
- f% ?! E4 C. c- `: U  y' t                .gpio = DA850_USER_LED1,
7 [& k/ ~" K* L3 @- u# M- ?                .name = "user_led1",
: i7 @# K, \+ R& R3 y                .default_trigger = "default-on",
# E0 K' \4 {: }% P/ ?3 y        },! d* n2 ~$ k( {9 S2 ^7 U. Z7 o, l
        {, H( O1 Z4 V. x' Z) g7 D
                .active_low = 0,6 Q; G/ k! ^6 F* ^  i
                .gpio = DA850_USER_LED2,
# u2 L  ]* t& p  v: U7 T$ ?+ m                .name = "user_led2",  r  Y2 R5 e$ W$ M) r" K
                .default_trigger = "default-on",
% X2 d* C5 O5 Y9 p  T# d% R        },: e. O7 R- a' H; K3 w; k% q& _( {
        {
. m, d" \) M' @5 [                .active_low = 0,
9 \. Y* C5 b5 H9 m. d( g                .gpio = DA850_USER_LED3,
5 X2 c* L7 z, [6 g# x1 ^$ _5 V) _3 d+ y; x                .name = "user_led3",3 ^) C9 ]4 _+ b
                .default_trigger = "default-on",
1 s0 ^6 d4 A* H3 V, c4 F        },6 ^& i; c( J4 i8 E+ x6 I' F, Z
};- C. ]9 B; C* R+ m

* _$ A- F3 L- Z) gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 \) f" o4 A2 ]  i1 Y" `
        .leds = da850_evm_tl_leds,
0 {; {- \/ b8 C0 l6 H% O2 A: K; `0 H        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. h. w1 Z0 W) G/ h1 j; @+ m
};
+ a& o3 F# u5 @9 B  `$ a! r/ I" i3 _2 H
static void led_dev_release(struct device *dev), r0 [9 f: s0 X: f' R
{' h2 U0 U8 b4 a4 ^2 {9 ^
};
) O% t9 p: @- X/ t) Q
0 e3 {4 R# Q- J# @static struct platform_device da850_evm_tl_leds_device = {1 T8 e7 {0 S3 s( W! @. ^0 X3 ?8 l
        .name                = "leds-gpio",
- n, f1 r) h0 M4 o4 C6 ]* t  w# M        .id                = 1,
3 F; W+ b( \1 _        .dev = {
" f% J# Q' U" s+ e4 m" r  X                .platform_data = &da850_evm_tl_leds_pdata,* w# _* j( w* ?# L4 q; t
                .release = led_dev_release,
: u( s7 J1 n( {5 G4 r5 C        }, @$ t. B8 v% c, T
};5 J- u7 x3 \' c

  |' e. k8 ^& b' t3 G# _' kstatic int __init led_platform_init(void): D- C  ]1 }$ l( ?& w/ O
{
$ v# H7 l8 [' A        int ret;$ x; u& b+ B2 J
#if 0
4 ~- t7 o, _5 g( A8 z5 w3 s        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# m- y7 L8 @3 G, p; h; |% N        if (ret)
+ v6 d2 E$ X5 G3 _* H, B* n                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 |# i# V0 n% y+ \# m                                "%d\n", ret);
* F8 W/ V$ J9 O7 E: h$ b( r#endif& y/ i# K# u4 q* X* {4 ]- v
        ret = platform_device_register(&da850_evm_tl_leds_device);
$ e' p& S$ O5 Q1 E        if (ret)
3 |/ m7 M3 I0 y" R                pr_warning("Could not register som GPIO expander LEDS");
( o" [, t0 a2 L/ ~4 u        else
7 W! l/ R/ U: g5 W1 B3 d) _% O                printk(KERN_INFO "LED register sucessful!\n");  h2 q/ R+ R5 K2 ?. J2 r

: I4 L4 m" Q8 h. n! w& t        return ret;
* @, w. q: A$ Y+ G}# G$ U* U1 z. O( a- G! ~6 i0 Y
# ~7 f" b8 i- A% C4 Z3 v/ C! u$ p& V
static void __exit led_platform_exit(void)
8 M+ P9 O% v) i4 g" Z{
2 D+ d% p0 h1 U5 c% ]        platform_device_unregister(&da850_evm_tl_leds_device);
1 y/ C5 L2 G9 M. o
2 a) \2 n, T/ T& s9 M2 e        printk(KERN_INFO "LED unregister!\n");
& s7 ~' O, c; n( t}
4 Q; N6 C! ]0 d1 b' U3 p2 n" K
2 H7 j5 I% N! _; F3 q3 q& zmodule_init(led_platform_init);' |: \7 {* O0 d; A
module_exit(led_platform_exit);% ?. r1 I6 Q0 h- k# o3 T* W% H8 M2 |

& g, B. J* d0 a" {; S& vMODULE_DESCRIPTION("Led platform driver");
" H9 Y# K7 \. [MODULE_AUTHOR("Tronlong");
% D7 h5 J9 _+ T" d' v2 ?+ uMODULE_LICENSE("GPL");! T8 t# [. p2 [: `5 j: n/ J

! |2 ?& c4 b: D  i* ~0 p
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-3 03:13 , Processed in 0.048927 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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