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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。  k% L3 g. `- ]" H" v+ o
#include <linux/init.h>, u* y3 }" |$ F% \  f
#include <linux/module.h>- z! {$ L8 ?) W4 Y5 G6 K9 ~
#include <linux/kernel.h>
0 u# i2 y$ ^+ a$ m#include <linux/types.h>! g6 \% M7 ?& b# b' l
#include <linux/gpio.h>
' `' s+ h: {. R8 l#include <linux/leds.h>$ w4 f$ B2 C% s1 x* E
#include <linux/platform_device.h>7 P" D8 U. t. p0 y/ B0 j

' y: y9 Q* A+ l) h#include <asm/mach-types.h>' V6 N! M+ I* k" o) r
#include <asm/mach/arch.h>
$ h# Z8 b% @: T" J- P+ _#include <mach/da8xx.h>: n" r( _& @) y* x" }" {/ l) G
#include <mach/mux.h>: t$ d& \1 ~- r/ X: [  u

. `; y8 Y* X9 X; i5 n* @$ l; R#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)8 m6 |8 n7 K% h: B1 @+ x
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
4 a, A3 q" O3 c3 K1 k4 M#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)" c- I2 @' E& g; e4 K& O" m$ U
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
& g- p! @$ h0 p) {
5 [0 w" X6 p8 M# @" ?3 c/* assign the tl som board LED-GPIOs*/0 ?" b2 t0 m& S, Q
static const short da850_evm_tl_user_led_pins[] = {9 }; j) E, E, S$ m: S& C
        /* These pins are definition at <mach/mux.h> file */
4 w6 m/ G) J' v! e* t# h        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 D4 W2 i* |5 O1 r( Q        -1
2 i3 c; d# O6 n0 {4 G8 _+ P3 C};. I0 C2 ^! A$ N5 Q# W) N. l% t
0 s! X+ C) G: Y1 D
static struct gpio_led da850_evm_tl_leds[] = {# f1 }; M5 H, x2 {
        {
- }5 _) ]4 E1 }                .active_low = 0,/ i& _4 N# ?( g, `. d& L
                .gpio = DA850_USER_LED0,8 A8 U5 L, N& c7 _
                .name = "user_led0",% ^% O3 Q! e" B! N, d* \$ a6 }& X; v
                .default_trigger = "default-on",
3 _$ B; G. L- f        },! u/ P' p( w0 L* d
        {
& A: e9 s5 r0 Q: V4 {( ~                .active_low = 0,, y1 M" o) Z! O; J$ P) W) b
                .gpio = DA850_USER_LED1,
+ `& j0 s5 e6 \5 ~7 m. W                .name = "user_led1",9 z0 a9 E. L; K/ ~8 N1 W& K3 w
                .default_trigger = "default-on",) R8 r2 p$ }! H5 q0 f
        },
3 ~- X2 p2 ?: {4 `& L) N        {
8 e# Z4 s# l- B( q9 z" [& d                .active_low = 0,
$ v4 V! M* g2 z                .gpio = DA850_USER_LED2,- e2 X. j/ L( i( a6 E1 S8 A3 b; x
                .name = "user_led2",( D  [1 B  E1 \
                .default_trigger = "default-on",- I, _4 W7 ~( l  Y
        },
; L& r1 y( G7 p5 |; B        {
, v* Y: G; X8 T) E4 t                .active_low = 0,; z& |2 {! m# J
                .gpio = DA850_USER_LED3,
3 p  T: C' X' h, {% x8 ~% y                .name = "user_led3",
+ D; Q" Z, W9 Z( D% ^                .default_trigger = "default-on",
' T  e( ~7 s2 |2 n9 v. I( b7 ^& ?        },; L* Q7 i  H9 X% b1 K
};# ?: b8 |1 _4 M: z' F' T7 v3 T6 }
: N) t3 }, S4 v! m! Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 I0 l5 ^. V8 F, t% l# @, N
        .leds = da850_evm_tl_leds,
# u% `/ U6 J2 X- ?7 s. A6 S        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! ]: y4 a- I! d8 z* S: C6 U, J% b
};
8 e5 J  U; H/ O8 i, l
) Z5 z, [5 D! V: J, j, N! ^# [# bstatic void led_dev_release(struct device *dev)
8 v7 `& z) [0 v. Y7 }- Y{- |4 e1 r1 ]6 M  k6 {% g
};; o4 P5 n4 r' H& t) X
  z8 u3 E- W* w
static struct platform_device da850_evm_tl_leds_device = {6 h3 b7 y7 Y: J2 N4 R( x6 ^
        .name                = "leds-gpio",
! A! ^- P' J0 e; \        .id                = 1,5 F9 Z* Z! Y9 Q5 ^; }1 b
        .dev = {- H( P' F4 A6 r, _- P
                .platform_data = &da850_evm_tl_leds_pdata,
/ |. [0 X- n) ]1 t5 l                .release = led_dev_release,
+ x: f& s6 u3 W( e; o- D, T4 D        }  u( [/ u, s) V' A1 A9 t
};4 v3 e6 J% L$ C3 a  v" }+ h

+ J+ d+ j) U+ S- c5 m+ ^" V* ostatic int __init led_platform_init(void)
* d6 d$ m* l+ e* Z1 i: ?{+ i/ R1 r# t# a% h* ~" s+ r
        int ret;
) m+ x( ^& L0 y6 p6 t( q  `! r* W#if 0( N/ I) B- s  b4 {  v1 t
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);  A7 W) ]- S" E; R; @& e; ~& W
        if (ret)
8 |3 n( Q7 n/ w% K. S( O0 G                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"  y+ E7 m4 t. r1 K
                                "%d\n", ret);$ `% z! c1 D: V6 G$ A% ^
#endif
! H+ `! j# q: O! E        ret = platform_device_register(&da850_evm_tl_leds_device);
$ n6 a( O6 R' Q8 ~5 ^+ C        if (ret). @: @3 s% e) x) t4 j1 b
                pr_warning("Could not register som GPIO expander LEDS");7 h' z* l7 c6 u) h, _
        else
1 a( ]- u' ^8 E8 E                printk(KERN_INFO "LED register sucessful!\n");
9 N  A& H! r- H% j* Q8 y5 n
" m6 F6 ^$ X, R) ^  S/ ?        return ret;$ u  C7 \/ L8 t# r2 T. r  `
}
% G1 g5 U( k$ r% [/ Z5 J. c+ @( m. x$ B+ ^& w- r* j7 \9 O
static void __exit led_platform_exit(void)# |8 B0 K9 U1 f: [) K# Z
{1 X: D* m# M6 c7 F" E
        platform_device_unregister(&da850_evm_tl_leds_device);
0 r* V& o7 @" ^3 L  s$ l) g: k* U+ |% u/ r7 K' Y$ t
        printk(KERN_INFO "LED unregister!\n");
3 `8 D* B* G8 f2 R8 P1 T}4 i3 U) g2 _# b3 q. g+ m& i

/ D/ b  v/ K! J% c' \. Imodule_init(led_platform_init);
/ Z! z) T7 O" L* H# m9 vmodule_exit(led_platform_exit);
& `3 B) w# I1 I4 C9 F) c2 d; i! Q/ B$ J  g7 l, q; K# u6 |
MODULE_DESCRIPTION("Led platform driver");
5 C" e1 I4 t1 m% o" U  L% `MODULE_AUTHOR("Tronlong");
" ]; a  \9 s$ Z) I1 w8 kMODULE_LICENSE("GPL");
, {' i9 ~$ p7 v2 u" P& k, \" L& G6 v: @
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-22 11:42 , Processed in 0.040323 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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