【极海APM32F407 Tiny Board】2、开发环境搭建&串口printf打印
[复制链接]
开发板支持KEIL MDK开发环境,从官网下载DFP安装包即可:
安装好后,就可以打开keil工程进行仿真调试了:
但是板载cmsis-dap调试器串口无法使用,只好使用外置的调试器了,在GPIO例子基础上增加串口打印功能:
/*!
* [url=home.php?mod=space&uid=1307177]@File[/url] main.c
*
* [url=home.php?mod=space&uid=159083]@brief[/url] Main program body
*
* [url=home.php?mod=space&uid=252314]@version[/url] V1.0.2
*
* [url=home.php?mod=space&uid=311857]@date[/url] 2023-03-01
*
* [url=home.php?mod=space&uid=1020061]@attention[/url] *
* Copyright (C) 2021-2023 Geehy Semiconductor
*
* You may not use this file except in compliance with the
* GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
*
* The program is only for reference, which is distributed in the hope
* that it will be useful and instructional for customers to develop
* their software. Unless required by applicable law or agreed to in
* writing, the program is distributed on an "AS IS" BASIS, WITHOUT
* ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
* See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
* and limitations under the License.
*/
/* Includes */
#include "main.h"
#include "Board.h"
#include "stdio.h"
#include "apm32f4xx_gpio.h"
#include "apm32f4xx_misc.h"
#include "apm32f4xx_usart.h"
#define DEBUG_USART USART1
int fputc(int ch, FILE* f)
{
/* send a byte of data to the serial port */
USART_TxData(DEBUG_USART, (uint8_t)ch);
/* wait for the data to be send */
while (USART_ReadStatusFlag(DEBUG_USART, USART_FLAG_TXBE) == RESET);
return (ch);
}
/** @addtogroup Examples
@{
*/
/** @addtogroup GPIO_Toggle
@{
*/
/** @defgroup GPIO_Toggle_Functions Functions
@{
*/
/* Delay */
void Delay(uint32_t count);
/*!
* @brief Main program
*
* @param None
*
* @retval None
*/
int main(void)
{
USART_Config_T usartConfigStruct;
/* USART configuration */
USART_ConfigStructInit(&usartConfigStruct);
usartConfigStruct.baudRate = 115200;
usartConfigStruct.mode = USART_MODE_TX_RX;
usartConfigStruct.parity = USART_PARITY_NONE;
usartConfigStruct.stopBits = USART_STOP_BIT_1;
usartConfigStruct.wordLength = USART_WORD_LEN_8B;
usartConfigStruct.hardwareFlow = USART_HARDWARE_FLOW_NONE;
/* COM1 init*/
APM_MINI_COMInit(COM1, &usartConfigStruct);
APM_MINI_LEDInit(LED2);
APM_MINI_LEDInit(LED3);
while (1)
{
printf("APM32F407 Test\r\n");
Delay(0x2FFFFF);
APM_MINI_LEDToggle(LED2);
APM_MINI_LEDToggle(LED3);
}
}
/*!
* @brief Delay
*
* @param count: delay count
*
* @retval None
*/
void Delay(uint32_t count)
{
volatile uint32_t delay = count;
while(delay--);
}
/**@} end of group GPIO_Toggle_Functions */
/**@} end of group GPIO_Toggle */
/**@} end of group Examples */
|