CM_SWRUSER.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Write Small User Zone
  2. //
  3. // The Write Small User Zone function is used to write data to CryptoMemory devices that have
  4. // 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. // Write Small User Zone
  11. uint8_t cm_WriteSmallZone(uint8_t ucCryptoAddr, uint8_t* pucBuffer, uint8_t ucCount)
  12. {
  13. uint8_t ucReturn;
  14. ucCM_InsBuff[0] = 0xb0;
  15. ucCM_InsBuff[1] = 0x00;
  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. // Include the data in the polynominals and encrypt it required
  21. cm_GPAencrypt(ucCM_Encrypt, pucBuffer, ucCount);
  22. // Write the data
  23. ucReturn = cm_WriteCommand(ucCM_InsBuff, pucBuffer,ucCount);
  24. // when anti-tearing, the host should send ACK should >= 20ms after write command
  25. if (ucCM_AntiTearing) CM_LOW_LEVEL.WaitClock(100); //10
  26. return ucReturn;
  27. }