AG903ライブラリリファレンス
内容インデックスホーム
前へ上へ次へ
AG903_UARTMgrGetReceiveData 関数

受信データ取得

Syntax
C++
int32_t AG903_UARTMgrGetReceiveData(AG903_UARTMgrHandle* handle, uint8_t* buf, uint32_t size);
引数 
説明 
AG903_UARTMgrHandle* handle 
[in] UARTハンドル 
uint8_t* buf 
[out] 受信データ格納アドレス 
uint32_t size 
[in] 受信データサイズ 

受信データ取得結果

返値の詳細 
説明 
-AG903_EINVAL 
引数異常 

受信データを取得します。 

受信データがない場合は0を返します。

1: int32_t AG903_UARTMgrGetReceiveData(AG903_UARTMgrHandle* handle, uint8_t* buf, uint32_t size) 2: { 3: int32_t result; 4: int32_t cnt; 5: uint8_t ch; 6: uint8_t loop; 7: uint8_t stat; 8: 9: result = UARTMgr_CheckHandle(handle, &ch); 10: if(AG903_ENONE != result) { 11: return -AG903_EINVAL; 12: } 13: if( (NULL == buf) || (0 >= size) ){ 14: return -AG903_EINVAL; 15: } 16: 17: cnt = 0; 18: for(loop=0; loop<AG903_UART_FIFO_SIZE; loop++) { 19: AG903_UARTPrmGetLineStatus(ch, &stat); 20: if(0 == (AG903_UART_LSR_DATARDY_BIT&stat)) { 21: break; 22: } 23: AG903_UARTPrmGetReceiveData(ch, buf); 24: buf++; 25: cnt++; 26: if(size <= (uint32_t)cnt) { 27: break; 28: } 29: } 30: 31: return cnt; 32: }
Copyright (c) 2017-2025 Axell Corporation. All rights reserved.