程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。! J. U+ B  |/ V. p+ Y! o: `- s; D
#include <linux/init.h>0 g$ t# @( P, I* N
#include <linux/module.h>
* Z: D' ?$ G- [/ b3 {2 K  j#include <linux/kernel.h>) C$ A1 x% K+ @. @! l" X) D
#include <linux/types.h>
' m- t' [4 ^3 n; [" j1 b1 A#include <linux/gpio.h>2 e' j  i0 o, R- c3 \7 J4 M8 g/ i6 x
#include <linux/leds.h>
( G9 ]2 _: G, T#include <linux/platform_device.h>
! K3 l* R& g% k; G) T9 i3 t1 ]( Z- W6 M  t' ^8 U  X
#include <asm/mach-types.h>3 S" V+ X3 w# c0 F) Q0 g- H
#include <asm/mach/arch.h>; G: i' s. H, _( E+ H9 u. @4 x
#include <mach/da8xx.h>
/ J+ i6 U" X' A1 I1 R3 k#include <mach/mux.h>% |6 B4 _$ W: x  y2 x. M

  e: I0 ?7 H$ f+ E' a#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
/ ^0 g* I8 b# D; V% j2 u# j#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
3 i. A$ d2 ?- N, X4 b/ f#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)) F% k$ P8 D  x9 F) _8 i
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
* {  d8 m8 V1 l3 g2 U" l& |2 M7 H* A" E
/* assign the tl som board LED-GPIOs*/4 n1 }1 |% o* C# ^: R- V, H" B& _
static const short da850_evm_tl_user_led_pins[] = {
. E4 t% J" u. l, m        /* These pins are definition at <mach/mux.h> file */' |; c0 `/ y0 T! a
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," ^3 y; t: g5 O4 _' Q7 Y
        -1
5 o& w# N6 x( b, R4 z6 v5 I) z# j};6 Z3 v+ z1 v# @3 W7 W$ W! s

- ]( A& h3 o9 z- T1 hstatic struct gpio_led da850_evm_tl_leds[] = {
; z1 B( R( H) E! f3 I6 X. u        {. H: a) u# A. j: Y) G
                .active_low = 0,
, |# A* o& k' m" W' d                .gpio = DA850_USER_LED0,
- `; v3 v8 l' ~$ J4 ^2 j! ]8 [                .name = "user_led0",
' P( J4 @$ H2 T/ d: R                .default_trigger = "default-on",
- l& m' k: u8 l, e. p+ y$ [        },4 B( ^! U" _; e. q" c  I" O
        {& h' C$ z( W' B2 ^* B; d2 B
                .active_low = 0,
5 U7 s2 k# Y; l1 W3 \* j5 q$ N                .gpio = DA850_USER_LED1,
5 d; O! O: W" P% |. V: q                .name = "user_led1",
7 v5 m, S, M  ?, x& g$ A4 {/ Z$ f                .default_trigger = "default-on",
6 P2 t7 R. y. q% ?: E' p        },
; M3 q2 }' @% [        {
2 T0 S$ w( X+ w# k4 ?0 E                .active_low = 0,
* Y2 _/ Y. A# d% u                .gpio = DA850_USER_LED2,' G0 m* Q9 G% `) Y9 D
                .name = "user_led2",
* V6 ?7 N( X0 Y5 f                .default_trigger = "default-on",
$ l0 e! A6 l6 k! _7 i        },
( s; J; v+ V* O( U* M* m0 `        {
/ k/ r8 S/ G3 [8 f" s* W& x2 ^) o  e                .active_low = 0,2 p# X$ D8 v' l* K. }( i
                .gpio = DA850_USER_LED3,
; h, t' [/ R8 T                .name = "user_led3",# a& b" d0 ~. N! _+ L' w! U
                .default_trigger = "default-on",
1 x1 N7 a/ l# P0 L1 ]! g& R        },* L2 T6 }8 _$ W6 e* [+ `. ]. H
};2 O1 a- e: S1 X5 d7 v7 Y8 [
! Y1 k$ w' A3 c; r( H+ f# A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) W/ X3 x) k) q# w7 q        .leds = da850_evm_tl_leds,; s+ x9 v1 U  _9 i9 P' \& K
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* z) N1 k/ a; _! J};
- a5 r& M9 D$ X
* A8 q! e( u! E- W+ X! G! rstatic void led_dev_release(struct device *dev)7 ?7 V1 C7 v6 Q; I. Y( c* ^
{' M9 u3 Z9 h& o7 |9 T- ?! ]- }
};
* W1 T- k' {3 |. T" U; q6 r0 Z; e. i0 V$ G" y2 B; |. I" U8 s( j+ X% l+ B& A2 y
static struct platform_device da850_evm_tl_leds_device = {" D& I* I" c5 _9 K, b: Q# o) i
        .name                = "leds-gpio",
9 Y  x! x0 H  Y& ?/ B        .id                = 1,$ ]# V& \* S# Q9 q# M
        .dev = {) ^* O6 y/ }! z3 }# B% |' W4 t
                .platform_data = &da850_evm_tl_leds_pdata,
( B' c; H! M( I' s: i                .release = led_dev_release,4 n9 J, l, h3 B
        }
1 v1 T2 X$ {8 m9 ^};* Q, d2 m- @% v; `

7 h! V; |9 D' Q5 x, ?- Jstatic int __init led_platform_init(void)1 B) l+ e- ?/ A$ E( H+ C
{
: g4 l: s# S" z4 ]" G- N$ y) T        int ret;: r0 U& q/ b4 z$ F0 ~* x( u, h0 V
#if 0
: Z+ X' M; d% V        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ e( l  K6 {3 F- J) i) ]* w
        if (ret)# i, {9 ]: g' j2 E# J( x: E
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 `$ ~$ @/ a/ I" K2 O- B                                "%d\n", ret);
+ n$ n1 f/ {7 T3 L#endif
+ ^/ F5 _# u1 |$ `" X        ret = platform_device_register(&da850_evm_tl_leds_device);
" j4 K8 @. R, |! C  `6 {        if (ret)
8 p* U* q& ^2 m5 v; e                pr_warning("Could not register som GPIO expander LEDS");- e$ x6 U7 ~1 k
        else
  g/ A, l# D( w8 P  z9 P3 }: G                printk(KERN_INFO "LED register sucessful!\n");
( w) A- A% U: C! l9 V+ M% S" _' m# r
# j1 F! X+ J3 z) k# U+ U5 x9 ^        return ret;* u  y, q4 d, o) g/ [7 h! }
}+ m# d( _# V6 w& Z& I( F. t
5 R" U& n8 \0 g8 ?; H( a& J
static void __exit led_platform_exit(void)) w9 z/ S* y$ f
{
) B+ q$ m- Z5 g6 B6 j. J        platform_device_unregister(&da850_evm_tl_leds_device);
' y' [  }9 P0 s: {3 O7 i
, [' N$ _6 M! U4 P2 ]        printk(KERN_INFO "LED unregister!\n");
- ]$ g- R2 b1 `9 H% q* _}: y. x2 ]$ N  o8 n1 C, h8 U

. I' z9 i8 O/ m3 ?: tmodule_init(led_platform_init);6 ]) j! C  K- N. j; H0 d, k; j
module_exit(led_platform_exit);
) o/ ^8 T$ q# m2 V' @% h1 c" k2 i; B& [8 _" }6 t" {
MODULE_DESCRIPTION("Led platform driver");
/ L& H. _9 x/ eMODULE_AUTHOR("Tronlong");3 d+ S/ g* J' `; t9 L+ D
MODULE_LICENSE("GPL");( |  d: ]5 M' @1 F
$ y$ f6 Y; P5 u! |: m, z: I
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-7 09:48 , Processed in 0.043434 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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