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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ T0 N# d% [* d# p: W, E8 ]8 }#include <linux/init.h>
  [5 p' q, Y, f; q& }#include <linux/module.h>
3 J. S( h, ?- S  l+ \* h5 V# M#include <linux/kernel.h>6 V- t  l6 N! v( i
#include <linux/types.h># J& M8 ^; d- {9 e5 L
#include <linux/gpio.h>
6 }+ U& P- S- z) V#include <linux/leds.h>
& H+ k* ?; z$ ~2 c/ ~#include <linux/platform_device.h>" V9 S# S# R2 X" s; I

$ [& d7 e* q) H" u3 V  \#include <asm/mach-types.h>
9 q9 r6 @" K, _( j5 A# `#include <asm/mach/arch.h>
( b7 x! x( z) i6 S) X#include <mach/da8xx.h>
% ?1 ?. d- o* T5 ^5 |- z+ V6 ?#include <mach/mux.h>
. @; s" d' ?% F8 E4 u1 o; \9 ~1 s) \" ~1 {
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
3 J8 |2 S9 R& a, a0 R#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
; _/ Q8 n$ l( J6 E# T#define DA850_USER_LED2        GPIO_TO_PIN(0, 1). S1 Z: J3 T0 m7 }  M0 ]
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
$ |( s$ I0 \( w: [& C( {" c1 {- D0 o' c. c
/* assign the tl som board LED-GPIOs*/  X( i! X) t, H" k
static const short da850_evm_tl_user_led_pins[] = {
" ]" |& N; H+ B) `7 p% m5 U& j5 y        /* These pins are definition at <mach/mux.h> file */
+ Z# j- w' h1 [; K        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ K6 g8 b) e" N8 q) L        -1
. e" I7 U: i4 |! I' @$ a};
' Y. j! W  ^  C5 P1 j8 E7 Z$ P$ {) \4 D  q8 Q
static struct gpio_led da850_evm_tl_leds[] = {) d% c  u2 L. R; S
        {  h( f7 x. O+ v
                .active_low = 0,$ o* M" P1 A* P3 D/ b: S
                .gpio = DA850_USER_LED0,( g) M* q& A* b% ?" R9 U3 S% J! b; h
                .name = "user_led0",% f9 J4 G1 a9 ]$ Y. W5 o& i
                .default_trigger = "default-on",
9 a2 }% k7 ^$ @# \4 T9 Y- N9 R9 _        },
4 t! l- S0 I! |4 }4 Q        {6 T) \( v7 ?0 C/ L% K! f2 ?' U+ M
                .active_low = 0,
7 ~# V2 m  q- Q" O                .gpio = DA850_USER_LED1,
  f5 F. \) Z' D                .name = "user_led1",
' [; F5 }6 i7 A; r# Y* y% W                .default_trigger = "default-on",
/ Q. l' k. f% N1 r8 q        },  [/ j" x* @& w; v# A2 p
        {
4 |+ M  s# Q8 C& M/ {                .active_low = 0,2 `% W  v) h3 X0 h- V# @$ z
                .gpio = DA850_USER_LED2," u7 v+ B; [8 O1 r3 J
                .name = "user_led2",* x2 P5 `0 W7 b& X' X
                .default_trigger = "default-on",
# B+ `5 {/ \1 ]' n        },6 W+ C# n0 O2 c, E: B" T$ o
        {$ z1 n5 [) J/ B! s
                .active_low = 0,
' T# f8 t9 v  o1 Z5 N& d1 }8 p                .gpio = DA850_USER_LED3,
, s1 ]2 u& b# `8 B                .name = "user_led3",' O, G1 U; v7 Y9 F$ A
                .default_trigger = "default-on",
) f% s) B% ^- H  ~- p        },
+ n( ]& _5 \5 c' z" ^  T- o};! e5 g3 ?5 I# ~8 P8 p

7 f. S" W4 r. i$ m; Xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
  k5 z" ^+ I7 W9 \/ R3 l* Z7 ^        .leds = da850_evm_tl_leds,
- {' B9 U8 u+ l" T1 A        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 |* J1 o* u/ _1 v% t};" _1 M! Q1 @5 Q8 W/ H, c2 z

- {9 m7 x# w6 @, [9 I/ K+ Pstatic void led_dev_release(struct device *dev)
# k; v& \( C" g. N4 r) y9 z{- N+ N# f' ^# ~) s- ?9 \
};% E3 {# A+ ~# U  ^9 {1 P! r" d

+ e' x4 O5 ^, Vstatic struct platform_device da850_evm_tl_leds_device = {
  p4 T5 L6 N% L: H        .name                = "leds-gpio",5 a, }- w+ t+ W1 ^( S; |
        .id                = 1,
4 C$ }5 E# R+ {        .dev = {
# A5 Q* C; m& N! o3 }                .platform_data = &da850_evm_tl_leds_pdata,
) Y$ A0 ~, H! q' @6 t7 q( U6 T2 N                .release = led_dev_release,* y+ u- y- u$ \, J! K
        }! X6 r% E% F; y2 R! B1 D, X
};3 a# z% ^! x! \- m* t
& w6 I. u3 t5 C0 y( T6 Z: e
static int __init led_platform_init(void)  z+ g2 M- B4 p( z' d
{" R9 o* e) m* q( z. O) z, U0 c% K
        int ret;
3 x0 `& U/ _3 x#if 06 F8 h1 b: k0 q- E
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- m/ i; W$ w& g# g8 u1 c
        if (ret)* b* n; _9 y) M1 |
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 X: T, B! m, ]                                "%d\n", ret);3 g, e  p! M' A, Y, m! k
#endif& R6 U9 r7 S' C: z' s
        ret = platform_device_register(&da850_evm_tl_leds_device);
$ p# c. ]1 n5 Q3 h3 r        if (ret)
) c  I2 n4 w% P  K                pr_warning("Could not register som GPIO expander LEDS");
& f" n! W7 X9 o6 U# r        else  i/ R' D$ t6 o5 q  P
                printk(KERN_INFO "LED register sucessful!\n");" k# p9 ~- P$ o+ Q# w

/ N& S# H. l% i, R# {        return ret;5 L# H" l4 J  g. d
}' x9 C0 u' R6 j, E4 `$ @
) X7 u) t6 H8 E0 V9 A0 V8 {9 w
static void __exit led_platform_exit(void)" a" F) O9 x3 p& r) p5 Y
{
( Y! ~) d8 R, U# }/ l  B" A- w% f        platform_device_unregister(&da850_evm_tl_leds_device);( a7 P* E3 P) e% p+ \/ c: m

) J9 V' w, i5 a$ ~        printk(KERN_INFO "LED unregister!\n");; f8 j; w; B  J( q& l2 T' g
}
; H( B; \+ S& R5 E
2 f8 A; Q5 m4 |) z0 f2 Zmodule_init(led_platform_init);" {. B! `6 @# V4 K) Q
module_exit(led_platform_exit);
7 q0 ^, ?, ]" Z( \  e5 M2 O( O6 Z& z; p' _7 }( V) A
MODULE_DESCRIPTION("Led platform driver");3 C1 Z: L4 J1 [5 `  L8 \
MODULE_AUTHOR("Tronlong");
) R5 t1 t3 P7 k( i; a7 S2 {  }MODULE_LICENSE("GPL");
/ T: p. V+ @- o5 d; Z. x6 q2 w- m, |
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-23 17:15 , Processed in 0.036871 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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