mcp2210.h 923 B

12345678910111213141516171819202122232425
  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. struct mcp2210_device;
  10. extern struct mcp2210_device *mcp2210_open(const struct lowlevel_device_info *);
  11. extern void mcp2210_close(struct mcp2210_device *);
  12. extern bool mcp2210_spi_cancel(struct mcp2210_device *);
  13. 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);
  14. extern bool mcp2210_set_spimode(struct mcp2210_device *, uint8_t spimode);
  15. extern bool mcp2210_spi_transfer(struct mcp2210_device *, const void *tx, void *rx, uint8_t sz);
  16. extern bool mcp2210_set_gpio_output(struct mcp2210_device *, int pin, enum bfg_gpio_value);
  17. extern enum bfg_gpio_value mcp2210_get_gpio_input(struct mcp2210_device *, int pin);
  18. #endif