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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
9 y5 V5 g/ P0 F: i. n% L#include <linux/init.h>) Q( W0 ?! [8 k, ]# ]0 ]
#include <linux/module.h>
2 W2 M, Y/ H/ L3 E3 S#include <linux/kernel.h>
( Q2 f6 J8 y& R" l# A* r#include <linux/types.h>
. ]5 m6 V' L" Q, o6 b% e#include <linux/gpio.h>
5 Q' @0 @+ z+ ^0 W6 ?) n#include <linux/leds.h>" j" c5 G& S9 X- w, f* ^
#include <linux/platform_device.h>
$ @8 N) G4 c7 T/ x  B+ T
& P% D  |/ i1 b- \+ ?+ Y#include <asm/mach-types.h>
- O% n+ c7 N. y! h/ o#include <asm/mach/arch.h>
' p( a2 `! P9 N! C8 l7 t. Y; p#include <mach/da8xx.h>
5 Y# W9 A1 Y; P" D# {6 A#include <mach/mux.h>$ ]1 U1 c2 L. f; N* q  h$ B+ ?: A8 c
. Q' `$ o3 P( g# V( x6 |% _
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)' P# \( b1 @; \! s  ~. F3 q
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
. `* n4 x" d& V1 B4 @0 D! o) m#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)5 m; _, ?* O- R( B
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)& i* h* W! E% h$ T
2 v5 _! m# _: T' Y- @
/* assign the tl som board LED-GPIOs*/
6 `" R6 {% a2 q/ n. \: U) s3 m. o+ Jstatic const short da850_evm_tl_user_led_pins[] = {( a5 r, L" \' q- t4 b* L
        /* These pins are definition at <mach/mux.h> file */
/ l" [! {: d4 x) ]4 W        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. n/ p! l0 i6 U
        -1
' z$ O6 {0 r9 H8 s% [3 K};0 P1 L+ D4 `8 i3 p# z1 n; d# J8 T

; a: _; e  ]2 U) a7 Astatic struct gpio_led da850_evm_tl_leds[] = {2 X' @7 }: D" Z
        {
' `2 V- A5 ?( ]  H3 ?                .active_low = 0,
0 e# s) J3 Z$ M3 q                .gpio = DA850_USER_LED0,* o8 m1 [7 L# ~3 G2 |1 B' ^) g# h3 D
                .name = "user_led0",5 ^- W1 F9 }. \# J, J
                .default_trigger = "default-on",
, i8 \+ @/ f& X' c) e$ h9 q; R        },
1 s" C4 R: W2 U        {
* n* Z/ a- G( @3 S0 m$ a                .active_low = 0,
4 F( {5 E3 p4 |) K4 A, p# E                .gpio = DA850_USER_LED1,- r; ?7 l, p# V) i; U) Y2 J% m1 B
                .name = "user_led1",
# ^* _' r1 z( G  F! D7 j                .default_trigger = "default-on",# d. Y7 s; [4 f) p
        },
' c6 F* d- i( k        {3 I0 U$ h+ v* A2 l0 ]* c
                .active_low = 0,5 m$ z. l  i2 q* c# E8 E$ t, w
                .gpio = DA850_USER_LED2,
' g1 l: {) G: A: K                .name = "user_led2",
4 P2 f. v: s/ i: O0 `                .default_trigger = "default-on",; D5 k. l2 Q* u6 d( h# e5 M1 ]$ c
        },
2 F: d' t. J" x/ M- U3 _        {
0 _6 U# u! e# W9 }5 n% t* c) ?                .active_low = 0,$ {9 [. q& u" a
                .gpio = DA850_USER_LED3,
' o. a2 Z5 I& F- w6 L9 K                .name = "user_led3",/ W5 a2 @$ U0 Z+ v4 F4 I
                .default_trigger = "default-on",1 a) b9 Z% h: Z
        },, o" `; h8 T+ C
};7 Z9 d5 [9 [2 ^8 A' h
1 X/ y1 H# y( @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 C, ]9 _9 ]8 Q2 I2 E. k  b        .leds = da850_evm_tl_leds,
" V, q7 N1 |7 A- X+ q        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. ~" x% |- }/ a5 v3 M) c& ~0 D1 {) j4 B$ P
};2 K  k4 u* a0 U! x- ?# D3 P! s( V4 y

" w0 i! z+ W, ?& ]6 ?static void led_dev_release(struct device *dev)+ p4 m! M; F" M- ]
{
5 N$ b- D5 s5 b6 B6 F2 s/ w- I. l};# Z1 w$ ]* }4 [9 N8 d, h
/ n* e  f& A! k# m2 o; m! \8 r; d
static struct platform_device da850_evm_tl_leds_device = {* v. r6 t. u! Z* [7 z- F
        .name                = "leds-gpio",% n! E& Q: t. ?/ S* ]
        .id                = 1,
5 U: J6 D& F4 K; H+ D2 A        .dev = {/ Y- O& f8 a: H( {
                .platform_data = &da850_evm_tl_leds_pdata,
& u' Y: |6 |# ]$ o7 l                .release = led_dev_release,
: w- ~- a' h6 K        }
4 \9 ?8 n: W* K, P1 O' G9 X};% \9 i6 L* ^$ j+ c2 @$ i" h( g& t

0 s9 F' M* f5 x4 |% Q2 T3 Hstatic int __init led_platform_init(void)
4 P7 Z7 S2 c. w# d0 Y  ?1 m{; T: ^7 A, p6 Z/ L1 ?6 r
        int ret;
2 s, u* L% C& ^  D4 G! S#if 0
8 x+ U, Y- D# ]0 Q/ D+ `        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) {+ ~5 l4 t1 M        if (ret)
+ Z/ t9 v* s( Y7 i* b4 \                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 Y) u. a& j, j* m" Q                                "%d\n", ret);  I  r5 y( o7 H5 Z0 m( O$ J
#endif3 q! u% X9 M6 n9 x
        ret = platform_device_register(&da850_evm_tl_leds_device);
4 I# t9 H- W1 ^6 h        if (ret)" O- n5 |" L1 B* U/ Q
                pr_warning("Could not register som GPIO expander LEDS");
* d% [  Z) O6 p0 t- u( ~( K        else
& Q& H* U2 [! {6 Z- k                printk(KERN_INFO "LED register sucessful!\n");
/ }* w6 m& ~( D9 G2 ]( C' G
8 j1 }. ?& E4 ^9 Y- v2 A        return ret;; Y9 M; q/ N# X$ d. m9 ^6 t
}# M) K' `. I' I# o: b; L% S! i/ @! l
9 L6 v. c6 c( o5 x
static void __exit led_platform_exit(void)0 E# @0 N5 x) O# a1 m3 N! M% |
{
% S1 ~7 K: \* }$ t2 r5 P: ^        platform_device_unregister(&da850_evm_tl_leds_device);
$ {2 h& |7 c& c% L. y& J/ @& ], E( J
        printk(KERN_INFO "LED unregister!\n");
3 z" A% @2 g( h$ `: B) ?}
5 P4 r, z7 Q& z3 Y! J3 a9 g+ I% t$ [" {) r8 K  l
module_init(led_platform_init);
) X% Y: B- x+ Z. K4 Pmodule_exit(led_platform_exit);
& u) W% N3 P7 J, S
3 p; c, [! `& {" @, Z% h- D  zMODULE_DESCRIPTION("Led platform driver");8 B- {8 ~$ R7 l9 A
MODULE_AUTHOR("Tronlong");
' A2 o! v; Z- `0 r8 \MODULE_LICENSE("GPL");
9 }& [0 i  ?) ~; i. r+ t( m3 Z2 v# O$ H& k! R- z% r2 h$ ^
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-10 18:39 , Processed in 0.038955 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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