本帖最后由 damiaa 于 2023-5-27 19:25 编辑
【极海APM32F407 Tiny Board】跑个串口例子USART_Polling
1,找到...\APM32F4xx_SDK_v1.3\Examples\USART\USART_Polling
2,修改预处理符号APM32F407_MINI为APM32F407_TINY
3,修改一下,适用TINY板子代码如下:
- void delayXms(uint32_t x)
- {
- for(uint32_t i=0;i<10000;i++){
- for(uint32_t j=0;j<x;j++){}
- }
- }
- int main(void)
- {
- BOOL state = TRUE;
- for(int i = 0; i < DATA_BUF_SIZE; i++){
- txDataBufUSART1[i] = i;
- txDataBufUSART2[i] = i;
- }
- APM_TINY_LEDInit(LED2); APM_TINY_LEDInit(LED3);
- USART_Init();
- while(1)
- {
- /** Send Data from USART1 to USART2 */
- for(int i = 0; i < DATA_BUF_SIZE; i++){
- /** Wait until end of transmission */
- while(USART_ReadStatusFlag(TINY_COM1, USART_FLAG_TXBE) == RESET);
- USART_TxData(TINY_COM1, txDataBufUSART1[i]);
- /** Wait until end of reception */
- while(USART_ReadStatusFlag(TINY_COM2, USART_FLAG_RXBNE) == RESET);
- rxDataBufUSART2[i] = USART_RxData(TINY_COM2);
- }
- /** Verify data */
- state = BufferCompare(rxDataBufUSART2, txDataBufUSART1, DATA_BUF_SIZE);
- /** Data is ok then turn off LED2 */
- if(state == TRUE){ APM_TINY_LEDOn(LED2);}
- /** Send Data from USART2 to USART1 */
- for(int i = 0; i < DATA_BUF_SIZE; i++){
- /** Wait until end of transmission */
- while(USART_ReadStatusFlag(TINY_COM2, USART_FLAG_TXBE) == RESET);
- USART_TxData(TINY_COM2, txDataBufUSART2[i]);
- /** Wait until end of reception */
- while(USART_ReadStatusFlag(TINY_COM1, USART_FLAG_RXBNE) == RESET);
- rxDataBufUSART1[i] = USART_RxData(TINY_COM1);
- }
- /** Verify data */
- state = BufferCompare(rxDataBufUSART1, txDataBufUSART2, DATA_BUF_SIZE);
- /** Data is ok then turn off LED2 */
- if(state == TRUE){ APM_TINY_LEDOn(LED3);}
- delayXms(1000); APM_TINY_LEDOff(LED2); APM_TINY_LEDOff(LED3); delayXms(1000);
- }
- }
4,具体就是这样:
5,编译后跑起来 如果led2 led3闪动。那就对了
播放器加载失败: 未检测到Flash Player,请到
安装
288022333904d7572743dcae86575570