Hi Kan,
Thanks for your reply, but sadly this tip didn't help. I got the same result, but after receive one "result" im getting PE_debughalt,
Result should be 0 or 1 as it is in mmcau/Cau User Guide, Can you give me correct code to send text and receive hash?
i begins to doubt that hardware hashing is really presented in this chip.
Kindly Regrads Alex
PS. Here is the code:
/* ###################################################################
** Filename : ProcessorExpert.c
** Project : ProcessorExpert
** Processor : MK60DN512VLQ10
** Version : Driver 01.01
** Compiler : GNU C Compiler
** Date/Time : 2013-06-20, 18:36, # CodeGen: 0
** Abstract :
** Main module.
** This module contains user's application code.
** Settings :
** Contents :
** No public methods
**
** ###################################################################*/
/*!
** @file ProcessorExpert.c
** @version 01.01
** @brief
** Main module.
** This module contains user's application code.
*/
/*!
** @addtogroup ProcessorExpert_module ProcessorExpert module documentation
** @{
*/
/* MODULE ProcessorExpert */
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "AS1.h"
#include "PE_Types.h"
#include "PE_Error.h"
#include "cau_api.h"
#include "PE_Const.h"
#include "IO_Map.h"
#define FREESCALE_MMCAU
/* User includes (#include below this line is not maintained by Processor Expert) */
volatile bool DataReceivedFlg = FALSE;
char InpData[10];
unsigned char hashed[32];
int num_blks_sha256;
unsigned int *out;
int i;
char padded[192];
LDD_TError Error;
LDD_TDeviceData *MySerialPtr;
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
/* Write your local variable definition here */
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
MySerialPtr = AS1_Init(NULL);
for(;;)
{
Error = AS1_ReceiveBlock(MySerialPtr, InpData, 1U); /* Start reception of one character */
while (!DataReceivedFlg);
mmcau_sha256_initialize_output(*out);
sprintf(hashed, " %d ", (*out));
Error = AS1_SendBlock(MySerialPtr, hashed, sizeof(hashed)); /* Send block of characters */
DataReceivedFlg = FALSE;
}
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;){}
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
void pad_sha256(char *p, char *padded)
{
int i, nbits, nbytes;
for (i=0; ; i++) {
padded[i] = p[i];
if (p[i] == 0) break;
}
nbytes = i;
padded[i++] = 0x80;
num_blks_sha256 = (((nbytes + 9) % 64) == 0)
? ((nbytes + 9) / 64)
: ((nbytes + 9) / 64) + 1;
for (; i < (64 * num_blks_sha256) - 4;)
padded[i++] = 0;
nbits = nbytes << 3;
padded[i++] = nbits >> 24;
padded[i++] = nbits >> 16;
padded[i++] = nbits >> 8;
padded[i] = nbits;
}
/* END ProcessorExpert */
/*!
** @}
*/
/*
** ###################################################################
**
** This file was created by Processor Expert 10.2 [05.06]
** for the Freescale Kinetis series of microcontrollers.
**
** ###################################################################
*/