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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
7 b# d2 z) {# b+ o2 T! R#include <linux/init.h>$ U: C7 Q8 ^- t6 Y! |' Y$ {
#include <linux/module.h>0 E# D% W4 D$ o5 J4 N
#include <linux/kernel.h>
( }& y* p: u4 m/ Y( l: K# D5 q#include <linux/types.h>
$ J! B" [! P+ A8 }( A: h/ e#include <linux/gpio.h>6 P; W* x) n6 E0 e( b+ s
#include <linux/leds.h>- ^8 V0 Q+ C; o; m& r
#include <linux/platform_device.h>+ B+ W# l3 _2 B$ D/ e* c" n$ ?: X

% W  M) ]6 M2 X! I  ?' [  `6 l7 @: G1 w#include <asm/mach-types.h>* U! m7 y8 q( u& A& Q6 L; \" u+ y5 y2 F
#include <asm/mach/arch.h>
+ q" ]# i4 C7 u8 C2 w3 d' [#include <mach/da8xx.h>" a( \3 r8 n9 E+ |4 l/ l2 \. Y8 f
#include <mach/mux.h>- o, A( r9 L3 {! ]2 a9 I4 [/ A2 h

# _3 ~3 o( @+ a#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
7 y& P7 H/ R% X  b4 ^#define DA850_USER_LED1        GPIO_TO_PIN(0, 5): [  a! }9 ]  \- {2 _
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
* Z# d3 S" d3 x( I  d7 H5 k#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)! e9 D9 T9 }( E2 }5 y! }' `
0 A  n; K1 n7 t' F  p" O
/* assign the tl som board LED-GPIOs*/& Y* _7 y: W& q4 j6 N2 c6 c
static const short da850_evm_tl_user_led_pins[] = {# z4 `& y7 r8 [" ]6 R
        /* These pins are definition at <mach/mux.h> file */
! D; @% t' z) }" \        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ m( Q2 \5 |0 x- v
        -1
9 U- d( |# _+ Y2 t% L8 g2 t7 M};0 {) W0 s6 ~8 h0 ?1 \
! M% q3 L. y& e) c6 \; s! f1 J
static struct gpio_led da850_evm_tl_leds[] = {
% U- R- C/ s% k% E$ A9 X4 y        {4 M: r  @$ i4 y6 n, c# [
                .active_low = 0,
3 n1 O$ F% s, N/ {$ J/ z$ R                .gpio = DA850_USER_LED0," k! N7 u! P& a" N% N
                .name = "user_led0",/ e/ P# W# ~! k9 Q4 J! a- y
                .default_trigger = "default-on",- g5 ?$ Q. n8 X; c9 N" i
        },
. i' P" U  ^3 B% W        {' [5 t% e; P5 ?# w: H5 f* ~
                .active_low = 0,
! R; o# [% a  k                .gpio = DA850_USER_LED1,
7 z- }, B8 Z. i  @9 o# K% z                .name = "user_led1",- }7 \, R/ s5 h4 z+ T" e
                .default_trigger = "default-on",
# j" y- r) X  d& E4 j$ W% Z        },
; X. ]. a2 F1 |! v; B        {
2 j3 {  Z* j/ _# U2 n; L                .active_low = 0,
6 O* U1 x, D2 x1 @' ~0 [                .gpio = DA850_USER_LED2,
/ j0 y( B$ F" j( M: j                .name = "user_led2",
1 \7 b6 ]/ j  C4 }+ j                .default_trigger = "default-on",
" T3 I5 P$ m8 O+ o  c1 v        }," h' E: H, E+ L: {. F. q2 T
        {
- i5 [+ C2 e  h& ], T- s1 A                .active_low = 0,
) ^5 i, c' Q7 W                .gpio = DA850_USER_LED3,
0 f( Y4 {' @, p2 A: N                .name = "user_led3",' [" m0 {: h7 d3 ^, U- I+ k; I- U
                .default_trigger = "default-on",
5 ^7 V( j# _. K/ W' c        },
8 T0 h! P3 Y" B5 b& Y# z};. f/ h& y/ `) F% L% C! b

6 I) S1 Y! U/ y3 `+ ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! k, }0 L+ q+ C/ [, T& l+ M: \* G8 |        .leds = da850_evm_tl_leds,
; l9 X4 ~4 @+ q( {7 S' Q        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ m5 O6 L1 G, J* u9 [2 {  Q3 r1 D};
5 t+ B  {9 t. v) z7 L: r! |/ q6 I9 u2 |
static void led_dev_release(struct device *dev)# P, A9 u2 `" ?
{
! M+ X3 N' a8 @! A};( u/ ~$ ?- I3 ?+ Q
9 h( a5 j6 Q% c1 a1 d! I1 O  G
static struct platform_device da850_evm_tl_leds_device = {. Y: f2 Y1 m: ]: c7 B& [1 ^! G
        .name                = "leds-gpio",. {+ P$ E: \- Q- v; y! t; q  _
        .id                = 1,2 E( ?4 x  c; S8 i% Q
        .dev = {' D/ `: Q( Q6 s9 J- G" O) e
                .platform_data = &da850_evm_tl_leds_pdata," }/ k: \" M) H3 Q8 [$ k6 a" V
                .release = led_dev_release,8 B# P- D* Z( w9 e; n$ l; E9 t/ F$ R; ?
        }1 G( J* ^) N  O
};2 o6 b+ O( F) [
1 F! ]1 P( |( N! `5 W8 [) b+ X! _/ r
static int __init led_platform_init(void)
/ D/ C# G$ {* i9 `$ S/ Q7 N5 T  a" {{6 `+ ?% R1 x$ \- L. C. h5 y
        int ret;
/ z( ~0 O# [1 R/ Q0 c% O. ]3 d#if 0" c7 H) y& U, d0 Z+ S4 M
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! v' I3 g! X' N, ]        if (ret), q" e8 e: P# ^* U
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"  p# B' O# p8 C2 U( G6 b
                                "%d\n", ret);
( @; `9 A2 s; H. ~/ Z+ P#endif. u6 T# [2 U3 {6 ]) I
        ret = platform_device_register(&da850_evm_tl_leds_device);- a0 I9 Z; m) ]0 `
        if (ret)' `. w" @4 v7 K: O
                pr_warning("Could not register som GPIO expander LEDS");" s. a" X  w$ p/ e( f( v
        else3 n' I! w1 ~) _
                printk(KERN_INFO "LED register sucessful!\n");
: K) o0 X% g$ D, t* G5 ?0 O$ q1 }# O; y$ I/ S/ d
        return ret;
. y- E, [$ Q$ H}& p+ {* {: R/ m+ s
) X# _1 E' n9 d
static void __exit led_platform_exit(void). n+ O4 d# c( s# G3 p  r5 T: {
{
" {# k1 N, p' k. F$ f9 ~8 x; ?        platform_device_unregister(&da850_evm_tl_leds_device);
4 W, y" n% g& C0 ^8 j: h: e
+ z6 |4 S! d$ l2 G6 f        printk(KERN_INFO "LED unregister!\n");
, m1 [" t3 o8 k}% w2 r0 S: E# @2 p" e0 H
6 m4 {2 x- X$ V1 |
module_init(led_platform_init);9 r1 C: c9 }0 X. q! {  u' W
module_exit(led_platform_exit);, B$ ?' x4 }! g3 z3 W

" x# \1 ?7 H! T- {. ]MODULE_DESCRIPTION("Led platform driver");; |" i7 v" ^6 D! f2 _- x, u1 y3 g
MODULE_AUTHOR("Tronlong");
) M$ I9 I; ]: e5 b2 Y1 \/ XMODULE_LICENSE("GPL");% S* ~/ p/ ]6 W4 u9 u- p; Y$ [% E- `

' ^  j1 A; |# F) `8 E
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-1 18:05 , Processed in 0.039924 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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