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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。" a) w7 a+ N; r% s* |& c2 b
#include <linux/init.h>& G. Z, i3 ~1 f* `
#include <linux/module.h>
; B: }5 W$ I. r; f$ J#include <linux/kernel.h>
0 n4 y4 ]$ K4 ~, q) Z$ ]4 i6 u#include <linux/types.h>
1 ]6 r. b0 @6 \! c+ b#include <linux/gpio.h># n: M' E3 g- L; T
#include <linux/leds.h>0 Y% V+ q, w8 @; ~3 }/ ~$ l9 e
#include <linux/platform_device.h>: [: u. T9 l4 v$ T& w9 a/ a9 W

8 D3 r; k/ F) v+ j#include <asm/mach-types.h>+ p& n3 `  u( Q/ ?5 F+ s
#include <asm/mach/arch.h># k/ u3 U+ a9 o1 W
#include <mach/da8xx.h>
1 o: _7 w' e+ q#include <mach/mux.h>
; s# {% H) f# R( z8 S2 ~. g
: I: E( P! b$ R3 ?+ g0 z& N#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
9 o/ y, G4 d4 K" \4 w#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)5 v- d- a3 C" j5 h: {
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)  _1 u6 u7 b3 E0 r( C6 R
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
! D0 R  g3 j9 z* S
% N; F$ i/ W0 v/* assign the tl som board LED-GPIOs*/
# V# s7 Q5 G" C7 p: w* ~& u8 _static const short da850_evm_tl_user_led_pins[] = {
2 W+ M" K2 y8 C% O/ P1 v7 j% x  ^        /* These pins are definition at <mach/mux.h> file */% c: U' I* w9 J1 g# X, ~
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 O8 r* b( w" o& J5 x
        -12 Q# [  _* B; G5 `3 O
};
" ^/ j  `, V2 @4 H) x5 ~0 Q  C3 @& W- g* ~8 l! |) r
static struct gpio_led da850_evm_tl_leds[] = {/ p! f2 B7 ~! B2 P
        {3 b3 U! A" F& |0 v
                .active_low = 0,2 z! `$ A) Y" }8 g
                .gpio = DA850_USER_LED0,: |& S5 d$ M1 X2 w$ b8 |
                .name = "user_led0",. S! ^( \7 ~- Y- L9 J
                .default_trigger = "default-on",0 b) j, s) s" ^' p" @5 l  F
        },- c- _6 S, y& e/ \, w, p. T
        {, s, I! R2 b. ]1 e
                .active_low = 0,
# T1 ?: e9 T: C/ g0 |                .gpio = DA850_USER_LED1,
, w8 _& ^+ w7 X, Q- _$ r                .name = "user_led1",& Y) T5 }9 K- x% l" @1 j, m
                .default_trigger = "default-on"," h$ r) B/ i# K' U
        },
' g! U6 z7 i& h! @        {
& y* Y4 \6 @$ x- r2 n4 V                .active_low = 0,
, L% J8 S' D0 r' d$ l: j                .gpio = DA850_USER_LED2,
2 Y6 ?# \4 D; G" ]% w7 g- S: l                .name = "user_led2",
5 A8 B$ o! [/ h/ Z# i                .default_trigger = "default-on",
. Y5 ~7 \4 H. i6 k& I        },, i2 r; m: r! h4 Y2 [* r$ @& f
        {
7 |- t- g1 x, S0 _4 y+ }                .active_low = 0,1 |4 X+ b( P, U3 \5 y
                .gpio = DA850_USER_LED3,! z/ [# x) }0 i. s- A9 q: A9 `
                .name = "user_led3",, W& t+ t) J- U2 B, g
                .default_trigger = "default-on",# U  N% d; _* c, ], `" a
        },; m* x! |# @, z/ Q+ o
};
7 k6 g( i3 @3 ]- u8 T
& @: G  z% N5 _7 _8 N8 Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% j3 c, N& w2 |5 X, p5 o! ~5 G2 e        .leds = da850_evm_tl_leds,
) K& X4 l" ?+ K' C% u2 k1 U        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ N2 Z# w6 a+ x$ c+ |- P' `8 j4 H6 g};
2 J% ^3 d& W: e; U
6 J3 M9 i9 A+ Kstatic void led_dev_release(struct device *dev)& _* M2 K% y: C4 L, y: x8 H) K
{; q/ o( v2 l" M. \4 [. m
};
! I9 Y1 `% I7 |. y
( O6 g! Q- H( p; N& ?, i. y; \static struct platform_device da850_evm_tl_leds_device = {7 ]0 q) N7 s5 V9 L7 j1 w1 l
        .name                = "leds-gpio",
8 a7 I2 [. x3 {, F7 o0 |        .id                = 1,& P+ ^- z+ ?; v  U
        .dev = {1 [: R3 A# K1 W) C& L
                .platform_data = &da850_evm_tl_leds_pdata," ^  L% d; Q8 x! J! Y
                .release = led_dev_release,% l9 W" p/ \; V! t) x+ D
        }
2 Y- i- {1 ?$ u: O9 f" ?7 @- k};2 d+ [' l/ Z- O) _& X

0 a/ V1 A% h5 istatic int __init led_platform_init(void)1 @0 @# K" y* k2 r1 d
{- a3 H# Y1 L  q; k1 n; [' l6 V' M
        int ret;# g! v' c) V- S2 T. v+ g
#if 0
7 ]% [  e+ z, E% r        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. `8 h7 J" Q5 ?0 H3 x4 K: `& ^        if (ret)0 H- Y4 h4 s3 a3 P6 D* f2 Q
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% Z9 f% \+ M% K9 E                                "%d\n", ret);
! J! a, }  |* f! R$ |#endif8 d8 w1 j7 a5 R5 S. e
        ret = platform_device_register(&da850_evm_tl_leds_device);3 Y; v/ Y! b6 C/ b
        if (ret)
4 i5 B% H& U5 b8 N1 P                pr_warning("Could not register som GPIO expander LEDS");
- n' M+ E: {* D; V- P4 X        else7 \4 O( Z% U2 m" V' ~0 J# f
                printk(KERN_INFO "LED register sucessful!\n");( k) `! g4 [9 ]1 g3 x2 N
$ E* O: B3 g9 d3 a
        return ret;7 ]( ?* @8 p$ F5 s* K
}' F8 ?1 S' F) f
/ n, F6 x: `( o- I' N8 O5 D
static void __exit led_platform_exit(void)% E$ v4 I; I5 j# ?9 K
{
5 Q* }9 l' u% Y" Z        platform_device_unregister(&da850_evm_tl_leds_device);
/ p) @0 q- d- y8 s1 E, l6 d: x6 v, C4 U
        printk(KERN_INFO "LED unregister!\n");) k* h8 u% z, C( V) f
}
7 v4 ?* f9 c* K
7 w; Q9 e- T' emodule_init(led_platform_init);$ ]9 Q3 `) |9 J+ I1 p
module_exit(led_platform_exit);5 u* V! d8 A5 j; c1 l

0 e+ b; K; A* t1 d& }MODULE_DESCRIPTION("Led platform driver");8 q0 f* n0 {5 S: X2 k" Y
MODULE_AUTHOR("Tronlong");& b4 ~& y/ X$ M) ?
MODULE_LICENSE("GPL");
& ?! S& j# Y9 ]7 _7 r" l$ b# X0 g0 d+ g( J+ _9 P3 I  O  T( o' |
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-22 13:16 , Processed in 0.039371 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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