PIOS SPI devices may now make use of automatic CRC generation
and checking on block transfers. Only supports CRC8 for now.
Since the SPI interface CRC calculation continues across message
boundaries (ie. not reset on every transfer), we must manually reset
the CRC registers for every transfer to allow the two sides of the
link to resynchronize.
Unfortunately, resetting the CRC registers requires disabling the
SPI peripheral which must now be done on every block transfer.
Note: The last byte of the tx buffer is never sent and is assumed to
be a place holder for the tx CRC8.
Note: The last byte of the rx buffer is expected to hold the rx CRC8.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1011 ebee16cc-31ac-478f-84a7-5cbb03baadba
Tx buffers should not be modified. This allows passing const data
to the transfer function.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1010 ebee16cc-31ac-478f-84a7-5cbb03baadba
The com layer transmit functions should provide guarantees
that they will not modify the buffer that you're transmitting.
Declaring the parameter as a pointer to const keeps the underlying
implementations honest.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1001 ebee16cc-31ac-478f-84a7-5cbb03baadba
TransferByte API is simplified to either assert or
return the rx byte.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@999 ebee16cc-31ac-478f-84a7-5cbb03baadba
SPI block transfers were broken in commit r759. Block
transfers are primarily used by the SD card interface so
this also broke accesses to the SD card.
SD card accesses should be fixed now. Verified by writing
config objects in the GCS and confirming that they survived
a reboot of the OP board.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@808 ebee16cc-31ac-478f-84a7-5cbb03baadba
- Created a pluggable COM layer
- Converted COM + USART init into static initializers
rather than typedefs
- Generalized the USB HID COM API to match the USART
API.
- Changed USART and COM layers to be data driven rather
than #ifdef'ing/switching on the specifics of each port
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@760 ebee16cc-31ac-478f-84a7-5cbb03baadba
Added support for SPI slave configurations to the pios SPI layer.
Converted the board specific configuration for the PIOS SPI layer to
use const static initializers rather than #defines (see pios_board.c).
SPI interface between the OP board and the AHRS is now operational at
a basic level, capable of moving simple single byte messages between
boards. Multi-byte, CRC protected messages will be added on top of this.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@759 ebee16cc-31ac-478f-84a7-5cbb03baadba
Many of the STM32 library functions take a pointer to an
initialization structure. In nearly every case, this struct
is a read-only (ie. const) parameter.
It is advantageous (and good coding practice) to actually declare
read-only data as const so that the compiler can place the const data
in the .rodata section which resides in flash and doesn't consume any
RAM. This has the added bonus advantage that it is impossible for the
running application to corrupt the read-only data.
In order to allow passing pointers to const data into the library
functions, it is essential that the function prototypes also declare
their associated read-only parameters as const. This commit adds
the const attribute to those parameters that are actually read-only.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@758 ebee16cc-31ac-478f-84a7-5cbb03baadba
No functionality changed. Clean up only.
Changed a few of the (1 << x) constructs to use existing macro
definitions to improve code readability.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@757 ebee16cc-31ac-478f-84a7-5cbb03baadba
No functionality changed. Clean up only.
Make early init code (Reset_Handler) use the existing irq stack
rather than the hard-coded one.
Remove (now) unused references to the hard-coded stack.
Removed the link-time check for a minimal task stack in RAM since
FreeRTOS allocates user stacks from the heap which is already reserved
in the .bss section (as symbol xHeap).
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@756 ebee16cc-31ac-478f-84a7-5cbb03baadba
The previous fix in r652 was _almost_ right. There was
still a one word (4-byte) overlap between _irq_stack_top
and the start of the data segment.
_irq_stack_end + _irq_stack_size leaves the '.' pointer at
the word immediatly after the stack. This commit corrects
this error and places _irq_stack_top on the last word
_inside_ the reserved space for the irq stack.
[Before]
$ ./tools/arm-2009q3/bin/arm-none-eabi-nm -n ./build/openpilot/OpenPilot.elf
...
20000000 A SRAM_BASE
20000000 B _irq_stack_end
20000400 d LED_GPIO_PORT <--- overlap
20000400 B _irq_stack_top <--- overlap
20000400 D _sdata
20000408 d ADC_GPIO_PORT
...
[After]
$ ./tools/arm-2009q3/bin/arm-none-eabi-nm -n ./build/openpilot/OpenPilot.elf
...
20000000 A SRAM_BASE
20000000 B _irq_stack_end
200003fc B _irq_stack_top
20000400 d LED_GPIO_PORT
20000400 D _sdata
20000408 d ADC_GPIO_PORT
...
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@668 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit fixes all existing warnings.
All basic compiler warnings will now be treated as errors.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@658 ebee16cc-31ac-478f-84a7-5cbb03baadba
This fixes the COM interface over USB HID to the point where
it can establish and maintain solid communications with the UAVObject
Browser in the GCS.
Tested only on Linux. The USB HID interface is still disabled for now
until it is tested successfully by a wider group.
Edit telemetry.c and set ALLOW_HID_TELEMETRY to 1 to enable telemetry
over the USB HID interface and report your results in the forum.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@656 ebee16cc-31ac-478f-84a7-5cbb03baadba
The MSP (IRQ stack) was trampling across the data segment. This was
especially disastrous in the USB interrupts since they allocate and
fill buffers on the stack.
The root of this trampling was that no RAM was being reserved for the
MSP and a hard-coded value of (0x20000400) was used as the initial MSP
base address. This resulted in the first 1K bytes of the .data segment
overlapping with the IRQ stack. As can be expected, all sorts of badness
resulted when interrupts were firing and trampling over variables.
This change reserves the first _isr_stack_size bytes at the beginning of
RAM for the MSP. If an ISR call chain runs off of the end of the MSP,
a Hard Fault will be generated as the (now invalid) sp is accessed.
There are two stack pointers in the Cortex-M3 CPU. These are MSP (Main
Stack Pointer) and PSP (Process Stack Pointer).
Which stack is in use at any given time is determined by the following table:
Mode CONTROL[ASPSEL] Stack
---- --------------- -----
Thread 0 MSP
Thread 1 PSP
Handler x MSP
Out of reset, the CPU is in Thread mode using the MSP. The initial value
of the MSP is automatically loaded from address 0 (lowest word in boot
region -- typically FLASH) immediately prior to jumping to the reset vector.
When running at interrupt level, the Cortex-M3 always uses the MSP and the
ASPSEL bit is forced to zero.
FreeRTOS allocates a separate stack for each task upon task creation. These
task stacks are allocated from the heap. FreeRTOS sets the active stack to
the PSP whenever running in a task context (both in privileged mode and user
mode).
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@652 ebee16cc-31ac-478f-84a7-5cbb03baadba
PIOS_SYS: Added system reset function.
OpenPilot Makefile: Default USE_BOOTLOADER should be NO.
OpenPilot Bootloader: Removed LED initialisation.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@303 ebee16cc-31ac-478f-84a7-5cbb03baadba
Added timer usage diagram to pios_board.h
Removed bloat for extra optimisation in PIOS_DELAY.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@265 ebee16cc-31ac-478f-84a7-5cbb03baadba
You can now send and receive packets (up to 63 bytes) just like using the USART port with PIOS_COM.
HID packet length will soon be increased to support maximum UAVTalk message length.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@182 ebee16cc-31ac-478f-84a7-5cbb03baadba
Added working preliminary PIOS_USB_HID support.
Integrated PIOS_USB_HID support into PIOS_USB_HID.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@171 ebee16cc-31ac-478f-84a7-5cbb03baadba
Added PIOS_USB.
Global improvements, see specific files for changes.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@144 ebee16cc-31ac-478f-84a7-5cbb03baadba
Made minGlue even more robust and simpler.
Fixed a small bug with the servo output code, which is now working 100%.
Enabled USART, which can now be used for debugging.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@138 ebee16cc-31ac-478f-84a7-5cbb03baadba
SD Card fixed and working, tested with 2Gb and 8Gb (SDHC) cards.
Changed startup_stm32f10x_HD.S to work with SysTick_Handler, needs to be changed back for FreeRTOS to work.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@132 ebee16cc-31ac-478f-84a7-5cbb03baadba
Added temporary flashing function as an easy way to know things are working.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@131 ebee16cc-31ac-478f-84a7-5cbb03baadba
init function will also try to access a file on the SDCard, this forces a real mount and will get real errors which we can handle.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@100 ebee16cc-31ac-478f-84a7-5cbb03baadba
Started work on BMP085 driver. Need more information from Bosch to continue.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@61 ebee16cc-31ac-478f-84a7-5cbb03baadba
New standard to be used is PIOS_Module_Function().
Likewise with OpenPilot, OP_Module_Function() is to be used.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@59 ebee16cc-31ac-478f-84a7-5cbb03baadba