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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% M. h5 Y. B. B: {* w
#include <linux/init.h>8 M& j+ [! i6 ?4 W6 f
#include <linux/module.h>
+ T) n3 _1 u. `7 S: W; [8 T#include <linux/kernel.h>; P- w  L0 ]8 D& d
#include <linux/types.h>& d! I( T' b8 ]
#include <linux/gpio.h>
3 T$ I* F; I5 A: f7 g#include <linux/leds.h>
" b% o3 w+ K! x, x+ E#include <linux/platform_device.h>* A# M( V8 ~4 m3 p1 C
# Q8 [  p/ d; A2 x, a0 ~  G
#include <asm/mach-types.h>
, l! w' N' {3 K#include <asm/mach/arch.h>
6 P4 n1 n) N( d; C6 a8 k: [#include <mach/da8xx.h>
, i3 \* M* {1 |6 N#include <mach/mux.h>) z7 \  v0 i# \

; s# Q! P( c9 g3 P% v0 s7 s! N#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)4 r. l& U/ B& g# m( N; J; f
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)% i( [' i7 c" u7 x
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
7 ]# ?* e% v* c3 m: g& W#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)' h2 S2 D) R* I8 t6 {  X4 |

1 ?$ H. t( F: x' l8 Q; w/* assign the tl som board LED-GPIOs*/
6 }! z3 N2 |) u$ c7 Gstatic const short da850_evm_tl_user_led_pins[] = {
% s4 O+ M9 G! U/ R" E        /* These pins are definition at <mach/mux.h> file */
$ ~7 m  w2 ^% _* N7 S        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 n* {3 F7 }' j3 s" \
        -1
8 `$ W* V; b4 Y' j8 x};
, j* N3 d  P1 h+ M* ]0 [2 d
! _$ [7 y7 i1 A, |% P( H' Hstatic struct gpio_led da850_evm_tl_leds[] = {  G- W9 Z0 Y1 [; |# [
        {% I( ]+ D: @7 j) T$ `
                .active_low = 0,
  t. b4 v2 [7 T- K6 @5 A+ t# P" X                .gpio = DA850_USER_LED0,
5 e: \6 i5 v5 X$ t0 T5 s                .name = "user_led0",8 c+ \8 W. B/ O& r9 D# K7 f3 M) N
                .default_trigger = "default-on",
8 k/ t' o4 }4 y* s5 x        },4 p6 X( V! u6 f% [; ]
        {
. {! g9 \( A3 y! @, ^% e                .active_low = 0,
1 r. f0 c. L( v; M, k                .gpio = DA850_USER_LED1,; Z: P& E, I, U' d9 E& W7 v
                .name = "user_led1",
2 G( |6 d7 R2 K( ~- E3 i2 n                .default_trigger = "default-on",
. t8 n) O3 U1 c/ t        },
) q( Y9 G3 L9 G2 c5 |% F        {
' |+ i. }0 h; {8 M                .active_low = 0,$ q" \+ \; y0 ^3 q7 b& }. T' n
                .gpio = DA850_USER_LED2,
3 P$ s$ a4 k3 m- D* W" E  c7 G0 M4 s                .name = "user_led2",
* b1 Q7 l6 V& e                .default_trigger = "default-on",
) @- a7 n* d" R0 H, ?# \        },
$ F% m- ~& N  M: t* |/ F        {, W3 A9 {7 R( @8 V
                .active_low = 0,7 c( }9 E4 ~8 h% o2 r
                .gpio = DA850_USER_LED3,
' H/ J8 {6 q! v, j3 o; N2 X4 H                .name = "user_led3",
& V9 z% E6 H. q: K2 Z* A+ P                .default_trigger = "default-on",
) D5 q; ~, V+ C) V2 W, }  O  O! r        },) r: U+ p; m- |$ b7 k5 N9 v7 x
};
3 B4 k) L: ]/ W$ ?- q" R6 d8 Q6 Z/ B. S0 ^$ Q6 K6 U% J- j1 v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 [# Q1 x) }  I' D4 f$ _& t
        .leds = da850_evm_tl_leds,. ^( t! P# n4 _: t/ n/ n" P% B
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( f0 {( U/ O1 s' _  u3 b6 i, E3 c, R};6 K8 Z$ P/ k" g* K0 `

, Q' L1 l8 d, n- |static void led_dev_release(struct device *dev)
3 M9 `- r5 U* l/ t! `: K! y$ Y7 t{( H$ J/ z* U: u; ]% {- S# L
};- }; m- j- C& O* u$ b: m! v; j$ O6 g4 f

3 e% K" h4 t. t3 `, tstatic struct platform_device da850_evm_tl_leds_device = {
; c" i. q4 h6 F+ n# ~8 T9 I        .name                = "leds-gpio",  K7 J  h. z" Q* X- {0 w
        .id                = 1,
3 u2 C. F" R1 s4 H+ X+ ?; ]        .dev = {
/ K6 Z" Q7 D- a- O2 \6 U* u                .platform_data = &da850_evm_tl_leds_pdata,* J  Y* r) j7 g. M2 Q% p( a
                .release = led_dev_release,
. ^+ |7 |" Z4 ]2 y! e/ s& r        }( N* C, A+ {, v3 K- a
};* `, @, T5 y. I# N$ ?0 ?# h
4 {% [, V' p: \
static int __init led_platform_init(void); l7 D7 O( o, x4 i
{
7 G2 G  [4 E4 A8 J  j3 d$ L        int ret;
7 C+ Q$ N' J! e5 v/ N#if 0: @) c& y; M) K8 @) p) u* T
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. o% W+ c9 b! H9 a% e        if (ret)6 N9 b: r- h& o3 e; z4 c
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, m  `! k1 ^7 t" m  l' u) U* r- D                                "%d\n", ret);/ l$ k' }; P/ s" e% r! Y9 N
#endif' d; f6 o6 R9 W1 v
        ret = platform_device_register(&da850_evm_tl_leds_device);$ |. i9 Y. d" @$ U3 d2 J. p; g
        if (ret)
. [0 k2 m( Y% S& Z2 G                pr_warning("Could not register som GPIO expander LEDS");8 o5 y2 N6 Z2 j2 c8 V
        else2 W8 r  n- g4 d8 U- q: J; z# R+ s
                printk(KERN_INFO "LED register sucessful!\n");
' r9 W4 L7 I0 T7 z9 L1 g7 A0 y/ S# B1 d
        return ret;3 G$ X6 P! h8 L# X. q, k
}5 X+ e# u5 C3 a! x

% _0 D/ J6 N" _$ Qstatic void __exit led_platform_exit(void)
+ I! ~* q* @+ K2 K$ t{
; ~# F, U, Q- x  x! ?        platform_device_unregister(&da850_evm_tl_leds_device);
, V. B8 h. u) U+ \8 {$ G9 }8 w' A4 H4 {- y$ H1 s1 b
        printk(KERN_INFO "LED unregister!\n");
" |) |$ L. a/ e4 Y4 e}
# v2 w7 C$ n& I- y, e( O
& @: P! [7 k6 \module_init(led_platform_init);; `7 i9 D  q; |+ `+ P! y
module_exit(led_platform_exit);
2 \2 l% ?: e5 k( v( b+ U: ~% J4 ^" N3 W7 w. m5 w
MODULE_DESCRIPTION("Led platform driver");
$ ^" G. k. _8 s, i4 ?+ b3 x7 |5 C6 uMODULE_AUTHOR("Tronlong");
; C$ `' P- T4 E3 hMODULE_LICENSE("GPL");1 g2 k1 V& D+ w4 s
9 \$ `* p: @6 ?) C' a1 [
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-30 16:01 , Processed in 0.041524 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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