diff options
author | Karl Palsson <karlp@tweak.net.au> | 2022-01-21 22:30:00 +0100 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2022-01-26 23:42:37 +0100 |
commit | 32df2ae55601f1ad135247ad79a913514d018032 (patch) | |
tree | 5e6227ed28a61f35a1d37952abe64279a8367fec /wpan | |
parent | 1155f57710a068efbdc7fdd167ac4e44dd54ec7f (diff) |
stm32_ipcc: helper methods to ease porting ST code
Make it a litle easier to read for some bits that are constantly
checked.
Signed-off-by: Karl Palsson <karlp@tweak.net.au>
Diffstat (limited to 'wpan')
-rw-r--r-- | wpan/stm32_ipcc.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/wpan/stm32_ipcc.h b/wpan/stm32_ipcc.h index e264d8b..c631ecf 100644 --- a/wpan/stm32_ipcc.h +++ b/wpan/stm32_ipcc.h @@ -19,4 +19,36 @@ template <typename T> class STM32_IPCC_t : public mmio_ptr<T> { public: using mmio_ptr<T>::ptr; + + bool tx_pending(uint32_t channel) const { + bool unmasked = ~(ptr()->C1MR) & ((1<<channel) << 16); + return unmasked && (!(ptr()->C1TOC2SR & (1<<channel))); + } + + bool rx_pending(uint32_t channel) const { + bool unmasked = ~(ptr()->C1MR) & (1<<channel); + return unmasked && (ptr()->C2TOC1SR & (1<<channel)); + } + + void c1_set_flag(const uint32_t channel) const { + ptr()->C1SCR = (1<<channel) << 16; + } + void c1_clear_flag(const uint32_t channel) const { + ptr()->C1SCR = (1<<channel); + } + + void enable_rx(const uint32_t channel) const { + ptr()->C1MR &= ~(1<<channel); + } + void disable_rx(const uint32_t channel) const { + ptr()->C1MR |= (1<<channel); + } + + void enable_tx(const uint32_t channel) const { + ptr()->C1MR &= ~((1<<channel) << 16); + } + void disable_tx(const uint32_t channel) const { + ptr()->C1MR |= (1<<channel) << 16; + } + }; |