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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。! V/ P) V, m6 S' B/ X" {5 y, p
#include <linux/init.h>
/ ~/ ]1 M" _' B' B$ X) f8 i7 C#include <linux/module.h>! N5 Z* L8 T6 g
#include <linux/kernel.h>( |; X# Q) P( c
#include <linux/types.h>0 f7 f4 i) X' X: f2 @
#include <linux/gpio.h>7 }% w2 k) K4 X9 p( x9 v
#include <linux/leds.h>
7 }5 o1 |' q! K  ?#include <linux/platform_device.h>
, E; m" t) T; X$ q  ~; L, _" Z2 _5 {: n
#include <asm/mach-types.h>
. f3 I+ \( Z8 {& @0 D#include <asm/mach/arch.h>
+ B  k* R3 _2 j! q; g' F5 Y#include <mach/da8xx.h>: O# h4 `' |1 {$ ]. u* s
#include <mach/mux.h>
6 o5 D0 q" l% D( L$ L8 z+ c
2 F2 _" l) a* V6 a; v4 y* {( J, s#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
- [  V! ?+ X$ W1 X/ d2 T9 V#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
3 |# e1 U9 O6 n( k6 [# ^8 M* n#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
, R) c2 ^& r% M- U#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ i3 x  b& c8 u1 X4 e8 {: q

: ^' S0 f! D/ \7 @% L& ]& ~/* assign the tl som board LED-GPIOs*/' v$ ?. E2 V; ?' t8 G: h& t4 ]
static const short da850_evm_tl_user_led_pins[] = {
9 B/ H8 D1 T+ \        /* These pins are definition at <mach/mux.h> file */
" X1 h2 `3 M% c! n8 L0 _        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 V+ x% t" A2 ~. [, z/ k, m, }: r        -1% F0 s7 B# M# z& \
};+ \6 y1 ^; F6 ~& b* ?' B4 F
* |7 @" O8 A# E+ s& [9 B! d
static struct gpio_led da850_evm_tl_leds[] = {
, W6 s" A8 K# ~4 f  _        {
5 H8 a. M! }& m                .active_low = 0,
' j+ E/ A9 p9 {8 ]                .gpio = DA850_USER_LED0,
* b% Y' y" L0 |' c6 N6 e( g2 r" Q4 s                .name = "user_led0",
4 z& }: ]0 V2 V- X5 A3 e# P                .default_trigger = "default-on",% q2 j6 K- V6 q& r- K! n
        },5 H1 i0 ~. X5 S3 h
        {
9 V/ d: P0 B+ H& {/ `  s$ x                .active_low = 0,
) h+ e2 k' F' g5 F- L                .gpio = DA850_USER_LED1,+ k( V) ?9 S; Q) C; y& ^
                .name = "user_led1",0 {; R0 c8 u; y) u# C# c. K
                .default_trigger = "default-on",# a% G# |: j2 Z# V9 h! h  \2 @
        },0 ]) U. |- i8 Z) _+ n
        {
& `5 |, V8 h- }; L& r                .active_low = 0,
, ^1 [( o; @7 g; ?7 R4 S                .gpio = DA850_USER_LED2,
: d* E+ q6 {6 `. n1 M/ k                .name = "user_led2",* L% U/ ^6 n8 H9 h) Y
                .default_trigger = "default-on",
  H% x4 O& G7 S% L) u        },( F6 T2 K' u7 J& M/ {
        {
  J3 u, W: |% S: K. q1 ^7 m% d1 c                .active_low = 0,
: W9 S# m: U, J                .gpio = DA850_USER_LED3,
+ b( X8 \6 V7 x2 R) P                .name = "user_led3",9 L  U+ O1 r* @# V! R
                .default_trigger = "default-on",2 k- z: [9 [/ z+ x2 \$ q
        },3 [) ~5 y; ?8 O2 x" s+ C* n
};$ l# ?) n  Z5 {( V
* `- m( D/ }' \- R4 I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 Y1 G  C* C! c0 k' A
        .leds = da850_evm_tl_leds,5 o) b" E7 \2 K
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, N+ ?4 ]) U: U! Z: [};+ i+ X* [) k" E( a6 b) ^" a
% o8 T  s2 b1 }( ?
static void led_dev_release(struct device *dev)
: _0 v: g$ @7 b  ^{( T% T4 P: _- m  ~2 N" f
};0 |( J) n" Y. R" a/ j: t

* f& F: G* K2 u' F- U# y$ ]static struct platform_device da850_evm_tl_leds_device = {' |/ `/ M0 Z" _* k
        .name                = "leds-gpio",
: V$ ?0 x% k# z4 W) i9 K6 G, U        .id                = 1,, z+ v' Q  k; k7 l
        .dev = {5 e9 @2 X. \& T. Z
                .platform_data = &da850_evm_tl_leds_pdata,
9 Z0 d: t, a# s7 s0 g4 z; j                .release = led_dev_release,  d! s$ a0 q& b1 q* _9 Z0 o
        }3 S& C' n) m& P# U' d3 d9 G. J* [8 N
};! b3 M0 S  _5 a# V  O9 o7 a! f
  s3 T2 _* |' _9 {0 i4 {
static int __init led_platform_init(void)9 v; j3 }: z# F  ?9 e/ @9 v6 a# c' G
{
- b1 E3 A6 U% @3 K) P        int ret;
7 e7 I3 y! H  G$ m- g' Q#if 0
4 f- q6 v3 P# U/ Y/ @        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& t/ ?" r0 H) S        if (ret)! K! p) V' b2 c
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 X; |* z( [" ]
                                "%d\n", ret);' i$ L5 t  m' S2 n- z
#endif
$ M! q" s5 m1 m/ s# M$ ]7 I# F        ret = platform_device_register(&da850_evm_tl_leds_device);
9 D2 N0 C8 ?. ]- s/ K& D        if (ret)
. Z5 u7 w( K" F                pr_warning("Could not register som GPIO expander LEDS");' {& ]& @& F, m9 t  y5 y- L
        else
$ P6 w$ z  G9 Y5 \4 L2 B" M                printk(KERN_INFO "LED register sucessful!\n");( n8 O) e# B$ f" u$ Y/ A, U3 C
4 v6 i2 h/ y3 O" Y. r
        return ret;: ]( N$ }8 C- `
}) ]0 v+ }1 S& l4 Z, s- B+ Z
' S5 y9 ]& M9 Z, Q& n  K1 W8 K, y
static void __exit led_platform_exit(void)8 O) i0 q* j' {, ?* ~" S8 X& ^
{6 ^* N% G  L& J5 ]% a
        platform_device_unregister(&da850_evm_tl_leds_device);
" J- ^6 m; B! K6 N8 P
. m- _0 W# [: E9 D) j1 R        printk(KERN_INFO "LED unregister!\n");
, d0 D( ^4 v% z$ C9 ~}
; W! }, f" [2 u2 H: X+ J3 S# @4 l1 d9 L- s( T, n: n
module_init(led_platform_init);
; h3 l8 K( i7 l" [module_exit(led_platform_exit);! m5 T: t+ [8 p6 M
% n* _  t2 e% x' Y. t
MODULE_DESCRIPTION("Led platform driver");2 f. E5 l- {0 W. {9 E# `" M
MODULE_AUTHOR("Tronlong");
3 L) ?) H# A7 p. f, sMODULE_LICENSE("GPL");; t" b6 H2 P7 I$ D. A! a

9 U# V! D$ S& V* ]4 K/ }- k
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-28 01:40 , Processed in 0.037858 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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