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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。- c% {# q5 G& w1 @
#include <linux/init.h>
5 T% [# F8 k! a4 x. X& L1 q$ B#include <linux/module.h>
# _6 c1 L8 H3 j  ^1 A#include <linux/kernel.h>
' U! e8 R' Y8 S. M+ M! z8 A. Z# X#include <linux/types.h>
0 @1 I& s/ Y: G3 m2 ?#include <linux/gpio.h>
! F" l) x8 N* B# v#include <linux/leds.h>
8 |+ I+ D8 d' Q6 @#include <linux/platform_device.h>  F( i7 K/ H0 m( P$ G

7 W, V! o! ^1 ~, E* p#include <asm/mach-types.h>
. |4 E& s  g' i& M#include <asm/mach/arch.h>. J  g8 R; V; H! k
#include <mach/da8xx.h>
4 H5 }2 J- ^, x/ k9 `#include <mach/mux.h>" ^7 g* s: D5 K1 I- Q

+ b& Y7 P- A/ a2 J7 Q0 [2 W! c' l#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
7 w* @# x% w" O; g) L) Z#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)0 E7 @! V8 a2 f
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
: W8 E' A. M) \7 H- T' r5 A  j#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)& U& F* h  n$ S
1 B) H# n  S4 w# y2 q; T
/* assign the tl som board LED-GPIOs*/
- v0 W" ?* g/ pstatic const short da850_evm_tl_user_led_pins[] = {
" X' n3 Z0 b9 a: o! Y# s' i        /* These pins are definition at <mach/mux.h> file */
" q! o; H0 Q! O3 e5 y% P        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ }3 h1 L5 P& r% T: ~) ~, r        -1
& [8 ~# J, c# R% f; L8 |4 i};
2 ?, T2 t: V8 ^$ n6 C2 G
, p- j4 A* E7 K0 [2 E, H( N) R0 sstatic struct gpio_led da850_evm_tl_leds[] = {* _5 b+ k0 d* t7 ?1 c+ ?
        {- c7 K. i) Q5 Q. D8 ^& ?
                .active_low = 0,
( P4 |6 y0 M. @  ]. p  |                .gpio = DA850_USER_LED0,1 z) c' ?+ m. K$ q1 _
                .name = "user_led0",5 Y; ^4 o( d$ ~6 I1 H* ^
                .default_trigger = "default-on",; S6 s+ ^' Y0 I) [" V6 r
        },% X2 ?# k5 L, ^7 u* k
        {
+ G' k* d( h* g( ~0 _3 G) J                .active_low = 0,
/ V+ O0 A5 O# [* @8 d+ S" M                .gpio = DA850_USER_LED1,! }; I8 Y) H* r  n1 j; n& b0 W8 a
                .name = "user_led1",
9 @  A* I! a% I. ?# k' l7 `5 c                .default_trigger = "default-on",& g( D: k8 _% Y$ A
        },/ \5 P7 `1 b1 l& w2 ?) ]8 R% ]
        {7 `+ Z, e' i$ M% l
                .active_low = 0,$ |, ?) L' s4 _0 Y2 x  R
                .gpio = DA850_USER_LED2,
1 p6 d: V7 F, E' z' o9 c  \                .name = "user_led2",
' I  d6 i. Z" U% L& i, t                .default_trigger = "default-on",
* u- P# i2 g. Z( ?6 d0 ?4 r        },$ a/ p: }% x% g8 O" C
        {& f6 G9 |* _" q: a4 G
                .active_low = 0,3 o( n* y2 F% _& z* ^0 d4 ~, N" f" i
                .gpio = DA850_USER_LED3,. ?2 u; X/ V1 ?! }5 [* q8 C
                .name = "user_led3",3 }; U6 {# i2 I6 R- h  ^4 g
                .default_trigger = "default-on",6 q, I! D. |4 Z' V
        },- P- d7 L+ L3 E: F9 [- e
};% a) E  v; O6 V7 f# C

( U! Y; S/ T4 A7 ?& B; b8 sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 P- W! y4 |' ^. k0 \, f
        .leds = da850_evm_tl_leds,
: C+ I" z4 L1 A  n; S! ^- A2 \        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% R% l. n3 _& r* f};- T+ v! c; A7 n& ?

% m8 ]! \  k, P9 D, bstatic void led_dev_release(struct device *dev)) \2 d: g! b# [2 d6 E7 C, ]
{/ E( \. E2 r& k& U! h
};, a! S; i9 Q! _6 A1 A* a6 F

$ S" K0 x; R6 gstatic struct platform_device da850_evm_tl_leds_device = {
# P/ ~1 k' g( c) h        .name                = "leds-gpio",
" T0 z% }; T6 o: K  _1 c, `        .id                = 1,
6 ?. A  o- s% {0 C; o8 x        .dev = {
6 O: T; J  k* d( \+ I/ f# m5 ]                .platform_data = &da850_evm_tl_leds_pdata,  |2 y* Z* H% U/ d* S
                .release = led_dev_release,
( E  ]3 D3 _  ~. {" C        }6 f  P5 R% I$ Z8 ?8 V; m% q
};
1 \9 l: S- `0 k8 o& t* }
8 I. v7 n% Z/ [static int __init led_platform_init(void)! Y& }- Y7 A, k9 g8 M
{( E+ }. f- T' ]% t
        int ret;
- J3 a2 T5 B' P#if 0
4 J# M* A" w# [# o        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" l; U/ O5 L8 v" ?7 f0 V, a
        if (ret)5 g$ v6 _. @: d- F
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, @1 G  j7 v1 N                                "%d\n", ret);
0 A; w" N, W) i+ Y  |. k6 |, h( i& a#endif
) R$ s, `9 A; {" ?. k( P; t' P        ret = platform_device_register(&da850_evm_tl_leds_device);
- P( `0 E* \+ f; N& `        if (ret)
( \* b" v+ M4 p+ e+ B( y4 u! K                pr_warning("Could not register som GPIO expander LEDS");
4 W$ F. m4 W( C        else) t5 T- {8 k6 b7 ?* H7 q
                printk(KERN_INFO "LED register sucessful!\n");
, [  O, T7 q8 Y6 v  T% ?3 D. P" N  |9 n
        return ret;
7 O- m4 ~3 S) Z0 H# Z. \8 |1 ]4 o}
9 X9 E9 E+ J* Z6 l( R: e0 E, n% J* {" _; [
static void __exit led_platform_exit(void)$ k! Y, I) l: l6 H, S. n
{
1 L6 x, t8 V  a9 x        platform_device_unregister(&da850_evm_tl_leds_device);8 F4 l& K3 p! D; t6 X/ x6 a3 P

9 t" {5 M9 Z2 }        printk(KERN_INFO "LED unregister!\n");& d9 U- \6 S& t; W% [
}
6 l+ M: A" l. l: T. b# F/ W: q4 n+ n1 J  [2 }) l/ N
module_init(led_platform_init);
' e" ?7 t  w* v# C2 \! Y; N, Gmodule_exit(led_platform_exit);
& @7 Y) H1 |) o5 I7 j: h+ d+ O
1 \% u% p+ `2 E# z" SMODULE_DESCRIPTION("Led platform driver");
$ _: _7 T- \9 \; y* fMODULE_AUTHOR("Tronlong");. [! b2 G9 k) o7 |0 i/ X' F
MODULE_LICENSE("GPL");
9 Q) w) M' }! c8 `) {4 D, Y+ z$ P  t
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-25 21:48 , Processed in 0.045176 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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