34 #define MS2100_DIVISOR_128 2
35 #define MS2100_DIVISOR_256 3
36 #define MS2100_DIVISOR_512 4
37 #define MS2100_DIVISOR_1024 5
39 #ifndef MS2100_DIVISOR
40 #define MS2100_DIVISOR MS2100_DIVISOR_1024
103 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx]<<8) | _buf[_idx+1]))
128 if (abs(new_val) < 2000) {
#define INT_VECT3_ZERO(_v)
enum SPIClockPolarity cpol
clock polarity control
enum SPIClockPhase cpha
clock phase control
enum SPISlaveSelect select
slave selection behavior
SPICallback before_cb
NULL or function called before the transaction.
SPICallback after_cb
NULL or function called after the transaction.
enum SPIDataSizeSelect dss
data transfer word size
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
uint16_t input_length
number of data words to read
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
volatile uint8_t * input_buf
pointer to receive buffer for DMA
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
enum SPIBitOrder bitorder
MSB/LSB order.
uint16_t output_length
number of data words to write
enum SPITransactionStatus status
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
@ SPICpolIdleLow
CPOL = 0.
@ SPISelectUnselect
slave is selected before transaction and unselected after
SPI peripheral structure.
void ms2100_event(struct Ms2100 *ms)
void ms2100_init(struct Ms2100 *ms, struct spi_periph *spi_p, uint8_t slave_idx)
void ms2100_read(struct Ms2100 *ms)
send request to read next axis
#define Int16FromBuf(_buf, _idx)
Driver for the ms2100 magnetic sensor from PNI.
volatile uint8_t req_buf[1]
SPI buffer for the command byte.
struct spi_transaction read_trans
volatile uint8_t read_buf[2]
SPI buffer for reading a single axis.
struct spi_transaction req_trans
struct spi_periph * spi_p
void ms2100_arch_init(void)
void ms2100_reset_cb(struct spi_transaction *t)
Reset callback.
Architecture independent SPI (Serial Peripheral Interface) API.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.