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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
: i. h: j  _6 a3 I) ^5 j5 F#include <linux/init.h>. s6 V' A5 {+ k$ D# U5 l7 p% Q) Y
#include <linux/module.h>
# O, n- n' g( C; w#include <linux/kernel.h>
: ^" R  {3 _/ p5 m6 U4 p8 C#include <linux/types.h>6 j5 N% X+ l: S( C1 h
#include <linux/gpio.h>7 F' G8 ]& O# x( W% F8 }% s
#include <linux/leds.h>
9 z' V; [6 S) @7 ^" V+ ~. X#include <linux/platform_device.h>3 F! N3 u. j  `7 T
# V; U4 M! h% |
#include <asm/mach-types.h>
( t/ ]& ^) r" L% h2 h0 V( F! }#include <asm/mach/arch.h>
9 e, r9 _7 |0 V9 W$ }$ B% |# X#include <mach/da8xx.h>
1 P) \8 _9 h. L  e% a#include <mach/mux.h>1 R5 |, C& Z; h: g( D' M
$ k2 h% C2 Q- R: }5 O
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
( ?5 o! q" E( E2 H( n- z#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)4 R1 W/ \4 t; I; f: M: j: y; d7 a
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
2 a" s* ^6 S% F#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
6 l' ^' B6 K. b9 s" F( W
. d) a( C( g3 v: j1 ?/* assign the tl som board LED-GPIOs*/! K2 v; }# p; u  |# o. K. u
static const short da850_evm_tl_user_led_pins[] = {* p; g! i1 u6 n
        /* These pins are definition at <mach/mux.h> file */% m$ r. v( [) X1 u" C
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 z+ O" G7 K2 R        -1* T' B, p! ~7 |2 l# L
};
7 I" A  D) ^" V# W3 G9 P' W% ?& n: I( ~
static struct gpio_led da850_evm_tl_leds[] = {8 |# r3 r: e9 m9 s/ ^
        {( }% m3 Q" k, A# a9 x: S! l
                .active_low = 0,7 W8 w% B& W1 p6 K% _& S
                .gpio = DA850_USER_LED0,$ F* ^1 t  J! A$ ?8 H, Y# u' S
                .name = "user_led0",/ ]+ D! `# w: J- ~# }# e
                .default_trigger = "default-on",
0 }# y5 C6 W$ Y4 X3 k        },
! V# G8 M' T. o% {- I1 [        {  A) R6 A& `" ~' G, W
                .active_low = 0,
2 F9 s( Z3 g0 c# P: f% U8 s                .gpio = DA850_USER_LED1,# ^, \7 z* P- g. I
                .name = "user_led1",7 O) L2 h  `! B$ N
                .default_trigger = "default-on",  L/ s, K2 r' R2 K1 m( t
        },
: L+ M  i! L" _# F  I4 t; ~        {
" E9 o1 P2 f+ q                .active_low = 0,
5 J& A/ C" }* l4 b" f                .gpio = DA850_USER_LED2,
6 Z& G9 |" t3 Y. O                .name = "user_led2",
) E) j3 c, r  I9 W4 @/ K                .default_trigger = "default-on",
/ u7 q; L  E( {1 h7 t  X' o        },3 @/ p: v- ~9 M2 \" [0 }0 p
        {/ F4 I& i/ x4 e1 {& p
                .active_low = 0,
% y2 m' P$ k! w8 e                .gpio = DA850_USER_LED3,  C  G: e8 ^& D; M
                .name = "user_led3",
; t" g0 q5 V: G2 K) |. Y) K; s                .default_trigger = "default-on",& x) v. i* `) h/ s& K& G; @& E, R
        },
5 Z8 C  g: f5 d};
8 e/ {7 [, ~+ A8 E( W5 C
; q1 v5 E- L8 `! D, K; K, q  hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {  ^( y4 B0 K/ I# t( b* U- z
        .leds = da850_evm_tl_leds,
  r* l7 h6 V6 N* Q* h        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ k! A( f( Q. Y( x
};
6 A( d: n+ ~. G) G- |7 [" N1 Y+ T& h' R' q/ ~. _
static void led_dev_release(struct device *dev)
# p% S6 O7 o6 x& Y{
; u! ^" ?: S3 v3 e. H2 S};
& t4 G( E6 ^' c1 R$ E7 X; Z' K# L
static struct platform_device da850_evm_tl_leds_device = {8 }0 B  k* P' [* Q$ i+ B! {" r
        .name                = "leds-gpio",
- E- l0 S) h2 t$ _- G8 U% w- e- S; ^9 `        .id                = 1,
2 `1 O: g4 z* Y% A$ T+ D+ v        .dev = {
! g7 g# Z  O0 {! z                .platform_data = &da850_evm_tl_leds_pdata,, s1 g5 Y' K# C8 _" H
                .release = led_dev_release,
8 Y0 A# Q6 l) j4 w        }
9 H/ n* a  {, S" ]6 @3 u/ x};
$ ?+ T$ {/ ]( B! X4 S  l4 ]* P" z: K/ X* A% G5 f
static int __init led_platform_init(void)# n) D6 P7 ]$ |- s7 P
{
5 d0 Z5 ?4 O" g! S        int ret;
! j, B6 @$ `- Y$ n# \#if 0
+ p; c8 [- ]  {; r8 T! o        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' k& c) l/ j) z: ?% ?        if (ret)0 T9 e# d% [$ N. e3 x& m
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. c* P9 X  Q# O8 {8 y                                "%d\n", ret);
! m) l8 V# F" x  |) D#endif2 p! D' Q/ X7 c7 T
        ret = platform_device_register(&da850_evm_tl_leds_device);
0 y5 r; K% g" w; m- |( D5 x9 O        if (ret)
3 F8 x( R! c& N& O, u                pr_warning("Could not register som GPIO expander LEDS");" h! W0 q# [/ Z4 H
        else
7 ?2 T% ~/ }( ]& \                printk(KERN_INFO "LED register sucessful!\n");6 G* D3 B$ s5 b8 ]/ {
! D/ t2 D2 ]! y  i  ~' q  S
        return ret;' r8 Y% @9 X+ T4 P+ B
}7 ?. B. a* H' @! k# V# D* w
; H6 v8 U* F8 S7 l
static void __exit led_platform_exit(void)
- Q/ z3 S, H) ]$ L5 Z" f) p{9 n& ~# n' L- V& a5 `
        platform_device_unregister(&da850_evm_tl_leds_device);) p* d( @8 }" G$ s+ A  b

. _8 g" P) N0 ~- V/ w& g        printk(KERN_INFO "LED unregister!\n");# K4 c) C. J- l8 g" E9 Y
}
9 q; d( `& A0 w) L9 g8 F- m8 i" W' u" t- r% N/ Q1 b  I7 t/ B+ o: i
module_init(led_platform_init);+ [2 b; C! [3 b/ M. `- f+ `
module_exit(led_platform_exit);
1 v) n1 d5 M7 v! h2 M" r2 x# V0 T1 V9 e  v  i  W5 _2 a3 }
MODULE_DESCRIPTION("Led platform driver");2 E$ U" B' S: E' ^
MODULE_AUTHOR("Tronlong");
* Y6 G3 l6 G1 y6 p4 S0 \/ }MODULE_LICENSE("GPL");0 _9 ^3 w" S; P/ B
( o  U: ^7 C  ~* G- Z
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-14 05:17 , Processed in 0.039753 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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