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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
6 T3 j0 _; m  i8 d6 h$ W#include <linux/init.h>
5 p: h* P5 H  N# H, n! p: }#include <linux/module.h>+ K3 Q& M! \% j1 M
#include <linux/kernel.h>
/ B0 `' W$ n4 y#include <linux/types.h>6 f* n- ~$ ], `' `6 i/ u+ }
#include <linux/gpio.h>
1 ?! D9 ]" t9 k- H/ c" B#include <linux/leds.h>: r5 J- n7 r; @: [  \, O
#include <linux/platform_device.h>
7 c" |2 d' {% @
. G1 b+ j2 b, m  [#include <asm/mach-types.h>  B* w# i# Z! f
#include <asm/mach/arch.h>& g+ t! z2 D2 P+ k( }. p  m% \( Q
#include <mach/da8xx.h>9 s4 i1 \+ B4 h, B3 y
#include <mach/mux.h>
6 H- j# _% |3 N/ r5 [2 ^4 U0 s4 F# c
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
' W8 V; Q/ c( [' A: c; r+ i#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
! k% k* z6 w! G#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
( [' N7 b2 ^6 _% A* M2 w#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)$ v' X' ~8 j" O3 ~# z! N4 a

0 E4 {! Y1 t# Y9 J9 H* b/* assign the tl som board LED-GPIOs*// m; _  B  O) P3 E2 E7 N0 V0 W
static const short da850_evm_tl_user_led_pins[] = {  e; \" H. m* R& g
        /* These pins are definition at <mach/mux.h> file */$ I" t( ^- ?) `4 D; B7 N
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ l4 \/ R. G5 s: U# V$ l        -1. `. Q& A+ \& s
};
0 E1 X8 K+ _0 H: e- k
' Z6 C& E4 Z2 }2 q; i5 T% Pstatic struct gpio_led da850_evm_tl_leds[] = {/ a4 I% u* j" G, o6 z4 a) r
        {
( E4 }' p( y: K$ }* C1 @- E: w* p7 |                .active_low = 0,
2 e5 Q7 o, K: @$ o5 E, v$ w                .gpio = DA850_USER_LED0,
7 h$ S4 B5 `  R' n  D$ G                .name = "user_led0",& Z3 V& S$ ^, ?! ]4 y
                .default_trigger = "default-on",
1 Q2 F$ k  r: r1 {, R8 _        }," R! `8 L+ M& J# ^) G
        {+ V4 X- a$ R0 R/ Q- w; N
                .active_low = 0,
" v( c' C& |. y3 k                .gpio = DA850_USER_LED1,
2 V7 N. z2 f1 X) U3 [9 F; p$ a- u/ w                .name = "user_led1",' v  o, _- T3 |  [# P! T# _
                .default_trigger = "default-on",0 G: _) g9 q+ N5 z% O
        },
1 Y5 X. W4 C6 G0 H0 A0 b3 T* c        {, V& {& E4 x* W# w
                .active_low = 0,, ^( O9 ^& f* ]4 _, D+ i
                .gpio = DA850_USER_LED2,
" C3 A' s5 V, F; q; \; Y2 x3 P3 l/ b                .name = "user_led2",
* J% x% i1 y' o; J                .default_trigger = "default-on",
6 X3 b1 ^6 b9 B7 R- j        },7 s$ _; b7 g) g& s  [- t4 v
        {! Q; S4 p! x( `6 b; s8 a
                .active_low = 0,* d! j0 N) c8 @- O) b
                .gpio = DA850_USER_LED3,: v7 b& i* D5 v$ [; q
                .name = "user_led3",( N) U  c1 i% \: e
                .default_trigger = "default-on",
" F, e0 S* k/ _* ~9 i3 x        },
- i" L: a2 g4 {; v};
6 V& h& R2 d2 \, ~9 |! l8 L
6 i: O8 f" h; d& @- I( }1 ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 Y! }2 J3 l8 U* `  K- P        .leds = da850_evm_tl_leds,' v1 \+ ?9 u7 o" z0 U/ m
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 N+ N5 b: K+ d6 n; d};  p' Z1 U# c3 `& {; K

8 m. u0 S" Q2 E: M3 ?: ]static void led_dev_release(struct device *dev)
3 Z, q" c& ?2 n: L) r{
) c% Z9 Q+ _) u0 h5 z};3 b) g- d; g: |& D" q1 V
0 z- f4 l2 C, m; Z+ R
static struct platform_device da850_evm_tl_leds_device = {# h, [/ s" c  o
        .name                = "leds-gpio",) q3 A) T6 E8 {$ L* g8 ^1 m0 S
        .id                = 1,9 P6 \+ ?% k, `
        .dev = {+ y. z% l8 j4 c
                .platform_data = &da850_evm_tl_leds_pdata,# t7 _% C- }! i7 F, ?8 Y) h
                .release = led_dev_release,
; Y3 D& p$ m' @% `2 D        }5 K$ o4 S/ i3 b6 A8 ?" C
};( Z2 H& `6 _  M. u! s

* y1 N0 T7 I* t# D3 S- C+ ~6 Sstatic int __init led_platform_init(void)
4 p+ S" C+ G) {{( X3 X+ ?" N/ r/ |2 _& f
        int ret;) c: Y& }- ~0 W# f' m8 N. l
#if 0! e/ y2 R0 P7 I0 y- z& x* A0 p# T
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 N: @, n* v5 [. u: T        if (ret)
% `4 ^7 Y5 _" W2 L                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 Y1 X( S8 t. q) \2 K
                                "%d\n", ret);
0 D" R; e' B8 p& |. I#endif+ @/ w, e6 [. ~! |. W% p! Q/ F
        ret = platform_device_register(&da850_evm_tl_leds_device);
& I/ P- y" Z9 E: I2 H        if (ret)* e( b. H9 L- f% ~8 W1 r4 O
                pr_warning("Could not register som GPIO expander LEDS");+ p8 v- U4 W: S, U
        else  _  a. f4 L: S5 T
                printk(KERN_INFO "LED register sucessful!\n");
  v" F- G7 w: }; i$ J/ W: d4 F
0 Z3 B1 ~+ t& s# J' m- F        return ret;
5 K( [+ k# G$ D! m) N) z}
9 d% A0 X0 L3 c- }, r# I' i8 Y' D3 E) k, C* [
static void __exit led_platform_exit(void)7 h- u$ O5 ]# `# K" W" ~
{
/ f% Z+ N! H" B7 K8 b        platform_device_unregister(&da850_evm_tl_leds_device);  z' F: _8 r' a) f' n, L/ x) E
! j! ~# p' H+ X) U3 {6 `3 w
        printk(KERN_INFO "LED unregister!\n");9 v: s4 R  |+ J4 I* a: x* K
}
" [! I8 f$ x5 e  r
. R/ {9 J8 ~. _  amodule_init(led_platform_init);
, [/ G) l* E9 kmodule_exit(led_platform_exit);
. S5 _5 i0 J' J6 E
4 P9 d( Q" u+ ~4 Y9 WMODULE_DESCRIPTION("Led platform driver");* Z- A& W6 X; R. ~4 U5 ^/ S
MODULE_AUTHOR("Tronlong");' j8 ]' h0 R6 h% E/ q
MODULE_LICENSE("GPL");
/ L+ `3 v& M* j0 y7 R" F+ u* y1 w/ s: O9 s/ T# ?4 V  i" W
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-3 18:06 , Processed in 0.036383 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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