中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 基于uclinux 的CAN總線嵌入式驅(qū)動編程

        基于uclinux 的CAN總線嵌入式驅(qū)動編程

        作者: 時間:2013-04-06 來源:網(wǎng)絡 收藏

          模塊首先對引用的庫函數(shù)進行申明,并且定義:
          #define IOPMOD (*(volatile unsigned *)0x3ff5000)
          #define IOPDATA (*(volatile unsigned *)0x3ff5008)
          #define IOPCON (*(volatile unsigned *)0x3ff5004)
          #define EXTDBWTH(*(volatile unsigned *)0x3ff5
          #define SYSCFG(*(volatile unsigned *)0x
          主要有以下幾個模塊:
          void can_init(void)
          {
          SYSCFG =SYSCFG 0x0fffffffd;
          EXTDBWTH =EXTDBWTH 0x00ff0ff;
          IOPMOD=0xf0ff;
          IOPDATA=0x6000; 寄存器地址0,MOD寄存器
          IOPDATA= IO_PDATA0xdfff; ALE=0 配置MOD寄存器
          IOPDATA= IO_PDATA|0x3f; ; 復位模式、使能
          IOPDATA=0x6006; ;寄存器地址6,總線定時器0寄存器
          IOPDATA=IO_PDATA0xdfff; ALE=0配置寄存器
          IOPDATA= IO_PDATA|0x3f; 跳轉(zhuǎn)寬度、波特率設置
          ……;配置總線定時器1、驗收代碼寄存器等
          IOPDATA=0x6000; SJA1000 寄存器地址0,MOD寄存器
          IOPDATA=IO_PDATA0xdfff; ALE=0配置MOD寄存器
          IOPDATA= IO_PDATA0xfe;寫復位位,進入工作模式
          result = register_chrdev(254,"can",can_fops);申請主設備號
          if (result0) {
          printk(KERN_WARNING "CAN:can’t getmajor ", result);
          return result;
          }
          在該驅(qū)動程序中,定義結(jié)構(gòu)變量can_fops為應用程序訪問內(nèi)核的接口:
          static struct file_operations can_fops = {
          read: can_read,
          write: can_write,
          open: can_open,
          release: can_release,
          }; 
          static int can_release(struct inode *inode, struct file *file)
          {
          MOD_DEC_USE_COUNT; ;用戶減計數(shù)
          Return 0;
          }
          static int can_open(struct inode *inode,struct file *file)
          {
          Scull_Dev *dev;
          Int num = NUM(inode->i_rdev); 設備號
          Int type = TYPE(inode->i_rdev); 設備類型
          If (num>=scull_nr_devs) return -ENODEV;
          dev = scull_devices[num];
          flip->private_data = dev;
          MOD_INC_USE_COUNT; 用戶數(shù)人工計數(shù)
          IOPCON=0x16; //xIRQ0
          disable_irq(INT_can);
          if(request_irq(INT_can, can_rx,
          SA_INTERRUPT, "can rx isr","can")) {
          printk("s3c4510-can: Can't get irq %d",
          INT_sja1000);
          return -EAGAIN;
          }
          printk("can has get irq 0");
          enable_irq(INT_can);
          …… ; 配置SJA1000內(nèi)部中斷及屏蔽寄存器
          return 0;
          }

          7 結(jié)束語

          本文介紹了在嵌入式系統(tǒng)中的驅(qū)動編程,對技術在嵌入式系統(tǒng)中的應用進行了探索.本設計已在通信用逆變電源遠程監(jiān)控系統(tǒng)中應用.

        參考文獻:

        [1].S3C4510Bdatasheethttp://www.dzsc.com/datasheet/S3C4510B_59.html.
        [2].RISCdatasheethttp://www.dzsc.com/datasheet/RISC_1189725.html.
        [3].SJA1000datasheethttp://www.dzsc.com/datasheet/SJA1000_609075.html.
        [4].PCA82C200datasheethttp://www.dzsc.com/datasheet/PCA82C200_554.html.
        [5].p12datasheethttp://www.dzsc.com/datasheet/p12_2043488.html.
        [6].p13datasheethttp://www.dzsc.com/datasheet/p13_2043489.html.
        [7].p15datasheethttp://www.dzsc.com/datasheet/p15_1204152.html.


        上一頁 1 2 3 下一頁

        評論


        相關推薦

        技術專區(qū)

        關閉