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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。( o/ G/ v6 x1 K' S
#include <linux/init.h>
2 L1 z) F/ U2 ^- f# L#include <linux/module.h>
1 \* O' M- X7 b! a1 U5 Z$ V9 L* m1 ^+ S#include <linux/kernel.h>
1 j7 G4 P! T3 K5 H2 D% Y* @#include <linux/types.h>
, U" t. p, g/ h4 E4 w3 u- _' k#include <linux/gpio.h>0 E) L: v, \: w2 N
#include <linux/leds.h>
0 V4 N0 p- K, P* z! q( _#include <linux/platform_device.h># @1 K2 P5 n7 k+ g  M/ y/ V
, |1 w5 v( @& A! K! Q- ~9 w7 I8 q
#include <asm/mach-types.h>  c& S8 f( i# g
#include <asm/mach/arch.h>
2 p0 H- d( h( J* F#include <mach/da8xx.h>
6 \0 D3 q1 \  j#include <mach/mux.h>
2 S6 K. c  w/ z& S8 P& O+ m" a- B- K4 G. m1 a# R
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
2 B. P# A/ m2 {, ]#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
' l( }8 }0 m; a7 |6 y7 D#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
  T# k8 @# a; X* }/ e1 N- Q  [#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)# c( a  m& k" u. `; e

9 Z4 v) q  r% B  ]8 o, V/* assign the tl som board LED-GPIOs*/
& C" Z: h. d& C# C- Mstatic const short da850_evm_tl_user_led_pins[] = {& V6 z& @9 q. L, W" r: q
        /* These pins are definition at <mach/mux.h> file */% w4 M+ Z* z& j) t* s
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 z$ ~* V" ^' N4 x3 K) Z( W+ h
        -1
, R0 b8 a/ a0 [4 ?; T& E};5 E  e% y6 Y( V% g

. M0 }% Z9 _! Y* u" x; Xstatic struct gpio_led da850_evm_tl_leds[] = {
5 z5 K; ^  m1 s+ r1 `* f9 m        {" M/ F0 R2 q3 X% I6 C
                .active_low = 0,
2 ]' a4 A/ N8 w3 N; o0 |& n                .gpio = DA850_USER_LED0,) D% W4 A# i2 R. y0 P
                .name = "user_led0",
7 j+ Y/ y8 n3 O% ~( e9 L3 i                .default_trigger = "default-on",
+ |- S( N0 S0 G/ n        },4 ?7 J) Q2 N, Z7 P( I
        {4 n, i& N! R7 @
                .active_low = 0,3 w$ G& q; B' S6 h; f2 h
                .gpio = DA850_USER_LED1,
* C1 A: g6 f" U) Y( ], t                .name = "user_led1",
8 `' u2 R* f1 d6 V% }% p                .default_trigger = "default-on",
9 a3 _6 ?# K& G8 v) S: T1 V, j        },
8 L+ P& ~2 Q" F& w( v1 y: R        {& j8 p  X2 q* [3 i' `' d! e
                .active_low = 0,
2 a* H7 {6 {0 R! e* r1 c                .gpio = DA850_USER_LED2,
, ^1 w% x; F. o' a' `3 i7 N3 h                .name = "user_led2",9 V5 y: h1 d$ q5 r* ~$ f! n0 E1 C9 S
                .default_trigger = "default-on",
; K8 q7 g4 N" {5 C, ^3 S, m        },
* ^( v& S/ N: k- L        {: c2 {4 g; T- z. T! n* W% L. d
                .active_low = 0,
+ u2 w2 Q% H2 J7 k/ F- K                .gpio = DA850_USER_LED3,
$ F% E) ]0 p: D- V: g6 Z                .name = "user_led3",
3 l# E3 B7 X; P& D9 {3 x, {6 V% [                .default_trigger = "default-on",
- D4 \9 W* Q0 C2 p        },
7 E% {) s6 @; V0 h' y. J( T7 [};% Q7 A6 X% Z, }
8 O$ G) f4 I6 J8 f7 k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" ^  v* _* `1 o2 _  B8 y2 N' Q- R        .leds = da850_evm_tl_leds,6 Z, L6 w5 O# F2 e  S% L
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# B8 b2 z1 D& `& Y7 j" y
};
" q) F  ^* G  x+ g( \* J- n- }. O
$ {1 q" J+ ^- Dstatic void led_dev_release(struct device *dev)
; t! D2 c& m9 J0 Y. J) n- b* W' x{1 M; j$ e3 Z* |. U9 @2 V2 W/ _
};6 J) f2 L5 `5 O0 c

- k, H" ?; A% _6 j9 G, B3 R4 Astatic struct platform_device da850_evm_tl_leds_device = {
5 F5 e) C/ W3 t( R        .name                = "leds-gpio",
5 I8 L' e1 r- D# v, E; L        .id                = 1,
6 W$ t; {' T% K% A$ r" B4 ?        .dev = {
1 y$ k8 n4 I2 T% `5 u" Q$ ~* N: i                .platform_data = &da850_evm_tl_leds_pdata,8 ]2 ?0 R8 u: r8 X5 k# }$ x3 d3 o; I
                .release = led_dev_release,9 w9 p, X8 F3 O& N3 Y9 G0 E/ V  z
        }& }' A$ r8 K. ?& v% ~& Q; p
};
1 n7 m$ L$ L4 p. D8 h; ^, x) O2 k- w8 Z7 C  w2 q
static int __init led_platform_init(void)( X* Z  D' L2 N! D; }, T1 }  ?
{
$ a! A6 Y' }% z; n9 d        int ret;+ E3 [7 D3 Z' r5 ]' ^- l
#if 0# t7 t3 ~, d, Z% D, L
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* F  j, x$ y# F        if (ret)# z: o/ j! Z, u. `! B$ r" ]; W
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 P. k& F9 E) b4 ~; L6 _+ d& T
                                "%d\n", ret);
4 F3 M4 k6 c. p' F& `#endif) f0 ?8 J1 d8 J5 s% |/ V
        ret = platform_device_register(&da850_evm_tl_leds_device);
5 h  @# m/ ?8 \        if (ret)
# }! d' a8 u/ `5 ]- R. {% `1 Q& h                pr_warning("Could not register som GPIO expander LEDS");' C- X; h0 {3 ~! }4 Z
        else- n: y# V1 }  }+ R6 a( `
                printk(KERN_INFO "LED register sucessful!\n");, m" P4 k& a7 H2 z

; l" Z, `7 D' J        return ret;9 y/ G" C; ~/ Z1 s: X
}
: b( o/ P0 X; [; V2 M: X; U3 s  f" t: c! \: ]- {( \4 z6 S
static void __exit led_platform_exit(void)1 F+ ~0 j0 B: V& x1 J6 ^( b, I) U" j
{' C5 Y4 I; G7 W4 J6 k+ o$ w
        platform_device_unregister(&da850_evm_tl_leds_device);2 B# V: m4 a* {2 _6 Z2 i( t- G
8 l( n. ?+ y. b
        printk(KERN_INFO "LED unregister!\n");
0 A6 N% L  Q1 A# l6 ^}
9 S8 s* P  w( {+ I. F1 t
& [) r; m+ }# K: Y0 j! `module_init(led_platform_init);0 K! e" l* @' J7 `/ M
module_exit(led_platform_exit);
4 g8 I& T& O5 j, Y! Z
1 g& m5 u3 O# K9 @" h7 g. AMODULE_DESCRIPTION("Led platform driver");
, w1 y4 h/ U3 }, I# J; X! ]# VMODULE_AUTHOR("Tronlong");
2 g1 g5 |# K( e+ o2 N+ WMODULE_LICENSE("GPL");
, c0 @+ x7 p/ w- s5 m. u/ M! @9 m7 N; q& v3 r
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-13 09:33 , Processed in 0.037844 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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