Fwd: STM CUBE - zkusenosti

Jaroslav Buchta jaroslav.buchta na hascomp.cz
Sobota Říjen 3 01:04:07 CEST 2015


Nakonec jsem to takovou metodou rovnak na ohejbak udelal, ale nelibi se 
mi to :-( Hlavne ze ukradnu UARTu callback funkci... Neni to moc ucesane 
po ruznych pokusech.

volatile static char dbgBuf[TXBUFFERSIZE];
volatile static int dbgBufR = 0;
volatile static int dbgBufW = 0;
volatile static int dbgTxCnt = 0;


static void TxRecovery();
static void   (* XferHalfCpltCallback)( struct __DMA_HandleTypeDef * hdma);

static void DbgTxCpltCallback(DMA_HandleTypeDef *hdma)
{
     uint32_t origPri = ulPortRaiseBASEPRI();
     HAL_UART_DMAStop(hDbgUart);     // uvede UART driver do stavu ready 
pro TX
     dbgBufR += dbgTxCnt;
     if (dbgBufR >= TXBUFFERSIZE) dbgBufR = 0;
     dbgTxCnt = 0;
     TxRecovery();
     vPortSetBASEPRI(origPri);
}


static void TxRecovery()
{
     if (dbgTxCnt != 0) return;
     if (dbgBufR == dbgBufW) return;
     int nCnt = dbgBufW - dbgBufR;
     if (nCnt < 0) nCnt = TXBUFFERSIZE - dbgBufR;
     if (nCnt > 64) nCnt = 64;
     HAL_UART_Transmit_DMA(hDbgUart, (uint8_t *)dbgBuf+dbgBufR, nCnt);
     hDbgUart->hdmatx->XferCpltCallback = DbgTxCpltCallback;            
                         //!!!!!
     dbgTxCnt = nCnt;
}

void DBGUSART_dbgSendChar(char c)
{
     vPortEnterCritical();
     dbgBuf[dbgBufW] = c;
     int w = dbgBufW+1;
     if (w >= sizeof(dbgBuf)) w = 0;
     if (w != dbgBufR) dbgBufW = w;
     TxRecovery();
     vPortExitCritical();
}



---
Tato zpráva byla zkontrolována na viry programem Avast Antivirus.
https://www.avast.com/antivirus



Další informace o konferenci Hw-list