user_twim.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef USER_TWIM_H__
  2. #define USER_TWIM_H__
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "sdk_config.h"
  6. #include "define.h"
  7. #include "nrf_drv_twi.h"
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. typedef void (*twim_xfer_func)(void);
  12. typedef struct{
  13. twim_xfer_func twim_xfer_done; //TWI传输完成标志
  14. twim_xfer_func twim_xfer_timeout; //TWI超时标志
  15. }user_twim_s;
  16. #if NRF_MODULE_ENABLED(NRFX_TWIM_0)
  17. void twim0_init(twim_xfer_func done,twim_xfer_func timeout);
  18. void twim0_uinit(void);
  19. ret_code_t nrf_drv_twim0_tx(uint8_t address,uint8_t const * p_data,uint8_t length,bool no_stop);
  20. ret_code_t nrf_drv_twim0_rx(uint8_t address,uint8_t * p_data,uint8_t length);
  21. #endif
  22. #if NRF_MODULE_ENABLED(NRFX_TWIM_1)
  23. void twim1_init(twim_xfer_func done,twim_xfer_func timeout);
  24. void twim1_uinit(void);
  25. ret_code_t nrf_drv_twim1_tx(uint8_t address,uint8_t const * p_data,uint8_t length,bool no_stop);
  26. ret_code_t nrf_drv_twim1_rx(uint8_t address,uint8_t * p_data,uint8_t length);
  27. #endif
  28. #ifdef __cplusplus
  29. }
  30. #endif
  31. #endif // USER_TWIM_H__
  32. /** @} */