add flash and timer driver for hc32f4a0

This commit is contained in:
wuzheng
2023-02-17 16:21:06 +08:00
parent ba51d8ba8e
commit 002325c1d8
28 changed files with 806 additions and 87 deletions

View File

@@ -1,4 +1,4 @@
SRC_DIR := kpu tensorflow-lite
SRC_DIR := cmsis_5 filter image_processing kpu nnom ota tensorflow-lite
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -1,3 +1,7 @@
SRC_DIR := tensorflow-lite-for-mcu
SRC_DIR :=
ifeq ($(CONFIG_USING_TENSORFLOWLITEMICRO),y)
SRC_DIR += tensorflow-lite-for-mcu
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -69,6 +69,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
return result;
}
#ifdef ADD_XIZI_FETURES
static int PinOpen(void){
int pin_fd = PrivOpen(SENSOR_DEVICE_QS_FX_PIN_DEV, O_RDWR);
if (pin_fd < 0) {
@@ -95,6 +96,7 @@ static int PinOpen(void){
return pin_fd;
}
#endif
/**
* @description: Read sensor device
@@ -104,22 +106,26 @@ static int PinOpen(void){
*/
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
{
#ifdef ADD_XIZI_FETURES
int pin_fd=PinOpen();
struct PinStat pin_dir;
pin_dir.pin = SENSOR_DEVICE_QS_FX_PIN_NUMBER;
pin_dir.val = GPIO_HIGH;
if (PrivWrite(pin_fd,&pin_dir,0) < 0) // pull-up pin to configure as tx mode
return -1;
#endif
PrivTaskDelay(20);
if (PrivWrite(sdev->fd, instructions, sizeof(instructions)) < 0)
return -1;
PrivTaskDelay(20);
#ifdef ADD_XIZI_FETURES
pin_dir.val = GPIO_LOW;
if (PrivWrite(pin_fd,&pin_dir,0) < 0) // pull-down pin to configure as rx mode
return -1;
return -1;
#endif
if (PrivRead(sdev->fd, sdev->buffer, len) < 0)
return -1;
PrivClose(pin_fd);

View File

@@ -68,7 +68,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
return result;
}
#ifdef ADD_XIZI_FETURES
static int PinOpen(void){
int pin_fd = PrivOpen(SENSOR_DEVICE_QS_FS_PIN_DEV, O_RDWR);
if (pin_fd < 0) {
@@ -96,6 +96,8 @@ static int PinOpen(void){
return pin_fd;
}
#endif
/**
* @description: Read sensor device
* @param sdev - sensor device pointer
@@ -104,6 +106,7 @@ static int PinOpen(void){
*/
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
{
#ifdef ADD_XIZI_FETURES
int pin_fd=PinOpen();
struct PinStat pin_dir;
pin_dir.pin = SENSOR_DEVICE_QS_FS_PIN_NUMBER;
@@ -111,16 +114,19 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
pin_dir.val = GPIO_HIGH;
if (PrivWrite(pin_fd,&pin_dir,0) < 0) // pull-up pin to configure as tx mode
return -1;
#endif
PrivTaskDelay(20);
if (PrivWrite(sdev->fd, instructions, sizeof(instructions)) < 0)
return -1;
PrivTaskDelay(20);
#ifdef ADD_XIZI_FETURES
pin_dir.val = GPIO_LOW;
if (PrivWrite(pin_fd,&pin_dir,0) < 0) // pull-down pin to configure as rx mode
return -1;
#endif
if (PrivRead(sdev->fd, sdev->buffer, len) < 0)
return -1;
@@ -128,6 +134,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
return 0;
}
static struct SensorDone done =
{
SensorDeviceOpen,

View File

@@ -172,6 +172,8 @@ int PrivIoctl(int fd, int cmd, void *args)
case WDT_TYPE:
case CAMERA_TYPE:
case KPU_TYPE:
case TIME_TYPE:
case FLASH_TYPE:
ret = ioctl(fd, cmd, ioctl_cfg->args);
break;
default:

View File

@@ -152,6 +152,8 @@ enum IoctlDriverType
RTC_TYPE,
CAMERA_TYPE,
KPU_TYPE,
FLASH_TYPE,
TIME_TYPE,
DEFAULT_TYPE,
};