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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% J2 U+ V/ c( p  ^" N
#include <linux/init.h>
7 G) d, m8 W7 F) F) l3 F#include <linux/module.h># f) P. E. n. p9 R" U& k& Y4 W. M
#include <linux/kernel.h># [) y) m  Q- z$ r$ o1 t
#include <linux/types.h>0 x. @# D% v  v$ B$ b4 [
#include <linux/gpio.h>
; W% }4 q! W  @8 B#include <linux/leds.h># V! G; i2 t3 W' y; ~- H! }
#include <linux/platform_device.h>
& o/ E" w" s# D9 {: Q6 F: e% M8 y, P
#include <asm/mach-types.h>. E+ x; l" J; f: m( w+ d& L, _
#include <asm/mach/arch.h>  g0 E6 c! U# E7 J
#include <mach/da8xx.h>
& f8 W" c" k1 D- M# E- U#include <mach/mux.h>
2 M! k8 e# f% Z, n( r! Q5 h* e$ ]5 t5 R7 E: d7 `2 ?: ~3 u
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
" E3 S) v8 ?" F( M. K#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
3 V# \# L9 s/ ]( i* u7 ^#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
# S! Z; g5 H5 E5 |& G5 \#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)/ X% a  Q3 T9 C/ {5 q% c
: }" R, x' b) _+ Y9 M) Y/ f  [) a
/* assign the tl som board LED-GPIOs*/
1 x- s: v4 n, U/ ?static const short da850_evm_tl_user_led_pins[] = {
" d4 f" \" E. X        /* These pins are definition at <mach/mux.h> file */7 K( v5 `8 Q6 ^& _) ]* k
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ ?" V! {2 a/ t3 h2 |5 J, ?
        -10 ^$ B: l; O9 q1 d2 t; m& j
};3 w4 E3 m. \( l% h) i, F
. E3 M) [" \3 c0 o/ B$ Y
static struct gpio_led da850_evm_tl_leds[] = {
& m1 V6 z. ?: S- L6 N: z3 N        {$ L, s1 e0 d  D2 r( `" V" }' z2 A6 Y
                .active_low = 0,0 E% |3 q0 J4 o7 L) W/ r
                .gpio = DA850_USER_LED0,+ V* U' g* S9 S
                .name = "user_led0",
& J9 L& z. h- N, R3 c, _5 ]0 @1 j8 c6 @                .default_trigger = "default-on",' D$ P4 Y: N$ K6 c$ l+ Y
        },
/ t) X* S1 u/ n& U; T. a" G- \        {
+ @* A- M% h- q                .active_low = 0,/ p4 `' Z3 Q4 h. X' u6 g: }
                .gpio = DA850_USER_LED1,
" b* D  x, C( t* u1 P6 _" d( p( a# D                .name = "user_led1",$ O' f+ k1 X5 r  w& F8 P! D
                .default_trigger = "default-on",- ]! [4 B5 e! a2 u# L+ U
        },0 f" |( m8 F+ H" f4 u; J: A
        {* n$ d0 b# F; x) w
                .active_low = 0,
5 b; B2 P3 _/ V# o$ g                .gpio = DA850_USER_LED2,
1 V  l% P4 {' y2 B2 S0 }* l                .name = "user_led2",
" i( Q2 g/ }4 ]% V+ F) I. w                .default_trigger = "default-on",$ T; ?  `$ A2 y6 T
        },
3 K1 j4 G/ o! ?; o        {
+ Q/ Y: X2 }- m, E- X                .active_low = 0,/ e. v. V9 Y' ]6 l5 v0 C! n5 G
                .gpio = DA850_USER_LED3,: |* Y/ J4 c, {' M1 l' V
                .name = "user_led3",
) \. G+ @: b5 v& b- j, q( T                .default_trigger = "default-on",
, ]. z, A/ ^3 V+ q) |1 w1 M        },
+ a: U/ I% O& Q7 i8 k};/ c) i6 v# h* S3 s2 g
, e3 m9 O0 o" I! k' e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ V  z8 n- H  n- @% B, }) k* I
        .leds = da850_evm_tl_leds,
. U3 k' x/ ?0 p% |4 _        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% \: d8 F* D9 w/ S" F};
. m0 p: B: ~/ Q; C
" y% e7 D) g, W9 ?9 Nstatic void led_dev_release(struct device *dev)/ Y4 {# Q. W  J& @
{- ]) ~6 v! a; j& R1 h# x
};
/ l" v' C, T, b5 o4 M! U. o$ [: F# t" A) x, k- {& k
static struct platform_device da850_evm_tl_leds_device = {
4 L5 B* k9 G% f- Y# M9 D* N        .name                = "leds-gpio",
2 G' W+ F8 Z& h) ^% j        .id                = 1,% |! A6 P! l6 }, q  H- X5 o
        .dev = {
- |% X# y6 l' h: u                .platform_data = &da850_evm_tl_leds_pdata,. q5 v5 l% h# c# M
                .release = led_dev_release,
/ W' e6 a- S; _! x* O( H4 `- `& d        }$ I& C4 K, w% I7 {9 h' G/ |
};
% U3 R2 i' ~4 ^3 M9 }
1 E! f$ O& F, Z% r" V+ Ustatic int __init led_platform_init(void)
0 _. l* {6 k. ?# g{& n- }) Q- d& q4 i' `& f( Q
        int ret;( E8 K6 g; ^1 A( L. f
#if 0
6 r" Z: R( ?2 M) f# E        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 s# X) T( q5 @3 q+ z9 c8 L) F
        if (ret): l% Q! M0 V/ {; v: I
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :") T4 \0 m0 }0 T4 l5 [
                                "%d\n", ret);. o# |: U- ]; }  ^
#endif
% O" U& C4 w6 y  I7 H5 c' P        ret = platform_device_register(&da850_evm_tl_leds_device);! [; O( e4 `+ e: G5 Y4 }" A( H% }
        if (ret). w; l. K2 K! X* a! V3 S# R
                pr_warning("Could not register som GPIO expander LEDS");5 W% T$ z4 y, q0 T6 [0 A
        else; `9 M! T) w4 ]4 X- \+ |
                printk(KERN_INFO "LED register sucessful!\n");6 F) {* u6 {- l# A7 Q  N+ y7 Y
6 u# E. l2 H+ G; \3 `
        return ret;8 c8 V# d6 _+ t1 Q3 h
}
/ {! g1 A( D- q3 `0 I! p4 U8 I/ O" t( {' V' O) W7 T
static void __exit led_platform_exit(void)
! X/ z7 ?0 w  C( E( x{
6 \  ^! R- F, S8 a        platform_device_unregister(&da850_evm_tl_leds_device);
& C- x* D# W9 ~* T+ j" T- c( ^
. J. A; z6 q3 b# t& U! k        printk(KERN_INFO "LED unregister!\n");
! `' u6 D% f! n# I}. {2 r6 f* ^6 }' Q1 P7 g

' N3 N% k  k7 ~- e: l9 Gmodule_init(led_platform_init);
4 C' O3 _" j& vmodule_exit(led_platform_exit);& u/ x$ F. Z7 ]6 [: x4 G* t/ N
4 Z! B9 I+ R4 C5 c& {" ~3 G* ]3 c' V
MODULE_DESCRIPTION("Led platform driver");$ O, ^% A3 E; o( f. a. V
MODULE_AUTHOR("Tronlong");; S4 x: R% r% q! E+ S$ p+ V' O
MODULE_LICENSE("GPL");
; K* F$ @7 B# x- U% I5 ~# A* _6 t" p# f/ M" K
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-13 09:21 , Processed in 0.036400 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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