Other Parts Discussed in Thread: HALCOGEN
Tool/software:
Hi,
I'm implementing an Hardware Abstraction Layer for the TI hercules HalCoGen .
Here's the function signature that I need to implement:
Mcu_Status_t mcu_spi_blocking_send(Mcu_SpiHandle_t spi, size_t size, uint8_t data[size]);
Notice that, while the implementation has a data type of `uint8_t*`, the `spiTransmitData()` function provided by HalCoGen only accept `uint16_t*`.
To solve this problem I was forced to copy the data to a temporary buffer:
Mcu_Status_t mcu_spi_blocking_send(Mcu_SpiHandle_t spi, size_t size, uint8_t data[size])
{
// We need to copy the data in the buffer because the TI only accept uint16_t*.
// This stress the stack and this is slow.
uint16_t buffer[256] = {0};
for (size_t i = 0; i < size; i++)
{
buffer[i] = data[i];
}
spi_cs(true);
spiTransmitData(SPI_REG, &g_spi_data_format, size, buffer);
spi_cs(false);
return MCU_SUCCESS;
}
Unnecessary buffer copies are pretty slow and stresses the stack, so I wondered:
Is there a smarter way to do this? Maybe I'm missing a HalCoGen configuration that would solve this problem?
If not, do you have an example of a custom `spiTransmitData` implementation that use uint8_t exclusively ?
P.S. I don't think I can simply cast the uint8_t* to uint16_t* because of the endianness of the TI RM46.
Regards,
Gabriel