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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。  e4 ^! C. K; z; C1 U6 T: H) ?7 O
#include <linux/init.h>
0 r( [; j9 p9 g% ^3 z#include <linux/module.h>& B% o6 X# }! M- E# ^; ^
#include <linux/kernel.h>
& J& y/ f9 T; j( t- w9 I/ h#include <linux/types.h>
0 @, A2 W' a" @7 }" w' L3 _#include <linux/gpio.h>% s. A: Z8 K' u/ T% Z
#include <linux/leds.h>
1 w7 W1 S) d3 r7 F; F#include <linux/platform_device.h>
  R8 ?' p# r6 O  w0 {& F& [) ^2 |; H3 H% d3 z' R0 y; c9 y
#include <asm/mach-types.h>; p% E. m) F' {& j7 N( ]
#include <asm/mach/arch.h>
: W' v) z! p- s, n5 d: Y#include <mach/da8xx.h>/ z  @) B: |5 m$ k1 a0 p
#include <mach/mux.h>9 O) f8 c6 X2 P6 z: [0 B) a  U+ G
9 y4 j; \$ U1 E6 q: v2 Z- U. o
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)% M5 ~4 N4 b7 p% p- Q
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5); _$ k/ x( Y; n
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)9 }: {2 ?: B* N" o4 E
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ X. _" @$ R# K& S6 f) K4 C

+ g" M) b# f$ y$ ?5 y/* assign the tl som board LED-GPIOs*/
. c, H  Q5 Y+ ~1 M. v+ _static const short da850_evm_tl_user_led_pins[] = {  H. U& w& R, Z1 X6 g! _
        /* These pins are definition at <mach/mux.h> file */
" U" U8 Q4 N6 _5 k( U$ ^5 b) f        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ c  b; R; q: c+ J7 K/ A        -10 _$ _' s6 }$ z. _, F7 f7 G2 `; `3 B
};
& F" m+ t9 u0 i7 N  c* \  J* B2 \) J8 {0 `- ^
static struct gpio_led da850_evm_tl_leds[] = {
  [) l+ g# d! C5 @' x) d7 K% R        {
% U$ E6 u2 L6 G3 ~: m( t' `                .active_low = 0,8 `  H5 {/ F$ C( I
                .gpio = DA850_USER_LED0,& ~# @& e% E. ^
                .name = "user_led0",  J2 T& P3 g- m$ v. m! m
                .default_trigger = "default-on",* j, i/ W* x2 P, ~0 Q1 f: K. E
        },
+ t7 h, T0 B) q& n# @: x" ^        {6 j# p5 }; w! d1 d% e) Y2 x
                .active_low = 0,
# i) f  l& w# S  _$ o* U2 h3 T                .gpio = DA850_USER_LED1,
2 O1 o- L7 l5 n- T8 C6 i# @5 r! M                .name = "user_led1",4 K8 _+ C3 z4 i, Z& @" h- v
                .default_trigger = "default-on",& ], s) _- e5 \; B
        },# Y  n+ E5 h3 j# _
        {
. B4 z6 m  t# Q                .active_low = 0,2 p. f( G$ b. o- e/ g, I
                .gpio = DA850_USER_LED2,
* o! @. U8 n* P: y8 G                .name = "user_led2",
* Z! y  B' X' {! A; x: |" ]                .default_trigger = "default-on",0 x" Z4 {7 Q2 C/ I; B( a" J) u
        },
& I. }6 A' T; q; x, d2 K7 ?( m# r        {. n; V& L0 F+ b8 Y2 I# P+ M
                .active_low = 0,
  Q4 H9 T9 v' x( S2 i7 b1 E5 a; y                .gpio = DA850_USER_LED3,
+ e. G1 @9 x' U# L* @! \                .name = "user_led3",9 Q0 [3 I3 ^; S5 ?" h* z
                .default_trigger = "default-on",# D3 r) c8 l, q
        },
  g8 H5 _+ y( g  x) f' [8 w};
1 T2 I3 \  x, `9 b# f4 R+ G9 _% Q) N7 ]& N; K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ X; |& h+ f+ M8 c
        .leds = da850_evm_tl_leds,! ], U, @6 ~0 v, ^, u/ w! u" t
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 w0 v0 T3 _9 `
};" ^# T8 \# E7 N. B' _5 L4 J% I  I
1 @8 K' m$ k. n) B6 Y7 f1 h, g
static void led_dev_release(struct device *dev); b0 l/ m0 c9 ~1 a  T! {; {
{
9 _/ [5 L+ F  x1 t6 M6 t% `};
& A( l5 u4 `4 p) ~: x( l8 ^+ a' x# @: c: Z5 s
static struct platform_device da850_evm_tl_leds_device = {
( \  T/ T7 `( H: Q2 M, y        .name                = "leds-gpio",# u; f& Y9 D% ?. z
        .id                = 1,
+ B7 v0 ]- E8 ~7 Z0 e' }* Q        .dev = {
9 W8 x2 X7 @8 X                .platform_data = &da850_evm_tl_leds_pdata,. T8 S9 S# Q* V6 }
                .release = led_dev_release,3 z- W3 Y) s' R# Y9 _1 Y# T% h1 F
        }3 P& A1 P; F( a& {. ?& v
};: _4 _; ?7 S# ?0 ]1 {
; g  E& s8 G) n$ j6 S" t# p# b
static int __init led_platform_init(void)) @0 D$ S' }/ H# m/ _1 v+ |
{: G0 R; a2 d5 `
        int ret;( d, U; i7 U1 d0 g# Q3 m
#if 08 F& r: d3 ]9 P/ J& Z
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 M2 L, y/ K! r- \% Y7 I$ r        if (ret)( v  d! P9 \/ |$ E& x; P  Q
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( f5 q: x8 B: b1 y9 u, Q5 Q5 M
                                "%d\n", ret);
1 ]8 N+ [! ^3 K+ y+ v#endif
7 Q7 a" H) s3 G        ret = platform_device_register(&da850_evm_tl_leds_device);
- M4 y& s/ s& Y7 e        if (ret)
3 W+ D& H; ~- R8 y                pr_warning("Could not register som GPIO expander LEDS");& h4 h$ _1 a& y9 V+ Q6 A# P
        else$ @/ ]0 ]1 L) }+ J
                printk(KERN_INFO "LED register sucessful!\n");& a  w; J* L( a6 x  N+ M+ {; p0 r: ~
6 T/ V9 X8 o5 D
        return ret;
; q% _+ k  Q0 @/ l6 x# N}7 G7 s% C1 {4 F3 v3 U" B! L

, C' s9 X0 D& d9 G# V$ B  pstatic void __exit led_platform_exit(void); g* R' O0 k. l' F. i
{4 D7 O. R% V- }2 u$ K7 x
        platform_device_unregister(&da850_evm_tl_leds_device);
7 l$ r- E+ J" p& ^* u3 `# ?" K
( n% X9 d. M1 f        printk(KERN_INFO "LED unregister!\n");/ c/ g6 e4 S; Y6 J7 C
}
" g/ M4 o: h- o. \8 A6 w; t$ A9 C3 w- r
module_init(led_platform_init);
( V; D2 j% B  h9 X' w' \9 _module_exit(led_platform_exit);
% @( M7 I$ T5 ~8 n; H  y1 F+ d4 d
8 Q$ |6 o5 `7 c8 a! jMODULE_DESCRIPTION("Led platform driver");
: ?3 ?+ K- l& FMODULE_AUTHOR("Tronlong");$ q& C5 ~4 \! f, C9 |) f
MODULE_LICENSE("GPL");
; P/ F8 ], c; E, J# H* Y3 S, x7 `# F- |8 a5 B4 O3 q2 U: f
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-10-26 01:48 , Processed in 0.042011 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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