1.底层接口新增返回值,增加超时判断。2.完善i2c机制,为软件i2c增加ack支持。
This commit is contained in:
@@ -61,7 +61,7 @@ struct mr_adc_ops
|
||||
{
|
||||
int (*configure)(struct mr_adc *adc, int state);
|
||||
int (*channel_configure)(struct mr_adc *adc, int channel, int state);
|
||||
uint32_t (*read)(struct mr_adc *adc, int channel);
|
||||
int (*read)(struct mr_adc *adc, int channel, uint32_t *data);
|
||||
};
|
||||
|
||||
int mr_adc_register(struct mr_adc *adc, const char *path, struct mr_drv *drv);
|
||||
|
||||
@@ -61,7 +61,7 @@ struct mr_dac_ops
|
||||
{
|
||||
int (*configure)(struct mr_dac *dac, int state);
|
||||
int (*channel_configure)(struct mr_dac *dac, int channel, int state);
|
||||
void (*write)(struct mr_dac *dac, int channel, uint32_t data);
|
||||
int (*write)(struct mr_dac *dac, int channel, uint32_t data);
|
||||
};
|
||||
|
||||
int mr_dac_register(struct mr_dac *dac, const char *path, struct mr_drv *drv);
|
||||
|
||||
@@ -99,10 +99,10 @@ struct mr_i2c_bus_ops
|
||||
{
|
||||
int (*configure)(struct mr_i2c_bus *i2c_bus, struct mr_i2c_config *config, int addr, int addr_bits);
|
||||
void (*start)(struct mr_i2c_bus *i2c_bus);
|
||||
void (*send_addr)(struct mr_i2c_bus *i2c_bus, int addr, int addr_bits);
|
||||
int (*send_addr)(struct mr_i2c_bus *i2c_bus, int addr, int addr_bits);
|
||||
void (*stop)(struct mr_i2c_bus *i2c_bus);
|
||||
uint8_t (*read)(struct mr_i2c_bus *i2c_bus, int ack_state);
|
||||
void (*write)(struct mr_i2c_bus *i2c_bus, uint8_t data);
|
||||
int (*read)(struct mr_i2c_bus *i2c_bus, uint8_t *data, int ack_state);
|
||||
int (*write)(struct mr_i2c_bus *i2c_bus, uint8_t data);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,8 +83,8 @@ struct mr_pin
|
||||
struct mr_pin_ops
|
||||
{
|
||||
int (*configure)(struct mr_pin *pin, int number, int mode);
|
||||
uint8_t (*read)(struct mr_pin *pin, int number);
|
||||
void (*write)(struct mr_pin *pin, int number, uint8_t value);
|
||||
int (*read)(struct mr_pin *pin, int number, uint8_t *value);
|
||||
int (*write)(struct mr_pin *pin, int number, uint8_t value);
|
||||
};
|
||||
|
||||
int mr_pin_register(struct mr_pin *pin, const char *path, struct mr_drv *drv);
|
||||
|
||||
@@ -87,8 +87,8 @@ struct mr_pwm_ops
|
||||
int (*configure)(struct mr_pwm *pwm, int state);
|
||||
int (*channel_configure)(struct mr_pwm *pwm, int channel, int state, int polarity);
|
||||
void (*start)(struct mr_pwm *pwm, uint32_t prescaler, uint32_t period);
|
||||
void (*write)(struct mr_pwm *pwm, int channel, uint32_t compare_value);
|
||||
uint32_t (*read)(struct mr_pwm *pwm, int channel);
|
||||
int (*read)(struct mr_pwm *pwm, int channel, uint32_t *compare_value);
|
||||
int (*write)(struct mr_pwm *pwm, int channel, uint32_t compare_value);
|
||||
};
|
||||
|
||||
int mr_pwm_register(struct mr_pwm *pwm, const char *path, struct mr_drv *drv, struct mr_pwm_info *info);
|
||||
|
||||
@@ -112,6 +112,7 @@ typedef uint8_t mr_serial_data_t; /**< Serial
|
||||
*/
|
||||
#define MR_ISR_SERIAL_RD_INT (MR_ISR_RD | (0x01)) /**< Read interrupt */
|
||||
#define MR_ISR_SERIAL_WR_INT (MR_ISR_WR | (0x02)) /**< Write interrupt */
|
||||
#define MR_ISR_SERIAL_RD_IDLE (MR_ISR_RD | (0x03)) /**< Read idle */
|
||||
|
||||
/**
|
||||
* @brief Serial structure.
|
||||
@@ -133,8 +134,8 @@ struct mr_serial
|
||||
struct mr_serial_ops
|
||||
{
|
||||
int (*configure)(struct mr_serial *serial, struct mr_serial_config *config);
|
||||
uint8_t (*read)(struct mr_serial *serial);
|
||||
void (*write)(struct mr_serial *serial, uint8_t data);
|
||||
int (*read)(struct mr_serial *serial, uint8_t *data);
|
||||
int (*write)(struct mr_serial *serial, uint8_t data);
|
||||
void (*start_tx)(struct mr_serial *serial);
|
||||
void (*stop_tx)(struct mr_serial *serial);
|
||||
};
|
||||
|
||||
@@ -36,13 +36,6 @@ extern "C" {
|
||||
#define MR_SPI_MODE_2 (2) /**< CPOL = 1, CPHA = 0 */
|
||||
#define MR_SPI_MODE_3 (3) /**< CPOL = 1, CPHA = 1 */
|
||||
|
||||
/**
|
||||
* @brief SPI data bits.
|
||||
*/
|
||||
#define MR_SPI_DATA_BITS_8 (8) /**< 8 bits data */
|
||||
#define MR_SPI_DATA_BITS_16 (16) /**< 16 bits data */
|
||||
#define MR_SPI_DATA_BITS_32 (32) /**< 32 bits data */
|
||||
|
||||
/**
|
||||
* @brief SPI bit order.
|
||||
*/
|
||||
@@ -64,7 +57,6 @@ extern "C" {
|
||||
3000000, \
|
||||
MR_SPI_HOST, \
|
||||
MR_SPI_MODE_0, \
|
||||
MR_SPI_DATA_BITS_8, \
|
||||
MR_SPI_BIT_ORDER_MSB, \
|
||||
MR_SPI_REG_BITS_8, \
|
||||
}
|
||||
@@ -77,7 +69,6 @@ struct mr_spi_config
|
||||
uint32_t baud_rate; /**< Baud rate */
|
||||
int host_slave; /**< Host/slave */
|
||||
int mode; /**< Mode */
|
||||
int data_bits; /**< Data bits */
|
||||
int bit_order; /**< Bit order */
|
||||
int reg_bits; /**< Register bits */
|
||||
};
|
||||
@@ -137,8 +128,8 @@ struct mr_spi_bus
|
||||
struct mr_spi_bus_ops
|
||||
{
|
||||
int (*configure)(struct mr_spi_bus *spi_bus, struct mr_spi_config *config);
|
||||
uint32_t (*read)(struct mr_spi_bus *spi_bus);
|
||||
void (*write)(struct mr_spi_bus *spi_bus, uint32_t data);
|
||||
int (*read)(struct mr_spi_bus *spi_bus, uint8_t *data);
|
||||
int (*write)(struct mr_spi_bus *spi_bus, uint8_t data);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -115,6 +115,7 @@ typedef void (*mr_init_fn_t)(void); /**< Auto in
|
||||
#define MR_EEXIST (-5) /**< Exists */
|
||||
#define MR_ENOTSUP (-6) /**< Operation not supported */
|
||||
#define MR_EINVAL (-7) /**< Invalid argument */
|
||||
#define MR_ETIMEOUT (-8) /**< Timeout */
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user