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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
, Q0 t* w# a0 H& ~/ Z# K#include <linux/init.h>
+ j8 _" ~2 [$ N#include <linux/module.h>( S! Q5 R6 P6 Q% k( h) \
#include <linux/kernel.h>/ s# H, ]  \0 S
#include <linux/types.h>' J! P, L0 }( W* H: ]: P8 M
#include <linux/gpio.h>- I; y  t( c1 a3 B- O
#include <linux/leds.h>& I/ g- K: |# ^* t' x
#include <linux/platform_device.h>3 i$ E1 _4 m4 i$ v& P8 i
0 h" N& M8 S, M, V) _, m0 e! |
#include <asm/mach-types.h>+ G( _" r+ c4 f' J: l' k. S: W
#include <asm/mach/arch.h>/ c; i, X( s0 _! X( p
#include <mach/da8xx.h>
( A, ?- N3 b& ^  {/ _; v) ]#include <mach/mux.h>
: v# u9 ?5 ^3 k3 a
" E: S$ I/ J5 |: c& p#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
# x9 |9 H7 |2 @+ I#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
* p- q( H4 \  L2 s; z- D& ?#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)1 n( l3 Y  l  b# e
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)1 W! g' I6 l6 K1 P) f/ ?& @- G5 q% Y

7 G& f/ e4 M/ Y) X* u+ S/* assign the tl som board LED-GPIOs*/- P$ d: [2 R0 V% M
static const short da850_evm_tl_user_led_pins[] = {
$ u7 t8 X  _) R3 H( h7 H, m4 V        /* These pins are definition at <mach/mux.h> file */) ^5 {+ u( h6 O8 s( v, g! A
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* c$ D; r/ l+ e) r
        -1  F4 [1 W; I9 X5 S6 A# N
};$ H7 p  E4 g, J) |7 Z

6 b) A+ N0 n4 Y# v( T" Astatic struct gpio_led da850_evm_tl_leds[] = {
  J1 H/ V. w( W7 c        {  A  e; {0 d2 F
                .active_low = 0,
% i5 [, b1 d( Z                .gpio = DA850_USER_LED0,
3 Z& K3 F; d: |! Z, I: }' k                .name = "user_led0",
3 f9 M7 ]* X; t" n. m  k                .default_trigger = "default-on",
4 x# [, H1 O" u4 x8 U        },# t' E1 G. S2 J& |' F, n' g
        {
, K, R9 N* G* x' ?                .active_low = 0,
' ]) W% j9 C& F, h9 U$ o6 A, V                .gpio = DA850_USER_LED1,
& C) ^+ ?# M, i1 \& w                .name = "user_led1",
9 D% r" L2 x9 U( u' }& Z; i3 S/ `                .default_trigger = "default-on",
' N0 y# `6 W" l6 f        },6 n' e- t- X% U+ l  I5 n' T& M$ J
        {- G8 p6 \" Z/ ?+ a
                .active_low = 0,0 v7 f! M" h0 M( m1 q# q, _
                .gpio = DA850_USER_LED2,  [/ W8 e0 K7 Q7 x& T3 M1 m6 J/ T( F
                .name = "user_led2",! P. @# z+ N4 x6 u+ `
                .default_trigger = "default-on",
: Q+ ]' C& o3 i/ a( J6 P0 L9 x        },
* f: q6 a8 d" M8 N        {9 G, I( y$ W- I9 `5 }
                .active_low = 0,
& ]$ b; M  |% z; O* P                .gpio = DA850_USER_LED3,7 x: U8 L0 W4 ^/ B. ~4 t
                .name = "user_led3",9 g5 h+ U( }; o2 X8 N( l' q
                .default_trigger = "default-on",
& q( Z$ W0 V8 D# N6 G# b        },
# U& ]; {5 H- [5 n: W  t};
# p- H% v; l, g% w& N  b6 M5 m+ u
9 {* K! D" J7 R- p3 y7 kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 f1 V3 r" R9 @( d. g' q
        .leds = da850_evm_tl_leds,
4 K: b, k. t3 Y3 q        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 |. [' L& h6 f& i  J5 P6 M9 U1 v};
, a0 f, c( C5 D1 v/ t( M+ v, ]6 |% y& e1 ^
static void led_dev_release(struct device *dev)
: @" F& S5 i+ n& V$ t{
: _) p9 a$ N. k};
# E$ U! ^" g  F! w( ], Z+ B, u2 f! K; z6 B3 B% z: t- d( P% L. p  u
static struct platform_device da850_evm_tl_leds_device = {
3 g6 Z# u3 ]) C9 Z' L+ [2 M2 g3 l        .name                = "leds-gpio",
! D$ \  K! a$ f4 G7 L  S' s+ l        .id                = 1,
' C+ {4 E" d' c2 n! \) @2 ]- r7 r        .dev = {6 _: G/ k4 A( j1 }. e4 l: k
                .platform_data = &da850_evm_tl_leds_pdata,5 ]8 R. D8 P# K
                .release = led_dev_release,
6 `0 l4 E4 L2 A3 m        }1 ?1 }) f$ x8 ~8 }7 ?; D$ I
};! D3 P9 t2 |. ~
- A: T) E$ n; Y+ h
static int __init led_platform_init(void)! z$ m, O: I9 g; x4 U$ }  h
{
1 N" i/ m; j6 n- q4 J% y        int ret;
* w+ h8 b- N, O; O% _# s) b#if 0* i7 `' R5 u7 Q% v6 l- u
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ H% j* g9 ]& o' {3 S        if (ret)/ }$ B& C1 Z3 D( q3 _! Q1 ^6 Q, ~
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# ?. v6 S7 a9 L% o                                "%d\n", ret);
+ @  E- {& M6 s#endif
1 q" S3 {: P- ]8 {- {        ret = platform_device_register(&da850_evm_tl_leds_device);
, k! {& u: }2 [  F6 i, \) B, n        if (ret)
! [7 u$ A5 x! d" O$ x                pr_warning("Could not register som GPIO expander LEDS");3 A0 I- L: Z9 ?' o9 I; {0 ^
        else
* u. W3 _: c& y5 k/ T7 V                printk(KERN_INFO "LED register sucessful!\n");
# u2 Z, ?& c& R' u: U# E0 n! n% L1 w+ Y' q
        return ret;# S0 q) ?! A4 \# K; _3 @
}
; v6 b; |' c% U) G& n) w) I
$ [1 U4 m% M' M* D. M, i; q2 wstatic void __exit led_platform_exit(void)4 ~5 x" H) p0 k, K' ~
{& f9 U- l* Y& V0 }: @
        platform_device_unregister(&da850_evm_tl_leds_device);! T6 B# c/ ^. e( ]
, B0 ~$ }8 U, E" C$ c% `  ]: h
        printk(KERN_INFO "LED unregister!\n");
1 J3 j" Z4 g; W}+ {+ H0 Y7 B) V: o) D
* n  u" i2 C. z* p
module_init(led_platform_init);
! j+ S: g3 q& smodule_exit(led_platform_exit);! H9 y$ g+ ^0 k6 |: J3 ]; A

  P/ H. X, k( j7 H- qMODULE_DESCRIPTION("Led platform driver");2 v2 g: E7 R% _+ _( U3 g8 n8 ~
MODULE_AUTHOR("Tronlong");
; l8 r, @4 m" N! B1 ^MODULE_LICENSE("GPL");
6 O! |* _0 G# {0 r) F& Z* Z8 D/ L* d4 Y2 n5 Q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-12-5 16:01 , Processed in 0.040842 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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