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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
. E- _& f- E# }  \  T8 u, u#include <linux/init.h>
9 ]9 w1 j9 z2 r#include <linux/module.h>0 r. ^% |! D! W
#include <linux/kernel.h>
; a- s# ^- B1 X! ?6 z8 Y1 B. j- |* X3 g#include <linux/types.h>' |  Y/ B" Q* I0 t; [+ H
#include <linux/gpio.h>
. Q% k$ K$ J+ x0 L7 S0 \5 [#include <linux/leds.h>8 ]3 ^$ {% R7 |0 r0 b, e
#include <linux/platform_device.h>  j9 Y1 C! d+ ]8 j; D

. p1 d5 K, h0 f. \0 O+ J#include <asm/mach-types.h>
  m8 I* x, {& _' N' Z#include <asm/mach/arch.h>
; q% p2 {+ n1 `' h/ e#include <mach/da8xx.h># L4 A3 @2 {" f7 D* K
#include <mach/mux.h>
2 Y( X3 a* q% G& j0 o6 n
& d/ ?0 y" Q6 g; p+ v1 G( x#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)" [9 C, Y* s. @" s  w  i
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- W, g) T% U# D$ J$ D#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
, Z2 x' x8 ~# t2 ~) r5 U#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)' S' [/ B5 F' o/ ~8 w! b

0 T; [6 d+ |, O/* assign the tl som board LED-GPIOs*/3 L1 t/ P, Y0 H% m% u2 k$ c
static const short da850_evm_tl_user_led_pins[] = {6 `  h# k6 z4 v$ Q0 }0 d1 p9 @
        /* These pins are definition at <mach/mux.h> file */
& S7 S) V( ]% {        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 W+ I1 G! P5 ]6 S7 \  J        -1
+ v& U! x9 J# U$ h! ~: A};
9 B2 E0 E/ s$ k8 v
1 X+ s8 K( s7 T! i" astatic struct gpio_led da850_evm_tl_leds[] = {
0 N( v: A0 z  |) X* H$ l. Q+ e        {
  }' W' \, I5 n% y                .active_low = 0,; s/ X1 T( ~( G( A1 ?/ S) j7 i
                .gpio = DA850_USER_LED0,2 d6 O6 |! K$ p: D# l# U4 ^
                .name = "user_led0",! c+ r! y7 n& W3 x4 A) `3 x
                .default_trigger = "default-on",
# k. @% c7 W% n5 v        },
6 ]! n& I- U# J3 O# k        {" J) x) g) U7 V# Q6 S9 U
                .active_low = 0,
5 y+ ?" T8 X: ?/ e4 S7 r. v                .gpio = DA850_USER_LED1,
; B7 S+ o6 q5 M6 ~                .name = "user_led1",
  J/ [7 R+ n6 D- A8 r5 G1 M                .default_trigger = "default-on",
& W1 G% I2 Q7 X8 r! @        },# ^" C+ v2 l, i& W# b
        {* Y# y3 f+ a) \
                .active_low = 0,
) h$ O' p8 C5 a4 E. x8 R4 K                .gpio = DA850_USER_LED2,9 J7 s- C' v. ~4 q; @! L
                .name = "user_led2",6 L3 p0 c- x* G+ B
                .default_trigger = "default-on",2 F& \& }! @  q" }" U9 o
        },
9 V3 [8 Q1 R7 M4 H3 a        {, d* a! K5 j; x1 f$ a
                .active_low = 0,
, `! H+ q: Z6 Q9 x# [3 K3 P! c                .gpio = DA850_USER_LED3,
- r7 D' Q0 C0 |; R( o9 A" w( H0 U                .name = "user_led3",
$ j" q) U/ u8 y1 k7 m6 j+ r                .default_trigger = "default-on",/ p  N6 k; e1 A7 _/ ?$ n
        },, Q5 P4 p2 o& n$ U
};
, Z) I! P. t8 o, R2 k4 F
% b) Z! o- I) u' Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
  n5 u! Y6 c& T9 _2 H        .leds = da850_evm_tl_leds,
) ~0 f& @* d; A) v3 u2 I& p        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* _& S" j7 q% E& q( L2 z};
" D8 s/ v/ O7 o; q+ Y! i4 m+ I0 g; i  Y1 g9 t+ J- }
static void led_dev_release(struct device *dev)
/ B  U' |5 J$ P5 \1 {{/ D0 D' }. C' s, N: `3 U
};4 Z) g) }  G$ U" q% E
% D. T$ P9 z$ z9 L/ D* g
static struct platform_device da850_evm_tl_leds_device = {8 }+ s9 {: G( r' a  w
        .name                = "leds-gpio",
3 \6 ]; a# R, X; p6 W( Q        .id                = 1,
* |1 ?5 y3 }6 O0 T$ i: `2 s        .dev = {$ G5 C  y7 O" X3 B) w
                .platform_data = &da850_evm_tl_leds_pdata,
0 V$ G  A8 V! ?  d: b0 F# K+ G                .release = led_dev_release,0 E% n2 I: P8 S
        }
3 J* i3 a3 A8 V$ q# V};
6 v! e4 U; S4 r$ S# J1 ?0 [/ U/ x  G4 S& T# x" d( o
static int __init led_platform_init(void)
* Z7 B) [: V( x3 c  r  y- [7 ?{
, n) U; ]( {5 Z1 a        int ret;
, ]1 F& ]/ Q' a2 Y+ q  |4 _! E: I/ U#if 0/ T- _1 Q- v  \4 E! e
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 o" V$ ~& a7 F
        if (ret): h  U& w( k& K+ x+ D: ^
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" G( V9 G7 C& V1 l# M                                "%d\n", ret);7 f, H3 A# @% V
#endif
3 r: R- q% z1 @( h4 q        ret = platform_device_register(&da850_evm_tl_leds_device);; w- b) i& M: w5 J
        if (ret)' ~- r  w4 x, }* Y' G4 W
                pr_warning("Could not register som GPIO expander LEDS");
, H7 Q! M5 N8 N1 g! R        else9 |0 Q; G1 x1 \* s1 Y$ J
                printk(KERN_INFO "LED register sucessful!\n");0 f1 U% t2 u7 U6 p

+ B8 Y' E" q  M& Z& r% e' u9 s% s        return ret;
& X: V+ h# |3 n" w0 h' J}
: r. C; m4 @' T/ h: a# ^2 s8 b& @4 T- W0 @$ f6 [% ~, ?
static void __exit led_platform_exit(void)
& |1 r! M* l* o- M9 _' R{0 I! t" m0 f0 U5 G& b( F: y3 k
        platform_device_unregister(&da850_evm_tl_leds_device);
, _- l9 i- X7 C: `7 k8 a4 I3 ^3 T
        printk(KERN_INFO "LED unregister!\n");
* {3 d0 C7 }5 ^! W}- w9 o) P. V+ b) ^! f

; z7 q; X* K( o- ]module_init(led_platform_init);
4 A4 G4 C+ P. \8 U8 j* mmodule_exit(led_platform_exit);
3 l: W& O  y9 f6 \* P" M5 f
% K1 c: g2 m6 D  UMODULE_DESCRIPTION("Led platform driver");
6 ]+ t5 U1 ~0 k: m! C, ~+ wMODULE_AUTHOR("Tronlong");
' F/ H, ^  M2 [; ~/ I% |MODULE_LICENSE("GPL");
; b! k+ f8 w1 j0 ~3 _9 a- K. k! A5 w" h+ F3 O/ w) b1 ~
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-24 08:10 , Processed in 0.038166 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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