AG903ライブラリリファレンス
Body Source
AG903_UARTMgrSend 関数
本文ソース
コピコード
1: int32_t AG903_UARTMgrSend(
AG903_UARTMgrHandle
* handle, uint8_t* buf, uint32_t size, _Bool dma) 2: { 3: int32_t retval =
AG903_ENONE
; 4: int32_t result; 5: uint32_t sndsz; 6: uint32_t loop; 7: uint8_t ch; 8: 9: result = UARTMgr_CheckHandle(handle, &ch); 10:
if
(
AG903_ENONE
!= result) { 11:
return
-
AG903_EINVAL
; 12: } 13:
if
(
false
== dma) { 14:
if
((NULL == buf) || (0 >= size)) { 15:
return
-
AG903_EINVAL
; 16: } 17:
if
(
AG903_UART_BUFSIZE
< size) { 18:
return
-
AG903_ENOBUFS
; 19: } 20: } 21:
if
(AG903_UART_STAT_IDLE != UartChStat[ch].snd.stat){ 22: 23:
return
-
AG903_EBUSY
; 24: } 25: 26: UartChStat[ch].snd.dma = dma; 27: UartChStat[ch].snd.stat = AG903_UART_STAT_SEND; 28:
if
(
true
== dma) { 29:
AG903_UARTPrmEnableInt
(ch,
AG903_UART_IER_THREMP_BIT
); 30: } 31:
else
{ 32: UartChStat[ch].snd.buf = &UartSendBuf[ch][0]; 33: UartChStat[ch].snd.size = size; 34:
for
(loop=0; loop<UartChStat[ch].snd.size; loop++) { 35: *(UartChStat[ch].snd.buf+loop) = *(buf+loop); 36: } 37:
if
(
AG903_UART_FIFO_SIZE
<= size) { 38: sndsz =
AG903_UART_FIFO_SIZE
; 39: } 40:
else
{ 41: sndsz = size; 42: } 43: UartChStat[ch].snd.cnt = sndsz; 44:
AG903_UARTPrmSendData
(ch, buf, sndsz); 45:
AG903_UARTPrmEnableInt
(ch,
AG903_UART_IER_THREMP_BIT
); 46: } 47: 48: 49:
return
retval; 50: }
Copyright (c) 2017-2025 Axell Corporation. All rights reserved.
内容
|
インデックス
|
ホーム