/* Configures maximum size of message payload, which can be stored either in dedicated transmit buffer or into transmit queue/FIFO. One size is applied both to transmit buffer and transmit queue / FIFO. Buffers can only be configured to sizes which are valid sizes of FDCAN payload. Sizes smaller than 8 are automatically padded to 8 bytes.  */
int fdcan_set_tx_element_size(uint32_t canport, uint8_t txbuf)
/* Configures maximum size of message payload, which can be stored either in dedicated transmit buffer or into transmit queue/FIFO. One size is applied both to transmit buffer and transmit queue / FIFO. Buffers can only be configured to sizes which are valid sizes of FDCAN payload. Sizes smaller than 8 are automatically padded to 8 bytes.  */
int fdcan_set_tx_element_size(uint32_t canport, uint8_t txbuf)
{
	unsigned txbufdlc = fdcan_length_to_dlc(txbuf);
	if (txbufdlc == 0xFF) {
		return FDCAN_E_INVALID;
	}
	if (txbufdlc <= 8) {
		txbufdlc = 0;
	} else {
		txbufdlc &= ~(1 << 4);
	}
	FDCAN_TXESC(canport) = txbufdlc << FDCAN_TXESC_TBDS_SHIFT;
	return FDCAN_E_OK;
}