1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00
Commit Graph

28 Commits

Author SHA1 Message Date
stac
47c36b3da0 i2c: fix error in FSM for restarted reads
The transition from the ADDR state to the read state
was broken for non-final reads.  The FSM diagram was
also wrong for this transition.

Since reads are always the last transaction in a sequence
in our current usage, this doesn't actually fix any known
bugs.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1350 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-08-21 16:19:06 +00:00
stac
98822bff98 i2c: force bus free on warm starts
Since the i2c bus is bidirectional, there are certain
states (eg. part way through a read) where the slave
device is in control of driving the SDA line.

On a cold start (power on), the slave devices are all
quiescent and will not drive the bus.  However, on a warm
start (eg. watchdog or jtag restart), it is possible that as
the CPU boots, the slave device may be holding the SDA line
low.  This is a bus busy condition and will prevent the I2C
bus master in the CPU from being able to seize the bus during
init.

The fix for this is to clock the i2c bus sufficiently to ensure
that the the slave device finishes its transaction and releases
the bus.

Once the slave has released the bus, the bus master can properly
initialize and assert a STOP condition on the bus.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1349 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-08-21 16:19:02 +00:00
FredericG
b46bc68e96 "addr" field of I2C transaction struct now takes real I2C address, and not address that is pre-shifted to accommodate the R/W bit
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1321 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-08-18 10:04:55 +00:00
stac
f74c6ffdd5 i2c: rewrite i2c layer
The STM32 I2C block has a number of errata associated with it.
These errata are primarily related to timing sensitivities between
the peripheral and the interrupt handler.  In particular, the
correct generation of the stop bit relies on the I2C IRQ running
immediately and not being held off for any reason.

NOTE: The I2C interrupts must be the highest priority IRQs in the
      system to ensure correct operation.

I2C protocol is now implemented as a formal state machine.
See: stm32_i2c_fsm.{dot,jpg} for FSM description.

I2C init is now expressed by const initializers in pios_board.c
for both OP and AHRS boards.

I2C device drivers (ie. bmp085/hmc5843) now pass in const arrays
of an unlimited number of bus transfers to be done atomically.
The I2C adapter driver now handles all bus-level locking across the
list of transactions.  Generation of start/restart/stop conditions
are handled automatically over the list of transactions.

Timeouts have been removed from the API for now.  May be added
back later.

This driver has run error free on both the OP and AHRS boards for
up to 48hrs but it still sometimes fails earlier than that on the OP
board.  There is another possible set of improvements to the driver
that could employ the DMA engine for transfers of >= 2bytes.  This
change would reduce the timing sensitivities between the peripheral
and the driver but unfortunately, both the SPI and I2C interfaces
share the DMA1 engine.  That means only one of these two peripherals
can use the DMA engine and right now, SPI between OP and AHRS is
already using it.

Failures are currently fatal and will lock up the CPU.  This allows
useful information to be obtained in the failure cases.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1241 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-08-08 04:15:08 +00:00
peabody124
d928676f5e More documentation updates, standardizing format to include addtogroup at the beginning of headers so files are associated with modules
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1121 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-07-16 19:53:35 +00:00
peabody124
99e94228a9 More doxygen updates
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1106 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-07-16 05:31:11 +00:00
FredericG
3bc938d45e lowered I2C timoout whne using RTOS
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@842 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-06-21 09:19:02 +00:00
FredericG
09981b39c2 A few small fixes
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@647 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-05-22 06:30:42 +00:00
gussy
ff73ab5a80 More updates to cross-target compatibility.
Added PIOS_I2C into AHRS code.
Added PIOS_HMC5843 Module.




git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@617 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-05-12 08:18:49 +00:00
fredericg
3281b1a128 OP-27 Use RTOS in LockDevice() and UnlockDevice()
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@564 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-05-01 14:49:51 +00:00
fredericg
e57ec315e1 fixed warning
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@319 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-03-15 12:00:47 +00:00
FredericG
8e873ec0e8 Use the new PIOS assert
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@315 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-03-14 17:13:27 +00:00
FredericG
3b332c786f OP-11 Use RTOS when waiting for an I2C transfer to finish when RTOS is enabled
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@298 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-03-13 17:28:42 +00:00
FredericG
50215e75c6 OP-28 Some changes in the I2C API
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@296 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-03-13 12:23:55 +00:00
fredericg
47038af0c0 PIOS_DONT_USE_XXX => PIOS_INCLUDE_XXX
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@283 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-03-11 12:38:51 +00:00
FredericG
dbde2b1bac I2C: Some more fixes. I2C test passes at 400KBit and 200KBit but needs to be investigated further
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@280 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-03-10 21:11:19 +00:00
FredericG
dd429536f7 pios_i2c.c: last commit broke reading; need to ack the incoming bytes
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@252 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-03-05 18:36:28 +00:00
FredericG
595a8f2cef One exit point for isr function
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@251 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-03-05 18:14:00 +00:00
FredericG
b3ad53acdc Enable and disable interrupts in TransferStart() and TransferEnd() functions
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@250 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-03-05 18:07:15 +00:00
FredericG
7dd7c0201c Fix: Don't generate start at the end of WriteWithoutStop transfer. Needs cleanup
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@248 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-03-05 07:57:26 +00:00
fredericg
35f07fe9dc Introduction of lacal functions TransferStart() and TransferEnd()
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@232 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-03-03 12:05:49 +00:00
fredericg
ad816dc070 Renamed PIOS_I2C_TransferBegin => PIOS_I2C_LockDevice because it better describes what it does
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@231 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-03-03 11:46:24 +00:00
FredericG
b205ebd873 Small fix: Write operations did have to time out before a new could be started
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@225 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-03-02 18:33:19 +00:00
gussy
22f02cb460 PIOS_I2C now non-application specific.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@204 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-02-28 06:57:59 +00:00
gussy
adcd47a31b Added ability to enable and disable PiOS modules.
Added PIOS_USB_COM.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@202 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-02-28 06:47:49 +00:00
gussy
3b32b89839 Updated copyright headers.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@146 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-01-31 17:56:54 +00:00
gussy
9eeaf09b80 Fixed a few typos in PIOS_I2C.
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
2009-12-10 01:59:46 +00:00
gussy
a1f7f260c1 Added PIOS_I2C module. It's blind code though, no idea if it works.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@60 ebee16cc-31ac-478f-84a7-5cbb03baadba
2009-12-09 23:10:32 +00:00