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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。; l0 b: h7 ]; P# L2 O) j
#include <linux/init.h>
1 v) n5 d" B# g8 e- L- y) c" j#include <linux/module.h>/ y( v# O  s1 ?' I9 Y9 X5 f# T
#include <linux/kernel.h>
: i2 Q3 y0 r  F* r#include <linux/types.h>8 X  y3 a- l" L
#include <linux/gpio.h>
+ c* a3 a$ }: D' ]9 R0 d#include <linux/leds.h>9 S4 S3 X0 o; S& |+ _4 m% y
#include <linux/platform_device.h>& o4 ]: q9 k" l. x3 u. Z  M  L
/ O# w2 L0 A( J' A
#include <asm/mach-types.h>- U# A6 t  F9 |% b9 q  a
#include <asm/mach/arch.h>+ ^1 i* z- i2 q9 v$ S. h! }
#include <mach/da8xx.h>
7 H+ R& Z/ M0 |  j/ G1 {) w; L6 C#include <mach/mux.h>- P* \* `# x6 O# m" \
: f- A) o  E; |7 w! X) Z, }1 c( W; i
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
) x: F  Y, ]* O' x  K#define DA850_USER_LED1        GPIO_TO_PIN(0, 5); y" I" ~' v8 W
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)4 x. I) b% ^- v
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)0 {) g; G7 c9 L1 {! a/ ~7 v0 p

) k- W$ M2 F" I  ?/* assign the tl som board LED-GPIOs*/
! X$ \! p8 y2 C' ~- jstatic const short da850_evm_tl_user_led_pins[] = {
7 p5 z6 z4 Y5 T: M* o        /* These pins are definition at <mach/mux.h> file */: A$ f6 s- `( p( V, M0 I
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; M/ i4 s" L$ o# c0 T! F4 l        -12 `& }2 Z" `( \  q
};
/ o5 @6 M* r; \& Z8 J5 L# y9 T8 I, U3 _0 `$ j: U' x5 @& A
static struct gpio_led da850_evm_tl_leds[] = {
- |) O! V. \# {. w        {3 _; s8 A- }0 |2 |# p( b& A: V/ u" @
                .active_low = 0,: D" A7 j; X% u. T% a  {
                .gpio = DA850_USER_LED0,- f5 c, J  f* r, |
                .name = "user_led0",
1 R) ]9 a8 r/ g- p4 t# Y                .default_trigger = "default-on",
) I4 B# a: H0 I. ]4 p        },( [1 Q2 b' U* G- k
        {1 E/ N# T0 O6 O  J, j
                .active_low = 0,3 C/ ], p7 x+ d8 P& U$ R9 Z$ y! X
                .gpio = DA850_USER_LED1,
' \# {. b# J: U                .name = "user_led1",
9 @: ]3 R% Y. D$ ?                .default_trigger = "default-on",
8 o0 I4 X7 R9 m$ m! ^/ A. Q        },
8 R8 X+ U4 h" d        {8 c5 c7 D& F, S+ G' b  L
                .active_low = 0,+ d& D$ {5 h1 ]9 ]. B9 X
                .gpio = DA850_USER_LED2,
9 |4 Q* m# a: X( O9 l                .name = "user_led2",
+ c- d5 T0 Q+ Q& F                .default_trigger = "default-on",0 M5 p0 M8 O: l2 Q
        },
! x) h- A/ U1 W4 o1 {1 S5 V        {2 e* J% \, ^5 M' x( [/ f
                .active_low = 0,
* [2 J) Z) D2 P  s4 T1 I8 Z: ]# d                .gpio = DA850_USER_LED3,
) T/ O9 u% v0 E' o4 T: t7 P: e                .name = "user_led3",2 T* O! t6 U2 q" s
                .default_trigger = "default-on",
! I3 R, X6 u% f: Z; [4 T: K9 I        },- {1 i* B! l- \% P5 e6 z" b0 \7 s
};  \# O5 }6 a, @3 m  V

- Y& {% t# c" G! p: xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% I' x# I0 a! y4 t: l1 T5 R
        .leds = da850_evm_tl_leds,
& |% T8 |/ ~+ F5 Y" T1 ^. X& X: s        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* c. G& L* G' V' z' F};3 a7 F( _1 p4 G( g* u
: t0 \0 z! K+ ?/ l6 Q3 G& E$ `# B
static void led_dev_release(struct device *dev)! T1 Y# n& d! _; h2 O/ R  A8 l
{
$ G5 Y+ R8 J* Z* g1 h" b; ~3 o, g};
0 [* f" ?: e$ E1 F1 s7 m& G
  J; g, d- I; F0 C4 f  gstatic struct platform_device da850_evm_tl_leds_device = {7 d1 h4 x  k! ]9 {
        .name                = "leds-gpio",7 n. x7 a! L6 t3 _1 `  X/ B* ^( z
        .id                = 1,; j" f+ J1 x2 J8 D/ _2 ?: h$ z
        .dev = {
7 s7 s8 n6 u+ w9 A                .platform_data = &da850_evm_tl_leds_pdata,
' _+ d8 [# w/ `  x4 E9 H5 S                .release = led_dev_release,; ~4 P- s  z/ f" a  j& t. u& U9 E
        }
# j& G3 `4 f/ d5 n};
; U5 g  M3 h, I3 _6 \7 s) l. O3 A  {) v: z4 v* M
static int __init led_platform_init(void)$ r# c/ `& c) v. |9 ~6 ^7 V, D
{
. y& V- h; [; l8 j) }. r6 A+ L: ?" g        int ret;
( J+ u. k  @* N2 l5 r#if 0, s8 Z' |5 [, g9 N* M8 ?9 C! d$ I7 R
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% {9 j. C( Z6 ?* `: f% O& @        if (ret)1 r1 C0 j5 X6 q( G- ^: h8 }5 I$ D
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' _; A2 u: e9 \9 M, G6 n
                                "%d\n", ret);8 |/ d! H5 l8 L, R  h) _" C4 N
#endif% T1 t' ^; ^$ P7 l. I
        ret = platform_device_register(&da850_evm_tl_leds_device);
) q! P. v, E! `# V( ~/ \- G. R% G0 B, }        if (ret)- `0 D" I% c& _, j  B7 U
                pr_warning("Could not register som GPIO expander LEDS");6 ~3 _8 m( v7 z/ o* T' X
        else
+ E2 p6 c7 `# {1 Q6 ?                printk(KERN_INFO "LED register sucessful!\n");
9 ?( |8 K4 u6 b. O) i  N/ D# m! _
' g  c1 r& c% _1 Z' J4 |6 f        return ret;
1 L$ H1 b3 [' R9 A& l' y}
+ N2 t6 v. T& A: d& ]- c4 o7 z
) l6 A' ^$ ?4 |" {" Jstatic void __exit led_platform_exit(void)  M( [8 A. W8 m2 B
{# H; ~  B* g" ?1 `
        platform_device_unregister(&da850_evm_tl_leds_device);
) z1 X& `# E( W- r- e, @
% E- ^5 G; `$ Z5 o, L4 ~        printk(KERN_INFO "LED unregister!\n");
. Y9 b- e6 {) L) @5 p2 G}6 f7 {  h0 @. W, F( m
  [6 B: [+ w  m) d* @! u; ^: g
module_init(led_platform_init);, n* ]- y/ W3 {. {1 o
module_exit(led_platform_exit);
* r7 U& A7 E+ B
* E, x- r' r9 IMODULE_DESCRIPTION("Led platform driver");
# F8 r& Q) R5 AMODULE_AUTHOR("Tronlong");
" b/ t5 Z% x1 J6 vMODULE_LICENSE("GPL");
8 o% I4 Z/ K+ T. g, a
+ h4 h' o* j9 \- H
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-2 01:19 , Processed in 0.039004 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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