我想在BootLoader里通过SPI实现对外部Flash的读写,但是初始化完SPI想要手动拉低CS,发现通过GPIO控不管写0还是写1都会导致管脚被拉低。代码都是直接移植的Gpio.c的库函数。包括
/* 使能外设GPIOA */
void
SysCtlPeripheralEnable(uint32_t ui32Peripheral)
{
//
// Check the arguments.
//
ASSERT(_SysCtlPeripheralValid(ui32Peripheral));
//
// Enable this peripheral.
//
HWREGBITW(SYSCTL_RCGCBASE + ((ui32Peripheral & 0xff00) >> 8),
ui32Peripheral & 0xff) = 1;
}
/* 设置GPIO管脚模式,包括驱动能力和output */
void
GPIOPinTypeGPIOOutput(uint32_t ui32Port, uint8_t ui8Pins)
{
//
// Check the arguments.
//
ASSERT(_GPIOBaseValid(ui32Port));
//
// Set the pad(s) for standard push-pull operation.
//
GPIOPadConfigSet(ui32Port, ui8Pins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
//
// Make the pin(s) be outputs.
//
GPIODirModeSet(ui32Port, ui8Pins, GPIO_DIR_MODE_OUT);
}
控制GPIO直接用的底层函数
/* 拉低 */
HWREG(GPIO_PORTA_BASE + (GPIO_O_DATA + (SSI_CS << 2))) = 0;
/* 拉高 */
HWREG(GPIO_PORTA_BASE + (GPIO_O_DATA + (SSI_CS << 2))) = 1;
但现在的情况是不管写0还是写1都会导致被拉低,且无法拉高
想问一下我的用法是不是有问题呢?或者最好是官方提供的BOOT代码中能直接控GPIO,或者SPI的SDK里有直接进行片选的方式?