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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% h$ }& I, B. N! U4 @5 }) G
#include <linux/init.h>8 ]# o; S8 B* D* Q7 ?
#include <linux/module.h>
, f' B2 H  U, k( c  y# W5 W#include <linux/kernel.h>, k. T1 g% w1 U8 S% V) W
#include <linux/types.h>* K% ?4 \( ~* H
#include <linux/gpio.h>
. H: J# {1 A# D, h2 N3 X#include <linux/leds.h>. n- S7 m6 B  i. I5 h
#include <linux/platform_device.h>
5 |. i3 A+ V, Z0 u: [  o
8 N$ n/ \& Y9 D0 m) [#include <asm/mach-types.h>
. e7 Q; Y! U3 W6 I#include <asm/mach/arch.h>
$ A+ N# E) {) l' F4 q0 h5 r#include <mach/da8xx.h>
& y( G; ^0 M. G; N$ ?! c+ f/ O#include <mach/mux.h>: T1 Z- y4 Z. t
) W/ A* X! U* H) {3 r! q6 K* `
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
* M% h% w& C; j; a9 c, q#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
9 d7 v; a- O( G; E$ O#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
# o- D: X3 x. w, b1 Z#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
5 z; `+ K1 k5 ]$ K% U3 @" x6 h& d: p4 h' \/ g0 D( P, a: @. f3 a( W* ?
/* assign the tl som board LED-GPIOs*/1 X* F9 c7 k6 w; x$ B6 q! E. N
static const short da850_evm_tl_user_led_pins[] = {( n9 R) ?! c, J/ S! J7 g5 \
        /* These pins are definition at <mach/mux.h> file */: m/ Q& T$ I# V, ]1 [
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 j5 C3 q  V9 Z9 n2 A        -1; ?, M! }4 ^" W' R
};: I' H5 Y7 v! n( o
  X  }  L$ G% {, k- A% W
static struct gpio_led da850_evm_tl_leds[] = {
2 {: I9 N) H+ N7 a3 H% d+ @" }1 v% F6 C        {; H9 [/ p. ~6 A. A" u8 r* V8 r
                .active_low = 0,
0 z# S* P  R( m  w5 A# h+ ~' U                .gpio = DA850_USER_LED0,
: P0 g% F+ U4 E; L+ f4 {                .name = "user_led0",
  N. |7 {+ y6 z* O                .default_trigger = "default-on",
0 y# |4 Q4 f! v3 ]. I+ _        },
+ i# W3 }8 H. t+ h        {
" T. v+ x/ ]0 J% v+ K% s                .active_low = 0,
! l* ~6 l; i: D/ p! h                .gpio = DA850_USER_LED1,9 ~" ^$ e9 Z4 _/ j* x4 D; c: I
                .name = "user_led1",$ }  x" J7 m0 C; a
                .default_trigger = "default-on",+ [$ X8 W+ Q0 |$ x: L
        },( E2 u5 y8 b' J! F& `: A; Y
        {
" S7 h& f/ W2 {5 T                .active_low = 0,  m) ?/ F1 f' b/ O/ ^  |
                .gpio = DA850_USER_LED2,. s! b3 h- F) }. ]' p" H) {( ]+ {
                .name = "user_led2",  @  f0 {" H0 F- C2 A: f
                .default_trigger = "default-on",
% q' o8 Y% N% ?        },
( N% P' ^" p1 F4 d) m- f$ {5 ~        {
3 H; S3 S0 J- l1 L$ K' v                .active_low = 0,) F1 G6 H% o  E% u7 t
                .gpio = DA850_USER_LED3,
( z& E% \2 c/ C5 Y                .name = "user_led3",( Q% z9 Y4 P& _  d4 V$ T
                .default_trigger = "default-on",
7 M# r. z) ~, m6 [8 y        },
! f9 Y& ^- }7 A" {3 ~" a/ M};4 X* h$ m& G, o, I

7 n1 r  F; t# s* c# I% a% Pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! q, _* g) n/ Z9 [2 |, @4 y1 {        .leds = da850_evm_tl_leds,9 \5 N' k; }8 E$ B  S6 m( B
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 d9 H# p( x4 U- \2 x1 U
};
2 ~4 D: J+ A3 {* G4 q/ b8 L; ]# o/ ^9 ]: M+ A
static void led_dev_release(struct device *dev)6 Y" t. N$ z7 L+ C
{
7 k' h% a- @7 S: j};$ K1 G7 F) s' [) f; n6 F8 X
% v' `1 q4 y2 i. w+ f* B4 U2 y
static struct platform_device da850_evm_tl_leds_device = {' C3 a. M4 S/ d, U2 l8 l
        .name                = "leds-gpio",$ ?1 @+ i* ?* w1 M3 X
        .id                = 1,
" L; }: I* F& v  w, Y4 O. k  L        .dev = {
6 \+ ~, J) \$ N+ c0 c5 b1 x: m4 E/ w                .platform_data = &da850_evm_tl_leds_pdata,* p7 O  C3 P% v$ U- R5 Y
                .release = led_dev_release,
6 Q+ T- d- f# O        }
: p5 @* y% D6 @# b0 a6 N9 e};4 N* ]9 M7 R! c
4 S7 [) n3 }( n( U. }
static int __init led_platform_init(void)
4 ]7 k. K: r* Q# p& q{
+ f$ S  t  @9 b3 l$ q  A        int ret;- x2 @) q0 B  H1 J* g( L, k  h4 e
#if 06 d  p' G& i* o, `% n; P  ?
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# H' `* \5 R  C
        if (ret); i2 n; ^! C" T
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* |9 y' u. s" |$ j! k7 a2 p8 O/ x
                                "%d\n", ret);
: q& ]' L2 z" l  Y#endif4 R$ @' y  C5 p( K- R$ C  l+ \
        ret = platform_device_register(&da850_evm_tl_leds_device);: U: ]/ m) W3 e
        if (ret)5 l' ~& L- @/ l; i% [  p$ ^
                pr_warning("Could not register som GPIO expander LEDS");
& w* K& N4 ?3 }0 D2 G. P3 a7 Y3 R        else
( s' d7 z. j! ^; D8 N$ ]* ~                printk(KERN_INFO "LED register sucessful!\n");
0 S) `1 G& P; H: E! M8 q/ B; S$ x  O3 a2 |4 \+ M2 b
        return ret;
/ y8 o: E( H* y, |# j; u0 e}% [% W- a, m% w. v+ d- u

6 h0 ^- u' ], G! f3 Dstatic void __exit led_platform_exit(void)
* P4 }1 {. L- Y/ ~! f& M{
9 K+ Z) J% s* ]3 }! V        platform_device_unregister(&da850_evm_tl_leds_device);- T7 P2 O+ `2 {) R

9 ^5 k4 I# E% i        printk(KERN_INFO "LED unregister!\n");
) G- A5 c- a7 a  U8 y9 \}
0 T7 D4 W- ]: ~5 n0 w. A: B% u$ ?  J& x+ b# k6 {/ z
module_init(led_platform_init);
: F/ ]2 D2 J- K; N) Vmodule_exit(led_platform_exit);! z3 z& y  x# v0 c& I* u

3 Y& A: c$ s4 \# i/ \0 W4 m! HMODULE_DESCRIPTION("Led platform driver");5 N# @" w. m: T% {4 j5 ?
MODULE_AUTHOR("Tronlong");. ~# L$ B* L8 c7 T
MODULE_LICENSE("GPL");2 K, f. d# m  Z& X& o

& g  ?% \" p% O3 J6 p- K8 x0 e
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-5-23 09:01 , Processed in 0.046141 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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