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) {
struct spi_transaction req_trans
enum SPIClockPolarity cpol
clock polarity control
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
uint16_t output_length
number of data words to write
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.
void ms2100_reset_cb(struct spi_transaction *t)
Reset callback.
void ms2100_event(struct Ms2100 *ms)
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
enum SPIBitOrder bitorder
MSB/LSB order.
volatile uint8_t read_buf[2]
SPI buffer for reading a single axis.
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
enum SPISlaveSelect select
slave selection behavior
Architecture independent SPI (Serial Peripheral Interface) API.
enum SPIClockPhase cpha
clock phase control
SPI peripheral structure.
struct spi_transaction read_trans
void ms2100_arch_init(void)
SPICallback after_cb
NULL or function called after the transaction.
uint16_t input_length
number of data words to read
#define INT_VECT3_ZERO(_v)
struct spi_periph * spi_p
slave is selected before transaction and unselected after
void ms2100_init(struct Ms2100 *ms, struct spi_periph *spi_p, uint8_t slave_idx)
enum SPIDataSizeSelect dss
data transfer word size
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
volatile uint8_t * input_buf
pointer to receive buffer for DMA
SPICallback before_cb
NULL or function called before the transaction.
enum SPITransactionStatus status