diff --git a/i2cspi_BaS_gcc/Makefile b/i2cspi_BaS_gcc/Makefile index 20b3a96..17071e9 100644 --- a/i2cspi_BaS_gcc/Makefile +++ b/i2cspi_BaS_gcc/Makefile @@ -71,7 +71,9 @@ CSRCS= \ $(SRCDIR)/sd_card.c \ $(SRCDIR)/wait.c \ $(SRCDIR)/s19reader.c \ - $(SRCDIR)/flash.c + $(SRCDIR)/flash.c \ + $(SRCDIR)/fifo.c \ + $(SRCDIR)/i2c_firebee.c ASRCS= \ $(SRCDIR)/startcf.S \ diff --git a/i2cspi_BaS_gcc/include/fifo.h b/i2cspi_BaS_gcc/include/fifo.h new file mode 100644 index 0000000..fe4022a --- /dev/null +++ b/i2cspi_BaS_gcc/include/fifo.h @@ -0,0 +1,39 @@ +/* + * This is taken from general implementations + * on the internet, and definately needs some + * work. + * + * good enough for now. + * + */ + +#ifndef FIREBEE_FIFO +#define FIREBEE_FIFO + +#include + +typedef struct { + char * buf; + int head; + int tail; + int size; +} fifo_t; + +void fifo_init(fifo_t*,char*,int); +void fifo_advance(fifo_t*,int*); + +uint8_t fifo_get(fifo_t*); +void fifo_put(fifo_t*,uint8_t); + +void fifo_clear(fifo_t*); + +int fifo_used(fifo_t*); +int fifo_unused(fifo_t*); + +int fifo_full(fifo_t*); +int fifo_empty(fifo_t*); + +int fifo_read(fifo_t*,char *,int); +int fifo_write(fifo_t*,const char*,int); + +#endif diff --git a/i2cspi_BaS_gcc/include/i2c_firebee.h b/i2cspi_BaS_gcc/include/i2c_firebee.h new file mode 100644 index 0000000..0d0c4c6 --- /dev/null +++ b/i2cspi_BaS_gcc/include/i2c_firebee.h @@ -0,0 +1,45 @@ +/* + * i2c.h + * + */ + +#ifndef I2CFIREBEE_h +#define I2CFIREBEE_h + +#include + +#ifndef BUFSIZ +#define BUFSIZ 512 +#endif + +#define I2CTLREAD (('i'<<8) | 1) +#define I2CTLWRITE (('i'<<8) | 2) +#define I2CTLSBUF (('i'<<8) | 3) +#define I2CTLINIT (('i'<<8) | 4) +#define I2CTLDEV (('i'<<8) | 5) + +// Set a specific bit +#define set_bit(p,bit) p |= bit +// Clear a specific bit +#define clear_bit(p,bit) p &= ~bit + +#define ELAPSED(t) (t - ReadTimer()) + +#define I2C_BUFFER_LENGTH 32 + +#define I2C_READY 0 +#define I2C_MXRX 1 +#define I2C_MXTX 2 + +#define I2C_ADDR 6 + +#define I2C_READ 1 +#define I2C_WRITE 0 + +unsigned long ReadTimer(); +void DelayMicroSec(unsigned long); + +void I2C_Init(); +int I2C_ioctl(unsigned int, unsigned long); + +#endif diff --git a/i2cspi_BaS_gcc/include/startcf.h b/i2cspi_BaS_gcc/include/startcf.h index 3ade02e..0ebc4da 100644 --- a/i2cspi_BaS_gcc/include/startcf.h +++ b/i2cspi_BaS_gcc/include/startcf.h @@ -1,4 +1,5 @@ +#define SYSTEM_CLOCK 133 #define cf_stack #define DIP_SWITCH (*(volatile uint8_t *)(&_MBAR[0xA2C]))