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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
- |; `, g  \  a& e% m* E#include <linux/init.h>3 T" P9 E: A- J) |/ m
#include <linux/module.h>
/ r" x5 N- k; B! b( D#include <linux/kernel.h>8 y$ G* g3 D* O8 \( Z
#include <linux/types.h>
% W( G1 T7 X- ^, |8 Q#include <linux/gpio.h>
. m- w2 ?3 ~  n+ c#include <linux/leds.h>, C( H. V* n: B9 n. [5 H
#include <linux/platform_device.h>7 m+ @5 t; ~# ?

2 A' Z8 U/ _% `! B! T#include <asm/mach-types.h>
1 {. @: j% i/ B: T8 x#include <asm/mach/arch.h>, ]; p0 w- Z) o! d# L1 t& a/ M1 E) H
#include <mach/da8xx.h>
: q* V" F7 k7 a' ^#include <mach/mux.h>
7 U. _  K4 y) X* j$ V# D& k+ @4 g, ]% }$ I" C, O
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)% ?, |7 j/ _2 o+ @' I! q
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)$ p" `% G3 q- T( K$ W: [
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
+ S" y% ?' v2 V4 X#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)5 N3 ?* g( _! L& r" g9 j& M

. B3 S' H2 e/ [  u7 w/* assign the tl som board LED-GPIOs*/. }) F7 ~& J8 Q: _, r
static const short da850_evm_tl_user_led_pins[] = {3 W3 l) z% x/ E4 ]' w
        /* These pins are definition at <mach/mux.h> file */2 }4 l8 t/ ]: Z3 K  j5 [
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; R7 F# n  R* k: P" @) R) @0 f        -1& \+ U5 U' l5 t, W% I
};
' M; V8 r) W# c/ P; s8 r1 M8 }( w6 k* O& H; E0 `$ O
static struct gpio_led da850_evm_tl_leds[] = {" `. r/ l7 u+ T
        {# Z# q# Z3 A% K; c$ X7 a
                .active_low = 0,0 G6 E. c2 Z9 t; t
                .gpio = DA850_USER_LED0,
6 Z, Y" O% S9 A: v7 Y: A) A5 K                .name = "user_led0",
6 U) O( Y' n2 s9 k% a* d                .default_trigger = "default-on",
- \2 d" o% @% i        },- u& I% {) W. P; B3 ^" p' H
        {
9 @! |$ P& a& _2 }* h# j3 W* b6 a( b                .active_low = 0,. j$ U# M! Y9 R  E
                .gpio = DA850_USER_LED1,+ I' T$ d# G( {# K5 w1 f
                .name = "user_led1",' o+ @% _$ T- N
                .default_trigger = "default-on",  P$ k# X( q' J1 w" y& }
        },
+ f2 ^# M4 j# F1 x% B        {
! L& y" ^( Y( w' S                .active_low = 0,
4 ?4 U, R, x- }                .gpio = DA850_USER_LED2,# [1 y* s* |5 X1 p) M
                .name = "user_led2",
9 {& s8 A: w5 j/ ^4 H                .default_trigger = "default-on",
0 m4 F( o6 {) ]. o( F        },
- B5 ?5 l( J& B# k. x        {
5 _- c6 N  `7 S- M) D. F                .active_low = 0,; J) }- F4 b$ C  e& c. f! j' m
                .gpio = DA850_USER_LED3,, z& T9 V' a  j, q1 h7 f6 o
                .name = "user_led3",8 z2 q! W  w% @7 Q) ~
                .default_trigger = "default-on",: b0 C" b/ c/ G2 H% _1 y' d0 V
        },
# G# f5 H/ w8 p7 v. o. {( g};
# z( |0 G7 f% t* M6 Q& ]& B* E, K# D  t, z+ |) q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) [" A1 j! _+ G4 I& s
        .leds = da850_evm_tl_leds,( w2 K# Q9 t$ R0 X5 O4 C9 o# A% ~
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 t( u2 [3 x- B$ q};
& i. W5 F5 T* t; q+ O/ q/ v: h% C, g0 I) u" Z' l2 g/ O
static void led_dev_release(struct device *dev)
2 I/ J' G, a* u- j) b{% ~0 ?1 H- P( o; q1 X5 D
};$ I9 R) B1 J. }" O$ ^" Y

; l" `; I7 C8 D  l8 c, _- U5 f! Astatic struct platform_device da850_evm_tl_leds_device = {
4 C% }# S# n3 Y3 X1 ~+ n        .name                = "leds-gpio",% D/ l. F1 \5 `8 s3 E) c+ s( m
        .id                = 1,
2 j4 O  Q% e5 M5 w1 p7 [& w/ O. c        .dev = {; u% O6 {+ w% Y
                .platform_data = &da850_evm_tl_leds_pdata,! @$ N4 M* r4 B) _# ?; ?* y
                .release = led_dev_release,+ a% i6 |' D  o- g# ?- C
        }
+ x6 ?- a6 Q$ Z8 ]9 E};
4 X+ q3 L: M/ S4 x0 A
* g/ S  Z( v7 x9 S+ V( Gstatic int __init led_platform_init(void)$ R9 a9 R6 X* o8 p( R9 f
{' b, V, U2 s4 C2 x8 b
        int ret;' B$ ~! L+ n# \
#if 0) q, T, S: p; w1 K  F- K  J4 J
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. ^! B+ C# w5 ?' L5 u2 {
        if (ret)3 c5 ]) F, p1 L* ~0 h+ D# O
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 E5 ]2 E# m0 g6 [/ x
                                "%d\n", ret);! c2 j- x1 ~, D2 u: e" Z% |& Z3 E; n
#endif# ^. J4 P' C6 L% K8 w. i
        ret = platform_device_register(&da850_evm_tl_leds_device);# v+ r0 ^1 p# k* s% @* @
        if (ret)6 Z, b9 [6 j6 x6 U4 f& A
                pr_warning("Could not register som GPIO expander LEDS");& o4 z; Y4 p# X4 @) }. R  I7 f: [
        else
9 e0 {( S$ i# y                printk(KERN_INFO "LED register sucessful!\n");
, e7 T0 Y0 [3 y: q! F  {* F4 V, r
7 R! C: v& g7 R! B$ x        return ret;
" U" E7 ]) `, H}1 X! T  V  d- ^+ Z% h
. f3 ~8 Y6 R7 f3 h) g5 L8 Z
static void __exit led_platform_exit(void)
+ Z9 l5 N6 G6 [' k- G  k6 s2 @{
* u% G8 }2 v2 [6 R- [, T; x" ?+ j2 h        platform_device_unregister(&da850_evm_tl_leds_device);% b/ n% L3 i# p- }# S6 w5 ]" b0 s8 t
) R0 O$ v6 K1 f/ w* P* ]) g, y
        printk(KERN_INFO "LED unregister!\n");
9 D  [% a  t! f; C, @4 J) [}- a) {/ f/ v$ L) R% b6 d# r# g$ m: s

- u8 g3 B3 F: ?  `5 ^+ Tmodule_init(led_platform_init);
' H! Q8 }+ ~9 c: B( tmodule_exit(led_platform_exit);! ?) W4 Y( S9 g9 t- L% i+ [

: v' X$ a3 H* M% M; mMODULE_DESCRIPTION("Led platform driver");# ?3 M. q2 k4 l8 b; k% |
MODULE_AUTHOR("Tronlong");
$ E* @8 [$ N! m8 ~! uMODULE_LICENSE("GPL");5 ]/ S: n% Z; }! D

4 P1 t" s& x- ?* V
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-16 22:03 , Processed in 0.038029 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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