CM_SRDUSER.c 982 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Read Small User Zone
  2. //
  3. // The Read Small User Zone function is used to read data from CryptoMemory devices that
  4. // have 256 bytes or less in each user zone (AT88SC3216C, and smaller)
  5. // CryptoMemory Library Include Files
  6. #include "CM_LIB.h"
  7. #include "CM_I2C.h"
  8. #include "CM_I2C_L.h"
  9. #include "CM_GPA.h"
  10. // Read Small User Zone
  11. uint8_t cm_ReadSmallZone(uint8_t ucCryptoAddr, uint8_t* pucBuffer, uint8_t ucCount)
  12. {
  13. uint8_t ucReturn;
  14. ucCM_InsBuff[0] = 0xb2;
  15. ucCM_InsBuff[1] = 0;
  16. ucCM_InsBuff[2] = ucCryptoAddr;
  17. ucCM_InsBuff[3] = ucCount;
  18. // Two bytes of the command must be included in the polynominals
  19. cm_GPAcmd2(ucCM_InsBuff);
  20. // Read the data
  21. if ((ucReturn = cm_ReadCommand(ucCM_InsBuff, pucBuffer, ucCount)) != SUCCESS) return ucReturn;
  22. // Include the data in the polynominals and decrypt it required
  23. cm_GPAdecrypt(ucCM_Encrypt, pucBuffer, ucCount);
  24. // Done
  25. return SUCCESS;
  26. }