-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit with cc2500 controller
- Loading branch information
0 parents
commit 5de2821
Showing
8 changed files
with
603 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/target | ||
**/*.rs.bk | ||
.idea |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[package] | ||
name = "cc2500" | ||
version = "0.1.0" | ||
authors = ["tschl"] | ||
edition = "2018" | ||
target = "armv7-unknown-linux-gnueabihf" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
rppal = "0.11.3" | ||
log = "0.4.8" | ||
|
||
[target.armv7-unknown-linux-gnueabihf] | ||
linker = "arm-linux-gnueabihf-gcc-8" | ||
ar = "arm-linux-gnueabihf-ar" | ||
|
||
[tasks.compile] | ||
command = "cargo" | ||
args = ["build", "--target", "armv7-unknown-linux-gnueabihf"] | ||
|
||
[tasks.upload] | ||
command = "scp" | ||
args = ["./target/armv7-unknown-linux-gnueabihf/debug/cc2500", "[email protected]:"] | ||
|
||
[tasks.gdb] | ||
command = "ssh" | ||
args = ["[email protected]", "gdbserver 0.0.0.0:2345 ./cc2500"] | ||
|
||
[tasks.debug-raspberry] | ||
dependencies = [ | ||
"compile", | ||
"upload", | ||
# "gdb" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Ansluta Rust controller | ||
|
||
This project is a rust application compiled for an raspberry pi to control IKEA lamps by faking an Ansluta remote. | ||
Thanks to [NDBCK](https://github.com/NDBCK/Ansluta-Remote-Controller) for his great research and example code in C++. | ||
In this project I used the first time ever rust language so please don't judge about code style :D. | ||
|
||
|
||
### Requirements | ||
|
||
* [Raspberry PI 3 <small>(€33,99 at Amazon)</small>](https://amzn.to/2oiGepb) | ||
* [CC2500 2.4 GHz chip <small>(€3 at Amazon)</small>](https://amzn.to/2mbaRwk) | ||
* [Breadboard & Jumper cables <small>(€8.99 at Amazon)</small>](https://amzn.to/2mRyfiG) | ||
* [Rust](https://www.rust-lang.org/tools/install) | ||
* [Cargo make](https://github.com/sagiegurari/cargo-make#installation) | ||
* [Cargo watch](https://github.com/passcod/cargo-watch#install) | ||
* Linux Subsystem if you are on windows | ||
* GCC for Raspberry ARM processor | ||
|
||
### Setup | ||
|
||
**1)** Open linux shell (`bash.exe` for linux subsystem on windows) | ||
|
||
**2)** Install rustup, rust and cargo | ||
```bash | ||
$ curl https://sh.rustup.rs -sSf | sh | ||
``` | ||
|
||
**3)** Install cargo-make | ||
``` | ||
$ cargo install --force cargo-make | ||
``` | ||
|
||
**4)** Install cargo-make | ||
``` | ||
$ cargo install --force cargo-watch | ||
``` | ||
|
||
**5)** Install ARM gcc to cross compile for raspberry pi. | ||
*Note: If you choose another gcc version you have to update the linker used in the Cargo.toml file.* | ||
``` | ||
$ apt-get install gcc-8-multilib-arm-linux-gnueabihf | ||
``` | ||
|
||
**6)** Add target in rustup | ||
``` | ||
$ rustup target add armv7-unknown-linux-gnueabihf | ||
``` | ||
|
||
**7)** Update ip in Cargo.toml to directly upload to raspberry pi on build | ||
``` | ||
$ sed -i 's/xxx.xxx.xxx.xxx/your-ip/g' ./Cargo.toml | ||
``` | ||
|
||
### Run | ||
|
||
**Build**: Compile and upload to raspberry pi | ||
```bash | ||
$ cargo make --makefile Cargo.toml debug-raspberry | ||
``` | ||
|
||
**Watch**: Compile and upload on every file change | ||
```bash | ||
cargo watch -x "make --makefile Cargo.toml debug-raspberry" | ||
``` | ||
|
||
**NOTE**: Seems like there is no remote debug functionality at all. I didn't managed it to have breakpoints working. Neither CLion with GDBRemote nor CLI worked and I just found bugs / issues raised by other users complaining about the same. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use crate::cc2500::chip::CC2500; | ||
use rppal::spi::Spi; | ||
|
||
mod chip; | ||
mod constants; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
pub struct Address(pub u8, pub u8); | ||
|
||
pub enum STATE { | ||
SIDLE = 0x36, // Exit RX / TX | ||
STX = 0x35, // Enable TX. If in RX state, only enable TX if CCA passes | ||
SFTX = 0x3B, // Flush the TX FIFO buffer. Only issue SFTX in IDLE or TXFIFO_UNDERFLOW states | ||
SRES = 0x30, // Reset chip | ||
SRX = 0x34, // Enable RX. Perform calibration if enabled | ||
SFRX = 0x3A, // Flush the RX FIFO buffer. Only issue SFRX in IDLE or RXFIFO_OVERFLOW states | ||
} | ||
|
||
pub enum COMMAND { | ||
LightOff = 0x01, // Command to turn the light off | ||
LightOn50 = 0x02, // Command to turn the light on 50% | ||
LightOn100 = 0x03, // Command to turn the light on 100% | ||
PAIR = 0xFF, // Command to pair a remote to the light | ||
} | ||
|
||
pub fn new(spi: Spi) -> CC2500 { | ||
CC2500 { spi, address: None } | ||
} |
Oops, something went wrong.