| // Copyright 2023 Google LLC. |
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| // SPDX-License-Identifier: Apache-2.0 |
| |
| #include "sw/device/lib/dif/dif_i2s.h" |
| |
| #include "i2s_regs.h" // Generated. |
| #include "sw/device/lib/base/bitfield.h" |
| #include "sw/device/lib/base/macros.h" |
| #include "sw/device/lib/dif/dif_base.h" |
| |
| dif_result_t dif_i2s_rxfifo_empty(const dif_i2s_t* i2s, bool* empty) { |
| if (!i2s || !empty) { |
| return kDifBadArg; |
| } |
| |
| uint32_t reg_val = mmio_region_read32(i2s->base_addr, I2S_STATUS_REG_OFFSET); |
| *empty = bitfield_bit32_read(reg_val, I2S_STATUS_RXEMPTY_BIT); |
| return kDifOk; |
| } |
| |
| dif_result_t dif_i2s_txfifo_full(const dif_i2s_t* i2s, bool* full) { |
| if (!i2s || !full) { |
| return kDifBadArg; |
| } |
| |
| uint32_t reg_val = mmio_region_read32(i2s->base_addr, I2S_STATUS_REG_OFFSET); |
| *full = bitfield_bit32_read(reg_val, I2S_STATUS_TXFULL_BIT); |
| return kDifOk; |
| } |