Skip to content

Commit

Permalink
开始增加spi/i2c设备
Browse files Browse the repository at this point in the history
Signed-off-by: latercomer <[email protected]>
  • Loading branch information
ComerLater committed Sep 28, 2024
1 parent 7ab286f commit 3dbc1e3
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/peripheral/sensor/imu/bmi088/BMI088.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static constexpr int16_t combine(uint8_t msb, uint8_t lsb) {
return (msb << 8u) | lsb;
}

class BMI088 : public device::SPI, public I2CSPIDriver<BMI088> {
class BMI088 : public device::SPI, public ModuleCommand<BMI088> {
public:
BMI088(const I2CSPIDriverConfig &config);

Expand Down
4 changes: 3 additions & 1 deletion nextpilot-flight-control.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@
"compare": "cpp",
"format": "cpp",
"regex": "cpp",
"variant": "cpp"
"variant": "cpp",
"xlocale": "cpp",
"typeinfo": "cpp"
},
"RTT_Studio.Debuger.Gdb_Path": ""
},
Expand Down
5 changes: 4 additions & 1 deletion pkgs/device/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Device {
}

virtual bool external() const {
return false;
return _external;
}

// 操作device_id
Expand Down Expand Up @@ -220,6 +220,9 @@ class Device {
// 驱动的名称,比如i2c1
const char *_bus_name{nullptr};
rt_device_t _bus_device{nullptr};

// 是否外部设备
bool _external{false};
};

} // namespace nextpilot::device
Expand Down
6 changes: 1 addition & 5 deletions pkgs/device/i2c.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace nextpilot::device {

class I2C : pulbic Device {
class I2C : public Device {
public:
// no copy, assignment, move, move assignment
I2C(const I2C &) = delete;
Expand Down Expand Up @@ -67,10 +67,6 @@ class I2C : pulbic Device {
*/
int transfer(const uint8_t *send, const unsigned send_len, uint8_t *recv, const unsigned recv_len);

bool external() const override {
return px4_i2c_device_external(_device_id.devid);
}

private:
// static unsigned int _bus_clocks[PX4_NUMBER_I2C_BUSES];

Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions pkgs/device/spi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*****************************************************************
* _ __ __ ____ _ __ __
* / | / /___ _ __ / /_ / __ \ (_)/ /____ / /_
* / |/ // _ \ | |/_// __// /_/ // // // __ \ / __/
* / /| // __/_> < / /_ / ____// // // /_/ // /_
* /_/ |_/ \___//_/|_| \__//_/ /_//_/ \____/ \__/
*
* Copyright All Reserved © 2015-2024 NextPilot Development Team
******************************************************************/
15 changes: 15 additions & 0 deletions pkgs/device/spi.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*****************************************************************
* _ __ __ ____ _ __ __
* / | / /___ _ __ / /_ / __ \ (_)/ /____ / /_
* / |/ // _ \ | |/_// __// /_/ // // // __ \ / __/
* / /| // __/_> < / /_ / ____// // // /_/ // /_
* /_/ |_/ \___//_/|_| \__//_/ /_//_/ \____/ \__/
*
* Copyright All Reserved © 2015-2024 NextPilot Development Team
******************************************************************/

#ifndef __SPI_H__
#define __SPI_H__


#endif // __SPI_H__

0 comments on commit 3dbc1e3

Please sign in to comment.