CM_READ.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Mid Level Utility Function: cm_ReadCommand()
  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_ReadCommand(uint8_t * pucInsBuff, uint8_t * pucRetVal, uint8_t ucLen)
  15. {
  16. uint8_t ucReturn;
  17. if(ucLen < 1)
  18. {
  19. printf("Invalid ucLen %d\n", ucLen);
  20. return -1;
  21. }
  22. if ((ucReturn = CM_LOW_LEVEL.SendCommand(pucInsBuff)) != SUCCESS) return ucReturn;
  23. ucReturn = CM_LOW_LEVEL.ReceiveRet(pucRetVal, ucLen);
  24. // printf("---> cm_ReadCommand: %#02x %#02x %#02x %#02x - ", pucInsBuff[0], pucInsBuff[1], pucInsBuff[2], pucInsBuff[3]);
  25. // int i;
  26. // for (i = 0; i < ucLen; i++)
  27. // {
  28. // printf("%#02x ", pucRetVal[i]);
  29. // }
  30. // printf("\n");
  31. return ucReturn;
  32. }