PICSimLab - Programmable IC Simulator Laboratory 0.9.2
PICSimLab - API
Loading...
Searching...
No Matches
sen_adxl345.h
1/* ########################################################################
2
3 PICSimLab - Programmable IC Simulator Laboratory
4
5 ########################################################################
6
7 Copyright (c) : 2021-2024 Luis Claudio GambĂ´a Lopes <lcgamboa@yahoo.com>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 For e-mail suggestions : lcgamboa@yahoo.com
24 ######################################################################## */
25
26#include "bitbang_i2c.h"
27#include "bitbang_spi.h"
28
29typedef struct {
30 unsigned char regs[0x3A];
31 unsigned char addr;
32 bitbang_i2c_t bb_i2c;
33 bitbang_spi_t bb_spi;
34 unsigned char data_wc;
35 unsigned int update;
36 int i2c_mode;
37} adxl345_t;
38
39void adxl345_rst(adxl345_t* adxl);
40void adxl345_init(adxl345_t* adxl);
41void adxl345_end(adxl345_t* adxl);
42void adxl345_set_addr(adxl345_t* adxl, unsigned char addr);
43
44void adxl345_set_accel(adxl345_t* adxl, double x, double y, double z); // g
45void adxl345_set_accel_raw(adxl345_t* adxl, short x, short y, short z); // g
46
47unsigned char adxl345_io_I2C(adxl345_t* adxl, unsigned char scl, unsigned char sda);
48unsigned short adxl345_io_SPI(adxl345_t* adxl, unsigned char mosi, unsigned char clk, unsigned char ss);
49
50// clang-format off
51
52// REGISTERS ADDRESS
53#define DEVID 0x00
54//0x01 to 0x1C Reserved
55#define THRESH_TAP 0x1D
56#define OFSX 0x1E
57#define OFSY 0x1F
58#define OFSZ 0x20
59#define DUR 0x21
60#define Latent 0x22
61#define WINDOW 0x23
62#define THRESH_ACT 0x24
63#define THRESH_INACT 0x25
64#define TIME_INACT 0x26
65#define ACT_INACT_CTL 0x27
66#define THRESH_FF 0x28
67#define TIME_FF 0x29
68#define TAP_AXES 0x2A
69#define ACT_TAP_STATUS 0x2B
70#define BW_RATE 0x2C
71#define POWER_CTL 0x2D
72#define INT_ENABLE 0x2E
73#define INT_MAP 0x2F
74#define INT_SOURCE 0x30
75#define DATA_FORMAT 0x31
76#define DATAX0 0x32
77#define DATAX1 0x33
78#define DATAY0 0x34
79#define DATAY1 0x35
80#define DATAZ0 0x36
81#define DATAZ1 0x37
82#define FIFO_CTL 0x38
83#define FIFO_STATUS 0x39
84
85// clang-format on
Definition sen_adxl345.h:29
Definition bitbang_i2c.h:39
Definition bitbang_spi.h:35