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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。) |' w( B" s4 r3 V
#include <linux/init.h>0 ?& E0 d" w  {) q0 t3 u
#include <linux/module.h>
- P: d2 y5 I2 Q7 J#include <linux/kernel.h>/ g, g* A, m% E0 G: _0 }
#include <linux/types.h>& j+ d/ D8 G' F0 t: {& N5 l
#include <linux/gpio.h>3 V( n8 D  S) E* i. U/ B9 P! E
#include <linux/leds.h>. D, W0 V* |# Q: Y4 b5 T% i
#include <linux/platform_device.h>
9 P) ]; M( n+ W1 c* |9 m2 W/ e2 L( h; ?: Q. a5 U) |
#include <asm/mach-types.h>
7 b8 Q; D0 j+ j( R#include <asm/mach/arch.h>
$ W/ K/ O; K2 _& Z#include <mach/da8xx.h>: @1 W- i7 ~7 G9 j& Y; X
#include <mach/mux.h>- m/ b9 B+ C- ^, x. y
; S% x$ T4 J; y9 N
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0); K: s8 N7 D! A! K; M1 B7 `4 u5 F
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
3 a" @  S8 m& Z5 o" P( x#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
* `0 [4 V- P# A. T  h9 Y- x#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
' l1 @% X" U4 e* [6 J9 b- x. B" A" a" F8 D# M6 Q
/* assign the tl som board LED-GPIOs*/
! J3 R  F; ^( @' j6 s& q, Z# Dstatic const short da850_evm_tl_user_led_pins[] = {
( i" Z& @1 @" x        /* These pins are definition at <mach/mux.h> file */( t/ F3 l& [" V% T
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( L6 N8 r/ @1 C9 v1 ~
        -13 u+ W# a" V) Q
};, k% `: i8 A2 d  a  e8 f. n5 r

4 \; M+ A$ h8 U5 w) @+ n. ?3 v% v8 Mstatic struct gpio_led da850_evm_tl_leds[] = {. ~" b" S" [' r$ T2 W
        {
  [& E7 ?* t6 O5 [                .active_low = 0,1 \: m& l4 ~6 ~, L6 }# [: M" e# i4 Y
                .gpio = DA850_USER_LED0,
9 Z  c/ e5 K5 n+ \" h$ c                .name = "user_led0",
$ l6 ?" z( u, ?                .default_trigger = "default-on",5 \; s7 F0 D+ }3 J3 ]5 F( k* Q
        },0 @+ u9 n* y1 v) `
        {
$ P8 I# q: c! Y' L: B& c7 E                .active_low = 0,( V8 k) W# A3 C0 a& h
                .gpio = DA850_USER_LED1,! ^! z3 L9 M7 L/ i
                .name = "user_led1",
" p$ l7 ]. w" ]9 n5 `                .default_trigger = "default-on",
, g) A% w# n! q, Y8 C- L! z' s4 a        },: K$ |% n" a5 b) B7 q- t) g1 k
        {2 i9 P: v  h$ y
                .active_low = 0,7 P0 R. @4 N3 s! F/ s7 E! l. e
                .gpio = DA850_USER_LED2,  ^3 W! i0 l5 G& T, ~& \
                .name = "user_led2",, Y; L% N  L# T5 _( f+ R9 y
                .default_trigger = "default-on",
7 V3 k# t% E; p( ?- h$ l+ @$ Q2 _. ~        },* z  i# G9 t, q& G% s7 B8 z$ m
        {0 V. d! C0 l# O& ?1 P1 ?+ [9 Q
                .active_low = 0,
4 f% L$ E7 b' [) _: a7 m. v                .gpio = DA850_USER_LED3,
& c% M! f5 p2 J8 m) ~: o& j                .name = "user_led3",; {& h1 c5 h7 M& p% K
                .default_trigger = "default-on",
. |4 [6 E4 N1 ?3 h$ y& e  d- z        },- l3 J; b$ S+ @8 ~# O
};0 g  Q# g4 x$ p/ M, p7 ~
5 D* g+ C1 |! m0 ]) ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: r6 r+ e& |: D% ?+ ?
        .leds = da850_evm_tl_leds,
" m+ `8 ~, W  s9 g5 o, G        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' k, ?+ C% y& l4 e9 k
};7 |6 K5 d4 h8 v; |2 ~. X3 I

4 G6 u- E" L4 f- V" N* Estatic void led_dev_release(struct device *dev)# X8 v7 v; _2 h7 j. p" ^
{
- [4 S( t1 I5 Q; c3 |. o6 S' @3 q0 W};  i, d8 N6 N! {( l9 A
( m, [3 `/ X) ~% ?% V" o
static struct platform_device da850_evm_tl_leds_device = {
3 y7 M# h2 J* h' h        .name                = "leds-gpio",
) q; E$ P/ S8 q4 x8 [        .id                = 1,
, z. K3 g3 J" }9 Q) z        .dev = {* ]! o) |9 Z+ ~' C" `
                .platform_data = &da850_evm_tl_leds_pdata,
+ N8 B! Q7 l' N  i' K                .release = led_dev_release,
- U7 g; b* V6 C5 E8 I5 T  c+ s4 o+ S        }
) }( d9 Y; o1 ~# E2 U2 ~};
; m- [5 B: d. w. g
( ]$ r# e' q% g8 I5 G- \& Jstatic int __init led_platform_init(void)
: y% h7 a- K+ i' R$ t4 J! e2 `{
* f4 R+ q$ t4 {- u+ N) y        int ret;1 a/ `" X- L1 C+ N$ f; L0 B$ T
#if 03 d$ _$ ^! k# Q. p8 ]3 g
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 p2 [" @5 P1 ^  P: ~/ x        if (ret)  U, |- Q/ A3 Q- n- j! ~$ @: [
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ r9 T3 U+ E1 O3 X* x# ^( L% n                                "%d\n", ret);
: ~% V7 r, r$ ^5 U* N" e5 _8 J9 L#endif4 V) [& l( c; ?' w: |  O0 z- ^
        ret = platform_device_register(&da850_evm_tl_leds_device);
4 L9 K3 a- s+ _: H        if (ret)
$ T" q- [9 Y  }% O                pr_warning("Could not register som GPIO expander LEDS");: \9 {, L3 T) }  P
        else, R6 t% c5 t( _: Y2 D  M/ e5 Q
                printk(KERN_INFO "LED register sucessful!\n");$ n) H1 p( a6 U. O9 o

: B  D( N8 p6 |) r% N; ]        return ret;
0 }5 u, \0 j) Y' v$ }. j}+ u" c6 L! z7 |( x4 v, s# ~
% f" X1 N  T  _6 R' Q, f" b5 d( [
static void __exit led_platform_exit(void)
, X3 \5 P# h+ m! \' q0 I{
; g, u5 ?0 ?2 B1 Z+ t        platform_device_unregister(&da850_evm_tl_leds_device);
. o9 s5 D" g7 g+ N  Y% Z# c( R! O% [- T* k+ q+ s" F- |  r' z. `
        printk(KERN_INFO "LED unregister!\n");
$ \3 V: O3 d- P/ v' Y6 k. A}
; H7 k3 V, K1 ~$ V, `4 l/ h# I9 Q. W3 |. d1 E3 N
module_init(led_platform_init);
+ B5 h5 q, {8 Kmodule_exit(led_platform_exit);' L' R1 d9 N' [

3 `; U/ X* Q7 f  ]& X: iMODULE_DESCRIPTION("Led platform driver");* m4 D4 `  n+ n. o! Q0 q
MODULE_AUTHOR("Tronlong");  F4 S! \" M6 Z8 o
MODULE_LICENSE("GPL");
) G' F. F9 S( T# I. n
4 F8 T, G  C0 t0 d. i; j3 g, U
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-12 16:38 , Processed in 0.039094 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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