diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-08-21 13:19:48 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-08-21 13:19:48 +0000 |
commit | f23670b728189b4549091d355e38218b31c0a0ad (patch) | |
tree | 33d4199ca6898675b6b108ab881b148c5924fd65 /os/hal/src | |
parent | 4e35a12a2a84afa813bf619df3bbb8146b98a973 (diff) | |
download | ChibiOS-f23670b728189b4549091d355e38218b31c0a0ad.tar.gz ChibiOS-f23670b728189b4549091d355e38218b31c0a0ad.tar.bz2 ChibiOS-f23670b728189b4549091d355e38218b31c0a0ad.zip |
Added I-class function checks to HAL APIs.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3244 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src')
-rw-r--r-- | os/hal/src/adc.c | 6 | ||||
-rw-r--r-- | os/hal/src/gpt.c | 10 | ||||
-rw-r--r-- | os/hal/src/icu.c | 4 | ||||
-rw-r--r-- | os/hal/src/serial.c | 2 | ||||
-rw-r--r-- | os/hal/src/uart.c | 10 | ||||
-rw-r--r-- | os/hal/src/usb.c | 22 |
6 files changed, 48 insertions, 6 deletions
diff --git a/os/hal/src/adc.c b/os/hal/src/adc.c index 4843ca90b..f2bf4eadd 100644 --- a/os/hal/src/adc.c +++ b/os/hal/src/adc.c @@ -176,13 +176,14 @@ void adcStartConversionI(ADCDriver *adcp, adcsample_t *samples,
size_t depth) {
+ chDbgCheckClassI();
chDbgCheck((adcp != NULL) && (grpp != NULL) && (samples != NULL) &&
((depth == 1) || ((depth & 1) == 0)),
"adcStartConversionI");
-
chDbgAssert((adcp->state == ADC_READY) ||
(adcp->state == ADC_COMPLETE),
"adcStartConversionI(), #1", "not ready");
+
adcp->samples = samples;
adcp->depth = depth;
adcp->grpp = grpp;
@@ -229,12 +230,13 @@ void adcStopConversion(ADCDriver *adcp) { */
void adcStopConversionI(ADCDriver *adcp) {
+ chDbgCheckClassI();
chDbgCheck(adcp != NULL, "adcStopConversionI");
-
chDbgAssert((adcp->state == ADC_READY) ||
(adcp->state == ADC_ACTIVE) ||
(adcp->state == ADC_COMPLETE),
"adcStopConversionI(), #1", "invalid state");
+
if (adcp->state != ADC_READY) {
adc_lld_stop_conversion(adcp);
adcp->grpp = NULL;
diff --git a/os/hal/src/gpt.c b/os/hal/src/gpt.c index e90a8911a..5f424453d 100644 --- a/os/hal/src/gpt.c +++ b/os/hal/src/gpt.c @@ -137,8 +137,11 @@ void gptStartContinuous(GPTDriver *gptp, gptcnt_t interval) { */
void gptStartContinuousI(GPTDriver *gptp, gptcnt_t interval) {
+ chDbgCheckClassI();
+ chDbgCheck(gptp != NULL, "gptStartContinuousI");
chDbgAssert(gptp->state == GPT_READY,
"gptStartContinuousI(), #1", "invalid state");
+
gptp->state = GPT_CONTINUOUS;
gpt_lld_start_timer(gptp, interval);
}
@@ -168,8 +171,11 @@ void gptStartOneShot(GPTDriver *gptp, gptcnt_t interval) { */
void gptStartOneShotI(GPTDriver *gptp, gptcnt_t interval) {
+ chDbgCheckClassI();
+ chDbgCheck(gptp != NULL, "gptStartOneShotI");
chDbgAssert(gptp->state == GPT_READY,
"gptStartOneShotI(), #1", "invalid state");
+
gptp->state = GPT_ONESHOT;
gpt_lld_start_timer(gptp, interval);
}
@@ -197,9 +203,12 @@ void gptStopTimer(GPTDriver *gptp) { */
void gptStopTimerI(GPTDriver *gptp) {
+ chDbgCheckClassI();
+ chDbgCheck(gptp != NULL, "gptStopTimerI");
chDbgAssert((gptp->state == GPT_READY) || (gptp->state == GPT_CONTINUOUS) ||
(gptp->state == GPT_ONESHOT),
"gptStopTimerI(), #1", "invalid state");
+
gptp->state = GPT_READY;
gpt_lld_stop_timer(gptp);
}
@@ -220,6 +229,7 @@ void gptPolledDelay(GPTDriver *gptp, gptcnt_t interval) { chDbgAssert(gptp->state == GPT_READY,
"gptPolledDelay(), #1", "invalid state");
+
gptp->state = GPT_ONESHOT;
gpt_lld_polled_delay(gptp, interval);
}
diff --git a/os/hal/src/icu.c b/os/hal/src/icu.c index 3be67448e..79d38798e 100644 --- a/os/hal/src/icu.c +++ b/os/hal/src/icu.c @@ -121,6 +121,8 @@ void icuStop(ICUDriver *icup) { */
void icuEnable(ICUDriver *icup) {
+ chDbgCheck(icup != NULL, "icuEnable");
+
chSysLock();
chDbgAssert(icup->state == ICU_READY, "icuEnable(), #1", "invalid state");
icu_lld_enable(icup);
@@ -137,6 +139,8 @@ void icuEnable(ICUDriver *icup) { */
void icuDisable(ICUDriver *icup) {
+ chDbgCheck(icup != NULL, "icuDisable");
+
chSysLock();
chDbgAssert((icup->state == ICU_READY) || (icup->state == ICU_WAITING) ||
(icup->state == ICU_ACTIVE) || (icup->state == ICU_IDLE),
diff --git a/os/hal/src/serial.c b/os/hal/src/serial.c index 414689aac..03b74be54 100644 --- a/os/hal/src/serial.c +++ b/os/hal/src/serial.c @@ -207,6 +207,7 @@ void sdStop(SerialDriver *sdp) { */
void sdIncomingDataI(SerialDriver *sdp, uint8_t b) {
+ chDbgCheckClassI();
chDbgCheck(sdp != NULL, "sdIncomingDataI");
if (chIQIsEmptyI(&sdp->iqueue))
@@ -233,6 +234,7 @@ void sdIncomingDataI(SerialDriver *sdp, uint8_t b) { msg_t sdRequestDataI(SerialDriver *sdp) {
msg_t b;
+ chDbgCheckClassI();
chDbgCheck(sdp != NULL, "sdRequestDataI");
b = chOQGetI(&sdp->oqueue);
diff --git a/os/hal/src/uart.c b/os/hal/src/uart.c index 05fdbb168..372a3ad02 100644 --- a/os/hal/src/uart.c +++ b/os/hal/src/uart.c @@ -161,12 +161,13 @@ void uartStartSend(UARTDriver *uartp, size_t n, const void *txbuf) { */
void uartStartSendI(UARTDriver *uartp, size_t n, const void *txbuf) {
+ chDbgCheckClassI();
chDbgCheck((uartp != NULL) && (n > 0) && (txbuf != NULL),
"uartStartSendI");
-
chDbgAssert((uartp->state == UART_READY) &&
(uartp->txstate != UART_TX_ACTIVE),
"uartStartSendI(), #1", "not active");
+
uart_lld_start_send(uartp, n, txbuf);
uartp->txstate = UART_TX_ACTIVE;
}
@@ -216,8 +217,8 @@ size_t uartStopSend(UARTDriver *uartp) { */
size_t uartStopSendI(UARTDriver *uartp) {
+ chDbgCheckClassI();
chDbgCheck(uartp != NULL, "uartStopSendI");
-
chDbgAssert(uartp->state == UART_READY, "uartStopSendI(), #1", "not active");
if (uartp->txstate == UART_TX_ACTIVE) {
@@ -267,9 +268,9 @@ void uartStartReceive(UARTDriver *uartp, size_t n, void *rxbuf) { */
void uartStartReceiveI(UARTDriver *uartp, size_t n, void *rxbuf) {
+ chDbgCheckClassI();
chDbgCheck((uartp != NULL) && (n > 0) && (rxbuf != NULL),
"uartStartReceiveI");
-
chDbgAssert((uartp->state == UART_READY) && (uartp->rxstate == UART_RX_IDLE),
"uartStartReceiveI(), #1", "not active");
@@ -322,8 +323,9 @@ size_t uartStopReceive(UARTDriver *uartp) { * @iclass
*/
size_t uartStopReceiveI(UARTDriver *uartp) {
- chDbgCheck(uartp != NULL, "uartStopReceiveI");
+ chDbgCheckClassI();
+ chDbgCheck(uartp != NULL, "uartStopReceiveI");
chDbgAssert(uartp->state == UART_READY,
"uartStopReceiveI(), #1", "not active");
diff --git a/os/hal/src/usb.c b/os/hal/src/usb.c index 484590f3b..8493b6f41 100644 --- a/os/hal/src/usb.c +++ b/os/hal/src/usb.c @@ -301,6 +301,8 @@ void usbStop(USBDriver *usbp) { void usbInitEndpointI(USBDriver *usbp, usbep_t ep,
const USBEndpointConfig *epcp) {
+ chDbgCheckClassI();
+ chDbgCheck((usbp != NULL) && (epcp != NULL), "usbInitEndpointI");
chDbgAssert(usbp->state == USB_ACTIVE,
"usbEnableEndpointI(), #1", "invalid state");
chDbgAssert(usbp->epc[ep] != NULL,
@@ -331,6 +333,8 @@ void usbInitEndpointI(USBDriver *usbp, usbep_t ep, void usbDisableEndpointsI(USBDriver *usbp) {
unsigned i;
+ chDbgCheckClassI();
+ chDbgCheck(usbp != NULL, "usbDisableEndpointsI");
chDbgAssert(usbp->state == USB_SELECTED,
"usbDisableEndpointsI(), #1", "invalid state");
@@ -364,6 +368,9 @@ void usbDisableEndpointsI(USBDriver *usbp) { size_t usbReadPacketI(USBDriver *usbp, usbep_t ep,
uint8_t *buf, size_t n) {
+ chDbgCheckClassI();
+ chDbgCheck((usbp != NULL) && (buf != NULL), "usbReadPacketI");
+
if (usbGetReceiveStatusI(usbp, ep))
return USB_ENDPOINT_BUSY;
@@ -391,6 +398,9 @@ size_t usbReadPacketI(USBDriver *usbp, usbep_t ep, size_t usbWritePacketI(USBDriver *usbp, usbep_t ep,
const uint8_t *buf, size_t n) {
+ chDbgCheckClassI();
+ chDbgCheck((usbp != NULL) && (buf != NULL), "usbWritePacketI");
+
if (usbGetTransmitStatusI(usbp, ep))
return USB_ENDPOINT_BUSY;
@@ -419,6 +429,9 @@ size_t usbWritePacketI(USBDriver *usbp, usbep_t ep, bool_t usbStartReceiveI(USBDriver *usbp, usbep_t ep,
uint8_t *buf, size_t n) {
+ chDbgCheckClassI();
+ chDbgCheck((usbp != NULL) && (buf != NULL), "usbStartReceiveI");
+
if (usbGetReceiveStatusI(usbp, ep))
return TRUE;
@@ -447,6 +460,9 @@ bool_t usbStartReceiveI(USBDriver *usbp, usbep_t ep, bool_t usbStartTransmitI(USBDriver *usbp, usbep_t ep,
const uint8_t *buf, size_t n) {
+ chDbgCheckClassI();
+ chDbgCheck((usbp != NULL) && (buf != NULL), "usbStartTransmitI");
+
if (usbGetTransmitStatusI(usbp, ep))
return TRUE;
@@ -468,6 +484,9 @@ bool_t usbStartTransmitI(USBDriver *usbp, usbep_t ep, */
bool_t usbStallReceiveI(USBDriver *usbp, usbep_t ep) {
+ chDbgCheckClassI();
+ chDbgCheck(usbp != NULL, "usbStallReceiveI");
+
if (usbGetReceiveStatusI(usbp, ep))
return TRUE;
@@ -488,6 +507,9 @@ bool_t usbStallReceiveI(USBDriver *usbp, usbep_t ep) { */
bool_t usbStallTransmitI(USBDriver *usbp, usbep_t ep) {
+ chDbgCheckClassI();
+ chDbgCheck(usbp != NULL, "usbStallTransmitI");
+
if (usbGetTransmitStatusI(usbp, ep))
return TRUE;
|