Skip to content

Commit

Permalink
Sync with psila
Browse files Browse the repository at this point in the history
  • Loading branch information
blueluna committed Jan 5, 2024
1 parent 827d19a commit bbf9e27
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ The code is split into following parts.

## Parts

### nRF52840 crypto cell

`nrf52-cryptocell` is a crate for using the nRF52480 crypto cell for AES
crypto.

### Target examples

#### Adafruit Feather nRF52840 Express
Expand Down
2 changes: 1 addition & 1 deletion adafruit-feather-nrf52840-express/.cargo/config
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[target.thumbv7em-none-eabihf]
runner = "probe-run --probe 1366:0101 --chip nRF52840_xxAA"
runner = ["probe-run", "--probe", "1366:0101", "--chip", "nRF52840_xxAA", "--log-format", "{t} [{L}] {s}"]
30 changes: 19 additions & 11 deletions adafruit-feather-nrf52840-express/examples/feather-express-psila.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use nrf52840_hal::gpio;
use nrf52840_pac as pac;

use psila_data::{
cluster_library::{AttributeDataType, ClusterLibraryStatus},
cluster_library::{AttributeDataType, ClusterLibraryStatus, Destination},
device_profile::SimpleDescriptor,
};
use psila_service::ClusterLibraryHandler;
use psila_service::{ClusterLibraryHandler};

use nrf_smartled::pwm::Pwm;
use smart_leds::{gamma, RGB8};
Expand Down Expand Up @@ -185,7 +185,7 @@ impl ClusterLibraryHandler for ClusterHandler {
fn active_endpoints(&self) -> &[u8] {
&[0x01]
}
fn get_simple_desciptor(&self, endpoint: u8) -> Option<SimpleDescriptor> {
fn get_simple_descriptor(&self, endpoint: u8) -> Option<SimpleDescriptor> {
match endpoint {
0x01 => Some(SimpleDescriptor::new(
0x01,
Expand All @@ -198,7 +198,7 @@ impl ClusterLibraryHandler for ClusterHandler {
CLUSTER_LEVEL_CONTROL,
CLUSTER_COLOR_CONTROL,
],
&[],
&[CLUSTER_ON_OFF],
)),
_ => None,
}
Expand All @@ -207,7 +207,7 @@ impl ClusterLibraryHandler for ClusterHandler {
&self,
profile: u16,
cluster: u16,
_endpoint: u8,
_destination: Destination,
attribute: u16,
value: &mut [u8],
) -> Result<(AttributeDataType, usize), ClusterLibraryStatus> {
Expand Down Expand Up @@ -284,7 +284,7 @@ impl ClusterLibraryHandler for ClusterHandler {
&mut self,
profile: u16,
cluster: u16,
_endpoint: u8,
_destination: Destination,
attribute: u16,
data_type: AttributeDataType,
value: &[u8],
Expand Down Expand Up @@ -313,7 +313,7 @@ impl ClusterLibraryHandler for ClusterHandler {
&mut self,
profile: u16,
cluster: u16,
_endpoint: u8,
_destination: Destination,
command: u8,
arguments: &[u8],
) -> Result<(), ClusterLibraryStatus> {
Expand Down Expand Up @@ -517,7 +517,7 @@ impl ClusterLibraryHandler for ClusterHandler {
Ok(())
}
(_, _, _) => {
defmt::info!("Operation {=u16} {=u16} {=u8}", profile, cluster, command);
defmt::info!("Command {=u16:04x} {=u16:04x} {=u8:04x}", profile, cluster, command);
Err(ClusterLibraryStatus::UnsupportedClusterCommand)
}
}
Expand All @@ -539,6 +539,7 @@ mod app {
timer::Timer,
};
use psila_service::{self, PsilaService};
use rtic::Mutex;

const TIMER_SECOND: u32 = 1_000_000;

Expand Down Expand Up @@ -600,7 +601,7 @@ mod app {
timer1.fire_in(1, TIMER_SECOND);

let mut radio = Radio::new(cx.device.RADIO);
radio.set_channel(15);
radio.set_channel(11);
radio.set_transmission_power(8);
radio.receive_prepare();

Expand Down Expand Up @@ -702,13 +703,20 @@ mod app {

#[task(shared = [radio], local = [tx_consumer])]
fn radio_tx(mut cx: radio_tx::Context) {
const NO_CCA_MARKER: u8 = 0x80;
let queue = cx.local.tx_consumer;
cx.shared.radio.lock(|radio| {
if !radio.is_tx_busy() {
if let Ok(grant) = queue.read() {
let packet_length = grant[0] as usize;
let no_cca = (grant[0] & NO_CCA_MARKER) == NO_CCA_MARKER;
let packet_length = (grant[0] & 0x7f) as usize;
let data = &grant[1..=packet_length];
let _ = radio.queue_transmission(data);
if no_cca {
let _ = radio.queue_transmission_no_cca(data);
}
else {
let _ = radio.queue_transmission(data);
}
grant.release(packet_length + 1);
}
let _ = radio_rx::spawn();
Expand Down
2 changes: 1 addition & 1 deletion nrf52840-dk/examples/nrf52840-dk-psila.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl ClusterLibraryHandler for ClusterHandler {
fn active_endpoints(&self) -> &[u8] {
&[0x01]
}
fn get_simple_desciptor(&self, endpoint: u8) -> Option<SimpleDescriptor> {
fn get_simple_descriptor(&self, endpoint: u8) -> Option<SimpleDescriptor> {
match endpoint {
0x01 => Some(SimpleDescriptor::new(
0x01,
Expand Down

0 comments on commit bbf9e27

Please sign in to comment.