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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
- U& z$ l( G5 V6 C! s( {# t$ U#include <linux/init.h>- r, {! Y7 d& ^, ?
#include <linux/module.h>4 w( w- s( }6 Z
#include <linux/kernel.h>! {: L: E, _7 [0 x* {( m
#include <linux/types.h>
8 }. w. R' S' t" E#include <linux/gpio.h>3 f0 C; w6 J/ G( x6 w" R  {
#include <linux/leds.h>
, |# {4 e5 o7 k3 X6 z) C' X1 a& b#include <linux/platform_device.h>
( u& K2 g+ @- |7 `) f) z$ `4 L2 @# b! N  f
#include <asm/mach-types.h>
, t. B) S) q8 c. b& \" f8 O#include <asm/mach/arch.h>
8 S$ L6 [$ _8 Y#include <mach/da8xx.h>
/ _/ y2 l0 J! g4 `) ]& l$ E#include <mach/mux.h>5 q& B$ l7 [: E) \* ~' o
; }: X  y- ^1 ~3 k9 b' H
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)% x  W9 ]" X( H% b  ~
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
5 u) K' O$ C. ~/ B5 b#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)# p) V+ j+ Z: U. N. f, ?7 g" \5 W
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)8 y9 w' O; ~8 s( U+ e+ [

0 A5 h5 Q; a/ J) j" Z( a/* assign the tl som board LED-GPIOs*/
1 M+ D0 j% `5 M+ astatic const short da850_evm_tl_user_led_pins[] = {' \# v* |5 E" `; e: y
        /* These pins are definition at <mach/mux.h> file */
7 q, x, F1 J& F        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& D' ^4 i& A' a' T- Y9 f6 D        -1, {* j0 @# c- h1 T% @
};3 ^- ^3 \+ T7 H  i: t3 A
7 z& K, {7 _0 o! R4 A( r
static struct gpio_led da850_evm_tl_leds[] = {2 @9 E0 k: U% @9 w5 F. i' q* O
        {
2 Q5 T; K( b. L1 M8 F4 }+ ?: d; [                .active_low = 0,4 A. N  L. Q! M+ Z5 c4 a9 `! G$ O
                .gpio = DA850_USER_LED0,
9 k/ O4 v6 g/ r                .name = "user_led0",
: Z: d$ y$ l* X6 t7 v. H+ d                .default_trigger = "default-on",% Q/ x4 i, `1 p
        },
* E" m+ `3 d' |) _! t        {; j1 B- F# F1 J( C9 l7 j
                .active_low = 0,
: m8 b) B6 q* k" q& T8 R3 I* O& b                .gpio = DA850_USER_LED1,+ T. z) _4 p, H5 Q, ~
                .name = "user_led1",
- Y$ S/ Y1 ]7 K! L2 T4 x                .default_trigger = "default-on",+ w3 c# h( D+ `4 M' d9 F6 }
        },
; r! b* ?. }: }, [) s        {. e7 H7 N! A  O4 I# w5 W0 z
                .active_low = 0,- o- m1 ]# @6 \/ v/ L
                .gpio = DA850_USER_LED2,' U& [  K0 X* g
                .name = "user_led2",3 @' d% D3 @/ p7 a
                .default_trigger = "default-on",
7 q! D' t' q% T9 y        },1 D+ `' f' z" M5 P* @
        {
/ r+ ]- }2 T6 x  |- q+ s                .active_low = 0,
5 l) ^5 F) o  T7 B" |                .gpio = DA850_USER_LED3,
. I2 S3 C/ {8 O( @0 B8 S                .name = "user_led3",
& a6 I! {5 l! h; v4 @& J( R                .default_trigger = "default-on",; T9 i3 `. Z, p: G+ M
        },
  z8 Q. k- w& j};
, A$ m* D. T. s+ Y3 l+ _. ]! g( Y. V( B8 P3 r: \& Q  g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ F9 }1 R0 ~2 z- q- Y- a
        .leds = da850_evm_tl_leds,3 O: g) `' b, g( U4 M* ^, [% a
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 k; G$ m8 t: ~# L5 {0 N+ [0 @9 ?# p};$ U* K# y% c& k4 H  \! T6 }
! G; ?9 J) n1 |2 `6 K
static void led_dev_release(struct device *dev)
# q/ V9 x' d6 q) w; R- {{
0 \: ~$ `& G7 Y) O};5 j. w% }3 |" b0 A/ r% H

: `2 }. o  B' N' n9 astatic struct platform_device da850_evm_tl_leds_device = {
1 }* o; q) J: @/ i" [        .name                = "leds-gpio",
+ R0 |( O+ s7 A        .id                = 1,5 q! R. V' N$ ?& Z4 n
        .dev = {
8 y" L* e% a7 Y+ B                .platform_data = &da850_evm_tl_leds_pdata,
- f$ G8 o/ V0 I- w3 f( n. _4 o9 m+ y2 A                .release = led_dev_release,
: ^" I, P$ z6 [! l3 a0 ^6 B0 ^        }# P( N: {6 S) d0 p
};' D8 c/ I5 z, K" i0 i4 i% A5 }

/ Z& b2 B" ]6 u5 N4 kstatic int __init led_platform_init(void)+ C2 K- I" ]2 E
{( N$ D- U& J1 ~: I* G
        int ret;
; `- R1 T/ Z5 f. d3 n#if 0+ G  d. u' P' Z  ~% V  K  M6 i3 z: i
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- c/ W4 `( a/ h' U7 y( q0 ]: P7 X
        if (ret)
( A! b7 }5 \$ j7 d+ m6 r                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 I# A+ U% u$ Q0 \                                "%d\n", ret);
5 V2 E5 Z1 X3 {7 h% J#endif
- A/ W5 ^4 @# W) F8 T  F6 Y        ret = platform_device_register(&da850_evm_tl_leds_device);6 {& w" `6 s5 Y5 `
        if (ret)
3 E: ^5 l. G3 a( `( d                pr_warning("Could not register som GPIO expander LEDS");/ `* @% U  }; H3 U9 g& w) r
        else: m4 p$ q, N4 b% B
                printk(KERN_INFO "LED register sucessful!\n");  h8 X: K8 E1 n) n: l9 @
3 y; d. ?& z8 R+ }. q5 @
        return ret;
. G; ?; C1 @' B4 D; v( O}
% t' S/ w7 ~  z* M. @1 l. g/ R8 g# W- L$ g- |9 h) \$ ~7 |; Z' u- `
static void __exit led_platform_exit(void), u1 C3 a  {  Z" L' ^: k5 D
{, T& q$ K6 H" g+ ^3 G: N3 V& c
        platform_device_unregister(&da850_evm_tl_leds_device);
2 R  p6 |& i6 O' [" V' u/ v% g8 b5 C4 _- t. t# a
        printk(KERN_INFO "LED unregister!\n");0 {3 v( y! l! g' j/ _4 [
}
/ a2 o; q& q$ y) _7 G/ z$ Q6 S4 |" {8 z7 [
module_init(led_platform_init);9 h' C, x; n5 P) `
module_exit(led_platform_exit);+ _. f" r* r; V0 P' N! _9 F) W
4 W0 O" n) `2 A0 C1 m$ [1 [( }8 K
MODULE_DESCRIPTION("Led platform driver");
$ N; P% f4 l. ^( QMODULE_AUTHOR("Tronlong");
" j& A2 H7 }8 n1 `, F2 xMODULE_LICENSE("GPL");
; U9 y2 `9 j6 _! l$ R
& e8 d' t, R2 h$ V$ r: ?
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-4 23:00 , Processed in 0.043981 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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