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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
4 I* {) s' A2 z& @. q% h% C#include <linux/init.h>
- ?8 X2 i! U% S9 d* \3 i#include <linux/module.h>7 q1 N4 O1 z) e8 e# E  Z
#include <linux/kernel.h>
( w( [  ~- i$ S* Y% v#include <linux/types.h>
2 E5 t1 S/ R5 u/ ^#include <linux/gpio.h>' Q* P" i. O6 p) l
#include <linux/leds.h>  y# O- K9 T0 J
#include <linux/platform_device.h>( j+ l# S* a' X/ J7 z  G

. O, A  J& G. G) I#include <asm/mach-types.h>
( l) x# W6 Q  I" t6 c( M( D& n#include <asm/mach/arch.h>
3 ?8 W. t( Q1 y  U* b, B% g* C#include <mach/da8xx.h>
) Y* S# f, W/ v* F9 T#include <mach/mux.h>0 N4 I3 u0 ~* `6 N2 N4 N6 F
6 m+ Z; d$ F! l1 v! e0 z. i, D
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
3 I  _+ E# E2 J% h#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
. _( a' a" y2 }" e5 X#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)* e9 r- b! o* }3 E
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
' x1 j7 ~, K7 G; T/ a2 h
5 d4 O) i0 m1 R  c7 l* _' a/* assign the tl som board LED-GPIOs*/
. h0 e; M$ @. Y# V1 A$ {static const short da850_evm_tl_user_led_pins[] = {
6 @3 }7 r, A& o" J5 \) A        /* These pins are definition at <mach/mux.h> file */5 V  x" B" i' Y8 V0 B2 i, T$ ?
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 q- t9 Z) k5 X: B        -16 R. A  W  Z- r% G. U% @
};3 n* ]" ]7 {: ~7 R/ I9 M
( U2 L6 q/ `: o( w+ o  k* t: S+ S
static struct gpio_led da850_evm_tl_leds[] = {
" A6 T% x4 p2 O! q% Q        {
% \  c9 }% K; ?% m9 ]: A- J                .active_low = 0,1 V! g. [" e, g9 t. w$ e
                .gpio = DA850_USER_LED0,4 u+ u4 J" h) i, z) m
                .name = "user_led0",6 B  ^+ U$ y" W/ t% ?" \2 N
                .default_trigger = "default-on",/ r% ^/ A7 u* j5 a: c
        },
4 Z4 p! C+ i: a, ~        {
7 B) M+ ]% G; Y- V) e5 F                .active_low = 0,
# D) J: t, o8 N! C8 M5 d/ d                .gpio = DA850_USER_LED1,
# g) e& U, I7 w- f                .name = "user_led1",
0 q6 W8 I0 ~4 r+ m                .default_trigger = "default-on",
3 I( f9 |; {! n! M% j        },
' m7 l) y2 U' k        {
# W( G( V% `1 o& T: t                .active_low = 0,
& B4 ]* W0 q1 Y( \                .gpio = DA850_USER_LED2,
+ h; X; u) B! n                .name = "user_led2",1 O7 i% v' X' J  F) o
                .default_trigger = "default-on",
, B: A4 J0 O8 G# A* E, w2 L        },& @4 }; q1 E2 K) \
        {# ]: @! F( Q! y+ j4 G9 K6 K$ t
                .active_low = 0,% G- ^2 ~1 f' K+ I5 p
                .gpio = DA850_USER_LED3," t* p8 `: U; I/ ^% ]1 M
                .name = "user_led3",9 [% }3 g% E+ w4 g5 z1 H! x
                .default_trigger = "default-on",/ _% a5 ?2 x& ^0 l$ |( k6 j" A, J! P
        },8 U" L; \" l9 }
};
3 ]# s! ^0 k5 X# O2 K0 O/ I/ b6 ?9 r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" r2 J) F' c4 O) G: S2 ?$ w+ M4 D
        .leds = da850_evm_tl_leds,& }1 ?+ m; v1 |- h+ E5 M7 h
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ J3 F: P) w- `! v' I3 _% w  Z( x- Y) _};4 m) V6 j  d1 o' `! [

1 s- `4 o, U" ystatic void led_dev_release(struct device *dev); E$ s2 I- V- j* S
{
* k5 F. K% ~4 o1 t+ G};
) e' [; [7 K# r* e6 K* Y
3 z7 `: M: G$ \6 _4 N* Jstatic struct platform_device da850_evm_tl_leds_device = {; B8 a! d0 u7 b0 [$ i/ p
        .name                = "leds-gpio",5 o7 ~+ u2 h5 r) k7 f3 J
        .id                = 1,
3 \0 u+ e8 i/ F; Z' p/ X  {        .dev = {
, l1 }8 r5 D: S                .platform_data = &da850_evm_tl_leds_pdata,) x8 a, W. f" D" V& r; O4 r
                .release = led_dev_release,! T5 w3 b2 m( R
        }- ~1 I/ @) i6 w3 L; X0 L
};+ d+ c2 b  g0 Q/ O
8 c! a5 |& Z1 M' g2 Z/ c" |
static int __init led_platform_init(void)0 D6 F9 t/ C. o2 _1 E8 Q5 F
{+ D: O* M- t0 }0 w( ]
        int ret;
; T# b$ i' t8 @0 _) }#if 05 C( M- U( c  i7 F3 _8 Z3 d1 ?6 H* G
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 Z0 |3 z$ [9 A/ m4 T1 |/ i7 b
        if (ret)
/ K0 h0 @0 L) }% i  R                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 K3 A5 [( `: B  X; y1 M                                "%d\n", ret);
& Y9 e0 M$ o) m' K8 }5 f3 [#endif
& z# z9 b$ ], o3 n- G        ret = platform_device_register(&da850_evm_tl_leds_device);
6 _* M3 \+ f8 S1 t  E4 _        if (ret)
9 g% c' y" t9 X  b$ e                pr_warning("Could not register som GPIO expander LEDS");/ O* K$ w: A2 m( h8 o$ j1 E6 {
        else4 q* t& T# Q( }; l- l1 j
                printk(KERN_INFO "LED register sucessful!\n");  w6 G/ h5 k! x: Y, T

  a2 B& Q5 t; x        return ret;6 A3 |& H$ O3 w
}
- @) r4 K% ]' S9 ]8 u( f0 y8 v. z% t% G7 d5 a" h7 a
static void __exit led_platform_exit(void)/ J, I% i" W/ o4 y3 `
{, r9 @0 R$ A# n+ E' L, K1 E
        platform_device_unregister(&da850_evm_tl_leds_device);# r1 P9 c1 H- U9 s2 T& ~& O! E8 X

9 X2 D7 L7 S! m) C$ p/ H& J- \6 n' v        printk(KERN_INFO "LED unregister!\n");: {" x7 f7 g% S# B1 d' l) w1 ?
}
9 g  j$ W% O% f( {: [6 X5 J! Y, f0 B* V
module_init(led_platform_init);
" M8 q/ A- ^/ h! t9 U0 Z+ y) W* ?module_exit(led_platform_exit);; {  J! Q7 K( \
: @0 Z3 v7 N1 ~% s3 t
MODULE_DESCRIPTION("Led platform driver");
& y8 L9 Q5 b4 \MODULE_AUTHOR("Tronlong");: y7 ]  o% h% l" m# F+ E
MODULE_LICENSE("GPL");
5 o3 M; A) B$ ^; o
! `+ t# v3 E( `; |9 r/ E$ f7 Q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-30 05:35 , Processed in 0.040901 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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