The MR
framework is a lightweight framework designed specifically for embedded systems. It fully considers the
resource and performance requirements of embedded systems.
By providing standardized device management interfaces, it greatly simplifies the development of embedded applications and helps developers quickly build embedded applications.
The framework provides developers with standardized open
, close
, ioctl
, read
, write
and other
interfaces. It decouples the applications from the low-level hardware drivers. The applications do not need to know the
implementation details of the drivers.
When the hardware changes, the applications can seamlessly migrate to the new hardware by only adapting the low-level drivers. This greatly improves the reusability of software and its extensibility to new hardware.
All operations of the device can be implemented through the following interfaces:
interface | describe |
---|---|
mr_dev_register | Registered device |
mr_dev_open | Open device |
mr_dev_close | Close device |
mr_dev_ioctl | Control device |
mr_dev_read | Read data from the device |
mr_dev_write | Writes data to the device |
Example:
int main(void)
{
/* Open SPI10 device under SPI1 bus line */
int ds = mr_dev_open("spi1/spi10", MR_O_RDWR);
/* Send data */
uint8_t wr_buf[] = {0x01, 0x02, 0x03, 0x04};
mr_dev_write(ds, wr_buf, sizeof(wr_buf));
/* Receive data */
uint8_t rd_buf[4] = {0};
mr_dev_read(ds, rd_buf, sizeof(rd_buf));
/* Close device */
mr_dev_close(ds);
}
Thanks to the standardized device interface, all devices automatically support the msh
device command,
and all device operations can be completed through the command line.
MR
provides Kconfig
visual configuration tool that developers can configure without deep knowledge of the source
code.
Kconfig
will automatically generate the configuration options interface based on the configuration file. Developers
can select the functional components that need to be enabled and set relevant parameters through simple operations.
By modifying parameters, you can quickly tailor the required functions. After the configuration is complete,
the Python
script automatically generates the configuration file.
name | describe |
---|---|
bsp | Board support package |
components | Components |
device | Device file |
document | Document |
driver | Driver file |
include | Library header file |
source | Library source file |
Kconfig | Configuration files |
LICENSE | Open-source license |
kconfig.py | Automatic configuration script |
tool.py | Automatic build script |
Device/Component | Plan | Preview | Stable | Document |
---|---|---|---|---|
ADC |
[√] | [√] | ||
CAN |
[√] | |||
DAC |
[√] | [√] | ||
I2C |
[√] | [√] | ||
Soft-I2C |
[√] | [√] | ||
Pin |
[√] | [√] | ||
PWM |
[√] | [√] | ||
Serial |
[√] | [√] | ||
SPI |
[√] | [√] | ||
Timer |
[√] | [√] | ||
msh |
[√] | [√] | ||
LCD |
[√] | |||
Senser |
[√] |
Verify that the Python environment is installed. Run python --version
on the command line to check the Python
version (the MR
scripting tool relies on Python, install it yourself if there is no Python environment,
Versions later than 3.11.7
are not supported).
Download the latest version source code from the Gitee
or GitHub
repository to the local.
Copy the source code to the directory where your project is located. Take the MDK
project (CubeMX-generated
standard project) as an example:
Copy the driver of the corresponding chip in the bsp
directory to driver
(Please read the documentation in bsp
carefully):
Remove unnecessary filesbsp
, document
directories (you can also remove .git
files if you don't
needgit
). When complete, the directory structure looks like this:
Use the automatic build script to complete the automatic build. In the mr-library
path, open the command line tool and run python tool.py -b
Take MDK
as an example:
Note:
MDK5
and Eclipse
.MDK
uncompiled or too low a version can cause the 'GNU' configuration to fail.Open the command line tool in the mr-library
directory and run python tool.py -m
for menu configuration.
Run failed:
Python
version (versions above 3.11.7
are not currently supported, reinstall and remove the installed modules).powershell(win10 and above)
, git bash(newer version)
and so on.Enter the menu by pressing the Enter key on Device configure
, and configure the desired functions according to
needs.
After configuration is complete, press Q
to exit the menu configuration interface, press Y
to save the
configuration.
In the project, introduce #include include/mr_lib.h
and addmr_auto_init()
tomain
function;
Automatically initialize the function and start using it.
Note: More commands can be entered: python tool.py -h
to view.
#include "include/mr_lib.h"
/* Define the LED pin-number (PC13) */
#define LED_PIN_NUMBER 45
int main(void)
{
/* Automatic initialization */
mr_auto_init();
/* Open the PIN device */
int ds = mr_dev_open("pin", MR_O_WRONLY);
/* Set to the LED pin */
mr_dev_ioctl(ds, MR_IOC_PIN_SET_NUMBER, MR_MAKE_LOCAL(int, LED_PIN_NUMBER));
/* Set the LED pin to push-pull output mode */
mr_dev_ioctl(ds, MR_IOC_PIN_SET_MODE, MR_MAKE_LOCAL(int, MR_PIN_MODE_OUTPUT));
while(1)
{
/* Light up the LED */
mr_dev_write(ds, MR_MAKE_LOCAL(uint8_t, 1), sizeof(uint8_t));
mr_delay_ms(500);
mr_dev_write(ds, MR_MAKE_LOCAL(uint8_t, 0), sizeof(uint8_t));
mr_delay_ms(500);
}
}
#include "include/mr_lib.h"
int main(void)
{
/* Automatic initialization */
mr_auto_init();
/* Open the Serial-1 device */
int ds = mr_dev_open("serial1", MR_O_RDWR);
/* Output Hello World */
mr_dev_write(ds, "Hello World\r\n", sizeof("Hello World\r\n"));
while(1);
}
MR
project. The project discussion group is: 199915649(QQ).此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。