简介
龙芯1c库的git是 http://git.oschina.net/caogos/OpenLoongsonLib1c
RT-Thread的git是 https://github.com/RT-Thread/rt-thread
龙芯1c库是为龙芯1c单片机封装的常用外设接口集合,类似于STM32库。不仅可以用于裸机编程,还可以和实时系统(比如RT-Thread等)配合使用。这里就是将龙芯1c库和RT-Thread配合使用,其中龙芯1c库中GPIO相关接口已经移植到RT-Thread,并且合并到RT-Thread官方源码中。
其实,在RT-Thread下使用龙芯1c库中的gpio相关函数与在裸机编程下是一样的,都是先包含头文件,然后直接调用。
建议先阅读【龙芯1c库】封装gpio接口,本文以gpio控制led闪烁为例,演示一下怎么在RT-Thread中使用龙芯1c库中的GPIO相关接口函数。
源码清单
在RT-Thread下,只需要新建一个线程,然后在线程的入口函数中调用gpio相关函数实现led闪烁就可以了。
比如,这里新建一个叫“thread_test”的线程,入口函数为thread_test_entry(),完整的源码为
bsp\ls1cdev\applications\application.c
/*
* File : application.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006-2012, RT-Thread Develop Team
*
* The license and distribution terms for this file may be
* found in the file