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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
7 K; X8 k1 |; K#include <linux/init.h>5 m  U2 ~. w' E4 w: d9 q6 g5 _
#include <linux/module.h>) Y$ }! q+ G% i, }! g! o/ o
#include <linux/kernel.h>$ ~+ a1 v2 Z0 }$ ~6 k7 ^5 _% ?
#include <linux/types.h>9 Q' l" O, E+ G1 \; v
#include <linux/gpio.h>
/ `6 u( W' C# P, Q/ T#include <linux/leds.h>" H, \/ P3 @4 W+ j. _
#include <linux/platform_device.h>
& M4 O& I& b5 r3 @/ r9 P5 z5 u7 N* S- V3 h  C
#include <asm/mach-types.h>
6 v+ t/ K& Q2 r! G% Z& s#include <asm/mach/arch.h>& y8 |( P6 O, p' s8 \; T
#include <mach/da8xx.h>
5 j* l$ d/ a9 {+ w( O2 v: C5 {, h#include <mach/mux.h>4 V+ d( N2 g$ ^

- @; q* J! Q! C- v; [3 o* E#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)  l: g/ _7 V$ v; r( w6 t
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)) b' v# T' }  r( G) w# @
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
. ?* }; x+ O* U  h) i$ |' h#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
9 B* |& [; @: }0 H1 ~7 b9 z% y. v) K  s% ~5 ?
/* assign the tl som board LED-GPIOs*/
: y- ~1 \0 M+ I+ z4 |# u1 Vstatic const short da850_evm_tl_user_led_pins[] = {
% A( A+ D: C1 ?0 y1 P7 l$ T! ?        /* These pins are definition at <mach/mux.h> file */
8 p( Q- ?- j7 q6 P3 c. t$ f* T        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 @$ Q$ I2 M3 m9 k
        -1
. I+ o) ]% i& g* o};
  `. j: ?, h; |# V
5 f( ~6 R# i+ Z; I7 f+ \static struct gpio_led da850_evm_tl_leds[] = {2 C9 d  T5 N* \0 o
        {
) i2 E+ J7 `4 V7 V6 z8 {                .active_low = 0,8 c& ^$ E9 y" V" }
                .gpio = DA850_USER_LED0,( Z- a" y/ }* H+ `& R
                .name = "user_led0",
  P) x6 Q. b5 V7 C+ d" }# N- g                .default_trigger = "default-on",( ]% q- ]: F  Y
        },
3 ]3 Y7 u- U$ C2 w7 E* O        {
1 E6 U8 x5 E; t0 o( G                .active_low = 0,
5 W9 q: n; j% N; V                .gpio = DA850_USER_LED1,4 J" Q9 o+ g7 V" d2 q, ?. l
                .name = "user_led1",
7 y% i4 Q! d& K- k9 |                .default_trigger = "default-on",$ ~5 s8 u# w+ x+ z5 u- E
        },
% C5 J; v3 g4 Q1 {        {% U7 G- w& W: E5 u
                .active_low = 0,
/ E$ Z2 y0 Z$ o9 F" I9 _! I                .gpio = DA850_USER_LED2,+ z% F( E/ L" m+ x4 w: _6 b' |
                .name = "user_led2",. t& a5 Z  v- l' Z
                .default_trigger = "default-on",
5 w% @. v9 e0 Q& Q        },
) T- g  ?3 J8 d; D# L$ }3 u$ j        {5 l: z4 M/ l  X0 W3 c& O' M8 i
                .active_low = 0,% L. r; ~/ o7 p. }% C
                .gpio = DA850_USER_LED3,
* z- a; h0 f5 l5 \' E                .name = "user_led3",
( [0 G( V6 [8 {9 K8 E6 G                .default_trigger = "default-on",
; g! Y5 z4 j4 B/ R4 v        },* |4 l. F1 W" w& H4 n
};
2 u( G3 w& o- o- U. o, }' U5 z" X0 `2 G. Y' j9 }/ O# T  t7 V1 e& A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ t2 a5 i3 i' O+ L        .leds = da850_evm_tl_leds,
  H) n# I' F% C& B        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" x4 U' V8 R% J};6 ]! c0 |! t' t7 i2 W8 \& H
4 X. {4 b$ X( x2 F$ d- ]/ A5 i1 I
static void led_dev_release(struct device *dev)! z9 N$ P9 M+ e* J  E6 {
{% Q: O/ `8 w+ y+ X! ?5 G) x
};. q  [0 ~# X: s: S6 N  j

4 V& ^# L' [. s  g4 mstatic struct platform_device da850_evm_tl_leds_device = {
+ Q& _" R6 b4 A5 j  [        .name                = "leds-gpio",( m! X. _" F& V! |4 L$ X
        .id                = 1,
) r& c6 s( o9 e* g        .dev = {
0 A( G" t- Q/ p5 i                .platform_data = &da850_evm_tl_leds_pdata,
! m$ y1 U9 s6 E                .release = led_dev_release,
; @; u1 r4 q( a$ c6 l' H0 F" m        }
: r& ]' s9 z9 }' I/ b+ G};
. }; m7 z( S. O# ^3 v( m- Y; x9 B8 t4 ]) n
static int __init led_platform_init(void), i* ^" I: `% z9 }' l2 v& g* S" ?
{
, F  ]9 P1 a  g        int ret;
( N: y: x8 W* S" g' T. X0 C4 b. r0 u#if 0
7 i1 g: ^; `* u  S! e1 H3 }$ x9 {        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! u- r$ U6 j  G- f        if (ret)  E- K3 o  E9 o  c
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 i  h6 @" n& y) Z0 k7 w* I                                "%d\n", ret);0 Z4 ]* }! j/ ~: v
#endif- Q1 u0 Z# s, G1 e9 F- F9 r' Q
        ret = platform_device_register(&da850_evm_tl_leds_device);! b2 n8 O2 J( y5 U) e
        if (ret)
) J6 f9 c) o$ `, {                pr_warning("Could not register som GPIO expander LEDS");
" d3 g! [7 ]. {* Y: H- `" R        else' k7 ~3 k+ V8 G0 f" g: y: u( X
                printk(KERN_INFO "LED register sucessful!\n");
) v1 a4 W$ h: G! {8 @* `0 X% P( o, e+ b0 j% ]$ p( e
        return ret;6 u# g* n) Z5 \9 b
}9 s% @8 Z' \7 ?  a9 n% e8 y
2 c% p' G( R. P* i: y3 c
static void __exit led_platform_exit(void)  e/ e( Z0 |4 G) V/ W7 w, o
{
8 s& H% A6 _8 D6 K        platform_device_unregister(&da850_evm_tl_leds_device);  ?  D! E' V$ H7 `* _
$ V* ?/ _1 H+ P" E4 c# U
        printk(KERN_INFO "LED unregister!\n");
5 ~; A% V/ r0 q1 o6 \- H: \8 `% ^7 `}
; u" h, ^9 @  W& q6 W2 e7 d+ M# m
module_init(led_platform_init);7 G' Q# o, M7 d4 d( j/ y
module_exit(led_platform_exit);
9 g5 n) W' Z2 f4 I( c2 B: M) r
( I3 Q0 J) V  ]  B1 k1 \2 s5 |MODULE_DESCRIPTION("Led platform driver");4 j; Z" a9 I! o- L. r
MODULE_AUTHOR("Tronlong");# z% l% G+ n9 f
MODULE_LICENSE("GPL");8 E9 `* Z* r) R* G7 w5 F* h: m

& s/ U/ r  C, D* K  Q6 b: S
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-6 08:17 , Processed in 0.044914 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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