From 6e58c44390303261af4a721df522affbc99c88ad Mon Sep 17 00:00:00 2001 From: sago35 Date: Fri, 10 May 2024 22:35:36 +0900 Subject: [PATCH] machine: add TxFifoFreeLevel() for CAN --- src/machine/machine_atsame5x_can.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/machine/machine_atsame5x_can.go b/src/machine/machine_atsame5x_can.go index 498646980d..bf38cd8988 100644 --- a/src/machine/machine_atsame5x_can.go +++ b/src/machine/machine_atsame5x_can.go @@ -221,6 +221,11 @@ func (can *CAN) TxFifoIsFull() bool { return (can.Bus.TXFQS.Get() & sam.CAN_TXFQS_TFQF_Msk) == sam.CAN_TXFQS_TFQF_Msk } +// TxFifoFreeLevel returns how many messages can still be set in the TxFifo. +func (can *CAN) TxFifoFreeLevel() int { + return int(can.Bus.GetTXFQS_TFFL()) +} + // TxRaw sends a CAN Frame according to CANTxBufferElement. func (can *CAN) TxRaw(e *CANTxBufferElement) { putIndex := (can.Bus.TXFQS.Get() & sam.CAN_TXFQS_TFQPI_Msk) >> sam.CAN_TXFQS_TFQPI_Pos