DEV_Config.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /******************************************************************************
  2. **************************Hardware interface layer*****************************
  3. | file : DEV_Config.cpp
  4. | version : V1.0
  5. | date : 2020-06-16
  6. | function : Provide the hardware underlying interface
  7. ******************************************************************************/
  8. #include "DEV_Config.h"
  9. /********************************************************************************
  10. function: System Init and exit
  11. note:
  12. Initialize the communication method
  13. ********************************************************************************/
  14. uint8_t System_Init(void)
  15. {
  16. Serial.begin(115200);
  17. Serial.println("USE_I2C");
  18. Wire.setClock(2000000);
  19. Wire.begin();
  20. return 0;
  21. }
  22. /********************************************************************************
  23. function: Hardware interface
  24. note:
  25. I2C_Write_Byte(value, cmd):
  26. hardware I2C
  27. ********************************************************************************/
  28. void I2C_Write_Byte(uint8_t value, uint8_t Cmd)
  29. {
  30. uint8_t Addr = IIC_ADR;
  31. Wire.beginTransmission(Addr);
  32. Wire.write(Cmd);
  33. Wire.write(value);
  34. Wire.endTransmission();
  35. }
  36. /********************************************************************************
  37. function: Delay function
  38. note:
  39. Driver_Delay_ms(xms) : Delay x ms
  40. Driver_Delay_us(xus) : Delay x us
  41. ********************************************************************************/
  42. void Driver_Delay_ms(unsigned long xms)
  43. {
  44. delay(xms);
  45. }
  46. void Driver_Delay_us(int xus)
  47. {
  48. for (int j = xus; j > 0; j--)
  49. ;
  50. }