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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% z( _  B8 i9 Q
#include <linux/init.h>& x& O7 U9 H* d/ q
#include <linux/module.h>7 k( l0 a+ U- r2 w
#include <linux/kernel.h>6 Z0 h, x; N- K8 C! n6 ^' [% q' V
#include <linux/types.h>- H  l& D9 G, d5 A
#include <linux/gpio.h>" n) x6 L0 v1 m- A
#include <linux/leds.h>
' g+ }! V# q0 U$ H( X$ c; J$ ~2 |#include <linux/platform_device.h>
- r$ b+ s/ f: J7 x7 L6 l. h
. C# Z2 R$ h: [' |#include <asm/mach-types.h>, {9 e  Y5 E" s8 C
#include <asm/mach/arch.h>
! T0 x7 B+ n- Q+ u0 V6 f#include <mach/da8xx.h>
* D% h' Q; z: u( U( V  T#include <mach/mux.h>
4 Z5 Z; w% C* }; B3 L7 d  C6 z
. {; J0 V4 x7 {#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)! k  {4 ^+ T4 t( J% d3 Q
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
; a+ G! j$ b8 g$ h#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
# h3 J: |: s& r4 Q" ^, D8 g' _#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 I* W6 [9 r% V! m  E; _
/ q# v% s- e* ~' u
/* assign the tl som board LED-GPIOs*/
) N9 q' ]4 \5 I2 Vstatic const short da850_evm_tl_user_led_pins[] = {
4 R/ f$ J4 i9 b7 r( T! C% q! p/ H. r        /* These pins are definition at <mach/mux.h> file */+ y. |4 U2 P: h' N) A8 }9 i$ V
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 X& r' `$ L9 h3 Y* E7 O
        -1
, n! a* J8 G3 M9 d- {, {};- l+ k2 v/ o; \! I/ K  |
3 I( x, [! }& L( {9 R$ u5 E# o$ Y( {
static struct gpio_led da850_evm_tl_leds[] = {
. u; h6 G$ i5 I" p; u/ N        {
7 G9 v3 u8 `3 p# h. J( N7 N+ S) C                .active_low = 0,' c. E% W' x9 O% m7 H5 g% m- e
                .gpio = DA850_USER_LED0,
2 I: G+ b6 f% y+ j                .name = "user_led0",4 E3 U8 y- r& O, ]5 e' d
                .default_trigger = "default-on",; ]7 m% R. s7 H3 R
        },& F5 L! ~6 u: {9 h/ B$ ~, {
        {3 i* g! Y# I) l) `9 w( d/ E
                .active_low = 0,- h' q* T7 P& p7 b( T" f' @  W
                .gpio = DA850_USER_LED1,
. U! F! l4 a: e. l! ^3 V                .name = "user_led1",! U- u/ r+ C6 |8 ~
                .default_trigger = "default-on",  \6 g3 g) c1 i3 k8 f, \
        },
2 }5 \. D2 u9 b% a( \        {# b8 o4 D( r4 ]. G6 Y
                .active_low = 0,
+ ^. m! ^) V4 X3 y2 e5 Q& T                .gpio = DA850_USER_LED2,% J& v8 }! U, `& B, M6 N: F" _! D
                .name = "user_led2",
$ z- V- F4 L. b3 D* C                .default_trigger = "default-on",
. I+ I9 z  Z1 d8 G: t* a1 C: h        },! W" b9 ~/ s! d
        {
7 ]8 @* a* A/ L7 E                .active_low = 0,3 s. E1 ]* C4 H/ I2 o
                .gpio = DA850_USER_LED3,
* e. F% `2 T) y: w3 c$ V; s: J' g                .name = "user_led3",4 e) r$ b1 e* Z* [
                .default_trigger = "default-on",) i  X7 u0 f/ m- {3 I; c7 {
        },
  U& R& N, r, T# u( x};0 x8 T( E, b% P
% U0 H  B/ Q! S! {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: R) H6 {- A" R+ U4 F( e0 p* `9 O        .leds = da850_evm_tl_leds,& L" v3 _4 q2 `9 S4 W
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& W* Y% g3 e: y' U/ D) B};& r+ X% q" d+ v* e5 J( R! z

( v0 ]* v) h" h; q2 Dstatic void led_dev_release(struct device *dev)
$ d( Z' @7 q% v) i3 n* y8 r{' L0 l. _: p& P# C0 p4 B6 S
};9 j/ x4 h( [- h- T* g3 O1 I
8 {4 C0 S( Y: w
static struct platform_device da850_evm_tl_leds_device = {
% `0 }2 J' Q! W- B# V        .name                = "leds-gpio",$ c7 h; @8 u8 R( x  c% y$ r
        .id                = 1,
0 |: D6 h, `0 Z        .dev = {2 A0 X  b$ @& h# q
                .platform_data = &da850_evm_tl_leds_pdata,
" n* H! s" ~/ b) X0 n9 z                .release = led_dev_release,2 t  Z& ?8 S% W: X) z
        }" y% K6 C% p- a8 ~
};5 [" e+ g6 o: b  A7 e8 x
: T' P! K/ O/ V1 s
static int __init led_platform_init(void)9 t2 a! d' d9 b- Y$ ?) ?
{
& q: C- E. i- }3 U5 L- j; o        int ret;
" O: H/ V/ g& H, i: K1 L7 Q/ [# o#if 0# N6 S$ ?" s! s
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. g3 ]1 |% h5 ?4 ^# ?
        if (ret)
' l5 ]- r1 T9 ~/ U                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 k6 J+ \5 Q2 G3 Y' s
                                "%d\n", ret);  x# O5 M! D& N, e  Y
#endif  n/ e5 ]% F& O; c  E; W9 q
        ret = platform_device_register(&da850_evm_tl_leds_device);$ m* P- }7 |4 e  j# l0 f  \% K5 x0 A
        if (ret)  e! c9 q" e5 z: S
                pr_warning("Could not register som GPIO expander LEDS");7 T* T# E# U( F) m
        else
7 i% n7 O( a1 W! I" d6 w                printk(KERN_INFO "LED register sucessful!\n");
4 R+ \! R2 r: j
$ [6 W7 C$ {. F  ?6 t2 `1 f        return ret;0 M: }3 I# a. R, M" ?1 Z9 o0 ]
}
" Q% Y" a  E" w: w/ l% j6 l/ S1 ?/ e5 U/ B- A9 B$ a
static void __exit led_platform_exit(void)
) E0 q2 r; o& t! j2 {- k9 t{
4 N& ?* H( t0 v( y, F+ i& R        platform_device_unregister(&da850_evm_tl_leds_device);/ N+ R' u' p8 g+ t" R

- V/ K" o, e. \5 D        printk(KERN_INFO "LED unregister!\n");
$ n0 o+ L% `% x6 U}: e1 ?1 h$ T2 N: N

, `7 D& f. N6 g1 ^" `6 fmodule_init(led_platform_init);" J8 P2 x% c" ~. t
module_exit(led_platform_exit);
8 Z' @; v! U9 q) Y5 a
, V: I  ]3 g1 C: Q8 V! JMODULE_DESCRIPTION("Led platform driver");
/ ]- I4 _/ y4 n' [& k. SMODULE_AUTHOR("Tronlong");* V4 C5 B( w! |* T7 d: R
MODULE_LICENSE("GPL");
; s5 n" Y% r6 n* W( q& V( t
' n: u# R8 Q) z2 x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-10-9 05:33 , Processed in 0.037865 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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