I've created a simple application to create a random number based on examples on this forum. Unfortunately, I always receive an 'HSE_SRV_RSP_INVALID_ADDR' response. I've tried with the Hse_Ip drivers and the hse_host.h files and get the same results each time. Cache is disabled.
If I modify the hse demoapp to create a random number, it works. I suspect the difference lays within the linker or startup assembly file, but I'm not sure. I've tried searching this response, but didn't find anything related in the docs or forums.
#include "Mcal.h"
#include "hse_host.h"
#include "sys_init.h"
#include <string.h>
#include "S32K312.h"
static uint8_t muIf = 0U; /* MU0 */
static uint8_t muChannelIdx = 1U; /* channel 1 */
hseSrvResponse_t getRandomNumReq(hseRngClass_t rngClass, uint32_t rngNumSize, uint8_t *rngNum)
{
hseSrvResponse_t hseStatus = HSE_SRV_RSP_GENERAL_ERROR;
hseGetRandomNumSrv_t *pGetRndSrv;
hseSrvDescriptor_t *pHseSrvDesc = &gHseSrvDesc[muIf][muChannelIdx];
memset(pHseSrvDesc, 0, sizeof(hseSrvDescriptor_t));
pHseSrvDesc->srvId = HSE_SRV_ID_GET_RANDOM_NUM;
pGetRndSrv = &(pHseSrvDesc->hseSrv.getRandomNumReq);
pGetRndSrv->rngClass = rngClass;
pGetRndSrv->pRandomNum = (HOST_ADDR)rngNum;
pGetRndSrv->randomNumLength = rngNumSize;
hseStatus = HSE_Send(muIf, muChannelIdx, gSyncTxOption, pHseSrvDesc);
return hseStatus;
}
int main(void)
{
hseSrvResponse_t srvResponse = HSE_SRV_RSP_GENERAL_ERROR;
uint8_t RandomNumber[16] = {0};
while (HSE_STATUS_INIT_OK == 0);
srvResponse = getRandomNumReq(HSE_RNG_CLASS_DRG3, 16, RandomNumber);
while(srvResponse != HSE_SRV_RSP_OK);
return 0;
}
/** @} */