detect MCU flash size and config usart

This commit is contained in:
2025-08-20 21:02:52 +08:00
parent b6485c5c39
commit c93704383a
8 changed files with 164 additions and 16 deletions

View File

@@ -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"};