drv_iic.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /******************************************************************//**
  2. * @file drv_iic.h
  3. * @brief IIC driver of RT-Thread RTOS for EFM32
  4. * COPYRIGHT (C) 2011, RT-Thread Development Team
  5. * @author onelife
  6. * @version 0.4 beta
  7. **********************************************************************
  8. * @section License
  9. * The license and distribution terms for this file may be found in the file LICENSE in this
  10. * distribution or at http://www.rt-thread.org/license/LICENSE
  11. **********************************************************************
  12. * @section Change Logs
  13. * Date Author Notes
  14. * 2011-01-07 onelife Initial creation for EFM32
  15. *********************************************************************/
  16. #ifndef __DRV_IIC_H__
  17. #define __DRV_IIC_H__
  18. /* Includes -------------------------------------------------------------------*/
  19. /* Exported types -------------------------------------------------------------*/
  20. struct efm32_iic_int_mode_t
  21. {
  22. rt_uint8_t *data_ptr;
  23. rt_uint8_t data_size;
  24. rt_uint32_t read_index, save_index;
  25. };
  26. struct efm32_iic_device_t
  27. {
  28. /* State */
  29. rt_uint8_t state;
  30. /* Pointer to IIC device structure */
  31. I2C_TypeDef* iic_device;
  32. /* Master address */
  33. rt_uint16_t master_address;
  34. /* Slave address */
  35. rt_uint16_t slave_address;
  36. /* RX structure */
  37. struct efm32_iic_int_mode_t *rx_buffer;
  38. };
  39. struct efm32_iic_control_t
  40. {
  41. rt_uint8_t config;
  42. rt_uint16_t master_address;
  43. rt_uint16_t slave_address;
  44. };
  45. /* Exported constants ---------------------------------------------------------*/
  46. /* Exported macro -------------------------------------------------------------*/
  47. #define IIC_STATE_MASTER (1 << 0)
  48. #define IIC_STATE_BROADCAST (1 << 1)
  49. //#define IIC_STATE_TX_BUSY (1 << 2)
  50. #define IIC_STATE_RX_BUSY (1 << 3)
  51. /* Exported functions --------------------------------------------------------- */
  52. void rt_hw_iic_init(void);
  53. #endif /* __DRV_IIC_H__ */