/* Both SFRs and RAM memory can be written at word level. */
int32_t can_ctrl_ram_write(struct can_ctrl_dev *dev, uint16_t address, uint32_t data)
/* Both SFRs and RAM memory can be written at word level. */
int32_t can_ctrl_ram_write(struct can_ctrl_dev *dev, uint16_t address, uint32_t data)
{
	uint8_t spi_msg[] = {0, 0, 0, 0, 0, 0};
	spi_msg[0] |= CAN_CTRL_CMD_MODE(CAN_CTRL_CMD_WRITE);
	spi_msg[0] |= CAN_CTRL_ADDR_UP_NIBBLE_MODE(address);
	spi_msg[1] |= CAN_CTRL_ADDR_DW_BYTE_MODE(address);
	spi_msg[2] = (data & 0x000000ff) >> 0;
	spi_msg[3] = (data & 0x0000ff00) >> 8;
	spi_msg[4] = (data & 0x00ff0000) >> 16;
	spi_msg[5] = (data & 0xff000000) >> 24;
	return spi_write_and_read(dev->can_ctrl_spi, spi_msg, 6);
}