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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。; s, D/ }: t2 i. B3 i8 g
#include <linux/init.h>9 m3 m. Z# ^& ], D, u$ i
#include <linux/module.h>
7 p. l6 t% S1 L+ ~' I#include <linux/kernel.h>
3 X) z9 A9 ?% E9 x#include <linux/types.h>
0 f: `1 v& J' \( B; p7 i; Z# Y#include <linux/gpio.h>
: ~6 @3 Z$ w' l+ _& e2 v* B#include <linux/leds.h>& Q$ R: x. E" R9 {; o- f4 i
#include <linux/platform_device.h>
& E- A: u% I% L; G, F1 c
. ^# A) K+ n9 i. j1 t7 C  ?#include <asm/mach-types.h>
) F+ `2 ^1 k1 A0 [4 ]! g#include <asm/mach/arch.h>
2 L+ o, k! d5 A: d#include <mach/da8xx.h>
+ L: Y  w0 y4 O/ }  b* v$ V#include <mach/mux.h>
  j% Y) O% c4 o6 K6 o. \  V! z8 e0 D
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0); u' ]( w. O. H
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
+ Y# Y, b/ Q& Z, A0 C+ D% y/ q#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)- H6 S4 {2 G  W- l0 Y( u# c1 m
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)* K2 h) _5 h% _- Z1 @
1 r: l" c3 c/ b) c- T" c, f+ k, [
/* assign the tl som board LED-GPIOs*/
7 L6 {: H+ V" y- j" @% Ustatic const short da850_evm_tl_user_led_pins[] = {* l! B& X) W, g5 r; M( j" d& ?- j
        /* These pins are definition at <mach/mux.h> file */( V3 d) C% i" A. q: d
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 _1 k: u7 M4 E1 Q
        -1
  Y  Y& ?5 C7 Q& {0 \2 Z};
; n& w7 I# G6 f) l, A+ S; l/ S! u! h! ^" x- r7 }
static struct gpio_led da850_evm_tl_leds[] = {- x$ z4 p& k8 L0 \9 H$ e" t
        {9 \- L" ?! L+ x8 q6 o$ h/ S
                .active_low = 0,
/ J: T# R& F' j                .gpio = DA850_USER_LED0,. i8 g8 k' |' _, W5 Y! O6 u3 f# p
                .name = "user_led0",  U7 i0 x& {' m; W+ r
                .default_trigger = "default-on",0 `6 l& m$ k) i- S6 u5 M
        },
; t! D* n* p! W8 \4 b( ?) X$ E* p, Q        {
) Z; `- w9 E8 {) d9 J; T                .active_low = 0,# y1 q/ k/ [  Q* M) n9 g. m
                .gpio = DA850_USER_LED1,: ^, t8 g! O( m! T2 ]+ f5 S/ z+ B9 M
                .name = "user_led1",) F' |9 L; N. x8 E( y+ c
                .default_trigger = "default-on",
% |3 o! a4 c( W9 q& V" o        },
/ P  q) J) ^8 e) w        {9 J4 _+ \+ N) |
                .active_low = 0,9 M* T6 Y+ W+ X' \8 W- q# Q
                .gpio = DA850_USER_LED2,' V: g, w' r# V% w" m( Y$ \, {
                .name = "user_led2",
* @; S, q3 [3 A1 w% c5 T4 t: J3 w$ i5 X                .default_trigger = "default-on",
! W2 E8 l4 _+ i) B  N        },3 I+ ~6 B( Y8 G5 H$ X" M, l- B( B
        {4 O, H( [5 A* s8 m
                .active_low = 0,
* @/ X0 n* T8 _  f3 B' {2 J  ^                .gpio = DA850_USER_LED3,& i% v; R' S+ r9 Y9 I
                .name = "user_led3",3 W2 p. z- g4 p* p& S0 O
                .default_trigger = "default-on",0 a) O- t5 Z0 b
        },/ \8 M% ^- J/ e4 f% h
};
8 a- J+ {7 v" D  a# s: K; T: _( t/ `/ E: K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ g* J4 n1 C/ K3 y
        .leds = da850_evm_tl_leds,8 C! B  i. o$ S2 p% N; e
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 p6 n; o$ v5 |" t3 w
};1 b! B0 @6 B$ N8 a& ]7 l
; X6 e2 u' e5 ~- s& Q; J  \
static void led_dev_release(struct device *dev)2 P% _4 O1 i9 h- p9 G8 s
{0 W* p1 I, a" [1 s. C# c
};2 T8 d5 [' j. E9 d# n7 ^1 T

/ W5 b5 Q3 e, ?3 Y* J% Bstatic struct platform_device da850_evm_tl_leds_device = {- ^8 ?( p7 A7 S$ q; i: b+ x
        .name                = "leds-gpio",- _2 I  o8 P6 N
        .id                = 1,. `! q, r6 ^+ j4 y0 z- P: {2 w# {
        .dev = {
# v* \; K* `5 L- @" t                .platform_data = &da850_evm_tl_leds_pdata,! s" N3 v: u# a
                .release = led_dev_release,4 H: J9 d  D# u' W7 k
        }4 K/ I4 b  a  X) U1 n$ o
};
2 Z3 {7 T* X8 R+ Q7 N$ s7 G5 E
; a# d: b! `1 v- [$ q) s9 Istatic int __init led_platform_init(void)
9 B6 c% G9 ]/ ~  x: F1 Y0 _{
9 y8 _2 K3 j7 ~, [: t        int ret;
/ N( [9 U1 Y5 p; K" l# ]: ^" {* X#if 09 ]% ]* ]1 l" F" l1 y
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( f, a% H$ B* S. r, _        if (ret)1 i$ e+ c' q# l) v% }
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' ]2 ~" i. d  a: q                                "%d\n", ret);( Q/ X7 s9 H5 }9 R6 v
#endif9 a3 F# V+ j  d2 j8 X
        ret = platform_device_register(&da850_evm_tl_leds_device);
6 N6 o: J, o3 }  H+ f* ^        if (ret)
$ ]$ O1 I0 e7 e# L. F' T& E                pr_warning("Could not register som GPIO expander LEDS");" K; w, R5 ^# U3 U* V  z% K; C
        else
" F$ x' G( C6 Y                printk(KERN_INFO "LED register sucessful!\n");
) J' Z& q- b4 D: n4 B8 `0 X2 V) n- g1 P1 k8 C% h- W
        return ret;! b5 M- A& i9 M4 ?5 w# b6 j; T
}+ j8 |0 A! w7 E9 k

* X  N6 F; ~0 H6 w( Nstatic void __exit led_platform_exit(void)
# d, ^# R) s" _0 t/ s5 B4 x& r  u{; c% l  b* ~2 d8 u- k
        platform_device_unregister(&da850_evm_tl_leds_device);
: c; G! k) y, ~. E7 f% h+ t" o1 M0 M* c$ A. Y. m; H
        printk(KERN_INFO "LED unregister!\n");  `, u3 Z2 T) v' N* [) L
}$ l, T' l) X& G& w. d
% e0 J/ v, j6 j( J6 p, k$ z& B
module_init(led_platform_init);: Q, q1 ^1 t9 j2 u1 v* X
module_exit(led_platform_exit);+ B, c7 g' h' o5 G6 C

( H% I0 g3 }5 i. X6 U9 B% E1 vMODULE_DESCRIPTION("Led platform driver");5 S0 B: u9 z2 @9 G4 X4 j
MODULE_AUTHOR("Tronlong");; X7 p/ u, ?' E2 t) D
MODULE_LICENSE("GPL");
8 O0 E7 |8 D# E9 W, c" b) i6 O; T8 \  m2 R1 W2 }5 B. K$ [
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-5 22:51 , Processed in 0.040363 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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