Skip to content

Commit 36a5e4d

Browse files
committed
Initial:add crazyflie core to components
forked from bitcraze/crazyflie-firmware
0 parents  commit 36a5e4d

File tree

151 files changed

+29788
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+29788
-0
lines changed

LICENSE

+674
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/**
2+
* || ____ _ __
3+
* +------+ / __ )(_) /_______________ _____ ___
4+
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
5+
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
6+
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
7+
*
8+
* Crazyflie control firmware
9+
*
10+
* Copyright (C) 2017 Bitcraze AB
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU General Public License as published by
14+
* the Free Software Foundation, in version 3.
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*
24+
* amg8833.h - Functions for interfacing AMG8833 thermal sensor
25+
* Reference : https://github.com/adafruit/Adafruit_AMG88xx
26+
*/
27+
#ifndef __AMG8833_H__
28+
#define __AMG8833_H__
29+
30+
#include <stdint.h>
31+
#include <stdbool.h>
32+
33+
#include "i2cdev.h"
34+
#include "task.h"
35+
#include "num.h"
36+
37+
38+
#define MINTEMP 22
39+
#define MAXTEMP 34
40+
41+
#define AMG_I2C_CHUNKSIZE 32
42+
#define AMG88xx_PIXEL_ARRAY_SIZE 64
43+
44+
#define AMG88xx_ADDRESS 0x68
45+
/************** Registers ***************/
46+
#define AMG88xx_PCTL 0x00
47+
#define AMG88xx_RST 0x01
48+
#define AMG88xx_FPSC 0x02
49+
#define AMG88xx_INTC 0x03
50+
#define AMG88xx_STAT 0x04
51+
#define AMG88xx_SCLR 0x05
52+
#define AMG88xx_AVE 0x07
53+
#define AMG88xx_INTHL 0x08
54+
#define AMG88xx_INTHH 0x09
55+
#define AMG88xx_INTLL 0x0A
56+
#define AMG88xx_INTLH 0x0B
57+
#define AMG88xx_IHYSL 0x0C
58+
#define AMG88xx_IHYSH 0x0D
59+
#define AMG88xx_TTHL 0x0E
60+
#define AMG88xx_TTHH 0x0F
61+
#define AMG88xx_INT_OFFSET 0x10
62+
#define AMG88xx_PIXEL_OFFSET 0x80
63+
/************* Power modes *************/
64+
#define AMG88xx_NORMAL_MODE 0x00
65+
#define AMG88xx_SLEEP_MODE 0x01
66+
#define AMG88xx_STAND_BY_60 0x20
67+
#define AMG88xx_STAND_BY_10 0x21
68+
/*********** Software resets ***********/
69+
#define AMG88xx_FLAG_RESET 0x30
70+
#define AMG88xx_INITIAL_RESET 0x3F
71+
/************* Frame rates *************/
72+
#define AMG88xx_FPS_10 0x00
73+
#define AMG88xx_FPS_1 0x01
74+
/********** Interrupt Enables **********/
75+
#define AMG88xx_INT_DISABLED 0x00
76+
#define AMG88xx_INT_ENABLED 0x01
77+
/********** Interrupt modes ************/
78+
#define AMG88xx_DIFFERENCE 0x00
79+
#define AMG88xx_ABSOLUTE_VALUE 0x01
80+
81+
typedef struct {
82+
uint8_t devAddr;
83+
I2C_Dev *I2Cx;
84+
} AMG8833_Dev_t;
85+
86+
typedef AMG8833_Dev_t *AMG8833_DEV;
87+
88+
// Initiate thermal sensor
89+
bool begin(AMG8833_Dev_t *dev, I2C_Dev *I2Cx);
90+
91+
// Data capture
92+
void readPixels(AMG8833_Dev_t *dev, float *buf, uint8_t size);
93+
float readThermistor(AMG8833_Dev_t *dev);
94+
95+
// Interrupts
96+
bool enableInterrupt(AMG8833_Dev_t *dev);
97+
bool disableInterrupt(AMG8833_Dev_t *dev);
98+
void setInterruptMode(AMG8833_Dev_t *dev, uint8_t mode);
99+
void getInterrupt(AMG8833_Dev_t *dev, uint8_t *buf, uint8_t size);
100+
void clearInterrupt(AMG8833_Dev_t *dev);
101+
// This will automatically set hysteresis to 95% of the high value
102+
void setInterruptLevels_N(AMG8833_Dev_t *dev, float high, float low);
103+
// This will manually set hysteresis
104+
void setInterruptLevels_H(AMG8833_Dev_t *dev, float high, float low, float hysteresis);
105+
106+
// Modes
107+
void setMovingAverageMode(AMG8833_Dev_t *dev, bool mode);
108+
109+
// Read operations
110+
uint8_t read8(AMG8833_Dev_t *dev, uint8_t reg);
111+
void read(AMG8833_Dev_t *dev, uint8_t reg, uint8_t *buf, uint8_t num);
112+
113+
// Write operations
114+
bool write8(AMG8833_Dev_t *dev, uint16_t reg, uint8_t value);
115+
void write(AMG8833_Dev_t *dev, uint8_t reg, uint8_t *buf, uint8_t num);
116+
117+
// Supportive calculations
118+
float signedMag12ToFloat(uint16_t val);
119+
float int12ToFloat(uint16_t val);
120+
uint8_t min(uint8_t a, uint8_t b);
121+
122+
#endif /* __AMG8833_H__ */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* || ____ _ __
3+
* +------+ / __ )(_) /_______________ _____ ___
4+
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
5+
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
6+
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
7+
*
8+
* Crazyflie control firmware
9+
*
10+
* Copyright (C) 2015 Bitcraze AB
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU General Public License as published by
14+
* the Free Software Foundation, in version 3.
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*
24+
* buzzdeck.h - Functions for interfacing with decks with buzzers
25+
*/
26+
#ifndef __BUZZER_H__
27+
#define __BUZZER_H__
28+
29+
#include <stdint.h>
30+
#include <stdbool.h>
31+
32+
/** Functionpointers used to control the buzzer */
33+
struct buzzerControl
34+
{
35+
void (*off)();
36+
void (*on)(uint32_t freq);
37+
};
38+
39+
/**
40+
* Initilize the buzzer sub-system.
41+
*/
42+
void buzzerInit();
43+
44+
/**
45+
* Test the buzzer sub-system.
46+
*/
47+
bool buzzerTest();
48+
49+
/**
50+
* Turn the buzzer off.
51+
*/
52+
void buzzerOff();
53+
54+
/**
55+
* Turn the buzzer on and set it to a specific frequency (if supported).
56+
*/
57+
void buzzerOn(uint32_t freq);
58+
59+
/**
60+
* Set function pointers for controlling the buzzer hardware.
61+
*/
62+
void buzzerSetControl(struct buzzerControl * bc);
63+
64+
#endif //__BUZZER_H__
65+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* || ____ _ __
3+
* +------+ / __ )(_) /_______________ _____ ___
4+
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
5+
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
6+
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
7+
*
8+
* Crazyflie control firmware
9+
*
10+
* Copyright (C) 2012 BitCraze AB
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU General Public License as published by
14+
* the Free Software Foundation, in version 3.
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*
24+
* eskylink.h: esky 2.4GHz-compatible link driver
25+
*/
26+
27+
#ifndef __ESKYLINK_H__
28+
#define __ESKYLINK_H__
29+
30+
#include "crtp.h"
31+
32+
void eskylinkInit();
33+
bool eskylinkTest();
34+
struct crtpLinkOperations * eskylinkGetLink();
35+
void eskylinkReInit(void);
36+
37+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* || ____ _ __
3+
* +------+ / __ )(_) /_______________ _____ ___
4+
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
5+
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
6+
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
7+
*
8+
* Crazyflie control firmware
9+
*
10+
* Copyright (C) 2011-2012 Bitcraze AB
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU General Public License as published by
14+
* the Free Software Foundation, in version 3.
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*
24+
* debug.h - Various debug functions
25+
*/
26+
#ifndef DEBUG_H_
27+
#define DEBUG_H_
28+
29+
/**
30+
* Initializes peripherals used for creating trace
31+
* information
32+
*/
33+
void debugInitTrace(void);
34+
35+
/**
36+
* Sends trace information using the UART1. This function is
37+
* used with the freertos traceTASK_SWITCHED_IN() macro.
38+
* @param Task number currently running
39+
*/
40+
void debugSendTraceInfo(unsigned int taskNbr);
41+
42+
#endif /* DEBUG_H_ */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* || ____ _ __
3+
* +------+ / __ )(_) /_______________ _____ ___
4+
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
5+
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
6+
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
7+
*
8+
* Crazyflie control firmware
9+
*
10+
* Copyright (C) 2011-2012 Bitcraze AB
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU General Public License as published by
14+
* the Free Software Foundation, in version 3.
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*
24+
*
25+
* imu.h - inertial measurement unit header file
26+
*/
27+
#ifndef IMU_H_
28+
#define IMU_H_
29+
#include <stdbool.h>
30+
#include "filter.h"
31+
#include "imu_types.h"
32+
33+
/**
34+
* IMU update frequency dictates the overall update frequency.
35+
*/
36+
#define IMU_UPDATE_FREQ 500
37+
#define IMU_UPDATE_DT (float)(1.0/IMU_UPDATE_FREQ)
38+
39+
/**
40+
* Set ACC_WANTED_LPF1_CUTOFF_HZ to the wanted cut-off freq in Hz.
41+
* The highest cut-off freq that will have any affect is fs /(2*pi).
42+
* E.g. fs = 350 Hz -> highest cut-off = 350/(2*pi) = 55.7 Hz -> 55 Hz
43+
*/
44+
#define IMU_ACC_WANTED_LPF_CUTOFF_HZ 4
45+
/**
46+
* Attenuation should be between 1 to 256.
47+
*
48+
* f0 = fs / 2*pi*attenuation ->
49+
* attenuation = fs / 2*pi*f0
50+
*/
51+
#define IMU_ACC_IIR_LPF_ATTENUATION (IMU_UPDATE_FREQ / (2 * 3.1415 * IMU_ACC_WANTED_LPF_CUTOFF_HZ))
52+
#define IMU_ACC_IIR_LPF_ATT_FACTOR (int)(((1<<IIR_SHIFT) / IMU_ACC_IIR_LPF_ATTENUATION) + 0.5)
53+
54+
void imu6Init(void);
55+
bool imu6Test(void);
56+
bool imu6ManufacturingTest(void);
57+
void imu6Read(Axis3f* gyro, Axis3f* acc);
58+
void imu9Read(Axis3f* gyroOut, Axis3f* accOut, Axis3f* magOut);
59+
bool imu6IsCalibrated(void);
60+
bool imuHasBarometer(void);
61+
bool imuHasMangnetometer(void);
62+
63+
64+
65+
#endif /* IMU_H_ */

0 commit comments

Comments
 (0)