diff --git a/platform/gpio/BUILD.gn b/platform/gpio/BUILD.gn index 1a16f0b..3d1c459 100644 --- a/platform/gpio/BUILD.gn +++ b/platform/gpio/BUILD.gn @@ -24,7 +24,8 @@ hdf_driver(module_name) { } include_dirs = [ "." ] - if (defined(LOSCFG_SHIELD_V200ZR_EVB_T1)) { + if (defined(LOSCFG_SHIELD_V200ZR_EVB_T1) && + defined(LOSCFG_DRIVERS_HDF_CONFIG_MACRO)) { deps = [ "//device/board/fnlink/shields" ] } } diff --git a/platform/pwm/pwm_bes.c b/platform/pwm/pwm_bes.c index 724f518..3caaffa 100644 --- a/platform/pwm/pwm_bes.c +++ b/platform/pwm/pwm_bes.c @@ -89,9 +89,31 @@ static int InitPwmDevice(struct PwmDev *host) } #ifdef LOSCFG_DRIVERS_HDF_CONFIG_MACRO -static uint32_t GetPwmDeviceResource(struct PwmDevice *device) +#define PWM_FIND_CONFIG(node, name, resource) \ + do { \ + if (strcmp(HCS_PROP(node, match_attr), name) == 0) { \ + tempPin = HCS_PROP(node, pwmPin); \ + resource->pwmPin = ((tempPin / DEC_TEN) * PIN_GROUP_NUM) + (tempPin % DEC_TEN); \ + resource->pwmId = HCS_PROP(node, pwmId); \ + break; \ + } \ + } while (0) +#define PLATFORM_PWM_CONFIG HCS_NODE(HCS_NODE(HCS_ROOT, platform), pwm_config) +static uint32_t GetPwmDeviceResource(struct PwmDevice *device, const char *deviceMatchAttr) { - (void)device; + uint32_t tempPin; + struct PwmResource *resource = NULL; + if (device == NULL) { + HDF_LOGE("%s: device is NULL", __func__); + return HDF_ERR_INVALID_PARAM; + } + resource = &device->resource; + if (resource == NULL) { + HDF_LOGE("%s: resource is NULL", __func__); + return HDF_ERR_INVALID_OBJECT; + } + + HCS_FOREACH_CHILD_VARGS(PLATFORM_PWM_CONFIG, PWM_FIND_CONFIG, deviceMatchAttr, resource); return HDF_SUCCESS; } #else @@ -151,7 +173,7 @@ static int32_t AttachPwmDevice(struct PwmDev *host, struct HdfDeviceObject *devi return HDF_ERR_MALLOC_FAIL; } #ifdef LOSCFG_DRIVERS_HDF_CONFIG_MACRO - ret = GetPwmDeviceResource(pwmDevice); + ret = GetPwmDeviceResource(pwmDevice, device->deviceMatchAttr); #else ret = GetPwmDeviceResource(pwmDevice, device->property); #endif diff --git a/platform/spi/spi_bes.c b/platform/spi/spi_bes.c index e5afea8..886de57 100644 --- a/platform/spi/spi_bes.c +++ b/platform/spi/spi_bes.c @@ -277,7 +277,7 @@ OUT: static int32_t HalSpiRecv(struct SpiDevice *spiDevice, uint8_t *data, uint16_t size, uint32_t timeOut) { int32_t ret; - uint32_t len = size; + int32_t len = (int32_t)size; uint32_t remainder; int32_t status = HDF_FAILURE; uint8_t *cmd = NULL; @@ -415,10 +415,44 @@ static int32_t InitSpiDevice(struct SpiDevice *spiDevice) /* get spi config from hcs file */ #ifdef LOSCFG_DRIVERS_HDF_CONFIG_MACRO +#define SPI_FIND_CONFIG(node, name, resource) \ + do { \ + if (strcmp(HCS_PROP(node, match_attr), name) == 0) { \ + resource->num = HCS_PROP(node, busNum); \ + resource->speed = HCS_PROP(node, speed); \ + resource->transmode = HCS_PROP(node, transmode); \ + resource->spiCsSoft = HCS_PROP(node, spiCsSoft); \ + resource->mode = HCS_PROP(node, mode); \ + resource->dataSize = HCS_PROP(node, dataSize); \ + resource->csNum = HCS_PROP(node, csNum); \ + tempPin = HCS_PROP(node, spiClkPin); \ + resource->spiClkPin = ((tempPin / DEC_NUM) * GROUP_PIN_NUM) + (tempPin % DEC_NUM); \ + tempPin = HCS_PROP(node, spiMosiPin); \ + resource->spiMosiPin = ((tempPin / DEC_NUM) * GROUP_PIN_NUM) + (tempPin % DEC_NUM); \ + tempPin = HCS_PROP(node, spiMisoPin); \ + resource->spiMisoPin = ((tempPin / DEC_NUM) * GROUP_PIN_NUM) + (tempPin % DEC_NUM); \ + tempPin = HCS_PROP(node, spiCsPin); \ + resource->spiCsPin = ((tempPin / DEC_NUM) * GROUP_PIN_NUM) + (tempPin % DEC_NUM); \ + break; \ + } \ + } while (0) + +#define PLATFORM_SPI_CONFIG HCS_NODE(HCS_NODE(HCS_ROOT, platform), spi_config) static int32_t GetSpiDeviceResource(struct SpiDevice *spiDevice, const char *deviceMatchAttr) { - (void)spiDevice; - (void)deviceMatchAttr; + uint32_t tempPin; + struct SpiResource *resource = NULL; + if (spiDevice == NULL) { + HDF_LOGE("device or resourceNode is NULL\r\n"); + return HDF_ERR_INVALID_PARAM; + } + resource = &spiDevice->resource; + if (resource == NULL) { + HDF_LOGE("%s %d: invalid parameter\r\n", __func__, __LINE__); + return HDF_ERR_INVALID_OBJECT; + } + + HCS_FOREACH_CHILD_VARGS(PLATFORM_SPI_CONFIG, SPI_FIND_CONFIG, deviceMatchAttr, resource); return HDF_SUCCESS; } #else diff --git a/platform/uart/BUILD.gn b/platform/uart/BUILD.gn index 19becc7..354811d 100644 --- a/platform/uart/BUILD.gn +++ b/platform/uart/BUILD.gn @@ -24,4 +24,8 @@ hdf_driver(module_name) { } include_dirs = [ "." ] + if (defined(LOSCFG_SHIELD_V200ZR_EVB_T1) && + defined(LOSCFG_DRIVERS_HDF_CONFIG_MACRO)) { + deps = [ "//device/board/fnlink/shields" ] + } } diff --git a/platform/uart/uart_bes.c b/platform/uart/uart_bes.c index 5045d26..736c3d5 100644 --- a/platform/uart/uart_bes.c +++ b/platform/uart/uart_bes.c @@ -223,7 +223,7 @@ static int32_t HalUartRecv(uint8_t uartId, void *data, uint32_t expectSize, uint32_t nowTime; uint32_t fifoPopLen; uint32_t recvedLen = 0; - uint32_t expectLen = expectSize; + int32_t expectLen = (int32_t)expectSize; if (data == NULL || expectLen == 0 || recvSize == NULL) { HDF_LOGE("%s %d Invalid input \r\n", __FILE__, __LINE__); @@ -459,10 +459,44 @@ static int InitUartDevice(struct UartHost *host) return HDF_SUCCESS; } #ifdef LOSCFG_DRIVERS_HDF_CONFIG_MACRO +#define UART_FIND_CONFIG(node, name, resource) \ + do { \ + if (strcmp(HCS_PROP(node, match_attr), name) == 0) { \ + resource->num = HCS_PROP(node, num); \ + resource->baudRate = HCS_PROP(node, baudRate); \ + resource->parity = HCS_PROP(node, parity); \ + resource->stopBit = HCS_PROP(node, stopBit); \ + resource->wLen = HCS_PROP(node, data); \ + resource->rxDMA = HCS_PROP(node, rxDMA); \ + resource->txDMA = HCS_PROP(node, txDMA); \ + break; \ + } \ + } while (0) + +#define PLATFORM_UART_CONFIG HCS_NODE(HCS_NODE(HCS_ROOT, platform), uart_config) static uint32_t GetUartDeviceResource(struct UartDevice *device, const char *deviceMatchAttr) { - (void)device; - (void)deviceMatchAttr; + struct UartResource *resource = NULL; + if (device == NULL || deviceMatchAttr == NULL) { + HDF_LOGE("device or resourceNode is NULL\r\n"); + return HDF_ERR_INVALID_PARAM; + } + resource = &device->resource; + if (resource == NULL) { + HDF_LOGE("%s %d: invalid parameter\r\n", __func__, __LINE__); + return HDF_ERR_INVALID_OBJECT; + } + + HCS_FOREACH_CHILD_VARGS(PLATFORM_UART_CONFIG, UART_FIND_CONFIG, deviceMatchAttr, resource); + // copy config + device->initFlag = false; + device->uartId = resource->num; + device->config.baud = resource->baudRate; + device->config.parity = resource->parity; + device->config.stop = resource->stopBit; + device->config.data = resource->wLen; + device->config.dma_rx = (resource->rxDMA == true) ? true : false; + device->config.dma_tx = (resource->txDMA == true) ? true : false; return HDF_SUCCESS; } #else