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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
1 H; h, z0 k  ~; X0 Y#include <linux/init.h>
- V7 R- y0 J: Q% j#include <linux/module.h>% t: d: q" I$ k! `
#include <linux/kernel.h>
8 z5 b6 {! O: Z7 }#include <linux/types.h>. X4 V, y6 D) c: h+ f  {3 Y2 s" U
#include <linux/gpio.h>' ?% h! D( u/ U& p9 O" u6 [, r
#include <linux/leds.h>
( }$ ^8 V. G. N% ]! l- u#include <linux/platform_device.h>
/ E" x4 }) O0 f0 O; i. {' }' S7 j: t* c& y
#include <asm/mach-types.h>
3 @7 y5 q" y2 o) |9 i4 z1 x#include <asm/mach/arch.h>. N! Q# g( i1 A0 G. @* R+ e- r, J
#include <mach/da8xx.h>4 E& h5 V* T& O
#include <mach/mux.h>
8 @7 _7 n# N& G/ g! l, \% M5 s, G' |+ _9 y  E# p6 e- z
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
8 X2 X  B& A( g, Z" j1 }/ N3 b#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
, U9 F% b7 H- z% ?) Z#define DA850_USER_LED2        GPIO_TO_PIN(0, 1): w8 t2 e' d5 a) b' G5 u
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
# j) p/ h0 S; [( J! H! i+ P' K* o7 @- t, i# M
/* assign the tl som board LED-GPIOs*/
5 m, o" c: ?# Rstatic const short da850_evm_tl_user_led_pins[] = {- {; O% V* `! S4 N6 s
        /* These pins are definition at <mach/mux.h> file */5 M; h4 O: F: ~% y
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 Y; ^$ G3 g/ f! M4 J" P  W1 ~5 c4 o
        -1
- Y; j- T& k7 K};7 I* u0 f! i8 j6 Y  A
, [. n0 U& b4 }
static struct gpio_led da850_evm_tl_leds[] = {) m( t) L$ W9 ]8 w" q3 d
        {
* W+ V8 ?" b4 B3 ^+ }/ g+ h' p$ N                .active_low = 0,/ ?( d# S! z7 j% [
                .gpio = DA850_USER_LED0,
+ X0 S) D3 `! |9 t) e; L: i2 `1 f( |& @                .name = "user_led0"," I& e8 }8 P0 d! l: v* C2 R
                .default_trigger = "default-on",$ C  h2 B3 G0 v1 U7 {! p4 q
        },
3 h) y7 e. Q0 ?- _& w        {
! V. ]# D& ]9 s2 W                .active_low = 0,
' x; a$ N6 E; e- o                .gpio = DA850_USER_LED1,* b" Y' q4 b5 y& s1 y9 U
                .name = "user_led1",% Y# h( X- y: P/ R5 a* `
                .default_trigger = "default-on",: W' E/ N' l4 o8 j% w9 ~
        },5 @" o# M5 W* L- r& j% f8 X$ O/ B3 U
        {
8 g9 V6 I8 n; W7 G  ?* R                .active_low = 0,
/ G. D% D, o, J/ f  t: a6 U                .gpio = DA850_USER_LED2,
& M# a+ C! j2 N: ?  |: q4 A' q                .name = "user_led2",# d7 i- N, q4 q% J9 g
                .default_trigger = "default-on",7 r& [0 C, _" @6 B) w! K) N
        },
# x; D) L3 j8 j; h7 `# [        {
! ~6 e2 E& H) H( U( G                .active_low = 0,- `$ {) g  v* V
                .gpio = DA850_USER_LED3,
. l0 L* w& |7 C- R6 W% }' v                .name = "user_led3",
6 F& U  w  t. j% o# i8 [                .default_trigger = "default-on",' X1 e( Z1 P4 j% P
        }," ]) Y5 ?$ u! e0 z$ s
};
6 }- V/ B, _$ s9 K/ S
! H# h' s" {0 l6 X- v7 R. }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; M3 m4 }9 _6 d6 C7 M# ?' ^
        .leds = da850_evm_tl_leds,
; i9 c# p; l, G' j$ i        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: @: Z  C6 R, \# [1 v' u3 ]- {# C
};% D7 n+ j  S) ~3 W. M, ~3 r, O. f

, {/ V# C6 q1 L) S: ~) ^$ bstatic void led_dev_release(struct device *dev)# d) ^/ r3 C9 k6 s( a
{2 A7 i3 k8 `1 ?% S) w/ w
};, t  [' l+ M. F: g

" ^; ^! k, u2 K$ C  w; Rstatic struct platform_device da850_evm_tl_leds_device = {; K4 |/ ~3 C* s2 ?! i: \! h
        .name                = "leds-gpio",$ D  [/ p3 M; k7 P' d- J2 o6 A. Y
        .id                = 1,
; r# y0 n/ \& t) V0 m( @# V        .dev = {) v- i9 F+ o9 S" I2 Y
                .platform_data = &da850_evm_tl_leds_pdata,
* G% M+ L6 C$ r& G0 w                .release = led_dev_release,' [( m' E9 x; Y; L0 U3 M
        }1 h0 Z$ s  [& O' D* o
};
, O4 H) `, n/ z* s+ j$ ]8 `  N4 A2 j+ z: A
static int __init led_platform_init(void); s8 _2 E! v7 q2 |9 w0 V
{7 v( e$ m0 N1 m- O' s% A3 Z* N4 q
        int ret;2 c, k$ T+ `8 c, i) M/ v
#if 0
; k6 t4 E6 D' K- v) J        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. Q. X" j5 h; i
        if (ret)6 z4 i  ?* K  ~) x$ f3 G
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* n/ k- M9 C' r
                                "%d\n", ret);- [3 K/ `* Z$ s& Y3 M
#endif
$ s& @! \$ _. l  ?% I4 |: Z        ret = platform_device_register(&da850_evm_tl_leds_device);
; u9 b( n8 d$ ]+ _8 O& ?( F        if (ret)$ V+ u5 C. ?9 e. {! d+ L! d
                pr_warning("Could not register som GPIO expander LEDS");
% n" s) b5 w' _) C1 g$ R: B        else
* C/ z8 [' Z9 P7 }( J  o, c: x) u' F                printk(KERN_INFO "LED register sucessful!\n");& Y0 d% e* p! y- C; c
3 L) {. ?3 A4 W/ f2 M
        return ret;
9 c4 N/ I. `; A2 C! }# `! v9 p}
% _/ |, q8 ^0 P& i+ F. }' v: Q' C% v  i& _0 m
static void __exit led_platform_exit(void)
2 V. x" Z) C# u2 g; f; c! |{
: P" b0 I; ^, ]( ]' M% x' a- ]( K        platform_device_unregister(&da850_evm_tl_leds_device);2 L7 U4 s; y" t$ E& |' M
7 D) U' x" Y# l3 O; p. p! L& v! y
        printk(KERN_INFO "LED unregister!\n");; U/ x" J* Z0 D, u, }
}
# U. g: H6 ^. U, C6 f" Y0 o$ U% l2 }! T
module_init(led_platform_init);0 P; L( W7 r2 u' A9 i4 e
module_exit(led_platform_exit);
0 C9 c2 ^" l' K$ l8 k+ W; v; k5 T! O- r# m
MODULE_DESCRIPTION("Led platform driver");! ~2 U4 @0 ^- h/ E9 W/ J
MODULE_AUTHOR("Tronlong");
' n* p4 K# X4 \2 C" pMODULE_LICENSE("GPL");+ [$ }; D9 A9 b2 F: t3 B

5 E( b# w( u5 ?* L# g' d! D) Q% I
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-10 08:01 , Processed in 0.046121 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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