main.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-05-26 RT-Thread first version
  9. */
  10. #include <rtthread.h>
  11. #include "stm32g0xx_hal.h"
  12. #include "usart/usart.h"
  13. #include "boot/boot.h"
  14. //#include <rtthread.h>
  15. //#include "ymodem.h"
  16. UART_HandleTypeDef UartHandle;
  17. extern char rt_hw_console_getchar(void);
  18. void MX_USART1_UART_Init(void);
  19. static void MX_GPIO_Init(void)
  20. {
  21. GPIO_InitTypeDef GPIO_InitStruct = {0};
  22. __HAL_RCC_GPIOA_CLK_ENABLE();
  23. HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET);
  24. /*Configure GPIO pin : PA12 */
  25. GPIO_InitStruct.Pin = GPIO_PIN_12;
  26. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  27. GPIO_InitStruct.Pull = GPIO_NOPULL;
  28. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  29. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  30. }
  31. int main(void)
  32. {
  33. char ad_val[4]={"BOOT"};
  34. HAL_Init(); //HAL库初始化
  35. MX_USART1_UART_Init();
  36. MX_GPIO_Init();
  37. HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, SET);
  38. HAL_UART_Transmit(&UartHandle,(unsigned char*)ad_val,4,1000);
  39. n_boot_memu(); //bootloader菜单
  40. thread_boot();//bootloader功能
  41. return RT_EOK;
  42. }