Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 24 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,32 @@ license = "ISC"
edition = "2018"

[dependencies]
gd32vf103-pac = "0.4.0"
riscv = "0.6.0"
nb = "0.1.2"
bare-metal = "0.2.5"
riscv = "0.10.1"
nb = "1.0.0"
void = { version = "1.0.2", default-features = false }
cast = { version = "0.2.3", default-features = false }
cast = { version = "0.3.0", default-features = false }
vcell = "0.1.2"
embedded-dma = "0.1.2"
embedded-dma = "0.2.0"

[dependencies.embedded-storage]
version = "0.3.0"
optional = true

[dependencies.embedded-hal]
version = "0.2.3"
version = "0.2.7"
features = ["unproven"]

[dependencies.gd32vf103-pac]
git = "https://github.com/katyo/gd32vf103-pac"
branch = "upcoming"

[dependencies.synopsys-usb-otg]
git = "https://github.com/katyo/synopsys-usb-otg"
branch = "gd32v-ng-cs"
features = ["fs"]
optional = true

[features]
default = []
usb_fs = ["synopsys-usb-otg"]
10 changes: 5 additions & 5 deletions src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::dma::{dma0::C0, CircBuffer, CircReadDma, Receive, RxDma, Transfer, Tr
use crate::gpio::{gpioa, gpiob, gpioc, Analog};
use crate::pac::{ADC0, ADC1};
use crate::rcu::{BaseFrequency, Clocks, Enable, Rcu, Reset};
use embedded_dma::StaticWriteBuffer;
use embedded_dma::WriteBuffer;
use embedded_hal::adc::{Channel, OneShot};

#[doc(hidden)]
Expand Down Expand Up @@ -674,13 +674,13 @@ where
impl<B, PINS, MODE> CircReadDma<B, u16> for AdcDma<PINS, MODE>
where
Self: TransferPayload,
&'static mut [B; 2]: StaticWriteBuffer<Word = u16>,
&'static mut [B; 2]: WriteBuffer<Word = u16>,
B: 'static,
{
fn circ_read(mut self, mut buffer: &'static mut [B; 2]) -> CircBuffer<B, Self> {
// NOTE(unsafe) We own the buffer now and we won't call other `&mut` on it until the end of
// the transfer
let (ptr, len) = unsafe { buffer.static_write_buffer() };
let (ptr, len) = unsafe { buffer.write_buffer() };
unsafe {
self.channel.set_peripheral_address(&(*ADC0::ptr()).rdata as *const _ as u32, false);
self.channel.set_memory_address(ptr as u32, true);
Expand All @@ -705,12 +705,12 @@ where
impl<B, PINS, MODE> crate::dma::ReadDma<B, u16> for AdcDma<PINS, MODE>
where
Self: TransferPayload,
B: StaticWriteBuffer<Word = u16>,
B: WriteBuffer<Word = u16>,
{
fn read(mut self, mut buffer: B) -> Transfer<W, B, Self> {
// NOTE(unsafe) We own the buffer now and we won't call other `&mut` on it
// until the end of the transfer.
let (ptr, len) = unsafe { buffer.static_write_buffer() };
let (ptr, len) = unsafe { buffer.write_buffer() };
unsafe {
self.channel.set_peripheral_address(&(*ADC0::ptr()).rdata as *const _ as u32, false);
self.channel.set_memory_address(ptr as u32, true);
Expand Down
10 changes: 5 additions & 5 deletions src/dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::{
marker::PhantomData,
sync::atomic::{compiler_fence, Ordering},
};
use embedded_dma::{StaticReadBuffer, StaticWriteBuffer};
use embedded_dma::{ReadBuffer, WriteBuffer};

use crate::rcu::Rcu;

Expand Down Expand Up @@ -43,7 +43,7 @@ where

impl<BUFFER, PAYLOAD> CircBuffer<BUFFER, PAYLOAD>
where
&'static mut [BUFFER; 2]: StaticWriteBuffer,
&'static mut [BUFFER; 2]: WriteBuffer,
BUFFER: 'static,
{
pub(crate) fn new(buf: &'static mut [BUFFER; 2], payload: PAYLOAD) -> Self {
Expand Down Expand Up @@ -556,7 +556,7 @@ pub trait Transmit {
/// Trait for circular DMA readings from peripheral to memory.
pub trait CircReadDma<B, RS>: Receive
where
&'static mut [B; 2]: StaticWriteBuffer<Word = RS>,
&'static mut [B; 2]: WriteBuffer<Word = RS>,
B: 'static,
Self: core::marker::Sized,
{
Expand All @@ -566,7 +566,7 @@ where
/// Trait for DMA readings from peripheral to memory.
pub trait ReadDma<B, RS>: Receive
where
B: StaticWriteBuffer<Word = RS>,
B: WriteBuffer<Word = RS>,
Self: core::marker::Sized + TransferPayload,
{
fn read(self, buffer: B) -> Transfer<W, B, Self>;
Expand All @@ -575,7 +575,7 @@ where
/// Trait for DMA writing from memory to peripheral.
pub trait WriteDma<B, TS>: Transmit
where
B: StaticReadBuffer<Word = TS>,
B: ReadBuffer<Word = TS>,
Self: core::marker::Sized + TransferPayload,
{
fn write(self, buffer: B) -> Transfer<R, B, Self>;
Expand Down
2 changes: 1 addition & 1 deletion src/eclic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::pac::ECLIC;
use riscv::interrupt::Nr;
use bare_metal::Nr;

const EFFECTIVE_LEVEL_PRIORITY_BITS: u8 = 4;

Expand Down
Loading