CM_WRITE.c 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // Mid Level Utility Function: cm_WriteCommand()
  2. //
  3. // Note: this module must be after all low level functions in the library and
  4. // before all high level user function to assure that any reference to
  5. // this function in this library are satistified.
  6. #include "CM_LIB.h"
  7. #include "CM_I2C.h"
  8. #include "CM_I2C_L.h"
  9. #include <unistd.h>
  10. #include <stdio.h>
  11. #include "linux/fcntl.h"
  12. #include "driver.h"
  13. #include <string.h>
  14. uint8_t cm_WriteCommand(uint8_t* pucInsBuff, uint8_t* pucSendVal, uint8_t ucLen)
  15. {
  16. // int i;
  17. // printf("---> cm_WriteCommand: %#02x %#02x %#02x %#02x - ", pucInsBuff[0], pucInsBuff[1], pucInsBuff[2], pucInsBuff[3]);
  18. // for(i=0;i<ucLen;i++)
  19. // printf("%#02x ", pucSendVal[i]);
  20. // printf("\n");
  21. uint8_t ucReturn;
  22. if ((ucReturn = CM_LOW_LEVEL.SendCommand(pucInsBuff)) != SUCCESS)
  23. {
  24. printf("---> cm_WriteCommand ucReturn %d\n", ucReturn);
  25. return ucReturn;
  26. }
  27. ucReturn = CM_LOW_LEVEL.SendData(pucSendVal, ucLen);
  28. //printf("---> cm_WriteCommand over!\n");
  29. return ucReturn;
  30. }