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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
% c; g& t( Q4 S2 y: |  N0 s#include <linux/init.h>
% [$ j. T6 m9 y#include <linux/module.h>
( c2 _: l1 G2 C) ?; u) S# h: [6 V3 l#include <linux/kernel.h>) `  l7 E" L5 C. h  Q) Y
#include <linux/types.h>
* V. P' _! ?& P6 ^1 u8 ]#include <linux/gpio.h>
4 y+ m- N8 Q, f3 W% l  v& f& T#include <linux/leds.h>' V) ~4 K4 j% m" v, x9 X
#include <linux/platform_device.h>* ^7 s* `. O$ U$ g  w

( c/ F& s8 f' S. C$ p9 f#include <asm/mach-types.h>/ w1 Z( d3 v+ K* H& P5 `7 f8 a
#include <asm/mach/arch.h>
% t( r% F! g6 p. C+ b. B#include <mach/da8xx.h>8 z6 Y  D" ?8 \0 c+ M
#include <mach/mux.h>2 ~( n9 N" B4 j/ L
8 @3 P3 Y) x. V: }5 {
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)( @  z! w* ^( c0 b2 D
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5); O5 l' u( X3 ]/ \/ p+ a
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)3 t) C3 s. p4 C- x/ p
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)$ R5 c7 k3 S9 Q) U7 z7 g  E$ B

" w5 u" T! R. _, S/* assign the tl som board LED-GPIOs*/4 P4 O+ M& j: \
static const short da850_evm_tl_user_led_pins[] = {8 W4 L" x) I7 T6 _
        /* These pins are definition at <mach/mux.h> file */
) s- z" e5 B! _  Z3 f0 G        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* X( Y4 f/ ^; p: c& I
        -1+ [: K  d5 U+ k: ~7 h" ~$ B
};
( J$ Z9 ]" t/ m  k3 k% v7 H8 ^1 a! T& X7 H, p& k
static struct gpio_led da850_evm_tl_leds[] = {; Q: s! [' S  q+ M, T0 L* |- g! c
        {
+ m6 e2 |5 t; Z, s                .active_low = 0,2 J, b4 Z/ X! ^/ B3 D  e
                .gpio = DA850_USER_LED0,
) T3 c& N/ ^, P* u- [                .name = "user_led0",. u7 X, z$ o6 \2 N) r
                .default_trigger = "default-on",
2 Y; _) w8 H: z0 V9 }9 ^6 B        },
& V( c8 c0 X" P9 `5 ~0 e. H. A        {2 P5 z& d$ q( J, C' W
                .active_low = 0,
( T5 J; w  S' r/ C6 d2 y                .gpio = DA850_USER_LED1,: S9 V; z5 u. [4 n* t# H6 ?# v
                .name = "user_led1",5 [: L0 M  `- X& C4 \: H  F
                .default_trigger = "default-on"," R" Y9 h- `. ]! H
        },$ h! k) I! C' ]# Z8 |% ~
        {
( u2 u* ?* {) v+ o1 f" x                .active_low = 0,/ a( V, e6 O0 u( w* q9 }) a
                .gpio = DA850_USER_LED2,
) \: |& l$ V5 L  ^2 a                .name = "user_led2"," r2 b2 h4 k$ G
                .default_trigger = "default-on",
" k' ?5 G3 q. M. @- e: p  m! W' ~7 R        },9 v8 [" {% U$ `% X- j. o; c
        {
5 _" Y3 [5 {9 n0 @- Q/ p. C& Z. o                .active_low = 0,& P; Y0 Z7 f& X& Q4 i7 _# z; m
                .gpio = DA850_USER_LED3,
' [2 G4 A1 g0 R: y! W- i, W) e                .name = "user_led3",. Q8 |! K' K8 o" F! z5 p
                .default_trigger = "default-on",
# e8 ~$ m. U9 Q( `" C        },+ J1 s+ z$ L+ K  L  X9 s
};
+ Y, U2 \7 Y" j2 P& M" H
( K% [7 x0 R: Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- A1 ]! B" c9 h( K. r
        .leds = da850_evm_tl_leds,2 B7 R/ q; ^9 X8 k8 d3 e  v& M
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& s" P* C8 J2 m7 {
};/ p* ]  y9 O( V& @

7 z, P8 S: `0 p; j+ |$ istatic void led_dev_release(struct device *dev)1 f6 O' w* m. y) s: J; i9 k
{, E8 R) F8 j9 @4 m& z( ?$ s& z
};# W' X- E; G- {

; K: c% v1 j: A0 g5 y8 }static struct platform_device da850_evm_tl_leds_device = {
4 K& J! O) N; O6 V# l5 ~        .name                = "leds-gpio",) s8 ^- T8 U" G5 l% B+ P3 g7 m8 u. j
        .id                = 1,4 H4 R# G! _, Q4 t4 Q# k
        .dev = {" h8 A  c+ L) _, z0 G# ?! S
                .platform_data = &da850_evm_tl_leds_pdata,. K' M0 B  G9 ~3 w' U
                .release = led_dev_release,% G0 ~+ G! _+ q- A( G+ d, f7 D
        }5 b! x7 `8 \$ h9 G
};
: O/ o( _2 ?( j" a3 g9 v
; g  ]" r/ j2 b1 d, r+ g( Pstatic int __init led_platform_init(void)
' f* {- y% t# |, H6 _* s) q3 _: ?{
: A$ ]" w- e5 I: G$ }        int ret;
' u$ ^2 M1 r* G  U1 }5 {* u$ F#if 0
- R3 k; B4 i* e6 Z. c        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);  D' h% r& g9 V! X. X% ^5 \
        if (ret)2 _2 T' u: \$ O4 L
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 }: E0 T- ]) J! F7 g1 [: z5 [                                "%d\n", ret);& q- z( F' d; q/ Y
#endif
" E( N+ p. v% ~, T6 [. @6 j& V        ret = platform_device_register(&da850_evm_tl_leds_device);6 m0 P* l8 R0 ^0 a. p
        if (ret)
( F! T" M  r. j# E& Q                pr_warning("Could not register som GPIO expander LEDS");
) N8 _# n1 \/ k2 E        else
, k! U8 X! n$ j+ W                printk(KERN_INFO "LED register sucessful!\n");
$ W" x" c" W! C. B6 q, _/ a/ f9 C! o3 z) b, U- j+ P- o
        return ret;
3 o/ {% {: q3 L0 t" |2 m. f}
, w5 \, l" l3 E$ k' N' a
% n3 H4 r* j! Astatic void __exit led_platform_exit(void)3 q' j+ ~- X  t# ^6 M3 ^, y6 m
{
* n) i+ Z% g$ |/ a0 y% P1 b        platform_device_unregister(&da850_evm_tl_leds_device);
  O1 n, A5 l$ K* s; b9 e+ q. q
9 D2 Q3 |& d' }( w: v5 _" A        printk(KERN_INFO "LED unregister!\n");
7 E/ q1 v) q! C; r) ?}' B9 L* w/ }3 W/ q/ y% U4 U" H

: A7 l' D' A0 s# T2 pmodule_init(led_platform_init);( o. b+ d! @0 O) b; \
module_exit(led_platform_exit);0 t. P7 x5 f/ e7 U* G) K. V5 }
% c! N  u- N7 D6 F
MODULE_DESCRIPTION("Led platform driver");# {0 N% ?3 [7 a- N
MODULE_AUTHOR("Tronlong");
0 N$ w: T+ V! M3 h% IMODULE_LICENSE("GPL");- N* T3 m3 {" r: H! g! G
; \4 ?1 M7 r8 t& Q7 e) ~% }
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-30 14:12 , Processed in 0.038959 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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