luat_gtfont.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "luat_base.h"
  2. #include "luat_spi.h"
  3. #ifndef u8
  4. #define u8 uint8_t
  5. #endif
  6. #define LUAT_GT_DEBUG 1
  7. #define LUAT_LOG_TAG "gt"
  8. #include "luat_log.h"
  9. luat_spi_device_t* gt_spi_dev = NULL;
  10. unsigned long r_dat_bat(unsigned long address,unsigned long DataLen,unsigned char *pBuff) {
  11. #if LUAT_GT_DEBUG
  12. // LLOGD("r_dat_bat addr %08X len %d pBuff %X", address, DataLen,*pBuff);
  13. #endif
  14. if (gt_spi_dev == NULL)
  15. return 0;
  16. char send_buf[4] = {
  17. 0x03,
  18. (u8)((address)>>16),
  19. (u8)((address)>>8),
  20. (u8)(address)
  21. };
  22. luat_spi_device_transfer(gt_spi_dev, send_buf, 4, (char *)pBuff, DataLen);
  23. return pBuff[0];
  24. }
  25. unsigned char CheckID(unsigned char CMD, unsigned long address,unsigned long byte_long,unsigned char *p_arr) {
  26. #if LUAT_GT_DEBUG
  27. // LLOGD("CheckID CMD %02X addr %08X len %d p_arr %X", CMD, address, byte_long,*p_arr);
  28. #endif
  29. if (gt_spi_dev == NULL)
  30. return 0;
  31. char send_buf[4] = {
  32. CMD,
  33. (u8)((address)>>16),
  34. (u8)((address)>>8),
  35. (u8)(address)
  36. };
  37. luat_spi_device_transfer(gt_spi_dev, send_buf, 4, (char *)p_arr, byte_long);
  38. // return p_arr[0];
  39. return 1;
  40. }