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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。! F4 n5 I! u0 f* N. Q! O& B( K
#include <linux/init.h>- U. |/ c' E1 d0 o; s0 S8 I: k
#include <linux/module.h>; H3 ]  j3 X8 S( O
#include <linux/kernel.h>
& ^8 C  h; U- L1 A#include <linux/types.h>( Q' p# U8 Y3 o" K) z# w
#include <linux/gpio.h>9 C. k5 F9 r. U* v& H# b% i5 L
#include <linux/leds.h>
+ |$ `, c% J" i/ H9 p0 G! i, \- K% w#include <linux/platform_device.h>
: J. Q& B* k6 q) B; B$ e$ k4 m6 A9 ?, V+ q; y) X
#include <asm/mach-types.h>
( n4 X  }5 V( F5 h/ a1 S+ ~#include <asm/mach/arch.h>) k7 k1 D- W7 m) Z2 J; D) q8 d* a( I
#include <mach/da8xx.h>) H; B5 z* Z% T  }- r. g; y, l! _/ \
#include <mach/mux.h>
- e5 G) }& d1 d0 M* ~- P
  a, G% F2 [- T* N+ W#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)5 m: B% v) H4 t9 k: L& P
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)4 L% ^# \' G1 Z2 z# A' x
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
8 `1 f  w" A7 F! W6 M; X#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
; \. \  [8 \0 o* [  }1 V( {& X5 R( }& h+ }3 v4 o& g+ ?) m
/* assign the tl som board LED-GPIOs*/# \& q. Z  E/ H# s
static const short da850_evm_tl_user_led_pins[] = {6 X* P' L7 Y! u  Y4 r3 h+ H7 D
        /* These pins are definition at <mach/mux.h> file */+ a1 X9 k% Y7 k0 s1 J
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& R7 W" ]" Z4 [! J; U
        -1
- p) n- ~6 D- |! K* B4 [};- i* \0 S3 y/ w2 ^4 e- o: V
8 w4 n- V4 Q' a' |) t* }
static struct gpio_led da850_evm_tl_leds[] = {7 w1 E, D3 N7 q
        {
/ i+ _. q6 }. {: O                .active_low = 0,( s: P) C: C  U0 o+ g) [+ G
                .gpio = DA850_USER_LED0,' f: \  z3 E+ W, L- H7 Y
                .name = "user_led0",) ]( K" S8 e1 z2 Q& u8 a
                .default_trigger = "default-on",
6 k. h1 s5 S9 S6 ?4 ?        },
3 H4 N" `6 E6 ^8 O' B! {( R        {
3 i6 K2 E) |0 @                .active_low = 0,* a4 F  v6 W, S7 l
                .gpio = DA850_USER_LED1,
2 D  b% {6 _9 |% f( |                .name = "user_led1",8 Z# K. E+ T( p: x- t
                .default_trigger = "default-on",' ^7 I3 V3 D' a* Y
        },2 y. d/ e0 t  i6 B2 M# F/ d
        {2 J9 M/ }) z1 g  A* v2 U; Y
                .active_low = 0,
* G" }  B3 A5 J, Z7 D; n                .gpio = DA850_USER_LED2,
. y1 ]. _8 J  ^9 s                .name = "user_led2",
1 J# _0 W  P: z3 O, W: Y6 }, [                .default_trigger = "default-on",
9 V) w! \: d. B& E& @4 X% Z9 B        },$ d$ d# q5 I" V7 E- Z6 T
        {/ x! h8 B$ V0 _6 `
                .active_low = 0," g; o2 ?1 v1 p! H
                .gpio = DA850_USER_LED3,
4 o7 p% r! G2 D8 I                .name = "user_led3",
- g: N* r* U9 p) w/ O- r0 K7 @                .default_trigger = "default-on",
" k) v+ Z7 u6 G5 Y3 M        },
: M: h, u& e( C. J4 ~* F};
2 S, V% x7 D/ G- r/ y; \; l5 r) k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 o. E6 F0 L/ I7 R5 n        .leds = da850_evm_tl_leds,. R6 |8 g. D7 w0 f3 R% m
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' x# _& N7 ]! R' l! ?& P' q7 U};
9 l/ s: a. D3 j! d+ ?6 y* b4 `7 v2 _6 U2 Y/ |( Y+ p
static void led_dev_release(struct device *dev)" s0 c. C; a. b/ x
{
% o4 d, P& z( G, r" P};4 {' o# O& x1 U' L- R
$ Q( {& T+ G6 o5 E
static struct platform_device da850_evm_tl_leds_device = {& O4 W9 i# N5 |
        .name                = "leds-gpio",6 _% I! h+ {% J  X1 L! X' {+ |
        .id                = 1,+ n" |$ p% s! g9 W. V6 B
        .dev = {
5 [/ f8 R( E$ r1 N8 ?% i                .platform_data = &da850_evm_tl_leds_pdata,! a5 Y4 j* t0 o
                .release = led_dev_release,1 U# n/ U& o0 ^0 O5 h2 x( s* g6 ~  [
        }
4 L: f0 ]& Y' f! t/ x% x};
! e0 y4 H+ ?+ I3 a0 H. i$ I. P2 L+ ]; Y! w* k; r- x
static int __init led_platform_init(void)
3 v, e% B; ~8 {, u1 M6 d( o* W$ p{( R, U/ s/ `2 \8 F6 \
        int ret;
: P/ p* d% v* _/ {0 f6 z#if 0
: T/ u4 Z: u$ o  t        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 I1 |! n8 F2 P6 n% F7 v
        if (ret)& C- D5 E+ p0 N7 H# L
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( }9 g5 P2 w2 i4 C$ r& i0 A                                "%d\n", ret);
* T& Z: U! v( |: w#endif1 f0 z6 Y! I' c
        ret = platform_device_register(&da850_evm_tl_leds_device);" Q8 w0 Y( Y: f4 c: j( Q
        if (ret)2 m  ?0 I! B+ V9 M& N1 I: G6 C
                pr_warning("Could not register som GPIO expander LEDS");
' N; |9 [+ x% {9 |4 R        else
( V/ i0 K# v- R0 o0 j* |1 F                printk(KERN_INFO "LED register sucessful!\n");9 s4 Y/ n8 Z1 ~! l/ K  e: D

9 h; u4 a* y# b% x3 t% k0 `( h: ]        return ret;
6 n$ ]% E8 r. O) b7 g& s6 E& M}2 g2 Z% `' z  G/ m
" Z" ]# e5 d9 @: X- O3 H4 r! n, s! U; C3 Z
static void __exit led_platform_exit(void)
& d8 y) n& H0 @# i: t{. e1 \6 h7 M4 o( Z7 X- {
        platform_device_unregister(&da850_evm_tl_leds_device);) a$ O' k; V) C- F+ E9 ?

4 ]& _5 X2 W, c& ]% G* ]) s        printk(KERN_INFO "LED unregister!\n");
: r9 y9 ]8 g6 O/ H}' }; t0 z2 M- O6 j- r. _9 x

  C6 \5 z- g; F& A' Kmodule_init(led_platform_init);
9 I8 u1 ]3 K7 u  o( r" ]- C/ vmodule_exit(led_platform_exit);- ?3 M. y+ @. R3 z6 {3 F0 {

% x0 N6 f9 ]0 ~/ eMODULE_DESCRIPTION("Led platform driver");1 O& `% S3 t: q
MODULE_AUTHOR("Tronlong");
0 t2 ^+ w2 U4 i$ ?! ^9 ~MODULE_LICENSE("GPL");( a$ E  j8 Z/ t2 N3 c; P

' d- F3 v, f" ^' R
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-24 23:40 , Processed in 0.038330 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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