Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
BSP
老的bsp怎么移植到新的内核上
发布于 2021-10-21 22:30:44 浏览:898
订阅该版
一直用的1.2.1的内核,7 8年了吧,现在想升级到3.1,程序也不想做大修改 想用一下新的功能,有没有简单一点的办法
查看更多
4
个回答
默认排序
按发布时间排序
ralfak
2021-10-22
这家伙很懒,什么也没写!
自己动手,丰衣足食 步骤如下 - git 取出3.1.5的版本 - 参考gd32f450的bsp - 目标芯片是stm32f407,3.5的外设库,用的串口1,PA9 PA10 - 复制gd32的bsp重新改个名字,不要复制Libraries - 把老工程的Libraries 复制过来 - keil 打开 template.uvproj - 把芯片换一下 - 然后修改下面几个文件 rtconfig.h 把网络文件系统之类的全部关掉 ```c #ifndef RT_CONFIG_H__ #define RT_CONFIG_H__ /* Automatically generated file; DO NOT EDIT. */ /* RT-Thread Configuration */ /* RT-Thread Kernel */ #define RT_NAME_MAX 8 #define RT_ALIGN_SIZE 4 #define RT_THREAD_PRIORITY_32 #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 100 #define RT_USING_OVERFLOW_CHECK #define RT_USING_HOOK #define RT_USING_IDLE_HOOK #define RT_IDLE_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG #define RT_DEBUG_COLOR /* Inter-Thread communication */ #define RT_USING_SEMAPHORE #define RT_USING_MUTEX #define RT_USING_EVENT #define RT_USING_MAILBOX #define RT_USING_MESSAGEQUEUE /* Memory Management */ #define RT_USING_MEMPOOL #define RT_USING_SMALL_MEM #define RT_USING_HEAP /* Kernel Device Object */ #define RT_USING_DEVICE #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "uart1" #define RT_VER_NUM 0x30105 /* RT-Thread Components */ #define RT_USING_COMPONENTS_INIT #define RT_USING_USER_MAIN #define RT_MAIN_THREAD_STACK_SIZE 2048 #define RT_MAIN_THREAD_PRIORITY 10 /* C++ features */ /* Command shell */ #define RT_USING_FINSH #define FINSH_THREAD_NAME "tshell" #define FINSH_USING_HISTORY #define FINSH_HISTORY_LINES 5 #define FINSH_USING_SYMTAB #define FINSH_USING_DESCRIPTION #define FINSH_THREAD_PRIORITY 20 #define FINSH_THREAD_STACK_SIZE 4096 #define FINSH_CMD_SIZE 80 #define FINSH_USING_MSH #define FINSH_USING_MSH_DEFAULT #define FINSH_ARG_MAX 10 /* Device virtual file system */ //#define RT_USING_DFS #define DFS_USING_WORKDIR #define DFS_FILESYSTEMS_MAX 4 #define DFS_FILESYSTEM_TYPES_MAX 4 #define DFS_FD_MAX 16 #define RT_USING_DFS_ELMFAT /* elm-chan's FatFs, Generic FAT Filesystem Module */ #define RT_DFS_ELM_CODE_PAGE 437 #define RT_DFS_ELM_WORD_ACCESS #define RT_DFS_ELM_USE_LFN_0 #define RT_DFS_ELM_USE_LFN 0 #define RT_DFS_ELM_MAX_LFN 255 #define RT_DFS_ELM_DRIVES 2 #define RT_DFS_ELM_MAX_SECTOR_SIZE 512 #define RT_DFS_ELM_REENTRANT #define RT_USING_DFS_DEVFS /* Device Drivers */ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SYSTEM_WORKQUEUE #define RT_SYSTEM_WORKQUEUE_STACKSIZE 2048 #define RT_SYSTEM_WORKQUEUE_PRIORITY 23 #define RT_USING_SERIAL //#define RT_SERIAL_USING_DMA #define RT_SERIAL_RB_BUFSZ 64 #define RT_USING_PIN /* Using Hardware Crypto drivers */ /* Using WiFi */ /* Using USB */ /* POSIX layer and C standard library */ #define RT_USING_LIBC //#define RT_USING_POSIX /* Network */ /* Socket abstraction layer */ //#define RT_USING_SAL /* protocol stack implement */ //#define SAL_USING_LWIP #define SAL_USING_POSIX /* Network interface device */ //#define RT_USING_NETDEV #define NETDEV_USING_IFCONFIG #define NETDEV_USING_PING #define NETDEV_USING_NETSTAT #define NETDEV_USING_AUTO_DEFAULT #define NETDEV_IPV4 1 #define NETDEV_IPV6 0 /* light weight TCP/IP stack */ //#define RT_USING_LWIP #define RT_USING_LWIP202 #define RT_LWIP_IGMP #define RT_LWIP_ICMP #define RT_LWIP_DNS #define RT_LWIP_DHCP #define IP_SOF_BROADCAST 1 #define IP_SOF_BROADCAST_RECV 1 /* Static IPv4 Address */ #define RT_LWIP_IPADDR "192.168.1.30" #define RT_LWIP_GWADDR "192.168.1.1" #define RT_LWIP_MSKADDR "255.255.255.0" #define RT_LWIP_UDP #define RT_LWIP_TCP #define RT_LWIP_RAW #define RT_MEMP_NUM_NETCONN 8 #define RT_LWIP_PBUF_NUM 16 #define RT_LWIP_RAW_PCB_NUM 4 #define RT_LWIP_UDP_PCB_NUM 4 #define RT_LWIP_TCP_PCB_NUM 4 #define RT_LWIP_TCP_SEG_NUM 40 #define RT_LWIP_TCP_SND_BUF 8196 #define RT_LWIP_TCP_WND 8196 #define RT_LWIP_TCPTHREAD_PRIORITY 10 #define RT_LWIP_TCPTHREAD_MBOX_SIZE 8 #define RT_LWIP_TCPTHREAD_STACKSIZE 1024 #define RT_LWIP_ETHTHREAD_PRIORITY 12 #define RT_LWIP_ETHTHREAD_STACKSIZE 1024 #define RT_LWIP_ETHTHREAD_MBOX_SIZE 8 #define LWIP_NETIF_STATUS_CALLBACK 1 #define LWIP_NETIF_LINK_CALLBACK 1 #define SO_REUSE 1 #define LWIP_SO_RCVTIMEO 1 #define LWIP_SO_SNDTIMEO 1 #define LWIP_SO_RCVBUF 1 #define LWIP_NETIF_LOOPBACK 0 #define RT_LWIP_USING_PING /* Modbus master and slave stack */ /* AT commands */ /* VBUS(Virtual Software BUS) */ /* Utilities */ /* RT-Thread online packages */ /* IoT - internet of things */ /* Wi-Fi */ /* Marvell WiFi */ /* Wiced WiFi */ /* IoT Cloud */ /* security packages */ /* language packages */ /* multimedia packages */ /* tools packages */ /* system packages */ /* peripheral libraries and drivers */ /* miscellaneous packages */ /* samples: kernel and components samples */ //#define BSP_USING_SDRAM #define BSP_USING_UART1 #endif ``` board.c ```c /* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2009-01-05 Bernard first implementation */ #include
#include
#include
#include
#include
#include
/******************************************************************************* * Function Name : assert_failed * Description : Reports the name of the source file and the source line number * where the assert error has occurred. * Input : - file: pointer to the source file name * - line: assert error line source number * Output : None * Return x,: None *******************************************************************************/ void assert_failed(uint8_t* file, uint32_t line) { rt_kprintf("\n\r Wrong parameter value detected on\r\n"); rt_kprintf(" file %s\r\n", file); rt_kprintf(" line %d\r\n", line); while (1) ; } /** * @brief This function is executed in case of error occurrence. * @param None * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler */ /* User can add his own implementation to report the HAL error return state */ while (1) { } /* USER CODE END Error_Handler */ } /** System Clock Configuration */ void SystemClock_Config(void) { SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND); NVIC_SetPriority(SysTick_IRQn, 0); } /** * This is the timer interrupt service routine. * */ void SysTick_Handler(void) { /* enter interrupt */ rt_interrupt_enter(); rt_tick_increase(); /* leave interrupt */ rt_interrupt_leave(); } /** * This function will initial GD32 board. */ void rt_hw_board_init() { #if 0 /* NVIC Configuration */ #define NVIC_VTOR_MASK 0x3FFFFF80 #ifdef VECT_TAB_RAM /* Set the Vector Table base location at 0x10000000 */ SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK); #else /* VECT_TAB_FLASH */ /* Set the Vector Table base location at 0x08000000 */ SCB->VTOR = (0x08000000 & NVIC_VTOR_MASK); #endif #endif SystemClock_Config(); #ifdef RT_USING_COMPONENTS_INIT rt_components_board_init(); #endif #ifdef RT_USING_CONSOLE rt_console_set_device(RT_CONSOLE_DEVICE_NAME); #endif #ifdef BSP_USING_SDRAM rt_system_heap_init((void *)EXT_SDRAM_BEGIN, (void *)EXT_SDRAM_END); #else rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END); #endif } /*@}*/ ``` drv_usart.c ```c /* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2009-01-05 Bernard the first version * 2010-03-29 Bernard remove interrupt Tx and DMA Rx mode * 2012-02-08 aozima update for F4. * 2012-07-28 aozima update for ART board. * 2016-05-28 armink add DMA Rx mode */ #include
#include
#include
#ifdef RT_USING_SERIAL #if !defined(BSP_USING_UART1) && !defined(BSP_USING_UART2) && \ !defined(BSP_USING_UART3) #error "Please define at least one UARTx" #endif #include
/* GD32 uart driver */ // Todo: compress uart info struct stm32_uart { USART_TypeDef *uart_periph; //Todo: 3bits IRQn_Type irqn; //Todo: 7bits uint32_t per_clk; //Todo: 5bits uint32_t tx_gpio_clk; //Todo: 5bits uint32_t rx_gpio_clk; //Todo: 5bits GPIO_TypeDef *tx_port; //Todo: 4bits uint16_t tx_af; //Todo: 4bits uint16_t tx_pin; //Todo: 4bits uint16_t tx_pin_source; GPIO_TypeDef *rx_port; //Todo: 4bits uint16_t rx_af; //Todo: 4bits uint16_t rx_pin; //Todo: 4bits uint16_t rx_pin_source; struct rt_serial_device * serial; char *device_name; }; static void uart_isr(struct rt_serial_device *serial); #if defined(BSP_USING_UART1) #define UART1_GPIO_TX GPIO_Pin_9 #define UART1_TX_PIN_SOURCE GPIO_PinSource9 #define UART1_GPIO_RX GPIO_Pin_10 #define UART1_RX_PIN_SOURCE GPIO_PinSource10 #define UART1_GPIO GPIOA #define UART1_GPIO_RCC RCC_AHB1Periph_GPIOA #define RCC_APBPeriph_UART1 RCC_APB2Periph_USART1 struct rt_serial_device serial1; void USART1_IRQHandler(void) { /* enter interrupt */ rt_interrupt_enter(); uart_isr(&serial1); /* leave interrupt */ rt_interrupt_leave(); } #endif /* BSP_USING_UART1 */ #if defined(BSP_USING_UART2) struct rt_serial_device serial2; void USART2_IRQHandler(void) { /* enter interrupt */ rt_interrupt_enter(); uart_isr(&serial2); /* leave interrupt */ rt_interrupt_leave(); } #endif /* BSP_USING_UART2 */ #if defined(BSP_USING_UART3) struct rt_serial_device serial3; void UART3_IRQHandler(void) { /* enter interrupt */ rt_interrupt_enter(); uart_isr(&serial3); /* leave interrupt */ rt_interrupt_leave(); } #endif /* BSP_USING_UART3 */ static const struct stm32_uart uarts[] = { #ifdef BSP_USING_UART1 { USART1, // uart peripheral index USART1_IRQn, // uart iqrn RCC_APBPeriph_UART1, UART1_GPIO_RCC, UART1_GPIO_RCC, // periph clock, tx gpio clock, rt gpio clock GPIOA, GPIO_AF_USART1, UART1_GPIO_TX,UART1_TX_PIN_SOURCE, // tx port, tx alternate, tx pin GPIOA, GPIO_AF_USART1, UART1_GPIO_RX,UART1_RX_PIN_SOURCE, // rx port, rx alternate, rx pin &serial1, "uart1", }, #endif #ifdef BSP_USING_UART2 { USART2, // uart peripheral index USART2_IRQn, // uart iqrn RCU_USART2, RCU_GPIOA, RCU_GPIOA, // periph clock, tx gpio clock, rt gpio clock GPIOA, GPIO_AF_7, GPIO_PIN_2, // tx port, tx alternate, tx pin GPIOA, GPIO_AF_7, GPIO_PIN_3, // rx port, rx alternate, rx pin &serial1, "uart1", }, #endif #ifdef BSP_USING_UART3 { USART3, // uart peripheral index USART3_IRQn, // uart iqrn RCU_USART3, RCU_GPIOB, RCU_GPIOB, // periph clock, tx gpio clock, rt gpio clock GPIOB, GPIO_AF_7, GPIO_PIN_10, // tx port, tx alternate, tx pin GPIOB, GPIO_AF_7, GPIO_PIN_11, // rx port, rx alternate, rx pin &serial2, "uart2", }, #endif }; /** * @brief UART MSP Initialization * This function configures the hardware resources used in this example: * - Peripheral's clock enable * - Peripheral's GPIO Configuration * - NVIC configuration for UART interrupt request enable * @param huart: UART handle pointer * @retval None */ void gd32_uart_gpio_init(struct stm32_uart *uart) { #if 0 /* enable USART clock */ /* Enable USART GPIO clocks */ RCC_AHB1PeriphClockCmd(uart->tx_gpio_clk, ENABLE); RCC_AHB1PeriphClockCmd(uart->rx_gpio_clk, ENABLE); /* Enable USART clock */ RCC_APB2PeriphClockCmd(uart->per_clk, ENABLE); GPIO_PinAFConfig(uart->tx_port, uart->tx_pin_source,uart->tx_af); GPIO_PinAFConfig(uart->rx_port, uart->rx_pin_source,uart->rx_af); /* connect port to USARTx_Tx */ //GPIO_PinAFConfig(uart->tx_port, uart->tx_pin,uart->tx_af); //GPIO_PinAFConfig(uart->rx_port, UART1_RX_PIN_SOURCE, GPIO_AF_USART1); //gpio_af_set(uart->tx_port, uart->tx_af, uart->tx_pin); /* connect port to USARTx_Rx */ //gpio_af_set(uart->rx_port, uart->rx_af, uart->rx_pin); //GPIO_PinAFConfig(uart->rx_port, uart->rx_pin,uart->rx_af); /* configure USART Tx as alternate function push-pull */ GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Pin = uart->tx_pin; GPIO_Init(uart->tx_port, &GPIO_InitStructure); /* Connect alternate function */ //GPIO_PinAFConfig(UART1_GPIO, UART1_TX_PIN_SOURCE, GPIO_AF_USART1); //GPIO_PinAFConfig(UART1_GPIO, UART1_RX_PIN_SOURCE, GPIO_AF_USART1); //gpio_mode_set(uart->tx_port, GPIO_MODE_AF, GPIO_PUPD_PULLUP, uart->tx_pin); //gpio_output_options_set(uart->tx_port, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, uart->tx_pin); /* configure USART Rx as alternate function push-pull */ //gpio_mode_set(uart->rx_port, GPIO_MODE_AF, GPIO_PUPD_PULLUP, uart->rx_pin); //gpio_output_options_set(uart->rx_port, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, uart->rx_pin); //NVIC_SetPriority(uart->irqn, 0); //NVIC_EnableIRQ(uart->irqn); NVIC_InitTypeDef NVIC_InitStructure; /* Enable the USART1 Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = uart->irqn; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); #endif if(uart->uart_periph == USART1) { /* Enable USART2 GPIO clocks */ RCC_AHB1PeriphClockCmd(UART1_GPIO_RCC, ENABLE); /* Enable USART2 clock */ RCC_APB2PeriphClockCmd(RCC_APBPeriph_UART1, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; /* Configure USART1 Rx/tx PIN */ GPIO_InitStructure.GPIO_Pin = UART1_GPIO_RX | UART1_GPIO_TX; GPIO_Init(UART1_GPIO, &GPIO_InitStructure); /* Connect alternate function */ GPIO_PinAFConfig(UART1_GPIO, UART1_TX_PIN_SOURCE, GPIO_AF_USART1); GPIO_PinAFConfig(UART1_GPIO, UART1_RX_PIN_SOURCE, GPIO_AF_USART1); NVIC_InitTypeDef NVIC_InitStructure; /* Enable the USART1 Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } } static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_configure *cfg) { struct stm32_uart *uart; RT_ASSERT(serial != RT_NULL); RT_ASSERT(cfg != RT_NULL); uart = (struct stm32_uart *)serial->parent.user_data; gd32_uart_gpio_init(uart); USART_InitTypeDef USART_InitStructure; USART_InitStructure.USART_BaudRate = cfg->baud_rate; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(uart->uart_periph, &USART_InitStructure); USART_Cmd(uart->uart_periph, ENABLE); /* enable interrupt */ //USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); #if 0 usart_baudrate_set(uart->uart_periph, cfg->baud_rate); switch (cfg->data_bits) { case DATA_BITS_9: usart_word_length_set(uart->uart_periph, USART_WL_9BIT); break; default: usart_word_length_set(uart->uart_periph, USART_WL_8BIT); break; } switch (cfg->stop_bits) { case STOP_BITS_2: usart_stop_bit_set(uart->uart_periph, USART_STB_2BIT); break; default: usart_stop_bit_set(uart->uart_periph, USART_STB_1BIT); break; } switch (cfg->parity) { case PARITY_ODD: usart_parity_config(uart->uart_periph, USART_PM_ODD); break; case PARITY_EVEN: usart_parity_config(uart->uart_periph, USART_PM_EVEN); break; default: usart_parity_config(uart->uart_periph, USART_PM_NONE); break; } usart_receive_config(uart->uart_periph, USART_RECEIVE_ENABLE); usart_transmit_config(uart->uart_periph, USART_TRANSMIT_ENABLE); usart_enable(uart->uart_periph); #endif return RT_EOK; } static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *arg) { struct stm32_uart *uart; NVIC_InitTypeDef NVIC_InitStructure; RT_ASSERT(serial != RT_NULL); uart = (struct stm32_uart *)serial->parent.user_data; switch (cmd) { case RT_DEVICE_CTRL_CLR_INT: #if 0 /* disable rx irq */ NVIC_DisableIRQ(uart->irqn); /* disable interrupt */ usart_interrupt_disable(uart->uart_periph, USART_INTEN_RBNEIE); #endif /* Enable the USART1 Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = uart->irqn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE; NVIC_Init(&NVIC_InitStructure); USART_ITConfig(uart->uart_periph, USART_IT_RXNE, DISABLE); break; case RT_DEVICE_CTRL_SET_INT: #if 0 /* enable rx irq */ NVIC_EnableIRQ(uart->irqn); /* enable interrupt */ usart_interrupt_enable(uart->uart_periph, USART_INTEN_RBNEIE); #endif /* Enable the USART1 Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = uart->irqn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); USART_ITConfig(uart->uart_periph, USART_IT_RXNE, ENABLE); break; } return RT_EOK; } static int stm32_putc(struct rt_serial_device *serial, char ch) { struct stm32_uart *uart; RT_ASSERT(serial != RT_NULL); uart = (struct stm32_uart *)serial->parent.user_data; #if 0 usart_data_transmit(uart->uart_periph, ch); while((usart_flag_get(uart->uart_periph, USART_FLAG_TC) == RESET)); #endif while (!(uart->uart_periph->SR & USART_FLAG_TXE)); USART_SendData(uart->uart_periph,ch); return 1; } static int stm32_getc(struct rt_serial_device *serial) { int ch; struct stm32_uart *uart; RT_ASSERT(serial != RT_NULL); uart = (struct stm32_uart *)serial->parent.user_data; ch = -1; if(USART_GetITStatus(uart->uart_periph, USART_IT_RXNE) != RESET) ch = uart->uart_periph->DR ; //if (usart_flag_get(uart->uart_periph, USART_FLAG_RBNE) != RESET) // ch = usart_data_receive(uart->uart_periph); return ch; } /** * Uart common interrupt process. This need add to uart ISR. * * @param serial serial device */ static void uart_isr(struct rt_serial_device *serial) { struct stm32_uart *uart = (struct stm32_uart *) serial->parent.user_data; RT_ASSERT(uart != RT_NULL); /* UART in mode Receiver -------------------------------------------------*/ #if 0 if ((usart_interrupt_flag_get(uart->uart_periph, USART_INT_RBNEIE) != RESET) && (usart_flag_get(uart->uart_periph, USART_FLAG_RBNE) != RESET)) { rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND); /* Clear RXNE interrupt flag */ usart_flag_clear(uart->uart_periph, USART_FLAG_RBNE); } #endif if(USART_GetITStatus(uart->uart_periph, USART_IT_RXNE) != RESET) { rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND); } } static const struct rt_uart_ops stm32_uart_ops = { stm32_configure, stm32_control, stm32_putc, stm32_getc, }; int stm32_hw_usart_init(void) { struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; int i; for (i = 0; i < sizeof(uarts) / sizeof(uarts[0]); i++) { uarts[i].serial->ops = &stm32_uart_ops; uarts[i].serial->config = config; /* register UART1 device */ rt_hw_serial_register(uarts[i].serial, uarts[i].device_name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, (void *)&uarts[i]); } return 0; } INIT_BOARD_EXPORT(stm32_hw_usart_init); #endif ``` board.h ```c /* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2009-09-22 Bernard add board.h to this bsp */ // <<< Use Configuration Wizard in Context Menu >>> #ifndef __BOARD_H__ #define __BOARD_H__ #include
#define EXT_SDRAM_BEGIN (0xC0000000U) /* the begining address of external SDRAM */ #define EXT_SDRAM_END (EXT_SDRAM_BEGIN + (32U * 1024 * 1024)) /* the end address of external SDRAM */ //
Internal SRAM memory size[Kbytes] <8-64> //
Default: 64 #ifdef __ICCARM__ // Use *.icf ram symbal, to avoid hardcode. extern char __ICFEDIT_region_RAM_end__; #define STM32_SRAM_END &__ICFEDIT_region_RAM_end__ #else #define STM32_SRAM_SIZE 128 #define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024) #endif #ifdef __CC_ARM extern int Image$$RW_IRAM1$$ZI$$Limit; #define HEAP_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit) #elif __ICCARM__ #pragma section="HEAP" #define HEAP_BEGIN (__segment_end("HEAP")) #else extern int __bss_end; #define HEAP_BEGIN (&__bss_end) #endif #define HEAP_END STM32_SRAM_END #endif //*** <<< end of configuration section >>> *** ``` main.c 加了个led显示 ```c /* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2018-05-18 tanek first implementation */ #include
#include
#include "stm32f4xx.h" int main(void) { GPIO_InitTypeDef GPIO_InitStructure; /* GPIOD Periph clock enable */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOF|RCC_AHB1Periph_GPIOG, ENABLE); /* Configure PE 2345 in output pushpull mode */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOE, &GPIO_InitStructure); GPIO_SetBits(GPIOE,GPIO_Pin_2 | GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5); while(1) { /* PD12 to be toggled */ GPIO_ToggleBits(GPIOE, GPIO_Pin_2); //ÔËÐÐָʾµÆ /* Insert delay */ rt_thread_delay(RT_TICK_PER_SECOND/5); } return 0; } ``` 最后还要把stm32f4xx_conf.h 扔到drivers目录中 注意要用scons 重新生成工程 ``` scons --target=mdk4 -s ```
出出啊
2021-10-22
恃人不如自恃,人之为己者不如己之自为也
直接4.x 没有简便方法,从头开始
cxhxy12345
2021-10-22
这家伙很懒,什么也没写!
版本升级距离有点远,只能自己一点一点改,建议你直接升到最新版,避免过几年又要升级~~~~。 如果程序稳定,或则不增加功能,就不要升了,毕竟不是电脑~~~
Jone
2021-10-22
写了还是懒
要是通过studio创建的工程,右击可以换内核版本升级 你这个只能自个动手了。。。
撰写答案
登录
注册新账号
关注者
0
被浏览
898
关于作者
ralfak
这家伙很懒,什么也没写!
提问
35
回答
102
被采纳
0
关注TA
发私信
相关问题
1
STM32 407 串口接收数据 系统卡死
2
RTT nrf24l01 设备驱动程序
3
stm32f10x串口只能发送数据,无法接收
4
第一次尝试移植rt-thread 到stm32F103系列问题
5
有人把stm32L07xx的bsp移到rtt上来了吗?求一个
6
rt-thread线程调度异常在stm32f103芯片上
7
RTT是否支持STM32F429
8
请问谁有 STM32F40x HAL + RT-THREAD 模板
9
rt-thread在stm32f411下的移植问题
10
针对STM32F7系列平台的MPU,Cache特性,需要注意哪些问题?
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
【RT-Thread】【ci】【scons】将ci.attachconfig.yml和scons结合使用
2
Rt-thread中OTA下载后,bootloader不搬程序
3
ulog 日志 LOG_HEX 输出时间改为本地日期时间
4
在RT-Thread Studio中构建前执行python命令
5
研究一了一段时间RTT,直接标准版上手太难,想用nano,但又舍不得组件
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
USB
DMA
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
FAL
rt-smart
I2C_IIC
ESP8266
UART
WIZnet_W5500
ota在线升级
PWM
cubemx
flash
freemodbus
BSP
packages_软件包
潘多拉开发板_Pandora
定时器
ADC
flashDB
GD32
socket
编译报错
中断
Debug
rt_mq_消息队列_msg_queue
SFUD
msh
keil_MDK
ulog
C++_cpp
MicroPython
本月问答贡献
xusiwei1236
8
个答案
2
次被采纳
踩姑娘的小蘑菇
1
个答案
2
次被采纳
用户名由3_15位
7
个答案
1
次被采纳
bernard
4
个答案
1
次被采纳
RTT_逍遥
3
个答案
1
次被采纳
本月文章贡献
聚散无由
2
篇文章
15
次点赞
catcatbing
2
篇文章
5
次点赞
Wade
2
篇文章
3
次点赞
Ghost_Girls
1
篇文章
6
次点赞
YZRD
1
篇文章
2
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部