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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。; F3 u) e- j( d' t1 `$ m- I- V
#include <linux/init.h>' K: M$ S+ o8 W% E2 ?, C
#include <linux/module.h>
$ \$ P. Y1 u0 T* ?2 q#include <linux/kernel.h>
$ \$ U" i) o3 B/ Q1 I+ m, b$ ]+ I#include <linux/types.h>" a9 }4 {0 p. r! N. A. |+ @
#include <linux/gpio.h>( C2 v* Q& v3 s% ^
#include <linux/leds.h>5 E9 S  H# y+ L
#include <linux/platform_device.h>- h" Q- f) ]6 y& I) }) F4 T6 ?

! Y3 f# `; s0 w: U2 P#include <asm/mach-types.h>& n" u6 z# }% [' U8 \: L' W
#include <asm/mach/arch.h>
: O7 M7 \) D, U, h, j; _/ m#include <mach/da8xx.h>
; @1 b: c8 [/ g0 t5 `8 @) G+ v#include <mach/mux.h>% V6 v: N. A" }6 u3 m$ Y
, L# c; e! E: d. _
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
3 ^; u0 ~# c' e( T! b#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
; W2 r& V) y6 P4 f  O/ f#define DA850_USER_LED2        GPIO_TO_PIN(0, 1); t+ @6 n7 s! }
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
6 q: W: r4 p3 D& m
  N# g! P* Z+ B$ R" q2 c/* assign the tl som board LED-GPIOs*/5 R2 N5 g7 `% }+ }  _; x
static const short da850_evm_tl_user_led_pins[] = {
* P) F( a7 j. B1 ]# C, \/ q        /* These pins are definition at <mach/mux.h> file */5 I! k; b5 e% X4 r. E  Q  _0 C/ w2 B
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
  t  l, f# ^8 u- _; v  v        -1( y, P" j2 n5 Z0 M
};
$ F* ]9 f1 Q. w  {" T! \; a5 z+ N' I# D/ T
static struct gpio_led da850_evm_tl_leds[] = {* l/ c) B! u. T( ~
        {
4 x, M- V% H  q! l) b: O+ [                .active_low = 0,
9 a0 r+ S. R5 e' w" P# X  y                .gpio = DA850_USER_LED0,3 C4 _: r# u- ?/ W' J
                .name = "user_led0",
, d- A" c- L* m+ P                .default_trigger = "default-on"," e( f$ M/ V  ~* K; W) A
        },
3 X: F2 E" P- G: U  d2 A        {
9 @# N* ?8 [) {) b8 Y. ~! A                .active_low = 0,
6 M  n! R- t; U: u, x                .gpio = DA850_USER_LED1,
% n' ]# {5 W+ e+ p( Y2 @- ~                .name = "user_led1",
8 g( h- i1 X6 i2 G- Z                .default_trigger = "default-on",* A9 z. Q) h0 s- D4 S
        },
. g& a; h/ s6 t8 Z        {
5 t) [( u/ z8 |. D6 Q7 u                .active_low = 0,7 k4 |4 t2 z3 W% I* s2 g
                .gpio = DA850_USER_LED2,
- H$ J  @6 ^) \' K' h( U- D. ^                .name = "user_led2",
) A1 e  P" {  ^$ y- z! x9 k! Q; g                .default_trigger = "default-on",* O  _& r6 e' e; \. f6 e/ L3 W
        },! g- {* @( N& Q4 M
        {( [3 P7 T: H8 @: h4 D' S
                .active_low = 0,
! r) R* M  q: j3 Q$ W; g& {) m- e                .gpio = DA850_USER_LED3,/ H$ g2 t6 D9 N" ^9 }$ d$ ^; B5 _  i
                .name = "user_led3",1 \9 g% `9 u6 t( f& ?7 `5 w6 S
                .default_trigger = "default-on",7 B6 W& A# `+ Y- [  m- s) f7 T
        },+ W, v! F) _8 N. _+ W
};
/ e7 T  E; \* U' f
$ C- k& o& X  h2 K- \: g. ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, z* Z/ h" i9 X5 ]& B- x* q        .leds = da850_evm_tl_leds,
7 e/ c1 e" u6 }* I  i# s: t+ Q        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' u- q- y9 n; U0 ?) @. T
};* ]+ q; J  }* J, Q: F7 j5 ]5 c
1 ~/ ?+ w8 |. p) K( b0 O
static void led_dev_release(struct device *dev); z, N2 G( r$ J* m' y* S0 U, ~: m
{. }- `2 p; t4 _0 [$ O. z6 z
};
) m4 m: H4 ~+ I" _( O. j5 ^9 r2 h* a2 h$ f$ a7 R! y$ f: ]
static struct platform_device da850_evm_tl_leds_device = {
; V6 y- I4 [% j9 Y2 x        .name                = "leds-gpio",
; S4 h0 p; a1 W/ u        .id                = 1,
: T# o8 T* l& j- W1 u" u        .dev = {; Q1 a/ d+ j% S) Q$ K
                .platform_data = &da850_evm_tl_leds_pdata,2 j0 J+ Z+ N4 d( b% M
                .release = led_dev_release,
+ |7 X) z  @2 X! ]0 X% W        }1 u, H! p) L( ~" ]) {1 ^: D
};. U; p: N, D' o! |& W
6 ?3 C$ H$ Z3 U. H
static int __init led_platform_init(void)
. Z( U1 C6 [' L) n/ |{
% K$ i" {  x# Z        int ret;- |! ~  }. u# |( p
#if 0
) X. M5 ^: C% I) S: W        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ p0 g9 n: ?: l# w        if (ret)
0 J6 Z/ l  r, H9 o: a& I                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" {, P' g, E* q5 r( q
                                "%d\n", ret);  K) N3 K) D5 R8 B& C7 j& ~; g
#endif, o- l% r. i! `
        ret = platform_device_register(&da850_evm_tl_leds_device);1 ^. y* n# Z6 T# M) B
        if (ret)$ k$ c% G5 |, a7 U( r' z# Y  |
                pr_warning("Could not register som GPIO expander LEDS");
7 P" a5 P3 B5 I3 l" Y/ |& b# r/ v        else
5 _6 y% x/ {2 p3 B# A: G! h: y                printk(KERN_INFO "LED register sucessful!\n");8 @9 E! y$ G1 Z. A' [
' K6 |/ v8 H' ~9 l
        return ret;
( i* E9 G" `' j; k2 t7 b}# k& s' u& T& X% t- N, @

+ k3 S$ L7 V8 ~2 ]( |static void __exit led_platform_exit(void)! j4 n" U( j- f4 h% k1 Z" K( p
{' f8 I" h2 v4 i" f2 |
        platform_device_unregister(&da850_evm_tl_leds_device);" C5 g2 Y/ p2 B" u- I) X
; Y: v! J, K5 Y) g. \9 o
        printk(KERN_INFO "LED unregister!\n");' c' q8 J8 V" `# o; C! M4 H/ F
}
! h1 L1 c# v1 L! a6 g* [0 z: X) q1 ~7 Q+ [
module_init(led_platform_init);
7 \" w6 M2 D5 p. n% h! G; o5 D& {module_exit(led_platform_exit);
1 k! `! k) Q# K  I3 i/ U. j/ J$ i
" c3 Q  V: N5 k+ m! mMODULE_DESCRIPTION("Led platform driver");
4 y% o9 N% \' k5 `* ^MODULE_AUTHOR("Tronlong");
; {) f, M' t+ k1 F# Y5 HMODULE_LICENSE("GPL");5 [) b2 t* _& @2 k9 y9 l' i6 Z

# I3 c4 c/ ~  c2 I7 d
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-23 23:56 , Processed in 0.038748 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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