Skip to content

Commit 29a855f

Browse files
committed
nrfx: hal: uarte: Add function for setting PTR and MAXCNT
There are cases where only PTR or MAXCNT need to be updated and not both. Since register access is costly use dedicated function instead of setting both at once. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 9587b1d commit 29a855f

File tree

1 file changed

+74
-8
lines changed

1 file changed

+74
-8
lines changed

nrfx/hal/nrf_uarte.h

Lines changed: 74 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,24 @@ NRF_STATIC_INLINE void nrf_uarte_configure(NRF_UARTE_Type * p_reg,
703703
NRF_STATIC_INLINE void nrf_uarte_baudrate_set(NRF_UARTE_Type * p_reg,
704704
nrf_uarte_baudrate_t baudrate);
705705

706+
/**
707+
* @brief Function for setting the transmit buffer length.
708+
*
709+
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
710+
* @param[in] length Maximum number of data bytes to receive.
711+
*/
712+
NRF_STATIC_INLINE void nrf_uarte_tx_maxcnt_set(NRF_UARTE_Type * p_reg,
713+
size_t length);
714+
715+
/**
716+
* @brief Function for setting the transmit buffer pointer.
717+
*
718+
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
719+
* @param[in] p_buffer Pointer to the buffer for received data.
720+
*/
721+
NRF_STATIC_INLINE void nrf_uarte_tx_ptr_set(NRF_UARTE_Type * p_reg,
722+
uint8_t const * p_buffer);
723+
706724
/**
707725
* @brief Function for setting the transmit buffer.
708726
*
@@ -732,6 +750,24 @@ NRF_STATIC_INLINE uint8_t const * nrf_uarte_tx_buffer_get(NRF_UARTE_Type * p_reg
732750
*/
733751
NRF_STATIC_INLINE uint32_t nrf_uarte_tx_amount_get(NRF_UARTE_Type const * p_reg);
734752

753+
/**
754+
* @brief Function for setting the receive buffer length.
755+
*
756+
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
757+
* @param[in] length Maximum number of data bytes to receive.
758+
*/
759+
NRF_STATIC_INLINE void nrf_uarte_rx_maxcnt_set(NRF_UARTE_Type * p_reg,
760+
size_t length);
761+
762+
/**
763+
* @brief Function for setting the receive buffer pointer.
764+
*
765+
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
766+
* @param[in] p_buffer Pointer to the buffer for received data.
767+
*/
768+
NRF_STATIC_INLINE void nrf_uarte_rx_ptr_set(NRF_UARTE_Type * p_reg,
769+
uint8_t * p_buffer);
770+
735771
/**
736772
* @brief Function for setting the receive buffer.
737773
*
@@ -1020,19 +1056,34 @@ NRF_STATIC_INLINE void nrf_uarte_baudrate_set(NRF_UARTE_Type * p_reg, nrf_uarte_
10201056
p_reg->BAUDRATE = baudrate;
10211057
}
10221058

1023-
NRF_STATIC_INLINE void nrf_uarte_tx_buffer_set(NRF_UARTE_Type * p_reg,
1024-
uint8_t const * p_buffer,
1059+
NRF_STATIC_INLINE void nrf_uarte_tx_maxcnt_set(NRF_UARTE_Type * p_reg,
10251060
size_t length)
10261061
{
10271062
#if NRF_UARTE_HAS_DMA_REG
1028-
p_reg->DMA.TX.PTR = (uint32_t)p_buffer;
10291063
p_reg->DMA.TX.MAXCNT = length;
10301064
#else
1031-
p_reg->TXD.PTR = (uint32_t)p_buffer;
10321065
p_reg->TXD.MAXCNT = length;
10331066
#endif
10341067
}
10351068

1069+
NRF_STATIC_INLINE void nrf_uarte_tx_ptr_set(NRF_UARTE_Type * p_reg,
1070+
uint8_t const * p_buffer)
1071+
{
1072+
#if NRF_UARTE_HAS_DMA_REG
1073+
p_reg->DMA.TX.PTR = (uint32_t)p_buffer;
1074+
#else
1075+
p_reg->TXD.PTR = (uint32_t)p_buffer;
1076+
#endif
1077+
}
1078+
1079+
NRF_STATIC_INLINE void nrf_uarte_tx_buffer_set(NRF_UARTE_Type * p_reg,
1080+
uint8_t const * p_buffer,
1081+
size_t length)
1082+
{
1083+
nrf_uarte_tx_ptr_set(p_reg, p_buffer);
1084+
nrf_uarte_tx_maxcnt_set(p_reg, length);
1085+
}
1086+
10361087
NRF_STATIC_INLINE uint8_t const * nrf_uarte_tx_buffer_get(NRF_UARTE_Type * p_reg)
10371088
{
10381089
#if NRF_UARTE_HAS_DMA_REG
@@ -1051,19 +1102,34 @@ NRF_STATIC_INLINE uint32_t nrf_uarte_tx_amount_get(NRF_UARTE_Type const * p_reg)
10511102
#endif
10521103
}
10531104

1054-
NRF_STATIC_INLINE void nrf_uarte_rx_buffer_set(NRF_UARTE_Type * p_reg,
1055-
uint8_t * p_buffer,
1105+
NRF_STATIC_INLINE void nrf_uarte_rx_maxcnt_set(NRF_UARTE_Type * p_reg,
10561106
size_t length)
10571107
{
10581108
#if NRF_UARTE_HAS_DMA_REG
1059-
p_reg->DMA.RX.PTR = (uint32_t)p_buffer;
10601109
p_reg->DMA.RX.MAXCNT = length;
10611110
#else
1062-
p_reg->RXD.PTR = (uint32_t)p_buffer;
10631111
p_reg->RXD.MAXCNT = length;
10641112
#endif
10651113
}
10661114

1115+
NRF_STATIC_INLINE void nrf_uarte_rx_ptr_set(NRF_UARTE_Type * p_reg,
1116+
uint8_t * p_buffer)
1117+
{
1118+
#if NRF_UARTE_HAS_DMA_REG
1119+
p_reg->DMA.RX.PTR = (uint32_t)p_buffer;
1120+
#else
1121+
p_reg->RXD.PTR = (uint32_t)p_buffer;
1122+
#endif
1123+
}
1124+
1125+
NRF_STATIC_INLINE void nrf_uarte_rx_buffer_set(NRF_UARTE_Type * p_reg,
1126+
uint8_t * p_buffer,
1127+
size_t length)
1128+
{
1129+
nrf_uarte_rx_ptr_set(p_reg, p_buffer);
1130+
nrf_uarte_rx_maxcnt_set(p_reg, length);
1131+
}
1132+
10671133
NRF_STATIC_INLINE uint8_t * nrf_uarte_rx_buffer_get(NRF_UARTE_Type * p_reg)
10681134
{
10691135
#if NRF_UARTE_HAS_DMA_REG

0 commit comments

Comments
 (0)