QCC3040---PIO的配置方法
0、路径
\os\qcc514x_qcc304x\hydra_os\src\fw\src\customer\core\trap_api\trap_api_core_pio.c
os\qcc514x_qcc304x\hydra_os\src\fw\src\gen\customer\core\trap_api\pio.h
1、相关PIO API
1.1、获取PIO的bank
1.1.1 自定义
#define PIO2BANK(pio) ((uint16)((pio) / 32))
1.1.2 SDK提供
#define PioCommonPioBank(_pio) ((_pio) / PIOS_PER_BANK)
1.2、获取PIO的mask(bank中对应的bit)
1.2.1 自定义
#define PIO2MASK(pio) (1UL << ((pio) % 32))
1.2.2 SDK提供
#define PioCommonPioMask(_pio) (1UL << ((_pio) % PIOS_PER_BANK))
1.3、绑定bank和对应的mask
/**
* \brief Maps PIOs as software or hardware controlled.
* Before using a PIO as a software controlled digital IO a call to this
* function is required. Not mapping the PIO may cause other functions in the
* PIO trap API to return errors and not produce the required behaviour.
* To put a PIO under HW control the app needs to call this function first and
* then PioSetFunction to select the HW functionality needed.
* Please note that there is no default state, all PIOs should be considered
* unmapped and unusable until they are configured by a call to this function.
* \param bank PIO bank number.
* \param mask Each bit in the mask corresponds to a PIO line. Bits set to 1 in this mask will
* be modified. Bits set to 0 in this mask will not be modified.
* \param bits Each bit corresponds to a PIO line. A bit set to 1 will cause a PIO to be
* behave as a software controlled pin. A bit set to 0 will result in the pio
* being marked as controlled by a hardware peripheral.
* \return A 32 bit mask. If any bit in this mask is high then that PIO could not be
* mapped or unmapped; note that no action will have been taken on any PIOs.
*
* \ingroup trapset_core
*/
function prototype:
uint32 PioSetMapPins32Bank(uint16 bank, uint32 mask, uint32 bits);
传入的实际参数按照顺序为:bank, mask, mask
1.4、设置输入输出模式
/**
* \brief Set PIOs as inputs or outputs.
*
* Note that all PIOs must be mapped in before they can be used.
* See the PioSetMapPins32Bank() documentation for information on valid PIO
* directions
* and PIO mapping.
* \param bank PIO bank number.
* \param mask Each bit in the mask corresponds to a PIO line. Bits set to 1 in this mask will
* be modified. Bits set to 0 in this mask will not be modified.
* \param dir Each bit in the "dir" value corresponds to a PIO line. Bits set to 1 in this
* value will result in that PIO line being configured as an output. Bits set to
* 0 in this value will result in that PIO line being configured as an input.
* \return A 32 bit mask. If any bit in this mask is high then that PIO could not be set
* to the direction specified; note that no action will have been taken on any
* PIOs.
*
* \ingroup trapset_core
*/
function prototype:
uint32 PioSetDir32Bank(uint16 bank, uint32 mask, uint32 dir);
参数dir的值决定了PIO的方向:
- mask:output(输出)
- 0:input(输入)
1.5、设置管脚电平
/**
* \brief Modifies the contents of the PIO data output register. PIO pins must be set to
* outputs via PioSetDir32Bank() before they can be driven high or low through
* this trap. This trap also sets pull direction for PIOs used as inputs.
*
* Note that all PIOs must be mapped in before they can be used.
* See the PioSetMapPins32Bank() documentation for information on valid PIO
* directions
* and PIO mapping.
* BlueCore has internal resistors which can be configured to either pull-up or
* pull-down the pins used for input. This is controlled by the value
* written to the output register using PioSet32Bank().
* The resistors pull-down if the value is zero, and pull-up otherwise, so the
* following fragment sets pins 1 and 2 to inputs with pin 1 configured to
* pull-up and pin 2 configured to pull-down.
* \code
* PioSet32Bank(0, 2|4, 2);
* PioSetDir32Bank(0, 2|4, 0);
* \endcode
* \param bank PIO bank number.
* \param mask Each bit in the mask corresponds to a PIO line. Bits set to 1 in this mask will
* be modified. Bits set to 0 in this mask will not be modified.
* \param bits Each bit in the "bits" value corresponds to a PIO line. Bits set to 1 in this
* value will result in that PIO line being driven high. Bits set to 0 in this
* value will result in that PIO line being driven low.
* \return A 32 bit mask. If any bit in this mask is high then that PIO could not be
* driven to the level specified; note that no action will have been taken on any
* PIOs.
*
* \ingroup trapset_core
*/
function prototype:
uint32 PioSet32Bank(uint16 bank, uint32 mask, uint32 bits);
参数bits的值决定了PIO的电平:
- mask:high(高电平)
- 0:low(低电平)
NOTE:当对应的管脚在调用该接口之前,已经设置为输入模式时候,那么此时设置的高低电平表示pull down or pull up,
0:pull down(下拉)
1:pull up(上拉)
1.6 获取电平状态
/**
* \brief Returns the contents of one of the PIO data input registers. For PIOs set as
* outputs, this function will return the value last written using
* PioSet32Bank().
* \param bank PIO bank number.
*
* \ingroup trapset_core
*/
function prototype:
uint32 PioGet32Bank(uint16 bank);
bank:表示读取的bank,返回的是整个bank pio的状态,需要用对应pio的mask来获取对应pio的状态。
1.7 设置管脚功能
/**
* \brief Sets a supported function for particular pio pin
* if a pin can be mapped as LED, UART, BITSERIAL, ANALOGUE etc, then this
* function can be used to set the pin for one of the supported functions.
* Consult the device's data sheet to understand what functions are supported
* for each PIO pins.
* A pin can support only few functions. Trying to set a function which is NOT
* supported by the pin will return FALSE without affecting/modifying the
* existing pin function.
* Before this trap can be used, it is necessary to use PioSetMapPins32Bank to
* put the PIO in HW mode.
* For functions corresponding to other susbystems the OTHER function ID must be
* used. This reverts the PIOs to the initial unmapped state. Any further use by
* the app needs remapping.
* PioSetFunction() Usage Example:
* if PIO[20] can be mapped to UART/BITSERIAL/LED/PIO and currently PIO[20] is
* mapped as PIO, then App should call the PioSetMapPins32Bank() to unmap it
* from PIO and then call PioSetFunction() to map to (UART/BITSERIAL/LED/PIO)
* function.
* Unmap PIO[20] so that it can be mapped to a function
* PioSetMapPins32Bank(0, 1<<20, 0<<20);
* This will map PIO[20] line as UART_RX
* PioSetFunction(20, UART_RX);*
*
* To map back the PIO[20] as a PIO, PioSetMapPins32Bank() should be used.
* PioSetMapPins32Bank(0, 1<<20, 1<<20);
* \param pin Pin that requires a function change; the pin value ranges from 0 to 95.
* \param function Supported function that needs to be set for the specified pin. Refer
* \#pin_function_id
* \return TRUE if successful, else FALSE.
*
* \ingroup trapset_core
*/
bool PioSetFunction(uint16 pin, pin_function_id function);
QCC3040---PIO的配置方法相关推荐
- Linux下环境变量配置方法梳理(.bash_profile和.bashrc的区别)
博客园 首页 新随笔 联系 管理 订阅 <div class="blogStats"><!--done--> 随笔- 556 文章- 38 评论- 77 ...
- TVM darknet yolov3算子优化与量化代码的配置方法
TVM darknet yolov3算子优化与量化代码的配置方法 使用以下接口函数 tvm.relay.optimize quantize.quantize 实际代码: convert nnv ...
- Lumen框架多数据库连接配置方法
Lumen作为一款API导向很浓的框架,配置极简化,默认只支持一路DB配置 然而随着业务复杂度的提高,引入多个数据库连接似乎无法避免,下面介绍一下LUMEN连接多个数据库的配置方法: 修改.env文件 ...
- mysql数据库解压安装教程_MySQL数据库之windows 10下解压版MySql安装配置方法教程...
本文主要向大家介绍了MySQL数据库之windows 10下解压版MySql安装配置方法教程 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助. windows 10 下安装解压版的 ...
- python3.6.2怎样安装,python 3.6.2 安装配置方法图文教程
python 3.6.2 安装配置方法图文教程 Windows下Python(pip)环境搭建(3.6)图解,供大家参考,具体内容如下 1.下载最新的Python安装:3.6.2 2.安装时不要选择默 ...
- .net下的富文本编辑器FCKeditor的配置方法(图)原创
.net下的富文本编辑器FCKeditor的配置方法(图)原创 FCKeditor是一款开源的富文本编辑器,几乎支持所有流行的Web开发语言,版本稳定,用户多,可配置性好. 以前做Java和php的时 ...
- php symfony 安装,Symfony的安装和配置方法
这篇文章主要介绍了Symfony的安装和配置方法,分析了使用Composer安装Symfony的具体步骤与相关技巧,需要的朋友可以参考下 本文实例讲述了Symfony的安装和配置方法.分享给大家供大家 ...
- Win2008远程多用户登陆的配置方法
核心提示:在使用Windows 2008远程登录功能时,如果需要进行多用户登录,可以采用以下配置方法 在使用Windows 2008远程登录功能时,如果需要进行多用户登录,可以采用以下配置方法: 首先 ...
- 微指令地址的形成方式_交换那些事儿 | 基础维护篇 IPv6地址分类及配置方法
IPv6地址分类及配置方法 H3C交换机基础维护篇 何为IPv6 随着网络的不断扩大和发展,IPv4的地址空间已不能满足需求,因此IPv6协议的应用越来越广泛.那么IPv6地址是如何规范和配置的呢,今 ...
- Ubuntu下QT控制台程序无法运行的解决方案以及XTerm的配置方法
Ubuntu下QT控制台程序无法运行的解决方案以及XTerm的配置方法 最近由于老师要求要在Ubuntu下QT上进程多线程服务器的开发,虽然只是单纯的调用qt的network模块,但是为了避免麻烦,我 ...
最新文章
- 云计算赋能人工智能,未来的红利在哪?
- 什么是API,SDK?它们之间有什么关系?
- 博客搭建攻略(二):工具推荐
- Linux内核链表实现剖析
- php session 跨子域和跨服务器解决方式
- android 实现磨砂效果_Android 5.0 下毛玻璃(磨砂)效果如何实现?
- C#与halcon联合开发——内存溢出
- 《从零开始学ASP.NET CORE MVC》:ASP.NET Core 中的 Main方法(5)
- centos6 postgresql安装
- 有趣的面试题解 (2 )
- ANR 问题一般解决思路
- fopen 參数具体解释
- kubenerte启动_老司机和你深聊Kubenertes 资源分配之 Request 和 Limit 解析
- 汉字转拼音开源工具包Jpinyin介绍
- 做个坚强的逆行者,献给终日奋斗的你我——《当幸福来敲门》
- 第一章节:期货及衍生品概述
- R/ggplot2保存图片中文字体至PDF——showtext包一文清除所有障碍
- Unity - Timeline 之About Timeline(关于Timeline)
- 2015中南大学夏令营机试(DFS求最短路径、子序列、字符串、贪心、数学找规律)
- 【数据库】(三)-- mysql 数据库操作应用