cmt2300_hal.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * THE FOLLOWING FIRMWARE IS PROVIDED: (1) "AS IS" WITH NO WARRANTY; AND
  3. * (2)TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
  4. * CONSEQUENTLY, CMOSTEK SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
  5. * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
  6. * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
  7. * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  8. *
  9. * Copyright (C) CMOSTEK SZ.
  10. */
  11. /*!
  12. * @file cmt2300_hal.c
  13. * @brief CMT2300 hardware abstraction layer
  14. *
  15. * @version 1.1
  16. * @date Feb 08 2017
  17. * @author CMOSTEK R@D
  18. */
  19. #include "cmt2300_hal.h"
  20. #include "cmt_spi3.h"
  21. /*! ********************************************************
  22. * @name Cmt2300_ReadReg
  23. * @desc Read the CMT2300 register at the specified address.
  24. * @param addr: register address
  25. * @return Register value
  26. * *********************************************************/
  27. uint8_t Cmt2300_ReadReg(uint8_t addr)
  28. {
  29. uint8_t dat = 0xFF;
  30. cmt_spi3_read(addr, &dat);
  31. return dat;
  32. }
  33. /*! ********************************************************
  34. * @name Cmt2300_WriteReg
  35. * @desc Write the CMT2300 register at the specified address.
  36. * @param addr: register address
  37. * dat: register value
  38. * *********************************************************/
  39. void Cmt2300_WriteReg(uint8_t addr, uint8_t dat)
  40. {
  41. cmt_spi3_write(addr, dat);
  42. }
  43. /*! ********************************************************
  44. * @name Cmt2300_ReadFifo
  45. * @desc Reads the contents of the CMT2300 FIFO.
  46. * @param buf: buffer where to copy the FIFO read data
  47. * len: number of bytes to be read from the FIFO
  48. * *********************************************************/
  49. void Cmt2300_ReadFifo(uint8_t buf[], uint16_t len)
  50. {
  51. cmt_spi3_read_fifo(buf, len);
  52. }
  53. /*! ********************************************************
  54. * @name Cmt2300_WriteFifo
  55. * @desc Writes the buffer contents to the CMT2300 FIFO.
  56. * @param buf: buffer containing data to be put on the FIFO
  57. * len: number of bytes to be written to the FIFO
  58. * *********************************************************/
  59. void Cmt2300_WriteFifo(const uint8_t buf[], uint16_t len)
  60. {
  61. cmt_spi3_write_fifo(buf, len);
  62. }