1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00
Commit Graph

227 Commits

Author SHA1 Message Date
Alessio Morale
ccc24d844a OP-901 updated STM32 USB OTG Driver 2013-05-11 23:10:47 +02:00
lilvinz
1016b08b70 f4 usb: removed DCD_EP_Flush on endpoint TX
This has probably caused the problem that prevented tx after
a bus reconnection.
2013-05-11 22:41:05 +02:00
Stacey Sheldon
0d8fe83dca usb cdc: advertise support for line coding and serial state
The CDC descriptor was not advertising support the the line
coding and serial state messages.  This was preventing Mac
from sending the SetControlLineState message to indicate
that a DTE (ie terminal program) was present and reading
from the serial port.

We support (and depend on) the DTE indication now so this
was making CDC not work on Mac.

Linux seems to provide the indication regardless of whether
it is advertised in the descriptor or not.
2013-05-11 22:41:03 +02:00
Stacey Sheldon
0e0571149b f4 usb: ensure that we NAK on unused OUT endpoints
The ST USB code will automatically receive on any
endpoint that is opened but not in the NAK state.
Make sure we set OUT endpoints to NAK initially.

It also happily writes via a NULL pointer in ep->xfer_buff
which writes to address 0x0000_0000.  Since address
0x0 is aliased onto the internal flash by the BOOT0/1 pins
and the internal flash is (normally) in the LOCKED state,
this write puts the internal flash into an errored state.

This errored state means that writes to internal flash
are no longer allowed and all further writes fail.
2013-05-11 22:41:03 +02:00
Stacey Sheldon
2165a5afe1 f4 usb hid: handle SET_IDLE request
The code doesn't do anything useful with the SET_IDLE
but this helps to keep the wireshark USB traces clean
so that the real errors stand out better.
2013-05-11 22:41:02 +02:00
Stacey Sheldon
c22daec1b0 usb cdc: avoid need for ZLP by using tx buffers smaller than max
USB CDC uses BULK endpoints to send/receive data.  Typically,
a USB host will enqueue large buffers on its IN (device-to-host)
URBs.  These buffers are larger than the max packet size for the
bulk endpoint.

The USB standard requires that an IN transfer ends when one of
these is true:
 * a short packet (ie. less than max packet size) is sent by the
   device
 * a zero length packet (ZLP)
 * enough packets that the entire host buffer is filled

Our device implementation never sends ZLPs.  We sometimes send
packets that are exactly max-packet-size bytes long.  This would
result in partially filling a host buffer without signalling (via
ZLP) that the transmission had finished.  The host would then wait
until the next transfer had taken place before processing the first
data, thus delaying the first data.

This change simply forces all of our transfers to be short packets
and avoids the need to worry about zero length packets.  This is
at the cost of some efficiency on the host side since its large
buffers will only ever be partially filled.

Conflicts:
	flight/PiOS/STM32F30x/pios_usb_cdc.c
2013-05-11 22:41:01 +02:00
Stacey Sheldon
366c573bab f4 usb hid: send correct report ID in dummy report
The desired report ID is in the LSB of the wValue field,
not the MSB.  This will now send the correct report ID
back to the host.
2013-05-11 22:41:01 +02:00
Stacey Sheldon
232f9b2f8f f4 usb hid: use static data for dummy report Tx
This code was previously passing a pointer to stack
data into PIOS_USBHOOK_CtrlTx() which may be sending
this data asynchronously.  Now pass a pointer to
static data so that the asynchronous send doesn't
tx random stack contents.
2013-05-11 22:41:00 +02:00
Stacey Sheldon
859734af98 f4 usb: fix tracking of OUT requests with data stages
This code was mistakenly tracking the IN (device-to-host)
requests with data stages.  It should have been tracking
the OUT (host-to-device) requests with data stages.

This tracking data is important now that CDC is supported.
CDC actually uses OUT requests with data stages whereas HID
does not.  This bug only triggered once CDC was enabled.
2013-05-11 22:41:00 +02:00
Stacey Sheldon
b56f5206bd com/usart/cdc: ensure that device structs are memset before use
CDC and USART device drivers were not all clearing their
device structs before using them.

This specifically caused crashes in the case where the upper
COM layer was binding only a Tx path.  The Rx path callback
in the lower driver was uninitialized random data and would
result in the lower driver faulting when it tried to call the
callback.

Conflicts:
	flight/PiOS/STM32F30x/pios_usart.c
	flight/PiOS/STM32F30x/pios_usb_cdc.c
	flight/PiOS/STM32F30x/pios_usb_hid.c
2013-05-11 22:40:59 +02:00
Stacey Sheldon
e16be98224 usb cdc: ensure com buffer is drained when no DTE is attached
The CDC layer on F1, F3 and F4 now always acts like an
infinte data sink whenever *either* there is no DTE present
(ie. no terminal program listening) *or* the USB cable is
disconnected.

F1 and F4 were previously checking the cable but not the DTE.
F3 didn't check anything.  The COM layer didn't even ask the
lower layers.

All of this used to mean that any time a caller did a blocking
send to a CDC device without a DTE, it would eventually block
for up to a 5s timeout waiting for space in the Tx buffer.

Conflicts:
	flight/PiOS/STM32F30x/pios_usb_cdc.c
2013-05-11 22:40:58 +02:00
Stacey Sheldon
c702ca0f1b usbhook: fix up indentation
No functional changes.
2013-05-11 22:40:57 +02:00
Stacey Sheldon
cb6f4a474e f4 usb: ensure data buffers are 4-byte aligned
4-byte alignment is required for DMA.
2013-05-11 22:40:56 +02:00
Stacey Sheldon
f4bed187f4 f4 usb cdc: implement CDC class driver for STM32 F4 SoCs 2013-05-11 22:38:26 +02:00
Stacey Sheldon
19714d2316 f4 usb: allocate TX FIFO RAM for endpoints 2 and 3
This is required to support USB CDC mgmt and data
endpoints.
2013-05-11 22:38:25 +02:00
Stacey Sheldon
02addaf4a0 usbhook: make ctrl endpoint OUT treat request as const
The req parameter is passed to the OUT stage as a convenience.
Since the OUT callback is called *after* the transfer has occurred,
modifying the req would have absolutely no effect.  Marking this
as const makes this expectation clear.
2013-05-11 22:38:25 +02:00
Stacey Sheldon
590feefd9b f1 usb cdc: ensure uart state is transmitted on control endpoint
Previously, the IN stage on the CTRL interface would write (and
send) its data via the buffer owned by the DATA endpoint.  This
would probably have overwritten any data being sent at that
moment.  This may have caused data corruption from FC -> GCS.
2013-05-11 22:35:19 +02:00
Alessio Morale
511283c608 Flash internal: writes optimization using 4 bytes parallelism 2013-05-11 22:04:47 +02:00
Richard Flay (Hyper)
04f59d5910 OP-950: Adds "higher priority task woken" logic to SPI and SPI bus resident
sensor device drivers. Based partly on code contributed by lilvinz.

+review OPReview
2013-05-11 16:18:34 +09:30
Corvus Corax
b76df471ee bugfix on revo proto. STM32F4 A revision has a hardware bug and cannot do flash prefetching properly 2013-05-10 19:53:51 +02:00
Werner Backes
7c9d2ce9a5 Merge branch 'D-Lite/OP-934_rfm22b_rcvr_timeout_handling_next' into next 2013-05-10 09:59:30 +02:00
Richard Flay (Hyper)
cf14608ebe Merge branch 'next' into hyper/OP-936_task-monitor-rework 2013-05-09 19:25:02 +09:30
Stacey Sheldon
8ab50bca13 flashfs: use uintptr_t instead of uint32_t in flashfs API 2013-05-08 19:42:01 +02:00
Stacey Sheldon
99e61dd617 logfs: support multiple instances of logfs
Conflicts:
	flight/pios/common/pios_flashfs_logfs.c
	flight/pios/inc/pios_flashfs_logfs_priv.h
	flight/tests/logfs/pios.h
	flight/tests/logfs/pios_config.h
	flight/tests/logfs/unittest.cpp
2013-05-08 19:28:11 +02:00
Alessio Morale
93bad2e8c2 Merge branch 'amorale/OP-917_f4_bootloader_updater' into next
***** PLEASE NOTE  ***** From this revision all F4 based boards (Revolution/OSD) needs bootloader version  5 to boot properly

Conflicts:
	flight/pios/stm32f4xx/libraries/CMSIS2/Device/ST/STM32F4xx/Source/osd/system_stm32f4xx.c
	flight/targets/boards/osd/board-info.mk
	make/boot-defs.mk
	make/common-defs.mk
2013-05-07 21:02:41 +02:00
Werner Backes
938ed58918 Corrected timout calculation formula. 2013-05-06 14:20:53 +02:00
Werner Backes
bb87e6390e Update ppm_fresh if we receive a new PPM packet in order to keep the
rfm22b receiver supervisor happy.
2013-05-06 12:00:58 +02:00
Richard Flay (Hyper)
fbc8bc698f OP-936: Merges branch 'next' into hyper/OP-936_task-monitor-rework, fixes damage/conflicts,
and brings the callback scheduler into the fold.

+review OPReview-461
2013-05-06 19:11:14 +09:30
Werner Backes
0005d643ca Merge branch 'D-Lite/OP-934_rfm22b_rcvr_timeout_handling' into D-Lite/OP-934_rfm22b_rcvr_timeout_handling_next 2013-05-06 08:23:22 +02:00
Brian Webb
ae8286e99a OP-932: Fixes a bug that was preventing setting of Tx power on remote modem. 2013-05-06 01:03:15 +01:00
Richard Flay (Hyper)
a2d8544931 OP-931: adds -Wextra compiler option for the flight code, and makes the bazillion code changes required
to make the flight code compile again. Needs careful review, particularly all the fixes for the
signed vs unsigned comparisons.

+review OPReview-459
2013-05-05 16:32:24 +09:30
Brian Webb
dc4455ff68 OP-932: Fixes a bug that was preventing setting of Tx power on remote modem. 2013-05-04 17:24:40 +01:00
Brian Webb
57552f4cc9 OP-932: Changed the clock syncronization to happen only on packts transmitted from the coordinator to the remote modem. The Tx finished time of the previous packet is now sent in the packet header. This is compared to the Rx complete time of that packet on the remote modem to calcualte the difference between two modems. This eliminates the need for ACKing, so ACKs were removed for PPM and status packet. 2013-05-04 16:50:08 +01:00
Richard Flay (Hyper)
87fcf9fa8b Merge branch 'next' into hyper/OP-931_extra_compiler_warnings and update as necessary.
Hopefully properly fixes conflicts:
	flight/modules/Attitude/attitude.c
	flight/modules/ManualControl/manualcontrol.c
	flight/modules/Osd/WavPlayer/wavplayer.c
	flight/modules/Osd/osdgen/osdgen.c
	flight/modules/System/systemmod.c
	ground/uavobjgenerator/generators/flight/uavobjectgeneratorflight.cpp
2013-05-04 11:12:44 +09:30
Brian Webb
33cb06b1b0 Merge branch 'next' of ssh://git.openpilot.org/OpenPilot into OP-932-Modularize_Radio_Driver 2013-05-04 01:30:01 +01:00
Oleg Semyonov
137ddbf73a Fix broken unit tests 2013-05-03 20:27:03 +02:00
Oleg Semyonov
7aa59f4573 pios.h: only include STM32xxx.h if particular STM32 MCU is defined 2013-05-03 20:25:48 +02:00
Brian Webb
12e8adbdc4 OP-932: Fixes vitual com port and (not tested) raw comms over a UART on the OPLink. 2013-05-03 14:46:01 +01:00
Brian Webb
84a0f981e0 Merge branch 'next' of ssh://git.openpilot.org/OpenPilot into OP-932-Modularize_Radio_Driver 2013-05-03 14:08:40 +01:00
Richard Flay (Hyper)
84e1a81f8b OP-936: Moves the task monitor code out of the flight library and into PiOS.
This move and rework also breaks the dependency of the task monitor on the UAVO subsystem,
and pushes the responsibility for updating the TaskInfo UAVO into the System module.

+review OPReview
2013-05-03 07:01:14 +09:30
Werner Backes
b48665e59b rfm22b receiver supervisor now properly indicates a timeout condition.
This allows upper layers to recognize control signal loss.
2013-05-02 12:57:00 +02:00
Sambas
f7b9223827 Merge remote-tracking branch 'remotes/origin/next' into sambas/diffnext
Conflicts:
	flight/modules/System/systemmod.c
	shared/uavobjectdefinition/taskinfo.xml
2013-05-02 09:00:12 +03:00
Brian Webb
80cef9dbcc OP-932: Fixes vitual com port and (not tested) raw comms over a UART on the OPLink. 2013-05-02 04:23:26 +01:00
Brian Webb
d8b09f132f OP-932: Removes requirement to ACK PPM packets. 2013-05-01 15:28:33 +01:00
Brian Webb
344e5cbb66 Merge branch 'next' of ssh://git.openpilot.org/OpenPilot into OP-932-Modularize_Radio_Driver 2013-05-01 14:38:28 +01:00
Brian Webb
8c763c8ed3 OP-932: Improves the timing of channel changes on the radio device. 2013-05-01 14:37:47 +01:00
Oleg Semyonov
654dd051c7 Merge remote-tracking branch 'origin/next' into os/debug-pins 2013-05-01 11:13:30 +02:00
Brian Webb
a7d606dfe9 OP-932: Syncronize start of transmissions using the same coordinated clock as used by FHSS. 2013-05-01 03:46:46 +01:00
Brian Webb
2201d9d2bb OP-932: Continued cleanup and modularization of radio code. Also fixed a bug that held the SPI lock when an error occured in an Rx. 2013-05-01 03:14:35 +01:00
Brian Webb
ef18319306 OP-932: Continued cleanup and modularization of the RFM22B radio code. Low-level radio driver has mostly been split out of the higher-level state machine. 2013-05-01 03:14:23 +01:00
Brian Webb
94cb92f410 OP-932: Additional restructuring of radio code. 2013-05-01 03:14:11 +01:00
Brian Webb
cb24d3266e OP-932: Hold SPI bus semephore through multiple read/write transactions. 2013-05-01 03:13:58 +01:00
Brian Webb
8c59271d48 OP-932: Store the device status in bitfields with meaningful names. 2013-05-01 03:13:48 +01:00
Brian Webb
c3ea1bf3c0 OP-932: Fixed GPIO debugging on RevoMini (both V1 and V2) 2013-05-01 03:13:36 +01:00
Brian Webb
39c6e81d07 OP-924: Ensures that the PPM pulse turns off between PPM frames. 2013-05-01 02:48:48 +01:00
Brian Webb
76e4638b8f OP-924: Added back setting of Tracking to true when a new sample is set. 2013-05-01 02:48:46 +01:00
Brian Webb
56a524ab9e OP-924: Completely turn off PPM output when it's not being refreshed. Also fixed testing of PPM input on the OPlink that was broken when the return values were changed to negative values. The PPM values were being stored in an unsigned datatype, which made detecting negative error returns impossible. 2013-05-01 02:48:45 +01:00
Brian Webb
ab926da507 OP-924: Added a supervisor timeout to the PPM output driver. This is based on the code in the PPM input driver. A (minor) uninitialize variable bug was also fixed in the PPM input driver. 2013-05-01 02:48:44 +01:00
Alessio Morale
37a0d2c99e OP-917 included a "compatibility" linker script used by the bootloader updater to ensure its compatibility with previous bootloader versions
+review OPReview-456
2013-05-01 01:14:30 +02:00
Alessio Morale
d79887d223 OP-917 relocate IRQStack to CCSRAM
+review OPReview-456
2013-05-01 01:11:17 +02:00
Richard Flay (Hyper)
7937ae6296 OP-931: Makes flight code compile with -Wfloat-equal and -Wunsuffixed-float-constants enabled.
Also fixes warnings (and bugs) in F4 STM32_USB_OTG_Driver code, allowing -Werror to be enabled for all flight code.
Fixes all other compiler warnings that would otherwise cause the flight code to not compile with -Werror enabled.
Along the way, this also adds some uses of isnan() to various places rather than questionable tests for x != x and
x == x to check for NaNs.

+review OPReview
2013-04-30 20:36:42 +09:30
Alessio Morale
41ecc09c3f OP-917 Various review fixes:
-Fixed casing for PIOS_BL_HELPER_FLASH_ERASE_BOOTLOADER
-fixed wrong condition in f1 bl_helper
-other cosmetic changes and use of stdbool in f1 pios_bl_helper
-remove now unused macros

+review OPReview-456
2013-04-28 10:19:08 +02:00
Richard Flay (Hyper)
80c917591e Cherry-pick and hand-merge of Sami's math cleanup commit from branch sambas/diffnext: 5f3e0c3e1d 2013-04-28 10:45:28 +09:30
sambas
5f3e0c3e1d Math cleanup 2013-04-27 16:30:02 +03:00
Alessio Morale
78498910cf OP-917 Moved all the flash architecture related code to pios_bl_helper, get the flash addresses from board defines, major cleanup.
+review OPReview
2013-04-27 15:15:28 +02:00
sambas
9fec3f5567 Merge remote-tracking branch 'remotes/origin/next' into sambas/diffnext 2013-04-27 13:39:58 +03:00
Richard Flay (Hyper)
fd1181959c Merge branch 'hyper/OP-913-flight-uavo-alignment' into next 2013-04-27 18:19:01 +09:30
Brian Webb
bb6986ea04 OP-914 - Converted PIOS_RFM22B_Validate back into a normal function from an inline. 2013-04-27 01:45:19 +01:00
Brian Webb
a9079bfb7e OP-914: Additional cleanup of the RFM22B driver code. Updated to code to the current coding standard. Added Doxygen documentation. Rearranged functions into functional groups to simplify reading the code. 2013-04-27 01:44:55 +01:00
Brian Webb
77b99cdafa OP-914 - Converted PIOS_RFM22B_Validate back into a normal function from an inline. 2013-04-27 01:44:39 +01:00
Oleg Semyonov
47619c9937 Make F4 pios debug pins compilable, still should be revised for real use 2013-04-26 21:04:10 +03:00
Oleg Semyonov
45f456580f Fix pios debug pin functions and defines (thanks to Mathieu for the patch) 2013-04-26 18:18:31 +03:00
Oleg Semyonov
18f7d7488b Fix directory name case for merged sambas/diffnext 2013-04-26 17:07:44 +03:00
Oleg Semyonov
e2fd821e97 Merge remote-tracking branch 'origin/next' into sambas/diffnext
Conflicts:
	make/common-defs.mk
2013-04-26 16:31:19 +03:00
Oleg Semyonov
7d5d513e75 Move flight/PiOS.osx->flight/pios/osx
It did not work and and is not fixed yet. But at least it is in place now.
2013-04-25 13:23:47 +03:00
Oleg Semyonov
9a53843168 Move flight/PiOS.win32->flight/pios/win32
It did not work and and is not fixed yet. But at least it is in place now.
2013-04-25 13:19:06 +03:00
Oleg Semyonov
b6e1331e5d Rename flight/PiOS->flight/pios 2013-04-25 13:13:41 +03:00