int main(void)
{
uint8_t i;
GPIO_Config_T GPIO_ConfigStruct;
USART_Config_T USART_ConfigStruct;
RCM_EnableAPB2PeriphClock((RCM_APB2_PERIPH_T)(RCM_APB2_PERIPH_AFIO|RCM_APB2_PERIPH_GPIOB | RCM_APB2_PERIPH_USART1));
GPIO_ConfigPinRemap(GPIO_REMAP_USART1);
GPIO_ConfigStruct.mode = GPIO_MODE_AF_PP;
GPIO_ConfigStruct.pin = GPIO_PIN_6;
GPIO_ConfigStruct.speed = GPIO_SPEED_50MHz;
GPIO_Config(GPIOB, &GPIO_ConfigStruct);
GPIO_ConfigStruct.mode = GPIO_MODE_IN_FLOATING;
GPIO_ConfigStruct.pin = GPIO_PIN_7;
GPIO_Config(GPIOB, &GPIO_ConfigStruct);
USART_ConfigStruct.baudRate = 9600;
USART_ConfigStruct.hardwareFlow = USART_HARDWARE_FLOW_NONE;
USART_ConfigStruct.mode = USART_MODE_TX_RX;
USART_ConfigStruct.parity = USART_PARITY_NONE;
USART_ConfigStruct.stopBits = USART_STOP_BIT_1;
USART_ConfigStruct.wordLength = USART_WORD_LEN_8B;
USART_Config(USART1, &USART_ConfigStruct);
USART_Enable(USART1);
SysTick_Config(SystemCoreClock / 1000);
while(1)
{
Delay();
for(i = 0; i < sizeof(txBuf); i++)
{
while(USART_ReadStatusFlag(USART1, USART_FLAG_TXBE) == RESET);
USART_TxData(USART1, txBuf[i]);
}
}
}
apm32 串口重映射打印消息
最新推荐文章于 2024-10-31 09:56:23 发布