mcp2210.h 988 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef BFG_MCP2210_H
  2. #define BFG_MCP2210_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. enum mcp2210_gpio_direction {
  6. MGD_OUTPUT,
  7. MGD_INPUT,
  8. };
  9. enum mcp2210_gpio_value {
  10. MGV_LOW,
  11. MGV_HIGH,
  12. MGV_ERROR,
  13. };
  14. struct mcp2210_device;
  15. extern struct mcp2210_device *mcp2210_open(struct lowlevel_device_info *);
  16. extern void mcp2210_close(struct mcp2210_device *);
  17. extern bool mcp2210_spi_cancel(struct mcp2210_device *);
  18. extern bool mcp2210_configure_spi(struct mcp2210_device *, uint32_t bitrate, uint16_t idlechipsel, uint16_t activechipsel, uint16_t chipseltodatadelay, uint16_t lastbytetocsdelay, uint16_t midbytedelay);
  19. extern bool mcp2210_set_spimode(struct mcp2210_device *, uint8_t spimode);
  20. extern bool mcp2210_spi_transfer(struct mcp2210_device *, const void *tx, void *rx, uint8_t sz);
  21. extern bool mcp2210_set_gpio_output(struct mcp2210_device *, int pin, enum mcp2210_gpio_value);
  22. extern enum mcp2210_gpio_value mcp2210_get_gpio_input(struct mcp2210_device *, int pin);
  23. #endif