Post by vinicius on Jul 22, 2018 14:24:37 GMT
Hello!
In upcoming project I will need to use NXP TJA1145 can transceiver.
I was wondering if anyone have already done something with AURIX and TJA1145. NXP do provide the library for the communication SPI, I think basically just need to add SPI configuration, for example:
In upcoming project I will need to use NXP TJA1145 can transceiver.
I was wondering if anyone have already done something with AURIX and TJA1145. NXP do provide the library for the communication SPI, I think basically just need to add SPI configuration, for example:
/**
* \brief SPI transmission routine
* \todo implement this function with your microcontroller specific code
* - Disable interrupts
* - SPI_DATA_REG = tx;
* - Wait until transition is done
* - tx = SPI_DATA_REG
* - Enable interrupts
* Remark: Furthermore, this function should not only send data via SPI, it should also check, if the SPI access was successful.
* Therefore, after the 1st SPI access, a 2nd SPI read access is performed to ensure that the configurations has been
* changed or rather the 1st read values have been correct.
*
* \param data A pointer to the data which shall be transmitted by the SPI interface
* \param length Number of data Bytes which shall be transmitted by the SPI interface
* \param mask Mask of Bits interesting for the consistency check
* \param type Type (write/read/interrupt) of the SPI access
* \return <b>NXP_UJA11XX_Error_Code_t</b> possible values: NXP_UJA11XX_ERROR_WRITE_FAIL = 0, NXP_UJA11XX_ERROR_READ_FAIL = 1, NXP_UJA11XX_ERROR_SPI_HW_FAIL = 2, NXP_UJA11XX_SUCCESS = 3
*/
NXP_UJA11XX_Error_Code_t SPI_Send(Byte* data, NXP_UJA11XX_SPI_Msg_Length_t length, Byte mask, NXP_UJA11XX_Access_t type) {
// Insert your microcontroller specific code here
// e.g.
// First SPI access:
// - Disable interrupts
// - SPI_DATA_REG = tx;
// - Wait until transision done
// - tx = SPI_DATA_REG
// - Enable interrupts
// If no MTP register is accessed, read a second time:
// - Disable interrupts
// - SPI_DATA_REG = tx;
// - Wait until transision done
// - tx = SPI_DATA_REG
// - Enable interrupts
// Check of consistency:
// - In case of a write access:
// -- If address bytes of both SPI accesses and the data byte(s) sent in 1st and read back in 2nd SPI access are similar, SPI access was successful (NXP_UJA11XX_SUCCESS).
// -- Else if address and data byte(s) read back are '0x00' or '0xFF', NXP_UJA11XX_ERROR_SPI_HW_FAIL is returned.
// -- Else SPI write access was not succesful and NXP_UJA11XX_ERROR_WRITE_FAIL is returned.
// - In case of an read access:
// -- If address bytes and the data byte(s) of both SPI read accesses are similar, SPI access was successful (NXP_UJA11XX_SUCCESS).
// -- Else SPI read access was not succesful and NXP_UJA11XX_ERROR_READ_FAIL is returned.
// - In case of an access to an interrupt register:
// -- If address bytes of both SPI accesses are similar and the according interrupt bit(s) are cleared in 2nd SPI access data, SPI access was successful.
// -- Else SPI write access was not succesful and NXP_UJA11XX_ERROR_WRITE_FAIL is returned.
return 3;
}