CM_WRUSER.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Write User Zone
  2. //
  3. // The Write Large User Zone function is used to write data to CryptoMemory devices that have
  4. // greater than 256 bytes in each user zone (AT88SC6416C, and larger).
  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. // Write User Zone
  11. char cm_WriteLargeZone(uint32_t uiCryptoAddr, uint8_t* pucBuffer, uint8_t ucCount)
  12. {
  13. uint8_t ucReturn;
  14. ucCM_InsBuff[0] = 0xb0;
  15. ucCM_InsBuff[1] = (uint8_t)(uiCryptoAddr>>8);
  16. ucCM_InsBuff[2] = (uint8_t)uiCryptoAddr;
  17. ucCM_InsBuff[3] = ucCount;
  18. // Three bytes of the command must be included in the polynominals
  19. cm_GPAcmd3(ucCM_InsBuff);
  20. // Include the data in the polynominals and encrypt it required
  21. cm_GPAencrypt(ucCM_Encrypt, pucBuffer, ucCount);
  22. ucReturn = cm_WriteCommand(ucCM_InsBuff, pucBuffer, ucCount);
  23. // when anti-tearing, the host should send ACK should >= 20ms after write command
  24. if (ucCM_AntiTearing) CM_LOW_LEVEL.WaitClock(100); //10
  25. // Done
  26. return ucReturn;
  27. }