summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bsp/lpc54608-LPCXpresso/drivers/drv_emac.c10
-rw-r--r--bsp/lpc54608-LPCXpresso/drivers/drv_sd.c16
2 files changed, 23 insertions, 3 deletions
diff --git a/bsp/lpc54608-LPCXpresso/drivers/drv_emac.c b/bsp/lpc54608-LPCXpresso/drivers/drv_emac.c
index 8dc3b5ad09..1f38471fca 100644
--- a/bsp/lpc54608-LPCXpresso/drivers/drv_emac.c
+++ b/bsp/lpc54608-LPCXpresso/drivers/drv_emac.c
@@ -433,6 +433,8 @@ rt_err_t lpc_emac_tx(rt_device_t dev, struct pbuf *p)
enet_handle_t * enet_handle = &lpc_emac_device.handle;
ENET_Type *enet_base = lpc_emac_device.base;
uint8_t * data;
+
+ uint16_t len;
RT_ASSERT(p != NULL);
RT_ASSERT(enet_handle != RT_NULL);
@@ -454,11 +456,13 @@ rt_err_t lpc_emac_tx(rt_device_t dev, struct pbuf *p)
}
}
- data = (uint8_t *)ENET_ALIGN(&lpc_emac_device.RxDataBuff[lpc_emac_device.txIdx * ENET_ALIGN(ENET_RXBUFF_SIZE)]);
- pbuf_copy_partial(p, data, p->tot_len, 0);
+ // fix RxDataBuff -> TxDataBuff, ENET_RXBUFF_SIZE -> ENET_TXBUFF_SIZE
+ data = (uint8_t *)ENET_ALIGN(&lpc_emac_device.TxDataBuff[lpc_emac_device.txIdx * ENET_ALIGN(ENET_TXBUFF_SIZE)]);
+ len = pbuf_copy_partial(p, data, p->tot_len, 0);
lpc_emac_device.txIdx = (lpc_emac_device.txIdx + 1) / ENET_TXBD_NUM;
- result = ENET_SendFrame(enet_base, enet_handle, data, p->len);
+ // fix 'p->len' to 'len', avoid send wrong partial packet.
+ result = ENET_SendFrame(enet_base, enet_handle, data, len);
if ((result == kStatus_ENET_TxFrameFail) || (result == kStatus_ENET_TxFrameOverLen) || (result == kStatus_ENET_TxFrameBusy))
{
diff --git a/bsp/lpc54608-LPCXpresso/drivers/drv_sd.c b/bsp/lpc54608-LPCXpresso/drivers/drv_sd.c
index d0b9573046..9400671301 100644
--- a/bsp/lpc54608-LPCXpresso/drivers/drv_sd.c
+++ b/bsp/lpc54608-LPCXpresso/drivers/drv_sd.c
@@ -407,6 +407,22 @@ rt_err_t mci_hw_init(const char *device_name)
rt_kprintf("SD_Init failed!\n");
return -RT_ERROR;
}
+
+ /*
+ follow the page: https://community.nxp.com/thread/454769
+
+ The issue concerns sdmmc library bug (I finally solved) in SD_Init() in the file sdmmc/src/fsl_sd.c:SD_SelectBusTiming()
+ calls SD_SwitchFunction() which sets block size to 64bytes (512bits).Therefore SD_SetBlockSize(card, FSL_SDMMC_DEFAULT_BLOCK_SIZE)
+ should be called again before SD_Init() exits.
+ */
+
+ if (kStatus_Success != SDMMC_SetBlockSize(_mci_device->card.host.base, _mci_device->card.host.transfer, FSL_SDMMC_DEFAULT_BLOCK_SIZE))
+ {
+ SD_Deinit(&_mci_device->card);
+ memset(&_mci_device->card, 0U, sizeof(_mci_device->card));
+ rt_kprintf("SD_Init failed!\n");
+ return -RT_ERROR;
+ }
/* initialize mutex lock */
rt_mutex_init(&_mci_device->lock, device_name, RT_IPC_FLAG_FIFO);