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.

BL24CXX.h 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /********************************************************************************
  24. * @file BL24CXX.h
  25. * @brief i2c EEPROM for Ender 3 v2 board (4.2.2)
  26. ********************************************************************************/
  27. /******************** IIC ********************/
  28. class BL24CXX;
  29. // All operation functions of IIC
  30. class IIC {
  31. friend class BL24CXX;
  32. protected:
  33. static void init(); // Initialize the IO port of IIC
  34. static void start(); // Send IIC start signal
  35. static void stop(); // Send IIC stop signal
  36. static void send_byte(uint8_t txd); // IIC sends a byte
  37. static uint8_t read_byte(unsigned char ack); // IIC reads a byte
  38. static uint8_t wait_ack(); // IIC waits for ACK signal
  39. static void ack(); // IIC sends ACK signal
  40. static void nAck(); // IIC does not send ACK signal
  41. };
  42. /******************** EEPROM ********************/
  43. #define BL24C01 127
  44. #define BL24C02 255
  45. #define BL24C04 511
  46. #define BL24C08 1023
  47. #define BL24C16 2047
  48. #define BL24C32 4095
  49. #define BL24C64 8191
  50. #define BL24C128 16383
  51. #define BL24C256 32767
  52. #define EE_TYPE BL24C16
  53. class BL24CXX {
  54. private:
  55. static bool _check(); // Check the device
  56. public:
  57. static void init(); // Initialize IIC
  58. static bool check(); // Check / recheck the device
  59. static uint8_t readOneByte(uint16_t ReadAddr); // Read a byte at the specified address
  60. static void writeOneByte(uint16_t WriteAddr, uint8_t DataToWrite); // Write a byte at the specified address
  61. static void writeLenByte(uint16_t WriteAddr, uint32_t DataToWrite, uint8_t Len); // The specified address begins to write the data of the specified length
  62. static uint32_t readLenByte(uint16_t ReadAddr, uint8_t Len); // The specified address starts to read the data of the specified length
  63. static void write(uint16_t WriteAddr, uint8_t *pBuffer, uint16_t NumToWrite); // Write the specified length of data from the specified address
  64. static void read(uint16_t ReadAddr, uint8_t *pBuffer, uint16_t NumToRead); // Read the data of the specified length from the specified address
  65. };