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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。; A0 A) g( M) A: u- z8 l% O
#include <linux/init.h>- @3 V, q# {: Q  n. m
#include <linux/module.h>7 G; ]7 e( |" o! D, r# l
#include <linux/kernel.h>0 y8 ]2 d0 ]8 u  c$ E; y
#include <linux/types.h>6 i. F5 X* D( t& p& I
#include <linux/gpio.h>1 T+ F/ i& f: h6 T3 \0 H3 [
#include <linux/leds.h>
! S* S: `0 h6 K! o! e#include <linux/platform_device.h>
0 ^$ D3 x0 `4 \. @9 ?- _8 A% ~: Q" H. o
#include <asm/mach-types.h>
" @3 ^% Z$ k+ h$ y3 f9 J* n* x#include <asm/mach/arch.h>
+ S& q& C2 O; F& {+ i& T#include <mach/da8xx.h>
1 H; A# l% e8 u1 q" n$ [( r3 A#include <mach/mux.h>9 g' f1 t& E7 j9 s: U) t

" s- C/ g8 M. J. a( O#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)8 Z: ]8 Z2 @+ p$ d. _% I# b: @
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
: p" r& f0 @! K7 W. z: D#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)9 y$ R3 B' M2 u7 h  `  P6 r
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
- i' e. F" K/ @& i; J6 K/ k" x4 _6 n4 s9 r4 w
/* assign the tl som board LED-GPIOs*/
& W! M* a3 d0 K. F* L# Q% Cstatic const short da850_evm_tl_user_led_pins[] = {
6 y3 P7 N& L! e        /* These pins are definition at <mach/mux.h> file */4 d: r/ e2 B; m5 t4 R
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. i$ p9 x! m# o/ J" ~( h
        -1+ D! `* i& p) O/ L$ P
};0 H7 u& i+ [1 }  R, v( z

3 b: U$ }: c- Z1 g+ tstatic struct gpio_led da850_evm_tl_leds[] = {! o8 Q" {8 R1 i
        {+ ?0 Z3 X. T. G2 Q( W
                .active_low = 0,/ [3 A3 h) a$ w0 q
                .gpio = DA850_USER_LED0," L* n3 H/ w" i% m
                .name = "user_led0",
" o" |# u+ z4 e4 r  H- f                .default_trigger = "default-on",
2 ]$ {+ J6 D- h( J) @4 t  z        },
( c) I1 r% N5 @- d3 `7 `: j* ~; a        {! u. b  M: a% ?0 ^$ k1 E8 i# Z
                .active_low = 0,
" a0 o9 w- G; {- h  o                .gpio = DA850_USER_LED1,
& ^% i$ }! P9 K# ~" w                .name = "user_led1",
! y7 d8 n( {2 ]: g$ g; Z) y# h6 l                .default_trigger = "default-on",
, w2 e3 @# A  i' K' p* x        },0 \: \5 M& i% v* T! B8 Q3 l- G
        {' c5 U/ M* G& E4 V( ]
                .active_low = 0,
+ c# v! `+ J/ x7 s  R  u# _3 j                .gpio = DA850_USER_LED2,( r7 i3 q# x9 V: o/ Z) q
                .name = "user_led2",2 Z% }  `/ j8 ]1 M* Q( H
                .default_trigger = "default-on",
! L- O4 R5 P9 P) B) `        },
1 _; q$ \5 D& ~" J5 L        {
8 v5 j5 c9 d$ f0 @% Z1 R                .active_low = 0,, q* U( y7 C" v' b9 i
                .gpio = DA850_USER_LED3,* g: A: z! {, M* k5 f/ e
                .name = "user_led3",: V$ \7 E% x) _. j3 Z& y
                .default_trigger = "default-on",
4 `% i3 K2 K1 Z% v  }7 I( D        },8 L* v* }8 I5 M" _! i
};
5 [4 Y7 L8 e- L% ]9 y- z1 f9 ^
' C5 d! ~7 a- b7 P/ s, U* x. tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. Y0 L& o2 _( Q1 c4 e4 C: ]        .leds = da850_evm_tl_leds,
/ f, M4 N' M4 S5 W1 u: ]/ i        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 N: H' m+ c! I- Q  P! x};
( V2 L; P$ |8 G9 W8 Z
: p' [3 x; Z" U2 Q2 g! Ustatic void led_dev_release(struct device *dev)
1 V# N( `1 C- G! O7 o{
8 ?' c' }; b5 X: e) |8 r};
0 a' ], y% O1 g  _2 Z+ J$ b, i1 j! [& X8 _; {4 T% h
static struct platform_device da850_evm_tl_leds_device = {
" F4 v) T/ J5 g$ }* o& u        .name                = "leds-gpio",' @; r7 W% y4 @. ~
        .id                = 1,) r$ h; K  n% U% S/ e# c
        .dev = {& @3 z: S  B/ O
                .platform_data = &da850_evm_tl_leds_pdata,
6 g5 p' e4 b2 x* F! s# k0 V* `                .release = led_dev_release,. q. f5 r" y; d0 A0 F- V
        }& O) m( E+ y5 S+ B5 V
};
, x, g' `- {2 y  j7 S1 V9 Q6 `" G2 e! x& W+ r5 X: {$ Z: l; N) `- [- l
static int __init led_platform_init(void)
3 N4 |8 L' d% G; x{- W) t  c; @$ b
        int ret;# d/ M4 v9 \1 M+ s/ V
#if 06 [: F' a, E, F5 }6 O
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 b: m% y3 \" u& G0 I' i! d9 O1 o7 e        if (ret)! b5 V1 N" z* b2 x
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 ]+ F) H0 I* s2 p* r' T                                "%d\n", ret);  a, C3 Y$ F- l& i
#endif
5 ~7 s7 u: P; l; R( i        ret = platform_device_register(&da850_evm_tl_leds_device);  ]4 {1 n5 ^9 {  ]- {) P+ ?
        if (ret)
/ t+ C- R& J5 F# P$ c  o4 F! y                pr_warning("Could not register som GPIO expander LEDS");
8 _7 `" Z4 E3 N2 z# F- w: q+ [1 E        else
5 x( ]+ d) i7 r* T                printk(KERN_INFO "LED register sucessful!\n");( J( n4 P  Q! l9 D# J

/ o  R5 D* k- L% u: T        return ret;6 W; }! V3 n3 V1 A/ V6 g0 @1 R9 x
}
; Z! v6 F# w, G* M/ S6 \7 x" c
static void __exit led_platform_exit(void)
6 Z# h. k. N. s{+ T" ]1 k: W. I7 ]4 A9 q
        platform_device_unregister(&da850_evm_tl_leds_device);
0 l- E1 {; r& \( b' D6 L+ V# s7 n3 `
        printk(KERN_INFO "LED unregister!\n");
+ ]) Z6 s, O9 N( ^}
9 D$ l. s% x- X2 p' |1 D
6 u/ L7 [8 }; X% e% |module_init(led_platform_init);' I5 R: O" [1 e% O' L, _9 C/ e# W
module_exit(led_platform_exit);4 F  `. r3 y# A2 d: `& j

( d3 ^* Q* P& b. g" k0 ^* V5 wMODULE_DESCRIPTION("Led platform driver");
8 ]9 N: q8 U0 k" R" {+ Y) VMODULE_AUTHOR("Tronlong");. g; I% W% a8 j6 P- [+ Y
MODULE_LICENSE("GPL");+ g2 R3 S% R- B' A

# ~) R$ ^3 {* x& V6 u: n
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-8 02:16 , Processed in 0.043847 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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