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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。5 p0 O: [  T" ]5 K4 i0 l
#include <linux/init.h>- T3 N( K9 _4 A% w! Q5 d
#include <linux/module.h>
* y, E' ~6 n9 ]4 y3 n  ?#include <linux/kernel.h>
1 I9 r. r3 V+ a9 w#include <linux/types.h>
1 H! B. [2 L8 S" [* T#include <linux/gpio.h>! z! r. r' |( _! x2 U. s5 T
#include <linux/leds.h>
+ X: }4 m/ f2 r. s; l#include <linux/platform_device.h>1 Y  y0 n. E2 f( O1 `
8 k7 |5 L. a5 u# `3 v6 i& g% j% e
#include <asm/mach-types.h>
& G3 [/ K: U" K5 N. }#include <asm/mach/arch.h>
, m  s8 B5 C/ |' H( b#include <mach/da8xx.h>
" u% H, b5 f+ m5 ?& P#include <mach/mux.h>5 A% I6 s! u3 [; ~

1 {& V8 }& ^0 P8 ]" l) }#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
4 b, ^4 }* b  j( N3 }9 }#define DA850_USER_LED1        GPIO_TO_PIN(0, 5); Y9 F, D  |1 O* ?# m6 N0 Q8 y
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)/ i1 N& Z# T7 X  l/ f% u$ R
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
  @. ^4 f( u- f' j# _" t7 V$ f
& C: L. M- k9 p' h/ g/* assign the tl som board LED-GPIOs*/
; Q0 T2 I2 y7 |. g1 C! O# k% kstatic const short da850_evm_tl_user_led_pins[] = {
: W% [0 ^" p' k# r3 l        /* These pins are definition at <mach/mux.h> file */0 c/ E2 c5 k7 o
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% b( a7 M1 J+ L; d        -1
1 ]& z0 Z, M' f4 t( w};' m" E+ N2 T, }' d
% M: z$ {) V( m( j
static struct gpio_led da850_evm_tl_leds[] = {
4 F- s- b4 L' y: J6 Y) `( q        {! s# G& H6 z8 @- ~5 c  P, }! i
                .active_low = 0,
; \7 r1 V' g  h0 @9 p$ P                .gpio = DA850_USER_LED0,
. M& @1 q# v( g7 P                .name = "user_led0",9 R! c. K- z, M* l5 A( @$ N9 i
                .default_trigger = "default-on",
7 [5 s2 K2 K. ~" `* M        },5 `, d3 v# w! `
        {0 V5 F0 \9 `) L
                .active_low = 0,1 M& G  N, m6 K/ S
                .gpio = DA850_USER_LED1,
- E% C8 X9 P4 Y                .name = "user_led1",
  p) Q* _- N0 i9 h1 E                .default_trigger = "default-on",9 ^1 a* O* l/ O1 f) u
        },( T) H9 n9 d! {7 h
        {
, h3 v' O# v3 }9 |, K                .active_low = 0,3 N. q% x  N& H; w, |7 G& D
                .gpio = DA850_USER_LED2,
8 U+ p. g8 F* S% W& D                .name = "user_led2",8 K& ~  ?9 Y: V* B, C* W0 Q
                .default_trigger = "default-on",* l! i. E! U+ n) K1 ~
        },4 F# M/ ^7 j0 d5 P  a' x  j1 @: m+ r
        {  Z$ k. s, y8 X% Y! S$ s5 B; K
                .active_low = 0,
0 G1 ~, o: y3 \) ]                .gpio = DA850_USER_LED3,7 r7 {( O0 l+ J* h' C2 g# @
                .name = "user_led3",
/ I7 @4 m) \& x                .default_trigger = "default-on",
: |& A& j9 w# R        },: ^- H1 i7 k& r% R+ \$ u# b
};1 X6 U2 ?) _1 w$ O; ]
& g1 P4 R8 J9 Q6 A9 F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 q/ _/ i  R; m
        .leds = da850_evm_tl_leds,! }' }4 g- n9 a+ Y
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% I& Y* k2 {: q; k; d- I! M1 s};9 X$ F* `  l* w% o* t% Z8 h8 m. V

, I- x; K( {+ h3 n8 v3 z4 H; Sstatic void led_dev_release(struct device *dev)
- g. M/ o; j! K( x{
, V, D8 n) g( i7 `. e, i& P+ F};
6 ]$ M' s6 A/ X9 ~. B- P; \& M) L! o" _' l& w2 ^# @9 ?1 N% o
static struct platform_device da850_evm_tl_leds_device = {
4 y2 a/ t( C9 @2 |$ u$ M        .name                = "leds-gpio",
9 I# d3 n% N/ d( q( Z- R  G) X        .id                = 1,
1 Q  x% o/ S" O! j/ p% g; @& U- U2 y        .dev = {( _7 f- j/ d2 k/ Q6 F4 O7 ~
                .platform_data = &da850_evm_tl_leds_pdata,
( j& u1 W0 r, G, W" u7 p, z  p                .release = led_dev_release,
2 M* |- y% I8 ?5 b        }
6 j# b. ?4 X7 L  Z2 m9 m};
7 m) D) J4 ?$ W1 q; ?$ ~& N: E
: ^- a7 `0 K5 H- M5 Ostatic int __init led_platform_init(void); E$ R3 V6 \. S; ?7 h
{
" a9 H  ~3 c! D* y, ]# L8 j        int ret;6 M/ _6 I0 a% g/ G' ^
#if 0* \" K2 K0 M. c6 e* e# G
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. k& M- j( _2 U& N) z; j8 }
        if (ret)3 n7 B7 G1 d4 H5 a# |5 f, g  C
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% }) W3 r7 [% o                                "%d\n", ret);% M# d$ c/ Q* a% o. k
#endif
7 k% f8 O. P. M        ret = platform_device_register(&da850_evm_tl_leds_device);
$ N: I; ^6 B$ X# x4 A        if (ret)$ K, v$ h& W6 K% ?! {: A! \
                pr_warning("Could not register som GPIO expander LEDS");
2 n, l$ G* d% \' I& F        else
, t* w0 l+ G3 Y" V+ L, c) z                printk(KERN_INFO "LED register sucessful!\n");# D/ J) a/ X* S1 }& z$ m; @' n+ U

4 O' T2 _3 w8 p+ C. p9 G! e        return ret;: t2 G5 \7 r, p5 R# D$ b6 \
}  O# g- B7 d! _9 w( o7 ^  ^

' L  V. y7 v+ q/ {static void __exit led_platform_exit(void)* E  d( q* ?4 [0 K
{
3 Z5 y0 _! X+ y- A! X        platform_device_unregister(&da850_evm_tl_leds_device);( \' H% r7 U3 F) V- z' W
8 {( y) a+ h+ t) o  p9 \% E2 z
        printk(KERN_INFO "LED unregister!\n");0 T0 {+ Q+ G& Z4 ?$ g1 s5 n; ?1 _
}4 M: V: z6 B; @5 u! |! U7 T" P

3 H% t, |- d# F  M& \module_init(led_platform_init);6 |* i- d# e3 t1 d& s; x
module_exit(led_platform_exit);0 [4 S# ~! r3 F% e6 ~+ a# i
; h' C, Y7 r. K+ @6 f. l
MODULE_DESCRIPTION("Led platform driver");
* k, A0 w7 ~. h: R- N% P7 ]5 SMODULE_AUTHOR("Tronlong");
/ v+ X: X1 u- M4 s+ }MODULE_LICENSE("GPL");2 T+ S$ A" t% Y  A2 ]
4 a- k0 b% O- [" i+ S+ K
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-1 04:59 , Processed in 0.044729 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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