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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。: y. q/ _) j7 m1 S8 S( I- o
#include <linux/init.h>
( R9 d3 L3 S, [3 S- }) D+ R, L, X#include <linux/module.h>
( A1 ?3 b  {" X4 k9 O9 u/ u#include <linux/kernel.h>
' F. ]: ?* V) I" I& H# s$ F' z#include <linux/types.h>: J" [8 f. ~! j( x
#include <linux/gpio.h>2 G! A% N) U+ x2 O
#include <linux/leds.h>- n0 E1 b9 I5 O9 y& ^, F) `
#include <linux/platform_device.h>* G5 s+ `' B( O) t

; B$ j$ V* d( J4 s4 f4 [#include <asm/mach-types.h>8 R# q' n$ {( u8 Q( Y
#include <asm/mach/arch.h>5 H* g# P7 n, y0 @
#include <mach/da8xx.h>
' [* M8 c! X/ O' ~$ c3 x#include <mach/mux.h>
8 l4 s% B7 |4 ?! r
" v/ |. U2 ]# m6 ?#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
: @; B, e; b" P; W! E% Q2 J#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)7 R5 S1 H+ s- U- T
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)8 S: k4 z5 i. v6 d1 |
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
1 K' }3 c' x; y% E2 w2 Z) J, L" E4 S' Y5 q9 e, x% D
/* assign the tl som board LED-GPIOs*/: ~, }( a6 l* y+ g" h
static const short da850_evm_tl_user_led_pins[] = {
$ J% t! w" f% u; Y* I( p4 n& N' j) c        /* These pins are definition at <mach/mux.h> file */% c  b" n: q' p5 ]
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. q/ l2 H2 Q; [& p1 ^
        -12 h0 q) p- \/ d/ C$ k& z
};( n1 R6 S+ v0 P7 I( U

: V- }' f" e& o5 J& o- W3 E: Kstatic struct gpio_led da850_evm_tl_leds[] = {7 A% B$ a. f6 l: V4 \! S* v* Y
        {
" t! Q  O( T* f3 n! u                .active_low = 0,
$ k6 L4 ^2 Q  F                .gpio = DA850_USER_LED0,0 U0 E- p7 S9 y5 [( f9 f
                .name = "user_led0",
) m7 Y7 O: N( Z) k4 N                .default_trigger = "default-on",. ~4 e) w3 @/ E1 K9 x
        },: P2 P5 x: k& G  c$ {9 }% l% f1 z
        {
7 [4 Z5 P3 Q& Z$ t9 g5 q                .active_low = 0,1 G8 \" B6 u8 I' o  H- Y
                .gpio = DA850_USER_LED1,, I  T2 |( B" m6 J
                .name = "user_led1",
; a/ r: Z( h9 `8 J/ E5 Y                .default_trigger = "default-on",# s6 S! m  d1 D* \! S- u2 \
        },
0 ~3 I: l4 f4 g* c        {
+ o% `( [7 Z0 l. T2 F* v6 Y                .active_low = 0,
' Z; x  Q* q  S! c& C3 Q) Y                .gpio = DA850_USER_LED2,
/ f# |4 {1 b" O$ J  f                .name = "user_led2",
6 v6 k9 r5 p% G6 h3 a                .default_trigger = "default-on",1 o8 K* Q8 t, _$ C$ }1 B4 B
        },
2 ^* C7 Z7 V+ R/ M0 K) O; E, C# m        {
& T6 k9 D3 v0 M6 E; I! T9 R                .active_low = 0,
8 V' i& |+ d! W- H                .gpio = DA850_USER_LED3,9 ?- i# t1 W' R. C
                .name = "user_led3",
5 ], J$ \9 Q3 c8 I3 g4 L# f8 X1 s                .default_trigger = "default-on",
. V' R- Y  I! C' Y        },
) Z: s4 F0 d& M+ p/ V; q' Z8 J};
7 @4 m. y! {0 Y3 S& I7 [* Y; G$ {/ U/ C% o; V5 v' G1 t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( U# |( M  k3 l
        .leds = da850_evm_tl_leds,' j2 h, @2 o- `/ n2 J
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ f7 Q, D" E8 u- |
};
0 d# @* J6 P: f, L
8 Q2 v& |, X  Ustatic void led_dev_release(struct device *dev)
3 A5 a# x# M6 y/ J# J$ k1 c) R9 B{
: ?7 v% h6 n/ f9 A};- o! q% v' r' R6 @; `

0 ]4 `( t/ F: Y( fstatic struct platform_device da850_evm_tl_leds_device = {
( g) V% f: S& h: P% z& k2 ~        .name                = "leds-gpio",
1 B& k  T4 n3 m7 W4 ]" }( N        .id                = 1,
1 s" x) \0 J7 l6 l; u: A        .dev = {  p% H( N/ p- R' U
                .platform_data = &da850_evm_tl_leds_pdata,
& w! B( E0 s2 R2 ^5 ~9 M1 e                .release = led_dev_release,
7 f+ a+ G. d8 T" |7 N        }
2 m0 x% g/ O- H  @3 a: H- G};$ a/ C0 `) }* }. L: V/ B* T
$ d6 {1 \- ~# e8 N
static int __init led_platform_init(void)1 i5 f/ ?1 p- S2 q; S4 m9 K
{
; j% z3 ^* Q/ \/ g8 [' T) b        int ret;
0 a# C" g  \' E# S  L) E! N  f#if 0
) @6 `; J/ Y4 }, S: W        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) R2 E7 c, W/ d2 n9 D        if (ret)! I1 @& J; x- P1 q
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :": A0 R/ W' Y0 D+ ]3 X. m$ M9 c  ?0 Y
                                "%d\n", ret);0 ?! \, H' I( \' X9 m# `
#endif% S4 ]. q! l8 r. L4 [, J
        ret = platform_device_register(&da850_evm_tl_leds_device);( `4 l8 W$ ]3 I& g
        if (ret)
' r4 Y) s. \" T" w0 Z4 L+ V                pr_warning("Could not register som GPIO expander LEDS");
1 B2 P% x, }7 ]  P) X; r' R" C9 W8 w        else
0 o* d! x, c8 v# X                printk(KERN_INFO "LED register sucessful!\n");
( L& L( j, F2 J% K
7 C& s- P/ k8 ?  ?        return ret;
; m3 P8 n  ^/ @}8 L' u  ~/ n  o
: {5 y$ F  [: Q0 W; C; ^3 h
static void __exit led_platform_exit(void)) o- w! |& L5 c! K
{
6 J* y" e+ ]- E! D        platform_device_unregister(&da850_evm_tl_leds_device);  M, p% d& w! A  ~/ a
: F9 `, N: D' n. G& p
        printk(KERN_INFO "LED unregister!\n");6 W+ }# N5 l. F8 k
}5 V% z) R; O# F5 \

' ]* C" f9 k2 i5 J. E+ Umodule_init(led_platform_init);
7 ^' K0 Q; Y2 i8 Pmodule_exit(led_platform_exit);
4 Y) ]4 u# a2 o0 O/ ^9 M: f9 F5 G5 `) q) E! W! g
MODULE_DESCRIPTION("Led platform driver");
2 Z/ O* W: T6 d2 C# O8 L4 L7 F* x* S8 MMODULE_AUTHOR("Tronlong");) K6 k/ q( |5 I: Z- P; f0 Y9 L
MODULE_LICENSE("GPL");% c. [! f. t/ @# m
  N5 k  c1 I) d) p1 t; c
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-1 07:19 , Processed in 0.039585 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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