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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
0 I. I8 K, r* \. V% g#include <linux/init.h>
$ H- \! p( H9 J9 [5 y#include <linux/module.h>
  v( D( d" T* {% A, i8 t#include <linux/kernel.h>
; k7 u& H3 X7 V. o#include <linux/types.h>
0 X: m) E8 e& G8 a# q6 ]#include <linux/gpio.h>& O6 ]: a( p  l0 x0 U
#include <linux/leds.h>
1 G) O  |: e' ~#include <linux/platform_device.h>( v9 [- m9 n4 r

$ d: J, a$ L1 k) S1 }#include <asm/mach-types.h>
, k( s- K+ u# s  ]9 s#include <asm/mach/arch.h>) y. w5 B2 O4 p, D8 l
#include <mach/da8xx.h>9 D* Q' C; \, j& H" E5 V5 Q
#include <mach/mux.h>
9 F) |( X4 I8 s! \, m9 y
( l$ P  p" c+ F#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
* e( v* f2 o5 x+ Q5 U#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
) M' R1 |, D8 K#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)+ T( r4 Y2 y6 u7 \$ V6 Q' G
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)& Y) j2 T- X* L
# ~6 j9 P) z3 q. ~
/* assign the tl som board LED-GPIOs*/
4 g: Z3 j8 D. K1 N; W) J" ?/ Wstatic const short da850_evm_tl_user_led_pins[] = {
' A5 K" u2 l% I0 i        /* These pins are definition at <mach/mux.h> file */( G4 |' A9 J% D, X( u9 m4 o
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ @7 J' P3 {3 Q+ ?  ]        -1! x* Q, a, M, f2 g7 Y# }9 S
};
. P- a8 y5 d$ P0 w; r' U+ U1 e
2 q5 `+ |6 Q; dstatic struct gpio_led da850_evm_tl_leds[] = {
, P5 k" _( h5 v, S5 j' J        {) c' `# Y' u1 w, v8 \3 a6 Q
                .active_low = 0,
, B9 @8 h* x5 M* ~! j" o, l6 B4 s& o                .gpio = DA850_USER_LED0,! E+ S$ f7 f5 c* g1 u8 x( d" X  {/ o
                .name = "user_led0",+ s8 C6 y7 H( C2 X- f
                .default_trigger = "default-on",
/ d( A7 J2 G3 R& D% ]        },
3 H2 J4 Q: N! v. K2 _4 N# H" E8 p: w% ~        {
; q' [- ]3 R. _# k2 Y( [                .active_low = 0,6 z( Q4 j2 s# k) J+ Z
                .gpio = DA850_USER_LED1,
4 t- H- S2 M, O5 c& ?# L                .name = "user_led1",
+ _1 C9 x7 Z- I% F0 u0 X. R                .default_trigger = "default-on",; E, F0 j7 R" ]
        },
5 x4 C( x- C5 o0 i( q$ W/ f        {% e1 N8 A2 L! \# V+ |
                .active_low = 0,1 I' _; O1 C, |- w
                .gpio = DA850_USER_LED2,. g; @) l9 {& @  }
                .name = "user_led2",- R/ o& V: N, }8 T
                .default_trigger = "default-on",
0 y/ @0 B- k9 I" n0 s        },
" b) a1 V4 \, q: |) s        {
+ F- V3 E# Q1 c& o( T                .active_low = 0,# r2 L5 z% s* E2 O
                .gpio = DA850_USER_LED3,
! v0 ]6 f) b! Q% u                .name = "user_led3",
# {( B# g/ h. h  T5 [9 f                .default_trigger = "default-on",4 X  t! t' k. D: E6 o
        },
: W4 X* H& E2 k) U};
2 Q' R4 ^" m% g- l, \4 k7 w
+ H- s# _1 X! R. cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, j, S' z! V' E. Z# u, Z6 R
        .leds = da850_evm_tl_leds,, R$ M. f3 Y, @
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 d0 H' M5 D4 B( Z, ]  V};( ?0 k; q$ u6 d& O6 @

( z7 |' K4 r' f+ {. ]static void led_dev_release(struct device *dev)+ F2 V, p" g$ k: e0 z. n$ v
{
& W1 s3 ]: `% E, H};
" v) {+ K7 n* F1 @- K( Z8 k: Y' a! Y6 L- Z. y" A4 y
static struct platform_device da850_evm_tl_leds_device = {
9 ^; I$ C& g8 E8 b9 i        .name                = "leds-gpio",5 z  L$ h+ h. l/ V. c& G4 p# }
        .id                = 1,
0 \, v( R& q8 A7 ]        .dev = {
& ^. P/ U; Z' [* a                .platform_data = &da850_evm_tl_leds_pdata,
5 \! c7 s, r* c  r8 Y" ~% K                .release = led_dev_release,# v) i$ ^# N6 z' b. E: b. |
        }# S( J( U$ l+ F$ Q6 _$ O
};) _$ O# M/ D& d# h( s( ^7 B

( a# p( ]# {5 N' U3 pstatic int __init led_platform_init(void)
3 ^- ]* W1 d8 @4 x; A, j( k; \& @0 I{  m+ R& l" k' J
        int ret;( i; Q$ s+ H- J
#if 07 C- O/ ~& O! x2 i! G" {
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 j( F' x, \& B$ u4 E) Q5 }        if (ret)
& G( a0 Z( ?2 L: k5 l7 N6 R9 W                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# x1 t0 L8 R: N+ U9 B
                                "%d\n", ret);
+ o2 ^0 w& n, J3 `8 A8 l4 i9 f#endif( ]! D, l% _5 F1 f+ D
        ret = platform_device_register(&da850_evm_tl_leds_device);& j# I6 L+ F, q# K7 O3 X5 O
        if (ret)* o8 n5 x4 }+ [0 y+ }: _& s
                pr_warning("Could not register som GPIO expander LEDS");2 m* j* {+ U. D
        else" g( V! n( ^" Q! F, K2 V
                printk(KERN_INFO "LED register sucessful!\n");
% U( A  \0 q! I
) s' a, e0 {) v/ W$ p        return ret;
' n$ i: j$ v" v( w1 J2 M" w6 N$ ~}
% ~$ O" V" T! _, Q" A& F4 E
8 r0 U  ?1 O8 e0 L( ~" q0 r! `static void __exit led_platform_exit(void)$ W0 @% E! J8 d; N7 E9 F7 f
{
+ |5 b$ H2 I' i, }* ]        platform_device_unregister(&da850_evm_tl_leds_device);
/ E6 Y, @5 Q0 }. n9 j; u: @2 `* ?8 K% m0 ]! T" e" B
        printk(KERN_INFO "LED unregister!\n");
7 w7 D: S( C+ ~2 {) Q; m+ l}2 B4 h! @0 f+ Q% U+ ]- E! m
9 y2 d9 n5 ^0 c6 O/ a- @
module_init(led_platform_init);7 X2 Z1 @8 t7 Z8 a
module_exit(led_platform_exit);& ~$ e5 h+ T( C
" Y' h+ y( e3 L' Y2 J5 c
MODULE_DESCRIPTION("Led platform driver");* C8 [, M7 H5 _
MODULE_AUTHOR("Tronlong");6 i1 u: y, l4 i, k4 o" Z
MODULE_LICENSE("GPL");$ I$ ]/ k  G; h; s- e6 T
5 A, q( s' i+ X  S0 _
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-6 02:29 , Processed in 0.040521 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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