My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

i2c_util.c 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * HAL_LPC1768/include/i2c_util.c
  24. */
  25. #ifdef TARGET_LPC1768
  26. #include "i2c_util.h"
  27. #define U8G_I2C_OPT_FAST 16 // from u8g.h
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. void configure_i2c(const uint8_t clock_option) {
  32. /**
  33. * Init I2C pin connect
  34. */
  35. PINSEL_CFG_Type PinCfg;
  36. PinCfg.OpenDrain = 0;
  37. PinCfg.Pinmode = 0;
  38. PinCfg.Portnum = 0;
  39. #if I2C_MASTER_ID == 0
  40. PinCfg.Funcnum = 1;
  41. PinCfg.Pinnum = 27; // SDA0 / D57 AUX-1 ... SCL0 / D58 AUX-1
  42. #elif I2C_MASTER_ID == 1
  43. PinCfg.Funcnum = 3;
  44. PinCfg.Pinnum = 0; // SDA1 / D20 SCA ... SCL1 / D21 SCL
  45. #elif I2C_MASTER_ID == 2
  46. PinCfg.Funcnum = 2;
  47. PinCfg.Pinnum = 10; // SDA2 / D38 X_ENABLE_PIN ... SCL2 / D55 X_DIR_PIN
  48. #endif
  49. PINSEL_ConfigPin(&PinCfg);
  50. PinCfg.Pinnum += 1;
  51. PINSEL_ConfigPin(&PinCfg);
  52. // Initialize I2C peripheral
  53. I2C_Init(I2CDEV_M, (clock_option & U8G_I2C_OPT_FAST) ? 400000: 100000); // LCD data rates
  54. // Enable Master I2C operation
  55. I2C_Cmd(I2CDEV_M, I2C_MASTER_MODE, ENABLE);
  56. }
  57. #ifdef __cplusplus
  58. }
  59. #endif
  60. #endif // TARGET_LPC1768