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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
" ^9 q" C) }! p) A0 U( u, j9 j4 i' y7 g#include <linux/init.h>0 M, F% A& K+ K4 Q- i2 W  a) V
#include <linux/module.h>' i# ?3 D. E7 c9 W+ Y/ \! v
#include <linux/kernel.h>0 `1 s3 \, P7 s  W1 ]/ k! X- O
#include <linux/types.h>
. u4 g8 b! h  [) o3 K1 T/ q6 N#include <linux/gpio.h>
  N  f8 c& K5 n9 S#include <linux/leds.h>' n% D% a: e) q% O: B; s
#include <linux/platform_device.h>
7 p) X6 u5 `: A1 s. @, i, D! q% @5 \. l
#include <asm/mach-types.h>( H5 K4 V. Z1 o/ G7 {/ L
#include <asm/mach/arch.h>% o3 [* Q$ b* u5 u# u
#include <mach/da8xx.h>! k6 u/ }/ [9 }/ T) f
#include <mach/mux.h>: O" \9 C& O- Z$ H- m
  C3 u& U" K9 q7 i' G
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
% J4 ^% P! u0 `' U#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
; A; h7 h& C; U#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
' B, z0 K( q8 {/ v+ [8 B* F% K#define DA850_USER_LED3        GPIO_TO_PIN(0, 2): m! S3 |& |- Z3 d

. e/ ?  u+ T# c! n/* assign the tl som board LED-GPIOs*/: i  H! |& \# b
static const short da850_evm_tl_user_led_pins[] = {
) d% q1 f/ n- p3 w3 t7 f5 }6 A; L! M        /* These pins are definition at <mach/mux.h> file */
7 }" b6 e& e9 j$ j8 {+ w, Q1 f        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 M3 j" B3 F( D8 k1 n, p* p6 b3 U% z8 N
        -1: r1 _: j4 g# f: h# S9 e' |
};! M( C, U" V6 T) e, j
$ t8 _! ?% ~3 ?# W
static struct gpio_led da850_evm_tl_leds[] = {6 y7 }  m3 w3 ^
        {
: x' k$ A/ ~8 }3 _5 V0 U                .active_low = 0,
4 n# t2 m" H: d. c                .gpio = DA850_USER_LED0,
, ~# G1 }: J; T2 g9 d, h                .name = "user_led0",
5 m/ U! b5 Y0 Q: x( {                .default_trigger = "default-on",( X8 l6 d. O/ P4 L) q
        }," |0 K' \" ~9 H" k: F
        {, `* K5 Z8 l; K, \
                .active_low = 0,9 c. Y( C; G1 m2 e) C5 W; x
                .gpio = DA850_USER_LED1,6 u0 g3 H* r; U
                .name = "user_led1",6 Z0 {- V; }: x3 W
                .default_trigger = "default-on",
& H! n2 N. Z( l( B        },
! [; |. S) L% F! W/ `+ J" ~5 \        {9 f2 N, z# q, |) T& `" n
                .active_low = 0,
" o$ Y3 y1 c1 \, h+ [                .gpio = DA850_USER_LED2,
5 Z/ J! V. x9 P$ a" j3 @5 u, q                .name = "user_led2",
6 N+ T4 o5 F) @: ?) X0 U                .default_trigger = "default-on",
& n( v' W1 G5 P+ x$ ?( e8 l2 O. H        },* z) B- r3 t: e' {& X8 e& ~4 S
        {
  g( H) A8 r1 I( O8 P5 Q" ?* b: U) }                .active_low = 0,
4 ?9 o. y- `- O                .gpio = DA850_USER_LED3,0 Q7 B8 ~$ a) Y  c# o, m
                .name = "user_led3",
& G# d% K+ T8 S8 `2 k                .default_trigger = "default-on",
. l6 x- D) S7 j' n% E        },
, m/ u; j* v; O$ @};' X8 F$ Z7 X9 C( W! O* @1 k7 ?$ R+ ?
  M& V) z: J; u3 k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 i% o2 x$ ?' n' F) Y        .leds = da850_evm_tl_leds,% e% F4 c& _: ?$ J* b3 H
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 J# m2 ]0 [6 j5 z) h+ }
};
6 ?4 \5 [" I# _7 ^0 p" _
: g9 Y+ l7 D7 `6 P: Zstatic void led_dev_release(struct device *dev)% C8 Y  ^: P) }. y! U+ B! p$ d2 ~$ |
{
( A$ }% q! D5 h};
3 W% G$ }0 R( K: T7 T0 [( o- Q! \! ?) n
static struct platform_device da850_evm_tl_leds_device = {7 `3 ~$ r. f8 [% ]* ~2 O
        .name                = "leds-gpio"," g0 g+ ]2 c* u4 O1 B& W' P0 [
        .id                = 1,+ D) _  n1 L4 f, w, C4 \& h
        .dev = {
& w9 S" T$ c' _9 h: M                .platform_data = &da850_evm_tl_leds_pdata,
# D  M5 B" e* b3 V7 y! M                .release = led_dev_release,
5 a: g) E( b( B        }
( l* Z. @6 M/ y* d8 h};+ a* E1 J, H7 q5 `5 ^

& ?. B+ Z: R2 M. U6 Q$ xstatic int __init led_platform_init(void)9 E) }0 X8 d* d4 I# b2 B
{" S: }6 a. e, s+ }- v
        int ret;8 \' t- j$ t/ N6 R& [
#if 0- p4 P& w1 S9 W/ X% q& C7 f) d' i/ \
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 V) X3 g1 D9 a* B
        if (ret)
  ?3 Z* h3 O2 }' j! [                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ _! @- W: t0 @2 @                                "%d\n", ret);1 h& ?5 S9 y/ Y2 s, c- Q
#endif
8 A/ R7 `+ D, o: J1 A" |        ret = platform_device_register(&da850_evm_tl_leds_device);
5 `) ?9 D* c* S( X& ?' O9 W        if (ret)5 I8 g5 W- v, S# a
                pr_warning("Could not register som GPIO expander LEDS");6 `0 A9 x7 r. g, ?& g1 n7 D
        else+ l" N# p& L9 {6 N) b- D* }& R
                printk(KERN_INFO "LED register sucessful!\n");6 Y! T. Y% t3 h8 i2 ~
3 S% n% y" }. Z9 y' E
        return ret;
: n( @( L, s9 X- ?! P4 @}
5 g; q, J2 {, |# u; {, I: J" J
: X' T* [* {, c$ Fstatic void __exit led_platform_exit(void)
$ s" j2 ?+ h6 y% j% L{0 M4 a8 d) L' H
        platform_device_unregister(&da850_evm_tl_leds_device);
7 v4 e5 h! t5 h4 w/ g$ k+ ]
. [. U3 k$ j1 j3 w+ ^7 Q" I5 ~        printk(KERN_INFO "LED unregister!\n");
1 g+ z1 c' S7 K0 A: B0 \}% Q, h- z# G9 d  y8 v

, }$ J  n6 _% I# `; a2 Q. kmodule_init(led_platform_init);
( \" h' Y$ w# n) a# kmodule_exit(led_platform_exit);
5 j9 @; D: P7 d0 N: h1 n2 w& L: V1 o+ Y+ B3 z
MODULE_DESCRIPTION("Led platform driver");( N& B( N* w3 Y" }  Z
MODULE_AUTHOR("Tronlong");
) H, _  p2 b% d6 y  bMODULE_LICENSE("GPL");
4 ]5 }0 @0 ?) g0 k+ k
( G& G" i8 r) K8 t
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-22 19:35 , Processed in 0.037570 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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