mirror of
https://github.com/Fishwaldo/bl_mcu_sdk.git
synced 2025-07-07 05:18:34 +00:00
[refactor] delete unused flag noun in device_register
This commit is contained in:
parent
66635f84f7
commit
50d130075c
74 changed files with 201 additions and 11419 deletions
|
@ -417,7 +417,7 @@ int ES8388_Set_Voice_Volume(int volume)
|
|||
*******************************************************************************/
|
||||
void ES8388_I2C_Init(void)
|
||||
{
|
||||
i2c_register(I2C0_INDEX, "i2c", DEVICE_OFLAG_RDWR);
|
||||
i2c_register(I2C0_INDEX, "i2c");
|
||||
es8388_i2c = device_find("i2c");
|
||||
|
||||
if (es8388_i2c) {
|
||||
|
|
|
@ -93,7 +93,7 @@ void spi0_init(void)
|
|||
if (spi0) {
|
||||
device_close(spi0);
|
||||
} else {
|
||||
spi_register(SPI0_INDEX, "spi0", DEVICE_OFLAG_RDWR);
|
||||
spi_register(SPI0_INDEX, "spi0");
|
||||
spi0 = device_find("spi0");
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ void spi0_init(void)
|
|||
if (dma_ch3) {
|
||||
device_close(dma_ch3);
|
||||
} else {
|
||||
dma_register(DMA0_CH3_INDEX, "dma0_ch3", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH3_INDEX, "dma0_ch3");
|
||||
dma_ch3 = device_find("dma0_ch3");
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ void spi0_init(void)
|
|||
if (dma_ch4) {
|
||||
device_close(dma_ch4);
|
||||
} else {
|
||||
dma_register(DMA0_CH4_INDEX, "dma0_ch4", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH4_INDEX, "dma0_ch4");
|
||||
dma_ch4 = device_find("dma0_ch4");
|
||||
}
|
||||
|
||||
|
|
|
@ -661,7 +661,7 @@ void cam_clk_out(void)
|
|||
|
||||
uint8_t image_sensor_init(BL_Fun_Type mjpeg_en, cam_device_t *cam_cfg, mjpeg_device_t *mjpeg_cfg)
|
||||
{
|
||||
i2c_register(I2C0_INDEX, "i2c", DEVICE_OFLAG_RDWR);
|
||||
i2c_register(I2C0_INDEX, "i2c");
|
||||
image_sensor_i2c = device_find("i2c");
|
||||
|
||||
if (image_sensor_i2c) {
|
||||
|
@ -836,7 +836,7 @@ void tr_timer_init(void)
|
|||
timer_user_cfg.timeout_val = 1000 * 1000; /* us */
|
||||
timer_user_cfg.comp_it = TIMER_COMP0_IT;
|
||||
|
||||
timer_register(TIMER_CH0_INDEX, "timer_ch0_comp2", DEVICE_OFLAG_RDWR);
|
||||
timer_register(TIMER_CH0_INDEX, "timer_ch0_comp2");
|
||||
|
||||
timer_ch0_comp2 = device_find("timer_ch0_comp2");
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ void bflb_platform_init(uint32_t baudrate)
|
|||
}
|
||||
|
||||
if (!uart_dbg_disable) {
|
||||
uart_register(board_get_debug_uart_index(), "debug_log", DEVICE_OFLAG_RDWR);
|
||||
uart_register(board_get_debug_uart_index(), "debug_log");
|
||||
struct device *uart = device_find("debug_log");
|
||||
|
||||
if (uart) {
|
||||
|
|
|
@ -90,6 +90,7 @@ void bflb_platform_printf(char *fmt, ...);
|
|||
void bflb_platform_print_set(uint8_t disable);
|
||||
uint8_t bflb_platform_print_get(void);
|
||||
void bflb_platform_dump(uint8_t *data, uint32_t len);
|
||||
uint32_t bflb_platform_get_log(uint8_t *data, uint32_t maxlen);
|
||||
void bflb_platform_deinit(void);
|
||||
|
||||
void bflb_platform_init_time(void);
|
||||
|
|
|
@ -43,7 +43,7 @@ uint8_t SD_SPI_Init(void)
|
|||
if (spi0) {
|
||||
device_close(spi0);
|
||||
} else {
|
||||
spi_register(SPI0_INDEX, "spi0", DEVICE_OFLAG_RDWR);
|
||||
spi_register(SPI0_INDEX, "spi0");
|
||||
spi0 = device_find("spi0");
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ uint8_t SD_SPI_Init(void)
|
|||
if (dma_ch3) {
|
||||
device_close(dma_ch3);
|
||||
} else {
|
||||
dma_register(DMA0_CH3_INDEX, "dma0_ch3", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH3_INDEX, "dma0_ch3");
|
||||
dma_ch3 = device_find("dma0_ch3");
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ uint8_t SD_SPI_Init(void)
|
|||
if (dma_ch4) {
|
||||
device_close(dma_ch4);
|
||||
} else {
|
||||
dma_register(DMA0_CH4_INDEX, "dma0_ch4", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH4_INDEX, "dma0_ch4");
|
||||
dma_ch4 = device_find("dma0_ch4");
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ void xpt2046_init(void)
|
|||
if (touch_spi) {
|
||||
device_close(touch_spi);
|
||||
} else {
|
||||
spi_register(SPI0_INDEX, "spi0", DEVICE_OFLAG_RDWR);
|
||||
spi_register(SPI0_INDEX, "spi0");
|
||||
touch_spi = device_find("spi0");
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void uart_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t s
|
|||
}
|
||||
void uart1_init(void)
|
||||
{
|
||||
uart_register(UART1_INDEX, "uart1", DEVICE_OFLAG_RDWR);
|
||||
uart_register(UART1_INDEX, "uart1");
|
||||
uart1 = device_find("uart1");
|
||||
|
||||
if (uart1) {
|
||||
|
@ -71,7 +71,7 @@ void uart1_init(void)
|
|||
device_control(uart1, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT | UART_RTO_IT));
|
||||
}
|
||||
|
||||
dma_register(DMA0_CH2_INDEX, "ch2", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH2_INDEX, "ch2");
|
||||
dma_ch2 = device_find("ch2");
|
||||
|
||||
if (dma_ch2) {
|
||||
|
|
|
@ -68,7 +68,7 @@ static void usb_dc_event_callback(struct device *dev, void *args, uint32_t size,
|
|||
}
|
||||
struct device *usb_dc_init(void)
|
||||
{
|
||||
usb_dc_register(USB_INDEX, "usb", DEVICE_OFLAG_RDWR);
|
||||
usb_dc_register(USB_INDEX, "usb");
|
||||
usb = device_find("usb");
|
||||
device_set_callback(usb, usb_dc_event_callback);
|
||||
device_open(usb, 0);
|
||||
|
|
|
@ -39,11 +39,8 @@ dlist_t device_head = DLIST_OBJECT_INIT(device_head);
|
|||
*
|
||||
* @return the error code, DEVICE_EOK on initialization successfully.
|
||||
*/
|
||||
int device_register(struct device *dev, const char *name, uint16_t flag)
|
||||
int device_register(struct device *dev, const char *name)
|
||||
{
|
||||
#define OBJECT_DEVICE_TYPE 0
|
||||
#define OBJECT_FLAG_DEFAULT 0
|
||||
|
||||
dlist_t *node;
|
||||
|
||||
dlist_for_each(node, &device_head)
|
||||
|
@ -56,7 +53,6 @@ int device_register(struct device *dev, const char *name, uint16_t flag)
|
|||
}
|
||||
}
|
||||
|
||||
dev->oflag = flag;
|
||||
strncpy(dev->name, name, NAME_MAX);
|
||||
|
||||
dlist_insert_after(&device_head, &(dev->list));
|
||||
|
|
|
@ -28,17 +28,13 @@
|
|||
|
||||
#define NAME_MAX 20 /* max device name*/
|
||||
|
||||
#define DEVICE_OFLAG_RDONLY 0x1000 /* open with read only */
|
||||
#define DEVICE_OFLAG_WRONLY 0x2000 /* open with write only */
|
||||
#define DEVICE_OFLAG_RDWR 0x3000 /* open with read and write */
|
||||
|
||||
#define DEVICE_OFLAG_DEFAULT 0x000 /* open with default */
|
||||
#define DEVICE_OFLAG_STREAM_TX 0x001 /* open with poll tx */
|
||||
#define DEVICE_OFLAG_STREAM_RX 0x002 /* open with poll rx */
|
||||
#define DEVICE_OFLAG_INT_TX 0x004 /* open with interrupt tx */
|
||||
#define DEVICE_OFLAG_INT_RX 0x008 /* open with interrupt rx */
|
||||
#define DEVICE_OFLAG_DMA_TX 0x010 /* open with dma tx */
|
||||
#define DEVICE_OFLAG_DMA_RX 0x020 /* open with dma rx */
|
||||
#define DEVICE_OFLAG_DEFAULT 0x040 /* open with default */
|
||||
|
||||
#define DEVICE_CTRL_SET_INT 0x01 /* set interrupt */
|
||||
#define DEVICE_CTRL_CLR_INT 0x02 /* clear interrupt */
|
||||
|
@ -47,12 +43,12 @@
|
|||
#define DEVICE_CTRL_SUSPEND 0x05 /* suspend device */
|
||||
#define DEVICE_CTRL_CONFIG 0x06 /* config device */
|
||||
#define DEVICE_CTRL_GET_CONFIG 0x07 /* get device configuration */
|
||||
#define DEVICE_CTRL_ATTACH_TX_DMA 0x08
|
||||
#define DEVICE_CTRL_ATTACH_RX_DMA 0x09
|
||||
#define DEVICE_CTRL_TX_DMA_SUSPEND 0x0a
|
||||
#define DEVICE_CTRL_RX_DMA_SUSPEND 0x0b
|
||||
#define DEVICE_CTRL_TX_DMA_RESUME 0x0c
|
||||
#define DEVICE_CTRL_RX_DMA_RESUME 0x0d
|
||||
#define DEVICE_CTRL_ATTACH_TX_DMA 0x08 /* deivce link tx dma */
|
||||
#define DEVICE_CTRL_ATTACH_RX_DMA 0x09 /* deivce link rx dma */
|
||||
#define DEVICE_CTRL_TX_DMA_SUSPEND 0x0a /* deivce suspend tx dma */
|
||||
#define DEVICE_CTRL_RX_DMA_SUSPEND 0x0b /* deivce suspend rx dma */
|
||||
#define DEVICE_CTRL_TX_DMA_RESUME 0x0c /* deivce resume tx dma */
|
||||
#define DEVICE_CTRL_RX_DMA_RESUME 0x0d /* deivce resume rx dma */
|
||||
#define DEVICE_CTRL_RESVD1 0x0E
|
||||
#define DEVICE_CTRL_RESVD2 0x0F
|
||||
|
||||
|
@ -89,11 +85,14 @@ enum device_class_type {
|
|||
DEVICE_CLASS_SPI,
|
||||
DEVICE_CLASS_I2C,
|
||||
DEVICE_CLASS_ADC,
|
||||
DEVICE_CLASS_DAC,
|
||||
DEVICE_CLASS_DMA,
|
||||
DEVICE_CLASS_TIMER,
|
||||
DEVICE_CLASS_PWM,
|
||||
DEVICE_CLASS_QDEC,
|
||||
DEVICE_CLASS_SDIO,
|
||||
DEVICE_CLASS_USB,
|
||||
DEVICE_CLASS_RMII,
|
||||
DEVICE_CLASS_I2S,
|
||||
DEVICE_CLASS_CAMERA,
|
||||
DEVICE_CLASS_SEC_HASH,
|
||||
|
@ -123,7 +122,7 @@ struct device {
|
|||
void *handle;
|
||||
};
|
||||
|
||||
int device_register(struct device *dev, const char *name, uint16_t flag);
|
||||
int device_register(struct device *dev, const char *name);
|
||||
int device_unregister(const char *name);
|
||||
struct device *device_find(const char *name);
|
||||
int device_open(struct device *dev, uint16_t oflag);
|
||||
|
|
|
@ -184,7 +184,8 @@ typedef struct dma_device {
|
|||
|
||||
#define DMA_DEV(dev) ((dma_device_t *)dev)
|
||||
|
||||
int dma_register(enum dma_index_type, const char *name, uint16_t flag);
|
||||
int dma_register(enum dma_index_type, const char *name);
|
||||
int dma_allocate_register(const char *name);
|
||||
int dma_reload(struct device *dev, uint32_t src_addr, uint32_t dst_addr, uint32_t transfer_size);
|
||||
int dma_allocate_register(const char *name, uint16_t flag);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -68,15 +68,6 @@ typedef enum {
|
|||
GPIO_PIN_26,
|
||||
GPIO_PIN_27,
|
||||
GPIO_PIN_28,
|
||||
GPIO_PIN_29,
|
||||
GPIO_PIN_30,
|
||||
GPIO_PIN_31,
|
||||
GPIO_PIN_32,
|
||||
GPIO_PIN_33,
|
||||
GPIO_PIN_34,
|
||||
GPIO_PIN_35,
|
||||
GPIO_PIN_36,
|
||||
GPIO_PIN_37,
|
||||
GPIO_PIN_MAX,
|
||||
} gpio_pin_type;
|
||||
|
||||
|
@ -95,12 +86,6 @@ typedef enum {
|
|||
#define GPIO_SYNC_HIGH_LEVEL_INT_MODE 12
|
||||
#define GPIO_SYNC_LOW_LEVEL_INT_MODE 13
|
||||
|
||||
typedef struct gpio_device {
|
||||
struct device parent;
|
||||
} gpio_device_t;
|
||||
|
||||
void gpio_register(const char *name, uint16_t flag);
|
||||
|
||||
void gpio_set_mode(uint32_t pin, uint32_t mode);
|
||||
void gpio_write(uint32_t pin, uint32_t value);
|
||||
void gpio_toggle(uint32_t pin);
|
||||
|
|
|
@ -147,6 +147,6 @@ typedef struct uart_device {
|
|||
void *rx_dma;
|
||||
} uart_device_t;
|
||||
|
||||
int uart_register(enum uart_index_type index, const char *name, uint16_t flag);
|
||||
int uart_register(enum uart_index_type index, const char *name);
|
||||
|
||||
#endif
|
|
@ -173,7 +173,7 @@ int dma_close(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int dma_register(enum dma_index_type index, const char *name, uint16_t flag)
|
||||
int dma_register(enum dma_index_type index, const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
|
@ -193,7 +193,7 @@ int dma_register(enum dma_index_type index, const char *name, uint16_t flag)
|
|||
dev->type = DEVICE_CLASS_DMA;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, flag);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
|
||||
static BL_Err_Type dma_scan_unregister_device(uint8_t *allocate_index)
|
||||
|
@ -227,7 +227,7 @@ static BL_Err_Type dma_scan_unregister_device(uint8_t *allocate_index)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
int dma_allocate_register(const char *name, uint16_t flag)
|
||||
int dma_allocate_register(const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
uint8_t index;
|
||||
|
@ -252,7 +252,7 @@ int dma_allocate_register(const char *name, uint16_t flag)
|
|||
dev->type = DEVICE_CLASS_DMA;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, flag);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "bl602_gpio.h"
|
||||
#include "hal_gpio.h"
|
||||
|
||||
gpio_device_t gpio_device;
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
|
@ -193,22 +192,4 @@ void gpio_irq_enable(uint32_t pin, uint8_t enabled)
|
|||
} else {
|
||||
GLB_GPIO_IntMask(pin, MASK);
|
||||
}
|
||||
}
|
||||
|
||||
void pin_register(const char *name, uint16_t flag)
|
||||
{
|
||||
struct device *dev;
|
||||
dev = &(gpio_device.parent);
|
||||
|
||||
dev->open = NULL;
|
||||
dev->close = NULL;
|
||||
dev->control = NULL;
|
||||
dev->write = NULL;
|
||||
dev->read = NULL;
|
||||
|
||||
dev->status = DEVICE_UNREGISTER;
|
||||
dev->type = DEVICE_CLASS_GPIO;
|
||||
dev->handle = NULL;
|
||||
|
||||
device_register(dev, name, flag);
|
||||
}
|
|
@ -223,14 +223,12 @@ int uart_control(struct device *dev, int cmd, void *args)
|
|||
if (uart_device->id == UART0_ID) {
|
||||
Interrupt_Handler_Register(UART0_IRQn, UART0_IRQ);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef BSP_USING_UART1
|
||||
|
||||
if (uart_device->id == UART1_ID) {
|
||||
Interrupt_Handler_Register(UART1_IRQn, UART1_IRQ);
|
||||
}
|
||||
|
||||
#endif
|
||||
/* Enable uart */
|
||||
UART_Enable(uart_device->id, UART_TXRX);
|
||||
|
@ -289,9 +287,10 @@ int uart_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t si
|
|||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return UART_SendData(uart_device->id, (uint8_t *)buffer, size);
|
||||
} else if (dev->oflag & DEVICE_OFLAG_INT_TX) {
|
||||
return -2;
|
||||
} else
|
||||
return UART_SendData(uart_device->id, (uint8_t *)buffer, size);
|
||||
}
|
||||
/**
|
||||
* @brief
|
||||
|
@ -312,9 +311,12 @@ int uart_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size)
|
|||
if (!dma_ch) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
} else if (dev->oflag & DEVICE_OFLAG_INT_RX) {
|
||||
return -2;
|
||||
} else {
|
||||
return UART_ReceiveData(uart_device->id, (uint8_t *)buffer, size);
|
||||
}
|
||||
|
||||
return UART_ReceiveData(uart_device->id, (uint8_t *)buffer, size);
|
||||
}
|
||||
/**
|
||||
* @brief
|
||||
|
@ -324,7 +326,7 @@ int uart_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size)
|
|||
* @param flag
|
||||
* @return int
|
||||
*/
|
||||
int uart_register(enum uart_index_type index, const char *name, uint16_t flag)
|
||||
int uart_register(enum uart_index_type index, const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
|
@ -344,7 +346,7 @@ int uart_register(enum uart_index_type index, const char *name, uint16_t flag)
|
|||
dev->type = DEVICE_CLASS_UART;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, flag);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
/**
|
||||
* @brief
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -158,7 +158,7 @@ typedef struct adc_device {
|
|||
|
||||
#define ADC_DEV(dev) ((adc_device_t *)dev)
|
||||
|
||||
int adc_register(enum adc_index_type index, const char *name, uint16_t flag);
|
||||
int adc_register(enum adc_index_type index, const char *name);
|
||||
int adc_trim_tsen(uint16_t *tsen_offset);
|
||||
float adc_get_tsen(uint16_t tsen_offset);
|
||||
|
||||
|
|
|
@ -63,6 +63,6 @@ typedef struct dac_device {
|
|||
|
||||
#define DAC_DEV(dev) ((adc_device_t *)dev)
|
||||
|
||||
int dac_register(enum dac_index_type index, const char *name, uint16_t flag);
|
||||
int dac_register(enum dac_index_type index, const char *name);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -192,7 +192,8 @@ typedef struct dma_device {
|
|||
|
||||
#define DMA_DEV(dev) ((dma_device_t *)dev)
|
||||
|
||||
int dma_register(enum dma_index_type, const char *name, uint16_t flag);
|
||||
int dma_register(enum dma_index_type, const char *name);
|
||||
int dma_allocate_register(const char *name);
|
||||
int dma_reload(struct device *dev, uint32_t src_addr, uint32_t dst_addr, uint32_t transfer_size);
|
||||
int dma_allocate_register(const char *name, uint16_t flag);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,13 +24,18 @@
|
|||
#define __HAL_FLASH__H__
|
||||
|
||||
#include "drv_device.h"
|
||||
#include "bl702_sflash.h"
|
||||
|
||||
#define FLASH_NOT_DETECT 0x10
|
||||
|
||||
int flash_init(void);
|
||||
int flash_read_jedec_id(uint8_t *data);
|
||||
BL_Err_Type flash_read_via_xip(uint32_t addr, uint8_t *data, uint32_t len);
|
||||
BL_Err_Type flash_read(uint32_t addr, uint8_t *data, uint32_t len);
|
||||
BL_Err_Type flash_write(uint32_t addr, uint8_t *data, uint32_t len);
|
||||
BL_Err_Type flash_erase(uint32_t startaddr, uint32_t len);
|
||||
BL_Err_Type flash_set_cache(uint8_t cont_read, uint8_t cache_enable, uint8_t cache_way_disable, uint32_t flash_offset);
|
||||
|
||||
#define BL_FLASH_XIP_BASE BL702_FLASH_XIP_BASE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -77,12 +77,6 @@ enum gpio_pin_type {
|
|||
#define GPIO_SYNC_LOW_LEVEL_INT_MODE 13
|
||||
#define GPIO_HZ_MODE 14
|
||||
|
||||
typedef struct gpio_device {
|
||||
struct device parent;
|
||||
} gpio_device_t;
|
||||
|
||||
void gpio_register(const char *name, uint16_t flag);
|
||||
|
||||
void gpio_set_mode(uint32_t pin, uint32_t mode);
|
||||
void gpio_write(uint32_t pin, uint32_t value);
|
||||
void gpio_toggle(uint32_t pin);
|
||||
|
|
|
@ -61,7 +61,7 @@ typedef struct i2c_device {
|
|||
|
||||
#define I2C_DEV(dev) ((i2c_device_t *)dev)
|
||||
|
||||
int i2c_register(enum i2c_index_type index, const char *name, uint16_t flag);
|
||||
int i2c_register(enum i2c_index_type index, const char *name);
|
||||
int i2c_transfer(struct device *dev, i2c_msg_t msgs[], uint32_t num);
|
||||
|
||||
#endif
|
|
@ -109,6 +109,6 @@ typedef struct i2s_device {
|
|||
|
||||
#define I2S_DEV(dev) ((i2s_device_t *)dev)
|
||||
|
||||
int i2s_register(enum i2s_index_type index, const char *name, uint16_t flag);
|
||||
int i2s_register(enum i2s_index_type index, const char *name);
|
||||
|
||||
#endif
|
|
@ -78,6 +78,6 @@ typedef struct pwm_device {
|
|||
|
||||
#define PWM_DEV(dev) ((pwm_device_t *)dev)
|
||||
|
||||
int pwm_register(enum pwm_index_type index, const char *name, uint16_t flag);
|
||||
int pwm_register(enum pwm_index_type index, const char *name);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -47,6 +47,7 @@ typedef struct sec_hash_device {
|
|||
uint8_t type; /*!< Sha has feed data */
|
||||
} sec_hash_device_t;
|
||||
|
||||
int sec_hash_register(enum sec_hash_index_type index, const char *name, uint16_t flag);
|
||||
int sec_hash_register(enum sec_hash_index_type index, const char *name);
|
||||
int sec_hash_sha256_register(enum sec_hash_index_type index, const char *name);
|
||||
|
||||
#endif
|
|
@ -96,7 +96,7 @@ typedef struct spi_device {
|
|||
|
||||
#define SPI_DEV(dev) ((spi_device_t *)dev)
|
||||
|
||||
int spi_register(enum spi_index_type index, const char *name, uint16_t flag);
|
||||
int spi_register(enum spi_index_type index, const char *name);
|
||||
|
||||
int spi_transmit(struct device *dev, void *buffer, uint32_t size, uint8_t type);
|
||||
int spi_receive(struct device *dev, void *buffer, uint32_t size, uint8_t type);
|
||||
|
|
|
@ -91,6 +91,6 @@ typedef struct timer_device {
|
|||
|
||||
#define TIMER_DEV(dev) ((timer_device_t *)dev)
|
||||
|
||||
int timer_register(enum timer_index_type index, const char *name, uint16_t flag);
|
||||
int timer_register(enum timer_index_type index, const char *name);
|
||||
|
||||
#endif
|
|
@ -116,6 +116,6 @@ typedef struct uart_device {
|
|||
|
||||
#define UART_DEV(dev) ((uart_device_t *)dev)
|
||||
|
||||
int uart_register(enum uart_index_type index, const char *name, uint16_t flag);
|
||||
int uart_register(enum uart_index_type index, const char *name);
|
||||
|
||||
#endif
|
|
@ -203,7 +203,7 @@ typedef struct usb_dc_device {
|
|||
void *rx_dma;
|
||||
} usb_dc_device_t;
|
||||
|
||||
int usb_dc_register(enum usb_index_type index, const char *name, uint16_t flag);
|
||||
int usb_dc_register(enum usb_index_type index, const char *name);
|
||||
|
||||
int usb_dc_set_dev_address(const uint8_t addr);
|
||||
int usb_dc_ep_open(struct device *dev, const struct usb_dc_ep_cfg *ep_cfg);
|
||||
|
|
|
@ -34,6 +34,45 @@ static adc_device_t adcx_device[ADC_MAX_INDEX] = {
|
|||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Check whether Channel Corresponding IO is configed success by Board System
|
||||
*
|
||||
* @param pos_list pos channel list
|
||||
* @param neg_list negative channel list
|
||||
* @param channelNum channel number
|
||||
*/
|
||||
uint8_t adc_check_channel_status(uint8_t *pos_list, uint8_t *neg_list, uint16_t channelNum)
|
||||
{
|
||||
uint16_t i = 0;
|
||||
|
||||
uint8_t channel_io_reference_table[] = {
|
||||
GPIO_PIN_8, /* CH0 IO */
|
||||
GPIO_PIN_15, /* CH1 IO */
|
||||
GPIO_PIN_17, /* CH2 IO */
|
||||
GPIO_PIN_11, /* CH3 IO */
|
||||
GPIO_PIN_12, /* CH4 IO */
|
||||
GPIO_PIN_14, /* CH5 IO */
|
||||
GPIO_PIN_7, /* CH6 IO */
|
||||
GPIO_PIN_9, /* CH7 IO */
|
||||
GPIO_PIN_18, /* CH8 IO */
|
||||
GPIO_PIN_19, /* CH9 IO */
|
||||
GPIO_PIN_20, /* CH10 IO */
|
||||
GPIO_PIN_21, /* CH11 IO */
|
||||
|
||||
};
|
||||
|
||||
for (i = 0; i < channelNum; i++) {
|
||||
if (pos_list[i] > ADC_CHANNEL11) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (GLB_GPIO_Get_Fun(channel_io_reference_table[pos_list[i]]) != GPIO_FUN_ANALOG) {
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
|
@ -103,45 +142,6 @@ int adc_close(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check whether Channel Corresponding IO is configed success by Board System
|
||||
*
|
||||
* @param pos_list pos channel list
|
||||
* @param neg_list negative channel list
|
||||
* @param channelNum channel number
|
||||
*/
|
||||
uint8_t adc_check_channel_status(uint8_t *pos_list, uint8_t *neg_list, uint16_t channelNum)
|
||||
{
|
||||
uint16_t i = 0;
|
||||
|
||||
uint8_t channel_io_reference_table[] = {
|
||||
GPIO_PIN_8, /* CH0 IO */
|
||||
GPIO_PIN_15, /* CH1 IO */
|
||||
GPIO_PIN_17, /* CH2 IO */
|
||||
GPIO_PIN_11, /* CH3 IO */
|
||||
GPIO_PIN_12, /* CH4 IO */
|
||||
GPIO_PIN_14, /* CH5 IO */
|
||||
GPIO_PIN_7, /* CH6 IO */
|
||||
GPIO_PIN_9, /* CH7 IO */
|
||||
GPIO_PIN_18, /* CH8 IO */
|
||||
GPIO_PIN_19, /* CH9 IO */
|
||||
GPIO_PIN_20, /* CH10 IO */
|
||||
GPIO_PIN_21, /* CH11 IO */
|
||||
|
||||
};
|
||||
|
||||
for (i = 0; i < channelNum; i++) {
|
||||
if (pos_list[i] > ADC_CHANNEL11) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (GLB_GPIO_Get_Fun(channel_io_reference_table[pos_list[i]]) != GPIO_FUN_ANALOG) {
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
|
@ -268,7 +268,7 @@ float adc_get_tsen(uint16_t tsen_offset)
|
|||
* @param adc_user_cfg
|
||||
* @return int
|
||||
*/
|
||||
int adc_register(enum adc_index_type index, const char *name, uint16_t flag)
|
||||
int adc_register(enum adc_index_type index, const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
|
@ -288,7 +288,7 @@ int adc_register(enum adc_index_type index, const char *name, uint16_t flag)
|
|||
dev->type = DEVICE_CLASS_ADC;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, flag);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,10 +25,11 @@
|
|||
#include "bl702_glb.h"
|
||||
#include "hal_cam.h"
|
||||
|
||||
#ifdef BSP_USING_CAM
|
||||
static intCallback_Type *camIntCbfArra[CAM_INT_ALL] = { NULL };
|
||||
|
||||
void CAMERA_IRQ(void);
|
||||
|
||||
#endif
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
|
@ -57,7 +58,9 @@ void cam_init(cam_device_t *cam_cfg, uint16_t oflag)
|
|||
CAM_Init(&camera_cfg);
|
||||
|
||||
if (oflag == DEVICE_OFLAG_INT) {
|
||||
#ifdef BSP_USING_CAM
|
||||
Interrupt_Handler_Register(CAM_IRQn, CAMERA_IRQ);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ void peripheral_clock_init(void)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_QDEC) || defined(BSP_USING_KEYSCAN)
|
||||
#if defined(BSP_USING_QDEC0) || defined(BSP_USING_QDEC1) || defined(BSP_USING_QDEC2) || defined(BSP_USING_KEYSCAN)
|
||||
#if BSP_QDEC_KEYSCAN_CLOCK_SOURCE == ROOT_CLOCK_SOURCE_32K_CLK
|
||||
GLB_Set_QDEC_CLK(GLB_QDEC_CLK_F32K, BSP_QDEC_KEYSCAN_CLOCK_DIV);
|
||||
#elif BSP_QDEC_KEYSCAN_CLOCK_SOURCE == ROOT_CLOCK_SOURCE_XCLK
|
||||
|
|
|
@ -219,7 +219,7 @@ int dac_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int dac_register(enum dac_index_type index, const char *name, uint16_t flag)
|
||||
int dac_register(enum dac_index_type index, const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
|
@ -236,10 +236,10 @@ int dac_register(enum dac_index_type index, const char *name, uint16_t flag)
|
|||
dev->read = NULL;
|
||||
|
||||
dev->status = DEVICE_UNREGISTER;
|
||||
dev->type = DEVICE_CLASS_ADC;
|
||||
dev->type = DEVICE_CLASS_DAC;
|
||||
dev->handle = NULL;
|
||||
|
||||
device_register(dev, name, flag);
|
||||
device_register(dev, name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ int dma_close(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int dma_register(enum dma_index_type index, const char *name, uint16_t flag)
|
||||
int dma_register(enum dma_index_type index, const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
|
@ -190,7 +190,7 @@ int dma_register(enum dma_index_type index, const char *name, uint16_t flag)
|
|||
dev->type = DEVICE_CLASS_DMA;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, flag);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
|
||||
static BL_Err_Type dma_scan_unregister_device(uint8_t *allocate_index)
|
||||
|
@ -224,7 +224,7 @@ static BL_Err_Type dma_scan_unregister_device(uint8_t *allocate_index)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
int dma_allocate_register(const char *name, uint16_t flag)
|
||||
int dma_allocate_register(const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
uint8_t index;
|
||||
|
@ -249,7 +249,7 @@ int dma_allocate_register(const char *name, uint16_t flag)
|
|||
dev->type = DEVICE_CLASS_DMA;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, flag);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -286,8 +286,20 @@ int dma_reload(struct device *dev, uint32_t src_addr, uint32_t dst_addr, uint32_
|
|||
dma_ctrl_cfg.bits.DI = 0;
|
||||
}
|
||||
|
||||
dma_ctrl_cfg.bits.SBSize = dma_device->src_burst_size;
|
||||
dma_ctrl_cfg.bits.DBSize = dma_device->dst_burst_size;
|
||||
if (dma_device->direction == DMA_MEMORY_TO_MEMORY) {
|
||||
switch (dma_device->src_width) {
|
||||
case DMA_TRANSFER_WIDTH_8BIT:
|
||||
dma_device->src_burst_size = DMA_BURST_16BYTE;
|
||||
case DMA_TRANSFER_WIDTH_16BIT:
|
||||
dma_device->src_burst_size = DMA_BURST_8BYTE;
|
||||
case DMA_TRANSFER_WIDTH_32BIT:
|
||||
dma_device->src_burst_size = DMA_BURST_4BYTE;
|
||||
}
|
||||
} else {
|
||||
dma_ctrl_cfg.bits.SBSize = dma_device->src_burst_size;
|
||||
dma_ctrl_cfg.bits.DBSize = dma_device->dst_burst_size;
|
||||
}
|
||||
|
||||
dma_ctrl_cfg.bits.SWidth = dma_device->src_width;
|
||||
dma_ctrl_cfg.bits.DWidth = dma_device->dst_width;
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
#include "hal_gpio.h"
|
||||
#include "drv_mmheap.h"
|
||||
|
||||
static gpio_device_t gpio_device;
|
||||
|
||||
static void GPIO_IRQ(void);
|
||||
|
||||
struct gpio_int_cfg_private {
|
||||
|
@ -198,24 +196,6 @@ void gpio_irq_enable(uint32_t pin, uint8_t enabled)
|
|||
}
|
||||
}
|
||||
|
||||
void pin_register(const char *name, uint16_t flag)
|
||||
{
|
||||
struct device *dev;
|
||||
dev = &(gpio_device.parent);
|
||||
|
||||
dev->open = NULL;
|
||||
dev->close = NULL;
|
||||
dev->control = NULL;
|
||||
dev->write = NULL;
|
||||
dev->read = NULL;
|
||||
|
||||
dev->status = DEVICE_UNREGISTER;
|
||||
dev->type = DEVICE_CLASS_GPIO;
|
||||
dev->handle = NULL;
|
||||
|
||||
device_register(dev, name, flag);
|
||||
}
|
||||
|
||||
static void GPIO_IRQ(void)
|
||||
{
|
||||
slist_t *i;
|
||||
|
|
|
@ -108,7 +108,7 @@ int i2c_open(struct device *dev, uint16_t oflag)
|
|||
* @param flag
|
||||
* @return int
|
||||
*/
|
||||
int i2c_register(enum i2c_index_type index, const char *name, uint16_t flag)
|
||||
int i2c_register(enum i2c_index_type index, const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
|
@ -128,7 +128,7 @@ int i2c_register(enum i2c_index_type index, const char *name, uint16_t flag)
|
|||
dev->type = DEVICE_CLASS_I2C;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, flag);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
/**
|
||||
* @brief
|
||||
|
|
|
@ -222,7 +222,11 @@ int i2s_open(struct device *dev, uint16_t oflag)
|
|||
I2S_Disable();
|
||||
I2S_Init(&i2sCfg);
|
||||
I2S_FifoConfig(&fifoCfg);
|
||||
I2S_Enable(I2S_ROLE_MASTER);
|
||||
|
||||
if (i2s_device->iis_mode == I2S_MODE_MASTER)
|
||||
I2S_Enable(I2S_ROLE_MASTER);
|
||||
else if (i2s_device->iis_mode == I2S_MODE_SLAVE)
|
||||
I2S_Enable(I2S_ROLE_SLAVE);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -352,7 +356,7 @@ int i2s_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size)
|
|||
}
|
||||
}
|
||||
|
||||
int i2s_register(enum i2s_index_type index, const char *name, uint16_t flag)
|
||||
int i2s_register(enum i2s_index_type index, const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
|
@ -372,7 +376,7 @@ int i2s_register(enum i2s_index_type index, const char *name, uint16_t flag)
|
|||
dev->type = DEVICE_CLASS_I2S;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, flag);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
|
||||
void i2s_isr(i2s_device_t *handle)
|
||||
|
|
|
@ -145,7 +145,7 @@ int keyscan_register(enum keyscan_index_type index, const char *name)
|
|||
dev->type = DEVICE_CLASS_KEYSCAN;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, 0);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
|
||||
#if defined(BSP_USING_KEYSCAN)
|
||||
|
|
|
@ -138,7 +138,7 @@ int pwm_control(struct device *dev, int cmd, void *args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int pwm_register(enum pwm_index_type index, const char *name, uint16_t flag)
|
||||
int pwm_register(enum pwm_index_type index, const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
|
@ -158,7 +158,7 @@ int pwm_register(enum pwm_index_type index, const char *name, uint16_t flag)
|
|||
dev->type = DEVICE_CLASS_PWM;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, flag);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
|
||||
static void pwm_isr(pwm_device_t *handle)
|
||||
|
|
|
@ -185,7 +185,7 @@ int sec_hash_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size)
|
|||
* @param flag
|
||||
* @return int
|
||||
*/
|
||||
static int sec_hash_sha_register(enum sec_hash_index_type index, enum sec_hash_type type, const char *name, uint16_t flag)
|
||||
static int sec_hash_sha_register(enum sec_hash_index_type index, enum sec_hash_type type, const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
|
@ -206,7 +206,7 @@ static int sec_hash_sha_register(enum sec_hash_index_type index, enum sec_hash_t
|
|||
dev->type = DEVICE_CLASS_SEC_HASH;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, flag);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -217,9 +217,9 @@ static int sec_hash_sha_register(enum sec_hash_index_type index, enum sec_hash_t
|
|||
* @param flag
|
||||
* @return int
|
||||
*/
|
||||
int sec_hash_sha256_register(enum sec_hash_index_type index, const char *name, uint16_t flag)
|
||||
int sec_hash_sha256_register(enum sec_hash_index_type index, const char *name)
|
||||
{
|
||||
return sec_hash_sha_register(index, SEC_HASH_SHA256, name, flag);
|
||||
return sec_hash_sha_register(index, SEC_HASH_SHA256, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -230,9 +230,9 @@ int sec_hash_sha256_register(enum sec_hash_index_type index, const char *name, u
|
|||
* @param flag
|
||||
* @return int
|
||||
*/
|
||||
int sec_hash_sha224_register(enum sec_hash_index_type index, const char *name, uint16_t flag)
|
||||
int sec_hash_sha224_register(enum sec_hash_index_type index, const char *name)
|
||||
{
|
||||
return sec_hash_sha_register(index, SEC_HASH_SHA224, name, flag);
|
||||
return sec_hash_sha_register(index, SEC_HASH_SHA224, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -329,7 +329,7 @@ int spi_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size)
|
|||
* @param flag
|
||||
* @return int
|
||||
*/
|
||||
int spi_register(enum spi_index_type index, const char *name, uint16_t flag)
|
||||
int spi_register(enum spi_index_type index, const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
|
@ -349,7 +349,7 @@ int spi_register(enum spi_index_type index, const char *name, uint16_t flag)
|
|||
dev->type = DEVICE_CLASS_SPI;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, flag);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -254,7 +254,7 @@ int timer_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size)
|
|||
* @return int
|
||||
*/
|
||||
|
||||
int timer_register(enum timer_index_type index, const char *name, uint16_t flag)
|
||||
int timer_register(enum timer_index_type index, const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
|
@ -274,7 +274,7 @@ int timer_register(enum timer_index_type index, const char *name, uint16_t flag)
|
|||
dev->type = DEVICE_CLASS_TIMER;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, flag);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
|
||||
void timer_isr(timer_device_t *handle)
|
||||
|
|
|
@ -315,11 +315,7 @@ int uart_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size)
|
|||
} else if (dev->oflag & DEVICE_OFLAG_INT_RX) {
|
||||
return -2;
|
||||
} else {
|
||||
uint32_t rx_len = 0;
|
||||
while (rx_len < size) {
|
||||
rx_len += UART_ReceiveData(uart_device->id, (uint8_t *)buffer + rx_len, size - rx_len);
|
||||
}
|
||||
return 0;
|
||||
return UART_ReceiveData(uart_device->id, (uint8_t *)buffer, size);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -330,7 +326,7 @@ int uart_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size)
|
|||
* @param flag
|
||||
* @return int
|
||||
*/
|
||||
int uart_register(enum uart_index_type index, const char *name, uint16_t flag)
|
||||
int uart_register(enum uart_index_type index, const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
|
@ -349,7 +345,7 @@ int uart_register(enum uart_index_type index, const char *name, uint16_t flag)
|
|||
dev->type = DEVICE_CLASS_UART;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, flag);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
/**
|
||||
* @brief
|
||||
|
|
|
@ -437,7 +437,7 @@ int usb_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size)
|
|||
* @param flag
|
||||
* @return int
|
||||
*/
|
||||
int usb_dc_register(enum usb_index_type index, const char *name, uint16_t flag)
|
||||
int usb_dc_register(enum usb_index_type index, const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
|
@ -457,7 +457,7 @@ int usb_dc_register(enum usb_index_type index, const char *name, uint16_t flag)
|
|||
dev->type = DEVICE_CLASS_USB;
|
||||
dev->handle = NULL;
|
||||
|
||||
return device_register(dev, name, flag);
|
||||
return device_register(dev, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -173,7 +173,7 @@ int ATTR_TCM_SECTION main(void)
|
|||
|
||||
struct device *uart0 = device_find("debug_log");
|
||||
|
||||
dma_register(DMA0_CH0_INDEX, "dma_cam", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH0_INDEX, "dma_cam");
|
||||
|
||||
dma_cam = device_find("dma_cam");
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ int main(void)
|
|||
bflb_platform_init(0);
|
||||
|
||||
/* register & open dac device */
|
||||
dac_register(DAC0_INDEX, "dac", DEVICE_OFLAG_RDWR);
|
||||
dac_register(DAC0_INDEX, "dac");
|
||||
struct device *dac = device_find("dac");
|
||||
|
||||
if (dac) {
|
||||
|
@ -69,7 +69,7 @@ int main(void)
|
|||
}
|
||||
|
||||
/* register & open dma device */
|
||||
if (dma_allocate_register("dac_dma", DEVICE_OFLAG_RDWR) == SUCCESS) {
|
||||
if (dma_allocate_register("dac_dma") == SUCCESS) {
|
||||
MSG("dma allocate success\r\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ int main(void)
|
|||
bflb_platform_init(0);
|
||||
|
||||
/* register & open dac device */
|
||||
dac_register(DAC0_INDEX, "dac", DEVICE_OFLAG_RDWR);
|
||||
dac_register(DAC0_INDEX, "dac");
|
||||
struct device *dac = device_find("dac");
|
||||
|
||||
if (dac) {
|
||||
|
@ -38,7 +38,7 @@ int main(void)
|
|||
}
|
||||
|
||||
/* register & open dma device */
|
||||
if (dma_allocate_register("dac_dma", DEVICE_OFLAG_RDWR) == SUCCESS) {
|
||||
if (dma_allocate_register("dac_dma") == SUCCESS) {
|
||||
MSG("dma allocate success\r\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ uint16_t sinList[] = {
|
|||
int main(void)
|
||||
{
|
||||
bflb_platform_init(0);
|
||||
dac_register(DAC0_INDEX, "dac", DEVICE_OFLAG_RDWR);
|
||||
dac_register(DAC0_INDEX, "dac");
|
||||
struct device *dac = device_find("dac");
|
||||
|
||||
if (dac) {
|
||||
|
|
|
@ -45,7 +45,7 @@ int main(void)
|
|||
{
|
||||
bflb_platform_init(0);
|
||||
|
||||
dma_register(DMA0_CH0_INDEX, "DMA", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH0_INDEX, "DMA");
|
||||
|
||||
struct device *dma = device_find("DMA");
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ int main(void)
|
|||
|
||||
bflb_platform_init(0);
|
||||
|
||||
i2c_register(I2C0_INDEX, "i2c", DEVICE_OFLAG_RDWR);
|
||||
i2c_register(I2C0_INDEX, "i2c");
|
||||
struct device *i2c0 = device_find("i2c");
|
||||
|
||||
if (i2c0) {
|
||||
|
|
|
@ -30,7 +30,7 @@ int main(void)
|
|||
|
||||
bflb_platform_init(0);
|
||||
|
||||
i2c_register(I2C0_INDEX, "i2c", DEVICE_OFLAG_RDWR);
|
||||
i2c_register(I2C0_INDEX, "i2c");
|
||||
struct device *i2c0 = device_find("i2c");
|
||||
|
||||
if (i2c0) {
|
||||
|
|
|
@ -67,7 +67,7 @@ int main(void)
|
|||
MSG("Play Music Form flash\r\n");
|
||||
|
||||
/* register & open i2s device */
|
||||
i2s_register(I2S0_INDEX, "I2S", DEVICE_OFLAG_RDWR);
|
||||
i2s_register(I2S0_INDEX, "I2S");
|
||||
i2s = device_find("I2S");
|
||||
if (i2s) {
|
||||
I2S_DEV(i2s)->iis_mode = I2S_MODE_MASTER;
|
||||
|
@ -81,7 +81,7 @@ int main(void)
|
|||
}
|
||||
|
||||
/* register & open dma device */
|
||||
dma_register(DMA0_CH2_INDEX, "dma_ch2_i2s_tx", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH2_INDEX, "dma_ch2_i2s_tx");
|
||||
dma_ch2 = device_find("dma_ch2_i2s_tx");
|
||||
if (dma_ch2) {
|
||||
DMA_DEV(dma_ch2)->direction = DMA_MEMORY_TO_PERIPH;
|
||||
|
|
|
@ -64,7 +64,7 @@ int main(void)
|
|||
ES8388_Set_Voice_Volume(60);
|
||||
|
||||
/* register & open i2s device */
|
||||
i2s_register(I2S0_INDEX, "I2S", DEVICE_OFLAG_RDWR);
|
||||
i2s_register(I2S0_INDEX, "I2S");
|
||||
i2s = device_find("I2S");
|
||||
if (i2s) {
|
||||
I2S_DEV(i2s)->iis_mode = I2S_MODE_MASTER;
|
||||
|
@ -78,7 +78,7 @@ int main(void)
|
|||
}
|
||||
|
||||
/* register & open dma device */
|
||||
dma_register(DMA0_CH3_INDEX, "dma_ch3_i2s_rx", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH3_INDEX, "dma_ch3_i2s_rx");
|
||||
dma_ch3 = device_find("dma_ch3_i2s_rx");
|
||||
if (dma_ch3) {
|
||||
DMA_DEV(dma_ch3)->direction = DMA_PERIPH_TO_MEMORY;
|
||||
|
@ -97,7 +97,7 @@ int main(void)
|
|||
device_control(dma_ch3, DEVICE_CTRL_SET_INT, NULL);
|
||||
}
|
||||
|
||||
dma_register(DMA0_CH2_INDEX, "dma_ch2_i2s_tx", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH2_INDEX, "dma_ch2_i2s_tx");
|
||||
dma_ch2 = device_find("dma_ch2_i2s_tx");
|
||||
if (dma_ch2) {
|
||||
DMA_DEV(dma_ch2)->direction = DMA_MEMORY_TO_PERIPH;
|
||||
|
|
|
@ -169,7 +169,7 @@ static int sd_wav_play_init(audio_dev_t *audio_dev, const TCHAR *path)
|
|||
if (audio_dev->device) {
|
||||
device_close(audio_dev->device);
|
||||
} else {
|
||||
i2s_register(I2S0_INDEX, "I2S", DEVICE_OFLAG_RDWR);
|
||||
i2s_register(I2S0_INDEX, "I2S");
|
||||
audio_dev->device = device_find("I2S");
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ static int sd_wav_play_init(audio_dev_t *audio_dev, const TCHAR *path)
|
|||
if (dma_ch2) {
|
||||
device_close(dma_ch2);
|
||||
} else {
|
||||
dma_register(DMA0_CH2_INDEX, "i2s_ch2", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH2_INDEX, "i2s_ch2");
|
||||
dma_ch2 = device_find("i2s_ch2");
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ int main(void)
|
|||
gpio_write(GPIO_PIN_30, 0);
|
||||
gpio_write(GPIO_PIN_31, 0);
|
||||
|
||||
pwm_register(PWM_CH2_INDEX, "led_breath", DEVICE_OFLAG_RDWR);
|
||||
pwm_register(PWM_CH2_INDEX, "led_breath");
|
||||
|
||||
struct device *led_breath = device_find("led_breath");
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ int main(void)
|
|||
|
||||
bflb_platform_init(0);
|
||||
|
||||
pwm_register(PWM_CH0_INDEX, "dc_motor_ch0", DEVICE_OFLAG_RDWR);
|
||||
pwm_register(PWM_CH1_INDEX, "dc_motor_ch1", DEVICE_OFLAG_RDWR);
|
||||
pwm_register(PWM_CH0_INDEX, "dc_motor_ch0");
|
||||
pwm_register(PWM_CH1_INDEX, "dc_motor_ch1");
|
||||
|
||||
struct device *dc_motor_ch0 = device_find("dc_motor_ch0");
|
||||
struct device *dc_motor_ch1 = device_find("dc_motor_ch1");
|
||||
|
|
|
@ -34,7 +34,7 @@ int main(void)
|
|||
{
|
||||
bflb_platform_init(0);
|
||||
|
||||
pwm_register(PWM_CH2_INDEX, "pwm", DEVICE_OFLAG_RDWR);
|
||||
pwm_register(PWM_CH2_INDEX, "pwm");
|
||||
|
||||
struct device *pwm = device_find("pwm");
|
||||
|
||||
|
|
|
@ -90,10 +90,10 @@ int main(void)
|
|||
{
|
||||
bflb_platform_init(0);
|
||||
|
||||
pwm_register(PWM_CH0_INDEX, "motor_ch0", DEVICE_OFLAG_RDWR);
|
||||
pwm_register(PWM_CH1_INDEX, "motor_ch1", DEVICE_OFLAG_RDWR);
|
||||
pwm_register(PWM_CH2_INDEX, "motor_ch2", DEVICE_OFLAG_RDWR);
|
||||
pwm_register(PWM_CH3_INDEX, "motor_ch3", DEVICE_OFLAG_RDWR);
|
||||
pwm_register(PWM_CH0_INDEX, "motor_ch0");
|
||||
pwm_register(PWM_CH1_INDEX, "motor_ch1");
|
||||
pwm_register(PWM_CH2_INDEX, "motor_ch2");
|
||||
pwm_register(PWM_CH3_INDEX, "motor_ch3");
|
||||
|
||||
motor_ch0 = device_find("motor_ch0");
|
||||
motor_ch1 = device_find("motor_ch1");
|
||||
|
|
|
@ -553,7 +553,7 @@ void FP_GPIO_Configuration(void)
|
|||
|
||||
uint8_t FP_Spi_Init()
|
||||
{
|
||||
spi_register(SPI0_INDEX, "spi", DEVICE_OFLAG_RDWR);
|
||||
spi_register(SPI0_INDEX, "spi");
|
||||
|
||||
struct device *spi = device_find("spi");
|
||||
|
||||
|
|
|
@ -65,8 +65,8 @@ void dma_ch2_irq_callback(struct device *dev, void *args, uint32_t size, uint32_
|
|||
|
||||
uint8_t spi_init(void)
|
||||
{
|
||||
spi_register(SPI0_INDEX, "spi0", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH3_INDEX, "ch2", DEVICE_OFLAG_RDWR);
|
||||
spi_register(SPI0_INDEX, "spi0");
|
||||
dma_register(DMA0_CH3_INDEX, "ch2");
|
||||
spi0 = device_find("spi0");
|
||||
|
||||
if (spi0) {
|
||||
|
@ -100,7 +100,7 @@ uint8_t spi_init(void)
|
|||
|
||||
void i2c_init(void)
|
||||
{
|
||||
i2c_register(I2C0_INDEX, "i2c", DEVICE_OFLAG_RDWR);
|
||||
i2c_register(I2C0_INDEX, "i2c");
|
||||
i2c0 = device_find("i2c");
|
||||
|
||||
if (i2c0) {
|
||||
|
|
|
@ -97,8 +97,8 @@ void uart0_rx_irq_callback(struct device *dev, void *args, uint32_t size, uint32
|
|||
|
||||
uint8_t spi_init(void)
|
||||
{
|
||||
spi_register(SPI0_INDEX, "spi0", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH3_INDEX, "ch3", DEVICE_OFLAG_RDWR);
|
||||
spi_register(SPI0_INDEX, "spi0");
|
||||
dma_register(DMA0_CH3_INDEX, "ch3");
|
||||
spi0 = device_find("spi0");
|
||||
|
||||
if (spi0) {
|
||||
|
@ -133,13 +133,13 @@ uint8_t spi_init(void)
|
|||
|
||||
void uart_init(void)
|
||||
{
|
||||
dma_register(DMA0_CH2_INDEX, "ch2", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH2_INDEX, "ch2");
|
||||
uart0 = device_find("debug_log");
|
||||
|
||||
if (uart0) {
|
||||
device_close(uart0);
|
||||
} else {
|
||||
uart_register(UART0_INDEX, "debug_log", DEVICE_OFLAG_RDWR);
|
||||
uart_register(UART0_INDEX, "debug_log");
|
||||
}
|
||||
|
||||
uart0 = device_find("debug_log");
|
||||
|
@ -171,7 +171,7 @@ void uart_init(void)
|
|||
|
||||
void i2c_init(void)
|
||||
{
|
||||
i2c_register(I2C0_INDEX, "i2c", DEVICE_OFLAG_RDWR);
|
||||
i2c_register(I2C0_INDEX, "i2c");
|
||||
i2c0 = device_find("i2c");
|
||||
|
||||
if (i2c0) {
|
||||
|
|
|
@ -32,7 +32,7 @@ uint32_t i;
|
|||
int main(void)
|
||||
{
|
||||
bflb_platform_init(0);
|
||||
spi_register(SPI0_INDEX, "spi", DEVICE_OFLAG_RDWR);
|
||||
spi_register(SPI0_INDEX, "spi");
|
||||
spi = device_find("spi");
|
||||
|
||||
if (spi) {
|
||||
|
|
|
@ -41,7 +41,7 @@ int main(void)
|
|||
timer_user_cfg2.timeout_val = 1000 * 1000; /* us */
|
||||
timer_user_cfg2.comp_it = TIMER_COMP2_IT;
|
||||
|
||||
timer_register(TIMER_CH1_INDEX, "timer_ch1", DEVICE_OFLAG_RDWR);
|
||||
timer_register(TIMER_CH1_INDEX, "timer_ch1");
|
||||
|
||||
struct device *timer_ch1 = device_find("timer_ch1");
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ int main(void)
|
|||
timer_user_cfg.timeout_val = 1000 * 1000; /* us */
|
||||
timer_user_cfg.comp_it = TIMER_COMP0_IT;
|
||||
|
||||
timer_register(TIMER_CH0_INDEX, "timer_ch0", DEVICE_OFLAG_RDWR);
|
||||
timer_register(TIMER_CH0_INDEX, "timer_ch0");
|
||||
|
||||
timer_ch0 = device_find("timer_ch0");
|
||||
|
||||
|
|
|
@ -50,14 +50,14 @@ int main(void)
|
|||
bflb_platform_init(0);
|
||||
sram_init();
|
||||
|
||||
uart_register(UART1_INDEX, "uart1", DEVICE_OFLAG_RDWR);
|
||||
uart_register(UART1_INDEX, "uart1");
|
||||
struct device *uart = device_find("uart1");
|
||||
|
||||
if (uart) {
|
||||
device_open(uart, DEVICE_OFLAG_DMA_TX);
|
||||
}
|
||||
|
||||
dma_register(DMA0_CH2_INDEX, "ch2", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH2_INDEX, "ch2");
|
||||
struct device *dma_ch2 = device_find("ch2");
|
||||
|
||||
if (dma_ch2) {
|
||||
|
|
|
@ -27,7 +27,7 @@ static uint8_t buffer[100];
|
|||
int main(void)
|
||||
{
|
||||
bflb_platform_init(0);
|
||||
uart_register(UART1_INDEX, "uart1", DEVICE_OFLAG_RDWR);
|
||||
uart_register(UART1_INDEX, "uart1");
|
||||
struct device *uart1 = device_find("uart1");
|
||||
|
||||
if (uart1) {
|
||||
|
|
|
@ -52,7 +52,7 @@ const char *string = "uart1 poll tx and rx irq test\r\n";
|
|||
int main(void)
|
||||
{
|
||||
bflb_platform_init(0);
|
||||
uart_register(UART1_INDEX, "uart1", DEVICE_OFLAG_RDWR);
|
||||
uart_register(UART1_INDEX, "uart1");
|
||||
struct device *uart1 = device_find("uart1");
|
||||
|
||||
if (uart1) {
|
||||
|
|
|
@ -452,7 +452,7 @@ int main(void)
|
|||
//device_control(usb_fs, DEVICE_CTRL_SET_INT, (void *)(USB_EP2_DATA_IN_IT));
|
||||
}
|
||||
|
||||
dma_register(DMA0_CH2_INDEX, "ch2", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH2_INDEX, "ch2");
|
||||
dma_ch2 = device_find("ch2");
|
||||
|
||||
if (dma_ch2) {
|
||||
|
|
|
@ -547,7 +547,7 @@ int main(void)
|
|||
device_control(usb_fs, DEVICE_CTRL_SET_INT, (void *)(USB_SOF_IT));
|
||||
}
|
||||
|
||||
dma_register(DMA0_CH2_INDEX, "ch2", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH2_INDEX, "ch2");
|
||||
dma_ch2 = device_find("ch2");
|
||||
|
||||
if (dma_ch2) {
|
||||
|
|
|
@ -133,12 +133,7 @@ function(generate_bin)
|
|||
|
||||
list(APPEND SRCS ${CMAKE_SOURCE_DIR}/bsp/bsp_common/platform/bflb_platform.c)
|
||||
list(APPEND SRCS ${CMAKE_SOURCE_DIR}/bsp/bsp_common/platform/syscalls.c)
|
||||
|
||||
if(${CHIP} STREQUAL "bl702")
|
||||
list(APPEND SRCS ${CMAKE_SOURCE_DIR}/bsp/board/bl70x/board.c)
|
||||
else()
|
||||
list(APPEND SRCS ${CMAKE_SOURCE_DIR}/bsp/board/${CHIP}/board.c)
|
||||
endif()
|
||||
|
||||
add_executable(${target_name}.elf ${mainfile} ${SRCS})
|
||||
target_link_options(${target_name}.elf PRIVATE ${GLOBAL_LD_FLAGS})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue