TI中文支持网
TI专业的中文技术问题搜集分享网站

CC2640R2F SPI IO 配置问题

Demo 程序 spimaster_CC2640R2_LAUNCHXL_tirtos_ccs

SPI配置之前有对管脚的配置 

CC2640R2_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out – slave in */
CC2640R2_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in – slave out */
CC2640R2_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */

为何配置MOSI 以及CLK脚为INPUT  

Alvin Chen:

这是预设值,在SPI初始化中会对引脚重新设置。
static bool ***(SPI_Handle handle) {****object;*** const*hwAttrs;PIN_ConfigspiPinTable[5];uint32_t i = 0;
/* Get the pointer to the object and hwAttrs */object = handle->object;hwAttrs = handle->hwAttrs;
/* Configure IOs *//* Build local list of pins, allocate through PIN driver and map HW ports */if (object->mode == SPI_SLAVE) {/* Configure IOs for slave mode */spiPinTable[i++] = hwAttrs->mosiPin | PIN_INPUT_EN;spiPinTable[i++] = hwAttrs->misoPin | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_INPUT_DIS | PIN_DRVSTR_MED;spiPinTable[i++] = hwAttrs->clkPin| PIN_INPUT_EN;spiPinTable[i++] = object->csnPin| PIN_INPUT_EN | PIN_PULLUP;

user1143055:

回复 Alvin Chen:

Alvin Chen

在这个工程spimaster_CC2640R2_LAUNCHXL_tirtos_ccs 中没有找到你提到的段落,能否将你截取的工程发一下,谢谢!

Alvin Chen:

回复 user1143055:

这是驱动里面的源程序在
C:\ti\simplelink_cc2640r2_sdk_3_20_00_21\source\ti\drivers\spi

user1143055:

回复 Alvin Chen:

AlvinDemo 工程中引用这个文件也没有涉及到SPI 管脚的驱动呀

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>

#include <ti/drivers/dpl/HwiP.h>
#include <ti/drivers/SPI.h>

extern const SPI_Config SPI_config[];
extern const uint_least8_t SPI_count;

/* Default SPI parameters structure */
const SPI_Params SPI_defaultParams = {SPI_MODE_BLOCKING,/* transferMode */SPI_WAIT_FOREVER,/* transferTimeout */NULL,/* transferCallbackFxn */SPI_MASTER,/* mode */1000000,/* bitRate */8,/* dataSize */SPI_POL0_PHA0,/* frameFormat */NULL/* custom */
};

static bool isInitialized = false;

/**======== SPI_close ========*/
void SPI_close(SPI_Handle handle)
{handle->fxnTablePtr->closeFxn(handle);
}

/**======== SPI_control ========*/
int_fast16_t SPI_control(SPI_Handle handle, uint_fast16_t cmd, void *controlArg)
{return (handle->fxnTablePtr->controlFxn(handle, cmd, controlArg));
}

/**======== SPI_init ========*/
void SPI_init(void)
{uint_least8_t i;uint_fast8_t key;
key = HwiP_disable();
if (!isInitialized) {isInitialized = (bool) true;
/* Call each driver's init function */for (i = 0; i < SPI_count; i++) {SPI_config[i].fxnTablePtr->initFxn((SPI_Handle)&(SPI_config[i]));}}
HwiP_restore(key);
}

/**======== SPI_open ========*/
SPI_Handle SPI_open(uint_least8_t index, SPI_Params *params)
{SPI_Handle handle = NULL;
if (isInitialized && (index < SPI_count)) {/* If params are NULL use defaults */if (params == NULL) {params = (SPI_Params *) &SPI_defaultParams;}
/* Get handle for this driver instance */handle = (SPI_Handle)&(SPI_config[index]);handle = handle->fxnTablePtr->openFxn(handle, params);}
return (handle);
}

/**======== SPI_Params_init ========*/
void SPI_Params_init(SPI_Params *params)
{*params = SPI_defaultParams;
}

/**======== SPI_transfer ========*/
bool SPI_transfer(SPI_Handle handle, SPI_Transaction *transaction)
{return (handle->fxnTablePtr->transferFxn(handle, transaction));
}

/**======== SPI_transferCancel ========*/
void SPI_transferCancel(SPI_Handle handle)
{handle->fxnTablePtr->transferCancelFxn(handle);
}

Alvin Chen:

回复 user1143055:

const *** ***[CC2640R2_LAUNCHXL_SPICOUNT] = {{.baseAddr= SSI0_BASE,.intNum= INT_SSI0_COMB,.intPriority= ~0,.swiPriority= 0,.powerMngrId= PowerCC26XX_PERIPH_SSI0,.defaultTxBufValue= 0xFF,.rxChannelBitMask= 1<<UDMA_CHAN_SSI0_RX,.txChannelBitMask= 1<<UDMA_CHAN_SSI0_TX,.mosiPin= CC2640R2_LAUNCHXL_SPI0_MOSI,.misoPin= CC2640R2_LAUNCHXL_SPI0_MISO,.clkPin= CC2640R2_LAUNCHXL_SPI0_CLK,.csnPin= CC2640R2_LAUNCHXL_SPI0_CSN,.minDmaTransferSize = 10

在SPI config 里面就已经设置了

user1143055:

回复 Alvin Chen:

Alvin 这里边只是指定了那个管脚,但没有配置输入输出 ,等配置呀?

Alvin Chen:

回复 user1143055:

上面不是提到调用了driver 里面的程序配置的

user1143055:

回复 Alvin Chen:

不好意思,是我没有表达清楚就是
static bool ***(SPI_Handle handle) {
*** *object;
*** const *hwAttrs;
PIN_Config spiPinTable[5];
uint32_t i = 0;

/* Get the pointer to the object and hwAttrs */
object = handle->object;
hwAttrs = handle->hwAttrs;

/* Configure IOs */
/* Build local list of pins, allocate through PIN driver and map HW ports */
if (object->mode == SPI_SLAVE) {
/* Configure IOs for slave mode */
spiPinTable[i++] = hwAttrs->mosiPin | PIN_INPUT_EN;
spiPinTable[i++] = hwAttrs->misoPin | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_INPUT_DIS | PIN_DRVSTR_MED;
spiPinTable[i++] = hwAttrs->clkPin | PIN_INPUT_EN;
spiPinTable[i++] = object->csnPin | PIN_INPUT_EN | PIN_PULLUP;

这段在demo 程序中没有找到,在SPI.C 中也没有看到这段

user1143055:

回复 Alvin Chen:

感谢!

赞(0)
未经允许不得转载:TI中文支持网 » CC2640R2F SPI IO 配置问题
分享到: 更多 (0)