Skip to content

Commit cf5b5a0

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 cf5b5a0

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

nrfx/hal/nrf_uarte.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,24 @@ NRF_STATIC_INLINE void nrf_uarte_tx_buffer_set(NRF_UARTE_Type * p_reg,
714714
uint8_t const * p_buffer,
715715
size_t length);
716716

717+
/**
718+
* @brief Function for setting the transmit buffer length.
719+
*
720+
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
721+
* @param[in] length Maximum number of data bytes to receive.
722+
*/
723+
NRF_STATIC_INLINE void nrf_uarte_tx_maxcnt_set(NRF_UARTE_Type * p_reg,
724+
size_t length);
725+
726+
/**
727+
* @brief Function for setting the transmit buffer pointer.
728+
*
729+
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
730+
* @param[in] p_buffer Pointer to the buffer for received data.
731+
*/
732+
NRF_STATIC_INLINE void nrf_uarte_tx_ptr_set(NRF_UARTE_Type * p_reg,
733+
uint8_t * p_buffer);
734+
717735
/**
718736
* @brief Function for getting the transmit buffer address.
719737
*
@@ -743,6 +761,24 @@ NRF_STATIC_INLINE void nrf_uarte_rx_buffer_set(NRF_UARTE_Type * p_reg,
743761
uint8_t * p_buffer,
744762
size_t length);
745763

764+
/**
765+
* @brief Function for setting the receive buffer length.
766+
*
767+
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
768+
* @param[in] length Maximum number of data bytes to receive.
769+
*/
770+
NRF_STATIC_INLINE void nrf_uarte_rx_maxcnt_set(NRF_UARTE_Type * p_reg,
771+
size_t length);
772+
773+
/**
774+
* @brief Function for setting the receive buffer pointer.
775+
*
776+
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
777+
* @param[in] p_buffer Pointer to the buffer for received data.
778+
*/
779+
NRF_STATIC_INLINE void nrf_uarte_rx_ptr_set(NRF_UARTE_Type * p_reg,
780+
uint8_t * p_buffer);
781+
746782
/**
747783
* @brief Function for getting the reception buffer address.
748784
*
@@ -1033,6 +1069,26 @@ NRF_STATIC_INLINE void nrf_uarte_tx_buffer_set(NRF_UARTE_Type * p_reg,
10331069
#endif
10341070
}
10351071

1072+
NRF_STATIC_INLINE void nrf_uarte_tx_maxcnt_set(NRF_UARTE_Type * p_reg,
1073+
size_t length)
1074+
{
1075+
#if NRF_UARTE_HAS_DMA_REG
1076+
p_reg->DMA.TX.MAXCNT = length;
1077+
#else
1078+
p_reg->TXD.MAXCNT = length;
1079+
#endif
1080+
}
1081+
1082+
NRF_STATIC_INLINE void nrf_uarte_tx_ptr_set(NRF_UARTE_Type * p_reg,
1083+
uint8_t * p_buffer)
1084+
{
1085+
#if NRF_UARTE_HAS_DMA_REG
1086+
p_reg->DMA.TX.PTR = (uint32_t)p_buffer;
1087+
#else
1088+
p_reg->TXD.PTR = (uint32_t)p_buffer;
1089+
#endif
1090+
}
1091+
10361092
NRF_STATIC_INLINE uint8_t const * nrf_uarte_tx_buffer_get(NRF_UARTE_Type * p_reg)
10371093
{
10381094
#if NRF_UARTE_HAS_DMA_REG
@@ -1064,6 +1120,26 @@ NRF_STATIC_INLINE void nrf_uarte_rx_buffer_set(NRF_UARTE_Type * p_reg,
10641120
#endif
10651121
}
10661122

1123+
NRF_STATIC_INLINE void nrf_uarte_rx_maxcnt_set(NRF_UARTE_Type * p_reg,
1124+
size_t length)
1125+
{
1126+
#if NRF_UARTE_HAS_DMA_REG
1127+
p_reg->DMA.RX.MAXCNT = length;
1128+
#else
1129+
p_reg->RXD.MAXCNT = length;
1130+
#endif
1131+
}
1132+
1133+
NRF_STATIC_INLINE void nrf_uarte_rx_ptr_set(NRF_UARTE_Type * p_reg,
1134+
uint8_t * p_buffer)
1135+
{
1136+
#if NRF_UARTE_HAS_DMA_REG
1137+
p_reg->DMA.RX.PTR = (uint32_t)p_buffer;
1138+
#else
1139+
p_reg->RXD.PTR = (uint32_t)p_buffer;
1140+
#endif
1141+
}
1142+
10671143
NRF_STATIC_INLINE uint8_t * nrf_uarte_rx_buffer_get(NRF_UARTE_Type * p_reg)
10681144
{
10691145
#if NRF_UARTE_HAS_DMA_REG

0 commit comments

Comments
 (0)