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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。  c* b1 b2 b0 r# X1 U
#include <linux/init.h>$ b. t$ H" A. C* O- H
#include <linux/module.h>  s9 e5 V3 }/ a; c3 T1 L# g
#include <linux/kernel.h>8 I, y8 g6 h7 j% T7 R
#include <linux/types.h>
  W0 {1 M, M; {- k#include <linux/gpio.h>
& q) Y( ]& \  e#include <linux/leds.h>
, u+ c2 w5 v3 y. ]7 z#include <linux/platform_device.h>
. N+ n9 K4 d9 ?8 m* ^$ E2 g- M% V& {
#include <asm/mach-types.h>) G6 x5 G9 C7 H! d2 N3 n" P
#include <asm/mach/arch.h>9 y- j* {: Y3 [4 M* D0 a+ I6 }
#include <mach/da8xx.h>$ l$ X3 f# L1 \
#include <mach/mux.h>
4 H3 }2 b1 x; ~7 V
  c8 V6 X7 P% `#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)+ c; |1 n$ d1 q" u' X8 o) o" M
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5), K  z; ]1 s; z# d( q  u% @
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
( F! {3 P1 L5 z#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)# z& z$ r6 Q* |* }( A5 w: K

% b9 Y/ B) {4 T$ ^! V7 f/* assign the tl som board LED-GPIOs*/
' r  t6 g* d; u- W3 Rstatic const short da850_evm_tl_user_led_pins[] = {
' ]& D/ P! s5 F$ O7 m+ I& z+ [# i  F        /* These pins are definition at <mach/mux.h> file */1 ^  E' ^) H0 }# G# K7 E
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 Z! \8 @2 b" F5 V! O9 i        -1
. ]1 y5 U! p( ?1 i* K};4 A/ o( j/ R' `$ x2 O) l

3 n9 J" ^/ @0 V9 K% Q) Istatic struct gpio_led da850_evm_tl_leds[] = {- x+ e  X3 Z) p, B& w! C
        {; Y' }5 G! e- l
                .active_low = 0,
' f" H! n8 ?& x* A# m7 c                .gpio = DA850_USER_LED0,- S- {! e: U  D" v
                .name = "user_led0",
" O2 L1 d1 e+ N8 A                .default_trigger = "default-on",' C/ U6 A* V  t
        },
3 ?# v6 S! O0 o& M& z        {
- ^# E) \6 D$ w3 ]; U                .active_low = 0,7 m3 J* ^! s/ V; s+ |: J
                .gpio = DA850_USER_LED1,6 T" r$ |4 C' U+ X* `! \& o( Q
                .name = "user_led1",2 Y* Q1 M6 s' b3 ?0 C$ w6 M
                .default_trigger = "default-on",
; n8 H) o9 T; _# ]: A        },& }9 V9 N$ n& o1 {+ [
        {
- b) k8 M. _. V3 Z7 Q; U                .active_low = 0,
  V9 A8 b/ \0 t- R; P                .gpio = DA850_USER_LED2,! `& W' D" X+ I/ o9 ~
                .name = "user_led2",+ v2 j  Q( Z  w
                .default_trigger = "default-on",) }4 X- T8 r. C2 x! e& S1 f
        },: _; C, l5 k7 A/ k+ l- I
        {* U# j# l9 d3 o% T$ j- B$ u
                .active_low = 0,+ f% L9 J# O3 h) H
                .gpio = DA850_USER_LED3,
, |$ V7 D# F/ a6 I                .name = "user_led3",' Z/ b# ~1 n( j9 }( K/ g" S, D/ K
                .default_trigger = "default-on",
3 V1 r% X7 }; X( L        },
% {- ?; n. {2 o$ }" O! L( H};
! @* p+ G' ^  U' y6 H5 E: k" o
2 |' R7 S# t/ \. E1 gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( C7 b3 d3 b0 o4 v7 U- s% f
        .leds = da850_evm_tl_leds,
( v( \6 c6 S4 s. c/ S. ?: l        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 P4 M% b; p8 h- b4 l. H' j
};
7 ?2 a3 r  F. Y8 b; r* |- N; B( c" x. r$ @' ^
static void led_dev_release(struct device *dev)# X. K8 x( M0 K9 v! R' i
{
9 m  |3 w- C- ?% z};
3 @, z4 ^+ A  i5 l: V8 k; _  r' u2 @. ~. H
static struct platform_device da850_evm_tl_leds_device = {2 }7 ]! @" i5 B7 d* z4 J
        .name                = "leds-gpio",
8 n" @# i2 l- Q$ A        .id                = 1,- \" F# D. t" w' T6 V, b0 e* U! e
        .dev = {
' T' D: |  d# ]; a+ q3 h1 G                .platform_data = &da850_evm_tl_leds_pdata,
, j1 ^* e8 R- [* `/ {* I) h                .release = led_dev_release,
! c3 o+ e6 b1 h8 v        }
% D. ~# l$ g% m' h) c3 [};
  X0 [3 V: T% V0 e' Y4 G7 _/ [  M, y0 Y- [; k: R2 M
static int __init led_platform_init(void)
5 ~8 q- e% b. i9 L5 O8 c{
& i* l+ e6 X- N& }: ~; p) m        int ret;
. B; b6 L0 b" z  X8 y" l. Z6 B#if 0* N6 x9 F8 I4 ]! u% ^; a& l4 m
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 g9 ~. J+ C( F        if (ret)" S( u( p4 E  N; D
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 `  k  h. X2 t" K! m: W
                                "%d\n", ret);# ^' \9 T% k4 n
#endif
' P7 _' l1 ~" q7 y+ y/ B9 ^        ret = platform_device_register(&da850_evm_tl_leds_device);  t7 ~( k" Q3 q! N, a3 o0 k
        if (ret)
& [. {2 v# ]4 j" O! i4 R1 D2 n3 z                pr_warning("Could not register som GPIO expander LEDS");
, z8 C! P* q/ T4 T8 j/ `4 o        else* O( A6 m: [* |7 F* Q7 I/ c5 o, A* l
                printk(KERN_INFO "LED register sucessful!\n");
/ U4 |( j" `  i% U0 i0 i2 E: L- V% d0 e$ |9 I+ V! |
        return ret;
4 }1 J* l& E3 f$ o}
3 P1 X# P$ z3 ?' D6 d) y& ~% {! O- R( c8 v: q+ P6 `, J; t
static void __exit led_platform_exit(void)
" H. Q1 Z" m2 c$ X, m7 U{
5 E2 J5 i' `# ?0 j8 z        platform_device_unregister(&da850_evm_tl_leds_device);* f5 Z" o( {2 Y" h
, [5 c7 O2 `7 S8 r* j1 d
        printk(KERN_INFO "LED unregister!\n");
* }9 o5 I! X. W5 j/ `5 d& t}/ [, a! U7 e2 C5 [: U

, a: _3 [- R, K9 n6 T- d* @7 p1 F9 @module_init(led_platform_init);% d2 x: h8 w) r: Q
module_exit(led_platform_exit);
: S" G: H: y. e5 g) Z, B) u% I+ L* f* H
MODULE_DESCRIPTION("Led platform driver");
* o* u  n6 U: MMODULE_AUTHOR("Tronlong");) G$ y+ D, O. l6 U
MODULE_LICENSE("GPL");
. p& z9 n6 e- @! ?( y* u/ B0 c2 [* s) ]" O# c2 P1 Q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-2 19:59 , Processed in 0.058507 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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