当前位置:   article > 正文

AT32F423-RTOS 建立过程(三) [SES&rtthread3.1.5]_at32f423gpio

at32f423gpio

要想使用shell,必须是要使用uart1,对于我的这个板子。

注意这个不要勾!!!

加塞一个关于main.c文件的问题。(或者不需要它去修改的文件)

因为每次使用WorkBench生成新的文件的话会覆盖自己的源码文件,所以我建议把main.c文件不要用它自己生成的。

好,继续。。。

  1. //在board.c文件最后粘贴以下代码
  2. #ifdef RT_USING_CONSOLE
  3. static int uart_init(void)
  4. {
  5. // #error "TODO 2: Enable the hardware uart and config baudrate."
  6. return 0;
  7. }
  8. INIT_BOARD_EXPORT(uart_init);
  9. void rt_hw_console_output(const char *str)
  10. {
  11. // #error "TODO 3: Output the string 'str' through the uart."
  12. rt_enter_critical();
  13. /*进入临界区*/
  14. while (*str != '\0')
  15. {
  16. if (*str == '\n')
  17. {
  18. usart_data_transmit(USART1, '\r');
  19. while (usart_flag_get(USART1, USART_TDC_FLAG) == RESET)
  20. ;
  21. }
  22. usart_data_transmit(USART1, *str++);
  23. while (usart_flag_get(USART1, USART_TDC_FLAG) == RESET)
  24. ;
  25. }
  26. /* 退出临界区*/
  27. rt_exit_critical();
  28. }
  29. #endif

F7:构建 F8:下载。。。。

信息出来了。

扩展:

上一篇文章,我闪灯了,我这次要看一下延时时间是不是500ms。

  1. /* add user code begin Header */
  2. /**
  3. **************************************************************************
  4. * @file main.c
  5. * @brief main program
  6. **************************************************************************
  7. * Copyright notice & Disclaimer
  8. *
  9. * The software Board Support Package (BSP) that is made available to
  10. * download from Artery official website is the copyrighted work of Artery.
  11. * Artery authorizes customers to use, copy, and distribute the BSP
  12. * software and its related documentation for the purpose of design and
  13. * development in conjunction with Artery microcontrollers. Use of the
  14. * software is governed by this copyright notice and the following disclaimer.
  15. *
  16. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  17. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  18. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  19. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  20. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  22. *
  23. **************************************************************************
  24. */
  25. /* add user code end Header */
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "at32f423_wk_config.h"
  28. /* private includes ----------------------------------------------------------*/
  29. /* add user code begin private includes */
  30. #include "rtthread.h"
  31. /* add user code end private includes */
  32. /* private typedef -----------------------------------------------------------*/
  33. /* add user code begin private typedef */
  34. /* add user code end private typedef */
  35. /* private define ------------------------------------------------------------*/
  36. /* add user code begin private define */
  37. /* add user code end private define */
  38. /* private macro -------------------------------------------------------------*/
  39. /* add user code begin private macro */
  40. /* add user code end private macro */
  41. /* private variables ---------------------------------------------------------*/
  42. /* add user code begin private variables */
  43. /* add user code end private variables */
  44. /* private function prototypes --------------------------------------------*/
  45. /* add user code begin function prototypes */
  46. /* add user code end function prototypes */
  47. /* private user code ---------------------------------------------------------*/
  48. /* add user code begin 0 */
  49. /* add user code end 0 */
  50. /**
  51. * @brief take some delay for waiting power stable, delay is about 60ms with frequency 8MHz.
  52. * @param none
  53. * @retval none
  54. */
  55. static void wk_wait_for_power_stable(void)
  56. {
  57. volatile uint32_t delay = 0;
  58. for(delay = 0; delay < 50000; delay++);
  59. }
  60. /**
  61. * @brief main function.
  62. * @param none
  63. * @retval none
  64. */
  65. int main(void)
  66. {
  67. /* add user code begin 1 */
  68. /* add user code end 1 */
  69. /* add a necessary delay to ensure that Vdd is higher than the operating
  70. voltage of battery powered domain (2.57V) when the battery powered
  71. domain is powered on for the first time and being operated. */
  72. //wk_wait_for_power_stable();
  73. ///* system clock config. */
  74. //wk_system_clock_config();
  75. ///* config periph clock. */
  76. //wk_periph_clock_config();
  77. ///* nvic config. */
  78. //wk_nvic_config();
  79. ///* init usart1 function. */
  80. //wk_usart1_init();
  81. ///* init gpio function. */
  82. //wk_gpio_config();
  83. /* add user code begin 2 */
  84. /* add user code end 2 */
  85. while(1)
  86. {
  87. /* add user code begin 3 */
  88. rt_thread_mdelay(500);
  89. rt_kprintf("ON\r\n");//打印
  90. gpio_bits_reset(RUNLED_GPIO_PORT,RUNLED_PIN);
  91. rt_thread_mdelay(500);
  92. rt_kprintf("OFF\r\n");//打印
  93. gpio_bits_set(RUNLED_GPIO_PORT,RUNLED_PIN);
  94. /* add user code end 3 */
  95. }
  96. }

这次实现了shell的显示,那么rtthread还有个比较不错的功能就是finsh,下一篇,我介绍以下RT_DEBUG和finsh的移植。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/67501
推荐阅读
相关标签
  

闽ICP备14008679号