Configuration cleanup on stop in the entire HAL.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9601 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2016-06-07 13:10:04 +00:00
parent afc0508c0b
commit 02d65c01db
19 changed files with 80 additions and 18 deletions

View File

@ -117,10 +117,14 @@ void adcStop(ADCDriver *adcp) {
osalDbgCheck(adcp != NULL);
osalSysLock();
osalDbgAssert((adcp->state == ADC_STOP) || (adcp->state == ADC_READY),
"invalid state");
adc_lld_stop(adcp);
adcp->state = ADC_STOP;
adcp->config = NULL;
adcp->state = ADC_STOP;
osalSysUnlock();
}

View File

@ -129,6 +129,7 @@ void canStop(CANDriver *canp) {
/* The low level driver is stopped.*/
can_lld_stop(canp);
canp->config = NULL;
canp->state = CAN_STOP;
/* Threads waiting on CAN APIs are notified that the driver has been

View File

@ -125,7 +125,8 @@ void dacStop(DACDriver *dacp) {
"invalid state");
dac_lld_stop(dacp);
dacp->state = DAC_STOP;
dacp->config = NULL;
dacp->state = DAC_STOP;
osalSysUnlock();
}

View File

@ -106,10 +106,14 @@ void extStop(EXTDriver *extp) {
osalDbgCheck(extp != NULL);
osalSysLock();
osalDbgAssert((extp->state == EXT_STOP) || (extp->state == EXT_ACTIVE),
"invalid state");
ext_lld_stop(extp);
extp->state = EXT_STOP;
extp->config = NULL;
extp->state = EXT_STOP;
osalSysUnlock();
}

View File

@ -104,10 +104,14 @@ void gptStop(GPTDriver *gptp) {
osalDbgCheck(gptp != NULL);
osalSysLock();
osalDbgAssert((gptp->state == GPT_STOP) || (gptp->state == GPT_READY),
"invalid state");
gpt_lld_stop(gptp);
gptp->state = GPT_STOP;
gptp->config = NULL;
gptp->state = GPT_STOP;
osalSysUnlock();
}

View File

@ -113,12 +113,16 @@ void i2cStart(I2CDriver *i2cp, const I2CConfig *config) {
void i2cStop(I2CDriver *i2cp) {
osalDbgCheck(i2cp != NULL);
osalSysLock();
osalDbgAssert((i2cp->state == I2C_STOP) || (i2cp->state == I2C_READY) ||
(i2cp->state == I2C_LOCKED), "invalid state");
osalSysLock();
i2c_lld_stop(i2cp);
i2cp->state = I2C_STOP;
i2cp->config = NULL;
i2cp->state = I2C_STOP;
osalSysUnlock();
}

View File

@ -104,10 +104,14 @@ void i2sStop(I2SDriver *i2sp) {
osalDbgCheck(i2sp != NULL);
osalSysLock();
osalDbgAssert((i2sp->state == I2S_STOP) || (i2sp->state == I2S_READY),
"invalid state");
i2s_lld_stop(i2sp);
i2sp->state = I2S_STOP;
i2sp->config = NULL;
i2sp->state = I2S_STOP;
osalSysUnlock();
}

View File

@ -104,10 +104,14 @@ void icuStop(ICUDriver *icup) {
osalDbgCheck(icup != NULL);
osalSysLock();
osalDbgAssert((icup->state == ICU_STOP) || (icup->state == ICU_READY),
"invalid state");
icu_lld_stop(icup);
icup->state = ICU_STOP;
icup->config = NULL;
icup->state = ICU_STOP;
osalSysUnlock();
}

View File

@ -117,10 +117,14 @@ void macStop(MACDriver *macp) {
osalDbgCheck(macp != NULL);
osalSysLock();
osalDbgAssert((macp->state == MAC_STOP) || (macp->state == MAC_ACTIVE),
"invalid state");
mac_lld_stop(macp);
macp->state = MAC_STOP;
macp->config = NULL;
macp->state = MAC_STOP;
osalSysUnlock();
}

View File

@ -430,7 +430,8 @@ void mmcStop(MMCDriver *mmcp) {
"invalid state");
spiStop(mmcp->config->spip);
mmcp->state = BLK_STOP;
mmcp->config = NULL;
mmcp->state = BLK_STOP;
}
/**

View File

@ -113,11 +113,15 @@ void pwmStop(PWMDriver *pwmp) {
osalDbgCheck(pwmp != NULL);
osalSysLock();
osalDbgAssert((pwmp->state == PWM_STOP) || (pwmp->state == PWM_READY),
"invalid state");
pwm_lld_stop(pwmp);
pwmp->enabled = 0;
pwmp->config = NULL;
pwmp->state = PWM_STOP;
osalSysUnlock();
}

View File

@ -124,7 +124,8 @@ void qspiStop(QSPIDriver *qspip) {
"invalid state");
qspi_lld_stop(qspip);
qspip->state = QSPI_STOP;
qspip->config = NULL;
qspip->state = QSPI_STOP;
osalSysUnlock();
}

View File

@ -594,10 +594,14 @@ void sdcStop(SDCDriver *sdcp) {
osalDbgCheck(sdcp != NULL);
osalSysLock();
osalDbgAssert((sdcp->state == BLK_STOP) || (sdcp->state == BLK_ACTIVE),
"invalid state");
sdc_lld_stop(sdcp);
sdcp->state = BLK_STOP;
sdcp->config = NULL;
sdcp->state = BLK_STOP;
osalSysUnlock();
}

View File

@ -170,13 +170,17 @@ void sdStop(SerialDriver *sdp) {
osalDbgCheck(sdp != NULL);
osalSysLock();
osalDbgAssert((sdp->state == SD_STOP) || (sdp->state == SD_READY),
"invalid state");
sd_lld_stop(sdp);
sdp->state = SD_STOP;
sdp->config = NULL;
sdp->state = SD_STOP;
oqResetI(&sdp->oqueue);
iqResetI(&sdp->iqueue);
osalOsRescheduleS();
osalSysUnlock();
}

View File

@ -264,6 +264,7 @@ void sduStop(SerialUSBDriver *sdup) {
osalDbgCheck(sdup != NULL);
osalSysLock();
osalDbgAssert((sdup->state == SDU_STOP) || (sdup->state == SDU_READY),
"invalid state");
@ -273,11 +274,13 @@ void sduStop(SerialUSBDriver *sdup) {
if (sdup->config->int_in > 0U) {
usbp->in_params[sdup->config->int_in - 1U] = NULL;
}
sdup->state = SDU_STOP;
sdup->config = NULL;
sdup->state = SDU_STOP;
/* Enforces a disconnection.*/
sduDisconnectI(sdup);
osalOsRescheduleS();
osalSysUnlock();
}

View File

@ -115,10 +115,14 @@ void spiStop(SPIDriver *spip) {
osalDbgCheck(spip != NULL);
osalSysLock();
osalDbgAssert((spip->state == SPI_STOP) || (spip->state == SPI_READY),
"invalid state");
spi_lld_stop(spip);
spip->state = SPI_STOP;
spip->config = NULL;
spip->state = SPI_STOP;
osalSysUnlock();
}

View File

@ -120,13 +120,16 @@ void uartStop(UARTDriver *uartp) {
osalDbgCheck(uartp != NULL);
osalSysLock();
osalDbgAssert((uartp->state == UART_STOP) || (uartp->state == UART_READY),
"invalid state");
uart_lld_stop(uartp);
uartp->state = UART_STOP;
uartp->config = NULL;
uartp->state = UART_STOP;
uartp->txstate = UART_TX_IDLE;
uartp->rxstate = UART_RX_IDLE;
osalSysUnlock();
}

View File

@ -314,12 +314,15 @@ void usbStop(USBDriver *usbp) {
osalDbgCheck(usbp != NULL);
osalSysLock();
osalDbgAssert((usbp->state == USB_STOP) || (usbp->state == USB_READY) ||
(usbp->state == USB_SELECTED) || (usbp->state == USB_ACTIVE) ||
(usbp->state == USB_SUSPENDED),
"invalid state");
usb_lld_stop(usbp);
usbp->state = USB_STOP;
spip->config = NULL;
spip->state = USB_STOP;
/* Resetting all ongoing synchronous operations.*/
for (i = 0; i <= (unsigned)USB_MAX_ENDPOINTS; i++) {
@ -336,6 +339,7 @@ void usbStop(USBDriver *usbp) {
usbp->epc[i] = NULL;
}
osalOsRescheduleS();
osalSysUnlock();
}

View File

@ -91,10 +91,14 @@ void wdgStop(WDGDriver *wdgp) {
osalDbgCheck(wdgp != NULL);
osalSysLock();
osalDbgAssert((wdgp->state == WDG_STOP) || (wdgp->state == WDG_READY),
"invalid state");
wdg_lld_stop(wdgp);
wdgp->state = WDG_STOP;
wdgp->config = NULL;
wdgp->state = WDG_STOP;
osalSysUnlock();
}