blob: 571ea1f4cdfe66fed9854b8af4b3827c5c7657f4 [file] [log] [blame]
/*
* Copyright 2023 Google LLC
* Copyright lowRISC contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#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;
}