mcp2210.h 911 B

1234567891011121314151617181920212223242526272829
  1. #ifndef BFG_MCP2210_H
  2. #define BFG_MCP2210_H
  3. #include <stdbool.h>
  4. enum mcp2210_gpio_direction {
  5. MGD_OUTPUT,
  6. MGD_INPUT,
  7. };
  8. enum mcp2210_gpio_value {
  9. MGV_LOW,
  10. MGV_HIGH,
  11. MGV_ERROR,
  12. };
  13. struct mcp2210_device;
  14. extern struct mcp2210_device *mcp2210_open(struct lowlevel_device_info *);
  15. extern void mcp2210_close(struct mcp2210_device *);
  16. 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);
  17. extern bool mcp2210_set_spimode(struct mcp2210_device *, uint8_t spimode);
  18. extern bool mcp2210_spi_transfer(struct mcp2210_device *, const void *tx, void *rx, uint8_t sz);
  19. extern bool mcp2210_set_gpio_output(struct mcp2210_device *, int pin, enum mcp2210_gpio_value);
  20. extern enum mcp2210_gpio_value mcp2210_get_gpio_input(struct mcp2210_device *, int pin);
  21. #endif