1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-21 11:54:15 +01:00

One exit point for isr function

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@251 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
FredericG 2010-03-05 18:14:00 +00:00 committed by FredericG
parent b3ad53acdc
commit 595a8f2cef

View File

@ -441,8 +441,7 @@ static void EV_IRQHandler(I2CRecTypeDef *i2cx)
/* Last byte received, disable interrupts and return. */ /* Last byte received, disable interrupts and return. */
if(i2cx->transfer_state.STOP_REQUESTED) { if(i2cx->transfer_state.STOP_REQUESTED) {
TransferEnd(i2cx); TransferEnd(i2cx);
DebugPinLow(DEBUG_PIN_ISR); goto isr_return;
return;
} }
/* Request NAK and stop condition before receiving last data */ /* Request NAK and stop condition before receiving last data */
@ -453,8 +452,7 @@ static void EV_IRQHandler(I2CRecTypeDef *i2cx)
I2C_GenerateSTOP(i2cx->base, ENABLE); I2C_GenerateSTOP(i2cx->base, ENABLE);
i2cx->transfer_state.STOP_REQUESTED = 1; i2cx->transfer_state.STOP_REQUESTED = 1;
} }
DebugPinLow(DEBUG_PIN_ISR); goto isr_return;
return;
} }
/* ADDR set, TRA flag not set (indicates transmitter/receiver mode). */ /* ADDR set, TRA flag not set (indicates transmitter/receiver mode). */
@ -469,8 +467,7 @@ static void EV_IRQHandler(I2CRecTypeDef *i2cx)
I2C_GenerateSTOP(i2cx->base, ENABLE); I2C_GenerateSTOP(i2cx->base, ENABLE);
i2cx->transfer_state.STOP_REQUESTED = 1; i2cx->transfer_state.STOP_REQUESTED = 1;
} }
DebugPinLow(DEBUG_PIN_ISR); goto isr_return;
return;
} }
/* TxE set, will be cleared by writing DR, or after START or STOP was generated */ /* TxE set, will be cleared by writing DR, or after START or STOP was generated */
@ -481,15 +478,13 @@ static void EV_IRQHandler(I2CRecTypeDef *i2cx)
/* Last byte already sent, disable interrupts and return. */ /* Last byte already sent, disable interrupts and return. */
if(i2cx->transfer_state.STOP_REQUESTED) { if(i2cx->transfer_state.STOP_REQUESTED) {
TransferEnd(i2cx); TransferEnd(i2cx);
DebugPinLow(DEBUG_PIN_ISR); goto isr_return;
return;
} }
if(i2cx->buffer_ix < i2cx->buffer_len) { if(i2cx->buffer_ix < i2cx->buffer_len) {
/* Checking tx_buffer_ptr for NULL is a failsafe measure. */ /* Checking tx_buffer_ptr for NULL is a failsafe measure. */
I2C_SendData(i2cx->base, (i2cx->tx_buffer_ptr == NULL) ? 0 : i2cx->tx_buffer_ptr[i2cx->buffer_ix++]); I2C_SendData(i2cx->base, (i2cx->tx_buffer_ptr == NULL) ? 0 : i2cx->tx_buffer_ptr[i2cx->buffer_ix++]);
DebugPinLow(DEBUG_PIN_ISR); goto isr_return;
return;
} }
/* Peripheral is transfering last byte, request stop condition / */ /* Peripheral is transfering last byte, request stop condition / */
@ -511,8 +506,7 @@ static void EV_IRQHandler(I2CRecTypeDef *i2cx)
/* If this is not done, BUSY will be cleared before the transfer is finished */ /* If this is not done, BUSY will be cleared before the transfer is finished */
I2C_ITConfig(i2cx->base, I2C_IT_BUF, DISABLE); I2C_ITConfig(i2cx->base, I2C_IT_BUF, DISABLE);
} }
DebugPinLow(DEBUG_PIN_ISR); goto isr_return;
return;
} }
/* SB set, cleared by reading SR1 (done by I2C_GetLastEvent) followed by writing DR register */ /* SB set, cleared by reading SR1 (done by I2C_GetLastEvent) followed by writing DR register */
@ -530,8 +524,7 @@ static void EV_IRQHandler(I2CRecTypeDef *i2cx)
(i2cx->i2c_address & 1) (i2cx->i2c_address & 1)
? I2C_Direction_Receiver ? I2C_Direction_Receiver
: I2C_Direction_Transmitter); : I2C_Direction_Transmitter);
DebugPinLow(DEBUG_PIN_ISR); goto isr_return;
return;
} }
/* This code is only reached if something got wrong, e.g. interrupt handler is called too late, */ /* This code is only reached if something got wrong, e.g. interrupt handler is called too late, */
@ -549,6 +542,7 @@ static void EV_IRQHandler(I2CRecTypeDef *i2cx)
b = I2C_ReceiveData(i2cx->base); b = I2C_ReceiveData(i2cx->base);
I2C_GenerateSTOP(i2cx->base, ENABLE); I2C_GenerateSTOP(i2cx->base, ENABLE);
isr_return:
DebugPinLow(DEBUG_PIN_ISR); DebugPinLow(DEBUG_PIN_ISR);
} }