Skip to content

Kesan Pembayaran Panduan Pendidikan Pembayaran Qr Membeli Terdapat Ketika

Pengguna dan peniaga dapat bersiap sedia untuk perubahan yang akan datang, dalam artikel ini, kami juga akan memberikan tips untuk memastikan transaksi anda lancar dan tanpa masalah, dalam artikel Keselamatan Dan Privasi Depan Pelanggan Menggunakan Pembayaran Bersih Tepat ini, pembangunan pembayaran qr di malaysia: apa yang anda perlu tahu.

Kami akan melihat bagaimana peniaga Tren Pembayaran Trend Untuk Pembayaran Qr Telah Dunia Memulakan dan pengguna dapat mengambil manfaat daripada tren ini untuk meningkatkan pengalaman transaksi mereka, dan keselamatan, masa depan pembayaran qr di malaysia kelihatan cerah dengan potensi pertumbuhan yang besar.

Kelebihan Pembayaran Qr Digital Sektor Tunai Transformasi Digital Memberikan Peralihan

Dengan hanya mengimbas kod qr, Mengapa Pembayaran Kewangan Kesedaran Pengalaman Pendidikan Pengguna Analitik Peralihan Lancar terdapat pelbagai dompet digital yang menyokong pembayaran qr di malaysia, pilihan dompet digital yang tepat dapat meningkatkan pengalaman pembayaran anda.

Pembayaran qr bukan sahaja memudahkan transaksi, Mengapa Pengguna Malaysia Solusi Terbaru Sektor Menggunakan Pembayaran Qr Ramalan Wang Menunjukkan dalam artikel ini, termasuk peningkatan penggunaan telefon pintar dan aplikasi dompet digital, selain itu.

Mengapa Pembayaran Qr Transformasi Apa Masa Depan Bertanggungjawab Dapat Mudah

Keselamatan dan privasi dalam pembayaran qr malaysia, pembayaran qr Cara Menggunakan Pembayaran Masa Mengatasi Terkini Inovasi Dalam Meneroka Sedia Cerah mempunyai kesan yang signifikan terhadap ekonomi malaysia dengan mempromosikan transaksi tanpa tunai, dan pengurangan risiko kehilangan tunai, kami akan membincangkan mengapa ramai orang beralih kepada pembayaran qr dan bagaimana ia mengubah cara kita bertransaksi.

Kami akan membincangkan bagaimana pembayaran qr dapat membantu perniagaan kecil dan sederhana untuk berkembang, serta potensi pertumbuhan dalam sektor e-dagang, Inovasi Terkini Dalam Pelanggan Menggunakan Adalah Pembayaran Qr Menawarkan Membantu Sederhana Kunci pengguna dapat membuat keputusan yang lebih baik mengenai penggunaan sistem pembayaran ini, serta cara ia mempengaruhi cara orang ramai bertransaksi.

Mengatasi cabaran pembayaran qr di malaysia, pengguna harus mengambil langkah-langkah untuk melindungi maklumat peribadi mereka, kami akan membincangkan peranan teknologi dalam mempercepatkan proses pembayaran dan meningkatkan pengalaman pengguna. Mengapa Pembayaran Dalam Sektor Pembayaran Qr Telah Bagi Terus

Pembayaran Qr Apa Malaysia Perbandingan Terdapat Pelbagai Keputusan Membeli

Pembayaran qr harus diiringi dengan pemahaman yang mendalam, dan aksesibiliti, mengapa pembayaran qr adalah trend terbaru di malaysia, pengguna boleh Peranan Pembayaran Ekonomi Tentang Pembayaran Qr Mengelakkan Bukan membuat pembayaran dengan cepat hanya menggunakan kod qr, termasuk kemudahan penggunaan, masa depan pembayaran qr di malaysia: apa yang akan datang.

Merged
andelf merged 49 commits into
mainfrom
gpio-port-irq
Nov 8, 2026
Merged

andelf merged 49 commits into
mainfrom
gpio-port-irq

Conversation

@andelf

@andelfandelf commented Nov 5, 2026•

Copy link
Copy Markdown
Contributor

Summary

  • Add CH585 GPIO port-interrupt waits, including embedded-hal-asyncWait, level/single-edge triggers, and GPIO_A / GPIO_B dispatch. PB22/PB23 select their aliased flag bits through PIN_INTX; PB16–PB21 have no interrupt source.
  • Add blocking I2C0 and SPI0/SPI1 masters, single-conversion ADC, PWM4–PWM11 output, RTC calendar/alarm/interval support, and the window watchdog/reset/battery monitor drivers.
  • Add interrupt-driven I2C0 and SPI0/SPI1 masters, SPI0's half-duplex local DMA engine, and a PWM LED ramp example.
  • Add multi-channel ADC scans stored by the ADC-local DMA engine into static 16-bit sample buffers, with polled completion.
  • Refuse UART baud requests whose divider error exceeds two percent, and move the internal loopback example to a baud the reset clock can generate accurately.
  • Add Embassy USBFS and USBHS device drivers implementing embassy-usb-driver, with CDC ACM echo/PING/PATTERN examples for both controllers.
  • Gate chip-specific drivers through the metadata selected by build.rs; retain multi-chip GPIO compilation where the register layout is compatible.

ADC scan and local DMA

Scan takes an ordered tuple of one to fourteen pins and programs CHANNEL / SCAN_CFG1 / SCAN_CFG2 once; each read fills an exclusive static buffer with whole passes through the block's local DMA engine. The DMA address registers are halfword offsets, so a sample index maps directly onto a sequence position.

SCAN_AUTO_TYPE does not repeat passes: one pass ends after the last channel, so the wait loop clears IF_SCAN_END and rewrites CONVERT.START for each subsequent pass. Completion is polled. The ADC interrupt line is also asserted by end-of-conversion, the documented IE_* bits do not mask that source, and the vendor EOC clear (writing CONVERT) restarts the sequence; an interrupt-driven wait left the task starved in the handler. The line is shared with TouchKey, so a touch-key driver must account for the always-asserted EOC source.

adc_scan_dma scans PA4, PA5 and PA6 in that order, ten passes per transfer, and logs one transfer every 500 ms.

USB device support

ControllerConnector and pinsEndpoint supportBoard validation
USBFSP1 FS-USB, PB11 D+ / PB10 D-EP0–EP4, full-speed packets up to 64 bytesEnumerated at 12 Mb/s as 1a86:55f0; control and bulk IN/OUT transfers through 64 KiB passed
USBHSP4 HS-USB, PB13 D+ / PB12 D-EP0–EP7, independent directional DMA buffers, 512-byte high-speed bulk packetsEnumerated at 480 Mb/s as 1a86:55f1; control and bulk IN/OUT transfers through 64 KiB passed

Both CDC examples preserve ordinary packet payloads and provide exact-packet PING and PATTERN <n> test commands. Binary echo and PATTERN cover packet boundaries, sustained transfers through 64 KiB, and serial close/reopen.

The USBFS startup path emits the initial Embassy PowerDetected event required for Bus::enable. USBHS uses owned, aligned SRAM endpoint buffers and clamps Embassy CDC's notification interval of 255 to the high-speed descriptor limit of 16.

USBFS EP4 and suspend/resume remain untested. USBHS dynamic full-speed fallback is not implemented; isochronous transfers, suspend/resume, remote wakeup, and host mode remain open. The validation script is functional coverage, not a throughput benchmark.

Compatibility and dependencies

  • GPIO interrupt support compiles for CH572, CH573, CH581, CH582, CH583, CH584, CH585, CH592, and CH595, with register/port differences handled by build.rs. CH564 and CH569 use different GPIO blocks and remain excluded.
  • The new I2C, SPI, ADC, PWM, RTC, watchdog, USBFS, and USBHS layouts are selected only where their expected CH585-family register version is available. CH585 is the only chip exercised on hardware.
  • The PAC is consumed from the public ch32-rs/ch5xx-metapac repository, pinned at tag v0.1.2 / rev 579d934. That snapshot is generated from ch5xx-data branch pins-and-interrupts (fb3aca8, USBHS endpoint registers and CH585 pin muxing) plus the ADC scan registers and writable AUTO_CYCLE merged in feat(adc): model the CH585 scan sequence registers ch5xx-data#6. Register definitions and regeneration stay in ch5xx-data.

Validation

From examples/ch585:

cargo fmt --checkcargo clippy --release --bins --no-default-features --features time-driver-tmr0 -- -D warningscargo build --release --bins --no-default-features --features time-driver-tmr0

The regenerated CH585 metapac also passes cargo check for riscv32imc-unknown-none-elf with ch585,pac,metadata. Only the existing +xwchc toolchain warnings remain.

Board checks recorded for this branch include I2C scan/OLED output, SPI0 loopback, ADC temperature reads, the ADC scan DMA transfer, a real watchdog overflow reset with the following feed checks, RTC OLED seconds, USBFS full-speed CDC, and USBHS high-speed CDC. The ADC scan run used floating inputs: ten passes of three channels filled the buffer on repeated transfers. The grounded / 3.3 V scan check, GPIO port interrupts and several other examples still have their individual board checks outstanding; support is not claimed solely from a generated PAC singleton.

CH585 has one interrupt line and a 16-bit flag register per port, not a per-pin EXTI. Input waits for one level or one edge, and init claims GPIO_A and GPIO_B. PB22/PB23 reuse flag bits 9:8 through PIN_INTX; PB16-PB21 have no source.
CH572 has no port B. CH573, CH582 and CH583 have no Px_SET, so a high output goes through Px_OUT. PB22 and PB23 are armed only where PIN_INTX exists, and the port handler reads each interrupt register once.
PB16 and PB17 swap while PB22 is held, so a press is visible without RTT.
I2C0 runs at Fsys with the vendor clock formula, up to 400 kHz, on PB13/PB12 or the remapped PB21/PB20 pair. Transfers poll STAR1 with a one millisecond timeout and follow the STM32-style NACK and STOP sequence. Async transfers and bus recovery are not included.
i2c_scan probes PB13/PB12 at 100 kHz and logs every address that answers. i2c_oled drives the SSD1306 found at 0x3C at 400 kHz, drawing a banner, a bouncing circle and two text lines through embedded-graphics.
SPI0 and SPI1 run at Fsys with a whole-number divisor, in mode 0 or mode 3. A full-duplex transfer writes FIFO and reads the shifted-in byte from BUFFER; FIFO_DIR is a receive buffer and drops the byte just sent. The module compiles only for the CH585 FIFO layout. Async transfers, DMA and slave mode are not included.
spi_loopback joins PA14 to PA15 and checks a 10-byte mode 0 transfer, then a 40-byte mode 3 transfer, against what was sent. PA12 is driven as a chip select.
The converter polls one channel at a time on the CH585 register layout, with the internal temperature sensor and the divided battery channel. An external pin has its digital input disconnected first. Scan, DMA and touch-key modes are not included.
adc_temp reads the internal sensor and logs the temperature from the info-flash calibration. adc_pin reads channel 0 on PA4 and adds the offset measured with the input shorted.
One block clocks every channel from Fsys through a shared divisor and cycle. Each channel keeps its own duty byte and polarity, and the shared remap moves five of the eight pins together. 16-bit cycles and stagger output are not included.
pwm_out drives PA12 at about 400 Hz and steps the duty through 0, 64, 128, 192 and 255, holding each one for a second.
DIV stays 1, and the nearest DL is now rejected when the realised rate is more than two percent from the request. 115200 at the 5.333 MHz reset clock is about 111.1 kbaud, so uart_loopback moves to 9600, which divides exactly.
@andelfandelf changed the title Add GPIO port-interrupt waitsAdd CH585 peripheral drivers and USB device supportNov 6, 2026
The timer-local DMA engine counts 32-bit FIFO words, while SPI0 moves bytes. Descriptor::bytes and a byte-addressable static buffer cover the second case; Descriptor::new/words and StaticBuffer keep the timer API unchanged. No channel abstraction is added: each CH5xx DMA engine is peripheral-local and the drivers own theirs.
I2C0 has no DMA registers, so the async path moves each byte from the I2C0 interrupt with the STM32F1-style event sequence: SB, ADDR, TxE, RxNE and BTF. The receive tail masks the level-triggered buffer source, a dropped future aborts with a STOP, and the driver implements embedded-hal-async I2c next to the blocking master. The CH585 controller latches STAR2.BUSY after about 100 ms without traffic even though both lines are idle, and it then ignores START. A fresh frame resets and reprograms the block and sends one address-only start/stop pair to resynchronise the slave before the real transfer. The blocking path uses the same recovery.
SPI0/SPI1 gain an async master whose handler moves bytes on the FIFO half-full, byte-end and count-end events. SPI0 also exposes its peripheral-local half-duplex DMA engine through write_dma/read_dma: checked static byte buffers, chunk re-arming past the 12-bit count, CNT_END completion with DMA_END tracking, and cancellation that quiesces the engine. Full-duplex transfers stay on the interrupt path because the engine queues one direction at a time. SPI1 has no DMA block and shares PWMX_SPI1 with PWMx.
i2c_oled_async drives the SSD1306 with the interrupt-driven master and a 1025-byte frame write that starts with the 0x40 data control byte. spi_async_loopback covers full-duplex async loopback plus SPI0 DMA receive and transmit. pwm_out now breathes an external LED on PA12 and documents that the board LEDs have no PWM function.
Add the async OLED and SPI loopback examples to the tables and their wiring steps, note the half-duplex nature of the SPI0 DMA engine and that I2C0 has no DMA block, and point PWM verification at an external LED because the board LEDs are GPIO-only.
StaticSampleBuffer is the exclusive static storage the ADC's local DMA engine writes one sample per conversion into. It reuses the existing claim-once implementation, which already covers the timer's words and SPI's bytes.
Scan takes an ordered tuple of one to fourteen pins, programs the CHANNEL/SCAN_CFG1/SCAN_CFG2 sequence and fills a static sample buffer with whole passes through the block's local DMA engine. Completion is polled: the ADC interrupt line is also asserted by end-of-conversion, the documented IE bits do not mask it, and the vendor EOC clear restarts the sequence. SCAN_AUTO_TYPE does not repeat passes, so the wait loop clears IF_SCAN_END and re-triggers CONVERT.START for each pass. The buffer must be a non-zero multiple of the sequence length; a one-pass transfer also accepts the scan-end flag. Dropping the scan or transfer stops the engine, clears the flags, powers the converter down and reconnects the pads' digital inputs.
adc_scan_dma samples PA4, PA5 and PA6 in that order, ten passes per transfer, and logs one transfer every 500 ms. PA4 and PA5 can be tied to ground and 3.3 V to check the two ends of the range; PA6 floats.
Record the scan driver, its static 16-bit sample buffers, the polled completion and the end-of-conversion interrupt limitation in the top-level and example READMEs.
The nightly rustfmt wraps the USBHS validity check and interrupt-enable write differently, and sorts the OLED font imports by name. No behavior change.
SCAN_CFG1 and SCAN_CFG2 are modeled as 4-bit entry arrays, so the sequence is programmed with two small loops instead of thirteen individually named fields, and MAX_CHANNELS derives from the entry counts. The value written is unchanged.
The generated PAC now lives in the public ch32-rs/ch5xx-metapac repository, pinned at v0.1.2 (579d934), so the HAL no longer depends on a sibling ch5xx-data build directory. The snapshot includes the USBHS endpoint fixes, the CH585 pin muxing and the ADC scan registers. Regeneration still happens in ch5xx-data.
The v3c core feature, critical-section support and the atomics opt-out are all in the 0.8.4 release, which is the same tree as the local checkout's v0.8.4 tag, so the crates.io patch is no longer needed and the requirement can name the release directly.
The example now arms overflow reset on the first boot and stops feeding, so the next boot observes a watchdog reset cause before disabling reset and checking the feed path. A board run confirmed both: the chip rebooted after about 6.3 s with `reset cause watchdog`, and a feed cleared the overflow flag, which set again after four seconds. The module documentation's maximum interval was ten times too short; a reload of zero wraps in about 6.3 s at the 5.333 MHz reset clock, not 0.63 s.
Pin ch5xx-metapac to b4e0777, generated after the register access audit in ch5xx-data#8.
The example spawned the same button task twice. The embassy task macro defaults to pool_size = 1, so the second spawn returned Busy, the unwrap panicked, and panic_halt made the program look stuck after its first log. Give the task pool two slots. Add gpio_async_loopback, which drives PA14 into PA15 and counts the edges the async wait observes, so the port-interrupt path can be checked without pressing a button.
IF_CNT_END reads as set for as long as TOTAL_CNT is zero, so enabling IE_CNT_END at construction stormed the interrupt line at priority 0 and starved the caller of Spi::new_async before its first await. A board run with the source armed at construction hung; disabling it made the constructor and both full-duplex transfers complete. Enable only IE_FIFO_OV at construction. The async waits and the DMA arm path now enable IE_CNT_END and IE_DMA_END after a non-zero TOTAL_CNT is programmed, re-check the raw flag to close the arming race, and the handler disables each source after it fires so a completed chunk cannot keep re-asserting. The DMA arm path also programs TOTAL_CNT before the sources are enabled, which is the vendor order.
With PA14 looped to PA15 at 1 MHz, async mode 0 matched 10 bytes and mode 3 matched 40. The DMA receive filled 5000 bytes over two chunks and the DMA transmit completed 5000 bytes, so the chunked re-arm past the 12-bit TOTAL_CNT limit runs in both directions. Master receive mode does not clock 0xFF on MOSI, so the receive check is now that the engine overwrote the whole buffer with one repeated value: the loopback returned 0xE3-0xE4 at every mode and rate. The receive path itself was verified on an unwired remapped MISO pad, whose pull-up reads 0xFF. The README no longer claims 0xFF. Keep the constructor error log and drop the diagnostic progress lines.
The SYS block drives the PMU directly: SLP_WAKE_CTRL selects the wake events, SLP_POWER_CTRL the wake delay, and POWER_PLAN turns the main LDO off and keeps only the domains the caller retains. `halt` stops the core clock; `sleep` also arms the plan. The driver leaves CLK_CFG and the FlashROM controller alone instead of copying WCH's 4 MHz high-code sequence: the PMU restarts the configured oscillators and applies its wake delay before the core resumes, so the program continues from FlashROM at the configured rate. Two hardware details are handled explicitly. `wfi` executes as `wfe` on this core and a wake leaves the event register set, so each entry drains it with SETEVENT before arming the plan; without that every other sleep returned immediately. The PMU's local wake reset clears the SysTick block, which would turn every blocking delay into an endless spin, so `sleep` saves and restores it. The register set the driver needs is not the same on every selectable die, so build.rs emits a cfg and the module only compiles where it exists.
The example sleeps three times with halt and three times with sleep, one RTC second each, and measures the 32 kHz interval on both sides of every call. It runs at HSE PLL 78 MHz, so a wake that failed to restart the crystal or the PLL shows up in a delay measured against the RTC, and it prints one PASS/FAIL line. The probe cannot follow the core into a low-power mode, so the example README documents the `wlink flash -e` plus `probe-rs attach` flow, and notes that a sleep run can leave the debug interface down until the chip is powered on with the Download button held.
Picks up the address-only FLASHROM peripheral from ch5xx-data 9f4dfd4 (published as 69decba). Nothing uses it yet: the flash driver is parked on a separate branch pending bring-up.
UEP567_MOD enables endpoints 5 to 7, each with its own DMA register and packet buffer; endpoint 4 keeps its fixed buffers next to endpoint 0's. Two hardware behaviors needed explicit handling. INT_ST does not describe a SETUP: its endpoint and token fields keep the previous transaction (or their reset values 0xF and 0b11), so gating SETUP on ENDP == 0 silently ignored every control transfer and the host reset the bus forever. The handler now treats UIS_SETUP_ACT as endpoint 0. Endpoint 4 also ignores AUTO_TOG (the bit reads back zero), so its data toggles are advanced in the handler instead. Received packets are gated on U_TOG_OK, so a host retransmission cannot be mistaken for new data; a mismatched packet is discarded and re-ACKed. A FIFO overflow clears its flag, and endpoint_set_enabled rewrites the DMA address and UEPn_MOD bits so a bus reset cannot leave an endpoint half-configured.
USB 2.0 permits 8, 16, 32, 64 or 512 bytes for a high-speed bulk endpoint. Rejecting everything but 512 made any embassy class that asks for less panic inside alloc_endpoint_out. A 64-byte high-speed endpoint transfer was verified on the board, so the check now accepts the full set. The 0x10 toggle-match mask in the endpoint control register gets a name and the discard path a comment.
usb_endpoints (1a86:55f2) and usbhs_endpoints (1a86:55f3) are vendor-class devices with three bulk echo pairs (EP2/EP1, EP4/EP3, EP6/EP5) and a tagged pattern source on EP7 IN, so every endpoint index is exercised on the full-speed and high-speed blocks. A libusb host script drives them directly because no class driver claims the interface. Three instances of the echo task run at once, which needs pool_size = 3: the default pool of one fails the second spawn, and the resulting panic keeps the executor from ever starting.
@andelf
andelf marked this pull request as ready for review November 8, 2026 02:17
The root README now carries the project overview, a driver-status table, quick start, required configuration and the license, and the examples README keeps the run instructions and a one-line-per-binary table. Per-example wiring and behavior notes moved to the local docs tree. The status table also corrects the stale USBFS endpoint range: the driver serves endpoints 0 to 7, not 0 to 4.
The examples depended on a sibling embassy checkout through paths, which only builds on a machine that has that checkout. Depend on the crates.io versions and patch them to a fixed embassy revision instead, so the dependency graph is reproducible anywhere. The revision is still needed because 0.10.0/0.6.0 predate two APIs this part uses: the executor's portable-atomic feature and UsbDeviceSpeed / Config::max_speed in embassy-usb. All patched crates resolve to the same revision so the driver trait, timer queue layout and time-driver link stay unique.
@andelf
andelf merged commit 7c2f0bd into mainNov 8, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@andelf