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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。- ?  I/ N4 {8 c# ?& C, Z
#include <linux/init.h>
0 V* W9 g) O3 B1 K: \9 J#include <linux/module.h>
) W7 x6 X. p1 s#include <linux/kernel.h>1 U# j  x- P$ ~8 z
#include <linux/types.h>3 p5 n: T' e- ^
#include <linux/gpio.h>
$ y$ u2 w2 Y* M/ [1 {5 q* {#include <linux/leds.h>& V& ?' ?* N3 ^( {2 ~
#include <linux/platform_device.h>+ x6 u5 [, X, u

, R1 Y3 y9 P6 p! W! `/ i, t#include <asm/mach-types.h>9 \& D9 W  ?& T" G, U- L
#include <asm/mach/arch.h>" O  x( k4 ^8 Z, R0 ?9 W) g
#include <mach/da8xx.h>
4 j% E0 Z5 t2 H4 S& E0 I#include <mach/mux.h>
' n: P' W2 I2 v/ b6 s  \1 h& E" e+ d2 N- p8 G
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
  n' S4 u  R1 G0 r4 Q- S" r#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)3 d" Y' _1 d9 K
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
4 A/ L' X1 a" z% U. \  v#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)% S9 x) w  A' l! C/ D
5 N/ h& x, J% s6 L4 [6 d0 t3 Z- h
/* assign the tl som board LED-GPIOs*/
$ c& u6 B3 }8 C. l+ g0 d0 Estatic const short da850_evm_tl_user_led_pins[] = {2 B" D0 f) \4 r0 Y
        /* These pins are definition at <mach/mux.h> file */
' q& V/ X  p) q* y5 t$ P, @        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& I. z, c9 r( R/ A        -1
' B; U. W2 p3 p3 s) |};0 P6 u/ H0 I+ i0 Z0 q1 d  D' d5 N* R+ p

  D4 j% K' H: `static struct gpio_led da850_evm_tl_leds[] = {! {  i8 o, E; T  q0 t, e* A8 j4 P
        {( z9 j& S6 G% U1 _+ n) C
                .active_low = 0,: E! d' K) n+ A8 X
                .gpio = DA850_USER_LED0,: j. B' T7 v2 [
                .name = "user_led0",8 {) L1 J; i. i, e8 A9 L; E
                .default_trigger = "default-on",
4 }2 |5 H) m2 x! n' }6 H        },
: t9 Z( d( z' g        {
5 e5 S- D$ v5 ?; x2 Z' R/ j5 p( {9 Y/ @                .active_low = 0,
, S' `1 \5 K0 I. @2 g  f3 C                .gpio = DA850_USER_LED1,
8 F" b7 T( P6 S1 f                .name = "user_led1",$ x6 c7 Y8 X: N: W0 D4 o! B, P
                .default_trigger = "default-on",5 s; A2 M- P5 A" t5 ^! l# b
        },
& d- b! _& ?8 B7 v        {
5 {9 B* r' o3 p# U7 J                .active_low = 0,
3 L$ i) u# p) h* p- S8 X* Z                .gpio = DA850_USER_LED2,
: D! E8 N% f! n' F3 v1 P0 U                .name = "user_led2",( V/ ~0 j- A1 A
                .default_trigger = "default-on",8 x# O1 E3 f0 j7 Z! V3 a8 F
        },
2 n9 ]2 X4 K$ C: j        {
3 r3 p( |+ `0 m+ M; |7 ?7 }                .active_low = 0,
! R+ ?1 G" Q/ S4 n0 }                .gpio = DA850_USER_LED3,
" A4 R# E9 t$ C0 s' u. y                .name = "user_led3",8 e) I9 ?+ i# g0 g
                .default_trigger = "default-on",* h" g2 K; I. K! i' A% g1 N
        },
5 U& x" ~, }+ d. M1 a9 }};
& ~3 T5 R* l' M1 C; [9 f! B) r1 ?; `' u2 ?. T
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. Y) x3 f1 M$ I- I3 G0 i        .leds = da850_evm_tl_leds,% Z& Q, y1 E0 @5 j7 n9 Q0 c$ K
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),  E3 t. C8 e! Q# L; k7 k
};4 x0 u7 h3 D. s9 H3 r% k7 y

& R# L/ l, S  q2 J$ `& i( Istatic void led_dev_release(struct device *dev)
5 i; N6 d1 s1 g) {! J1 z{* E+ U6 V+ ]* v. r
};! r) [$ ~: N9 P* d5 h" d* V
, j1 Q1 Z& O2 m+ J- G9 r; R* k4 K
static struct platform_device da850_evm_tl_leds_device = {; l0 A& S, l) M/ {
        .name                = "leds-gpio",
  Q4 i# l/ v' \! ]( k  y' |1 |' X: N0 j        .id                = 1,
# v* H7 u4 i# w( ~: q        .dev = {, W% F' z% C0 n( a; _1 |$ f
                .platform_data = &da850_evm_tl_leds_pdata,, N3 Y/ R9 D- y% c4 I- Y1 B
                .release = led_dev_release,) q6 u4 n. k8 h- m. O
        }
, D, Y9 k/ O% M' W1 G6 k};
9 f- f  a" z+ ]: c* I* \7 x. v
static int __init led_platform_init(void). c+ X' p) Y" {5 K5 N
{: U! K+ Q: P5 e) p/ l+ y/ o6 I
        int ret;: w' {; l5 ]; G7 s; [4 ~5 Q% h
#if 0
8 G! S/ B6 n/ U; M8 O+ k2 R* v        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);  j" Y  d# B  \
        if (ret)
9 x6 [+ W3 M1 {                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 q* m1 }9 W- W- P7 U* g3 E
                                "%d\n", ret);
( D5 l' O4 k3 e+ R6 ]8 V' s3 r/ M#endif) i6 W/ S7 q( X1 ^( D: z
        ret = platform_device_register(&da850_evm_tl_leds_device);  p, ?' Y# l+ n; T- ^1 `
        if (ret)
! r, I+ P( r# Q2 p; s- d                pr_warning("Could not register som GPIO expander LEDS");
, h+ y) w9 w1 t* t" E/ ~) R' K        else, W- z9 d0 I* J
                printk(KERN_INFO "LED register sucessful!\n");) M4 X# L6 D( F- V9 X; X: c9 q7 p( k
; C7 f; K+ R, K1 u6 L3 B1 G$ R" e
        return ret;1 y; c  q! Y( U3 U6 z. F0 Z- K
}2 r+ ~$ w# A: e  m  u

( Z0 ~. Q, H6 E( E2 astatic void __exit led_platform_exit(void)
: C$ R* s% O: \( C. d) L; G; b{
0 q" `' H2 N& \3 \        platform_device_unregister(&da850_evm_tl_leds_device);
1 a3 |* O; n& u  J# a+ D( X5 M0 c, r9 t( y( U! o7 E' S5 V5 h
        printk(KERN_INFO "LED unregister!\n");
) e3 F* F4 e1 N. q- B8 z}
' y5 [* I! E/ ~1 w$ Q% h! \) Q8 d
% y# W# r; Y0 c$ D* vmodule_init(led_platform_init);
/ A2 }* j- e; ~- R5 J5 \module_exit(led_platform_exit);: m5 j! U7 w. B+ P! {
' f, \- t; X0 R" d8 r! a: c
MODULE_DESCRIPTION("Led platform driver");
. E8 k5 T1 U. h! {5 ~2 _& BMODULE_AUTHOR("Tronlong");: q& g; E  ^5 ]1 {& O
MODULE_LICENSE("GPL");- @( P: e0 C; Q, |6 G+ I

# L) q1 L8 b1 ~( G$ [0 _  q' p: V8 `
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-6 09:44 , Processed in 0.044357 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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