add flash and timer driver for hc32f4a0
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user