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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
- j; m6 G6 |5 W) R$ O. t$ w#include <linux/init.h>0 n8 d5 [. j6 Y
#include <linux/module.h>
) m. R( T4 y4 X. a  U  [3 U* M6 x#include <linux/kernel.h>
4 n7 ]4 ^& m' y! L" m#include <linux/types.h>5 Y" H5 D# S* p! \' E
#include <linux/gpio.h>7 J/ g$ s- ]  g  L7 S; ^" k" y  \! O6 [
#include <linux/leds.h>
, @; ?7 M/ e, K/ K0 F$ I& [#include <linux/platform_device.h>9 S8 s' Q7 ^& G  U
1 Z% `9 e4 d4 u
#include <asm/mach-types.h>1 w% F' P( e, P  P+ N3 l2 ?
#include <asm/mach/arch.h>
  h3 d/ r* k* Q#include <mach/da8xx.h>
: |$ i, j) `2 S#include <mach/mux.h>5 b  ^% L$ o/ a) k5 ~
1 _4 o7 o# ^+ m9 O
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)- U' [" q4 B/ E3 u8 h
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)# i# l9 m7 A' [" m  r
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)" ^3 q/ X- C2 v& x2 L- t: k$ E
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2): A0 s+ C9 q, m

$ |" K% K" L! z7 I& J/* assign the tl som board LED-GPIOs*/
9 C4 Q, H, o" h4 R' C; kstatic const short da850_evm_tl_user_led_pins[] = {& C7 r* d) {" r; [- c% j
        /* These pins are definition at <mach/mux.h> file */
5 O5 S) C- c' D- a% ]; w9 h- }+ ^        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) V+ T/ F: i5 d5 w# n4 O
        -1
9 k* j; ^/ C$ A9 g5 y$ l};4 W8 @# c; ~. ^$ f
2 _% ~, M7 h& M; A/ q; u
static struct gpio_led da850_evm_tl_leds[] = {
0 Y' O7 C7 x* f# i        {$ Y- D+ G9 }% c
                .active_low = 0,
/ ]$ s$ P- g+ [' Z# L1 G! i                .gpio = DA850_USER_LED0,
; V: F% P. o/ d3 b5 b                .name = "user_led0",
9 H6 `' b+ J, e6 Z8 w# f' f                .default_trigger = "default-on",
6 [& H2 n8 s% c7 N        },
6 M- {8 @4 ~* c& U- {/ G( ]9 F; i. f        {8 Y# b) z+ Z% ]5 F4 C( w5 k
                .active_low = 0,5 O# W, J5 H) _6 V
                .gpio = DA850_USER_LED1,
, f7 r% G' k/ ?                .name = "user_led1",
/ \6 ]1 j/ i1 U, M( |) O# j                .default_trigger = "default-on",2 c# z( S( b# F' d, L, G/ |" z
        },: ?* o4 F& W, C# J3 \
        {
& s  ^( S+ T" m: z9 j! R                .active_low = 0,
7 i6 A5 `- K' t4 B                .gpio = DA850_USER_LED2,& a. p0 d& L9 P& l7 J
                .name = "user_led2",
7 Z- E0 @7 Z# e                .default_trigger = "default-on",: L) g) \. e% y+ c% c
        },1 r/ ]6 P: f$ e% [3 \8 N
        {
) W/ i( X3 M  C. z6 t% w% O                .active_low = 0,
7 R' [* F  X) J2 X' y1 o3 R, N                .gpio = DA850_USER_LED3,* `( ]# @' Z. Q% x
                .name = "user_led3",
8 K- Y( r8 y' H9 Q0 x# G) w, y                .default_trigger = "default-on",
3 i* x5 \4 c6 D3 o( N& _        },1 I0 P" q1 u* L" O; Q3 x
};  T$ d, i( _" j  i8 ~

1 L3 Z* a4 d+ Q+ B/ ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 T1 P, p* R: c- }' s
        .leds = da850_evm_tl_leds,
, F! {4 s+ ?! m, B        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 W8 m8 h" o% c$ \; h};- w3 V7 B; z1 C" K

# q" z, {3 V# i2 B+ H: F" Qstatic void led_dev_release(struct device *dev)
8 ]. j. O, W* X0 W, T* D3 _% y{0 |, c. u& y' a( l+ b, Q
};' c( [. T4 n; A8 g# F
, |/ C3 x; m8 M
static struct platform_device da850_evm_tl_leds_device = {
% \: G; _. q  j0 B* B* H        .name                = "leds-gpio",
0 [( Q' e& a5 R8 b5 b1 Z( \% I        .id                = 1,
& P* T0 I! J6 I! M1 C        .dev = {' w( b, [( p& B  J3 b
                .platform_data = &da850_evm_tl_leds_pdata,
; s; x) T# b2 m( e$ Z& ?) l                .release = led_dev_release,
( J+ {: w+ |5 x! G  b- G        }
" x$ `5 _; @* H};( r( x' N% k7 f4 n# w

7 o7 V* `: T* S4 f1 Q* Estatic int __init led_platform_init(void)! v% q1 [0 [0 y6 ~
{+ e7 G- o3 o4 H4 }8 D) B8 g
        int ret;  u2 p: x8 d8 o& N4 C; r" h
#if 06 J# w; i. ?( S
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ F. N' `+ I- j7 t& T$ K# S$ C9 ?        if (ret)0 c# Q0 [- Y" y- c( d* p
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' }. q3 l3 X8 R& m! m                                "%d\n", ret);) O, Z7 ~4 I% M+ V! s
#endif4 t4 z" c2 P& ]9 c1 d% N2 A
        ret = platform_device_register(&da850_evm_tl_leds_device);: N' _4 F" [# i* C! f1 q! \
        if (ret); _  o: b3 H( ?! L& X. @
                pr_warning("Could not register som GPIO expander LEDS");2 p& }$ N) ]8 A! O$ ], K; V
        else1 _5 n" ^; D( \+ U
                printk(KERN_INFO "LED register sucessful!\n");( h; h7 g3 Y9 t+ I7 Q
/ ]' W8 x' i3 W1 I1 t  |( m$ V/ f
        return ret;$ Y' W6 L# i& Y; `
}
# O+ [2 q+ V% e: k. ?% x, p- {- g/ C# i% Z+ x
static void __exit led_platform_exit(void)- L7 a6 F% g  ^2 g; v
{
2 l/ S& c+ a. ?  g! \8 {' h- D        platform_device_unregister(&da850_evm_tl_leds_device);1 {; V$ c' h; f" S* x3 o% \

5 A9 ~. D  I  j9 [; S+ L        printk(KERN_INFO "LED unregister!\n");! V( w" ?# e, c5 u) n3 J; l+ m
}1 f" @  E3 z$ [9 S) l3 L0 l! F

9 z! {) G" q% Q/ Nmodule_init(led_platform_init);
: X4 f* I& i* A# k/ I6 ~module_exit(led_platform_exit);
, X8 O. s2 J: Y2 o6 U, c/ c
; S: R( j: l% s) l$ n& X9 p" vMODULE_DESCRIPTION("Led platform driver");
) z8 T$ Z* m$ mMODULE_AUTHOR("Tronlong");  ]( Q( c2 s' B" u  c; {* d
MODULE_LICENSE("GPL");
0 J. A' C# ~$ F) l% V8 j% \) M4 Z$ A
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-9 10:49 , Processed in 0.039413 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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