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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。8 W. ?3 _9 C+ d
#include <linux/init.h>$ f6 ~6 R) w# x: V8 R- i5 E) C
#include <linux/module.h>
. ~; v1 _6 k% c: v- s4 U#include <linux/kernel.h>
2 g# [- i+ z7 V4 g. e( q' y#include <linux/types.h>0 `9 T& p8 S' B/ t! T, G0 d2 a
#include <linux/gpio.h>
$ C* p5 `4 \5 F) J5 m8 B0 V2 Z#include <linux/leds.h>5 I3 m( f, X) [% \% r
#include <linux/platform_device.h>: h% ~2 v8 d3 B- }5 E6 |+ [
# Z& j( {: G' x9 s5 m8 {" P
#include <asm/mach-types.h>" E) P1 g" Y8 M2 K1 \
#include <asm/mach/arch.h>
3 i; m% b, w1 ?& F2 ~6 {5 ]% w#include <mach/da8xx.h>
0 _; t  |5 p$ @#include <mach/mux.h>- [2 R; S8 l4 l( e" ]0 D' g$ N

" q# s+ u! c2 ~#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
1 X$ I" ~# V, x/ b4 q/ r/ X! W#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)- R% \0 H, H7 Z- x. m
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)% k( r$ L9 `% u. Q5 v0 x
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
9 W2 c: T, A2 C8 b$ r: \
; X5 T  z) n, u+ o& z& @4 X0 c: R, m/* assign the tl som board LED-GPIOs*/. U" m/ a# M/ y: `. ^) ]+ ]' W
static const short da850_evm_tl_user_led_pins[] = {! l5 h( Q0 S' }9 V1 ^
        /* These pins are definition at <mach/mux.h> file */! L+ n4 U, z, _- c& z9 h. M, k
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# J& t' {2 l8 ~) }( A3 ^- A- T  H
        -17 S6 u$ L* y! C8 W5 h4 Y% p6 A
};, |3 Q2 H7 U) P7 @
" [4 a+ q) f+ }4 V
static struct gpio_led da850_evm_tl_leds[] = {  v$ @5 h) O# {# A: Q
        {
- ?# K) R% {6 x: M                .active_low = 0,* l. }% v% n( k# a/ P" q( y) H6 ~
                .gpio = DA850_USER_LED0,
. n; g" u) M% h6 o+ |3 m                .name = "user_led0",* X8 z& E6 @- w
                .default_trigger = "default-on",
3 O) d; i2 n- \        },% A  F, @& w, V( Z, W- z5 [4 |: r5 N1 m
        {$ e5 y9 @3 `3 T% F9 o+ Q" U- ?
                .active_low = 0,
, K  b5 @2 D( R3 t                .gpio = DA850_USER_LED1,: ]  E$ B  ^% z* J$ Y
                .name = "user_led1",6 K+ h8 X# l& |9 u2 ~
                .default_trigger = "default-on",4 V3 @) F3 T5 t& n/ q8 j! T
        },
' V' Z3 b' S" R) @4 Z1 g. }        {4 K- D% N% S' n8 t' d4 @6 e* B0 _
                .active_low = 0,
: k2 k  ]6 ^2 R$ S/ R% `4 [                .gpio = DA850_USER_LED2,
0 t9 b5 @: `: U: a$ `7 e3 Y                .name = "user_led2",0 P3 \- G7 t) U' K6 d
                .default_trigger = "default-on",& u$ K  G6 O; O) Q
        },
0 _- U; A* ~0 {: D1 E  [        {/ t! F; ]* I. q! l9 _
                .active_low = 0,
  z6 \/ j0 H7 m# M7 Z; G' ~! x8 t* O                .gpio = DA850_USER_LED3,+ [1 N, k/ E/ g# r: b
                .name = "user_led3",
+ E7 I/ T( {) Z2 W                .default_trigger = "default-on",
9 f. V3 M1 L( F+ M        },: D) Z2 t4 n% e
};  M/ j8 t+ r" c$ K2 E( L/ P& L  k
" t6 Z1 V7 u, g$ W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( b+ K8 X% C& p1 H+ s% M        .leds = da850_evm_tl_leds,
1 a, g/ D. B9 L  f8 v; @0 y8 v        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; ^  k: r% {" m# d7 g1 R+ O* N4 f};% a" R5 _& W/ |6 |/ ~) f

# o- |3 V# S& mstatic void led_dev_release(struct device *dev)& b- i" m, \$ o$ z' ~+ H( q
{
  a' M* A, ~3 A8 d6 v( h};
4 {3 Y; m2 |% x
9 U+ A+ p2 b* Astatic struct platform_device da850_evm_tl_leds_device = {8 Y$ d/ M$ s! d! l- T# u
        .name                = "leds-gpio",7 h( Y) t# I- Y9 f$ O7 D- b+ z. a
        .id                = 1,
- m/ j, u: l2 W3 X        .dev = {; U. |! d  ^$ T9 ?! Q$ J, ~
                .platform_data = &da850_evm_tl_leds_pdata,5 z) W4 O6 R3 U' n" C- ^+ U
                .release = led_dev_release,% w$ s( [/ j# L3 I
        }/ D+ v1 N/ t# X7 ], q( b1 l9 i1 e
};% u0 S! v& J$ a$ I, q6 s! T  u

! f/ x0 ]' g$ @9 ustatic int __init led_platform_init(void)9 S* \8 p. [; N7 ~: L
{. j/ q& W$ f) K  T" f/ V/ ?3 ^9 F
        int ret;" w/ e$ Y* A! X4 p- _5 c1 t
#if 0" l, I- D7 i) R; a8 d1 C' \+ i/ k
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 E+ v& Y' e- L+ V% k
        if (ret): O& R  a8 L7 P1 z- T
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 k7 q! Y8 v$ L4 b9 L# A$ M
                                "%d\n", ret);
+ G+ L/ z" a2 J: H2 g#endif- F: K3 O5 t: K* m0 U
        ret = platform_device_register(&da850_evm_tl_leds_device);
7 e9 \  m$ ^/ X& @4 R        if (ret)7 \; Q5 J( c  Q2 O6 Z0 I
                pr_warning("Could not register som GPIO expander LEDS");
3 ?% [+ R2 `" _- }2 v1 m5 ^+ ^; K2 |        else
. i" u4 I: P# M6 b* q                printk(KERN_INFO "LED register sucessful!\n");
% o& j8 d4 a3 u1 }$ ^7 u$ Y8 A
* `: [" w/ u9 L9 n/ }/ H        return ret;
' d0 ]- U& F3 F- U/ w* g  A}
; M( a; G; K6 e4 O7 x) {1 S7 n" Q
) o9 L% X" A! wstatic void __exit led_platform_exit(void)" S8 Q1 f; O' w9 q# Z: L4 U* h
{: T! s8 W: p+ c' h1 s/ }1 ~
        platform_device_unregister(&da850_evm_tl_leds_device);
. A9 C) r. }, B
  u0 X( W& D0 J' g/ h* q        printk(KERN_INFO "LED unregister!\n");6 F0 C  Q, j) O4 H% f- ?# K
}& b/ @6 D. |: X1 N
8 v$ k0 u3 E' o0 [) k/ _& w
module_init(led_platform_init);8 N# O1 C7 m$ X) b9 b
module_exit(led_platform_exit);% m! R! W/ Y1 O4 Z$ E2 P
3 k* D& |6 x) [8 J" M9 T/ D
MODULE_DESCRIPTION("Led platform driver");
0 J9 W+ G9 L- X$ U# u: z2 eMODULE_AUTHOR("Tronlong");2 D. s1 D& C3 l& u+ o* ?
MODULE_LICENSE("GPL");
, d& Q+ @$ s' B1 U+ B& Z- b; B; K  a, y
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-6 19:03 , Processed in 0.037681 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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