Skip to content

Commit 4bd37f1

Browse files
committed
power output fix, added ci builds
1 parent 54c499a commit 4bd37f1

3 files changed

Lines changed: 33 additions & 35 deletions

File tree

.travis.yml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
language: rust
22
cache: cargo
3-
43
matrix:
54
include:
65
- env: TARGET=x86_64-unknown-linux-gnu
@@ -10,24 +9,32 @@ matrix:
109
addons:
1110
apt:
1211
packages:
13-
- libc6-i386
14-
- libc6-dev-i386
15-
- gcc-arm-linux-gnueabihf
16-
- libc6-armhf-cross
17-
- libc6-dev-armhf-cross
18-
12+
- libc6-i386
13+
- libc6-dev-i386
14+
- gcc-arm-linux-gnueabihf
15+
- libc6-armhf-cross
16+
- libc6-dev-armhf-cross
1917
install:
2018
- cargo fetch
2119
- rustup target add armv7-unknown-linux-gnueabihf
2220
- rustup component add rustfmt
23-
24-
script:
25-
- cargo build && cargo test && cargo build --target=$TARGET --release
26-
27-
before_deploy:
28-
- "tar -cvf target/sx128-$TARGET-$TRAVIS_TAG.tgz -C target/$TARGET/release/ sx127x-util || return 0"
21+
script:
22+
- cargo build && cargo test && cargo build --target=$TARGET --release
23+
before_deploy:
24+
- tar -cvf target/sx127x-$TARGET-$TRAVIS_TAG.tgz -C target/$TARGET/release/ sx127x-util
2925

3026
notifications:
3127
email:
3228
on_success: never
3329
on_failure: never
30+
deploy:
31+
provider: releases
32+
api_key:
33+
secure: KwL6ue3wNTQiUM05SxMUNlcOnlkCHxpZIKRNmpqhdT0F27RxNIl4DD0wcrA9yD1IB2jv+ZOiXeQGgYEu5s/uYpoNul9lEk3K3UxxxnzKxKH/ByaeiPnlzymBnaN47QFcjFEk5uY8eLHdtXzk6Ku6YbmSJ4uS2WSq3+Q/hnS2od/jqGi2aYy/RBHrS7oFirpcEDYQWfBDftn8vRtVSVPrv+kdBV1qKI5GhP7nodApC3g/LJHeoXHfJo9gxf4PxyCsrFKrjWvUPVkHAq62+J2ETzWNupMYpj8t23Ip+1KxTQd2MLL2epUggTvLA6nunwI3877Trjy76b4F1Ic72GD1WbL3o4UXG/9QRfAGXfjfDnp2W52v0L9uW9URF4qmBI1NY0lceQOmaSyYSJz/4xMV6Txbx+MPoISpsgVsdieMkRFUPo9cm/Lj4+TTgbLVXl2iNZU6H9ezbkx8K0gdrqGZIUJmpsPmONl7nqSNKHHtmyE0xME6TlRDwHWnLizRe4XfoIN89Fj3IM9I6AHx96gK8T7SRWBhIyVsJmuM13E1rbmKyaamB7onBjbay2rXeeO89f2uqvRBjcdsMecH85uUw0H5DnC4mPBJE8bGHnwm3sHx25a6ZP+vBS/Dza33Nqodh3KgNDOPSEK15Vn7+zB5Z5YhERhiL81bke3NF2irSko=
34+
file: target/*.tgz
35+
file_glob: true
36+
skip_cleanup: true
37+
on:
38+
tags: true
39+
on:
40+
repo: ryankurte/rust-radio-sx127x

src/lora.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,7 @@ where
173173
let mut power = power;
174174

175175
// Limit to viable input range
176-
if power > 15 {
177-
power = 15;
178-
}
176+
let power = core::cmp::min(power, 15);
179177

180178
// Read from config to determine PA mode
181179
let config = self.read_reg(regs::Common::PACONFIG)?;
@@ -184,7 +182,7 @@ where
184182
PASELECT_RFO => {
185183
let max = (config & MAXPOWER_MASK) >> MAXPOWER_SHIFT;
186184

187-
let power = core::cmp::max(power, 17u8);
185+
let power = core::cmp::min(power, 17u8);
188186
let value = power - max + 15;
189187

190188
let v = self.update_reg(regs::Common::PACONFIG, OUTPUTPOWER_MASK, value)?;
@@ -193,7 +191,7 @@ where
193191
},
194192
PASELECT_PA_BOOST => {
195193

196-
let power = core::cmp::max(power, 20u8);
194+
let power = core::cmp::min(power, 20u8);
197195
let value = power - 17 + 15;
198196

199197
self.update_reg(regs::Common::PACONFIG, OUTPUTPOWER_MASK, value)?;

src/util/main.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ use radio_sx127x::prelude::*;
2727
#[derive(StructOpt)]
2828
#[structopt(name = "Sx127x-util")]
2929
/// A Command Line Interface (CLI) for interacting with a local Sx127x radio device
30-
/// Configuration 1: --spi=/dev/spidev0.0 --cs-pin 16 --rst-pin 17 --busy-pin 5
31-
/// Configuration 2: --spi=/dev/spidev0.0 --cs-pin 13 --rst-pin 18 --busy-pin 8
30+
///
31+
/// Configuration 1: --cs-pin 16 --rst-pin 17 --busy-pin 5
32+
///
33+
/// Configuration 2: --cs-pin 13 --rst-pin 18 --busy-pin 8
34+
///
35+
/// Configuration 3: --cs-pin 8 --rst-pin 17 --busy-pin 5
36+
///
3237
pub struct Options {
3338

3439
#[structopt(subcommand)]
@@ -52,19 +57,10 @@ pub struct Options {
5257
#[structopt(long = "busy-pin", default_value = "5", env = "SX127X_BUSY")]
5358
busy: u64,
5459

55-
/// DIO1 pin
56-
#[structopt(long = "dio1-pin", default_value = "20", env = "SX127X_DIO1")]
57-
dio1: u64,
58-
59-
/// DIO2 pin
60-
#[structopt(long = "dio2-pin", default_value = "23", env = "SX127X_DIO2")]
61-
_dio2: u64,
62-
6360
/// Baud rate setting
6461
#[structopt(long = "baud", default_value = "1000000", env = "SX127X_BAUD")]
6562
baud: u32,
6663

67-
6864
#[structopt(long = "log-level", default_value = "info")]
6965
/// Enable verbose logging
7066
level: LevelFilter,
@@ -147,7 +143,7 @@ fn main() {
147143
// Connect to hardware
148144
let mut spi = Spidev::open(opts.spi).expect("error opening spi device");
149145
let mut config = spidev::SpidevOptions::new();
150-
config.mode(spidev::SPI_MODE_0);
146+
config.mode(spidev::SPI_MODE_0 | spidev::SPI_NO_CS);
151147
config.max_speed_hz(opts.baud);
152148
spi.configure(&config).expect("error configuring spi device");
153149

@@ -165,11 +161,6 @@ fn main() {
165161
busy.export().expect("error exporting busy pin");
166162
busy.set_direction(Direction::Out).expect("error setting busy pin direction");
167163

168-
let dio1 = PinDev::new(opts.dio1);
169-
dio1.export().expect("error exporting dio1 pin");
170-
dio1.set_direction(Direction::Out).expect("error setting dio1 pin direction");
171-
172-
173164
debug!("Creating radio instance");
174165

175166
let settings = Settings::default();
@@ -247,4 +238,6 @@ fn main() {
247238
//_ => warn!("unsuppored command: {:?}", opts.command),
248239
}
249240

241+
242+
250243
}

0 commit comments

Comments
 (0)