cleanups
This commit is contained in:
Binary file not shown.
2
board/.gitignore
vendored
2
board/.gitignore
vendored
@@ -34,3 +34,5 @@ _autosave-*
|
||||
|
||||
# Autorouter files (exported from Pcbnew)
|
||||
fp-info-cache
|
||||
*.zip
|
||||
netlist.ipc
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
1
board/modules/3v3/fabrication-toolkit-options.json
Normal file
1
board/modules/3v3/fabrication-toolkit-options.json
Normal file
@@ -0,0 +1 @@
|
||||
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
|
1
board/modules/LightOut/fabrication-toolkit-options.json
Normal file
1
board/modules/LightOut/fabrication-toolkit-options.json
Normal file
@@ -0,0 +1 @@
|
||||
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
|
1
board/modules/MPPT/fabrication-toolkit-options.json
Normal file
1
board/modules/MPPT/fabrication-toolkit-options.json
Normal file
@@ -0,0 +1 @@
|
||||
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
|
@@ -0,0 +1 @@
|
||||
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
|
@@ -0,0 +1 @@
|
||||
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
|
4
board/modules/Sensors_can/Sensors/fp-lib-table
Normal file
4
board/modules/Sensors_can/Sensors/fp-lib-table
Normal file
@@ -0,0 +1,4 @@
|
||||
(fp_lib_table
|
||||
(version 7)
|
||||
(lib (name "Sensor")(type "KiCad")(uri "/home/empire/workspace/PlantCtrl/board/modules/Sensors/Sensors/Sensor.pretty")(options "")(descr ""))
|
||||
)
|
71
board/modules/Sensors_can/Sensors/production/netlist.ipc
Normal file
71
board/modules/Sensors_can/Sensors/production/netlist.ipc
Normal file
@@ -0,0 +1,71 @@
|
||||
P CODE 00
|
||||
P UNITS CUST 0
|
||||
P arrayDim N
|
||||
317GND VIA MD0118PA00X+040551Y-024902X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+054232Y-022933X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+053346Y-021949X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+040846Y-019980X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+041043Y-025787X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+040059Y-019980X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+044291Y-025787X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+046654Y-025000X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+041240Y-021949X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+043307Y-020768X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+039961Y-022539X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+049606Y-021260X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+043898Y-024803X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+044587Y-023917X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+041142Y-024016X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+052461Y-022835X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+053642Y-024016X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+047835Y-026378X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+042618Y-020669X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+049409Y-022047X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+042520Y-022441X0236Y0000R000S3
|
||||
317GND VIA MD0118PA00X+048622Y-022835X0236Y0000R000S3
|
||||
327GND R_slop-1 A01X+053967Y-020177X0315Y0374R180S2
|
||||
327NET-(U1-RS) R_slop-2 A01X+053317Y-020177X0315Y0374R180S2
|
||||
3173_3V U6 -1 D0394PA00X+039016Y-019370X0669Y0669R000S0
|
||||
317(U6-VBAT-PAD2) U6 -2 D0394PA00X+039016Y-020370X0669Y0000R000S0
|
||||
317-(U6-SDA-PAD3) U6 -3 D0394PA00X+039016Y-021370X0669Y0000R000S0
|
||||
317-(U6-SCL-PAD4) U6 -4 D0394PA00X+039016Y-022370X0669Y0000R000S0
|
||||
317ENABLE_CAN U6 -5 D0394PA00X+039016Y-023370X0669Y0000R000S0
|
||||
317CAN+ U6 -6 D0394PA00X+039016Y-024370X0669Y0000R000S0
|
||||
317CAN- U6 -7 D0394PA00X+039016Y-025370X0669Y0000R000S0
|
||||
317GND U6 -8 D0394PA00X+039016Y-026370X0669Y0000R000S0
|
||||
317GND U6 -9 D0394PA00X+071260Y-034252X0669Y0669R000S0
|
||||
317GND U6 -10 D0394PA00X+055512Y-031299X0669Y0669R000S0
|
||||
317GND U6 -11 D0394PA00X+038780Y-034252X0669Y0669R000S0
|
||||
317GND U6 -12 D0394PA00X+055512Y-020669X0669Y0669R000S0
|
||||
317GND U6 -13 D0394PA00X+071260Y-019094X0669Y0669R000S0
|
||||
327NET-(QP_1-G) QP_1 -1 A01X+047835Y-021280X0354Y0315R000S2
|
||||
3273_3V QP_1 -2 A01X+047835Y-022028X0354Y0315R000S2
|
||||
327CAN_POWER QP_1 -3 A01X+048622Y-021654X0354Y0315R000S2
|
||||
327CAN_POWER R5 -1 A01X+047835Y-022904X0315Y0374R090S2
|
||||
327NET-(I1-A) R5 -2 A01X+047835Y-023553X0315Y0374R090S2
|
||||
327NET-(QP_1-G) R6 -1 A01X+046654Y-021329X0315Y0374R090S2
|
||||
3273_3V R6 -2 A01X+046654Y-021978X0315Y0374R090S2
|
||||
327NET-(QP_1-G) R7 -1 A01X+045669Y-021329X0315Y0374R090S2
|
||||
327NET-(Q1-D) R7 -2 A01X+045669Y-021978X0315Y0374R090S2
|
||||
317CAN_POWER J1 -1 D0374PA00X+055197Y-025394X0669Y0768R270S0
|
||||
317NET-(J1-PIN_2) J1 -2 D0374PA00X+055197Y-024409X0669Y0768R270S0
|
||||
317NET-(J1-PIN_3) J1 -3 D0374PA00X+055197Y-023425X0669Y0768R270S0
|
||||
317GND J1 -4 D0374PA00X+055197Y-022441X0669Y0768R270S0
|
||||
327NET-(Q1-G) Q1 -1 A01X+043819Y-021280X0354Y0315R000S2
|
||||
327GND Q1 -2 A01X+043819Y-022028X0354Y0315R000S2
|
||||
327NET-(Q1-D) Q1 -3 A01X+044606Y-021654X0354Y0315R000S2
|
||||
327CAN+ U1 -1 A01X+050295Y-020707X0768Y0236R000S2
|
||||
327GND U1 -2 A01X+050295Y-021207X0768Y0236R000S2
|
||||
327CAN_POWER U1 -3 A01X+050295Y-021707X0768Y0236R000S2
|
||||
327CAN- U1 -4 A01X+050295Y-022207X0768Y0236R000S2
|
||||
327(U1-VREF-PAD5) U1 -5 A01X+052244Y-022207X0768Y0236R000S2
|
||||
327NET-(J1-PIN_2) U1 -6 A01X+052244Y-021707X0768Y0236R000S2
|
||||
327NET-(J1-PIN_3) U1 -7 A01X+052244Y-021207X0768Y0236R000S2
|
||||
327NET-(U1-RS) U1 -8 A01X+052244Y-020707X0768Y0236R000S2
|
||||
327NET-(Q1-G) R8 -1 A01X+042520Y-021329X0315Y0374R090S2
|
||||
327GND R8 -2 A01X+042520Y-021978X0315Y0374R090S2
|
||||
327GND I1 -1 A01X+047835Y-025541X0384Y0551R270S2
|
||||
327NET-(I1-A) I1 -2 A01X+047835Y-024803X0384Y0551R270S2
|
||||
327NET-(Q1-G) R4 -1 A01X+040846Y-023346X0315Y0374R180S2
|
||||
327ENABLE_CAN R4 -2 A01X+040197Y-023346X0315Y0374R180S2
|
||||
999
|
32
board/modules/Sensors_can/ch32-sensor/.doomrc
Normal file
32
board/modules/Sensors_can/ch32-sensor/.doomrc
Normal file
@@ -0,0 +1,32 @@
|
||||
;;; .doomrc --- doom runtime config -*- mode: emacs-lisp; lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
(require 'doom) ; be silent, byte-compiler
|
||||
|
||||
(after! dape
|
||||
(add-to-list
|
||||
'dape-configs
|
||||
`(gdb-dap-openocd
|
||||
ensure (lambda (config)
|
||||
(dape-ensure-command config)
|
||||
(let* ((default-directory
|
||||
(or (dape-config-get config 'command-cwd)
|
||||
default-directory))
|
||||
(command (dape-config-get config 'command))
|
||||
(output (shell-command-to-string (format "%s --version" command)))
|
||||
(version (save-match-data
|
||||
(when (string-match "GNU gdb \\(?:(.*) \\)?\\([0-9.]+\\)" output)
|
||||
(string-to-number (match-string 1 output))))))
|
||||
(unless (>= version 14.1)
|
||||
(user-error "Requires gdb version >= 14.1"))))
|
||||
modes ()
|
||||
command-cwd dape-command-cwd
|
||||
command "gdb"
|
||||
command-args ("--interpreter=dap")
|
||||
:request nil
|
||||
:program nil
|
||||
:args []
|
||||
:stopAtBeginningOfMainSubprogram nil))
|
||||
)
|
||||
|
||||
;;; .doomrc ends here
|
8
board/modules/Sensors_can/ch32-sensor/.idea/.gitignore
generated
vendored
Normal file
8
board/modules/Sensors_can/ch32-sensor/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
11
board/modules/Sensors_can/ch32-sensor/.idea/ch32-sensor.iml
generated
Normal file
11
board/modules/Sensors_can/ch32-sensor/.idea/ch32-sensor.iml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="EMPTY_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
1
rust_can_sensor/.idea/vcs.xml
generated
1
rust_can_sensor/.idea/vcs.xml
generated
@@ -3,5 +3,6 @@
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/../website/themes/blowfish" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@@ -4,7 +4,7 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
ch32-hal = { path = "/home/empire/workspace/ch32-hal/", features = [
|
||||
ch32-hal = { git = "https://github.com/empirephoenix/ch32-hal.git", features = [
|
||||
"ch32v203c8t6",
|
||||
"memory-x",
|
||||
"embassy",
|
||||
@@ -25,6 +25,7 @@ embassy-executor = { version = "0.7.0", features = [
|
||||
embassy-usb = { version = "0.3.0" }
|
||||
embassy-futures = { version = "0.1.0" }
|
||||
embassy-sync = { version = "0.6.0" }
|
||||
embedded-can = "0.4.1"
|
||||
|
||||
# This is okay because we should automatically use whatever ch32-hal uses
|
||||
qingke-rt = "*"
|
||||
@@ -35,13 +36,14 @@ panic-halt = "1.0"
|
||||
|
||||
heapless = { version = "0.8.0", features = ["portable-atomic-critical-section"] }
|
||||
embassy-time = { version = "0.4.0" }
|
||||
static_cell = "2.1.1"
|
||||
|
||||
[profile.dev]
|
||||
#lto = true
|
||||
opt-level = 1
|
||||
|
||||
[profile.release]
|
||||
strip = false # symbols are not flashed to the microcontroller, so don't strip them.
|
||||
strip = true # symbols are not flashed to the microcontroller, so don't strip them.
|
||||
lto = true
|
||||
debug = false
|
||||
opt-level = "z" # Optimize for size.
|
||||
|
@@ -1,9 +1,14 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
|
||||
use crate::hal::peripherals::CAN1;
|
||||
use core::fmt::Write as _;
|
||||
use ch32_hal::gpio::{Level, Output, Speed};
|
||||
use ch32_hal::adc::{Adc, SampleTime, ADC_MAX};
|
||||
use ch32_hal::can;
|
||||
use ch32_hal::can::{Can, CanFifo, CanFilter, CanFrame, CanMode};
|
||||
use ch32_hal::mode::{Blocking, Mode};
|
||||
use ch32_hal::peripherals::USBD;
|
||||
// use ch32_hal::delay::Delay;
|
||||
use embassy_executor::{Spawner, task};
|
||||
@@ -14,22 +19,24 @@ use hal::usbd::{Driver};
|
||||
use hal::{bind_interrupts};
|
||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
use embassy_sync::channel::{Channel, TrySendError};
|
||||
use embassy_time::{Timer, Instant, Duration};
|
||||
use embassy_time::{Timer, Instant, Duration, Ticker};
|
||||
use embedded_can::StandardId;
|
||||
use heapless::String;
|
||||
use {ch32_hal as hal, panic_halt as _};
|
||||
|
||||
macro_rules! mk_static {
|
||||
($t:ty,$val:expr) => {{
|
||||
static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new();
|
||||
#[deny(unused_attributes)]
|
||||
let x = STATIC_CELL.uninit().write(($val));
|
||||
x
|
||||
}};
|
||||
}
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
USB_LP_CAN1_RX0 => hal::usbd::InterruptHandler<hal::peripherals::USBD>;
|
||||
});
|
||||
|
||||
// 'static storage for USB descriptors and state so we can spawn tasks
|
||||
static mut USB_CONFIG_DESCRIPTOR: [u8; 256] = [0; 256];
|
||||
static mut USB_BOS_DESCRIPTOR: [u8; 256] = [0; 256];
|
||||
static mut USB_CONTROL_BUF: [u8; 64] = [0; 64];
|
||||
static mut CDC_STATE: core::mem::MaybeUninit<State<'static>> = core::mem::MaybeUninit::uninit();
|
||||
static mut USB_DEVICE: core::mem::MaybeUninit<UsbDevice<'static, Driver<'static, hal::peripherals::USBD>>> = core::mem::MaybeUninit::uninit();
|
||||
static mut CDC_CLASS: core::mem::MaybeUninit<CdcAcmClass<'static, Driver<'static, hal::peripherals::USBD>>> = core::mem::MaybeUninit::uninit();
|
||||
|
||||
static LOG_CH: Channel<CriticalSectionRawMutex, heapless::String<128>, 8> = Channel::new();
|
||||
|
||||
#[embassy_executor::main(entry = "qingke_rt::entry")]
|
||||
@@ -57,30 +64,25 @@ async fn main(spawner: Spawner) {
|
||||
config.device_protocol = 0x00;
|
||||
config.composite_with_iads = false;
|
||||
|
||||
let usb = unsafe {
|
||||
let mut builder = Builder::new(
|
||||
driver,
|
||||
config,
|
||||
&mut USB_CONFIG_DESCRIPTOR,
|
||||
&mut USB_BOS_DESCRIPTOR,
|
||||
&mut [], // no msos descriptors
|
||||
&mut USB_CONTROL_BUF,
|
||||
);
|
||||
let mut builder = Builder::new(
|
||||
driver,
|
||||
config,
|
||||
mk_static!([u8;256], [0; 256]),
|
||||
mk_static!([u8;256], [0; 256]),
|
||||
&mut [], // no msos descriptors
|
||||
mk_static!([u8;64], [0; 64]),
|
||||
);
|
||||
// Initialize CDC state and create CDC-ACM class
|
||||
let class = mk_static!(CdcAcmClass<'static, Driver<'static, hal::peripherals::USBD>>,
|
||||
CdcAcmClass::new(
|
||||
&mut builder,
|
||||
mk_static!(State, State::new()),
|
||||
64
|
||||
)
|
||||
);
|
||||
|
||||
// Initialize CDC state and create CDC-ACM class
|
||||
CDC_STATE.write(State::new());
|
||||
let class = {
|
||||
let state_ref: &mut State<'static> = CDC_STATE.assume_init_mut();
|
||||
CdcAcmClass::new(&mut builder, state_ref, 64)
|
||||
};
|
||||
CDC_CLASS.write(class);
|
||||
|
||||
// Build USB device
|
||||
let dev = builder.build();
|
||||
USB_DEVICE.write(dev);
|
||||
|
||||
USB_DEVICE.assume_init_mut()
|
||||
};
|
||||
// Build USB device
|
||||
let usb = mk_static!(UsbDevice<Driver<USBD>>, builder.build()) ;
|
||||
|
||||
// Create GPIO for 555 Q output (PB0)
|
||||
let q_out = Output::new(p.PB0, Level::Low, Speed::Low);
|
||||
@@ -91,15 +93,27 @@ async fn main(spawner: Spawner) {
|
||||
let adc = Adc::new(p.ADC1, Default::default());
|
||||
let ain = p.PA1;
|
||||
|
||||
let config = can::can::Config::default();
|
||||
let can: Can<'static, CAN1 , Blocking> = Can::new_blocking(p.CAN1, p.PB8, p.PB9, CanFifo::Fifo1, CanMode::Normal, 500_000, config).expect("Valid");
|
||||
let mut filter = CanFilter::new_id_list();
|
||||
|
||||
filter
|
||||
.get(0)
|
||||
.unwrap()
|
||||
.set(StandardId::new(0x580 | 0x42).unwrap().into(), Default::default());
|
||||
|
||||
can.add_filter(CanFilter::accept_all());
|
||||
|
||||
|
||||
// Spawn independent tasks using 'static references
|
||||
unsafe {
|
||||
let class = CDC_CLASS.assume_init_mut();
|
||||
spawner.spawn(usb_task(usb)).unwrap();
|
||||
spawner.spawn(usb_writer(class)).unwrap();
|
||||
// move Q output, LED, ADC and analog input into worker task
|
||||
spawner.spawn(worker(q_out, led, adc, ain)).unwrap();
|
||||
spawner.spawn(worker(q_out, led, adc, ain, can)).unwrap();
|
||||
}
|
||||
|
||||
|
||||
// Prevent main from exiting
|
||||
core::future::pending::<()>().await;
|
||||
}
|
||||
@@ -110,6 +124,7 @@ async fn worker(
|
||||
mut led: Output<'static>,
|
||||
mut adc: Adc<'static, hal::peripherals::ADC1>,
|
||||
mut ain: hal::peripherals::PA1,
|
||||
mut can: Can<'static, CAN1, Blocking>,
|
||||
) {
|
||||
// 555 emulation state: Q initially Low
|
||||
let mut q_high = false;
|
||||
|
Reference in New Issue
Block a user