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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
9 Y& O+ M- u9 @$ g#include <linux/init.h>3 u/ l$ q6 P* A
#include <linux/module.h>' _: h8 `/ D+ `# ~5 W
#include <linux/kernel.h>
* c! @# r0 N% f& B# O: I#include <linux/types.h>+ `. A0 K" K+ d9 n! w: _0 A" V0 ~
#include <linux/gpio.h>
$ W! k/ R0 q4 t/ b  T5 g#include <linux/leds.h>, f6 z6 u6 X5 \/ G1 G
#include <linux/platform_device.h>
- m3 ?/ e8 Q2 R( H" A4 d+ h* O; j- [' k
#include <asm/mach-types.h>
5 S; T0 i+ Z# w( ?#include <asm/mach/arch.h>( x* U1 z7 j; M- p; q
#include <mach/da8xx.h>
/ m. a# }" \  d0 w. R7 o7 \#include <mach/mux.h>
' v  D  k. @! d. c! l3 p' Y# e6 R' w# a" Z3 m- H
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
+ B8 F0 N! E+ p: S% V6 I#define DA850_USER_LED1        GPIO_TO_PIN(0, 5): C6 j3 a3 U7 c& E7 s
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)' A+ Y. o* r$ t
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)4 `: I9 e: Y9 M" q, N: m

+ G$ }! P$ |5 A, P( q7 e4 b% J/ Y/* assign the tl som board LED-GPIOs*/7 t& \4 k0 s0 c$ Q
static const short da850_evm_tl_user_led_pins[] = {3 V  |" U* b& K; V( a( X5 e
        /* These pins are definition at <mach/mux.h> file */
4 W1 G) i7 n/ f; H# }$ F+ A3 x0 M; l        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
  \& t% L+ Q: v$ l$ O  W        -1; r7 o( ^; E) V
};. M" g, w2 G/ e3 R/ _1 R
8 ~9 Q( Z& o$ w( }7 V
static struct gpio_led da850_evm_tl_leds[] = {
2 E0 k, c& o6 J% n+ c7 L        {2 D' G6 G2 P  q! K( a9 R5 l
                .active_low = 0,
/ X5 F& B4 U% r/ E# `( y. q                .gpio = DA850_USER_LED0,
8 C( m0 s$ ?$ D                .name = "user_led0",
7 `5 g0 V+ d4 a( t' n5 C( J. I                .default_trigger = "default-on",1 Q9 k( i( }3 S3 w( G
        },
# W% l) I/ T/ g. W, H3 Y6 U5 u        {* O' I3 {" L1 M
                .active_low = 0,, v. s4 Y- }& q( j- `# v
                .gpio = DA850_USER_LED1,
4 N0 R( D7 P1 e- Q% `- p                .name = "user_led1",
! v8 G3 V7 w. l7 C: z/ H                .default_trigger = "default-on",
9 M- P) ~* n, B% F- G        },
  k# M9 J1 o7 W! h; x        {
3 R( q4 b, V. b1 q1 l; Z" R/ Q5 s8 r                .active_low = 0,
" S8 y+ Q0 k! e                .gpio = DA850_USER_LED2,
; W0 E1 [, G6 O9 E! Z                .name = "user_led2",
5 S& q$ B$ k7 @' k                .default_trigger = "default-on",/ B# O0 ?- I1 T' c* W- R6 s* q
        },1 @9 A2 ]* {; O! t3 C5 {
        {
. [* G8 w7 t' r: t6 E                .active_low = 0,+ ]) t( @# q4 F$ N) A; x6 Q, H
                .gpio = DA850_USER_LED3,! P; }; {" O9 C# ]
                .name = "user_led3",/ U1 V' L; I+ y7 \) L
                .default_trigger = "default-on",
+ i7 F7 S5 Q4 }, Y! u        },
2 r, b3 r8 @( z1 m, q' V};7 d& ~; j2 o1 R9 B2 E, R5 m
- c/ r" X9 U: t. ~) O. X' I: I0 \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 O2 n' j0 z- t( E( N7 l- \        .leds = da850_evm_tl_leds,
5 |8 e# q! H% s        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),  F3 K0 b# _4 Z5 s1 X! n
};% u; P2 y( Y+ u  f7 k# W

0 g$ x9 W5 t0 w8 z( ]9 x' cstatic void led_dev_release(struct device *dev)+ d1 m) f# k8 l0 l8 K
{
6 q4 j1 _- N4 o) w3 w};
% b2 f8 M; T" v/ ~6 [7 T- c2 p6 s" y- l( ]$ [
static struct platform_device da850_evm_tl_leds_device = {
0 f1 C, }0 U" w& R        .name                = "leds-gpio",
& c' w) h4 Z; G- |/ g        .id                = 1,
5 ]( t7 D9 f& W2 Y        .dev = {" \4 P/ n" |9 a  B; |: o
                .platform_data = &da850_evm_tl_leds_pdata,
7 ]2 L! g; R0 {1 X4 p* w                .release = led_dev_release,9 a% U# S/ N/ Y# b
        }- O" l- ~) u( L5 D( a6 \
};3 T. e. ], K/ r

' [8 `; J8 \  R5 x# u4 S( |static int __init led_platform_init(void)/ \- r" @: e( u9 b* k* I
{0 [0 K: h4 N6 E! b6 y4 e
        int ret;! a: Z6 c  K9 D0 F7 r
#if 0$ i$ C8 M- \5 r6 e( `
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ L4 \) ~1 S/ O' p. f
        if (ret)
: ]  W7 F8 ^) W% ~! {6 u1 e0 H2 O                pr_warning("da850_evm_tl_leds_init : User LED mux failed :", v9 ?$ F+ t6 b; z* Z# \
                                "%d\n", ret);0 e' ]" o- z) P& a8 [6 U
#endif# p9 f7 Q; p/ O* u% z( `" r: v8 p! v
        ret = platform_device_register(&da850_evm_tl_leds_device);
9 _& @  w( b/ h: F* ^: Y: w        if (ret)
1 q5 J  t; D- J; E                pr_warning("Could not register som GPIO expander LEDS");
- P. G, A6 s3 X  H# F; `  x6 B        else
+ W0 M3 ^/ u3 e5 t                printk(KERN_INFO "LED register sucessful!\n");
# D/ r3 `* K- s; [2 b6 w
+ I! @2 g- f* V( y        return ret;1 f$ g( v1 `( i
}
3 M- _5 Q- e# Z7 [' h) ?. h2 z3 e- ]# H3 n; I: B% Q
static void __exit led_platform_exit(void)
6 g7 g8 K0 U# x8 a$ o# g{- c/ B& i4 N( u8 @8 k6 Y
        platform_device_unregister(&da850_evm_tl_leds_device);1 u$ V$ m8 \9 D* D: Y' ~
, b7 a7 F8 Y& G+ U
        printk(KERN_INFO "LED unregister!\n");
9 z! W; _5 l& b7 q}/ q! X  v& y$ _7 N  ^

' x3 ^# W9 Z# I  z8 \8 rmodule_init(led_platform_init);0 M+ T+ t# M6 {( ]2 ]
module_exit(led_platform_exit);
3 Q2 L# {5 Y( H9 y" q$ `, [3 R% b* z- `. U8 [5 A# y0 _
MODULE_DESCRIPTION("Led platform driver");) z: c1 F3 V$ x; g
MODULE_AUTHOR("Tronlong");! k' c3 x5 k' r* c7 y. E2 Z
MODULE_LICENSE("GPL");
) W2 b* J+ j" K  ?& j: U" H0 c* g, Q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-6-27 02:36 , Processed in 0.040819 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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