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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。: x% M, z0 v' |
#include <linux/init.h>
" b7 h; F2 I% O* O#include <linux/module.h>% M& O7 x( G% I9 c5 u( j3 [1 |
#include <linux/kernel.h>/ _# x- f1 _4 Y9 ~
#include <linux/types.h>. a: v: N# B" x+ S
#include <linux/gpio.h>) ]  H1 ^2 o) k- Y3 K. N* g
#include <linux/leds.h>  e# ?4 G7 C; `, g4 b) Z' N$ G
#include <linux/platform_device.h>2 M: M8 V+ |- N- \

9 J) N. N9 q& x7 l#include <asm/mach-types.h>3 P3 E9 O+ ^6 B" v7 `
#include <asm/mach/arch.h>
, @# h( S) X. W#include <mach/da8xx.h>: J3 b1 I' S" L. b; Y
#include <mach/mux.h>. ?, v; n, b( v0 ~! r, g" U7 |

0 b! `! H' F: ^9 s& L, a#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)3 C9 c' k9 A3 v9 E* ]
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)* t  ~! ]3 g" g% w/ S6 e
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)) f0 L% `$ ]& r& c8 J
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ K) e5 T  `- l
# g# w* G: t4 W5 X( o7 b$ b& Z  U
/* assign the tl som board LED-GPIOs*/
6 [" T; U. F. fstatic const short da850_evm_tl_user_led_pins[] = {
+ e% H0 h! \& J& I2 t7 V1 B  f        /* These pins are definition at <mach/mux.h> file */7 x, C# n, D( N  f
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 T! q: t5 D. l3 R0 K8 C        -1
! O9 G+ A8 I/ F};. T4 W  b  Z( a/ G. O6 {( n

- t. J" R& C/ @; c9 zstatic struct gpio_led da850_evm_tl_leds[] = {% W3 K$ E9 ^8 N' j. w) r! @
        {
5 E) \' p7 `2 Q: u1 ?4 A                .active_low = 0,7 C- w: A7 S+ M0 S! z/ j
                .gpio = DA850_USER_LED0,
' E+ K- @( m1 ~' }4 e9 k1 \                .name = "user_led0",
4 }$ g+ l- h& U2 B                .default_trigger = "default-on",
8 w2 q2 C( \; i5 j7 L; U: b        },
. A# G+ D7 f5 h' [8 T# Y$ Q% C        {
* v3 J2 {  w( @                .active_low = 0,' p  |  l7 A2 N& u" p! w
                .gpio = DA850_USER_LED1,
3 t, e* }6 z  h                .name = "user_led1",
; E7 V5 L" s! |" c, T! p4 J                .default_trigger = "default-on",
0 l4 q2 e  F& a& H- k9 h2 S/ R        },1 ]/ c8 [$ F  e5 X& @
        {7 i. L, f$ c7 |6 B' c( x% u4 O
                .active_low = 0,
: I' v2 x8 z- B( o                .gpio = DA850_USER_LED2,
- f5 y+ c' |- q0 @$ q                .name = "user_led2",, R/ F: G' [! c' N4 h9 T6 t. n
                .default_trigger = "default-on",- g6 z1 Q$ ^* B/ h0 f0 ^
        },9 y2 L. `/ Y4 n: Z: `+ j
        {. v& k' B8 l0 j2 i
                .active_low = 0,! L$ f% L* z; y- p9 n8 G
                .gpio = DA850_USER_LED3,5 {4 a- @9 @8 _
                .name = "user_led3",0 H- [* {% `. a( q2 U
                .default_trigger = "default-on",
. A" n) q7 N9 `/ i0 p+ ]! q        },' A8 Z& p0 c0 G3 m4 [; c, v
};
  d! Q& R% w0 h9 [
4 r( T& e1 Z7 U* p, N+ H$ c7 Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# c2 r5 M5 ^8 Q
        .leds = da850_evm_tl_leds,5 i1 l+ k4 Z: W5 @( G& B6 ~6 D% X
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," L* j# W! w8 f0 i
};- _' m4 j6 w$ I4 u
2 K: F0 g3 |# `' Z0 e5 ?, |5 \5 ]
static void led_dev_release(struct device *dev)7 h* u- x# n5 b# l' d) H2 |
{
/ [" T8 Z; o' h' f% D0 E1 ?};3 ], H* r. ~! X; g9 F
3 L8 X. w7 B7 q
static struct platform_device da850_evm_tl_leds_device = {
1 d7 l& }5 \! C; K3 P& @; G        .name                = "leds-gpio",
1 `8 s7 \" a# f- M        .id                = 1,. |3 f7 |! D% R  V/ U
        .dev = {
* q* N+ c! L# k( G" E8 r                .platform_data = &da850_evm_tl_leds_pdata,/ `; X0 R2 V' Q! K! w/ |
                .release = led_dev_release,/ U, U4 ]9 m& ^. h
        }
4 d2 L2 B& U3 V: ]: x* W& T};5 Z2 z, {$ [6 H8 v0 \' Y! t2 H

- I( N9 j) [9 \static int __init led_platform_init(void)7 V5 V2 X- @1 V/ N' a' v7 Z8 ?
{
# V4 v0 |  v2 g; Y        int ret;8 ~, o6 V; i$ V8 r! H; @
#if 0
) z: U: P) x9 x$ R/ D        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( h  y2 V' `* s* |! z
        if (ret)" k; V- h! o1 i' \6 b. k' S
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- Z4 o% [2 i( E* K1 a( J2 Y1 l
                                "%d\n", ret);7 P4 u7 L% I* j* L3 @
#endif
) ~2 o9 D# |, {6 ^        ret = platform_device_register(&da850_evm_tl_leds_device);8 p0 K% W: k# b9 g
        if (ret)9 s  E! y6 \5 e4 m$ _/ B
                pr_warning("Could not register som GPIO expander LEDS");
3 u% a: |4 K) q  l9 r4 O        else( Z( O- @/ Z4 A) x# x/ F3 B* c
                printk(KERN_INFO "LED register sucessful!\n");: o# t/ J  ], m0 C: t8 t- P$ L
3 b! N; B; p5 x- m, H: a) [
        return ret;
& ^. _* J" S/ [+ o" c; X8 U" o}
+ A5 y. h9 L  i) @  G" H% _* d3 p3 S3 O- H+ K: A, ?& E9 A! P$ G
static void __exit led_platform_exit(void)
) _: q  t( X: ?+ H{
& Z' o7 Q$ q7 l# d6 j6 t2 H* W        platform_device_unregister(&da850_evm_tl_leds_device);
1 T' D6 Z" H5 y0 E6 k& |& ^# s' f# U  l" {9 \- u7 t
        printk(KERN_INFO "LED unregister!\n");
( `* W% Y/ r! V, Q: U}
8 B7 w/ Z' p1 @& ~4 V  R8 B7 G& {! k; f1 S/ Z$ Z, W/ {. V* L$ d. B" [
module_init(led_platform_init);
7 r/ n8 a4 G0 \! Omodule_exit(led_platform_exit);' R+ o6 t- P; W* e4 b2 S) j7 m
! c* ?, H0 Z6 D6 L
MODULE_DESCRIPTION("Led platform driver");/ b+ }1 M" @+ }0 {: F- I
MODULE_AUTHOR("Tronlong");/ T# E+ `+ h; K! ^: T% P
MODULE_LICENSE("GPL");  B) \& {$ [4 K! e! e

. ?5 I& F2 ]2 Q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-21 06:02 , Processed in 0.044040 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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