zoukankan      html  css  js  c++  java
  • STM32F103 rtthread工程构建

    STM32F103 工程构建

    1.基本情况

    RAM 20K

    ROM 64K

    2.硬件连接

    硬件连接

    现在采用串口1作为调试串口

    3.rtthread配置

    第一步:

    下载rtthread的源代码

     git clone https://github.com/RT-Thread/rt-thread.git
    

    或者

    git clone https://gitee.com/rtthread/rt-thread 
    

    第二步:

    配置工程,选择型号

    输入menuconfig

    接着生成相应的工程

    scons --target=mdk5 -s
    

    接上串口,可以看到打印信息,即项目完成移植

    4.点灯

    由于已经实现了通用的GPIO驱动程序,所以只需按照说明操作即可

    输入list_device

    现在我们在main函数中创建一个点灯线程

    /*
     * Copyright (c) 2006-2018, RT-Thread Development Team
     *
     * SPDX-License-Identifier: Apache-2.0
     *
     * Change Logs:
     * Date Author Notes
     * 2015-07-29 Arda.Fu first implementation
     */
    #include <rthw.h>
    #include <rtdevice.h>
    #include <board.h>
    #include <rtthread.h>
    
    #define LED0 2 //在 drv_gpio.c 文件 pin_index pins[] 中查到 PC13 编号为 2
    
     void led_thread_entry(void* parameter)
    {
        // 设置管脚为输出模式
        rt_pin_mode(LED0, PIN_MODE_OUTPUT);
    
        while (1)
        {
            // 输出低电平,LED0 亮
            rt_pin_write(LED0, PIN_LOW);
         rt_kprintf("on
    ");
            // 挂起 500ms
            rt_thread_delay(rt_tick_from_millisecond(500));
            // 输出高电平,LED0 灭
            rt_pin_write(LED0, PIN_HIGH);
         rt_kprintf("off
    ");
            // 挂起 500ms
            rt_thread_delay(rt_tick_from_millisecond(500));
        }
    }
    
    int main(void)
    {
        /* user app entry */
        rt_thread_t led_task_tid;
        led_task_tid = rt_thread_create("led", led_thread_entry, RT_NULL, 1024, 3, 10);
        if(led_task_tid != RT_NULL)
        {
            rt_thread_startup(led_task_tid);
        }
        return 0;
    }
    
    

    运行后结果如下,表示操作成功

    5. 码云上git操作

    cd existing_git_repo
    git remote add origin git@gitee.com:bigmagic/stm32f103c8t6_demo.git
    git push -u origin master
    
    学而不思则罔,思而不学则殆
  • 相关阅读:
    mac c++编译出现segmentation fault :11错误
    ssh 连接缓慢解决方法
    237. Delete Node in a Linked List
    203. Remove Linked List Elements
    Inversion of Control Containers and the Dependency Injection pattern
    82. Remove Duplicates from Sorted List II
    83. Remove Duplicates from Sorted List
    SxsTrace
    使用CCleaner卸载chrome
    decimal and double ToString problem
  • 原文地址:https://www.cnblogs.com/bigmagic/p/10307474.html
Copyright © 2011-2022 走看看