在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

RT-Thread PIN驅動添加

RT-Thread官方賬號 ? 2025-03-28 18:59 ? 次閱讀

Pin驅動框架

c9476c30-0bc3-11f0-9434-92fbcf53809c.png

NXP MCXA153為例

PIN設備驅動層

單純的提供接口給應用層用,其中PIN設備驅動框架接口包含rt_pin_read等,具體在pin.c 文件中查看

pin.c是提供應用接口

drv_gpio.c是具體實現

實現操作方法原理

struct rt_pin_ops{ void (*pin_mode)(struct rt_device *device, rt_base_t pin, rt_uint8_t mode); void (*pin_write)(struct rt_device *device, rt_base_t pin, rt_uint8_t value); rt_ssize_t (*pin_read)(struct rt_device *device, rt_base_t pin); rt_err_t (*pin_attach_irq)(struct rt_device *device, rt_base_t pin, rt_uint8_t mode, void (*hdr)(void *args), void *args); rt_err_t (*pin_detach_irq)(struct rt_device *device, rt_base_t pin); rt_err_t (*pin_irq_enable)(struct rt_device *device, rt_base_t pin, rt_uint8_t enabled); rt_base_t (*pin_get)(const char *name);#ifdef RT_USING_DM rt_err_t (*pin_irq_mode)(struct rt_device *device, rt_base_t pin, rt_uint8_t mode); rt_ssize_t (*pin_parse)(struct rt_device *device, struct rt_ofw_cell_args *args, rt_uint32_t *flags);#endif#ifdef RT_USING_PINCTRL rt_err_t (*pin_ctrl_confs_apply)(struct rt_device *device, void *fw_conf_np);#endif /* RT_USING_PINCTRL */};

rt_pin_ops 成員介紹

pin_mode

引腳初始化

pin_write

引腳寫

pin_read

引腳讀

pin_attach_irq

中斷操作 為某個引腳綁定一個中斷回調函數,使能中斷,當中斷來時調用該函數

pin_detach_irq

中斷操作 脫離某個引腳的中斷回調函數

pin_irq_enable

中斷操作 開啟或關閉中斷

pin_get

獲取某個pin腳編號

pin_irq_mode

pin_parse

pin_ctrl_confs_apply

引腳編號

#define GET_GPIO_PORT(x) ((x) / 32)#defineGET_GPIO_PIN(x)((x)%32)

rt_pin_ops 賦值

rt_hw_pin_init(){ int ret = RT_EOK; mcx_pin_ops.pin_mode = mcx_pin_mode; mcx_pin_ops.pin_read = mcx_pin_read; mcx_pin_ops.pin_write = mcx_pin_write; mcx_pin_ops.pin_attach_irq = mcx_pin_attach_irq; mcx_pin_ops.pin_detach_irq = mcx_pin_detach_irq; mcx_pin_ops.pin_irq_enable = mcx_pin_irq_enable; mcx_pin_ops.pin_get = RT_NULL, ret = rt_device_pin_register("pin", &mcx_pin_ops, RT_NULL);// return ret;}INIT_BOARD_EXPORT(rt_hw_pin_init);

注意:這里的操作很奇怪INIT_BOARD_EXPORT ,根據老師的講解是在預編譯的時候就處理了,具體后面再學習。。。

drv_pin.c 的 rt_hw_pin_init 將底層驅動和驅動框架進行鏈接起來,此文件實現gpio的初始化

添加Pin驅動代碼流程

編寫drv_pin.c文件

實現 rt_pin_ops 的各種操作接口函數

然后利用 rt_hw_pin_init 進行鏈接驅動層

實際上就是指針的賦值

實驗代碼

rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT); /* Set GPIO as Output */rt_pin_mode(KEY_BAND, PIN_MODE_INPUT);rt_kprintf("MCXA153 HelloWorld\r\n");while (1){ rt_thread_mdelay(1000); if(rt_pin_read(KEY_BAND)) rt_pin_write(LED_PIN, PIN_HIGH); /* Set GPIO output 1 */ else rt_pin_write(LED_PIN, PIN_LOW); /* Set GPIO output 0 */ #if 0 rt_pin_write(LED_PIN, PIN_HIGH); /* Set GPIO output 1 */ rt_thread_mdelay(500); /* Delay 500mS */ rt_pin_write(LED_PIN, PIN_LOW); /* Set GPIO output 0 */ rt_thread_mdelay(500); /* Delay 500mS */ #endif}

注意:這里延遲1s,目的是為了有msh 功能

總結

學習了PIN設備驅動框架的添加

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • 驅動
    +關注

    關注

    12

    文章

    1874

    瀏覽量

    86098
  • PIN
    PIN
    +關注

    關注

    1

    文章

    311

    瀏覽量

    24825
  • RT-Thread
    +關注

    關注

    31

    文章

    1329

    瀏覽量

    41086
收藏 人收藏

    評論

    相關推薦

    RT-Thread NUC97x 移植 LVGL

    不涉及 rt-thread 驅動,但是它是 LVGL 和 rt-thread 的接口。LVGL 在 rt-thread 上運行的基石。
    發表于 07-08 09:37 ?1575次閱讀

    RT-Thread ssd1306驅動

    RT-Thread 驅動ssd1306
    的頭像 發表于 04-21 10:08 ?26.5w次閱讀
    <b class='flag-5'>RT-Thread</b> ssd1306<b class='flag-5'>驅動</b>

    RT-Thread編程指南

    RT-Thread編程指南——RT-Thread開發組(2015-03-31)。RT-Thread做為國內有較大影響力的開源實時操作系統,本文是RT-Thread實時操作系統的編程指南
    發表于 11-26 16:06 ?0次下載

    RT-Thread用戶手冊

    RT-Thread用戶手冊——本書是RT-Thread的編程手冊,用于指導在RT-Thread實時操作系統環境下如何進行編 程。
    發表于 11-26 16:16 ?0次下載

    RT-Thread Studio驅動SD卡

    RT-Thread Studio驅動SD卡前言一、創建基本工程1、創建Bootloader2、創建項目工程二、配置RT-Thread Settings三、代碼分析1.引入庫2.讀入數據四、效果驗證
    發表于 12-27 19:13 ?20次下載
    <b class='flag-5'>RT-Thread</b> Studio<b class='flag-5'>驅動</b>SD卡

    RT-Thread開源作品秀】基于RT-Thread的星務平臺研究

    本作品為了驗證星務軟件在RT-Thread系統運行的可行性,底層是否能夠驅動星務軟件,同時擴展RT-Thread應用范圍。ART-Pi作為衛星下位機,...
    發表于 01-25 18:26 ?6次下載
    【<b class='flag-5'>RT-Thread</b>開源作品秀】基于<b class='flag-5'>RT-Thread</b>的星務平臺研究

    RT-Thread全球技術大會:Kconfig在RT-Thread中的工作機制

    RT-Thread全球技術大會:Kconfig在RT-Thread中的工作機制 ? ? ? ? ? ? ? 審核編輯:彭靜
    的頭像 發表于 05-27 14:49 ?1656次閱讀
    <b class='flag-5'>RT-Thread</b>全球技術大會:Kconfig在<b class='flag-5'>RT-Thread</b>中的工作機制

    RT-Thread全球技術大會:RT-Thread測試用例集合案例

    RT-Thread全球技術大會:RT-Thread測試用例集合案例 ? ? ? ? ? 審核編輯:彭靜
    的頭像 發表于 05-27 16:34 ?2219次閱讀
    <b class='flag-5'>RT-Thread</b>全球技術大會:<b class='flag-5'>RT-Thread</b>測試用例集合案例

    RT-Thread學習筆記 RT-Thread的架構概述

    RT-Thread 簡介 作為一名 RTOS 的初學者,也許你對 RT-Thread 還比較陌生。然而,隨著你的深入接觸,你會逐漸發現 RT-Thread 的魅力和它相較于其他同類型 RTOS
    的頭像 發表于 07-09 11:27 ?4730次閱讀
    <b class='flag-5'>RT-Thread</b>學習筆記 <b class='flag-5'>RT-Thread</b>的架構概述

    RT-Thread文檔_RT-Thread 簡介

    RT-Thread文檔_RT-Thread 簡介
    發表于 02-22 18:22 ?5次下載
    <b class='flag-5'>RT-Thread</b>文檔_<b class='flag-5'>RT-Thread</b> 簡介

    RT-Thread文檔_RT-Thread 潘多拉 STM32L475 上手指南

    RT-Thread文檔_RT-Thread 潘多拉 STM32L475 上手指南
    發表于 02-22 18:23 ?9次下載
    <b class='flag-5'>RT-Thread</b>文檔_<b class='flag-5'>RT-Thread</b> 潘多拉 STM32L475 上手指南

    RT-Thread文檔_RT-Thread SMP 介紹與移植

    RT-Thread文檔_RT-Thread SMP 介紹與移植
    發表于 02-22 18:31 ?9次下載
    <b class='flag-5'>RT-Thread</b>文檔_<b class='flag-5'>RT-Thread</b> SMP 介紹與移植

    RT-Thread文檔_PIN 設備

    RT-Thread文檔_PIN 設備
    發表于 02-22 18:33 ?0次下載
    <b class='flag-5'>RT-Thread</b>文檔_<b class='flag-5'>PIN</b> 設備

    基于RT-Thread Studio學習

    前期準備:從官網下載 RT-Thread Studio,弄個賬號登陸,開啟rt-thread學習之旅。
    的頭像 發表于 05-15 11:00 ?4538次閱讀
    基于<b class='flag-5'>RT-Thread</b> Studio學習

    RT-Thread設備驅動開發指南》基礎篇--以先楫bsp的hwtimer設備為例

    一、概述(一)RT-Thread設備驅動RT-Thread設備驅動開發指南》書籍是RT-thread官方出品撰寫,系統講解
    的頭像 發表于 02-24 08:16 ?2163次閱讀
    《<b class='flag-5'>RT-Thread</b>設備<b class='flag-5'>驅動</b>開發指南》基礎篇--以先楫bsp的hwtimer設備為例
    主站蜘蛛池模板: 日本一区二区三区在线网 | 国产三级日本三级日产三级66 | 黄视频网站免费看 | 在线视频一区二区 | 91华人在线视频 | 伦理片日本韩国电影三级在线观看 | 国产一级毛片午夜福 | 天天操精品视频 | 五月激情电影 | 夜夜澡人人爽人人喊_欧美 夜夜综合网 | 亚洲综合激情 | 日黄网站 | 天天做天天爱夜夜爽毛片毛片 | 久久vs国产综合色大全 | 欧美一级欧美三级在线观看 | 网站免费黄| www四虎影院 | 2018天天干天天操 | 国产成人毛片毛片久久网 | 国产一级aaa全黄毛片 | gogo亚洲肉体艺术100 | 日本三级在线观看免费 | 日本h视频在线 | 日本免费的一级绿象 | 色色色色色网 | 久久伊人草 | 狠狠干狠狠插 | 国产女人18毛片水真多18精品 | 欧美性猛交xxxx免费看久久 | 美女三级在线 | 第四色视频 | 亚洲午夜精品久久久久 | 狼人狠狠干| 亚洲日韩图片专区第1页 | 天堂在线资源最新版 | 成年人黄色大片大全 | 69女poren18女 | 人人干人人看 | 动漫精品成人免费网站 | 亚洲免费国产 | 夜夜夜精品视频免费 |