Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ uint8_t i2c_active_t(_i2c_t *p_obj);
TXZ_Result i2c_transfer_asynch_t(_i2c_t *p_obj, uint8_t *p_tx, int32_t tx_length, uint8_t *p_rx, int32_t rx_length, int32_t address, int32_t stop);
uint32_t i2c_irq_handler_asynch_t(_i2c_t *p_obj);
void i2c_abort_asynch_t(_i2c_t *p_obj);
uint32_t set_i2c(uint8_t ch, uint32_t *p_irqn);

/* For slave */
void i2c_slave_mode_t(_i2c_t *p_obj, int32_t enable_slave);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ __STATIC_INLINE void set_port_ch1(i2c_port_t sda, i2c_port_t scl);
__STATIC_INLINE void set_port_ch2(i2c_port_t sda, i2c_port_t scl);
__STATIC_INLINE void set_port_ch3(i2c_port_t sda, i2c_port_t scl);
__STATIC_INLINE void set_port_ch4(i2c_port_t sda, i2c_port_t scl);
__STATIC_INLINE uint32_t set_i2c(uint8_t ch, uint32_t *p_irqn);
__STATIC_INLINE void reset_asynch(_i2c_t *p_obj);
__STATIC_INLINE int32_t wait_status(_i2c_t *p_obj);
static void i2c_irq_handler(_i2c_t *p_obj);
Expand Down Expand Up @@ -574,7 +573,7 @@ __STATIC_INLINE void set_port_ch4(i2c_port_t sda, i2c_port_t scl)
* @note -
*/
/*--------------------------------------------------*/
__STATIC_INLINE uint32_t set_i2c(uint8_t ch, uint32_t *p_irqn)
uint32_t set_i2c(uint8_t ch, uint32_t *p_irqn)
{
uint32_t instance = 0;

Expand Down Expand Up @@ -725,7 +724,7 @@ static void i2c_irq_handler(_i2c_t *p_obj)
}
else
{
if (p_obj->tx_buff.pos < p_obj->tx_buff.length)
if ((p_obj->tx_buff.pos < p_obj->tx_buff.length) || (p_obj->tx_buff.length == 0))
{
if (p_obj->tx_buff.pos == 0)
{
Expand All @@ -740,16 +739,7 @@ static void i2c_irq_handler(_i2c_t *p_obj)
}
else if (p_obj->rx_buff.length != 0)
{
if (p_obj->tx_buff.pos == 0)
{
p_obj->info.asynch.event = (I2C_EVENT_ERROR | I2C_EVENT_ERROR_NO_SLAVE);
p_obj->info.asynch.state = I2C_TRANSFER_STATE_IDLE;
}
else
{
p_obj->info.asynch.event = (I2C_EVENT_ERROR | I2C_EVENT_TRANSFER_EARLY_NACK);
p_obj->info.asynch.state = I2C_TRANSFER_STATE_IDLE;
}
I2C_start_condition(&p_obj->i2c, (p_obj->info.asynch.address | 1U));
}
else
{
Expand Down Expand Up @@ -1470,35 +1460,32 @@ TXZ_Result i2c_transfer_asynch_t(_i2c_t *p_obj, uint8_t *p_tx, int32_t tx_length

if (p_obj->info.asynch.state == I2C_TRANSFER_STATE_IDLE)
{
if (((p_tx != I2C_NULL) && (tx_length > 0)) || ((p_rx != I2C_NULL) && (rx_length > 0)))
reset_asynch(p_obj);
I2C_clear_int_status(&p_obj->i2c);
clear_irq(p_obj->info.irqn);
p_obj->info.asynch.address = (uint32_t)address;
p_obj->info.asynch.event = 0;
p_obj->info.asynch.stop = (uint32_t)stop;
p_obj->tx_buff.p_buffer = p_tx;
p_obj->tx_buff.length = (uint32_t)tx_length;
p_obj->tx_buff.pos = 0;
p_obj->rx_buff.p_buffer = p_rx;
p_obj->rx_buff.length = (uint32_t)rx_length;
p_obj->rx_buff.pos = 0;
p_obj->info.asynch.state = I2C_TRANSFER_STATE_BUSY;
I2C_enable_interrupt(&p_obj->i2c);
if ((tx_length == 0) && (rx_length != 0))
{
reset_asynch(p_obj);
I2C_clear_int_status(&p_obj->i2c);
clear_irq(p_obj->info.irqn);
p_obj->info.asynch.address = (uint32_t)address;
p_obj->info.asynch.event = 0;
p_obj->info.asynch.stop = (uint32_t)stop;
p_obj->tx_buff.p_buffer = p_tx;
p_obj->tx_buff.length = (uint32_t)tx_length;
p_obj->tx_buff.pos = 0;
p_obj->rx_buff.p_buffer = p_rx;
p_obj->rx_buff.length = (uint32_t)rx_length;
p_obj->rx_buff.pos = 0;
p_obj->info.asynch.state = I2C_TRANSFER_STATE_BUSY;
I2C_enable_interrupt(&p_obj->i2c);
if ((tx_length == 0) && (rx_length != 0))
{
I2C_start_condition(&p_obj->i2c, (uint32_t)((uint32_t)address | 1U));
}
else
{
I2C_start_condition(&p_obj->i2c, (uint32_t)address);
}
p_obj->info.bus_free = 0;
p_obj->info.start = 0;
enable_irq(p_obj->info.irqn);
result = TXZ_SUCCESS;
I2C_start_condition(&p_obj->i2c, (uint32_t)((uint32_t)address | 1U));
}
else
{
I2C_start_condition(&p_obj->i2c, (uint32_t)address);
}
p_obj->info.bus_free = 0;
p_obj->info.start = 0;
enable_irq(p_obj->info.irqn);
result = TXZ_SUCCESS;
}
return (result);
}
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_TOSHIBA/TARGET_TMPM4G9/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#ifndef MBED_DEVICE_H
#define MBED_DEVICE_H

#define TRANSACTION_QUEUE_SIZE_SPI 4
#define DEVICE_ID_LENGTH 32

#include <stddef.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE ; load region size_region
.ANY (+RW, +ZI)
}

ARM_LIB_STACK (0x20000320+0x30000) EMPTY -Stack_Size { ; stack
ARM_LIB_STACK (0x20000000+0x30000) EMPTY -Stack_Size { ; stack
}
}
8 changes: 4 additions & 4 deletions targets/TARGET_TOSHIBA/TARGET_TMPM4G9/gpio_irq_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
// Get gpio interrupt event
if (event == IRQ_RISE) {
if ((obj->event == CG_INT_ACTIVE_STATE_FALLING) ||
(obj->event == CG_INT_ACTIVE_STATE_BOTH_EDGES)) {
(obj->event == CG_INT_ACTIVE_STATE_BOTH_EDGES)) {
obj->event = CG_INT_ACTIVE_STATE_BOTH_EDGES;
} else {
obj->event = CG_INT_ACTIVE_STATE_RISING;
}
} else if (event == IRQ_FALL) {
if ((obj->event == CG_INT_ACTIVE_STATE_RISING) ||
(obj->event == CG_INT_ACTIVE_STATE_BOTH_EDGES)) {
(obj->event == CG_INT_ACTIVE_STATE_BOTH_EDGES)) {
obj->event = CG_INT_ACTIVE_STATE_BOTH_EDGES;
} else {
obj->event = CG_INT_ACTIVE_STATE_FALLING;
Expand All @@ -198,14 +198,14 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
// Get gpio interrupt event
if (event == IRQ_RISE) {
if ((obj->event == CG_INT_ACTIVE_STATE_RISING) ||
(obj->event == CG_INT_ACTIVE_STATE_INVALID)) {
(obj->event == CG_INT_ACTIVE_STATE_INVALID)) {
obj->event = CG_INT_ACTIVE_STATE_BOTH_EDGES;
} else {
obj->event = CG_INT_ACTIVE_STATE_FALLING;
}
} else if (event == IRQ_FALL) {
if ((obj->event == CG_INT_ACTIVE_STATE_FALLING) ||
(obj->event == CG_INT_ACTIVE_STATE_INVALID)) {
(obj->event == CG_INT_ACTIVE_STATE_INVALID)) {
obj->event = CG_INT_ACTIVE_STATE_BOTH_EDGES;
} else {
obj->event = CG_INT_ACTIVE_STATE_RISING;
Expand Down
Loading