User Tools

Site Tools


en:pfw:usb_cdc_driver_for_rp2040

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:pfw:usb_cdc_driver_for_rp2040 [2025-12-27 15:12] – [Pseudo code] willemen:pfw:usb_cdc_driver_for_rp2040 [2026-01-13 18:16] (current) – [The idea] willem
Line 101: Line 101:
  
 Function: XTABLE Function: XTABLE
 +    Define an execution table entry for '+n' request actions
     Define:  ( +n "name" -- )     Define:  ( +n "name" -- )
-        Create an execution "name" table with '+n' actions+        Create a table with "name" for '+n' actions
     Action:  ( request -- )     Action:  ( request -- )
         Execute the action for 'request' or generate a stall         Execute the action for 'request' or generate a stall
Line 111: Line 112:
 to signal the handling of a request that sends no data back to signal the handling of a request that sends no data back
  
-Function: HANDLE-SETUP ( request -- )+Define four action in front that leave their execution tokens on the stack 
 +0302 action xt 
 +0300 action xt 
 +0200 action xt 
 +0100 action xt 
 +Function: HANDLE-SETUP ( req0 .. req3 4 -- )
  
-Function: HANDLE-REQ) request -- )+2221 action xt 
 +21A1 action xt 
 +2021 action xt 
 +0900 action xt 
 +0880 action xt 
 +0680 action xt 
 +0500 action xt 
 +Function: HANDLE-REQ) req0 .. req6 7 -- )
  
-...+Function: HANDLE-REQ   ( -- ) 
 +Reset setup request interrupt, read bmrequest type and do HANDLE-REQ) 
 + 
 +Function: #L           ( -- +n ) 
 +Ring buffer size, must be a power of two 
 +Function: #R           ( -- +n ) 
 +this is equal to #L - 1 
 + 
 +Function: #RX          ( -- +n ) 
 +Leave number of characters in receive buffer 
 +Function: #TX          ( -- +n ) 
 +Leave number of characters in transmit buffer 
 + 
 +Function: >RX          ( c -- ) 
 +Store character 'c' in RX ring buffer 
 +Function: >TX          ( c -- ) 
 +Store character 'c' in TX ring buffer 
 + 
 +Function: RX>          ( -- c ) 
 +Read character 'c' from RX ring buffer 
 +Function: TX>          ( -- c ) 
 +Read character 'c' from TX ring buffer 
 + 
 +Function: IFLAG    
 +Reserve one cell space for receive interrupt flag 
 + 
 +Function: ENDPOINTS    ( -- ) 
 +Handle EP1 & EP3 endpoints, save received data interrupt flag in IFLAG 
 +Release all interrupt flags 
 + 
 +Function: REQUESTS     ( -- ) 
 +Handle all USB interrupts, that are the USB bus reset, setup requests & endpoints 
 + 
 +Function: USB-HANDLER  ( -- ) 
 +Handle the receiving of the RX data using iFLAG and use the low level USB 
 +ACK/NAK handshake to move data from an endpoint to the RX ring buffer in a controlled way. 
 +Handle the transmitting of TX data, but only when a connection is madeBefore filling 
 +the TX endpoint check if the previous data packet was sent too. 
 + 
 +Function: USB-KEY?     ( -- flag ) 
 +Leave true flag when there is data in the RX ring buffer, otherwise false 
 +Call the USB-HANDLER once too 
 + 
 +Function: USB-KEY      ( -- c ) 
 +Leave character 'c' when there is data in the RX ring buffer 
 +Call the USB-HANDLER waiting for space in the RX ring buffer 
 + 
 +Function: USB-EMIT     ( c -- ) 
 +Store character 'c' when there is space in the TX ring buffer 
 +Call the USB-HANDLER waiting for space in the TX ring buffer 
 + 
 +Function: USB-ON 
 +Initialise the USB DPRAM, call START-USB, clear USB-STATE & IFLAG 
 +finally initialse the KEY?, KEY and EMIT vectors of the used system.
  
 </code> </code>
  
-===== Implementation example =====+===== Generic Forth implementation example =====
  
 <code forth> <code forth>
Line 356: Line 422:
 </code> </code>
  
 +===== Implementations =====
 +
 +[[https://github.com/WillemOuwerkerk/noForth-T-hardware-examples-RP2040/tree/main/USB-CDC|Different noForth implementations for the USB-CDC driver]]
en/pfw/usb_cdc_driver_for_rp2040.1766844750.txt.gz · Last modified: 2025-12-27 15:12 by willem