generated from hulk/gd32e23x_template_cmake_vscode
detect MCU flash size and config usart
This commit is contained in:
32
Src/main.c
32
Src/main.c
@@ -43,6 +43,8 @@ OF SUCH DAMAGE.
|
||||
#include "ldc1612.h"
|
||||
#include "tmp112.h"
|
||||
|
||||
#define FLASH_SIZE_ADDR (*(const uint16_t *)0x1FFFF7E0)
|
||||
|
||||
/*!
|
||||
\brief main function
|
||||
\param[in] none
|
||||
@@ -51,13 +53,41 @@ OF SUCH DAMAGE.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
systick_config();
|
||||
|
||||
/* Detect MCU type and configure USART accordingly */
|
||||
mcu_detect_and_config();
|
||||
|
||||
uint16_t flash_kb = FLASH_SIZE_ADDR;
|
||||
|
||||
rs485_init();
|
||||
printf("MCU Type detected: ");
|
||||
switch (get_mcu_type()) {
|
||||
case GD32E23XF4:
|
||||
printf("GD32E23XF4 (using USART0)\r\n");
|
||||
break;
|
||||
case GD32E23XF6:
|
||||
printf("GD32E23XF6 (using USART1)\r\n");
|
||||
break;
|
||||
case GD32E23XF8:
|
||||
printf("GD32E23XF8 (using USART1)\r\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown (default to GD32E23XF8)\r\n");
|
||||
break;
|
||||
}
|
||||
|
||||
setbuf(stdout, NULL);
|
||||
systick_config();
|
||||
|
||||
rs485_init();
|
||||
|
||||
led_init();
|
||||
|
||||
printf("Flash Size: %d KB\r\n", flash_kb);
|
||||
printf("%x\r\n", flash_kb);
|
||||
|
||||
printf("Flash Size Bytes: %02X\r\n", flash_kb & 0xFF);
|
||||
|
||||
#ifdef DEBUG_VERBOSE
|
||||
char hello_world[] = {"Hello World!\r\n"};
|
||||
|
||||
|
Reference in New Issue
Block a user