microbit_i2c.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Microbit stub for Nordic Semiconductor nRF51 SoC Two-Wire Interface
  3. * http://infocenter.nordicsemi.com/pdf/nRF51_RM_v3.0.1.pdf
  4. *
  5. * Copyright 2019 Red Hat, Inc.
  6. *
  7. * This code is licensed under the GPL version 2 or later. See
  8. * the COPYING file in the top-level directory.
  9. */
  10. #ifndef MICROBIT_I2C_H
  11. #define MICROBIT_I2C_H
  12. #include "hw/sysbus.h"
  13. #include "hw/arm/nrf51.h"
  14. #include "qom/object.h"
  15. #define NRF51_TWI_TASK_STARTRX 0x000
  16. #define NRF51_TWI_TASK_STARTTX 0x008
  17. #define NRF51_TWI_TASK_STOP 0x014
  18. #define NRF51_TWI_EVENT_STOPPED 0x104
  19. #define NRF51_TWI_EVENT_RXDREADY 0x108
  20. #define NRF51_TWI_EVENT_TXDSENT 0x11c
  21. #define NRF51_TWI_REG_ENABLE 0x500
  22. #define NRF51_TWI_REG_RXD 0x518
  23. #define NRF51_TWI_REG_TXD 0x51c
  24. #define NRF51_TWI_REG_ADDRESS 0x588
  25. #define TYPE_MICROBIT_I2C "microbit.i2c"
  26. OBJECT_DECLARE_SIMPLE_TYPE(MicrobitI2CState, MICROBIT_I2C)
  27. #define MICROBIT_I2C_NREGS (NRF51_PERIPHERAL_SIZE / sizeof(uint32_t))
  28. struct MicrobitI2CState {
  29. SysBusDevice parent_obj;
  30. MemoryRegion iomem;
  31. uint32_t regs[MICROBIT_I2C_NREGS];
  32. uint32_t read_idx;
  33. };
  34. #endif /* MICROBIT_I2C_H */