Wykres commitów

39 Commity (c972c60dbe72d7448faff7f631dfb798b694093e)

Autor SHA1 Wiadomość Data
Damien George c972c60dbe stmhal: Clean up USB CDC/MSC files and remove commented-out code. 2017-07-19 13:01:22 +10:00
Sylvain Pelissier 3bb69f645a stmhal/usb: Use local USB handler variable in Start-of-Frame handler. 2017-06-07 16:03:19 +10:00
Sylvain Pelissier 6adcf7bb82 stmhal: Pass USB handler as parameter to allow more than one USB handler 2017-06-07 15:50:26 +10:00
Damien George 3b447ede78 stmhal/usbd_cdc_interface: Change CDC RX to use a circular buffer.
This should be a little more efficient (since we anyway scan the input
packet for the interrupt char), and it should also fix any non-atomic read
issues with the buffer state being changed during an interrupt.

Throughput tests show that RX rate is unchanged by this patch.
2017-04-04 16:23:25 +10:00
Damien George 9a8e7f7a8e stmhal/usbd_cdc_interface: Increase in-endpoint timeout to 500ms.
The previous timeout value of 150ms could lead to data being lost (ie never
received by the host) in some rare cases, eg when the host is under load.
A value of 500ms is quite conservative and allows the host plenty of time
to read our data.
2017-04-04 15:18:58 +10:00
Damien George e5cc681cb1 stmhal: Use generic interrupt char code. 2017-02-15 16:39:30 +11:00
Damien George a770ba147e stmhal: Use core-provided keyboard exception object. 2016-12-15 15:51:34 +11:00
Damien George 979ab4e126 stmhal/usb: Always use the mp_kbd_exception object for VCP interrupt.
There's no need to store a separate pointer to this object.
2016-12-15 12:45:56 +11:00
Damien George ea89b80ff4 stmhal: Make TIM3 available for use by the user.
TIM3 is no longer used by USB CDC for triggering outgoing data, so we
can now make it available to the user.

PWM fading on LED(4) is now gone, but will be reinstated in a new way.
2016-01-29 22:31:56 +00:00
Damien George d363133917 stmhal: Make USB CDC driver use SOF instead of TIM3 for outgoing data.
Previous to this patch the USB CDC driver used TIM3 to trigger the
sending of outgoing data over USB serial.  This patch changes the
behaviour so that the USB SOF interrupt is used to trigger the processing
of the sending.  This reduces latency and increases bandwidth of outgoing
data.

Thanks to Martin Fischer, aka @hoihu, for the idea and initial prototype.

See PR #1713.
2016-01-29 15:21:43 +00:00
Paul Sokolovsky 4a9c60cdfb stmhal: Typo fix in comment. 2015-10-24 21:58:58 +03:00
Damien George 0aa5e75000 stmhal: Break immediately from USB CDC busy wait loop if IRQs disabled.
If IRQs are disabled then the USB CDC buffer will never be
drained/filled and the sys-tick timer will never increase, so we should
not busy wait in this case.
2015-06-07 23:48:07 +01:00
Damien George 7674da8057 stmhal: Remove some unnecessary declarations, purely for cleanup. 2015-03-20 22:27:34 +00:00
Damien George d39c7aa517 stmhal: Add Python-configurable USB HID mode.
Different HID modes can be configured in Python.  You can either use
predefined mouse or keyboard, or write your own report descriptor.
2015-02-13 14:02:51 +00:00
Damien George 19fb1b4dd7 stmhal: Add USB_VCP.setinterrupt method, to disable CTRL-C. 2014-11-29 15:23:21 +00:00
Damien George 5cbc9e0db0 stmhal: Reduce coupling between USB driver and readline.
This makes it easier to re-use readline.c and pyexec.c from stmhal in
other ports.
2014-11-27 16:58:31 +00:00
Damien George 9a41b32b3f stmhal: Add ioctl to USB_VCP object, so it works with select.
This patch also enables non-blocking streams on stmhal port.

One can now make a USB-UART pass-through function:

def pass_through(usb, uart):
    while True:
        select.select([usb, uart], [], [])
        if usb.any():
            uart.write(usb.read(256))
        if uart.any():
            usb.write(uart.read(256))

pass_through(pyb.USB_VCP(), pyb.UART(1, 9600))
2014-10-31 00:12:02 +00:00
Damien George bc1488a05f stmhal: Improve REPL control codes; improve pyboard.py script.
Improvements are:

2 ctrl-C's are now needed to truly kill running script on pyboard, so
make CDC interface allow multiple ctrl-C's through at once (ie sending
b'\x03\x03' to pyboard now counts as 2 ctrl-C's).

ctrl-C in friendly-repl can now stop multi-line input.

In raw-repl mode, use ctrl-D to indicate end of running script, and also
end of any error message.  Thus, output of raw-repl is always at least 2
ctrl-D's and it's much easier to parse.

pyboard.py is now a bit faster, handles exceptions from pyboard better
(prints them and exits with exit code 1), prints out the pyboard output
while the script is running (instead of waiting till the end), and
allows to follow the output of a previous script when run with no
arguments.
2014-10-26 15:39:22 +00:00
Damien George 124df6f8d0 py: Add mp_pending_exception global variable, for VM soft interrupt.
This allows to implement KeyboardInterrupt on unix, and a much safer
ctrl-C in stmhal port.  First ctrl-C is a soft one, with hope that VM
will notice it; second ctrl-C is a hard one that kills anything (for
both unix and stmhal).

One needs to check for a pending exception in the VM only for jump
opcodes.  Others can't produce an infinite loop (infinite recursion is
caught by stack check).
2014-10-25 23:37:57 +01:00
Damien George 3c4db9f91c stmhal: Add USB_VCP class/object, for direct USB VCP control.
Before, pyb.stdin/pyb.stdout allowed some kind of access to the USB VCP
device, but it was basic access.

This patch adds a proper USB_VCP class and object with much more control
over the USB VCP device.  Create an object with pyb.USB_VCP(), then use
this object as if it were a UART object.  It has send, recv, read,
write, and other methods.  send and recv allow a timeout to be specified.

Addresses issue 774.
2014-07-31 10:30:42 +01:00
Damien George 09bbe7215a stmhal: Fix USB CDC not flushing packets when an exact multiple of 64.
Need to send a zero-sized packet after sending an exact multiple of 64
bytes (not just after sending 64 bytes exactly).

Addresses issue #494, part 2.
2014-05-10 18:56:16 +01:00
Damien George 04b9147e15 Add license header to (almost) all files.
Blanket wide to all .c and .h files.  Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.

Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-05-03 23:27:38 +01:00
Damien George efc22e376f stmhal: Fix 64-byte USB packet bug properly.
A 64-byte packet is now followed by a 0-byte packet if there is nothing
more to send.  This flushes the USB endpoint.
2014-04-17 00:12:07 +01:00
Damien George 28817725fc stmhal: Replace magic number 3 with CDC_IN_EP define. 2014-04-16 23:17:29 +01:00
Damien George 9388a90842 stmhal: Fix USB CDC buffer overrun error.
Need to wait for the low-level USB driver to send the data over the USB
in-endpoint before the buffer can be used again.  This patch adds a
check for this.
2014-04-16 15:51:27 +01:00
Damien George cce7119a2b stmhal: Work around crazy bug in USB CDC.
Packets of 64 bytes length are not send to the host until the following
packet is sent.  Fixed by never sending packets of 64 bytes length.
2014-04-14 01:46:25 +01:00
Damien George 212f89e61a stmhal: Improve USB CDC write function (increase timeout). 2014-04-13 16:39:04 +01:00
Damien George 038df43183 stmhal: Implement selector for USB device mode; improve boot up.
Can now choose at boot up whether the USB device is CDC+MSC or CDC+HID.
Choice is made by an option in boot.py, with default being CDC+MSC.
HID+MSC is not currently supported, but should be easy to implement.

Boot up now has ability to change the reset mode: hold down USR switch
while booting and LEDs will count from 1 to 7 to indicate the boot mode.
Release USR when correct mode is selected.  Current modes are 1 (normal
boot), 2 (safe mode), 3 (reset FS mode).
2014-03-30 00:00:15 +00:00
Damien George 2f8beb8d88 stmhal: Fix bug with USB CDC transmit buffer wrap around. 2014-03-24 12:23:03 +00:00
Damien George f357a19202 stmhal: Fix issues with USB CDC init and receive.
Late USB enumeration could clear settings after they had been set.
Now fixed by not clearing some settings on init.

RX was blocking if received characters were not being processed, so
CTRL-C would not be picked up.  Now "fixed" by not blocking, but
instead discarding incoming characters if they overflow the buffer.
2014-03-23 18:54:48 +00:00
Damien George 908a670dfc stmhal: Add intensity method for blue LED.
As part of this, rejig the way TIM3 is initialised, since it's now
shared by USB CDC and the blue LED PWM.
2014-03-22 23:54:13 +00:00
Damien George 0119fc7532 stmhal: Servo driver can move at a given speed. 2014-03-22 18:34:16 +00:00
Damien George 2fb37847a7 stmhal: Tidy up USB CDC+MSC device some more. 2014-03-22 13:21:58 +00:00
Damien George a6787edcea stmhal: Tidy up USB device configuration. Make it use less RAM. 2014-03-22 12:46:23 +00:00
Damien George 02a8543841 stmhal: Check CDC tx buffer has free space before filling with data. 2014-03-15 16:54:23 +00:00
Damien George 6c2455f481 stmhal: Put an array in ROM. 2014-03-15 14:46:35 +00:00
Damien George 07174c6fca stmhal: Fix escape sequences in USB CDC input. 2014-03-15 12:53:51 +00:00
Damien George e285511a23 stmhal: Get USB CDC REPL working.
New USB HAL is quite a bit improved over previous one.  Now has better
callbacks and flow control.

REPL over USB CDC now works as before, except for soft-reset (since USB
driver uses malloc...).
2014-03-15 11:52:29 +00:00
Damien George b30c02afa0 stmhal: Get USB enumerating a CDC device.
Enumerates CDC device over USB, but doesn't transmit/receive yet.
2014-03-14 00:30:37 +00:00