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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% ^! L2 x) {+ R- O, n
#include <linux/init.h>
' s/ P/ R+ L# E#include <linux/module.h>. r# d) Y; Z  `" R" u& t
#include <linux/kernel.h>
* x! C0 B# X. r1 j5 W#include <linux/types.h>
# d7 \& s* s4 g#include <linux/gpio.h>
6 o5 v4 L9 L& C& y9 a! `4 q#include <linux/leds.h>( B" Z- v4 A; S- g, W
#include <linux/platform_device.h>
: J( \5 N0 E3 O! ^6 N7 X& W% G' Z7 _
#include <asm/mach-types.h>. K& v: u2 ?5 a- L
#include <asm/mach/arch.h>8 e/ k1 _8 L9 b
#include <mach/da8xx.h>1 B4 c! Z" `8 E" d0 b& o; E
#include <mach/mux.h>, s& y5 C( E% r. H" p

# k% I8 \. P3 s& [#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
5 p/ j9 S" A* I- K) E3 i#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
. B$ s) x4 [2 I* ~  M; }4 F& }#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
. h  W* e) N3 x/ s) U#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)# U, u4 ~( K& o# B! K  ^. B3 d$ b
" m4 j+ W5 q# }% V$ _8 C
/* assign the tl som board LED-GPIOs*/! y" d, X9 E5 ~
static const short da850_evm_tl_user_led_pins[] = {. E* ]1 u! c8 c+ w0 f
        /* These pins are definition at <mach/mux.h> file */& \7 d8 w! {' j  E( ^
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 R& X5 T5 m( |) X' Q" k9 l        -1
6 C& N% _' Y! t4 L9 S2 m0 j};
4 R$ N" r- f6 x
+ ~' K  s' D0 ~; b8 \- Hstatic struct gpio_led da850_evm_tl_leds[] = {
* D4 x' c* P" j& S: p        {
5 b% X- b- [. Y1 |# {) w3 T                .active_low = 0,; d9 ^: L$ y( z+ g/ F' d; G
                .gpio = DA850_USER_LED0,2 Q" |# F; m2 K2 j, |& T% V
                .name = "user_led0",
" l& b$ d( ~8 g8 h; e: J; ]- S                .default_trigger = "default-on",
  F- |' e4 G+ F/ @; k8 {8 D        },
! T; D1 A  n$ \, f0 c9 N$ ~/ \- q        {/ b2 E4 u) }! i) c4 p5 [4 J
                .active_low = 0,
: E" B: k# H2 m& [2 n                .gpio = DA850_USER_LED1,
4 V6 I' M& z  N* P% @1 |% O                .name = "user_led1",% ]' m/ U. @# C- e9 f
                .default_trigger = "default-on",( l, R& J3 S8 D# S7 T
        },/ }% e* E5 e6 k& I( Y  ?
        {% U: T- {7 S2 z1 Y# o- A9 S
                .active_low = 0,  C% n; m$ o$ J& u  |
                .gpio = DA850_USER_LED2,. n: y! {" N- q' d) w  t1 Y5 ~# P" K
                .name = "user_led2",
- y0 s, o# j% C! W                .default_trigger = "default-on",/ K- D% k2 Z7 D" y% W
        },0 \2 `5 A- `7 b. a. p0 p
        {
9 J+ x. V' C9 `9 ?! t2 l/ o& `* _                .active_low = 0,
( |9 d0 m+ H, }  c: B                .gpio = DA850_USER_LED3,% M+ i" @# b) r" J' I' l% D
                .name = "user_led3",, L9 h" _$ H4 P% _3 t. g3 v
                .default_trigger = "default-on",. _4 @( V, r; u" I4 E
        },# t4 t3 P& g; P2 ?5 t$ h
};: [- c% B! n# P0 k4 e( D* A% O
. c8 K0 a- x9 A" H& G+ e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* E& ~" B( ~6 F  b4 g        .leds = da850_evm_tl_leds,
; w( Z- b5 c6 N6 t# V        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 \0 _6 A* K7 m9 a3 D" V};
, T; S- s4 H* W" w7 z9 N/ ~( ^: p9 H/ R% N: B/ ?
static void led_dev_release(struct device *dev)
9 i+ y" Q9 t; t# F) a5 e3 @{- h( J' `% w  F6 Y- q/ u
};: R0 y0 ~8 ^4 @. `
) l' X. Z, m/ }$ V3 z8 x* L, V; |
static struct platform_device da850_evm_tl_leds_device = {; }% ^5 y5 W$ T: t
        .name                = "leds-gpio",
; m# U+ L! r' U* v        .id                = 1,( {1 G" `% u  y% x
        .dev = {- |" w" {! U' B- @" j4 F
                .platform_data = &da850_evm_tl_leds_pdata,
+ s  u+ i" C6 K* q7 n; u0 }* y, k3 Z. s* n                .release = led_dev_release,
  G9 V; n3 e% |4 z( h) D        }/ K" J# H4 ~- ?% P
};( u( h% Z( e4 A6 r/ [9 q+ D

/ e, b, v; O, E* G3 g; Vstatic int __init led_platform_init(void)
! E5 t6 M+ t- H& C{, S  W) c9 d* U# s( K
        int ret;/ ?: P" q  X  E1 T' i4 u
#if 0
/ M/ ^" M, M7 ^- Y" N# h: |        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 W! F/ H' X+ t        if (ret)# k: [: L: S& t. t$ i" V: K
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 ]7 K( ^# p% j2 J8 G                                "%d\n", ret);, y- X% R" n$ \* r8 v5 E  N+ E; ~
#endif
, I: @# l0 ]2 R) h/ K" ]        ret = platform_device_register(&da850_evm_tl_leds_device);
* P: N% f- r& l) h% M8 L) {9 F        if (ret)( k3 u/ L+ V" U) _
                pr_warning("Could not register som GPIO expander LEDS");( j7 C0 a; j- F
        else6 a! H0 N0 c1 Q4 \: K
                printk(KERN_INFO "LED register sucessful!\n");
! \% ?  I, S8 e& ^
. y! c- w" R9 }' x9 `; d        return ret;  \$ l; k% d) E3 k
}
0 O$ N" u" B7 o( |6 i* s3 a1 ~4 O$ P2 l: b. N$ o* g* t( \/ C/ x
static void __exit led_platform_exit(void)
+ ]$ E8 j1 P8 P* p* P) l{4 i) I+ a  T, x- P: H7 h8 P+ }! j/ x
        platform_device_unregister(&da850_evm_tl_leds_device);
& [; r* ^; m2 E8 }
/ j/ t1 r1 P6 p& {; Y% a( ^0 \- J        printk(KERN_INFO "LED unregister!\n");
; h& X% ~3 k2 }7 ~9 t+ U) U* G}* ^& o: w1 R. @/ u9 V1 m
) u; {  G: Z" R6 L+ D& ?) {, J* [6 @
module_init(led_platform_init);
9 ~  `: W  g) j3 j8 \" @- smodule_exit(led_platform_exit);
# b8 I7 V3 l6 k2 M; t; d8 j3 _/ E: t! Q& U! C- n' x" |$ O9 E, @
MODULE_DESCRIPTION("Led platform driver");
2 q2 G3 |* ]- M) \# I. m5 hMODULE_AUTHOR("Tronlong");2 T$ R' e' }9 k2 O/ [
MODULE_LICENSE("GPL");
( d/ f9 f6 f! U
( _7 T# _7 M" H& ~$ p" b% L1 T
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-23 15:36 , Processed in 0.042679 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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