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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
% |9 b* v1 d! W! n. Y#include <linux/init.h>
' r! ^5 [& P2 A+ _0 L5 y#include <linux/module.h>
4 P) Q+ t$ I, c) ~" F#include <linux/kernel.h>4 S' g; f/ g) `
#include <linux/types.h>( ^& f  O1 I9 ~
#include <linux/gpio.h>
* k  P1 U- q' \#include <linux/leds.h>
) e( Y9 S: e0 ?# {2 p, @#include <linux/platform_device.h>
" p8 f5 c7 m. ]: E, O6 q
3 o  s% v  u7 Q* ?#include <asm/mach-types.h>
8 o/ f/ h0 q# q4 c#include <asm/mach/arch.h>
+ R% c( N4 c4 x#include <mach/da8xx.h>
1 j+ v+ R- i+ N) z  A* d; w0 T#include <mach/mux.h>& O& e0 E% x8 u7 v
2 ]: A2 F. |3 s6 B: c/ r
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
! L5 G* M' A" e1 T; d0 [: t. y#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
7 H  N: o0 K  m+ ?- l# o#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)' d  r9 r) U' _& F( O! n
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
1 ]4 W  j) v! [" y6 k8 s0 f9 a9 L5 t7 |7 n6 T
/* assign the tl som board LED-GPIOs*/  B1 j1 _+ n" m* x* h  S
static const short da850_evm_tl_user_led_pins[] = {7 F8 y/ p( d5 v& y
        /* These pins are definition at <mach/mux.h> file */, _  \. b1 C# G
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,  Y0 m3 [5 w# v+ T# M; E
        -12 J, x! B: A6 s  ^7 G0 i4 {
};! z5 I$ X2 v4 i& J1 n& H) F

9 b6 F/ @% h8 r( N6 u, |; Astatic struct gpio_led da850_evm_tl_leds[] = {. J- R) I6 v+ z* z0 l% b- R
        {7 f2 {  l! I4 L- }5 E. ?3 p1 \0 m" r
                .active_low = 0,3 d3 U9 y7 H1 O* ?2 N$ i
                .gpio = DA850_USER_LED0,
" _) m7 e7 e1 o7 o                .name = "user_led0",
9 E# f: l" q# i                .default_trigger = "default-on",
6 V4 a& l0 `1 r        },
+ ~6 |5 C! K) T        {  B/ F2 F4 t, n6 v
                .active_low = 0,1 H/ t. E( ^9 @/ ?/ c
                .gpio = DA850_USER_LED1,: g( V6 ~7 ?: H! X
                .name = "user_led1",
9 [2 O' _% m5 h                .default_trigger = "default-on",
7 y% x) {. g2 A2 n# k+ ~        },
# \0 ]& n. q, u$ [        {
; r: {! r2 g& D                .active_low = 0,# J  z7 [, ?. q& }
                .gpio = DA850_USER_LED2,
" g& L- G, ]8 \% G' B0 u7 h                .name = "user_led2",+ M) |8 G" H9 C: Z1 }# b
                .default_trigger = "default-on",  b9 E/ z  f( P1 S. F5 h" Y" \6 Y
        },
4 q+ a  O! {2 B- P        {9 W$ A: c4 e% a9 _4 \+ p
                .active_low = 0,8 ^, L6 f  f) V9 V0 G5 g6 W
                .gpio = DA850_USER_LED3,+ `7 }$ c% a, A! ~1 @
                .name = "user_led3",
9 h9 H$ r9 T8 \* T; K+ K& A) r                .default_trigger = "default-on",' h" I, L9 ]; B. o$ q7 F' i
        },
! x9 _' {2 T; V1 s: L};
/ k/ Y! o7 T; x8 l/ g* X* J5 m+ x+ |) m) T7 s' S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {  m3 _; I  U7 q, w3 T2 D& |; N) p
        .leds = da850_evm_tl_leds,
% ]# n2 z- A% a4 Q        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 w# _6 C# F: m8 e1 S8 ~. V};
8 A9 D' e9 q7 a
* f/ l+ ~  x; f$ Kstatic void led_dev_release(struct device *dev)( a0 |: f% ^% M- B) ^7 ^: Z4 b
{# k  {2 a' P. }/ J. q
};+ g1 x- v  r+ Q
: H8 V+ N6 }; q( A7 Z% v
static struct platform_device da850_evm_tl_leds_device = {
6 n. \7 f( U* G4 F        .name                = "leds-gpio",& F$ h8 k. ^6 E# T% x6 H+ ]
        .id                = 1,
& Q+ n" H/ W2 U0 L! u5 H4 |        .dev = {  t  [- @5 b& g1 J. v
                .platform_data = &da850_evm_tl_leds_pdata,- U, w% N8 H, d
                .release = led_dev_release,' C3 d/ W3 G4 z8 x0 {7 A5 ]+ U, G
        }
! H& }6 T. c  Y( F+ A5 K};  n7 f5 G0 T9 C/ a5 \
! I$ d, B) X7 R/ m
static int __init led_platform_init(void)
7 V4 k7 V( Z0 r2 \1 e{  f, z1 C+ Z+ Q7 A6 z0 q( a
        int ret;
  \  i4 ^' M7 P4 t: c8 Y#if 02 k+ K4 _  X8 s% y7 s5 R  L: Y
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 q- m6 w: d8 G4 U9 B' l) Z: Q        if (ret)4 ?% r- J5 o) x& |; v6 ^; Q
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; `$ I' `  r+ Z& w2 n2 x2 X                                "%d\n", ret);
3 N4 ]* R% F7 D  }4 L8 s" V2 C- q#endif
$ \! H4 a' A! w+ ^3 u        ret = platform_device_register(&da850_evm_tl_leds_device);* c0 p+ I3 U) _1 H4 N1 Z
        if (ret)
4 M- }5 N) g+ n4 T5 s% x" o                pr_warning("Could not register som GPIO expander LEDS");9 K; X5 E4 c. e6 n; H, _) R
        else
; K! S7 _+ `" B+ L0 _5 C                printk(KERN_INFO "LED register sucessful!\n");
% c( u! c: h* L- p5 K/ B9 R, u' `6 N# E4 @, l
        return ret;' j3 ~3 l, v- }9 ?* _& T2 A: p4 y
}
9 U4 D6 W, H% ^3 P8 N8 O: V& F' i  A; k- Z7 q8 `/ f4 \$ T3 p6 |
static void __exit led_platform_exit(void)
5 M' L; t9 t6 ]{7 H) L( G! V; e! R7 @, i
        platform_device_unregister(&da850_evm_tl_leds_device);
" [1 `( {4 E% `5 g: x, r( o& @6 U" J( X
        printk(KERN_INFO "LED unregister!\n");2 a0 m5 n/ r( u& ~" w1 F
}) z7 g0 v1 c6 h5 M8 x# |

7 s! l3 |0 D. Mmodule_init(led_platform_init);
2 b7 S7 P& f, p( s8 y. Z" U& t3 Zmodule_exit(led_platform_exit);; E0 R  Z1 Z( q3 c7 B  ^) M

/ X' I4 s: b3 M; w5 q  OMODULE_DESCRIPTION("Led platform driver");6 u8 ~/ G0 Z4 A1 T9 A
MODULE_AUTHOR("Tronlong");- S  K9 B; h- C0 q9 j
MODULE_LICENSE("GPL");
9 g' G1 \9 L+ |# Q- v' t( i* o/ _; s- A" `/ n6 F
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-9-12 04:37 , Processed in 0.046315 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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