RT-Thread STM32L431 Bear-Pi开发板BSP说明

这篇具有很好参考价值的文章主要介绍了RT-Thread STM32L431 Bear-Pi开发板BSP说明。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

RT-Thread STM32L431 Bear-Pi开发板BSP说明

bsp源码下载,stm32,linux,arm开发,运维,嵌入式硬件,单片机

简介

本文档为Bear-Pi 开发板的 BSP (板级支持包) 说明。

主要内容如下:

  • 开发板资源介绍
  • BSP 快速上手
  • 进阶使用方法

通过阅读快速上手章节开发者可以快速地上手该 BSP,将 RT-Thread 运行在开发板上。在进阶使用指南章节,将会介绍更多高级功能,帮助开发者利用 RT-Thread 驱动更多板载资源。

开发板介绍

对于 Bear-Pi,内核是 Cortex-M4,这款芯片是低功耗系列,板载 ST-LINK/V2-1 调试器/编程器,迷你尺寸,mirco USB 接口,可数的外设,Arduino™ nano 兼容的接口。

开发板外观如下图所示:
bsp源码下载,stm32,linux,arm开发,运维,嵌入式硬件,单片机

该开发板常用 板载资源 如下:

  • MCU:STM32L431RC,主频 80MHz,256KB FLASH ,64KB RAM。
  • 常用外设
    • SPI FLASH: 8M
    • 按键:2个功能键,一个复位按键。
    • 支持E53系列传感器案例扩展板
    • LCD: 240 * 240 tft
    • LED:一个用户LED, 上电指示灯,下载灯。
  • 常用接口:USB 支持 3 种不同接口:虚拟 COM 端口、大容量存储和调试端口。
  • 调试接口:板载 ST-LINK/V2-1 调试器。

开发板更多详细信息请参考【Bear-Pi 官网】 Bear-Pi。

外设支持

本 BSP 目前对外设的支持情况如下:

板载外设 支持情况 备注
板载 ST-LINK 转串口 支持 UART1
片上外设 支持情况 备注
GPIO 支持 PA0, PA1… PC15 —> PIN: 0, 1…47
UART 支持 UART1

使用说明

使用说明分为如下两个章节:

  • 快速上手

    本章节是为刚接触 RT-Thread 的新手准备的使用说明,遵循简单的步骤即可将 RT-Thread 操作系统运行在该开发板上,看到实验效果 。

  • 进阶使用

    本章节是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多板载资源,实现更多高级功能。

快速上手

本 BSP 为开发者提供 MDK5 和 IAR 工程,并且支持 GCC 开发环境。下面以 MDK5 开发环境为例,介绍如何将系统运行起来。

硬件连接

使用数据线连接开发板到 PC,打开电源开关。

编译下载

双击 project.uvprojx 文件,打开 MDK5 工程,编译并下载程序到开发板。

工程默认配置使用 ST-LINK 仿真器下载程序,在通过 microUSB 连接开发板的基础上,点击下载按钮即可下载程序到开发板

运行结果

下载程序成功之后,系统会自动运行,观察开发板上 LED 的运行效果,红色 D5、蓝色 LED 会周期性闪烁。

USB 虚拟 COM 端口默认连接串口 1,在终端工具里打开相应的串口(115200-8-1-N),复位设备后,可以看到 RT-Thread 的输出信息:

 \ | /
- RT -     Thread Operating System
 / | \     4.0.3 build Dec 28 2020
 2006 - 2020 Copyright by rt-thread team
---Welcome use BearPi---
msh >

进阶使用

此 BSP 默认只开启了 GPIO 和 串口2 的功能,如果需使用更多高级功能,需要利用 ENV 工具对 BSP 进行配置,步骤如下:

  1. 在 bsp 下打开 env 工具。

  2. 输入menuconfig命令配置工程,配置好之后保存退出。

  3. 输入pkgs --update命令更新软件包。

  4. 输入scons --target=mdk4/mdk5/iar 命令重新生成工程。

本章节更多详细的介绍请参考 STM32 系列 BSP 外设驱动使用教程。

注意事项

  • 开机时如果不能打印 RT-Thread 版本信息,请将BSP中串口 GPIO 速率调低
  • 开机时如果不能打印 RT-Thread 版本信息,请重新选择 PC 端串口调试软件的串口号

示例代码

…\rt-threadcode\src\ipc.c


/**
 * @brief    This function will try to take a mutex, if the mutex is unavailable, the thread returns immediately.
 *
 * @note     This function is very similar to the rt_mutex_take() function, when the mutex is not available,
 *           except that rt_mutex_trytake() will return immediately without waiting for a timeout
 *           when the mutex is not available.
 *           In other words, rt_mutex_trytake(mutex) has the same effect as rt_mutex_take(mutex, 0).
 *
 * @see      rt_mutex_take()
 *
 * @param    mutex is a pointer to a mutex object.
 *
 * @return   Return the operation status. ONLY When the return value is RT_EOK, the operation is successful.
 *           If the return value is any other values, it means that the mutex take failed.
 */
rt_err_t rt_mutex_trytake(rt_mutex_t mutex)
{
    return rt_mutex_take(mutex, RT_WAITING_NO);
}
RTM_EXPORT(rt_mutex_trytake);


/**
 * @brief    This function will release a mutex. If there is thread suspended on the mutex, the thread will be resumed.
 *
 * @note     If there are threads suspended on this mutex, the first thread in the list of this mutex object
 *           will be resumed, and a thread scheduling (rt_schedule) will be executed.
 *           If no threads are suspended on this mutex, the count value mutex->value of this mutex will increase by 1.
 *
 * @param    mutex is a pointer to a mutex object.
 *
 * @return   Return the operation status. When the return value is RT_EOK, the operation is successful.
 *           If the return value is any other values, it means that the mutex release failed.
 */
rt_err_t rt_mutex_release(rt_mutex_t mutex)
{
    rt_base_t level;
    struct rt_thread *thread;
    rt_bool_t need_schedule;

    /* parameter check */
    RT_ASSERT(mutex != RT_NULL);
    RT_ASSERT(rt_object_get_type(&mutex->parent.parent) == RT_Object_Class_Mutex);

    need_schedule = RT_FALSE;

    /* only thread could release mutex because we need test the ownership */
    RT_DEBUG_IN_THREAD_CONTEXT;

    /* get current thread */
    thread = rt_thread_self();

    level = rt_spin_lock_irqsave(&(mutex->spinlock));

    LOG_D("mutex_release:current thread %s, hold: %d",
          thread->parent.name, mutex->hold);

    RT_OBJECT_HOOK_CALL(rt_object_put_hook, (&(mutex->parent.parent)));

    /* mutex only can be released by owner */
    if (thread != mutex->owner)
    {
        thread->error = -RT_ERROR;
        rt_spin_unlock_irqrestore(&(mutex->spinlock), level);

        return -RT_ERROR;
    }

    /* decrease hold */
    mutex->hold --;
    /* if no hold */
    if (mutex->hold == 0)
    {
        /* remove mutex from thread's taken list */
        rt_list_remove(&mutex->taken_list);

        /* whether change the thread priority */
        if ((mutex->ceiling_priority != 0xFF) || (thread->current_priority == mutex->priority))
        {
            rt_uint8_t priority = 0xff;

            /* get the highest priority in the taken list of thread */
            priority = _thread_get_mutex_priority(thread);

            rt_thread_control(thread,
                              RT_THREAD_CTRL_CHANGE_PRIORITY,
                              &priority);

            need_schedule = RT_TRUE;
        }

        /* wakeup suspended thread */
        if (!rt_list_isempty(&mutex->parent.suspend_thread))
        {
            /* get the first suspended thread */
            struct rt_thread *next_thread = rt_list_entry(mutex->parent.suspend_thread.next,
                                   struct rt_thread,
                                   tlist);

            LOG_D("mutex_release: resume thread: %s",
                  next_thread->parent.name);

            rt_spin_lock(&(next_thread->spinlock));
            /* remove the thread from the suspended list of mutex */
            rt_list_remove(&(next_thread->tlist));

            /* set new owner and put mutex into taken list of thread */
            mutex->owner = next_thread;
            mutex->hold  = 1;
            rt_list_insert_after(&next_thread->taken_object_list, &mutex->taken_list);
            /* cleanup pending object */
            next_thread->pending_object = RT_NULL;
            rt_spin_unlock(&(next_thread->spinlock));
            /* resume thread */
            rt_thread_resume(next_thread);

            /* update mutex priority */
            if (!rt_list_isempty(&(mutex->parent.suspend_thread)))
            {
                struct rt_thread *th;

                th = rt_list_entry(mutex->parent.suspend_thread.next,
                        struct rt_thread,
                        tlist);
                mutex->priority = th->current_priority;
            }
            else
            {
                mutex->priority = 0xff;
            }

            need_schedule = RT_TRUE;
        }
        else
        {
            /* clear owner */
            mutex->owner    = RT_NULL;
            mutex->priority = 0xff;
        }
    }

    rt_spin_unlock_irqrestore(&(mutex->spinlock), level);

    /* perform a schedule */
    if (need_schedule == RT_TRUE)
        rt_schedule();

    return RT_EOK;
}
RTM_EXPORT(rt_mutex_release);


/**
 * @brief    This function will set some extra attributions of a mutex object.
 *
 * @note     Currently this function does not implement the control function.
 *
 * @param    mutex is a pointer to a mutex object.
 *
 * @param    cmd is a command word used to configure some attributions of the mutex.
 *
 * @param    arg is the argument of the function to execute the command.
 *
 * @return   Return the operation status. When the return value is RT_EOK, the operation is successful.
 *           If the return value is any other values, it means that this function failed to execute.
 */
rt_err_t rt_mutex_control(rt_mutex_t mutex, int cmd, void *arg)
{
    /* parameter check */
    RT_ASSERT(mutex != RT_NULL);
    RT_ASSERT(rt_object_get_type(&mutex->parent.parent) == RT_Object_Class_Mutex);

    return -RT_ERROR;
}
RTM_EXPORT(rt_mutex_control);

/**@}*/
#endif /* RT_USING_MUTEX */

源码下载

…\bsp\stm32\stm32l431-BearPi\project.uvproj

bsp源码下载,stm32,linux,arm开发,运维,嵌入式硬件,单片机


RT-Thread STM32L431 Bear-Pi开发板BSP说明 源码下载文章来源地址https://www.toymoban.com/news/detail-763863.html


维护人:

  • 华为奋斗者精神, 邮箱:1992152446@qq.com

到了这里,关于RT-Thread STM32L431 Bear-Pi开发板BSP说明的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【STM32&RT-Thread零基础入门】 2. 新建RT-Thread项目

    硬件:STM32F103ZET6、ST-LINK、usb转串口工具 RT-Thread的全称是Real Time Thread,顾名思义,它是一个嵌入式实时多线程操作系统。相较于 Linux 操作系统,RT-Thread 体积小,成本低,功耗低、启动快速,除此之外 RT-Thread 还具有实时性高、占用资源小等特点,非常适用于各种资源受限(

    2024年02月13日
    浏览(34)
  • 使用RT-Thread Studio搭配STM32CubeMX新建RT-Thread项目

    STM32CubeMX下载 RT-Thread Studio下载 安装好RT-Thread Studio后,先打开RT-Thread SDK管理器确认有没有自己MCU需要的SDK包,直接安装好之后里面是有STM32F1系列的SDK包,其他的需要自己安装。 之后点击文件→新建→RT-Thread项目,根据自己需要配置好后点击完成就会生成RT-Thread项目。 新建项

    2024年02月11日
    浏览(34)
  • 【STM32&RT-Thread零基础入门】8. 基于 CubeMX 移植 RT-Thread Nano

    硬件:STM32F103ZET6、ST-LINK、usb转串口工具、4个LED灯、1个蜂鸣器、4个1k电阻、2个按键、面包板、杜邦线 利用RT_Thread操作系统实现三种不同的LED等闪烁 提示:以下是本篇文章正文内容,下面案例可供参考 cubemx配置参考教程: 基于 CubeMX 移植 RT-Thread Nano 后面程序所需的引脚 RT

    2024年02月09日
    浏览(33)
  • STM32 + RT-Thread + LwIp + DM9000

    开发板:STM32F103ZET6(战舰) RT-Thread:5.0.0 LwIp:2.1.2 网卡芯片:DM9000 编译环境:keil 我简单了解了一下,在嵌入式中,网络芯片的使用方式大致有三种,如下: (MCU + MAC + PHY) (MUC + MAC) —— PHY MCU —— (MAC + PHY) 注意: 我用括号里面的表示在同一块芯片中 移植 RT-Thread 不是此文

    2024年02月07日
    浏览(39)
  • RT-Thread:STM32实时时钟 RTC开启及应用

    说明: STM32F103/407系列基于 RT-Thread 系统的 RTC 开启及应用 应用流程介绍。 完成以上系统配置,编译无误情况下RTC 就已经开启了。 官方 API 查询地址:https://www.rt-thread.org/document/api/rtc_sample_8c-example.html#a3 1.设置日期:设置系统日期但不修改时间 2.设置时间:设置系统时间但不

    2024年01月17日
    浏览(51)
  • 【STM32&RT-Thread零基础入门】 4. 线程介绍(理论)

    前文中的最后一个任务发现,一个main()函数很难同时实现按键功能和闪灯功能,就好像人很难同时完成左手画圆右手画方一样,这种情况可以安排一人去画圆、一人去画方,并行进行就很容易了,两人各司其职,互不干扰。 操作系统中,一个线程就像做事的一个人。一个操作

    2024年02月12日
    浏览(29)
  • STM32CubeMX+VSCODE+EIDE+RT-THREAD 工程创建

            Eide环境搭建暂且不表,后续补充。主要记录下Vscode环境下 创建Rt-thread工程的过程。分别介绍STM32CubeMX添加rtt支持包的方式和手动添加rtt kernel方式。STM32CubeMX生成工程的时候有\\\"坑\\\",防止下次忘记,方便渡一下有缘人,特此记录。         此工程以创建stm32f405为例

    2024年02月14日
    浏览(37)
  • RT-Thread STM32 GoKit V2.1 开发板BSP说明

    本文档为刘恒为 GoKit V2.1 开发板提供的 BSP (板级支持包) 说明。 主要内容如下: 开发板资源介绍 BSP 快速上手 进阶使用方法 通过阅读快速上手章节开发者可以快速地上手该 BSP,将 RT-Thread 运行在开发板上。在进阶使用指南章节,将会介绍更多高级功能,帮助开发者利用 RT-

    2024年02月04日
    浏览(27)
  • 基于stm32单片机和rt-thread操作系统的智能灯

    目    录 一、 总体概况 二、 各部分介绍 2.1  STM32F4开发板 2.2  光敏模块 2.3  麦克风模块 2.4  超声波模块 三、 RT-Thread介绍 四、 开发过程 五、 未来设想 六、 开发心得 总体概况 本次测试技术与信号处理课程作业,我利用了stm32单片机和rt-thread实时操作系统进行实践。

    2023年04月16日
    浏览(67)
  • 【STM32&RT-Thread零基础入门】 7. 线程创建应用(多线程运行机制)

    硬件:STM32F103ZET6、ST-LINK、usb转串口工具、4个LED灯、1个蜂鸣器、4个1k电阻、2个按键、面包板、杜邦线 本章进一步研究多线程的运行机制。要求实现功能如下:创建2个线程,线程名称分别为LED和BEEP。两个线程的任务是连续5次打印本线程的名字后退出线程(注意:线程不执行

    2024年02月03日
    浏览(27)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包