Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for hrtim #153

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
bf01572
Use latest pac
usbalbin Dec 16, 2023
0a0edec
Update DMA for new pac
usbalbin Dec 16, 2023
3f00ac9
Update for new pac
usbalbin Dec 16, 2023
d533228
Fix clippy warnings
usbalbin Dec 18, 2023
d594db4
fmt
usbalbin Aug 6, 2024
aa1a7a3
Add G91 and G4A1 to CI
usbalbin Aug 6, 2024
4886998
Add support for G491 and G4A1
usbalbin Aug 6, 2024
5de0c65
rename device feature
usbalbin Aug 7, 2024
41fb3c2
Update for new pac with write and modify not returning unit type
usbalbin Nov 7, 2024
c92be81
Update for new pac with write and modify not returning unit type - fo…
usbalbin Nov 7, 2024
6e23b8d
Fix some leftover G491 things
usbalbin Nov 7, 2024
bfc82e2
g491 and g4a1 does not have ADC4 and 5
usbalbin Nov 7, 2024
de17e3e
Update src/fdcan.rs
usbalbin Nov 7, 2024
145ba50
Slightly demacrofy DMA
usbalbin Nov 7, 2024
ad40976
Update cordic.rs
AdinAck Nov 8, 2024
9772644
fix annoying clippy lint
AdinAck Nov 8, 2024
9c2e5ff
Update ci.yml
AdinAck Nov 8, 2024
c8cfbba
fix cordic example
AdinAck Nov 8, 2024
1a98a67
update ci to include logging for cordic
AdinAck Nov 8, 2024
46d44d8
override clippy empty loop
AdinAck Nov 8, 2024
efc5913
Merge remote-tracking branch 'upstream/main' into update_for_main_cha…
usbalbin Dec 3, 2024
3e78aef
fmt
usbalbin Dec 3, 2024
9f3c8f2
Fix clippy
usbalbin Dec 3, 2024
13f2b09
Merge pull request #152 from usbalbin/update_for_main_changes
usbalbin Dec 3, 2024
c9f612f
Bump pac (#149)
usbalbin Dec 3, 2024
87bd6f0
DMA - rename stream to channel (#147)
usbalbin Dec 3, 2024
5923272
Add hrtim to rcc
usbalbin Dec 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on:
pull_request:

name: Continuous integration

# Make sure CI fails on all warnings, including Clippy lints
Expand All @@ -22,13 +22,14 @@ jobs:
- stm32g474
- stm32g483
- stm32g484
#- stm32g491 # Does not seem ready yet
#- stm32g4a1 # Does not seem ready yet
- stm32g491 # Does not seem ready yet
- stm32g4a1 # Does not seem ready yet
features:
- log-rtt,defmt
# TODO: -log-rtt # log-rtt without defmt, more combos?
- log-itm
- log-semihost
- cordic,log-rtt,defmt

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ version = "0.0.2"

[dependencies]
nb = "0.1.1"
stm32g4 = "0.15.1"
#stm32g4 = { git = "https://github.com/stm32-rs/stm32-rs-nightlies" } #"0.15.1"
stm32g4 = { version = "0.19.0", package = "stm32g4-staging" }
paste = "1.0"
bitflags = "1.2"
vcell = "0.1"
Expand Down
6 changes: 3 additions & 3 deletions examples/adc-continious-dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::hal::{
AdcClaim, ClockSource, Temperature, Vref,
},
delay::SYSTDelayExt,
dma::{config::DmaConfig, stream::DMAExt, TransferExt},
dma::{channel::DMAExt, config::DmaConfig, TransferExt},
gpio::GpioExt,
pwr::PwrExt,
rcc::{Config, RccExt},
Expand All @@ -36,7 +36,7 @@ fn main() -> ! {
let pwr = dp.PWR.constrain().freeze();
let mut rcc = rcc.freeze(Config::hsi(), pwr);

let streams = dp.DMA1.split(&rcc);
let channels = dp.DMA1.split(&rcc);
let config = DmaConfig::default()
.transfer_complete_interrupt(false)
.circular_buffer(true)
Expand All @@ -62,7 +62,7 @@ fn main() -> ! {

info!("Setup DMA");
let first_buffer = cortex_m::singleton!(: [u16; 15] = [0; 15]).unwrap();
let mut transfer = streams.0.into_circ_peripheral_to_memory_transfer(
let mut transfer = channels.ch1.into_circ_peripheral_to_memory_transfer(
adc.enable_dma(AdcDma::Continuous),
&mut first_buffer[..],
config,
Expand Down
10 changes: 5 additions & 5 deletions examples/adc-one-shot-dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::hal::{
AdcClaim, ClockSource, Temperature,
},
delay::SYSTDelayExt,
dma::{config::DmaConfig, stream::DMAExt, TransferExt},
dma::{channel::DMAExt, config::DmaConfig, TransferExt},
gpio::GpioExt,
pwr::PwrExt,
rcc::{Config, RccExt},
Expand Down Expand Up @@ -37,7 +37,7 @@ fn main() -> ! {
let pwr = dp.PWR.constrain().freeze();
let mut rcc = rcc.freeze(Config::hsi(), pwr);

let mut streams = dp.DMA1.split(&rcc);
let mut channels = dp.DMA1.split(&rcc);
let config = DmaConfig::default()
.transfer_complete_interrupt(false)
.circular_buffer(false)
Expand All @@ -61,7 +61,7 @@ fn main() -> ! {

info!("Setup DMA");
let first_buffer = cortex_m::singleton!(: [u16; 2] = [0; 2]).unwrap();
let mut transfer = streams.0.into_peripheral_to_memory_transfer(
let mut transfer = channels.ch1.into_peripheral_to_memory_transfer(
adc.enable_dma(AdcDma::Single),
&mut first_buffer[..],
config,
Expand All @@ -74,10 +74,10 @@ fn main() -> ! {
info!("Conversion Done");

transfer.pause(|adc| adc.cancel_conversion());
let (s0, adc, first_buffer) = transfer.free();
let (ch1, adc, first_buffer) = transfer.free();
let adc = adc.disable();

streams.0 = s0;
channels.ch1 = ch1;

let millivolts = adc.sample_to_millivolts(first_buffer[0]);
info!("pa3: {}mV", millivolts);
Expand Down
9 changes: 5 additions & 4 deletions examples/cordic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ extern crate cortex_m;
extern crate cortex_m_rt as rt;
extern crate stm32g4xx_hal as hal;

use fixed::types::I1F15;
use hal::cordic::{
func::{dynamic::Mode as _, scale::N0, Magnitude, SinCos, Sqrt},
op::{dynamic::Mode as _, Magnitude, SinCos, Sqrt},
prec::P60,
types::{Q15, Q31},
scale::N0,
types::{I1F15, Q15, Q31},
Ext as _,
};
use hal::prelude::*;
Expand All @@ -34,7 +34,7 @@ fn main() -> ! {
let mut cordic = dp
.CORDIC
.constrain(&mut rcc)
.freeze::<Q15, Q31, SinCos, P60>(); // 16 bit arguments, 32 bit results, compute sine and cosine, 60 iterations
.freeze::<Q15, Q31, P60, SinCos>(); // 16 bit arguments, 32 bit results, compute sine and cosine, 60 iterations

// static operation (zero overhead)

Expand All @@ -53,5 +53,6 @@ fn main() -> ! {
let magnitude = cordic.run::<Magnitude>((I1F15::from_num(0.25), I1F15::from_num(0.5)));
println!("magnitude: {}", magnitude.to_num::<f32>());

#[allow(clippy::empty_loop)]
loop {}
}
2 changes: 1 addition & 1 deletion examples/flash_with_rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ mod app {

unsafe {
let mut flash = &(*stm32g4xx_hal::stm32::FLASH::ptr());
flash.acr.modify(|_, w| {
flash.acr().modify(|_, w| {
w.latency().bits(0b1000) // 8 wait states
});
}
Expand Down
13 changes: 7 additions & 6 deletions examples/spi-dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use crate::hal::{

use cortex_m_rt::entry;
use stm32g4xx_hal as hal;
use stm32g4xx_hal::dma::channel::DMAExt;
use stm32g4xx_hal::dma::config::DmaConfig;
use stm32g4xx_hal::dma::stream::DMAExt;
use stm32g4xx_hal::dma::TransferExt;

#[macro_use]
Expand All @@ -50,7 +50,7 @@ fn main() -> ! {
let spi = dp
.SPI1
.spi((sclk, miso, mosi), spi::MODE_0, 400.kHz(), &mut rcc);
let streams = dp.DMA1.split(&rcc);
let channels = dp.DMA1.split(&rcc);
let config = DmaConfig::default()
.transfer_complete_interrupt(false)
.circular_buffer(true)
Expand All @@ -62,10 +62,11 @@ fn main() -> ! {
*item = index as u8;
}
let dma_buf = cortex_m::singleton!(: [u8; BUFFER_SIZE] = buf).unwrap();
let mut transfer_dma =
streams
.0
.into_memory_to_peripheral_transfer(spi.enable_tx_dma(), &mut dma_buf[..], config);
let mut transfer_dma = channels.ch1.into_memory_to_peripheral_transfer(
spi.enable_tx_dma(),
&mut dma_buf[..],
config,
);
transfer_dma.start(|_spi| {});
loop {
delay_tim2.delay_ms(1000_u16);
Expand Down
6 changes: 3 additions & 3 deletions examples/uart-dma-rx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

extern crate cortex_m_rt as rt;

use hal::dma::{config::DmaConfig, stream::DMAExt, TransferExt};
use hal::dma::{channel::DMAExt, config::DmaConfig, TransferExt};
use hal::prelude::*;
use hal::pwr::PwrExt;
use hal::serial::*;
Expand All @@ -30,7 +30,7 @@ fn main() -> ! {
let pwr = dp.PWR.constrain().freeze();
let mut rcc = rcc.freeze(rcc::Config::hsi(), pwr);

let streams = dp.DMA1.split(&rcc);
let channels = dp.DMA1.split(&rcc);
let config = DmaConfig::default()
.transfer_complete_interrupt(false)
.circular_buffer(true)
Expand Down Expand Up @@ -65,7 +65,7 @@ fn main() -> ! {

let (_tx, rx) = usart.split();

let mut transfer = streams.0.into_circ_peripheral_to_memory_transfer(
let mut transfer = channels.ch1.into_circ_peripheral_to_memory_transfer(
rx.enable_dma(),
&mut rx_buffer[..],
config,
Expand Down
13 changes: 7 additions & 6 deletions examples/uart-dma-tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern crate cortex_m_rt as rt;

use core::fmt::Write;

use hal::dma::{config::DmaConfig, stream::DMAExt, TransferExt};
use hal::dma::{channel::DMAExt, config::DmaConfig, TransferExt};
use hal::prelude::*;
use hal::pwr::PwrExt;
use hal::serial::*;
Expand All @@ -32,7 +32,7 @@ fn main() -> ! {
let pwr = dp.PWR.constrain().freeze();
let mut rcc = rcc.freeze(rcc::Config::hsi(), pwr);

let streams = dp.DMA1.split(&rcc);
let channels = dp.DMA1.split(&rcc);
let config = DmaConfig::default()
.transfer_complete_interrupt(false)
.circular_buffer(false)
Expand Down Expand Up @@ -64,10 +64,11 @@ fn main() -> ! {
let (tx, _rx) = usart.split();

// Setup DMA for USART2 TX with dma channel 1.
let mut transfer =
streams
.0
.into_memory_to_peripheral_transfer(tx.enable_dma(), &mut tx_buffer[..], config);
let mut transfer = channels.ch1.into_memory_to_peripheral_transfer(
tx.enable_dma(),
&mut tx_buffer[..],
config,
);

transfer.start(|_tx| {});
loop {
Expand Down
Loading
Loading