File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,8 +8,8 @@ documentation = "https://docs.rs/qingke"
88homepage = " https://github.com/ch32-rs/qingke"
99categories = [" embedded" , " no-std" , " hardware-support" ]
1010license = " MIT/Apache-2.0"
11- version = " 0.5 .0" # for rt and macros
12- edition = " 2021 "
11+ version = " 0.6 .0" # for rt and macros
12+ edition = " 2024 "
1313
1414[package ]
1515name = " qingke"
@@ -27,17 +27,19 @@ readme = "README.md"
2727
2828[dependencies ]
2929bit_field = " 0.10.2"
30- riscv = " 0.12 .0"
30+ riscv = " 0.15 .0"
3131cfg-if = " 1.0"
3232critical-section = { version = " 1.2.0" , features = [
3333 " restore-state-bool" ,
3434], optional = true }
35- defmt = { version = " 0.3.8 " , optional = true }
35+ defmt = { version = " 1.0.1 " , optional = true }
3636
3737[features ]
3838critical-section-impl = [" dep:critical-section" ]
3939defmt = [" dep:defmt" ]
40+ v2 = []
4041v3 = []
42+ v4 = []
4143unsafe-trust-wch-atomics = []
4244
4345[package .metadata .docs .rs ]
Original file line number Diff line number Diff line change @@ -14,9 +14,9 @@ readme = "README.md"
1414
1515
1616[features ]
17- v2 = []
17+ v2 = [" qingke/v2 " ]
1818v3 = [" qingke/v3" ]
19- v4 = []
19+ v4 = [" qingke/v4 " ]
2020
2121u-mode = []
2222# v5 is not released yet
@@ -25,8 +25,8 @@ u-mode = []
2525highcode = []
2626
2727[dependencies ]
28- qingke-rt-macros = { version = " 0.5 .0" , path = " ./macros" }
29- qingke = { version = " 0.5 .0" , path = " ../" , features = [" critical-section-impl" ] }
28+ qingke-rt-macros = { version = " 0.6 .0" , path = " ./macros" }
29+ qingke = { version = " 0.6 .0" , path = " ../" , features = [" critical-section-impl" ] }
3030
3131[package .metadata .docs .rs ]
3232targets = [" riscv32imc-unknown-none-elf" ]
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ set_impl!(SingleHartCriticalSection);
66unsafe impl Impl for SingleHartCriticalSection {
77 unsafe fn acquire ( ) -> RawRestoreState {
88 cfg_if:: cfg_if! {
9- if #[ cfg( qingke_v2 ) ] {
9+ if #[ cfg( feature = "v2" ) ] {
1010 // CH32V003 (qingke_v2) does not have gintenr register
1111 // Use standard RISC-V mstatus.MIE instead
1212 let mut mstatus: usize ;
@@ -24,7 +24,7 @@ unsafe impl Impl for SingleHartCriticalSection {
2424 // Only re-enable interrupts if they were enabled before the critical section.
2525 if irq_state {
2626 cfg_if:: cfg_if! {
27- if #[ cfg( qingke_v2 ) ] {
27+ if #[ cfg( feature = "v2" ) ] {
2828 core:: arch:: asm!( "csrsi mstatus, 0b1000" ) ;
2929 } else {
3030 use crate :: register:: gintenr;
Original file line number Diff line number Diff line change 66//!
77//! Write 0x08 to enable global interrupt
88//!
9- //! NOTE: This register is NOT available on qingke_v2 (CH32V003).
10- //! Use mstatus.MIE instead for qingke_v2 .
9+ //! NOTE: This register is NOT available on v2 (CH32V003).
10+ //! Use mstatus.MIE instead for v2 .
1111
12- #[ cfg( not( qingke_v2 ) ) ]
12+ #[ cfg( not( feature = "v2" ) ) ]
1313use core:: arch:: asm;
1414
15- #[ cfg( not( qingke_v2 ) ) ]
15+ #[ cfg( not( feature = "v2" ) ) ]
1616#[ inline]
1717pub fn read ( ) -> usize {
1818 let ans: usize ;
1919 unsafe { asm ! ( "csrr {}, 0x800" , out( reg) ans) } ;
2020 ans
2121}
2222
23- #[ cfg( not( qingke_v2 ) ) ]
23+ #[ cfg( not( feature = "v2" ) ) ]
2424#[ inline]
2525pub unsafe fn write ( bits : usize ) {
2626 asm ! ( "csrw 0x800, {}" , in( reg) bits) ;
2727}
2828
29- #[ cfg( not( qingke_v2 ) ) ]
29+ #[ cfg( not( feature = "v2" ) ) ]
3030#[ inline]
3131pub unsafe fn set_enable ( ) {
3232 let mask = 0x8 ;
3333 asm ! ( "csrs 0x800, {}" , in( reg) mask) ;
3434}
3535
36- #[ cfg( not( qingke_v2 ) ) ]
36+ #[ cfg( not( feature = "v2" ) ) ]
3737#[ inline]
3838/// Disable interrupt and return the old `GINTENR` value
3939pub fn set_disable ( ) -> usize {
You can’t perform that action at this time.
0 commit comments