Customized SNICInterface
Fork of NySNICInterface by
Diff: SNIC/SNIC_Core.cpp
- Revision:
- 35:e4e7f86fd975
- Parent:
- 33:33f1bc919486
- Child:
- 36:f33fcf5975ab
--- a/SNIC/SNIC_Core.cpp Mon Jun 09 08:28:07 2014 +0000 +++ b/SNIC/SNIC_Core.cpp Tue Jun 10 10:19:48 2014 +0000 @@ -16,15 +16,14 @@ #include <string> /** Wait signal ID of UART recv */ -#define UART_DISPATCH_SIGNAL 0x00000002 -#define UART_RECEIVE_SIGNAL 0x00000004 +#define UART_DISPATCH_SIGNAL 0x00000002 -#define UART_RECVBUF_SIZE 2048 +#define UART_RECVBUF_SIZE 2048 #define UART_THREAD_STACK_SIZE 512 typedef struct { - tagMEMPOOL_BLOCK_T *mem_p; + tagMEMPOOL_BLOCK_T *mem_p; unsigned int size; }tagUART_RECVBUF_T; @@ -38,7 +37,7 @@ MemoryPool<tagMEMPOOL_BLOCK_T, MEMPOOL_PAYLOAD_NUM> mMemPoolPayload __attribute__((section("AHBSRAM1"))); /** MemoryPool for UART receive */ MemoryPool<tagMEMPOOL_BLOCK_T, MEMPOOL_UART_RECV_NUM> mMemPoolUartRecv __attribute__((section("AHBSRAM1"))); -Queue<tagMEMPOOL_BLOCK_T, MEMPOOL_UART_RECV_NUM> mUartRecvQueue; +Queue<tagMEMPOOL_BLOCK_T, MEMPOOL_UART_RECV_NUM> mUartRecvQueue; tagMEMPOOL_BLOCK_T *gUART_RCVBUF_p; C_SNIC_Core *C_SNIC_Core::mInstance_p = NULL; @@ -88,8 +87,6 @@ int C_SNIC_Core::initUart(PinName tx, PinName rx, int baud) { -// printf("[C_SNIC_Core::initUart]1\r\n"); - mUartRequestSeq = 0; mUart_p = new RawSerial( tx, rx ); @@ -99,7 +96,7 @@ // Initialize uart gUART_RCVBUF_p = NULL; - mUart_p->attach( C_SNIC_Core::uartRecvCallback ); + mUart_p->attach( C_SNIC_Core::uartRecvCallback ); // Create UART recv dispatch thread mUartRecvDispatchThread_p = new Thread( C_SNIC_Core::uartRecvDispatchThread, NULL, osPriorityNormal, UART_THREAD_STACK_SIZE); if( mUartRecvDispatchThread_p == NULL ) @@ -140,7 +137,6 @@ ret = mUart_p->putc( data[i] ); if( ret == -1 ) { - ret = -1; break; } } @@ -198,8 +194,6 @@ return gUART_COMMAND_BUF; } -DigitalOut led1(LED1); - void C_SNIC_Core::uartRecvCallback( void ) { C_SNIC_Core *instance_p = C_SNIC_Core::getInstance(); @@ -208,7 +202,6 @@ int recvdata = 0; // set signal -// instance_p->mUartRecvThread_p->signal_set( UART_RECEIVE_SIGNAL ); if( instance_p->mUart_p->readable() ) { // Receive data from UART. @@ -225,7 +218,6 @@ // Check received data is EOM. if( recvdata == UART_CMD_EOM ) { - led1 = 0; // Add queue mUartRecvQueue.put( gUART_RCVBUF_p ); @@ -240,7 +232,6 @@ // Check received data is SOM. if( recvdata == UART_CMD_SOM ) { - led1 = 1; gUART_RCVBUF_p = instance_p->allocUartRcvBuf(); gUART_RCVBUF_p->size = 0; // get buffer for Uart receive @@ -315,8 +306,6 @@ // Checks in the command which is waiting. else if( uartCmdMgr_p->isWaitingCommand(command_id, gUART_TEMP_BUF) ) { - //lcd_printf("cid:%02x scid:%02x\r\n", command_id, gUART_TEMP_BUF[0]); - // Get buffer for payload data unsigned char *payload_buf_p = uartCmdMgr_p->getResponseBuf(); if( payload_buf_p != NULL )