Browse Source

add parity parameter to Serial module

Signed-off-by: surenyi <surenyi82@163.com>
master
surenyi 6 years ago
parent
commit
681161bdc6
  1. BIN
      doc/dspkit.pdf
  2. 4
      doc/dspkit.tex
  3. 9
      packages/vsky/libdsp/Serial.c
  4. 7
      packages/vsky/libdsp/Serial.xdc
  5. 84
      packages/vsky/libdsp/emac/nimu_eth.c

BIN
doc/dspkit.pdf

Binary file not shown.

4
doc/dspkit.tex

@ -88,8 +88,8 @@ citecolor=blue,anchorcolor=black, pdfauthor={surenyi82@163.com}, urlcolor=black]
\noindent \texttt{XDCCGROOT}: 指向 C6000 编译器的安装路径, 例如:\texttt{d:\textbackslash ti\textbackslash ccsv5\textbackslash tools\textbackslash compiler\textbackslash c6000\_7.4.24}
\noindent \texttt{XDCPATH}: 包含安装的 bios, pdk, ndk 的packages路径,例如: \texttt{d:\textbackslash ti\textbackslash bios\_6\_34\_02\_18\textbackslash packages;\\
d:\textbackslash ti\textbackslash ndk\_2\_21\_02\_43\textbackslash packages;d:\textbackslash ti\textbackslash pdk\_C6678\_1\_1\_2\_6\textbackslash packages;}
\noindent \texttt{XDCPATH}: 包含安装的 bios, pdk, ndk 的packages路径,例如: \texttt{c:\textbackslash ti\textbackslash bios\_6\_34\_02\_18\textbackslash packages;\\
c:\textbackslash ti\textbackslash ndk\_2\_21\_02\_43\textbackslash packages;c:\textbackslash ti\textbackslash pdk\_C6678\_1\_1\_2\_6\textbackslash packages;}
设置好环境变量以后,打开 git 的 bash 窗口, cd 到 libdsp/packages/vsky/libdsp 目录,执行下面命令编译:

9
packages/vsky/libdsp/Serial.c

@ -12,9 +12,12 @@ Int Serial_Instance_init(Serial_Object *obj, Int p, const Serial_Params *param,
}
return -1;
}
uart_set_baudrate(obj->_uart, param->baudrate);
uart_set_databits(obj->_uart, param->databits);
uart_set_stopbits(obj->_uart, param->stopbits);
if (param) {
uart_set_baudrate(obj->_uart, param->baudrate);
uart_set_databits(obj->_uart, param->databits);
uart_set_stopbits(obj->_uart, param->stopbits);
uart_set_parity(obj->_uart, param->parity);
}
return 0;
}

7
packages/vsky/libdsp/Serial.xdc

@ -8,15 +8,22 @@ instance:
config UInt32 baudrate = 115200;
config UInt32 databits = 8;
config UInt32 stopbits = 1;
config UInt32 parity = 0;
/*!
* Create serial port.
*
* @p(html)
* Error_Block eb;
* Serial_Handle h;
* Serial_Params p;
*
* Serial_Params_init(&p);
* p.baudrate = 115200;
* p.databits = 8;
* p.stopbits = 1;
*
* Error_init(&eb);
* h = Serial_create(0, &p);
* if (h != NULL) {
* ...

84
packages/vsky/libdsp/emac/nimu_eth.c

@ -218,14 +218,14 @@ static int32_t __add_mac_address (paEthInfo_t *ethInfo, paRouteInfo_t *routeInfo
/* Get a Tx free descriptor to send a command to the PA PDSP */
if ((QMSS_QPOP (gTxCmdFreeQHnd, QHANDLER_QPOP_FDQ_NO_ATTACHEDBUF, (Cppi_HostDesc **)&pHostDesc )) != NULL) {
System_printf ("Error obtaining a Tx free descriptor \r\n");
System_printf ("Error obtaining a Tx free descriptor \n");
return -1;
}
/* Allocate a Tx buffer and attach the command info to it. */
cmdbuf_len = __roundup(cmdbuf_len, 128);
if ((pCmdDataBuffer = (Ptr) Osal_nimuMalloc (cmdbuf_len, 128)) == NULL) {
System_printf ("Error allocating memory for PA Command data buffer \r\n");
System_printf ("Error allocating memory for PA Command data buffer \n");
return -1;
}
@ -260,7 +260,7 @@ static int32_t __add_mac_address (paEthInfo_t *ethInfo, paRouteInfo_t *routeInfo
&cmdReplyInfo,
&cmdDest);
if (retVal != pa_OK) {
System_printf ("Pa_addMac returned error %d\r\n", retVal);
System_printf ("Pa_addMac returned error %d\n", retVal);
ret_val = -1;
goto return_fail;
}
@ -323,7 +323,7 @@ static int32_t __add_mac_address (paEthInfo_t *ethInfo, paRouteInfo_t *routeInfo
}
if (pHostDesc->softwareInfo0 != cmdReplyInfo.replyId) {
System_printf ("Found an entry in PA response queue with swinfo0 = 0x%08x, expected 0x%08x\r\n",
System_printf ("Found an entry in PA response queue with swinfo0 = 0x%08x, expected 0x%08x\n",
pHostDesc->softwareInfo0, cmdReplyInfo.replyId);
pHostDesc->buffLen = pHostDesc->origBufferLen;
QMSS_QPUSH (gTxCmdFreeQHnd, pHostDesc, pHostDesc->buffLen, SIZE_HOST_DESC, Qmss_Location_TAIL);
@ -334,7 +334,7 @@ static int32_t __add_mac_address (paEthInfo_t *ethInfo, paRouteInfo_t *routeInfo
retVal = Pa_forwardResult (res_mgr_get_painstance(), (Ptr)pHostDesc->buffPtr, &retHandle, &handleType, &cmdDest);
if (retVal != pa_OK) {
System_printf ("PA sub-system rejected Pa_addMac command\r\n");
System_printf ("PA sub-system rejected Pa_addMac command\n");
ret_val = -1;
goto return_fail;
}
@ -347,7 +347,7 @@ static int32_t __add_mac_address (paEthInfo_t *ethInfo, paRouteInfo_t *routeInfo
}
if (j == 100) {
System_printf ("Timeout waiting for reply from PA to Pa_addMac command\r\n");
System_printf ("Timeout waiting for reply from PA to Pa_addMac command\n");
ret_val = -1;
}
return_fail:
@ -654,7 +654,7 @@ static int32_t __setup_rx(NETIF_DEVICE* ptr_net_device)
* Open the next available High Priority Accumulation queue for Rx.
*/
if ((gRxQHnd = Qmss_queueOpen (Qmss_QueueType_HIGH_PRIORITY_QUEUE, QMSS_PARAM_NOT_SPECIFIED, &isAllocated)) < 0) {
System_printf("Error opening a High Priority Accumulation Rx queue \r\n");
System_printf("Error opening a High Priority Accumulation Rx queue \n");
return -1;
}
@ -677,7 +677,7 @@ static int32_t __setup_rx(NETIF_DEVICE* ptr_net_device)
/* Ensure that the accumulator channel we are programming is not in use currently. */
result = Qmss_disableAccumulator (Qmss_PdspId_PDSP1, accChannelNum);
if (result != QMSS_ACC_SOK && result != QMSS_ACC_CHANNEL_NOT_ACTIVE) {
System_printf("Error Disabling high priority accumulator for channel : %d error code: %d\r\n",
System_printf("Error Disabling high priority accumulator for channel : %d error code: %d\n",
accChannelNum, result);
return -1;
}
@ -697,7 +697,7 @@ static int32_t __setup_rx(NETIF_DEVICE* ptr_net_device)
/* Program the accumulator */
if ((result = Qmss_programAccumulator (Qmss_PdspId_PDSP1, &accCfg)) != QMSS_ACC_SOK) {
System_printf("Error Programming high priority accumulator for channel : %d queue : %d error code : %d\r\n",
System_printf("Error Programming high priority accumulator for channel : %d queue : %d error code : %d\n",
accCfg.channel, accCfg.queMgrIndex, result);
return -1;
}
@ -711,7 +711,7 @@ static int32_t __setup_rx(NETIF_DEVICE* ptr_net_device)
/* Pick a interrupt vector id to use */
vectId = PLATFORM_ETH_INTERRUPT;
System_printf("Ethernet eventId : %d and vectId (Interrupt) : %d \r\n", eventId, vectId);
System_printf("Ethernet eventId : %d and vectId (Interrupt) : %d \n", eventId, vectId);
/* Register our ISR handle for this event */
EventCombiner_dispatchPlug (eventId, (EventCombiner_FuncPtr)EmacRxPktISR, (UArg)ptr_net_device, TRUE);
@ -729,7 +729,7 @@ static int32_t __setup_rx(NETIF_DEVICE* ptr_net_device)
* used by the PASS CPDMA to hold data received via CPSW.
*/
if ((gRxFreeQHnd = Qmss_queueOpen (Qmss_QueueType_STARVATION_COUNTER_QUEUE, QMSS_PARAM_NOT_SPECIFIED, &isAllocated)) < 0) {
System_printf("Error opening Rx Free descriptor queue \r\n");
System_printf("Error opening Rx Free descriptor queue \n");
return -1;
}
rxFreeQInfo = Qmss_getQueueNumber (gRxFreeQHnd);
@ -747,7 +747,7 @@ static int32_t __setup_rx(NETIF_DEVICE* ptr_net_device)
pktLen = __roundup(pktLen, 128);
if ((pDataBuffer = Osal_nimuMalloc (pktLen, 128)) == NULL)
{
System_printf("Error allocating memory for Rx data buffer \r\n");
System_printf("Error allocating memory for Rx data buffer \n");
break;
}
@ -773,7 +773,7 @@ static int32_t __setup_rx(NETIF_DEVICE* ptr_net_device)
QMSS_QPUSHDESCSIZE (gRxFreeQHnd, pCppiDesc, SIZE_HOST_DESC);
}
if (i != NIMU_NUM_RX_DESC) {
System_printf("Error allocating Rx free descriptors \r\n");
System_printf("Error allocating Rx free descriptors \n");
return -1;
}
@ -829,7 +829,7 @@ static int32_t __setup_rx(NETIF_DEVICE* ptr_net_device)
/* Configure the Rx flow */
if ((gRxFlowHnd = Cppi_configureRxFlow (res_mgr_cppi_get_passhandle(), &rxFlowCfg, &isAllocated)) == NULL) {
System_printf("Error configuring Rx flow \r\n");
System_printf("Error configuring Rx flow \n");
return -1;
}
@ -871,25 +871,25 @@ static int32_t __verify_init (Void)
/*Verify if we got NIMU_NUM_TX_DESC Tx Free Q*/
if ((count = Qmss_getQueueEntryCount (gTxFreeQHnd)) != num_tx_desc) {
System_printf("__verify_init: Expected %d entry count for gTxFreeQHnd queue %d, found %d entries\r\n", num_tx_desc, gTxFreeQHnd, count);
System_printf("__verify_init: Expected %d entry count for gTxFreeQHnd queue %d, found %d entries\n", num_tx_desc, gTxFreeQHnd, count);
returnVal = -1;
}
/* Verify if we got NIMU_NUM_RX_DESC Rx FDQ */
if ((count = Qmss_getQueueEntryCount (gRxFreeQHnd)) != num_rx_desc) {
System_printf ("__verify_init: Expected %d entry count for gRxFreeQHnd queue %d, found %d entries\r\n", num_rx_desc, gRxFreeQHnd, count);
System_printf ("__verify_init: Expected %d entry count for gRxFreeQHnd queue %d, found %d entries\n", num_rx_desc, gRxFreeQHnd, count);
returnVal = -1;
}
/* Verify if we got empty Tx completion Q*/
if ((count = Qmss_getQueueEntryCount (gTxReturnQHnd)) != 0) {
System_printf("__verify_init: Expected 0 entry count for gTxReturnQHnd queue %d, found %d entries\r\n", gTxReturnQHnd, count);
System_printf("__verify_init: Expected 0 entry count for gTxReturnQHnd queue %d, found %d entries\n", gTxReturnQHnd, count);
returnVal = -1;
}
/* Verify if we got NIMU_NUM_RX_DESC Rx FDQ */
if ((count = Qmss_getQueueEntryCount (gRxQHnd)) != 0) {
System_printf ("__verify_init: Expected 0 entry count for gRxQHnd= %d, found %d entries\r\n", gRxQHnd, count);
System_printf ("__verify_init: Expected 0 entry count for gRxQHnd= %d, found %d entries\n", gRxQHnd, count);
returnVal = -1;
}
@ -899,7 +899,7 @@ static int32_t __verify_init (Void)
count = Qmss_getQueueEntryCount (i);
if (count != 0) {
System_printf ("__verify_init: Expected 0 entry count for Queue number = %d, found %d entries\r\n", i, count);
System_printf ("__verify_init: Expected 0 entry count for Queue number = %d, found %d entries\n", i, count);
}
}
@ -935,7 +935,7 @@ static int32_t __setup_tx (Void)
*/
for (i = 0; i < NUM_PA_TX_QUEUES; i ++) {
if ((gPaTxQHnd[i] = Qmss_queueOpen (Qmss_QueueType_PASS_QUEUE, QMSS_PARAM_NOT_SPECIFIED, &isAllocated)) < 0) {
System_printf("Error opening PA Tx queue \r\n");
System_printf("Error opening PA Tx queue \n");
return -1;
}
}
@ -947,7 +947,7 @@ static int32_t __setup_tx (Void)
* later with data buffers for transmission onto wire.
*/
if ((gTxFreeQHnd = Qmss_queueOpen (Qmss_QueueType_STARVATION_COUNTER_QUEUE, QMSS_PARAM_NOT_SPECIFIED, &isAllocated)) < 0) {
System_printf("Error opening Tx Free descriptor queue \r\n");
System_printf("Error opening Tx Free descriptor queue \n");
return -1;
}
@ -958,7 +958,7 @@ static int32_t __setup_tx (Void)
* later with data buffers for transmission onto wire.
*/
if ((gTxReturnQHnd = Qmss_queueOpen (Qmss_QueueType_GENERAL_PURPOSE_QUEUE, QMSS_PARAM_NOT_SPECIFIED, &isAllocated)) < 0) {
System_printf("Error opening Tx Return descriptor queue \r\n");
System_printf("Error opening Tx Return descriptor queue \n");
return -1;
}
@ -991,7 +991,7 @@ static int32_t __setup_tx (Void)
QMSS_QPUSHDESCSIZE (gTxFreeQHnd, pCppiDesc, SIZE_HOST_DESC);
}
if (i != NIMU_NUM_TX_DESC) {
System_printf("Error allocating Tx free descriptors \r\n");
System_printf("Error allocating Tx free descriptors \n");
return -1;
}
@ -1000,7 +1000,7 @@ static int32_t __setup_tx (Void)
* This queue will be used to hold Tx Command free decriptors
*/
if ((gTxCmdFreeQHnd = Qmss_queueOpen (Qmss_QueueType_STARVATION_COUNTER_QUEUE, QMSS_PARAM_NOT_SPECIFIED, &isAllocated)) < 0) {
System_printf("Error opening Tx Cmd Free descriptor queue \r\n");
System_printf("Error opening Tx Cmd Free descriptor queue \n");
return -1;
}
@ -1009,7 +1009,7 @@ static int32_t __setup_tx (Void)
* This queue will be used to hold Tx command completed decriptors
*/
if ((gTxCmdReturnQHnd = Qmss_queueOpen (Qmss_QueueType_GENERAL_PURPOSE_QUEUE, QMSS_PARAM_NOT_SPECIFIED, &isAllocated)) < 0) {
System_printf("Error opening Tx Return descriptor queue \r\n");
System_printf("Error opening Tx Return descriptor queue \n");
return -1;
}
@ -1037,7 +1037,7 @@ static int32_t __setup_tx (Void)
QMSS_QPUSHDESCSIZE (gTxCmdFreeQHnd, pCppiDesc, SIZE_HOST_DESC);
}
if (i != NIMU_MAX_NUM_TX_CMD_DESC) {
System_printf("Error allocating Tx Command free descriptors \r\n");
System_printf("Error allocating Tx Command free descriptors \n");
return -1;
}
@ -1091,13 +1091,13 @@ static int __emac_start(NETIF_DEVICE* ptr_net_device)
/* Setup Tx */
if (__setup_tx () != 0) {
System_printf("Tx setup failed \r\n");
System_printf("Tx setup failed \n");
return -1;
}
/* Setup Rx */
if (__setup_rx (ptr_net_device) != 0) {
System_printf("Rx setup failed \r\n");
System_printf("Rx setup failed \n");
return -1;
}
@ -1105,20 +1105,20 @@ static int __emac_start(NETIF_DEVICE* ptr_net_device)
/* Set up the MAC Address LUT*/
if (__add_mac_address (&ethInfo, &routeInfo) != 0) {
System_printf("__add_mac_address failed \r\n");
System_printf("__add_mac_address failed \n");
return -1;
}
memcpy(&ethInfo.dst[0], broadcast_mac_addr, sizeof(paMacAddr_t));
/* Set up the MAC Address LUT for Broadcast */
if (__add_mac_address (&ethInfo, &routeInfo) != 0) {
System_printf("__add_mac_address failed \r\n");
System_printf("__add_mac_address failed \n");
return -1;
}
/* Verify the Tx and Rx Initializations */
if (__verify_init () != 0) {
System_printf("Warning:Queue handler Verification failed \r\n");
System_printf("Warning:Queue handler Verification failed \n");
}
/* Copy the MAC Address into the network interface object here. */
@ -1242,7 +1242,7 @@ void emac_display_linkstatus (uint32_t port_num, uint32_t link_status)
"1000Mb/s Full Duplex"
};
System_printf("Port %d Link Status: %s on PHY %d\r\n",
System_printf("Port %d Link Status: %s on PHY %d\n",
port_num, LinkStr[link_status],
platform_get_phy_addr(port_num));
}
@ -1764,7 +1764,7 @@ static int32_t __init_PASS (Void)
* This queue is used only when configuring the PA PDSP. We will use it when adding our mac address.
*/
if ((gPaCfgCmdRespQHnd = Qmss_queueOpen(Qmss_QueueType_GENERAL_PURPOSE_QUEUE, QMSS_PARAM_NOT_SPECIFIED, &isAllocated)) < 0) {
System_printf ("Error opening a PA Command Response queue \r\n");
System_printf ("Error opening a PA Command Response queue \n");
return -1;
}
@ -1784,7 +1784,7 @@ static int emac_init_core(STKEVENT_Handle hEvent)
ptr_pvt_data = Osal_nimuMalloc (__roundup(sizeof(EMAC_DATA), 128), 128);
if (ptr_pvt_data == NULL) {
System_printf("Error: Unable to allocate private memory data\r\n");
System_printf("Error: Unable to allocate private memory data\n");
return -1;
}
@ -1816,7 +1816,7 @@ static int emac_init_core(STKEVENT_Handle hEvent)
}
if (i == 2) {
System_printf("Error: Unable to find a TX EMAC port\r\n");
System_printf("Error: Unable to find a TX EMAC port\n");
return -1;
}
@ -1827,7 +1827,7 @@ static int emac_init_core(STKEVENT_Handle hEvent)
/* ptr_device needs to be allocated via mmAlloc since NDK frees it during shutdown */
ptr_device = mmAlloc(sizeof(NETIF_DEVICE));
if (ptr_device == NULL) {
System_printf("Error: Unable to allocate memory for the EMAC\r\n");
System_printf("Error: Unable to allocate memory for the EMAC\n");
return -1;
}
@ -1850,27 +1850,27 @@ static int emac_init_core(STKEVENT_Handle hEvent)
/* Init PA LLD */
if (__init_PASS() != 0) {
System_printf("PASS init failed \r\n");
System_printf("PASS init failed \n");
return -1;
} else {
System_printf("PASS successfully initialized \r\n");
System_printf("PASS successfully initialized \n");
}
/* Initialize the CPSW switch */
if (__init_CPSW((uint32_t)ptr_device->mtu, ptr_pvt_data->pdi.bMacAddr) != 0) {
System_printf("Ethernet subsystem init failed \r\n");
System_printf("Ethernet subsystem init failed \n");
return -1;
} else {
System_printf("Ethernet subsystem successfully initialized \r\n");
System_printf("Ethernet subsystem successfully initialized \n");
}
/* Register the device with NIMU */
if (NIMURegister (ptr_device) < 0) {
System_printf("Error: Unable to register the EMAC\r\n");
System_printf("Error: Unable to register the EMAC\n");
return -1;
}
System_printf("Registration of the EMAC Successful, waiting for link up ..\r\n");
System_printf("Registration of the EMAC Successful, waiting for link up ..\n");
return 0;
}

Loading…
Cancel
Save