关于CSR8670如何使用PioSetMapPins32()函数配置额外的IO口

来源:互联网 发布:货品查询软件 编辑:程序博客网 时间:2024/04/28 04:43

当使用csr8670发现PIO0-15都被占用的时候,这时可通过PioSetMapPins32()这个函数来配置未用到过的引脚(比如,UART_RX,UART_TX),这里以UART_RX为例:

通过PioSetMapPins32()接口函数的描述可知UART_RX通过映射为PIO13;此时函数的写法如下:

#define  UART_RX    (13 )        //这里我们知道RX对于的映射脚为13,不可以将其配置为其他值;

PioSetMapPins32(1<<UART_RX  , 1<<UART_RX); //调用映射函数

PioSetDir32(1<<UART_RX  ,1<<UART_RX  )  //配置作为输出

配置为输入的函数:

PioSetDir32(1<<UART_RX  ,0 ) ;


注意:如果将UART_RX配置为PIO13时候,PIO13将于UART_RX的特性一致;比如RX作为输入,PIO13也作为输入,反之亦然;

以下为ADK4.1平台下,PioSetMapPins32()函数的介绍:


/*!
  @brief Cause the usual function of chip pins to be suppressed, and instead 
  make them behave as PIOs.


  @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 
  (non-PIO) chip pin to be behave as the corresponding PIO. A bit set to 0 
  will result in any mapped pin being returned to its original function.
  
  @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.


  For BC5-MM the PIO lines map to other pins as follows:


  (PIO 0..15) have no mapping. They are always PIO 0..15. They can be 
  configured as inputs or outputs.


  (PIO 16) maps to PCM_DATA. This can be configured as an input or an output.


  (PIO 17) maps to PCM_SYNC. This can be configured as an input or an output.


  (PIO 18) maps to UART_DATA_OUT. This can be configured as an input or an 
  output.


  (PIO 19) maps to PCM_CLK_OUT. Set this to output to the PCM_CLK pin. This 
  line is output only. Note that the PCM_CLK pin direction shadows PCM_SYNC 
  direction and ignores directions set via PioSetDir32().


  (PIO 20) maps to AIO0. Mapping this PIO will overwrite the value set in 
  PSKEY_AMUX_AIO0. Unmapping this PIO will restore the value set in 
  PSKEY_AMUX_AIO0. Note that on BC5-MM configuring AIO lines as PIO lines is 
  not recommended due to the low voltage level.


  (PIO 21) maps to AIO1. Mapping this PIO will overwrite the value set in 
  PSKEY_AMUX_AIO1. Unmapping this PIO will restore the value set in 
  PSKEY_AMUX_AIO1. Note that on BC5-MM configuring AIO lines as PIO lines is 
  not recommended due to their low voltage level.


  PIO lines above 21 map to nothing and cannot be mapped or written. 


  For CSR8670 the PIO lines map to other pins as follows:


  (PIO 0..12) have no mapping. They are always PIO 0..12.
  They can be configured as inputs or outputs.
  The smaller packages such as Chip Scale Package (CSP) does not have PIO8..12.


  (PIO 13..15) may be mapped if required. The exact signal routing is dependent
  on which package is being used. On smaller packages, such as CSP, you must
  map PIO13-15 if you want PIO instead of UART UART_RX, UART_TX and UART_CTS.
  On the BGA package PIO13..15 have their own pins, but if mapped, will be 
  connected to the UART_RX, UART_TX and UART_CTS pins as well. Whether mapped
  or not, these PIO pins may be configured as inputs or outputs. For each pin,
  if mapped and set as output, both (UART and PIO) pins are driven. If mapped
  and set as input, the UART pin is connected and the PIO pin is n/c.


  (PIO 16) maps to the UART_RTS pin. This can be configured as an input or an
  output.


  (PIO 17) maps to the PCM_IN pin. This can be configured as an input or an
  output.


  (PIO 18) maps to the PCM_OUT pin. This can be configured as an input or an 
  output.


  (PIO 19) maps to the PCM_SYNC pin. This can be configured as an input or an 
  output.


  (PIO 20) maps to the PCM_CLK pin. This can be configured as an input or an 
  output.


  (PIO 21) maps to the SQIF Flash Clock pin. This can be configured as an input
   or an output.


  (PIO 22) maps to the SQIF RAM Clock pin. This can be configured as an input
  or an output.  
  
  (PIO 23) maps to the SQIF Flash CS pin. This can be configured as an input
  or an output.  
  
  (PIO 24) maps to the SQIF RAM CS pin. This can be configured as an input or
  an output.


  (PIO 25) maps to the SQIF DB0 pin. This can be configured as an input or an 
  output.


  (PIO 26) maps to the SQIF DB1 pin. This can be configured as an input or an 
  output.
  
  (PIO 27) maps to the SQIF DB2 pin. This can be configured as an input or an 
  output.
  
  (PIO 28) maps to the SQIF DB3 pin. This can be configured as an input or an 
  output.


  PIO lines above 28 map to nothing and cannot be mapped or written.
*/
uint32 PioSetMapPins32(uint32 mask, uint32 bits);


1 0