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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。( h# G, T2 l) [/ L$ U
#include <linux/init.h>* d" P( C; {, G* ~4 l# E6 M
#include <linux/module.h>, t  h/ N# v8 J. J4 W" u
#include <linux/kernel.h>
- Y3 j$ I: w# N  H, G4 q#include <linux/types.h>
$ [: w8 k# }- P4 H) W( A#include <linux/gpio.h>6 M; l8 t" z$ j! n! \, O7 C
#include <linux/leds.h>& ]. ]3 ]: S* \* q
#include <linux/platform_device.h>
/ w+ _* s3 y- h( P  Q! g$ V8 Y: M! S: D+ ^6 ]3 s) D' r+ \! o& `2 v
#include <asm/mach-types.h>8 U& }; v0 m1 z* V/ N& C( V0 _
#include <asm/mach/arch.h>
# o2 m0 \/ h, q& }#include <mach/da8xx.h>
. |0 o7 b/ y; M4 ]% T  z#include <mach/mux.h>
" m* ^$ l$ n6 n! p# O  f) W
# b( k/ B. F) q; ]#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
( F+ ]$ c2 h0 u9 F9 H5 j; V& D7 W#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)6 T/ Y0 u! `2 ]8 C% @8 Z! o0 \
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
$ w7 t4 I4 {) T2 q: _& g- j7 k#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 A, E8 p+ j7 L/ t
7 |" u' N# Z9 z/ M& o2 \! S- ^
/* assign the tl som board LED-GPIOs*/
8 G9 R; Y4 y9 t: z7 Q- ~7 [static const short da850_evm_tl_user_led_pins[] = {
) o" J6 l8 ]+ t* C% \& l        /* These pins are definition at <mach/mux.h> file */
! A6 V; _" [- a$ S6 X        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ o- x( M; S$ U        -10 c) J8 @8 G% a
};# m9 E6 [( K6 Z5 I! t7 Z+ P6 y

4 z0 z; J  B/ n7 J# V( ^static struct gpio_led da850_evm_tl_leds[] = {2 O6 v- f- n. P
        {2 @) H2 f( G, D7 _
                .active_low = 0,) G- P7 f  r! p8 Y4 k* ?
                .gpio = DA850_USER_LED0,
) \% g! m: }, I- g                .name = "user_led0",) ]: ~  a& M' s6 `# }( r% @
                .default_trigger = "default-on",
5 b7 ~0 K( R; K& O" L) ~        },
. W' h+ @( n# |% k+ w        {
5 o8 P' ], X! C3 m2 [                .active_low = 0,
/ i2 f: U- _- S7 D" A                .gpio = DA850_USER_LED1,
9 l7 R( u# o2 N" B$ l7 S- Z( z                .name = "user_led1",
& g  y6 b0 _' m& [" Q, j                .default_trigger = "default-on",
( N" b; X! ~; F6 [: U  [2 `2 b& B        },0 A. M+ o8 u3 w3 S
        {
& L1 P5 p7 V6 I  Q5 g                .active_low = 0,5 p5 M* h. U2 N' O4 ~: O2 K
                .gpio = DA850_USER_LED2,
- [( R6 m* p/ Z8 K4 L. k6 M' R                .name = "user_led2",
4 v- h' K5 ~) p- c8 W+ F                .default_trigger = "default-on",
* g2 @, ?- U, p        },. E* ]% D7 Q3 P; c0 m+ e; q
        {
5 v0 c( V7 f3 F0 r. @1 C+ V                .active_low = 0,' L% w( D: F) i9 E( w, b
                .gpio = DA850_USER_LED3,
9 \" W+ q8 F3 P! D/ A4 |# P" q                .name = "user_led3",; j# z% R$ c- e& l' g
                .default_trigger = "default-on",
( D! W3 U% P9 D" c  G% L        },/ M3 z+ A) d% u; m% E: K. z
};* ^" O3 ?4 B) q7 w6 j4 x
' d6 f) j/ s" y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ y1 ^: p% f8 L2 F
        .leds = da850_evm_tl_leds,: F4 N* M$ {! k6 R6 q2 F
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 M9 y/ ^5 O" \0 d! C- H
};7 l* u% @; I- y

9 n- E+ n9 N5 F+ Q* W7 G8 f  gstatic void led_dev_release(struct device *dev)
# q+ I! M) S- o* M{; U* l! o2 x% A3 u* p& w
};
3 J; [; Z8 P/ w5 W5 i( K! y0 ^3 C) @4 p& ]" z/ i
static struct platform_device da850_evm_tl_leds_device = {
) p  B. d' A0 j! H, p        .name                = "leds-gpio",
  A5 P/ g# H/ c+ d        .id                = 1,! l0 o: P5 X9 Z4 r# h: W" C
        .dev = {
6 F+ J- `% k/ ?) ?/ z4 M' `                .platform_data = &da850_evm_tl_leds_pdata,( s- R0 [' I( X$ n! T! ^9 H
                .release = led_dev_release,, R3 |$ J1 M. e) F! T  [
        }+ D+ T4 u% Y' K& q& J
};( K' u- q; W2 V  u, o% n( m$ m) P

4 ^! _; ?/ }: d) \! y9 C5 m# v3 dstatic int __init led_platform_init(void)/ I2 b+ l7 B4 a; l( k3 \; K
{
) S$ q" W3 L  Z* f3 R        int ret;5 d$ v& p* C2 \0 R4 p3 U, g
#if 0# R: c+ w. \% H8 {
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' U% V2 _4 X/ V8 A9 {" z        if (ret)
# n9 e+ j" p) f9 k2 r                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- I) z# F  Z1 n" Z, A0 M2 l2 b( l                                "%d\n", ret);" ^  }* H* E3 \
#endif! w6 D; K% s& t! d. a. `
        ret = platform_device_register(&da850_evm_tl_leds_device);
5 s  k9 F2 O5 Z& a& d) ~/ T        if (ret)
6 d6 b9 r/ O! C  {3 }- C0 `                pr_warning("Could not register som GPIO expander LEDS");
$ ^, g2 w* ]6 Z$ e        else
) H$ _- m- j* L) [$ d4 n; w+ Y1 B                printk(KERN_INFO "LED register sucessful!\n");
: P6 A& v" R0 m5 Z. f8 ~6 i4 r/ {  ?) \& D
        return ret;
% G  _* G7 U! U% s. {}& t) K$ e' |2 C" U! b

+ [$ u7 x/ F3 g, a2 Bstatic void __exit led_platform_exit(void)
4 k6 @& U" A$ ]) h; ^( q% I: l{
$ e2 H7 r( g) u0 I) m        platform_device_unregister(&da850_evm_tl_leds_device);: z& y2 f( f- T/ ^' W

- V2 G& [( B0 v+ Z3 P# q( h        printk(KERN_INFO "LED unregister!\n");
; Z0 q: j! i0 d}
0 @! R! z0 h; r$ Y. p8 R, h  X9 `) l! @
' }1 k3 D: S! @# l3 A' Jmodule_init(led_platform_init);
$ {. E; {9 h/ ]+ |module_exit(led_platform_exit);
1 _& }7 o- c6 Q* E3 M/ o& G3 j6 x- n& U$ W% X
MODULE_DESCRIPTION("Led platform driver");4 k% F2 K8 P! m& Q8 V3 f
MODULE_AUTHOR("Tronlong");
' ~" x& L8 F  t5 ?, zMODULE_LICENSE("GPL");$ C+ @. n0 ~; t; a

: ^" Q5 D  w& M! S
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-3 22:19 , Processed in 0.058302 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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