#ifndef __spiregs_h__
#define __spiregs_h__

/* SPI Control Register */

#define CTRL_MASK         (lpc210x_reg)0xF8

#define CTRL_CLK_PHASE    (lpc210x_reg)0x08 // 1=data sampled on trailing clock edge 
#define CTRL_CLK_POLARITY (lpc210x_reg)0x10 // 1=SCK is active low
#define CTRL_MASTER_MODE  (lpc210x_reg)0x20 // 1=master, 0=slave
#define CTRL_LSB_FIRST    (lpc210x_reg)0x40 // 1=data is sent lsb first, 0=msb first
#define CTRL_IRQ_ENABLE   (lpc210x_reg)0x80 // 1=interrupts enabled

/* SPI Status Register */

#define STATUS_MASK       (lpc210x_reg)0xF8

#define STATUS_SLAVE_ABRT (lpc210x_reg)0x08
#define STATUS_MODE_FAULT (lpc210x_reg)0x10
#define STATUS_RD_OVERRUN (lpc210x_reg)0x20 // read overrun
#define STATUS_WRITE_COL  (lpc210x_reg)0x40
#define STATUS_XFER_DONE  (lpc210x_reg)0x80 // data transfer complete

/* SPI Interrupt Register */

#define IRQ_ACKNOWLEDGE   (lpc210x_reg)0x01

#endif /* __spiregs_h__ */

