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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
. K) m+ P/ |2 a! O#include <linux/init.h>) v7 b" ^0 W) G
#include <linux/module.h>
$ D# k4 {$ m5 r#include <linux/kernel.h>
& X# z% D- ]8 N" T/ e+ F" E8 |) f#include <linux/types.h>
' b$ O& s' [! R) ?$ i' J1 F3 A% X#include <linux/gpio.h>6 t" T. w' L7 w4 o
#include <linux/leds.h>  L0 G# {: Q) l# i' h
#include <linux/platform_device.h>
' U6 ?& `4 h9 P! ~$ f5 w# Z
6 u5 X# c& A% ~% J: k  R6 B1 e/ s* m#include <asm/mach-types.h>
' U  T& l7 D. z#include <asm/mach/arch.h>
2 \! Y% a: H% A+ |4 E! r% F. e#include <mach/da8xx.h>
. |$ c/ J; S  c+ W2 z3 r#include <mach/mux.h>) _! `6 }7 [0 k+ Y: R/ C

5 t" i" @/ W; \& }! d3 C# F' ?#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
# O! L) _$ j* P( \  J#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)6 l" k. z. c; |" Y6 U8 R
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)2 r. R* F* X' ?
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
0 L/ S4 i1 a8 C8 Z" d% ^. y% o$ a' {
1 K! S$ [) H" F; O+ F5 H/ M/* assign the tl som board LED-GPIOs*/
. n  [6 ]- V& w+ m. zstatic const short da850_evm_tl_user_led_pins[] = {
8 |3 w* H* l3 d        /* These pins are definition at <mach/mux.h> file */
+ X3 w0 n* R8 t3 B2 i, ^        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 v3 B- z: S' o  d' q9 H        -1
$ E3 Z2 {7 o# W" d};1 R7 U0 A* R/ [, o7 H
& y: X9 s1 W; ?0 \% m' y
static struct gpio_led da850_evm_tl_leds[] = {
& [" I% @: Y% s  V$ ]5 U        {
3 p' m3 D: M, `  ~" s0 b                .active_low = 0,
* \0 n1 z3 |1 E: A2 V                .gpio = DA850_USER_LED0,. [2 g5 d+ A( ?  B5 p+ Z4 d
                .name = "user_led0",
: f$ |# `7 ~* i- y( I                .default_trigger = "default-on",
$ Y* H& B" v: Y        },
$ ]9 S  Z+ L9 A3 E8 U; P        {
3 h3 i5 |0 y8 J: g6 C9 l- R                .active_low = 0,5 E1 S" |4 V$ E: F5 X2 e. X
                .gpio = DA850_USER_LED1,
5 W" i! d' Q( m3 h- C. d                .name = "user_led1",
& X% ?& P! i* i  p; y# O                .default_trigger = "default-on",
! o  Y+ F' C  {$ f        },
9 R  F' H* \0 Y$ l) M- `! {) N% C7 E        {
/ z$ R! t) f! v5 p$ J& i                .active_low = 0,
4 S! e6 k3 Y( j8 {" i. ]6 _4 m                .gpio = DA850_USER_LED2,+ A) n$ z) \: i
                .name = "user_led2",2 U1 G) n, s/ h, _+ _
                .default_trigger = "default-on",* H9 S, q" Y, l. M/ N% G2 f4 |$ c
        },
0 U; g6 I! @' J4 [0 w8 a9 g" A, ~. l2 l7 q        {' ?6 T0 u. V$ B5 \3 V; i6 d
                .active_low = 0," s- h2 n5 m# t" b; G
                .gpio = DA850_USER_LED3,2 m  R6 v* t* Y; h  P; Y
                .name = "user_led3",! K. ?  O$ K- V" V* Z; {# g2 V
                .default_trigger = "default-on",
1 A% f! f' c" l) c) M8 i2 \4 B        },
6 L  B4 e) |% M) q( E- I};
  j1 b# H- ?+ x! w! q
: D( i/ ?/ n, ], x9 \- Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 S( K3 N! L' m, E, ^
        .leds = da850_evm_tl_leds,! C' `0 N5 v! a. Y
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: g4 O# |. n, Y0 r  V( `/ e0 D
};+ [: p0 a) D) B$ u8 z
4 Q1 P1 I* c1 n0 a0 F4 p
static void led_dev_release(struct device *dev)1 F" c9 W  x/ I) j# v) f4 p0 F( w; L
{' F0 y* S9 h8 T( A0 d- p
};- J! s( \$ z) U

% B5 o+ {5 G# g7 t8 ostatic struct platform_device da850_evm_tl_leds_device = {. ?# F6 s) T! S' F5 r# L* c$ |0 N9 `
        .name                = "leds-gpio",
" Q" U. g3 t+ l& D        .id                = 1,
" L( Z$ t8 [" ]. @  \7 _6 ]        .dev = {
5 o" W( n% B8 k( `  I2 D. f                .platform_data = &da850_evm_tl_leds_pdata,
6 f2 i9 ]2 u2 ^! X' n/ O( ?                .release = led_dev_release,
8 Y+ V( A/ S6 d* M: ~' G; j        }2 v9 |7 L- c# F. Z
};  F: {& M1 o# O; h8 M, f3 I) u
8 u, ~2 h% [8 f1 w( A# X
static int __init led_platform_init(void)
  {% v$ }- z2 D$ Z8 W7 M+ S% Z9 m{
8 H( K. P) ?8 Q; l" n        int ret;
9 M: X  H7 E' w  j  L6 b* y# V#if 07 u; m% _) R: o5 x/ T  D
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 E; N9 K9 h% T: v        if (ret)
8 z  [1 M  s1 h* U$ H7 u8 v4 N6 i                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( N1 z# D1 H( r8 Q/ C) K                                "%d\n", ret);
# }5 q" }3 A& n! G, [. U! H& u#endif- D  \$ L( e( ~4 Q) `$ ~0 b( A
        ret = platform_device_register(&da850_evm_tl_leds_device);- S! G* J. h. ~5 |0 {0 L1 D
        if (ret)
8 u' }* d% `% o                pr_warning("Could not register som GPIO expander LEDS");
) V1 |- ?2 x7 M        else8 X5 V' L. p) p) s
                printk(KERN_INFO "LED register sucessful!\n");( u% R# {$ ]) _* O" a" b
! M, l8 T3 j0 D  I% s
        return ret;
+ s  M6 {' _8 n( r; D( I}
- ?1 ^( o  H, b3 }6 J, [. U; l: P5 v
static void __exit led_platform_exit(void)
3 s" V: N6 w( q1 V" k{
4 M; b; `+ C4 [: K% x        platform_device_unregister(&da850_evm_tl_leds_device);
/ Y* v2 l- k" _
0 e# O6 Z1 H4 e- [  x4 X        printk(KERN_INFO "LED unregister!\n");7 F4 [: k3 f( a( _; J
}; J3 h4 h% ^. a4 o, M

9 Q- Q  V+ |; I- b5 hmodule_init(led_platform_init);% e3 J8 G: T; |* m& b* X: A% x. i
module_exit(led_platform_exit);
8 Y  @% g  K$ W9 H& a* X- q/ M/ a! j2 {  f+ Z* P
MODULE_DESCRIPTION("Led platform driver");
# S/ }) q2 u5 `4 c! RMODULE_AUTHOR("Tronlong");
% W: K1 N3 R$ p) x5 x( P$ M" kMODULE_LICENSE("GPL");
" h7 u( p" b; c' W  ^  k" m  C6 w9 z  {& h: o& e
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-21 01:13 , Processed in 0.037921 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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