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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。1 `) |0 L0 ^, `" X8 c6 |; o" W5 U
#include <linux/init.h>9 C( y0 e" @( g6 U
#include <linux/module.h>
- S6 y8 }' ^* H6 U! h$ y#include <linux/kernel.h>
& }1 |, z* f+ ?3 U2 W& q) ?1 v#include <linux/types.h>5 X+ G# R3 _7 U4 X6 j; X! T
#include <linux/gpio.h>9 S1 W! M5 y8 t% ^9 r
#include <linux/leds.h>
% H/ y$ Z; z% v6 e6 c- M( c#include <linux/platform_device.h>
& L: Z% Q, C- a3 l. [& o+ L; A* j7 _% D$ A$ P
#include <asm/mach-types.h>; j+ V9 k2 q; d' U
#include <asm/mach/arch.h>
  s/ g$ G" t+ g) h#include <mach/da8xx.h>: E. z, s* f# G0 A1 Z% q6 i6 Q0 D
#include <mach/mux.h>  p& W/ A' c) A" X( q' ~
' o5 [8 m$ a4 Z' [
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
# ]4 P' J$ _7 S9 d$ g5 D) O, K! H: P#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- E: n) n1 z, a4 u* z+ v9 B#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
8 w; |- M# u' A#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)5 X% @7 A' _/ p' g

% G1 p) l! {! m8 y2 R1 N/* assign the tl som board LED-GPIOs*/
6 l; }; L9 y; m% xstatic const short da850_evm_tl_user_led_pins[] = {
) i, O+ p* G; g6 F+ k) ^        /* These pins are definition at <mach/mux.h> file */
- f6 t8 S+ ?& x. b        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
  ]" R* l/ o5 U        -1* b0 \) J) H; L" ~8 ]3 I6 C
};6 H0 Z: m" u" k7 F. Y! h+ l" E, T
- b& }* e+ T0 a6 M( r  P  W6 d1 C
static struct gpio_led da850_evm_tl_leds[] = {4 U. \6 y6 a3 d' J* d
        {
9 C, @, Y3 F: v; O. c                .active_low = 0,& U6 y1 u, V) U
                .gpio = DA850_USER_LED0,1 o, H: o0 C" `$ g8 \  H6 K# ]
                .name = "user_led0",
" F2 t& x2 m+ z5 k                .default_trigger = "default-on",
& g" y4 E" z- d* [        },0 D# m/ D- A3 ~7 `
        {3 b4 I% B$ w% Y. O. H7 r: E: J4 M9 m
                .active_low = 0,
$ a" b" W9 z8 |+ M$ D4 w                .gpio = DA850_USER_LED1,! j$ `2 }- m0 z5 V9 U* h
                .name = "user_led1",
1 n; j3 O$ ^: {) ]+ D: x                .default_trigger = "default-on",! O, X8 u% Y% n
        },! P& l5 _- p; ?& w5 w! U
        {2 t! c9 x: J' x4 Z& i  g; F; f& D
                .active_low = 0,
- D: @# p! ?: Y/ E/ g' j% ?5 q                .gpio = DA850_USER_LED2,
+ y& C! I) g5 `$ U4 A/ Y                .name = "user_led2",% R3 L/ l3 d/ k$ {. L. J  t1 p0 X
                .default_trigger = "default-on",6 x5 O1 U8 h" M  e
        },
# r' R9 b/ h% c, B) Q8 A6 K        {5 x! S" \  q2 m0 U4 }
                .active_low = 0,
8 R6 H7 p! B- y1 w( O8 X                .gpio = DA850_USER_LED3,5 {6 E0 k; n' n8 k& j, n4 v. _9 q
                .name = "user_led3",
9 }- S9 I3 S- j( Q8 ~                .default_trigger = "default-on",
7 C$ O$ [. j: O' c  U        },$ q4 ]0 t! V# I, Y8 R% N% ^; l
};
6 ^3 q  |, u9 `, Q1 i6 G" z: D3 }) G7 I% v# X& B7 d! n: b
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 B9 m/ w* k% I) d4 O2 ]        .leds = da850_evm_tl_leds,! Q# O- ~1 o6 R3 f$ Q6 S9 I7 E
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& o$ W  [" ^2 n4 w" e$ I
};6 N) s9 z; Z& T1 [# R4 z  \( p# R
3 s8 Q: ]! ~, R1 C; e7 e# ~1 f
static void led_dev_release(struct device *dev)
7 \# p! |7 p+ ]* _* [{
4 j9 c  B7 T. v) p% |7 m1 @8 M. U};
  }; A0 t- l; A
1 b( Q: P2 H7 z' z8 D1 w5 Tstatic struct platform_device da850_evm_tl_leds_device = {8 J& `$ ~' i. p5 N, \/ ?
        .name                = "leds-gpio",
! }  v1 {! S5 ], x        .id                = 1,
+ l7 C5 A/ W# h        .dev = {
' T6 e$ M7 ~8 a) ~                .platform_data = &da850_evm_tl_leds_pdata,0 i! Z% `( C- I- A& m9 W
                .release = led_dev_release,7 p7 [6 i& G) T1 z  Z1 F! a
        }
. G" ]# p' H& M9 j+ f% C( Z};
5 W" k/ w9 k) [" F! T9 _, {! j8 W( ]* A
static int __init led_platform_init(void)2 R) U  k) H$ H0 h+ `, h' T
{
* O/ G* ]! N* _: y+ O& F2 _        int ret;
8 k) n+ E% S. O' D& t+ N# M. K#if 0& m! l9 y) h$ `" h
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 d4 M1 _& H9 \5 w1 n7 A% G+ j+ H
        if (ret)6 `3 F. M, W0 t; g4 C4 M* f' g
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :", K8 N! h3 e& G% W* x
                                "%d\n", ret);
; t6 u6 T" u3 g. U1 v' S1 M#endif; H' ^; |6 h: m' g4 d" ^
        ret = platform_device_register(&da850_evm_tl_leds_device);
$ h9 O+ `! l+ ]# E, B8 k" `3 M        if (ret). ~4 D' y( e1 U. k# a+ F/ C! F8 v; C
                pr_warning("Could not register som GPIO expander LEDS");* V: Z" t4 V% B, U, u: S
        else
2 Q  n& `/ t9 Z7 z' Y. Y: F- H                printk(KERN_INFO "LED register sucessful!\n");5 S  U: h9 K; K1 u

& I1 ]: ?0 r, N, f' g        return ret;( z: |7 v) x" ~; P
}
2 \) A* ^( y9 q  m* m* X# w' T5 d, H9 D
static void __exit led_platform_exit(void)7 K$ Q4 E1 Q: @
{
5 y7 `* a# a$ W  [. H% x: _" U  t        platform_device_unregister(&da850_evm_tl_leds_device);
, p- x6 E) k8 _! C5 @+ D! N/ B, z* S. f6 e) M6 \: h
        printk(KERN_INFO "LED unregister!\n");
2 z+ r# P- h8 E% W1 x}- ~7 i/ l$ N3 P# W3 x
) F8 z7 P* f( M* V( U
module_init(led_platform_init);
+ |: I* X2 x2 P+ Z$ V( S( [module_exit(led_platform_exit);
, K/ a# d' P6 W
7 Z! @" i% r. z4 x) [) F4 h* D0 M6 B4 YMODULE_DESCRIPTION("Led platform driver");; j  T& }' x1 b4 M7 a
MODULE_AUTHOR("Tronlong");# t2 C1 Z, @6 G% ]& j9 ]
MODULE_LICENSE("GPL");- g" Y  n9 q7 M  r% Q' A
. ?7 q. p8 w* @
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-5 07:21 , Processed in 0.039724 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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