mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
theoretically clean version which has been tested with and without the feature
This commit is contained in:
parent
0412a401d8
commit
04bf756b8e
6 changed files with 28 additions and 6 deletions
|
|
@ -32,11 +32,13 @@ camera-ov2640 = []
|
|||
camera-gc2145 = []
|
||||
display-sh1107 = []
|
||||
axp2101 = []
|
||||
bmp180 = []
|
||||
board-baosec = [
|
||||
"std",
|
||||
"camera-gc2145",
|
||||
"display-sh1107",
|
||||
"axp2101",
|
||||
"bmp180",
|
||||
"utralib/cramium-soc",
|
||||
"ux-api/board-baosec",
|
||||
] # USB form factor token
|
||||
|
|
@ -45,6 +47,7 @@ loader-baosec = [
|
|||
"camera-gc2145",
|
||||
"display-sh1107",
|
||||
"axp2101",
|
||||
"bmp180",
|
||||
"ux-api/loader-baosec",
|
||||
]
|
||||
kernel-baosec = ["utralib/cramium-soc"]
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
use cramium_api::{I2cApi, I2cResult};
|
||||
|
||||
pub const BMP180_ADDR: u8 = 0x77;
|
||||
#[cfg(feature = "std")]
|
||||
const REG_CALIB_START: u8 = 0xAA;
|
||||
const REG_CTRL: u8 = 0xF4;
|
||||
const REG_DATA_START: u8 = 0xF6;
|
||||
const CMD_READ_TEMP: u8 = 0x2E;
|
||||
const REG_CHIP_ID: u8 = 0xD0;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct Bmp180Calibration {
|
||||
ac1: i16,
|
||||
ac2: i16,
|
||||
|
|
@ -29,10 +28,17 @@ pub struct Bmp180 {
|
|||
}
|
||||
|
||||
impl Bmp180 {
|
||||
#[cfg(feature = "std")]
|
||||
pub fn new(i2c: &mut dyn I2cApi) -> Result<Self, I2cResult> {
|
||||
let mut cal_buf = [0u8; 22];
|
||||
// dummy read to wake the chip
|
||||
let mut chip_id_buf = [0u8; 1];
|
||||
match i2c.i2c_read(BMP180_ADDR, REG_CHIP_ID, &mut chip_id_buf, true) {
|
||||
Ok(I2cResult::Ack(_)) => (),
|
||||
Ok(I2cResult::Nack) => (),
|
||||
Ok(other) => return Err(other),
|
||||
Err(_) => return Err(I2cResult::InternalError),
|
||||
}
|
||||
|
||||
let mut cal_buf = [0u8; 22];
|
||||
match i2c.i2c_read(BMP180_ADDR, REG_CALIB_START, &mut cal_buf, true) {
|
||||
Ok(i2c_result) => match i2c_result {
|
||||
I2cResult::Ack(_) => (),
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
pub mod debug;
|
||||
#[cfg(feature = "axp2101")]
|
||||
pub mod axp2101;
|
||||
#[cfg(feature = "bmp180")]
|
||||
pub mod bmp180;
|
||||
pub mod board;
|
||||
#[cfg(feature = "camera-gc2145")]
|
||||
|
|
|
|||
|
|
@ -49,6 +49,10 @@ hosted-baosec = [
|
|||
"pddb/hosted-baosec",
|
||||
"cramium-hal/hosted-baosec",
|
||||
]
|
||||
bmp180 = [
|
||||
"cramium-hal/bmp180",
|
||||
"cram-hal-service",
|
||||
]
|
||||
usb = []
|
||||
battery-readout = []
|
||||
with-pddb = []
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
use String;
|
||||
use cram_hal_service::I2c;
|
||||
use cramium_hal::bmp180::Bmp180;
|
||||
|
||||
use crate::{CommonEnv, ShellCmdApi};
|
||||
|
||||
|
|
@ -15,13 +13,22 @@ impl<'a> ShellCmdApi<'a> for Test {
|
|||
fn process(&mut self, args: String, _env: &mut CommonEnv) -> Result<Option<String>, xous::Error> {
|
||||
use core::fmt::Write;
|
||||
let mut ret = String::new();
|
||||
|
||||
#[allow(unused_variables)]
|
||||
let helpstring = "Test commands. See code for options.";
|
||||
|
||||
#[cfg(feature = "bmp180")]
|
||||
let helpstring = "Usage:
|
||||
temp - reads temperature from bmp180.";
|
||||
|
||||
let mut tokens = args.split(' ');
|
||||
|
||||
if let Some(sub_cmd) = tokens.next() {
|
||||
match sub_cmd {
|
||||
#[cfg(feature = "bmp180")]
|
||||
"temp" => {
|
||||
use cram_hal_service::I2c;
|
||||
use cramium_hal::bmp180::Bmp180;
|
||||
let mut i2c = I2c::new();
|
||||
|
||||
match Bmp180::new(&mut i2c) {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ rawserial = []
|
|||
pinger = []
|
||||
swap = []
|
||||
mpw = ["cramium-hal/mpw"]
|
||||
bmp180 = ["cramium-hal/bmp180"]
|
||||
board-baosec = ["cramium-hal/board-baosec"]
|
||||
board-baosor = ["cramium-hal/board-baosor"]
|
||||
board-dabao = ["cramium-hal/board-dabao"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue