altos/lpc: i2c appears to be working
[fw/altos] / src / stm / ao_i2c_stm.c
index 8f54931808a7f95abab74a9e684b10c47299adf4..988e2a6c729bd90d0ee92f438c194ca8b2ebca56 100644 (file)
@@ -132,17 +132,17 @@ ao_i2c_ev_isr(uint8_t index)
        if (sr1 & (1 << STM_I2C_SR1_SB))
                stm_i2c->dr = ao_i2c_addr[index];
        if (sr1 & (1 << STM_I2C_SR1_ADDR)) {
-               stm_i2c->cr2 &= ~(1 << STM_I2C_CR2_ITEVTEN);
+               stm_i2c->cr2 &= ~(1UL << STM_I2C_CR2_ITEVTEN);
                ao_i2c_state[index] = I2C_RUNNING;
                ao_wakeup(&ao_i2c_state[index]);
        }
        if (sr1 & (1 << STM_I2C_SR1_BTF)) {
-               stm_i2c->cr2 &= ~(1 << STM_I2C_CR2_ITEVTEN);
+               stm_i2c->cr2 &= ~(1UL << STM_I2C_CR2_ITEVTEN);
                ao_wakeup(&ao_i2c_state[index]);
        }
        if (sr1 & (1 << STM_I2C_SR1_RXNE)) {
                if (ao_i2c_recv_len[index]) {
-                       *(ao_i2c_recv_data[index]++) = stm_i2c->dr;
+                       *(ao_i2c_recv_data[index]++) = (uint8_t) stm_i2c->dr;
                        if (!--ao_i2c_recv_len[index])
                                ao_wakeup(&ao_i2c_recv_len[index]);
                }
@@ -161,7 +161,7 @@ ao_i2c_er_isr(uint8_t index)
        sr1 = stm_i2c->sr1;
        if (sr1 & (1 << STM_I2C_SR1_AF)) {
                ao_i2c_state[index] = I2C_ERROR;
-               stm_i2c->sr1 = sr1 & ~(1 << STM_I2C_SR1_AF);
+               stm_i2c->sr1 = sr1 & ~(1UL << STM_I2C_SR1_AF);
                ao_wakeup(&ao_i2c_state[index]);
        }
 }
@@ -237,7 +237,7 @@ ao_i2c_wait_addr(uint8_t index)
 }
 
 uint8_t
-ao_i2c_send(void *block, uint16_t len, uint8_t index, uint8_t stop)
+ao_i2c_send(const void *block, uint16_t len, uint8_t index, uint8_t stop)
 {
        struct stm_i2c  *stm_i2c = ao_i2c_stm_info[index].stm_i2c;
        uint8_t         tx_dma_index = ao_i2c_stm_info[index].tx_dma_index;
@@ -248,7 +248,7 @@ ao_i2c_send(void *block, uint16_t len, uint8_t index, uint8_t stop)
        stm_i2c->cr2 = AO_STM_I2C_CR2 | (1 << STM_I2C_CR2_DMAEN);
        ao_dma_set_transfer(tx_dma_index,
                            &stm_i2c->dr,
-                           block,
+                           (void *) block,
                            len,
                            (0 << STM_DMA_CCR_MEM2MEM) |
                            (STM_DMA_CCR_PL_MEDIUM << STM_DMA_CCR_PL) |