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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。& d) q$ Y& j8 W8 }; V- O
#include <linux/init.h>- N+ [7 F  C0 x+ D$ C* m6 Y; ]
#include <linux/module.h>
$ I! }7 |2 y- @4 q3 m#include <linux/kernel.h>$ g! P* s2 w# K3 @
#include <linux/types.h>9 B! o& W7 S" t2 i0 t1 N0 ]
#include <linux/gpio.h>; u% `* e1 a! _3 j
#include <linux/leds.h>. {, M  b" @( ?& d" q& K9 k
#include <linux/platform_device.h>/ q7 q  A; ]6 r" }6 k
$ k7 g& V9 T' Y$ K1 q9 B
#include <asm/mach-types.h>4 p4 ?$ _/ x3 b! Y6 `+ P2 l4 F
#include <asm/mach/arch.h>- \9 T* f9 p% N. m. j
#include <mach/da8xx.h>, N+ d  S) t+ g- s
#include <mach/mux.h>
' \; j7 S, B6 c; s; y  M
5 P" A( O3 u* ^8 m/ j( h# ]#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
6 Z" k  K3 {+ H, \9 f: `9 E#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)9 u" ^8 Z5 L& _, J& n$ d
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1): ^) O$ e3 y0 t) G5 [4 C9 ]6 o
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
& p0 b) I1 \4 w. j" ^
; E5 i9 l% y$ F4 I4 U9 p/* assign the tl som board LED-GPIOs*/
" F0 N$ ]: u4 }. C$ V5 B0 Ustatic const short da850_evm_tl_user_led_pins[] = {1 }6 G1 x+ e) y8 n
        /* These pins are definition at <mach/mux.h> file */
* B& K  ]# P- N+ [6 l0 T        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,  @; J, y: c; \4 {( s
        -1
, V. c3 P) O' `};
. z5 ^5 U% U3 w& J# F' ~: |, D
static struct gpio_led da850_evm_tl_leds[] = {/ Y: a* g* U; u& {8 w
        {
' p& e: w' [9 c# A: D                .active_low = 0,
( U+ E2 w1 S: R9 ~7 R( W2 P: Q                .gpio = DA850_USER_LED0,
( n* k' G4 @" ^  k. E4 ]! h5 z                .name = "user_led0",/ w3 _+ `# W5 J. f( W
                .default_trigger = "default-on",
% Q. Y$ U2 Q8 ]% q4 t        },8 V& R. T7 g. G0 `
        {+ \2 x/ w" T0 I9 W, w6 \$ P# h
                .active_low = 0,
9 \; l5 i4 }. @                .gpio = DA850_USER_LED1,
6 X2 I+ c3 n! B* n8 ?0 z                .name = "user_led1",
' t9 d+ Y( B; q                .default_trigger = "default-on",
3 I& G3 P9 K1 q7 c: k: B        },
  R+ I8 o6 K9 Y        {3 f0 q5 `! j7 ]2 {
                .active_low = 0," i) d; N( J% O3 H
                .gpio = DA850_USER_LED2,0 `" T& y/ c7 T* m+ k" u% x
                .name = "user_led2",
5 f5 u+ u. p, q$ f: O, Y                .default_trigger = "default-on",* h  x: ?3 @3 `7 V. W$ f7 h, q
        },
" @- G, H9 D; v5 d1 q3 r! l        {
4 U8 W# [- ?+ i5 X9 Q' X' z7 V* _                .active_low = 0,8 c% W; i) J. a9 y) T
                .gpio = DA850_USER_LED3,6 ]) T* g! M* [8 c  A8 D. D
                .name = "user_led3",
* x. Q) _: b9 ]' w                .default_trigger = "default-on",1 ]4 R0 T* ^& N# e  P7 |: e( }: ~
        },9 m# n5 N4 X# t/ o* R& ?$ T" x
};
# U% }4 o: E) ?/ B& z+ \
% U! N$ f8 a) i3 Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% g( ^2 d- f/ G- M0 E. u: }
        .leds = da850_evm_tl_leds,
  ?) m# w/ N: \  P- T5 I+ ?        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" E& ^8 R6 z, S. Q3 N};( n" ?7 @7 s5 E: I, Q4 c" ^
! d) v0 b0 [: T" Q. t3 u
static void led_dev_release(struct device *dev)
6 d7 G' a8 m1 P! q! c/ r{
5 @% T5 L" C- x3 O2 C' k3 {5 ]};4 |- T( n4 F: P1 d0 d
/ j, F) k% t: U* D0 b
static struct platform_device da850_evm_tl_leds_device = {
4 {, a3 V' ~) c$ G! T' j& ^        .name                = "leds-gpio",
6 _$ n* N0 _! d' k3 B: e" \        .id                = 1,, N' Y1 v0 I9 H! N6 k. l
        .dev = {& I& ^8 p  f. R4 j$ C. V
                .platform_data = &da850_evm_tl_leds_pdata,
5 J: u6 p3 X- j4 ]0 `. b                .release = led_dev_release,
% s+ w" L. m% s1 J4 u0 i        }; [* G4 v) d# ?8 S' Q" c5 Q
};2 F$ B5 z% E+ R5 c2 \
' h6 d; a4 s1 F3 m
static int __init led_platform_init(void)# s- o0 \7 ?( q  B- Q" J8 e
{' t; J1 M' K, A# E
        int ret;+ a. |+ u* l: W  U8 n
#if 0
" i7 {9 S2 \; g: l. G        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; X  q, D1 h+ `" r& \* {  u        if (ret), b! Z$ z. n; C$ n  Z5 Y& Z
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 U* z" D1 H! o2 c1 p
                                "%d\n", ret);
4 |& j4 D8 s  k% P) T' q' ?#endif0 b0 d8 w* C& |* X6 }; O
        ret = platform_device_register(&da850_evm_tl_leds_device);
8 ]2 H7 |1 {9 f, z$ K% T        if (ret)
& E; p* w0 y1 q# g9 B                pr_warning("Could not register som GPIO expander LEDS");; Q$ a" K8 k, D1 Q- l: w# k
        else* G9 t5 n0 d6 `' o0 U
                printk(KERN_INFO "LED register sucessful!\n");
1 h$ c6 n' N% T& Q% k6 K- P# h0 h8 S7 K) |" A8 [5 L- _/ j
        return ret;
! y% z# E, O0 o" f/ [}9 b, e( f0 |& A
" i2 ~0 t8 `: }: M( g3 L2 l
static void __exit led_platform_exit(void)1 I+ ^( h. `, v: X
{6 M- Z  ]3 r# u) N4 H
        platform_device_unregister(&da850_evm_tl_leds_device);: q6 F1 M9 L. k

# [7 x+ u6 C$ l: A% u8 P        printk(KERN_INFO "LED unregister!\n");# W$ f5 |3 z' b  X; c3 S" K
}
. c3 i% f  w" p* R; j/ F9 N1 k8 I/ @) h
module_init(led_platform_init);
7 {( Q8 R2 \0 B+ V1 c+ g6 S. imodule_exit(led_platform_exit);
3 J0 C3 J/ K% ]4 t  j. z+ d  k8 P% \5 n4 C( b2 }* b
MODULE_DESCRIPTION("Led platform driver");
) u( j. `% q3 A* I4 a2 L) xMODULE_AUTHOR("Tronlong");2 @- d6 s9 S2 O+ V  j. y
MODULE_LICENSE("GPL");
* y' c1 }8 D' d- ^' Z
6 W" F* b3 a3 h  B
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-9 04:06 , Processed in 0.042226 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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