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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。' q  X; r8 A% f, ~, E/ x+ U8 p
#include <linux/init.h>2 _2 `6 Y& L8 ^2 Z
#include <linux/module.h>$ x; F1 P, ~# [. `
#include <linux/kernel.h>
0 b' z# w% g( R2 ?4 e) L' u#include <linux/types.h>
6 C/ k( _) v  v. n7 [3 c5 C. K8 Q#include <linux/gpio.h>
) ]* A+ @% b/ E0 s#include <linux/leds.h>
! g( ?- `# h- e! p/ L#include <linux/platform_device.h>; d, Z- M  ]  ?. E
9 p! O4 i+ ^) Y
#include <asm/mach-types.h>
# v3 U1 M5 e2 A( w! G#include <asm/mach/arch.h>
+ @; v6 x6 l% z0 O+ E- ^#include <mach/da8xx.h>/ i& Q; M- i. z% H
#include <mach/mux.h>
, o7 K+ k. |/ m$ g, L6 Y3 B, G2 c& z/ p
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
7 C  `' y$ u8 l7 y' y2 P#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
1 m8 @8 m8 w! N' d#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
" e+ L" ^9 u4 N+ P6 ~#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)* l6 I% ]. \: h( O$ M# g+ G
  J8 \/ S: I6 Y2 T8 U" Q" }
/* assign the tl som board LED-GPIOs*/
) W5 a9 P& \5 \' l# Hstatic const short da850_evm_tl_user_led_pins[] = {; s8 R1 l& p. M
        /* These pins are definition at <mach/mux.h> file */" _7 U- ]+ O5 l% r
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( `3 H9 P6 u5 R
        -1
3 l  I' k: B8 V/ o};
: R( m3 ^$ D5 U7 g8 L5 H) B' ~) J- R0 ?* y) y
static struct gpio_led da850_evm_tl_leds[] = {
6 z& ^" w6 d! ^; }! v& G4 k        {
$ d6 [7 C7 ]  e3 Z                .active_low = 0,9 C, u; f% a, a/ V6 U' w
                .gpio = DA850_USER_LED0,8 i9 R4 Q. l7 M: I
                .name = "user_led0",) _9 ]3 P% z2 R5 W6 O- c- I
                .default_trigger = "default-on",
( T2 B5 F$ g; k/ Y( k        },# N; U+ G/ n0 @8 i5 |& K
        {# A! A/ l  g" @$ k1 I
                .active_low = 0,9 Z" n/ x# E/ Y* |: P
                .gpio = DA850_USER_LED1,
* L+ |! Q1 U; B- U; _3 \                .name = "user_led1",# h8 B4 o' P# N
                .default_trigger = "default-on",
5 P3 o) v) m# `7 h        },& f  u1 W- k' |0 {+ k* [; A
        {
+ i5 K. k! j0 b- n8 D6 ?5 J0 F                .active_low = 0,5 J5 I  \7 q$ a9 F7 K% N
                .gpio = DA850_USER_LED2,
6 V4 G7 A7 U+ t' q1 F1 _9 A& W                .name = "user_led2",
/ ?4 i& a# R8 d9 G+ r; Y/ w4 O                .default_trigger = "default-on",
; y' y9 _  I- R! f$ p! [+ D' R        }," C1 i1 S6 |5 a3 {+ m( X5 N
        {
8 X! _- g8 \7 A# G1 N                .active_low = 0,( H. ^" v5 I9 v2 D, J
                .gpio = DA850_USER_LED3," f" z) Q. L" W) ~
                .name = "user_led3",, F" q2 Q( z" s
                .default_trigger = "default-on",
$ Z/ b- d6 W9 w9 p1 }- e        },5 j6 c+ t3 X/ |8 u: M- p' X8 _
};/ F) ~6 x* h. \
" C: F1 c* ~  D9 G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 f* g3 M$ D* i, k* f- s) C
        .leds = da850_evm_tl_leds,' e3 [4 q1 T6 n4 {8 v' \+ K) R
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 D' }* ~, @7 p/ _6 U- A};
: B6 x" R/ k& a- A3 g+ y
! O" X7 a% f* f4 Y- kstatic void led_dev_release(struct device *dev)
; \9 i9 Q! u8 ^{
; K" a- ^; o, {1 o  B) J0 [};
) N$ \5 U$ a% U8 l* Y7 M8 _1 R/ {# U% i  ~7 `7 W9 c+ q
static struct platform_device da850_evm_tl_leds_device = {
- C% ^1 @2 a' m3 {        .name                = "leds-gpio",9 @4 @) S$ P& t; n  D& T' O
        .id                = 1,/ c/ |; O7 x0 {  k$ Z3 ?
        .dev = {
- H$ [9 g* g! G$ Y% S5 ?; F/ @4 C                .platform_data = &da850_evm_tl_leds_pdata,
) d+ |: ~. L: p9 y                .release = led_dev_release,( [& L& P# R% D" l
        }) [. J  K8 X2 I6 z
};% g3 m; p8 q5 z/ e# O; r! n) N! {8 e

& X! ]$ S, n' f; xstatic int __init led_platform_init(void)
; }5 t! Y- D: g9 s+ k{
1 a- S6 w  ?9 m9 ^! o4 r+ n        int ret;  ~! G8 G7 U. s* Q1 X- ~, g( f1 h
#if 00 C0 C, R5 V& G7 A
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 l1 i. G# d5 ?9 q5 J, W+ A( H8 {
        if (ret)
% o: x$ E* L0 a) g7 Q) T                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& Y" Q5 g3 [3 {. u+ a4 e
                                "%d\n", ret);9 a8 R- u: i( E; D) J! G3 e
#endif' \! _7 p: }; @' U+ i- U% b" R9 i
        ret = platform_device_register(&da850_evm_tl_leds_device);
* a, k8 P, g1 R: H  k8 w0 \        if (ret)6 ]' x  q) x; w: ]& C& {
                pr_warning("Could not register som GPIO expander LEDS");2 [% I6 h& H4 n& t! V2 d
        else
4 f3 F* O4 S& w/ \                printk(KERN_INFO "LED register sucessful!\n");
# I% i5 [; w% y* A- F% L; E! m8 e9 i1 A  [+ U# v( q8 Z
        return ret;. j5 L7 \9 C. q, S9 f7 r9 T
}
; R! u( e& ], h9 Y, ?& L: h( Z
  {; j. q* E( [2 ^2 k* y. Xstatic void __exit led_platform_exit(void)8 b2 m9 Z( b: b5 k1 _4 z, M
{
% @3 |$ j+ ~! [- Q  A        platform_device_unregister(&da850_evm_tl_leds_device);7 l" y' X9 t: Y7 `0 V, h( `/ ~5 G
, h0 W; n# l0 ~( a
        printk(KERN_INFO "LED unregister!\n");
2 R6 {' }% [) b" C7 T9 L6 d) f}% ]7 K; j' ^" t- o* Q. L

( p1 J& Y/ L8 L$ E3 Smodule_init(led_platform_init);8 T3 u/ m( l9 w( Y5 w) b
module_exit(led_platform_exit);; Y6 s$ ?7 R3 O2 A* \+ U3 x

3 v! \* ?6 M  k! Z. j0 e& QMODULE_DESCRIPTION("Led platform driver");
: W( i7 L- ^& c" D7 D: `MODULE_AUTHOR("Tronlong");7 b* A0 s$ m+ Q
MODULE_LICENSE("GPL");$ J$ f4 O1 h9 h
# X; {# o+ t$ U' G  [8 s% G
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-16 17:17 , Processed in 0.037891 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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