Skip to content

Commit

Permalink
STK and interrupt fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
orangecms committed Dec 5, 2022
1 parent 842b097 commit c2a821c
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
61 changes: 60 additions & 1 deletion ch32v3/src/ch32v30x/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,23 @@ pub mod interrupt {
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u16)]
pub enum Interrupt {
// see https://gitlab.com/eta-for-ci/ch32v307-gnumake/-/blob/945a34b9cf168c2dc8451b044c51f47053528d54/wch/hal_libraries/ch32v307_hal/include/ch32v30x.h#L29
/* RISC-V Processor Exceptions Numbers */
///2 - Non Maskable Interrupt
NMI = 2,
///3 - Exception Interrupt
EXC = 3,
///5 - E-call M Mode Interrupt
ECALL_M_MODE = 5,
///8 - E-call U Mode Interrupt
ECALL_U_MODE = 8,
///9 - Break Point Interrupt
BREAK_POINT = 9,
///14 - software Interrupt
SOFTWARE = 14,
///12 - SysTick / System Timer interrupt
STK = 12,
/* RISC-V specific Interrupt Numbers */
///16 - Window Watchdog interrupt
WWDG = 16,
///17 - PVD through EXTI line detection interrupt
Expand Down Expand Up @@ -138904,7 +138921,7 @@ pub mod systick {
const RESET_VALUE: Self::Ux = 0;
}
}
///SR (r) register accessor: an alias for `Reg<SR_SPEC>`
///SR (rw) register accessor: an alias for `Reg<SR_SPEC>`
pub type SR = crate::Reg<sr::SR_SPEC>;
///System count status register
pub mod sr {
Expand All @@ -138923,15 +138940,51 @@ pub mod systick {
R(reader)
}
}
///Register `SR` writer
pub struct W(crate::W<SR_SPEC>);
impl core::ops::Deref for W {
type Target = crate::W<SR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl core::ops::DerefMut for W {
#[inline(always)]
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl From<crate::W<SR_SPEC>> for W {
#[inline(always)]
fn from(writer: crate::W<SR_SPEC>) -> Self {
W(writer)
}
}
///Field `CNTIF` reader - Count value compare flag
pub type CNTIF_R = crate::BitReader<bool>;
///Field `CNTIF` writer - Count value compare flag
pub type CNTIF_W<'a, const O: u8> = crate::BitWriter<'a, u32, SR_SPEC, bool, 0>;
impl R {
///Bit 0 - Count value compare flag
#[inline(always)]
pub fn cntif(&self) -> CNTIF_R {
CNTIF_R::new((self.bits & 1) != 0)
}
}
impl W {
///Bit 0 - Count value compare flag
#[inline(always)]
pub fn cntif(&mut self) -> CNTIF_W<0> {
CNTIF_W::new(self)
}
///Writes raw bits to the register.
#[inline(always)]
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
self.0.bits(bits);
self
}
}
///System count status register
///
///This register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).
Expand All @@ -138945,6 +138998,12 @@ pub mod systick {
impl crate::Readable for SR_SPEC {
type Reader = R;
}
///`write()` method returns [sr::W](W) writer structure
impl crate::Writable for SR_SPEC {
type Writer = W;
const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
}
///`reset()` method sets SR to value 0
impl crate::Resettable for SR_SPEC {
const RESET_VALUE: Self::Ux = 0;
Expand Down
3 changes: 2 additions & 1 deletion ch32v3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ pub use self::generic::*;

#[cfg(feature = "ch32v30x")]
pub mod ch32v30x;

#[cfg(feature = "ch32v30x")]
pub use ch32v30x::interrupt;

0 comments on commit c2a821c

Please sign in to comment.