程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站
点击跳转“创龙科技服务通”

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。. e0 }4 t6 ^1 y0 w
#include <linux/init.h>! D: O( u1 D+ P  @' [
#include <linux/module.h>
4 a: M" j* K0 [. ]* ]3 T#include <linux/kernel.h>
0 m+ N/ h9 N/ ^7 d: Z& J6 u#include <linux/types.h>- g% A/ u3 v5 P
#include <linux/gpio.h>; V0 J( M9 F8 s4 D/ e. e
#include <linux/leds.h>
5 W8 _+ M2 y+ d+ K9 W#include <linux/platform_device.h>
) L# F" O+ c6 W" N8 l7 E7 b! _: a! ~! n$ `  B" I* G( V
#include <asm/mach-types.h>
/ F0 @; i; l# m1 \* N9 u) k#include <asm/mach/arch.h>+ P  u) u, v$ z3 ?' f) C
#include <mach/da8xx.h>0 v$ [+ u" u( w: E& U# q
#include <mach/mux.h># p+ y" Y0 l6 V" [
7 [# _: L6 C; n7 T' j
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
/ R* l$ G2 c$ p# ?#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)% u: z" t1 X6 u* w9 y1 C5 A
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
- b$ @" p$ f' ]4 x8 M. r: M( ?#define DA850_USER_LED3        GPIO_TO_PIN(0, 2). B. X) P9 S5 @" r7 q9 ?

2 m, o9 `- o$ |: K. w0 j: _/* assign the tl som board LED-GPIOs*/& f) d( J. ]2 j( E
static const short da850_evm_tl_user_led_pins[] = {1 m, G) z+ I7 k
        /* These pins are definition at <mach/mux.h> file */
% }' i8 q# P. k3 j( I( v/ l1 T$ k        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. ]) S& }+ Y; \$ K4 u, W        -1
5 `, S8 R( s9 Y* e9 k" y3 [};, K" h& _  K! g$ r) ~
# e6 h' {5 q; Q" S, u* r
static struct gpio_led da850_evm_tl_leds[] = {: T: W: S$ [% M6 t+ u
        {% X" w+ d# u6 D% s4 ^, a0 i- z
                .active_low = 0,! i( \, @/ y4 t) ^( e- `
                .gpio = DA850_USER_LED0,
. M0 ^$ `/ j; j! z" m' k- w                .name = "user_led0",  ~9 W! n9 P/ a5 e6 e
                .default_trigger = "default-on",
) E5 J5 o2 f4 C  }) U9 x7 `        },* I/ {: s/ T; `4 L: Y
        {
  f! I- {/ U) g                .active_low = 0,& C2 {1 I% R7 U  J# Z' _
                .gpio = DA850_USER_LED1,+ Q! \1 f: N7 S0 ?: M9 g% j
                .name = "user_led1",( M( C. F- _: L; x
                .default_trigger = "default-on",8 m+ y8 [7 e) E9 S0 I' f. w
        },
5 v8 e* r& i1 G$ l3 a        {
, }& b' G% ?6 T: M# X; O                .active_low = 0,
- x+ D! ^+ a( D# `* q6 D( t, I                .gpio = DA850_USER_LED2,4 J+ r! R  f, K! @' Y5 y
                .name = "user_led2",
1 ^& c$ K3 Q! t                .default_trigger = "default-on",6 o) j& G2 X! H& X0 o6 w0 t3 U
        },
, q; c+ a$ p% u/ k! r( P        {4 J4 a5 V: Q% S5 e
                .active_low = 0,
2 s$ m( Q8 d: b- U  F                .gpio = DA850_USER_LED3,1 a5 D7 y" Q9 n* O& ^
                .name = "user_led3",3 S1 e0 {. o7 m
                .default_trigger = "default-on",
" Z' w1 n4 ^4 i( z! |4 v        },( x; w) k1 x- {& c# @" }
};6 M1 \5 X1 j4 v( v+ _. o
) b1 V6 [; I7 p# v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. Q0 V  h- p3 {; u- A- m        .leds = da850_evm_tl_leds,. ^: v; i( f. x- ?! W, C
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: \6 ~4 @* |' z3 @. f" B2 ?  S};
2 k: y) R  m. J9 U" O6 J4 {6 W4 }: g( z' y
static void led_dev_release(struct device *dev)
( t: L5 b# s/ `; J3 t* R, P, ^{
, ^) Q$ A2 i" h& D/ S" S};
. b; K$ s) Z' W7 j" [) h( I' I! p+ T/ E- a! b. H
static struct platform_device da850_evm_tl_leds_device = {
' Z  ?  H3 |2 O3 d" e4 C' h        .name                = "leds-gpio",6 i; ~& t; x( m0 L5 ?( Y; B* V
        .id                = 1,' T: H$ W) E$ u
        .dev = {3 y! d% P1 f# n3 p; D1 G
                .platform_data = &da850_evm_tl_leds_pdata,
! I/ y* i6 j$ n5 i" C* |5 |                .release = led_dev_release,
# p2 G# f" u; ~% h8 I) H. X        }9 s% {0 e* Z/ `0 N# _
};
5 @8 s/ L% [0 k1 _5 i1 E' I
( `: D* E) P5 O8 @$ X& estatic int __init led_platform_init(void)/ ~) _" B+ J( w/ y' W
{
% T  ?( `# `- j$ f7 s/ Q        int ret;: E* f: A, ~9 ~- C
#if 0
; d+ m- X8 Y0 p( b! e        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 K3 k) ]( i9 w) l- ]( p        if (ret)
! `2 u! o5 U0 T" n                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 q! x3 x: N& k0 \  I
                                "%d\n", ret);9 o- U3 h& V# e9 N
#endif$ [+ b( T8 M/ V
        ret = platform_device_register(&da850_evm_tl_leds_device);; g$ n* w. T6 z
        if (ret)- i5 M( G' F  t
                pr_warning("Could not register som GPIO expander LEDS");
) b7 x1 w+ ^) ]. `$ R9 p" W        else$ B& A2 C( c' o' J# Q; b. _1 B
                printk(KERN_INFO "LED register sucessful!\n");
* p% q+ c0 B0 v. ?. W6 h4 V
' I# _# c- z2 _. U& ]        return ret;
9 c( i# [/ `0 p- Q/ b! ?}
, ^+ }" m% I% u/ y6 \" e3 b) u4 |7 n0 X3 J
static void __exit led_platform_exit(void)
3 k0 j, i% S3 _" C/ }4 V( Q{3 R( e: m* @5 b2 b" h  @
        platform_device_unregister(&da850_evm_tl_leds_device);
2 f7 T0 s- f1 a4 m! m' Y) d+ V. M
        printk(KERN_INFO "LED unregister!\n");
, ^/ ^# V! {- s/ n" p& w}
# w5 R5 h! J! c2 H7 R% S, s! L' U5 s
module_init(led_platform_init);
8 o) f# d0 ^7 u/ m. E9 Wmodule_exit(led_platform_exit);
' t) r9 D$ w" t
; s5 s, Y: t- V, uMODULE_DESCRIPTION("Led platform driver");
: y) H) j7 w6 s4 g9 t6 SMODULE_AUTHOR("Tronlong");
6 [2 d& v0 G0 F4 i( j& QMODULE_LICENSE("GPL");5 C1 p2 i1 t$ r1 N. d

0 W% k' k: ^+ i8 k0 Q. n
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

点击跳转“创龙科技服务通”

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

GMT+8, 2026-4-7 21:13 , Processed in 0.038931 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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