1.路径优化。
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* @date 2023-11-08 MacRsh First version
|
||||
*/
|
||||
|
||||
#include "include/device/pin.h"
|
||||
#include "pin.h"
|
||||
|
||||
#ifdef MR_USING_PIN
|
||||
|
||||
@@ -59,7 +59,7 @@ static int mr_pin_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case MR_CTRL_PIN_SET_MODE:
|
||||
case MR_CTL_PIN_SET_MODE:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
|
||||
@@ -45,13 +45,13 @@ extern "C" {
|
||||
/**
|
||||
* @brief PIN mode command.
|
||||
*/
|
||||
#define MR_CTRL_PIN_SET_MODE ((0x01|0x80) << 16) /**< Set pin mode */
|
||||
#define MR_CTL_PIN_SET_MODE ((0x01|0x80) << 16) /**< Set pin mode */
|
||||
|
||||
/**
|
||||
* @brief PIN number command.
|
||||
*/
|
||||
#define MR_CTRL_PIN_SET_NUMBER MR_CTRL_SET_OFFSET /**< Set pin number */
|
||||
#define MR_CTRL_PIN_GET_NUMBER MR_CTRL_GET_OFFSET /**< Get pin number */
|
||||
#define MR_CTL_PIN_SET_NUMBER MR_CTL_SET_OFFSET /**< Set pin number */
|
||||
#define MR_CTL_PIN_GET_NUMBER MR_CTL_GET_OFFSET /**< Get pin number */
|
||||
|
||||
/**
|
||||
* @brief PIN data type.
|
||||
@@ -6,7 +6,7 @@
|
||||
* @date 2023-10-20 MacRsh First version
|
||||
*/
|
||||
|
||||
#include "include/device/serial.h"
|
||||
#include "serial.h"
|
||||
|
||||
#ifdef MR_USING_SERIAL
|
||||
|
||||
@@ -88,7 +88,7 @@ static int mr_serial_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case MR_CTRL_SET_CONFIG:
|
||||
case MR_CTL_SET_CONFIG:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
@@ -103,7 +103,7 @@ static int mr_serial_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
}
|
||||
return MR_EINVAL;
|
||||
}
|
||||
case MR_CTRL_SET_RD_BUFSZ:
|
||||
case MR_CTL_SET_RD_BUFSZ:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
@@ -119,7 +119,7 @@ static int mr_serial_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
}
|
||||
return MR_EINVAL;
|
||||
}
|
||||
case MR_CTRL_SET_WR_BUFSZ:
|
||||
case MR_CTL_SET_WR_BUFSZ:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
@@ -136,7 +136,7 @@ static int mr_serial_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
return MR_EINVAL;
|
||||
}
|
||||
|
||||
case MR_CTRL_GET_CONFIG:
|
||||
case MR_CTL_GET_CONFIG:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
@@ -147,7 +147,7 @@ static int mr_serial_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
}
|
||||
return MR_EINVAL;
|
||||
}
|
||||
case MR_CTRL_GET_RD_BUFSZ:
|
||||
case MR_CTL_GET_RD_BUFSZ:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
@@ -156,7 +156,7 @@ static int mr_serial_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
}
|
||||
return MR_EINVAL;
|
||||
}
|
||||
case MR_CTRL_GET_WR_BUFSZ:
|
||||
case MR_CTL_GET_WR_BUFSZ:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
|
||||
24
device/spi.c
24
device/spi.c
@@ -6,12 +6,12 @@
|
||||
* @date 2023-11-01 MacRsh First version
|
||||
*/
|
||||
|
||||
#include "include/device/spi.h"
|
||||
#include "spi.h"
|
||||
|
||||
#ifdef MR_USING_SPI
|
||||
|
||||
#ifdef MR_USING_PIN
|
||||
#include "include/device/pin.h"
|
||||
#include "pin.h"
|
||||
#else
|
||||
#warning "Please define MR_USING_PIN. Otherwise SPI-CS will not work."
|
||||
#endif /* MR_USING_PIN */
|
||||
@@ -121,7 +121,7 @@ int mr_spi_bus_register(struct mr_spi_bus *spi_bus, const char *name, struct mr_
|
||||
spi_bus->hold = MR_FALSE;
|
||||
|
||||
/* Register the spi-bus */
|
||||
return mr_dev_register(&spi_bus->dev, name, Mr_Dev_Type_Spi, MR_SFLAG_RDWR, &ops, drv);
|
||||
return mr_dev_register(&spi_bus->dev, name, Mr_Dev_Type_SPI, MR_SFLAG_RDWR, &ops, drv);
|
||||
}
|
||||
|
||||
#ifdef MR_USING_PIN
|
||||
@@ -135,7 +135,7 @@ static void spi_dev_cs_configure(struct mr_spi_dev *spi_dev, int state)
|
||||
|
||||
if (spi_dev->cs_active != MR_SPI_CS_ACTIVE_NONE)
|
||||
{
|
||||
mr_dev_ioctl(desc, MR_CTRL_PIN_SET_NUMBER, mr_make_local(int, spi_dev->cs_pin));
|
||||
mr_dev_ioctl(desc, MR_CTL_PIN_SET_NUMBER, mr_make_local(int, spi_dev->cs_pin));
|
||||
|
||||
if (state == MR_ENABLE)
|
||||
{
|
||||
@@ -154,11 +154,11 @@ static void spi_dev_cs_configure(struct mr_spi_dev *spi_dev, int state)
|
||||
mode = MR_PIN_MODE_INPUT_DOWN;
|
||||
}
|
||||
}
|
||||
mr_dev_ioctl(desc, MR_CTRL_PIN_SET_MODE, &mode);
|
||||
mr_dev_ioctl(desc, MR_CTL_PIN_SET_MODE, &mode);
|
||||
mr_dev_write(desc, mr_make_local(uint8_t, !spi_dev->cs_active), sizeof(uint8_t));
|
||||
} else
|
||||
{
|
||||
mr_dev_ioctl(desc, MR_CTRL_PIN_SET_MODE, mr_make_local(int, MR_PIN_MODE_NONE));
|
||||
mr_dev_ioctl(desc, MR_CTL_PIN_SET_MODE, mr_make_local(int, MR_PIN_MODE_NONE));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -488,7 +488,7 @@ static int mr_spi_dev_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case MR_CTRL_SET_CONFIG:
|
||||
case MR_CTL_SET_CONFIG:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
@@ -523,7 +523,7 @@ static int mr_spi_dev_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
}
|
||||
return MR_EINVAL;
|
||||
}
|
||||
case MR_CTRL_SET_RD_BUFSZ:
|
||||
case MR_CTL_SET_RD_BUFSZ:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
@@ -540,7 +540,7 @@ static int mr_spi_dev_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
return MR_EINVAL;
|
||||
}
|
||||
|
||||
case MR_CTRL_GET_CONFIG:
|
||||
case MR_CTL_GET_CONFIG:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
@@ -551,7 +551,7 @@ static int mr_spi_dev_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
}
|
||||
return MR_EINVAL;
|
||||
}
|
||||
case MR_CTRL_GET_RD_BUFSZ:
|
||||
case MR_CTL_GET_RD_BUFSZ:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
@@ -561,7 +561,7 @@ static int mr_spi_dev_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
return MR_EINVAL;
|
||||
}
|
||||
|
||||
case MR_CTRL_SPI_TRANSFER:
|
||||
case MR_CTL_SPI_TRANSFER:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
@@ -643,7 +643,7 @@ int mr_spi_dev_register(struct mr_spi_dev *spi_dev, const char *name, int cs_pin
|
||||
spi_dev->cs_desc = -1;
|
||||
|
||||
/* Register the spi-device */
|
||||
return mr_dev_register(&spi_dev->dev, name, Mr_Dev_Type_Spi, MR_SFLAG_RDWR | MR_SFLAG_NONDRV, &ops, MR_NULL);
|
||||
return mr_dev_register(&spi_dev->dev, name, Mr_Dev_Type_SPI, MR_SFLAG_RDWR | MR_SFLAG_NONDRV, &ops, MR_NULL);
|
||||
}
|
||||
|
||||
#endif /* MR_USING_SPI */
|
||||
|
||||
@@ -81,7 +81,7 @@ struct mr_spi_config
|
||||
/**
|
||||
* @brief SPI transfer command.
|
||||
*/
|
||||
#define MR_CTRL_SPI_TRANSFER ((0x01|0x80) << 16) /**< Transfer */
|
||||
#define MR_CTL_SPI_TRANSFER ((0x01|0x80) << 16) /**< Transfer */
|
||||
|
||||
/**
|
||||
* @brief SPI transfer structure.
|
||||
@@ -96,8 +96,8 @@ struct mr_spi_transfer
|
||||
/**
|
||||
* @brief SPI register command.
|
||||
*/
|
||||
#define MR_CTRL_SPI_SET_REG MR_CTRL_SET_OFFSET /**< Set register */
|
||||
#define MR_CTRL_SPI_GET_REG MR_CTRL_GET_OFFSET /**< Get register */
|
||||
#define MR_CTL_SPI_SET_REG MR_CTL_SET_OFFSET /**< Set register */
|
||||
#define MR_CTL_SPI_GET_REG MR_CTL_GET_OFFSET /**< Get register */
|
||||
|
||||
/**
|
||||
* @brief SPI data type.
|
||||
@@ -6,7 +6,7 @@
|
||||
* @date 2023-11-15 MacRsh First version
|
||||
*/
|
||||
|
||||
#include "include/device/timer.h"
|
||||
#include "timer.h"
|
||||
|
||||
#ifdef MR_USING_TIMER
|
||||
|
||||
@@ -91,7 +91,7 @@ static int mr_timer_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case MR_CTRL_SET_CONFIG:
|
||||
case MR_CTL_SET_CONFIG:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
@@ -151,7 +151,7 @@ static int mr_timer_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
}
|
||||
return MR_EINVAL;
|
||||
}
|
||||
case MR_CTRL_TIMER_SET_CHANNEL_STATE:
|
||||
case MR_CTL_TIMER_SET_CHANNEL_STATE:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
@@ -184,7 +184,7 @@ static int mr_timer_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
|
||||
return MR_EINVAL;
|
||||
}
|
||||
|
||||
case MR_CTRL_TIMER_GET_CHANNEL_STATE:
|
||||
case MR_CTL_TIMER_GET_CHANNEL_STATE:
|
||||
{
|
||||
if (args != MR_NULL)
|
||||
{
|
||||
|
||||
@@ -51,10 +51,10 @@ struct mr_timer_config
|
||||
/**
|
||||
* @brief Timer channel mode command.
|
||||
*/
|
||||
#define MR_CTRL_TIMER_SET_CHANNEL_STATE ((0x01|0x80) << 16) /**< Set channel mode */
|
||||
#define MR_CTRL_TIMER_GET_CHANNEL_STATE ((0x01|0x00) << 16) /**< Get channel mode */
|
||||
#define MR_CTL_TIMER_SET_CHANNEL_STATE ((0x01|0x80) << 16) /**< Set channel mode */
|
||||
#define MR_CTL_TIMER_GET_CHANNEL_STATE ((0x01|0x00) << 16) /**< Get channel mode */
|
||||
|
||||
#define MR_CTRL_TIMER_SET_TIMING ((0x02|0x80) << 16) /**< Set timing */
|
||||
#define MR_CTL_TIMER_SET_TIMING ((0x02|0x80) << 16) /**< Set timing */
|
||||
|
||||
struct mr_timer_info
|
||||
{
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* @copyright (c) 2023, MR Development Team
|
||||
*
|
||||
* @license SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* @date 2023-11-10 MacRsh First version
|
||||
*/
|
||||
|
||||
#ifndef _MR_BOARD_H_
|
||||
#define _MR_BOARD_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define MR_USING_ADC1
|
||||
#define MR_USING_ADC2
|
||||
|
||||
#define MR_USING_DAC1
|
||||
|
||||
#define MR_USING_GPIOA
|
||||
#define MR_USING_GPIOB
|
||||
#define MR_USING_GPIOC
|
||||
#define MR_USING_GPIOD
|
||||
#define MR_USING_GPIOE
|
||||
|
||||
#define MR_USING_UART1
|
||||
#define MR_CFG_UART1_GROUP 1
|
||||
#define MR_USING_UART2
|
||||
#define MR_CFG_UART2_GROUP 1
|
||||
#define MR_USING_UART3
|
||||
#define MR_CFG_UART3_GROUP 1
|
||||
#define MR_USING_UART4
|
||||
#define MR_CFG_UART4_GROUP 1
|
||||
#define MR_USING_UART5
|
||||
#define MR_CFG_UART5_GROUP 1
|
||||
#define MR_USING_UART6
|
||||
#define MR_CFG_UART6_GROUP 1
|
||||
#define MR_USING_UART7
|
||||
#define MR_CFG_UART7_GROUP 1
|
||||
#define MR_USING_UART8
|
||||
#define MR_CFG_UART8_GROUP 1
|
||||
|
||||
#define MR_USING_SPI1
|
||||
#define MR_CFG_SPI1_GROUP 1
|
||||
#define MR_USING_SPI2
|
||||
#define MR_CFG_SPI2_GROUP 1
|
||||
#define MR_USING_SPI3
|
||||
#define MR_CFG_SPI3_GROUP 1
|
||||
|
||||
#define MR_USING_I2C1
|
||||
#define MR_CFG_I2C1_GROUP 1
|
||||
#define MR_USING_I2C2
|
||||
#define MR_CFG_I2C2_GROUP 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _MR_BOARD_H_ */
|
||||
@@ -32,11 +32,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef MR_USING_PIN
|
||||
#include "drv_gpio.h"
|
||||
#include "drv_pin.h"
|
||||
#endif
|
||||
|
||||
#ifdef MR_USING_SERIAL
|
||||
#include "drv_uart.h"
|
||||
#include "drv_serial.h"
|
||||
#endif
|
||||
|
||||
#ifdef MR_USING_SPI
|
||||
|
||||
12
include/mr_config.h
Normal file
12
include/mr_config.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef _MR_CONFIG_H_
|
||||
#define _MR_CONFIG_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _MR_CONFIG_H_ */
|
||||
@@ -14,9 +14,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mr_config.h"
|
||||
#include "mr_board.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -158,13 +156,13 @@ struct mr_avl
|
||||
*/
|
||||
enum mr_drv_type
|
||||
{
|
||||
Mr_Drv_Type_Pin = 0, /**< GPIO */
|
||||
Mr_Drv_Type_Spi, /**< SPI */
|
||||
Mr_Drv_Type_I2c, /**< I2C */
|
||||
Mr_Drv_Type_ADC, /**< ADC */
|
||||
Mr_Drv_Type_CAN, /**< CAN */
|
||||
Mr_Drv_Type_DAC, /**< DAC */
|
||||
Mr_Drv_Type_I2C, /**< I2C */
|
||||
Mr_Drv_Type_Pin, /**< PIN */
|
||||
Mr_Drv_Type_Serial, /**< SERIAL */
|
||||
Mr_Drv_Type_Can, /**< CAN */
|
||||
Mr_Drv_Type_Adc, /**< ADC */
|
||||
Mr_Drv_Type_Dac, /**< DAC */
|
||||
Mr_Drv_Type_SPI, /**< SPI */
|
||||
Mr_Drv_Type_Timer, /**< Timer */
|
||||
};
|
||||
|
||||
@@ -183,13 +181,13 @@ struct mr_drv
|
||||
*/
|
||||
enum mr_dev_type
|
||||
{
|
||||
Mr_Dev_Type_Pin = Mr_Drv_Type_Pin, /**< GPIO */
|
||||
Mr_Dev_Type_Spi = Mr_Drv_Type_Spi, /**< SPI */
|
||||
Mr_Dev_Type_I2c = Mr_Drv_Type_I2c, /**< I2C */
|
||||
Mr_Dev_Type_ADC = Mr_Drv_Type_ADC, /**< ADC */
|
||||
Mr_Dev_Type_CAN = Mr_Drv_Type_CAN, /**< CAN */
|
||||
Mr_Dev_Type_DAC = Mr_Drv_Type_DAC, /**< DAC */
|
||||
Mr_Dev_Type_I2C = Mr_Drv_Type_I2C, /**< I2C */
|
||||
Mr_Dev_Type_Pin = Mr_Drv_Type_Pin, /**< PIN */
|
||||
Mr_Dev_Type_Serial = Mr_Drv_Type_Serial, /**< SERIAL */
|
||||
Mr_Dev_Type_Can = Mr_Drv_Type_Can, /**< CAN */
|
||||
Mr_Dev_Type_Adc = Mr_Drv_Type_Adc, /**< ADC */
|
||||
Mr_Dev_Type_Dac = Mr_Drv_Type_Dac, /**< DAC */
|
||||
Mr_Dev_Type_SPI = Mr_Drv_Type_SPI, /**< SPI */
|
||||
Mr_Dev_Type_Timer = Mr_Drv_Type_Timer, /**< Timer */
|
||||
Mr_Dev_Type_Sensor, /**< Sensor */
|
||||
};
|
||||
@@ -205,23 +203,23 @@ struct mr_dev;
|
||||
/**
|
||||
* @brief Descriptor control command.
|
||||
*/
|
||||
#define MR_CTRL_SET_OFFSET ((0x01|0x80) << 24) /**< Set offset */
|
||||
#define MR_CTRL_SET_RD_CALL ((0x02|0x80) << 24) /**< Set read callback */
|
||||
#define MR_CTRL_SET_WR_CALL ((0x03|0x80) << 24) /**< Set write callback */
|
||||
#define MR_CTRL_SET_SLEEP ((0x04|0x80) << 24) /**< Set sleep */
|
||||
#define MR_CTRL_SET_WAKEUP ((0x05|0x80) << 24) /**< Set wakeup */
|
||||
#define MR_CTRL_SET_CONFIG ((0x06|0x80) << 24) /**< Set configuration */
|
||||
#define MR_CTRL_SET_RD_BUFSZ ((0x07|0x80) << 24) /**< Set read buffer size */
|
||||
#define MR_CTRL_SET_WR_BUFSZ ((0x08|0x80) << 24) /**< Set write buffer size */
|
||||
#define MR_CTL_SET_OFFSET ((0x01|0x80) << 24) /**< Set offset */
|
||||
#define MR_CTL_SET_RD_CALL ((0x02|0x80) << 24) /**< Set read callback */
|
||||
#define MR_CTL_SET_WR_CALL ((0x03|0x80) << 24) /**< Set write callback */
|
||||
#define MR_CTL_SET_SLEEP ((0x04|0x80) << 24) /**< Set sleep */
|
||||
#define MR_CTL_SET_WAKEUP ((0x05|0x80) << 24) /**< Set wakeup */
|
||||
#define MR_CTL_SET_CONFIG ((0x06|0x80) << 24) /**< Set configuration */
|
||||
#define MR_CTL_SET_RD_BUFSZ ((0x07|0x80) << 24) /**< Set read buffer size */
|
||||
#define MR_CTL_SET_WR_BUFSZ ((0x08|0x80) << 24) /**< Set write buffer size */
|
||||
|
||||
#define MR_CTRL_GET_OFFSET ((0x01|0x00) << 24) /**< Get offset */
|
||||
#define MR_CTRL_GET_RD_CALL ((0x02|0x00) << 24) /**< Get read callback */
|
||||
#define MR_CTRL_GET_WR_CALL ((0x03|0x00) << 24) /**< Get write callback */
|
||||
#define MR_CTRL_GET_SLEEP ((0x04|0x00) << 24) /**< Get sleep (reserved) */
|
||||
#define MR_CTRL_GET_WAKEUP ((0x05|0x00) << 24) /**< Get wakeup (reserved) */
|
||||
#define MR_CTRL_GET_CONFIG ((0x06|0x00) << 24) /**< Get configuration */
|
||||
#define MR_CTRL_GET_RD_BUFSZ ((0x07|0x00) << 24) /**< Get read buffer size */
|
||||
#define MR_CTRL_GET_WR_BUFSZ ((0x08|0x00) << 24) /**< Get write buffer size */
|
||||
#define MR_CTL_GET_OFFSET ((0x01|0x00) << 24) /**< Get offset */
|
||||
#define MR_CTL_GET_RD_CALL ((0x02|0x00) << 24) /**< Get read callback */
|
||||
#define MR_CTL_GET_WR_CALL ((0x03|0x00) << 24) /**< Get write callback */
|
||||
#define MR_CTL_GET_SLEEP ((0x04|0x00) << 24) /**< Get sleep (reserved) */
|
||||
#define MR_CTL_GET_WAKEUP ((0x05|0x00) << 24) /**< Get wakeup (reserved) */
|
||||
#define MR_CTL_GET_CONFIG ((0x06|0x00) << 24) /**< Get configuration */
|
||||
#define MR_CTL_GET_RD_BUFSZ ((0x07|0x00) << 24) /**< Get read buffer size */
|
||||
#define MR_CTL_GET_WR_BUFSZ ((0x08|0x00) << 24) /**< Get write buffer size */
|
||||
|
||||
/**
|
||||
* @brief ISR event.
|
||||
@@ -295,10 +293,10 @@ struct mr_dev
|
||||
|
||||
uint32_t type; /**< Device type */
|
||||
size_t ref_count; /**< Reference count */
|
||||
#ifdef MR_USING_RDWR_CTRL
|
||||
#ifdef MR_USING_RDWR_CTL
|
||||
uint32_t sflags; /**< Support flags */
|
||||
volatile uint32_t lflags; /**< Lock flags */
|
||||
#endif /* MR_USING_RDWR_CTRL */
|
||||
#endif /* MR_USING_RDWR_CTL */
|
||||
|
||||
struct
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ extern "C" {
|
||||
*
|
||||
* @param ex The condition to assert.
|
||||
*/
|
||||
#ifdef MR_USING_ASSERT
|
||||
#define mr_assert(ex) \
|
||||
do{ \
|
||||
if (!(ex)) \
|
||||
@@ -34,6 +35,9 @@ extern "C" {
|
||||
while(1); \
|
||||
} \
|
||||
} while(0)
|
||||
#else
|
||||
#define mr_assert(ex)
|
||||
#endif /* MR_USING_ASSERT */
|
||||
|
||||
/**
|
||||
* @brief This macro function logs a message.
|
||||
|
||||
@@ -24,7 +24,7 @@ int mr_hx711_register(struct mr_hx711 *hx711, const char *name, int sck_pin, int
|
||||
```c
|
||||
#define FILTER_BITS 4
|
||||
|
||||
mr_dev_ioctl(desc, MR_CTRL_HX711_SET_FILTER_BITS, mr_make_local(int, FILTER_BITS));
|
||||
mr_dev_ioctl(desc, MR_CTL_HX711_SET_FILTER_BITS, mr_make_local(int, FILTER_BITS));
|
||||
```
|
||||
|
||||
## 自校准
|
||||
@@ -32,7 +32,7 @@ mr_dev_ioctl(desc, MR_CTRL_HX711_SET_FILTER_BITS, mr_make_local(int, FILTER_BITS
|
||||
自校准零点,使用前请确保输入值稳定。
|
||||
|
||||
```c
|
||||
mr_dev_ioctl(desc, MR_CTRL_HX711_SET_SELF_CAL, MR_NULL);
|
||||
mr_dev_ioctl(desc, MR_CTL_HX711_SET_SELF_CAL, MR_NULL);
|
||||
```
|
||||
|
||||
## 读取数据
|
||||
@@ -67,10 +67,10 @@ int main(void)
|
||||
}
|
||||
|
||||
/* 设置滤波位数 */
|
||||
mr_dev_ioctl(desc, MR_CTRL_HX711_SET_FILTER_BITS, mr_make_local(int, HX711_FILTER_BITS));
|
||||
mr_dev_ioctl(desc, MR_CTL_HX711_SET_FILTER_BITS, mr_make_local(int, HX711_FILTER_BITS));
|
||||
|
||||
/* 自校准 */
|
||||
mr_dev_ioctl(desc, MR_CTRL_HX711_SET_SELF_CAL, MR_NULL);
|
||||
mr_dev_ioctl(desc, MR_CTL_HX711_SET_SELF_CAL, MR_NULL);
|
||||
|
||||
/* 读取数据 */
|
||||
uint32_t data = 0;
|
||||
|
||||
41
mr_config.h
41
mr_config.h
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* @copyright (c) 2023, MR Development Team
|
||||
*
|
||||
* @license SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* @date 2023-10-18 MacRsh First version
|
||||
*/
|
||||
|
||||
#ifndef _MR_CONFIG_H_
|
||||
#define _MR_CONFIG_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define MR_CFG_NAME_MAX (10)
|
||||
#define MR_CFG_DESC_MAX (32)
|
||||
|
||||
#define MR_USING_RDWR_CTRL
|
||||
#define MR_USING_ADC
|
||||
#define MR_USING_CAN
|
||||
#define MR_USING_DAC
|
||||
#define MR_USING_I2C
|
||||
#define MR_USING_PIN
|
||||
#define MR_USING_SERIAL
|
||||
#define MR_USING_SPI
|
||||
#define MR_USING_TIMER
|
||||
|
||||
#define MR_CFG_HEAP_SIZE (4 * 1024)
|
||||
#define MR_CFG_CONSOLE_NAME "uart1"
|
||||
#define MR_CFG_SERIAL_RD_BUFSZ (32)
|
||||
#define MR_CFG_SERIAL_WR_BUFSZ (0)
|
||||
#define MR_CFG_SPI_RD_BUFSZ (32)
|
||||
#define MR_CFG_I2C_RD_BUFSZ (32)
|
||||
#define MR_CFG_CAN_RD_BUFSZ (32)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _MR_CONFIG_H_ */
|
||||
Reference in New Issue
Block a user