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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
4 |7 j# A7 U+ T# h. F# Z. w#include <linux/init.h>! T; o# G1 U" Y2 z0 E
#include <linux/module.h>- w8 B4 f3 L4 u: X4 o: S
#include <linux/kernel.h>& Q# g  h' ?1 U2 F
#include <linux/types.h>% m( b7 b7 o, G! Y$ m1 f/ d9 f
#include <linux/gpio.h>
6 c+ S1 f- a# i8 o; ^#include <linux/leds.h>& c9 I" n, e8 ^) N2 {
#include <linux/platform_device.h>
, i, ~" M2 a' C; b. F. Z7 e* I1 k5 b$ Y1 i  \( W6 P6 o  v
#include <asm/mach-types.h>& ~. h; L) O/ n+ |
#include <asm/mach/arch.h>
8 t- \% c1 {) G8 C#include <mach/da8xx.h>
$ {; f* I3 l1 g- u#include <mach/mux.h>7 s# Y. M. C- X5 U. U* Z; \) `% W

9 ?* }* x% R7 C, O#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
8 b" h7 ]4 u$ g; I5 W+ e. H. d* {#define DA850_USER_LED1        GPIO_TO_PIN(0, 5), L- A* g. t" |; x5 m9 w& X) j
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1), t+ e2 X0 K" b
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
% N! E5 |# L4 P0 i3 c6 F
9 x# m/ W/ ^" l! L/* assign the tl som board LED-GPIOs*/* W& l0 M9 D& p7 |. R  j% K
static const short da850_evm_tl_user_led_pins[] = {
& E- D7 I' ~+ _. g/ V        /* These pins are definition at <mach/mux.h> file */2 p) R* C  Q  H; U( ]& F, I
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 O! D& o- y  O, o' i9 Q        -14 L* W8 {% }9 c3 n$ N5 S: o, n( q
};
, J  t& o3 m+ e. A; P, o% A/ X/ g& d, _' M2 Q
static struct gpio_led da850_evm_tl_leds[] = {
% V+ a; L3 r  ~3 Z: L        {- Q! ^$ P  n& M' ^% a- r
                .active_low = 0,5 n1 F5 ?8 ]% R/ B" X
                .gpio = DA850_USER_LED0,
" X: g8 u$ G% ?# R                .name = "user_led0",
) }, A: g9 k  l; D, q                .default_trigger = "default-on",
% u- |7 ~: e& W) C  m/ M        },/ {. y( z* ~/ e. u
        {3 Z; b1 v" t, b5 z# i4 T
                .active_low = 0,
' e* C) h# S, r  q/ B, r7 {# q                .gpio = DA850_USER_LED1,& {: l; ?8 @5 p4 {
                .name = "user_led1",. M2 G: o; x9 z
                .default_trigger = "default-on",
, b- Z% g/ E9 u% l% h5 O        },! I; n. N0 D4 O" a( G: V+ w. t
        {' G! D. L* F9 e
                .active_low = 0,; E: B' `0 `% `7 }
                .gpio = DA850_USER_LED2,( T" n" }: Z  i* J' w! ^
                .name = "user_led2",
5 i' E+ F) i( o                .default_trigger = "default-on",
! s1 U! T+ q: W1 @2 I6 g        },! C4 q2 Y  `! i8 x6 y+ ?; j
        {" h. Y2 u0 ^( r9 l' s9 j0 b/ a$ W
                .active_low = 0,$ [( I2 D& A8 B
                .gpio = DA850_USER_LED3,; _: Q. n" M( V" O% E- w5 `
                .name = "user_led3",
  [) H" {3 k' L$ {                .default_trigger = "default-on",
% F: [0 Q9 d, g        },* x* ^6 z6 Y' D! T% y
};
3 m4 I+ F, }5 G8 n/ k. Q
% s7 v3 F- z4 Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ k7 H' S7 ]7 M& ]
        .leds = da850_evm_tl_leds,, s$ x1 [* q$ B8 c. e
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ ~- Z+ W$ L' c7 n7 h
};3 Z" B+ D# k2 y7 E, E
3 T5 Y, Q" q4 o
static void led_dev_release(struct device *dev)
4 `  m2 B! ]' E3 A" e* d6 s{& C$ H. g, r3 ?' B& Z2 F" U
};
* [  H% _# s  _% v# j* U8 s8 L6 b5 U6 U
static struct platform_device da850_evm_tl_leds_device = {
7 b) ?3 \8 F0 W! O) x( G$ K; y        .name                = "leds-gpio",& a$ y4 H* [0 R# [6 V7 A; |
        .id                = 1,& B9 E1 \' p+ e. |9 f
        .dev = {# V5 x/ W4 w- k; a9 [7 X' p5 N
                .platform_data = &da850_evm_tl_leds_pdata,+ ]$ I9 }: q, y* f- A5 T4 O
                .release = led_dev_release,/ Z" q% j2 |# w- M' @' C+ n- k! _& r
        }4 J. D+ c% E/ x, P  W: K
};
1 i; Z% M# {2 h$ Q8 Z4 b2 F) s: e/ C7 h/ ]# y( F) _
static int __init led_platform_init(void)$ D" S5 D; o! q5 _# Y) y7 a
{# x1 W  @; W0 q" ~
        int ret;
1 e2 Y7 @* ?( z/ ?9 W#if 0* H3 `6 F$ T- b
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. ?2 A& e6 K9 O7 `2 x8 g* e; |- n        if (ret)9 {/ v0 q. ?# e
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- u: |9 C% j. f( a' h3 B7 e: t) C( F                                "%d\n", ret);
/ d' h8 _4 ~5 z- H! V#endif2 Z* B/ G  U8 v/ n3 L8 r
        ret = platform_device_register(&da850_evm_tl_leds_device);6 {1 `* k3 w* k6 y, C7 [/ _
        if (ret)4 K1 }) D/ T9 \0 a+ B7 g! e* U8 h
                pr_warning("Could not register som GPIO expander LEDS");
+ \7 o. k" [# O8 @; E5 x        else( X6 w9 {2 f$ K: d/ O+ Q
                printk(KERN_INFO "LED register sucessful!\n");/ ^* y" @& s" v6 v+ B9 _

% a9 s3 l- T- Q9 `6 J        return ret;9 ?7 ^& |! U+ ^
}7 g3 @* M6 V, |! g; U$ e

/ P( T! E3 F* e8 I) vstatic void __exit led_platform_exit(void)
2 _0 S& J: B4 H1 x{
7 ?1 H( @, z- L3 Z! X        platform_device_unregister(&da850_evm_tl_leds_device);% J& V8 \2 F2 \! q4 f7 Y
, W% y+ E; L/ J- A: G6 g
        printk(KERN_INFO "LED unregister!\n");
8 F/ {! W9 z# Y9 l( z+ v2 S}
1 t# `$ }+ \- m, V  t4 }% Y
8 p- y* A1 j% N* g6 pmodule_init(led_platform_init);
. a! h4 P' [$ Smodule_exit(led_platform_exit);
* a) ^/ i# J# f4 F7 r
  m. V5 f3 H  h: _# c5 {6 J$ S/ mMODULE_DESCRIPTION("Led platform driver");0 ~- z$ O2 K9 q, j9 r( s
MODULE_AUTHOR("Tronlong");+ {  k, H/ q9 |( @5 \
MODULE_LICENSE("GPL");
7 l7 }$ a; t. m. Y9 j9 x' w; g( W) u/ _% r
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-30 03:10 , Processed in 0.046930 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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