2019-01-12 01:44:06 +00:00
|
|
|
#pragma once
|
2019-04-27 00:24:00 +00:00
|
|
|
|
|
|
|
#include "quantum.h"
|
2019-01-12 01:44:06 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "i2c_master.h"
|
2019-04-27 00:24:00 +00:00
|
|
|
#include <util/delay.h>
|
2019-01-12 01:44:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern i2c_status_t mcp23018_status;
|
2019-04-27 00:24:00 +00:00
|
|
|
#define I2C_TIMEOUT 1000
|
2019-01-12 01:44:06 +00:00
|
|
|
|
|
|
|
// I2C aliases and register addresses (see "mcp23018.md")
|
2024-01-17 13:05:38 +00:00
|
|
|
#define I2C_ADDR (0x20<<1)
|
2019-01-12 01:44:06 +00:00
|
|
|
#define IODIRA 0x00 // i/o direction register
|
|
|
|
#define IODIRB 0x01
|
|
|
|
#define GPPUA 0x0C // GPIO pull-up resistor register
|
|
|
|
#define GPPUB 0x0D
|
|
|
|
#define GPIOA 0x12 // general purpose i/o port register (write modifies OLAT)
|
|
|
|
#define GPIOB 0x13
|
|
|
|
#define OLATA 0x14 // output latch register
|
|
|
|
#define OLATB 0x15
|
|
|
|
|
|
|
|
uint8_t init_mcp23018(void);
|