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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。* R7 A% R8 l/ {, |
#include <linux/init.h>- q1 {( [5 `( I$ I6 H0 }
#include <linux/module.h>, i! P* ~; T- p; t" ^
#include <linux/kernel.h>
8 {2 C6 G( h4 \0 m8 I#include <linux/types.h>) B0 [6 _1 w8 p2 J
#include <linux/gpio.h>" E1 s" c1 `% H9 W0 A' }" J
#include <linux/leds.h>/ E+ R0 @' [! ]# q) d
#include <linux/platform_device.h>
/ n. F% b* f+ A- Y, u
8 ^% z0 _+ H7 ]- l#include <asm/mach-types.h>
$ U5 i. W: g1 e2 F2 h! ^% E" X#include <asm/mach/arch.h>
' R% z( \7 I$ B' m; I1 F( P#include <mach/da8xx.h>
' p3 n& J* P+ P% w, n7 A% f5 z#include <mach/mux.h>0 {7 J0 P& r! _$ U* C

$ A$ _3 S6 k+ V0 E6 \#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
% G+ E7 R* H+ i#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)4 _0 k4 @0 {. B4 e8 [
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
8 Z9 L( h; {6 j; n/ g5 i# G#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)& G' |, b1 G8 P' F! f" z

4 j" |) e# H9 J/* assign the tl som board LED-GPIOs*/8 s" Z( f; s  ]5 v* C
static const short da850_evm_tl_user_led_pins[] = {0 [$ @0 i; ^$ c% L7 m
        /* These pins are definition at <mach/mux.h> file */
$ {0 c, {$ z0 `2 B; f; t$ I7 P! K+ M        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ s: n9 u9 U( j% N6 b* i. z
        -1
6 z1 h: ~2 g& J2 L: \0 I/ m- z) A- z! q};: M( z) W) [( P% s+ K3 B7 j  c
( F& _6 A/ {& @4 z' A8 k
static struct gpio_led da850_evm_tl_leds[] = {
' n2 i/ G" m5 W7 L        {: O+ F1 S* C. V7 P5 }4 v2 `
                .active_low = 0,# K9 G" u* \) c/ A( H. K/ B& |
                .gpio = DA850_USER_LED0,
. b, c/ u+ g  A4 u: `8 J                .name = "user_led0",
  c/ u; {& @* x, U, `+ b                .default_trigger = "default-on",
1 r* w$ ^$ j7 Y9 |: H8 \6 ~% }# R1 B        },
( H2 K; i9 e/ J8 ?8 z        {
+ {6 ?6 D: p- C                .active_low = 0,, K  a4 J0 \# r/ S. K3 f. s
                .gpio = DA850_USER_LED1,# W% B$ l, B  `  _6 t
                .name = "user_led1",  _# j& `  l) `. ]
                .default_trigger = "default-on",' I. |" x; ^) d; a4 G
        },
2 f* A% z. W, O$ \3 t  p        {( g( R/ t" L* s- `0 ?' f
                .active_low = 0,% E/ ?; f& s0 E7 p6 w
                .gpio = DA850_USER_LED2,
- B  M! K9 A$ g$ M+ @. i% ?                .name = "user_led2",
# g/ s7 R) V' p8 F( U- a6 ^                .default_trigger = "default-on",- x0 A% J; A5 D! g: d
        },
# `. }# w5 J7 S1 G/ ]        {9 B  o' g% ^: r8 T' u% v8 e
                .active_low = 0,
  Q) f6 x" _0 |* g                .gpio = DA850_USER_LED3,2 [4 S! X- J& a
                .name = "user_led3",( U' q9 d2 L" S- ]2 P) j! g
                .default_trigger = "default-on",: {0 T' g; h) O3 @) m. p
        },
& H! ?4 w- D6 r* M1 z};
; `' R5 U; J! }% v" _2 F8 P% h( U' j, k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 q: U4 a: g' [6 l/ E
        .leds = da850_evm_tl_leds,$ ?4 C0 d. H+ i2 `2 }
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! u9 [( T( k" i, S- v};
+ |5 Z" a$ [2 l3 e
6 A# t5 o4 z% r8 N# sstatic void led_dev_release(struct device *dev)- P9 d. h9 E/ m% i9 t0 y. ?
{
% L$ J4 v  J) N5 E' @' v};
8 T+ v8 @3 q* B+ E: Z& W) C, F, s5 j
6 [  W! t  ]0 N6 F! c) k" s9 Jstatic struct platform_device da850_evm_tl_leds_device = {
8 O3 S0 X5 c3 c. Y( ^8 Y& R        .name                = "leds-gpio",
7 u! F  M. L& S        .id                = 1,
; [4 K% N  ]% Z+ v$ P        .dev = {. _) W4 B; O3 A& V3 E: A, y3 M1 {( J
                .platform_data = &da850_evm_tl_leds_pdata,
7 a5 k. R: M/ m: O2 M, l                .release = led_dev_release,
; u( s/ f8 J; z7 }  o9 ~5 W' X& ~        }# X: R- V0 y1 W+ s( X2 L
};" w. U/ C+ K0 I1 X- M9 c/ y! d

1 I: W* H6 I) o& O% Nstatic int __init led_platform_init(void)- ^: k! V- v" t, k
{" W/ U6 k. P1 G
        int ret;' k( y9 I2 O+ n, a( h5 \6 u& e( d
#if 0/ i! t( l4 X; b
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( h: Y. e" G% d* m4 s        if (ret)
0 K1 J% Q; a" I$ b                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% w" |+ A+ O2 e* O                                "%d\n", ret);& ~' I) x( `2 M5 h5 J
#endif
& K6 W/ k- O1 n1 H4 R# o) b9 z        ret = platform_device_register(&da850_evm_tl_leds_device);9 x  G) T, d9 y- [0 `
        if (ret)
0 c- ?* A3 K! v5 ?                pr_warning("Could not register som GPIO expander LEDS");
7 R% z6 h0 B; |% t# G2 _        else
# ~" N7 c  c5 i7 p& P9 Y                printk(KERN_INFO "LED register sucessful!\n");! N/ D8 E" x  |. U5 N9 N7 f9 l( f( j
: `, d$ D  Q9 M0 V/ E* e) v* E( L
        return ret;
1 F* p: B- B' ^* w# m" H$ Q9 b}
( w7 C; w' P" x* Z; B0 u8 r) O' ?% P' _6 Y) w
static void __exit led_platform_exit(void)
" C1 E/ @" `8 M3 F7 ?9 J{
+ Y1 d  U- y: o/ Z        platform_device_unregister(&da850_evm_tl_leds_device);
+ `/ A+ A3 R; E# q7 [
& ]2 |$ v# ]( z        printk(KERN_INFO "LED unregister!\n");6 E9 r0 l# k$ W& A+ S& k
}
( H- p+ j( @5 l
% V7 D( g7 y3 F  F1 ?( s7 L% L; }module_init(led_platform_init);9 n; d2 Z0 j* q* r' E7 W' k* I& d
module_exit(led_platform_exit);
  N% o% ]& N! }$ d# S5 x% q+ O% \# C' E% f0 J0 ]; e
MODULE_DESCRIPTION("Led platform driver");: P7 j5 k  o1 W! u: s
MODULE_AUTHOR("Tronlong");$ @+ t% }& w& z* N3 g- ?' j
MODULE_LICENSE("GPL");
5 h2 X8 s2 d( I" F1 r- t5 p; s+ @0 k3 M' o" N
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-20 04:44 , Processed in 0.042233 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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