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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
3 T+ _6 A8 R& f#include <linux/init.h>& u* \, W/ X9 \
#include <linux/module.h>
5 q" i9 S6 c; ?2 Z2 Q#include <linux/kernel.h>/ p3 V! S* _! o5 b1 L* @: V
#include <linux/types.h>
3 \+ [# v3 x( u6 z8 ]#include <linux/gpio.h>2 m" i4 O0 b: K. i# o
#include <linux/leds.h>
, R" _( n( Z' ?5 P#include <linux/platform_device.h>
( g9 L* R, ~; q7 Q2 ^
% H: k* S/ n! S, c' b% S+ U( V#include <asm/mach-types.h>
% o# a; U, y6 i8 d% g#include <asm/mach/arch.h>
. F( F# l  l( ^% g3 e0 B#include <mach/da8xx.h>
; W# N$ _/ K* I! V9 `5 T- T#include <mach/mux.h>
+ C1 e0 P$ x- ~' M7 ~3 ~7 W
" C! b$ T0 x5 ?) Z#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
6 {9 m% p/ v- }4 }9 h, v#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
& x+ {2 i3 _$ e; z# Q#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)8 R, \$ ?  D/ x. l
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)- a- a9 P& r2 f8 k: z6 R% b: k
' b; g& Y* S* q2 T- B
/* assign the tl som board LED-GPIOs*/
9 w2 n$ L) y7 y3 z0 @static const short da850_evm_tl_user_led_pins[] = {
/ G/ u/ C# R2 `3 y8 y        /* These pins are definition at <mach/mux.h> file */
- N+ V$ u( i9 J5 E( b3 y# o        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 v" u6 z  [/ M- K+ Z, Q* c/ j0 y/ l
        -1/ o5 A+ `1 t; L' d% }2 d) a
};
( P8 H' v* l; V0 [* d
3 H$ O% |, [& H% I+ f- E" lstatic struct gpio_led da850_evm_tl_leds[] = {
' h9 t  C5 \0 e" C( i        {1 O6 H: f4 [; d) f! Y  F: c
                .active_low = 0,. O0 q7 m1 D& D$ |; k
                .gpio = DA850_USER_LED0,, f: N( @9 M9 h" z  s: u
                .name = "user_led0",
9 ]- j; O9 V4 `9 u4 C- R                .default_trigger = "default-on",
% p% ]2 y9 u, V        },
2 r% S6 t( `7 b+ C* `) y3 |5 R        {
9 F9 V9 N! R0 T. t3 R6 B4 @' z                .active_low = 0,
+ I( r, V, n6 G9 L0 h! o4 P: i1 P                .gpio = DA850_USER_LED1,' `/ }& o9 T/ c- [+ i, _
                .name = "user_led1",. R; A' [8 ~- L5 A4 f
                .default_trigger = "default-on",' i6 u" ?4 \$ b1 Z
        },
1 S1 [7 O: S4 g: q* }/ P        {
& k! x# R: {! v" g% c                .active_low = 0,
, d. J$ j5 d5 N4 H  O% W                .gpio = DA850_USER_LED2,
( U1 [, u" I/ S9 ~6 L( s9 j                .name = "user_led2",
( C  `, F8 c/ H! {! u# c                .default_trigger = "default-on",' @! u0 I: y( q8 \$ k
        },: F+ d6 |' g3 B: e% C* ^
        {
8 o2 c; u# C( u7 P                .active_low = 0,. P" @! \! g/ W# c8 N2 I9 x) K
                .gpio = DA850_USER_LED3,5 L" I* D! ^" e: W' \. {4 o+ u9 j
                .name = "user_led3",, I& a$ l0 ]; K% @" S, z
                .default_trigger = "default-on",1 @. l2 N/ _8 P7 c7 k
        },# h' m: C' U9 p2 C
};
, y+ y. X. N3 K5 x, g. b/ A" c+ Y9 K' N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- z9 A6 i" r3 q! |% T        .leds = da850_evm_tl_leds,& f. S7 o8 {) Y' I; ?
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! }2 |. I3 h$ j+ P3 h& Z' r
};
+ T! i* ?3 R( ?" l6 z2 M6 p* s/ K# E4 k2 B
static void led_dev_release(struct device *dev)
! n; Z, P$ X, c{
& k$ ^! L& Z) j};
/ z5 k- I4 H8 O$ Y$ T, q# Z; }* n0 x* r# I# ?! W- T0 f
static struct platform_device da850_evm_tl_leds_device = {
9 j/ @  S1 H% z" d7 w        .name                = "leds-gpio",
8 f2 X. f% s% H* u8 R3 \) Y9 I        .id                = 1,+ }; ?2 K! N3 _# O1 y/ U9 Q
        .dev = {% ]2 j, i; N8 W' y* z& Q' m
                .platform_data = &da850_evm_tl_leds_pdata," t7 f& M: M: W; t( Y' I, e# y
                .release = led_dev_release,  N7 L, i; d2 \4 N5 c9 v! X! v6 Z
        }
7 D" U2 U* J6 V1 o. `! x1 F7 a};9 ^- Z( ?, m  U7 _. n3 `

2 ?. n1 C6 J$ w6 r8 {static int __init led_platform_init(void)4 @, m0 s4 S/ W
{
; @; u) b3 \, h4 {0 V* Z3 ^3 F, `+ q        int ret;. Y7 V8 B- Z; |
#if 0# L& ~; w+ F! d% d$ A6 e6 Q! f
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 w% w# m6 d) Y0 i        if (ret)
1 ~3 ~! k( W8 q8 j" h                pr_warning("da850_evm_tl_leds_init : User LED mux failed :", U: v7 v3 G7 y
                                "%d\n", ret);
0 K2 W1 N' j1 w0 T# T9 r. @#endif
1 p2 i) ~# N: v8 _        ret = platform_device_register(&da850_evm_tl_leds_device);7 p% {0 {4 q- @& f+ t
        if (ret)2 c: k: F; r5 L/ u
                pr_warning("Could not register som GPIO expander LEDS");
; I  l, e/ N8 o7 d" H        else
9 c$ a2 [' K# K$ ?                printk(KERN_INFO "LED register sucessful!\n");
$ r, X& n% S5 O6 _: X/ D  F) Y' k
4 h" {/ i- w, _        return ret;
- Z) h" R+ p0 {2 g# H}. ~9 g" b: f& @' {/ j
! n* D. _- N6 Y" q+ E
static void __exit led_platform_exit(void)
/ w9 n. I' O  G- Z3 K' h$ f{
# N+ F8 E  R6 D( x0 B        platform_device_unregister(&da850_evm_tl_leds_device);
, i# a: J& y  l
& e6 F- U5 C5 W2 ^- e5 u8 I        printk(KERN_INFO "LED unregister!\n");2 C* K9 O0 b7 i1 c- E
}
+ g) ]1 d4 o% x$ ?+ M+ M, C0 N' N0 U; r& v' L  A( A
module_init(led_platform_init);: w6 L  T% E0 ]* i- l
module_exit(led_platform_exit);( n3 |, b0 ~, m6 D- u$ r5 Q  ]

; K2 }$ z  X5 l' ~MODULE_DESCRIPTION("Led platform driver");
: c9 v. f# h( MMODULE_AUTHOR("Tronlong");3 k. h, H. Y& O$ w5 e. y
MODULE_LICENSE("GPL");# e. d9 F& O3 x+ Q: ~
! T8 u- J/ ~0 A% n0 |6 W
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-25 21:17 , Processed in 0.038048 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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