diff options
author | px4dev <px4@purgatory.org> | 2013-01-09 21:39:54 -0800 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2013-01-13 19:05:00 -0800 |
commit | 3cea0959b72fe160e6a05e8efef1d325d12d4544 (patch) | |
tree | 92067e4c4d1e5c54000d29218bddd5b6d57a7acb /apps/px4io/i2c.c | |
parent | 2fb820fabd7c7b675c4e0da026c95546b62424e6 (diff) | |
download | px4-firmware-3cea0959b72fe160e6a05e8efef1d325d12d4544.tar.gz px4-firmware-3cea0959b72fe160e6a05e8efef1d325d12d4544.tar.bz2 px4-firmware-3cea0959b72fe160e6a05e8efef1d325d12d4544.zip |
Implement a simple byte loopback server on I2C for more testing.
Diffstat (limited to 'apps/px4io/i2c.c')
-rw-r--r-- | apps/px4io/i2c.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/apps/px4io/i2c.c b/apps/px4io/i2c.c index e55e992fd..3e4ac3488 100644 --- a/apps/px4io/i2c.c +++ b/apps/px4io/i2c.c @@ -78,7 +78,6 @@ static DMA_HANDLE tx_dma; uint8_t rx_buf[64]; unsigned rx_len; uint8_t tx_buf[64]; -unsigned tx_len; enum { DIR_NONE = 0, @@ -210,6 +209,9 @@ i2c_rx_complete(DMA_HANDLE handle, uint8_t status, void *arg) { rx_len = sizeof(rx_buf) - stm32_dmaresidual(rx_dma); + for (unsigned i = 0; i < rx_len; i++) + tx_buf[i] = rx_buf[i] + 1; + /* XXX handle reception */ i2c_rx_setup(); } @@ -217,7 +219,6 @@ i2c_rx_complete(DMA_HANDLE handle, uint8_t status, void *arg) static void i2c_tx_setup(void) { - tx_len = 0; stm32_dmasetup(tx_dma, (uintptr_t)&rDR, (uintptr_t)&tx_buf[0], sizeof(tx_buf), DMA_CCR_DIR | DMA_CCR_MINC | @@ -229,9 +230,7 @@ i2c_tx_setup(void) static void i2c_tx_complete(DMA_HANDLE handle, uint8_t status, void *arg) { - tx_len = sizeof(tx_buf) - stm32_dmaresidual(tx_dma); - - /* XXX handle reception */ + /* XXX handle transmit-done */ i2c_tx_setup(); } |