程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站
点击跳转“创龙科技服务通”

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。8 Z6 ]5 `% Y. F! I6 \2 h0 R! ]! B9 Y
#include <linux/init.h>
8 V: k. d" d* d) n' A#include <linux/module.h>
* x; _0 w; W! Z1 w  g$ @#include <linux/kernel.h>) s. @$ _; q* y# ]8 n6 U6 H0 p
#include <linux/types.h>
5 S" L1 j' Q, ^6 ^; A% T3 \#include <linux/gpio.h>9 z0 c  W7 N; z* O0 z+ W
#include <linux/leds.h>+ ^" ?: B9 d( M. F' ?9 T
#include <linux/platform_device.h>
/ C- J1 d" @$ h/ b% h/ S; H0 q0 ~8 z7 i
#include <asm/mach-types.h>
" J* C$ H! T; o' p  z1 n) N1 [#include <asm/mach/arch.h>; ?1 f# }& d4 ~3 X5 h' q8 c
#include <mach/da8xx.h>
" M% f% S6 G4 z* V#include <mach/mux.h>
$ }, e, ?9 s7 n! A2 z) U8 A# s0 Y
: y7 I0 G6 a. ?& Q#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
& H4 M% l% I: O#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
: q1 @3 l, ~8 U( L' I#define DA850_USER_LED2        GPIO_TO_PIN(0, 1). U1 _8 n% s( D3 {6 `0 I
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2), `' j$ U% U  c
  e7 M1 X5 j! E; @& `
/* assign the tl som board LED-GPIOs*/7 a( `5 ~+ ]: j2 y$ i
static const short da850_evm_tl_user_led_pins[] = {! ~4 v& P" t) B1 V* B
        /* These pins are definition at <mach/mux.h> file */, O3 i( d4 a" B5 N4 Z, b4 d
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' g& w- D6 @' E" L& O6 l
        -1
1 E, c/ e" H: a};% @) l- ~; @: b- ^
1 d) f; f9 Z5 K
static struct gpio_led da850_evm_tl_leds[] = {
/ M, l9 ~: k7 V& T7 M$ m! j, f" A        {8 b  B* H; U+ A  [+ A4 U0 s
                .active_low = 0,
3 w$ w" z) k* ~3 L+ I9 }$ ]                .gpio = DA850_USER_LED0,
$ h6 A/ }: R5 c3 R                .name = "user_led0",6 p4 A2 E" V; z: r& G( R# D+ I9 ^/ h
                .default_trigger = "default-on",
' a1 q& m- c' u& S; R# \        },# V* ]. o8 Q' J% k& ^* d5 J
        {
) }8 ]2 h& T8 m0 O  O9 u. H: Y' {                .active_low = 0,
8 J* S' ^6 g* s3 T6 M& m                .gpio = DA850_USER_LED1,# u% s( e! M/ q2 L% P4 @( w5 O
                .name = "user_led1",9 G) C, k' Q- t" H! t
                .default_trigger = "default-on",
' v  G- ~( M2 _& |6 W        },) w4 ^0 ^0 p$ X8 w
        {6 J4 X0 `& o: F$ w
                .active_low = 0,
/ u" h$ N/ P9 k' ^1 \9 b                .gpio = DA850_USER_LED2,2 ]' g9 t, R, M+ Q  q4 w
                .name = "user_led2",* |0 j1 p; z7 H8 N& c6 ^, Q0 T8 g
                .default_trigger = "default-on",
7 ~- l$ R# h; j) T0 R        },
% o, E+ B3 T3 ?, }6 m        {
! o- F% E  ]( f" L, q' l/ ]                .active_low = 0,
3 D& i2 A1 y! D  [. i: }: y9 r                .gpio = DA850_USER_LED3,) \& y9 j+ O. _3 `" [1 B& p
                .name = "user_led3",
/ N( T# f1 `* l3 w9 Q* T5 `                .default_trigger = "default-on",1 g8 `' B. W& B) K# [
        },
; {$ ?4 \- N& V};$ {) h! g# n  b" [4 c1 @

) m/ Y9 K. h2 i9 N6 ^6 cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 K% e8 |! B3 ~9 q5 C
        .leds = da850_evm_tl_leds,
1 x2 p4 y# a" g$ ^. G4 O# q        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' f  f; j5 k8 p4 P8 [2 r7 ?7 h+ K0 e
};
" W5 C+ U4 Q" ?5 u4 n7 \* g; c6 h4 _# S% g/ }8 {' o
static void led_dev_release(struct device *dev)
7 C2 \# _( b5 v! R4 q7 T{
" C1 m5 d/ x2 _2 }) p};0 r* c" D) D9 t% B% k

6 [1 N& v$ o( P8 X4 nstatic struct platform_device da850_evm_tl_leds_device = {
2 n! p+ N# e8 W9 X4 H        .name                = "leds-gpio",
2 R" Z3 b# P( D5 K1 T        .id                = 1,
, N9 D5 q3 U: [6 H1 c( ^        .dev = {/ P& y( C- V. K- R4 S2 i% V
                .platform_data = &da850_evm_tl_leds_pdata,
" x' K( X1 i. @8 N; }                .release = led_dev_release,
! M8 Y3 g- I4 y        }
& ^% q  W( O6 p* p* k( s  a9 V};
9 c' J  K( S0 H' E2 ?
% e+ L! b; E( sstatic int __init led_platform_init(void); R: ?" F( z, e; _- `8 n3 j. q
{
+ }- ]# U. c8 |' F' N$ a2 M% Y        int ret;
8 m1 @/ s, ?5 f- ^3 V#if 07 D! R3 C3 e7 I4 r  m
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: B, @  e% e0 r7 w
        if (ret)
7 q5 }2 W' L! i: g) e1 c                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 D5 a& N: h! i/ X, U8 [3 b5 y+ P
                                "%d\n", ret);$ }; C8 q3 |5 u/ X8 q& }
#endif
2 Y) ~( T, h2 ^6 d        ret = platform_device_register(&da850_evm_tl_leds_device);, j9 m7 J8 z8 O$ ~& O
        if (ret)
) o+ D' d7 [- N* `4 Q% X+ C                pr_warning("Could not register som GPIO expander LEDS");6 {4 D+ b0 w9 y, `4 T, E, F/ ]& ^4 J
        else
6 ~! U3 |! G( E. m, X. |                printk(KERN_INFO "LED register sucessful!\n");# H" x$ D) u6 c5 C

0 j8 `! i% O0 B; ~; Q! }& F1 S        return ret;
6 b  o: p( K3 ?1 Y! k& }}! m* t6 v0 C& P+ ^

  y' i0 B$ w. E. dstatic void __exit led_platform_exit(void)
: D% R% w; V$ `$ u9 L{
3 k* R3 c+ r) z! r. M. D# K: W        platform_device_unregister(&da850_evm_tl_leds_device);
2 K8 Z- P6 M8 X- v& `7 Q/ z% {' r" Z+ K$ ?* c% B
        printk(KERN_INFO "LED unregister!\n");5 W0 N& }& `$ k# w( k' g3 c
}# ^9 q  U  ]) F9 R! f

6 S& m/ W1 u* _2 H9 L7 `, Q9 v& Qmodule_init(led_platform_init);
' _( o& c: W/ `* _' F9 u- g% vmodule_exit(led_platform_exit);( |& H2 |$ R4 S; i% g: I3 A

/ f: A) _3 t3 |2 x4 \* q* TMODULE_DESCRIPTION("Led platform driver");( {( E8 L% |% b
MODULE_AUTHOR("Tronlong");
6 L9 L3 u: X: T  L; L/ pMODULE_LICENSE("GPL");8 h- |0 M/ |2 ~: @2 `) O) t1 ]
7 b! r1 f4 M2 p2 j, S& p, \+ k, P  L
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

点击跳转“创龙科技服务通”

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

GMT+8, 2026-3-15 13:43 , Processed in 0.040879 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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