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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
" K2 Z& K, x! F+ x' a#include <linux/init.h>
% B  O) G7 g- C; L+ V#include <linux/module.h>) V0 f1 J% I) X/ T! k: a
#include <linux/kernel.h>
8 Y4 z. s& Q( I& x" U#include <linux/types.h>8 j8 }6 t# ^6 F, ^
#include <linux/gpio.h>
6 U! O+ y- P6 K4 N! c#include <linux/leds.h>+ r8 v8 b. j0 @( ^: c7 u2 {8 J
#include <linux/platform_device.h>
* `+ h( m8 ]* T% Q/ Y" X; I5 n4 h# s- R& C  w, N" p
#include <asm/mach-types.h>5 Y+ i  ~/ U3 n# P! K/ h3 T
#include <asm/mach/arch.h>
- Y. O4 N6 o" A#include <mach/da8xx.h>
1 i* D6 P( a" {1 [6 E) T#include <mach/mux.h>/ G4 Q1 I$ Y( y2 ~& U" l& w

* E# f' `- @, U! x1 Q#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
3 n2 j3 C2 c( b/ x) c- P# H+ k! [#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
' g& K( ^4 ?3 g* I; b( O#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
# @5 l/ M7 ^8 s1 m5 S3 Q#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
. r: b  O. c: i3 a# j2 X/ X3 i" S2 p# m' A
/* assign the tl som board LED-GPIOs*/
) S% Q9 F  @) _4 a4 y- estatic const short da850_evm_tl_user_led_pins[] = {) Y8 T  h. X  T9 ]1 i% V
        /* These pins are definition at <mach/mux.h> file */3 y& [, a0 B3 h4 k6 F5 p
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 Y2 G2 Z, S6 r+ N3 y  m
        -1
7 l* q# q4 m. w% `, M1 \};
2 s% x. r* Z. ~- @7 ~
1 d1 s/ ]/ p; E! f: \static struct gpio_led da850_evm_tl_leds[] = {
0 o- Z3 h& N% }1 u9 S, s7 |        {5 ^! I; K0 \9 e$ _! N
                .active_low = 0,/ B* O& g0 }/ \" U) |; a0 \6 y
                .gpio = DA850_USER_LED0,
& z  M- Z; ^' |1 P                .name = "user_led0",( V* J3 V% p8 ?9 ]* B
                .default_trigger = "default-on",
% X, n/ ]  p" o, C        },) `, @+ V9 `, ^6 P# A  ?. A5 J
        {
2 X; ]+ |- }. M/ m( {/ f! r# S                .active_low = 0,; i; ?* d* F; j) G( q7 P* X2 H
                .gpio = DA850_USER_LED1,- v& l) [1 d/ T% O! N) u( a( z
                .name = "user_led1",
+ E, T3 o( w/ r+ M5 ]                .default_trigger = "default-on",
' e2 i4 M7 a( x& @! @. p+ f        },7 E0 U3 r: X( O$ I, G
        {$ L& X$ E& ?5 n% G
                .active_low = 0,. A3 l+ O- y$ a# I4 s( O
                .gpio = DA850_USER_LED2,. y  g. q4 F  r  E/ ^
                .name = "user_led2",
6 S: ~' R4 ^! f0 [# a3 {" ?                .default_trigger = "default-on",* Z: I/ y$ Y% q4 v
        },
( a+ z" ~; O1 |6 X3 `" \        {2 I/ ]9 H( v" f* b- E& s: q, K
                .active_low = 0,; t# ?7 |8 b4 I! u- \: [1 z
                .gpio = DA850_USER_LED3,
8 a  Q4 [( `- B' R+ `                .name = "user_led3",
* N6 B' z- s9 u1 x" v2 \                .default_trigger = "default-on",
- U$ w4 S6 q8 ~6 E* s- ]( h" E% K+ H        },3 G# |. `9 h; H0 P
};
, K- x7 X0 _% |. z9 T& b# k9 f9 K. S
( T  Y  N/ D7 E$ z! Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& K( |. p) B0 l; h9 `. i  P3 p        .leds = da850_evm_tl_leds,5 _* E/ n% r* k7 g3 i  Q3 g
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 b# O6 G# x" }# U# x6 ~0 A0 I
};( i1 t0 b7 o  O+ R  i7 g6 m
4 J3 Z1 p" L/ X
static void led_dev_release(struct device *dev)
! z/ }/ }5 M+ v8 A/ f; i{
( m. _7 a( k- T& N% q- n6 K};
" l( Q4 ~; A6 i, Z: R/ |8 j
) J) Y1 w5 m) Rstatic struct platform_device da850_evm_tl_leds_device = {
7 Z; E5 s( N, @. W! F        .name                = "leds-gpio",: t2 r1 A1 n1 c7 g
        .id                = 1,# s# b7 x; r" x- m
        .dev = {
$ W; y' z2 s/ b5 p, O                .platform_data = &da850_evm_tl_leds_pdata,
$ g  e0 t* Z5 S# n$ x8 M                .release = led_dev_release,
6 J: }4 c# I1 |$ A  y1 n# L6 _$ u        }" ]6 F' j' C( S
};
) w: x8 k; C3 P/ N* G, T9 O2 b3 {  a9 X6 V) D
static int __init led_platform_init(void)/ z  G& `7 c" Z1 T9 [
{3 Q! O* w  Y: @% h9 f6 n
        int ret;  ~% B3 X: f% i, \  g/ ~1 }
#if 0
, `' V" B; f& G, N        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
  L" i7 M2 `" m* d  j        if (ret)
1 Q3 s7 G+ U6 Q9 ^                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 _# V3 p) C1 W% t& Z, ?4 a: V
                                "%d\n", ret);  u# z1 o' _. K; G! N3 V0 r, T% X
#endif8 d5 e: \. v8 X) o
        ret = platform_device_register(&da850_evm_tl_leds_device);
' h8 G$ h8 [7 ?8 s5 {8 b        if (ret)5 q+ r# q6 A4 w2 _/ v+ t8 `: s
                pr_warning("Could not register som GPIO expander LEDS");8 s! R  @) A% c2 l& s
        else2 e2 c5 l5 O" H4 ~5 B/ W
                printk(KERN_INFO "LED register sucessful!\n");. W1 }. v8 a6 X$ f) ]- r; z) S
# c( n7 M* p, J( @( a' Y3 ^
        return ret;
' Y0 w' j& D- |7 S5 F( f}$ _2 O. t9 L- L' r
2 k* h4 |$ J) t$ u' `
static void __exit led_platform_exit(void)
' B1 K  J4 U4 G* }$ ]4 m" o* m{! X' s4 b* q2 K3 z# q- g
        platform_device_unregister(&da850_evm_tl_leds_device);
0 {. V- A/ u- p5 `1 N) V$ M& Q7 L# j# t2 U! Q/ ^/ q  d; c  {* X
        printk(KERN_INFO "LED unregister!\n");4 X8 P2 m$ `! W5 o
}% [( J3 ^' R9 O# m" l

+ R; J0 Q5 H% R' Zmodule_init(led_platform_init);( N& l; D; ^' g/ l1 ~: [8 l
module_exit(led_platform_exit);
% t; w% N: j$ i# A1 M
$ d6 m: N4 Q6 w; S) QMODULE_DESCRIPTION("Led platform driver");
, Q8 @8 R& }! D( c- V8 G/ b7 kMODULE_AUTHOR("Tronlong");
' [! {, j+ C6 S  Y2 O+ aMODULE_LICENSE("GPL");$ Z9 x( S  {2 Z6 y4 b

, m9 F. R, C1 _! z) y9 G. s1 B
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-2 02:04 , Processed in 0.075283 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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