Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
pmw3901.h
Go to the documentation of this file.
1/*
2 * Copyright (C) Tom van Dijk
3 *
4 * This file is part of paparazzi
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 */
39#ifndef PMW3901_H_
40#define PMW3901_H_
41
42#include "mcu_periph/spi.h"
44
45#include <stdbool.h>
46#include <math.h>
47
48
49#define SPI_BUFFER_SIZE 8
50
51
60
76
77void pmw3901_init(struct pmw3901_t *pmw, struct spi_periph *periph, uint8_t slave_idx);
78bool pmw3901_get_data(struct pmw3901_t *pmw, int16_t *delta_x, int16_t *delta_y);
79
80
81
82#endif // PMW3901_H_
thread_t * pprz_thread_t
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
Definition spi.h:149
SPI peripheral structure.
Definition spi.h:171
SPI transaction structure.
Definition spi.h:144
volatile uint8_t spi_output_buf[SPI_BUFFER_SIZE]
Definition pmw3901.h:67
struct spi_periph * periph
Definition pmw3901.h:62
pprz_thread_t thd_handle
Definition pmw3901.h:63
uint8_t readwrite_state
Definition pmw3901.h:69
volatile uint8_t spi_input_buf[SPI_BUFFER_SIZE]
Definition pmw3901.h:66
float rad_per_px
Definition pmw3901.h:74
int16_t delta_y
Definition pmw3901.h:72
void pmw3901_init(struct pmw3901_t *pmw, struct spi_periph *periph, uint8_t slave_idx)
Definition pmw3901.c:232
struct spi_transaction trans
Definition pmw3901.h:65
#define SPI_BUFFER_SIZE
Definition pmw3901.h:49
bool data_available
Definition pmw3901.h:73
uint32_t readwrite_timeout
Definition pmw3901.h:70
enum pmw3901_state state
Definition pmw3901.h:68
bool pmw3901_get_data(struct pmw3901_t *pmw, int16_t *delta_x, int16_t *delta_y)
Definition pmw3901.c:260
int16_t delta_x
Definition pmw3901.h:71
pmw3901_state
Definition pmw3901.h:52
@ PMW3901_IDLE
Definition pmw3901.h:53
@ PMW3901_READ_DELTAXHIGH
Definition pmw3901.h:55
@ PMW3901_READ_MOTION
Definition pmw3901.h:54
@ PMW3901_READ_DELTAYLOW
Definition pmw3901.h:58
@ PMW3901_READ_DELTAXLOW
Definition pmw3901.h:56
@ PMW3901_READ_DELTAYHIGH
Definition pmw3901.h:57
pprz_bsem_t bsem
Definition pmw3901.h:64
Architecture independent SPI (Serial Peripheral Interface) API.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.