HAL MISRA-related fixes.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8687 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
5c2d43e691
commit
788175c088
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
--- Module: ..\..\..\os\hal\src\hal.c (C)
|
--- Module: ..\..\..\os\hal\src\hal.c (C)
|
||||||
|
|
||||||
|
--- Module: ..\..\..\os\hal\src\hal_buffers.c (C)
|
||||||
|
|
||||||
--- Module: ..\..\..\os\hal\src\hal_queues.c (C)
|
--- Module: ..\..\..\os\hal\src\hal_queues.c (C)
|
||||||
|
|
||||||
--- Module: ..\..\..\os\hal\src\hal_mmcsd.c (C)
|
--- Module: ..\..\..\os\hal\src\hal_mmcsd.c (C)
|
||||||
|
@ -45,6 +47,8 @@
|
||||||
|
|
||||||
--- Module: ..\..\..\os\hal\src\usb.c (C)
|
--- Module: ..\..\..\os\hal\src\usb.c (C)
|
||||||
|
|
||||||
|
--- Module: ..\..\..\os\hal\src\wdg.c (C)
|
||||||
|
|
||||||
--- Module: ..\..\..\os\hal\templates\osal\osal.c (C)
|
--- Module: ..\..\..\os\hal\templates\osal\osal.c (C)
|
||||||
|
|
||||||
--- Module: ..\..\..\os\hal\templates\hal_lld.c (C)
|
--- Module: ..\..\..\os\hal\templates\hal_lld.c (C)
|
||||||
|
|
|
@ -132,7 +132,7 @@ typedef io_buffers_queue_t output_buffers_queue_t;
|
||||||
* @param[in] size size of the buffers
|
* @param[in] size size of the buffers
|
||||||
*/
|
*/
|
||||||
#define BQ_BUFFER_SIZE(n, size) \
|
#define BQ_BUFFER_SIZE(n, size) \
|
||||||
(((size_t)(size) + (sizeof (size_t)) * (size_t)(n)))
|
((size_t)(size) + ((sizeof (size_t)) * (size_t)(n)))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Macro Functions
|
* @name Macro Functions
|
||||||
|
@ -192,8 +192,10 @@ typedef io_buffers_queue_t output_buffers_queue_t;
|
||||||
*
|
*
|
||||||
* @iclass
|
* @iclass
|
||||||
*/
|
*/
|
||||||
#define ibqIsFullI(ibqp) ((bool)(((ibqp)->bwrptr == (ibqp)->brdptr) && \
|
#define ibqIsFullI(ibqp) \
|
||||||
((ibqp)->bcounter != 0U)))
|
/*lint -save -e9007 [13.5] No side effects, a pointer is passed.*/ \
|
||||||
|
((bool)(((ibqp)->bwrptr == (ibqp)->brdptr) && ((ibqp)->bcounter != 0U))) \
|
||||||
|
/*lint -restore*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Evaluates to @p true if the specified output buffers queue is empty.
|
* @brief Evaluates to @p true if the specified output buffers queue is empty.
|
||||||
|
@ -205,8 +207,10 @@ typedef io_buffers_queue_t output_buffers_queue_t;
|
||||||
*
|
*
|
||||||
* @iclass
|
* @iclass
|
||||||
*/
|
*/
|
||||||
#define obqIsEmptyI(obqp) ((bool)(((obqp)->bwrptr == (obqp)->brdptr) && \
|
#define obqIsEmptyI(obqp) \
|
||||||
((obqp)->bcounter != 0U)))
|
/*lint -save -e9007 [13.5] No side effects, a pointer is passed.*/ \
|
||||||
|
((bool)(((obqp)->bwrptr == (obqp)->brdptr) && ((obqp)->bcounter != 0U))) \
|
||||||
|
/*lint -restore*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Evaluates to @p true if the specified output buffers queue is full.
|
* @brief Evaluates to @p true if the specified output buffers queue is full.
|
||||||
|
@ -228,7 +232,7 @@ typedef io_buffers_queue_t output_buffers_queue_t;
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
void ibqObjectInit(io_buffers_queue_t *ibqp, uint8_t *bp,
|
void ibqObjectInit(input_buffers_queue_t *ibqp, uint8_t *bp,
|
||||||
size_t size, size_t n,
|
size_t size, size_t n,
|
||||||
bqnotify_t infy, void *link);
|
bqnotify_t infy, void *link);
|
||||||
void ibqResetI(input_buffers_queue_t *ibqp);
|
void ibqResetI(input_buffers_queue_t *ibqp);
|
||||||
|
|
|
@ -174,8 +174,10 @@ typedef io_queue_t input_queue_t;
|
||||||
*
|
*
|
||||||
* @iclass
|
* @iclass
|
||||||
*/
|
*/
|
||||||
#define iqIsFullI(iqp) ((bool)(((iqp)->q_wrptr == (iqp)->q_rdptr) && \
|
#define iqIsFullI(iqp) \
|
||||||
((iqp)->q_counter != 0U)))
|
/*lint -save -e9007 [13.5] No side effects, a pointer is passed.*/ \
|
||||||
|
((bool)(((iqp)->q_wrptr == (iqp)->q_rdptr) && ((iqp)->q_counter != 0U))) \
|
||||||
|
/*lint -restore*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Input queue read.
|
* @brief Input queue read.
|
||||||
|
@ -240,8 +242,10 @@ typedef io_queue_t output_queue_t;
|
||||||
*
|
*
|
||||||
* @iclass
|
* @iclass
|
||||||
*/
|
*/
|
||||||
#define oqIsEmptyI(oqp) ((bool)(((oqp)->q_wrptr == (oqp)->q_rdptr) && \
|
#define oqIsEmptyI(oqp) \
|
||||||
((oqp)->q_counter != 0U)))
|
/*lint -save -e9007 [13.5] No side effects, a pointer is passed.*/ \
|
||||||
|
((bool)(((oqp)->q_wrptr == (oqp)->q_rdptr) && ((oqp)->q_counter != 0U))) \
|
||||||
|
/*lint -restore*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Evaluates to @p true if the specified output queue is full.
|
* @brief Evaluates to @p true if the specified output queue is full.
|
||||||
|
|
|
@ -321,11 +321,11 @@ extern "C" {
|
||||||
size_t uartStopReceiveI(UARTDriver *uartp);
|
size_t uartStopReceiveI(UARTDriver *uartp);
|
||||||
#if UART_USE_WAIT == TRUE
|
#if UART_USE_WAIT == TRUE
|
||||||
msg_t uartSendTimeout(UARTDriver *uartp, size_t *np,
|
msg_t uartSendTimeout(UARTDriver *uartp, size_t *np,
|
||||||
const void *txbuf, systime_t time);
|
const void *txbuf, systime_t timeout);
|
||||||
msg_t uartSendFullTimeout(UARTDriver *uartp, size_t *np,
|
msg_t uartSendFullTimeout(UARTDriver *uartp, size_t *np,
|
||||||
const void *txbuf, systime_t time);
|
const void *txbuf, systime_t timeout);
|
||||||
msg_t uartReceiveTimeout(UARTDriver *uartp, size_t *np,
|
msg_t uartReceiveTimeout(UARTDriver *uartp, size_t *np,
|
||||||
void *rxbuf, systime_t time);
|
void *rxbuf, systime_t timeout);
|
||||||
#endif
|
#endif
|
||||||
#if UART_USE_MUTUAL_EXCLUSION == TRUE
|
#if UART_USE_MUTUAL_EXCLUSION == TRUE
|
||||||
void uartAcquireBus(UARTDriver *uartp);
|
void uartAcquireBus(UARTDriver *uartp);
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
typedef enum {
|
typedef enum {
|
||||||
WDG_UNINIT = 0, /**< Not initialized. */
|
WDG_UNINIT = 0, /**< Not initialized. */
|
||||||
WDG_STOP = 1, /**< Stopped. */
|
WDG_STOP = 1, /**< Stopped. */
|
||||||
WDG_READY = 2, /**< Ready. */
|
WDG_READY = 2 /**< Ready. */
|
||||||
} wdgstate_t;
|
} wdgstate_t;
|
||||||
|
|
||||||
#include "wdg_lld.h"
|
#include "wdg_lld.h"
|
||||||
|
|
|
@ -524,7 +524,7 @@ struct UARTDriver {
|
||||||
* @brief Current configuration data.
|
* @brief Current configuration data.
|
||||||
*/
|
*/
|
||||||
const UARTConfig *config;
|
const UARTConfig *config;
|
||||||
#if UART_USE_WAIT || defined(__DOXYGEN__)
|
#if (UART_USE_WAIT == TRUE) || defined(__DOXYGEN__)
|
||||||
/**
|
/**
|
||||||
* @brief Synchronization flag for transmit operations.
|
* @brief Synchronization flag for transmit operations.
|
||||||
*/
|
*/
|
||||||
|
@ -538,7 +538,7 @@ struct UARTDriver {
|
||||||
*/
|
*/
|
||||||
thread_reference_t threadtx;
|
thread_reference_t threadtx;
|
||||||
#endif /* UART_USE_WAIT */
|
#endif /* UART_USE_WAIT */
|
||||||
#if UART_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
|
#if (UART_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
|
||||||
/**
|
/**
|
||||||
* @brief Mutex protecting the peripheral.
|
* @brief Mutex protecting the peripheral.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -623,7 +623,7 @@ struct UARTDriver {
|
||||||
* @brief Current configuration data.
|
* @brief Current configuration data.
|
||||||
*/
|
*/
|
||||||
const UARTConfig *config;
|
const UARTConfig *config;
|
||||||
#if UART_USE_WAIT || defined(__DOXYGEN__)
|
#if (UART_USE_WAIT == TRUE) || defined(__DOXYGEN__)
|
||||||
/**
|
/**
|
||||||
* @brief Synchronization flag for transmit operations.
|
* @brief Synchronization flag for transmit operations.
|
||||||
*/
|
*/
|
||||||
|
@ -637,7 +637,7 @@ struct UARTDriver {
|
||||||
*/
|
*/
|
||||||
thread_reference_t threadtx;
|
thread_reference_t threadtx;
|
||||||
#endif /* UART_USE_WAIT */
|
#endif /* UART_USE_WAIT */
|
||||||
#if UART_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
|
#if (UART_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
|
||||||
/**
|
/**
|
||||||
* @brief Mutex protecting the peripheral.
|
* @brief Mutex protecting the peripheral.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
#if HAL_USE_WDG || defined(__DOXYGEN__)
|
#if (HAL_USE_WDG == TRUE) || defined(__DOXYGEN__)
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver local definitions. */
|
/* Driver local definitions. */
|
||||||
|
@ -135,6 +135,6 @@ void wdg_lld_reset(WDGDriver * wdgp) {
|
||||||
wdgp->wdg->KR = KR_KEY_RELOAD;
|
wdgp->wdg->KR = KR_KEY_RELOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAL_USE_WDG */
|
#endif /* HAL_USE_WDG == TRUE */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#ifndef _WDG_LLD_H_
|
#ifndef _WDG_LLD_H_
|
||||||
#define _WDG_LLD_H_
|
#define _WDG_LLD_H_
|
||||||
|
|
||||||
#if HAL_USE_WDG || defined(__DOXYGEN__)
|
#if (HAL_USE_WDG == TRUE) || defined(__DOXYGEN__)
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver constants. */
|
/* Driver constants. */
|
||||||
|
@ -176,7 +176,7 @@ extern "C" {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* HAL_USE_WDG */
|
#endif /* HAL_USE_WDG == TRUE */
|
||||||
|
|
||||||
#endif /* _WDG_LLD_H_ */
|
#endif /* _WDG_LLD_H_ */
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ void ibqObjectInit(input_buffers_queue_t *ibqp, uint8_t *bp,
|
||||||
size_t size, size_t n,
|
size_t size, size_t n,
|
||||||
bqnotify_t infy, void *link) {
|
bqnotify_t infy, void *link) {
|
||||||
|
|
||||||
osalDbgCheck((ibqp != NULL) && (bp != NULL) && (size >= 2));
|
osalDbgCheck((ibqp != NULL) && (bp != NULL) && (size >= 2U));
|
||||||
|
|
||||||
osalThreadQueueObjectInit(&ibqp->waiting);
|
osalThreadQueueObjectInit(&ibqp->waiting);
|
||||||
ibqp->bcounter = 0;
|
ibqp->bcounter = 0;
|
||||||
|
@ -148,7 +148,7 @@ void ibqPostFullBufferI(input_buffers_queue_t *ibqp, size_t size) {
|
||||||
|
|
||||||
osalDbgCheckClassI();
|
osalDbgCheckClassI();
|
||||||
|
|
||||||
osalDbgCheck((size > 0) && (size <= ibqp->bsize - sizeof (size_t)));
|
osalDbgCheck((size > 0U) && (size <= (ibqp->bsize - sizeof (size_t))));
|
||||||
osalDbgAssert(!ibqIsFullI(ibqp), "buffers queue full");
|
osalDbgAssert(!ibqIsFullI(ibqp), "buffers queue full");
|
||||||
|
|
||||||
/* Writing size field in the buffer.*/
|
/* Writing size field in the buffer.*/
|
||||||
|
@ -314,7 +314,7 @@ msg_t ibqGetTimeout(input_buffers_queue_t *ibqp, systime_t timeout) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Next byte from the buffer.*/
|
/* Next byte from the buffer.*/
|
||||||
msg = *ibqp->ptr;
|
msg = (msg_t)*ibqp->ptr;
|
||||||
ibqp->ptr++;
|
ibqp->ptr++;
|
||||||
|
|
||||||
/* If the current buffer has been fully read then it is returned as
|
/* If the current buffer has been fully read then it is returned as
|
||||||
|
@ -396,19 +396,19 @@ size_t ibqReadTimeout(input_buffers_queue_t *ibqp, uint8_t *bp,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Size of the data chunk present in the current buffer.*/
|
/* Size of the data chunk present in the current buffer.*/
|
||||||
size = ibqp->top - ibqp->ptr;
|
size = (size_t)ibqp->top - (size_t)ibqp->ptr;
|
||||||
if (size > n - r) {
|
if (size > (n - r)) {
|
||||||
size = n - r;
|
size = n - r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Smaller chunks in order to not make the critical zone too long,
|
/* Smaller chunks in order to not make the critical zone too long,
|
||||||
this impacts throughput however.*/
|
this impacts throughput however.*/
|
||||||
if (size > 64) {
|
if (size > 64U) {
|
||||||
/* Giving the compiler a chance to optimize for a fixed size move.*/
|
/* Giving the compiler a chance to optimize for a fixed size move.*/
|
||||||
memcpy(bp, ibqp->ptr, 64);
|
memcpy(bp, ibqp->ptr, 64U);
|
||||||
bp += 64;
|
bp += 64U;
|
||||||
ibqp->ptr += 64;
|
ibqp->ptr += 64U;
|
||||||
r += 64;
|
r += 64U;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
memcpy(bp, ibqp->ptr, size);
|
memcpy(bp, ibqp->ptr, size);
|
||||||
|
@ -447,7 +447,7 @@ void obqObjectInit(output_buffers_queue_t *obqp, uint8_t *bp,
|
||||||
size_t size, size_t n,
|
size_t size, size_t n,
|
||||||
bqnotify_t onfy, void *link) {
|
bqnotify_t onfy, void *link) {
|
||||||
|
|
||||||
osalDbgCheck((obqp != NULL) && (bp != NULL) && (size >= 2));
|
osalDbgCheck((obqp != NULL) && (bp != NULL) && (size >= 2U));
|
||||||
|
|
||||||
osalThreadQueueObjectInit(&obqp->waiting);
|
osalThreadQueueObjectInit(&obqp->waiting);
|
||||||
obqp->bcounter = n;
|
obqp->bcounter = n;
|
||||||
|
@ -635,7 +635,7 @@ void obqPostFullBuffer(output_buffers_queue_t *obqp, size_t size) {
|
||||||
void obqPostFullBufferS(output_buffers_queue_t *obqp, size_t size) {
|
void obqPostFullBufferS(output_buffers_queue_t *obqp, size_t size) {
|
||||||
|
|
||||||
osalDbgCheckClassS();
|
osalDbgCheckClassS();
|
||||||
osalDbgCheck((size > 0) && (size <= obqp->bsize - sizeof (size_t)));
|
osalDbgCheck((size > 0U) && (size <= (obqp->bsize - sizeof (size_t))));
|
||||||
osalDbgAssert(!obqIsFullI(obqp), "buffers queue full");
|
osalDbgAssert(!obqIsFullI(obqp), "buffers queue full");
|
||||||
|
|
||||||
/* Writing size field in the buffer.*/
|
/* Writing size field in the buffer.*/
|
||||||
|
@ -774,19 +774,19 @@ size_t obqWriteTimeout(output_buffers_queue_t *obqp, const uint8_t *bp,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Size of the space available in the current buffer.*/
|
/* Size of the space available in the current buffer.*/
|
||||||
size = obqp->top - obqp->ptr;
|
size = (size_t)obqp->top - (size_t)obqp->ptr;
|
||||||
if (size > n - w) {
|
if (size > (n - w)) {
|
||||||
size = n - w;
|
size = n - w;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Smaller chunks in order to not make the critical zone too long,
|
/* Smaller chunks in order to not make the critical zone too long,
|
||||||
this impacts throughput however.*/
|
this impacts throughput however.*/
|
||||||
if (size > 64) {
|
if (size > 64U) {
|
||||||
/* Giving the compiler a chance to optimize for a fixed size move.*/
|
/* Giving the compiler a chance to optimize for a fixed size move.*/
|
||||||
memcpy(obqp->ptr, bp, 64);
|
memcpy(obqp->ptr, bp, 64U);
|
||||||
bp += 64;
|
bp += 64U;
|
||||||
obqp->ptr += 64;
|
obqp->ptr += 64U;
|
||||||
w += 64;
|
w += 64U;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
memcpy(obqp->ptr, bp, size);
|
memcpy(obqp->ptr, bp, size);
|
||||||
|
@ -829,7 +829,7 @@ bool obqTryFlushI(output_buffers_queue_t *obqp) {
|
||||||
/* If queue is empty and there is a buffer partially filled and
|
/* If queue is empty and there is a buffer partially filled and
|
||||||
it is not being written.*/
|
it is not being written.*/
|
||||||
if (obqIsEmptyI(obqp) && (obqp->ptr != NULL)) {
|
if (obqIsEmptyI(obqp) && (obqp->ptr != NULL)) {
|
||||||
size_t size = (size_t)(obqp->ptr - (obqp->bwrptr + sizeof (size_t)));
|
size_t size = (size_t)obqp->ptr - ((size_t)obqp->bwrptr + sizeof (size_t));
|
||||||
|
|
||||||
if (size > 0U) {
|
if (size > 0U) {
|
||||||
|
|
||||||
|
@ -865,7 +865,7 @@ void obqFlush(output_buffers_queue_t *obqp) {
|
||||||
|
|
||||||
/* If there is a buffer partially filled and not being written.*/
|
/* If there is a buffer partially filled and not being written.*/
|
||||||
if (obqp->ptr != NULL) {
|
if (obqp->ptr != NULL) {
|
||||||
size_t size = (size_t)(obqp->ptr - obqp->bwrptr);
|
size_t size = (size_t)obqp->ptr - (size_t)obqp->bwrptr;
|
||||||
|
|
||||||
if (size > 0U) {
|
if (size > 0U) {
|
||||||
obqPostFullBufferS(obqp, size);
|
obqPostFullBufferS(obqp, size);
|
||||||
|
|
|
@ -56,8 +56,9 @@ static cdc_linecoding_t linecoding = {
|
||||||
|
|
||||||
static size_t write(void *ip, const uint8_t *bp, size_t n) {
|
static size_t write(void *ip, const uint8_t *bp, size_t n) {
|
||||||
|
|
||||||
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE)
|
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return obqWriteTimeout(&((SerialUSBDriver *)ip)->obqueue, bp,
|
return obqWriteTimeout(&((SerialUSBDriver *)ip)->obqueue, bp,
|
||||||
n, TIME_INFINITE);
|
n, TIME_INFINITE);
|
||||||
|
@ -65,8 +66,9 @@ static size_t write(void *ip, const uint8_t *bp, size_t n) {
|
||||||
|
|
||||||
static size_t read(void *ip, uint8_t *bp, size_t n) {
|
static size_t read(void *ip, uint8_t *bp, size_t n) {
|
||||||
|
|
||||||
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE)
|
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return ibqReadTimeout(&((SerialUSBDriver *)ip)->ibqueue, bp,
|
return ibqReadTimeout(&((SerialUSBDriver *)ip)->ibqueue, bp,
|
||||||
n, TIME_INFINITE);
|
n, TIME_INFINITE);
|
||||||
|
@ -74,48 +76,54 @@ static size_t read(void *ip, uint8_t *bp, size_t n) {
|
||||||
|
|
||||||
static msg_t put(void *ip, uint8_t b) {
|
static msg_t put(void *ip, uint8_t b) {
|
||||||
|
|
||||||
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE)
|
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE) {
|
||||||
return MSG_RESET;
|
return MSG_RESET;
|
||||||
|
}
|
||||||
|
|
||||||
return obqPutTimeout(&((SerialUSBDriver *)ip)->obqueue, b, TIME_INFINITE);
|
return obqPutTimeout(&((SerialUSBDriver *)ip)->obqueue, b, TIME_INFINITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static msg_t get(void *ip) {
|
static msg_t get(void *ip) {
|
||||||
|
|
||||||
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE)
|
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE) {
|
||||||
return MSG_RESET;
|
return MSG_RESET;
|
||||||
|
}
|
||||||
|
|
||||||
return ibqGetTimeout(&((SerialUSBDriver *)ip)->ibqueue, TIME_INFINITE);
|
return ibqGetTimeout(&((SerialUSBDriver *)ip)->ibqueue, TIME_INFINITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static msg_t putt(void *ip, uint8_t b, systime_t timeout) {
|
static msg_t putt(void *ip, uint8_t b, systime_t timeout) {
|
||||||
|
|
||||||
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE)
|
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE) {
|
||||||
return MSG_RESET;
|
return MSG_RESET;
|
||||||
|
}
|
||||||
|
|
||||||
return obqPutTimeout(&((SerialUSBDriver *)ip)->obqueue, b, timeout);
|
return obqPutTimeout(&((SerialUSBDriver *)ip)->obqueue, b, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static msg_t gett(void *ip, systime_t timeout) {
|
static msg_t gett(void *ip, systime_t timeout) {
|
||||||
|
|
||||||
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE)
|
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE) {
|
||||||
return MSG_RESET;
|
return MSG_RESET;
|
||||||
|
}
|
||||||
|
|
||||||
return ibqGetTimeout(&((SerialUSBDriver *)ip)->ibqueue, timeout);
|
return ibqGetTimeout(&((SerialUSBDriver *)ip)->ibqueue, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t writet(void *ip, const uint8_t *bp, size_t n, systime_t timeout) {
|
static size_t writet(void *ip, const uint8_t *bp, size_t n, systime_t timeout) {
|
||||||
|
|
||||||
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE)
|
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return obqWriteTimeout(&((SerialUSBDriver *)ip)->obqueue, bp, n, timeout);
|
return obqWriteTimeout(&((SerialUSBDriver *)ip)->obqueue, bp, n, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t timeout) {
|
static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t timeout) {
|
||||||
|
|
||||||
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE)
|
if (usbGetDriverStateI(((SerialUSBDriver *)ip)->config->usbp) != USB_ACTIVE) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return ibqReadTimeout(&((SerialUSBDriver *)ip)->ibqueue, bp, n, timeout);
|
return ibqReadTimeout(&((SerialUSBDriver *)ip)->ibqueue, bp, n, timeout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,12 +71,12 @@ void uartObjectInit(UARTDriver *uartp) {
|
||||||
uartp->txstate = UART_TX_IDLE;
|
uartp->txstate = UART_TX_IDLE;
|
||||||
uartp->rxstate = UART_RX_IDLE;
|
uartp->rxstate = UART_RX_IDLE;
|
||||||
uartp->config = NULL;
|
uartp->config = NULL;
|
||||||
#if UART_USE_WAIT || defined(__DOXYGEN__)
|
#if UART_USE_WAIT == TRUE
|
||||||
uartp->early = false;
|
uartp->early = false;
|
||||||
uartp->threadrx = NULL;
|
uartp->threadrx = NULL;
|
||||||
uartp->threadtx = NULL;
|
uartp->threadtx = NULL;
|
||||||
#endif /* UART_USE_WAIT */
|
#endif /* UART_USE_WAIT */
|
||||||
#if UART_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
|
#if UART_USE_MUTUAL_EXCLUSION == TRUE
|
||||||
osalMutexObjectInit(&uartp->mutex);
|
osalMutexObjectInit(&uartp->mutex);
|
||||||
#endif /* UART_USE_MUTUAL_EXCLUSION */
|
#endif /* UART_USE_MUTUAL_EXCLUSION */
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ size_t uartStopReceiveI(UARTDriver *uartp) {
|
||||||
* @param[in,out] np number of data frames to transmit, on exit the number
|
* @param[in,out] np number of data frames to transmit, on exit the number
|
||||||
* of frames actually transmitted
|
* of frames actually transmitted
|
||||||
* @param[in] txbuf the pointer to the transmit buffer
|
* @param[in] txbuf the pointer to the transmit buffer
|
||||||
* @param[in] time operation timeout
|
* @param[in] timeout operation timeout
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval MSG_OK if the operation completed successfully.
|
* @retval MSG_OK if the operation completed successfully.
|
||||||
* @retval MSG_TIMEOUT if the operation timed out.
|
* @retval MSG_TIMEOUT if the operation timed out.
|
||||||
|
@ -362,7 +362,7 @@ size_t uartStopReceiveI(UARTDriver *uartp) {
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
msg_t uartSendTimeout(UARTDriver *uartp, size_t *np,
|
msg_t uartSendTimeout(UARTDriver *uartp, size_t *np,
|
||||||
const void *txbuf, systime_t time) {
|
const void *txbuf, systime_t timeout) {
|
||||||
msg_t msg;
|
msg_t msg;
|
||||||
|
|
||||||
osalDbgCheck((uartp != NULL) && (*np > 0U) && (txbuf != NULL));
|
osalDbgCheck((uartp != NULL) && (*np > 0U) && (txbuf != NULL));
|
||||||
|
@ -377,7 +377,7 @@ msg_t uartSendTimeout(UARTDriver *uartp, size_t *np,
|
||||||
uartp->txstate = UART_TX_ACTIVE;
|
uartp->txstate = UART_TX_ACTIVE;
|
||||||
|
|
||||||
/* Waiting for result.*/
|
/* Waiting for result.*/
|
||||||
msg = osalThreadSuspendTimeoutS(&uartp->threadtx, time);
|
msg = osalThreadSuspendTimeoutS(&uartp->threadtx, timeout);
|
||||||
if (msg != MSG_OK) {
|
if (msg != MSG_OK) {
|
||||||
*np = uartStopSendI(uartp);
|
*np = uartStopSendI(uartp);
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ msg_t uartSendTimeout(UARTDriver *uartp, size_t *np,
|
||||||
* @param[in,out] np number of data frames to transmit, on exit the number
|
* @param[in,out] np number of data frames to transmit, on exit the number
|
||||||
* of frames actually transmitted
|
* of frames actually transmitted
|
||||||
* @param[in] txbuf the pointer to the transmit buffer
|
* @param[in] txbuf the pointer to the transmit buffer
|
||||||
* @param[in] time operation timeout
|
* @param[in] timeout operation timeout
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval MSG_OK if the operation completed successfully.
|
* @retval MSG_OK if the operation completed successfully.
|
||||||
* @retval MSG_TIMEOUT if the operation timed out.
|
* @retval MSG_TIMEOUT if the operation timed out.
|
||||||
|
@ -405,7 +405,7 @@ msg_t uartSendTimeout(UARTDriver *uartp, size_t *np,
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
msg_t uartSendFullTimeout(UARTDriver *uartp, size_t *np,
|
msg_t uartSendFullTimeout(UARTDriver *uartp, size_t *np,
|
||||||
const void *txbuf, systime_t time) {
|
const void *txbuf, systime_t timeout) {
|
||||||
msg_t msg;
|
msg_t msg;
|
||||||
|
|
||||||
osalDbgCheck((uartp != NULL) && (*np > 0U) && (txbuf != NULL));
|
osalDbgCheck((uartp != NULL) && (*np > 0U) && (txbuf != NULL));
|
||||||
|
@ -420,7 +420,7 @@ msg_t uartSendFullTimeout(UARTDriver *uartp, size_t *np,
|
||||||
uartp->txstate = UART_TX_ACTIVE;
|
uartp->txstate = UART_TX_ACTIVE;
|
||||||
|
|
||||||
/* Waiting for result.*/
|
/* Waiting for result.*/
|
||||||
msg = osalThreadSuspendTimeoutS(&uartp->threadtx, time);
|
msg = osalThreadSuspendTimeoutS(&uartp->threadtx, timeout);
|
||||||
if (msg != MSG_OK) {
|
if (msg != MSG_OK) {
|
||||||
*np = uartStopSendI(uartp);
|
*np = uartStopSendI(uartp);
|
||||||
}
|
}
|
||||||
|
@ -440,7 +440,7 @@ msg_t uartSendFullTimeout(UARTDriver *uartp, size_t *np,
|
||||||
* @param[in,out] np number of data frames to receive, on exit the number
|
* @param[in,out] np number of data frames to receive, on exit the number
|
||||||
* of frames actually received
|
* of frames actually received
|
||||||
* @param[in] rxbuf the pointer to the receive buffer
|
* @param[in] rxbuf the pointer to the receive buffer
|
||||||
* @param[in] time operation timeout
|
* @param[in] timeout operation timeout
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval MSG_OK if the operation completed successfully.
|
* @retval MSG_OK if the operation completed successfully.
|
||||||
|
@ -450,7 +450,7 @@ msg_t uartSendFullTimeout(UARTDriver *uartp, size_t *np,
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
msg_t uartReceiveTimeout(UARTDriver *uartp, size_t *np,
|
msg_t uartReceiveTimeout(UARTDriver *uartp, size_t *np,
|
||||||
void *rxbuf, systime_t time) {
|
void *rxbuf, systime_t timeout) {
|
||||||
msg_t msg;
|
msg_t msg;
|
||||||
|
|
||||||
osalDbgCheck((uartp != NULL) && (*np > 0U) && (rxbuf != NULL));
|
osalDbgCheck((uartp != NULL) && (*np > 0U) && (rxbuf != NULL));
|
||||||
|
@ -464,7 +464,7 @@ msg_t uartReceiveTimeout(UARTDriver *uartp, size_t *np,
|
||||||
uartp->rxstate = UART_RX_ACTIVE;
|
uartp->rxstate = UART_RX_ACTIVE;
|
||||||
|
|
||||||
/* Waiting for result.*/
|
/* Waiting for result.*/
|
||||||
msg = osalThreadSuspendTimeoutS(&uartp->threadrx, time);
|
msg = osalThreadSuspendTimeoutS(&uartp->threadrx, timeout);
|
||||||
if (msg != MSG_OK) {
|
if (msg != MSG_OK) {
|
||||||
*np = uartStopReceiveI(uartp);
|
*np = uartStopReceiveI(uartp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,14 +419,16 @@ void usbStartReceiveI(USBDriver *usbp, usbep_t ep,
|
||||||
USBOutEndpointState *osp;
|
USBOutEndpointState *osp;
|
||||||
|
|
||||||
osalDbgCheckClassI();
|
osalDbgCheckClassI();
|
||||||
osalDbgCheck((usbp != NULL) && (ep <= USB_MAX_ENDPOINTS));
|
osalDbgCheck((usbp != NULL) && (ep <= (usbep_t)USB_MAX_ENDPOINTS));
|
||||||
osalDbgAssert(!usbGetReceiveStatusI(usbp, ep), "already receiving");
|
osalDbgAssert(!usbGetReceiveStatusI(usbp, ep), "already receiving");
|
||||||
|
|
||||||
/* Marking the endpoint as active.*/
|
/* Marking the endpoint as active.*/
|
||||||
usbp->receiving |= (uint16_t)((unsigned)1U << (unsigned)ep);
|
usbp->receiving |= (uint16_t)((unsigned)1U << (unsigned)ep);
|
||||||
|
|
||||||
/* Setting up the transfer.*/
|
/* Setting up the transfer.*/
|
||||||
|
/*lint -save -e661 [18.1] pclint is confused by the check on ep.*/
|
||||||
osp = usbp->epc[ep]->out_state;
|
osp = usbp->epc[ep]->out_state;
|
||||||
|
/*lint -restore*/
|
||||||
osp->rxbuf = buf;
|
osp->rxbuf = buf;
|
||||||
osp->rxsize = n;
|
osp->rxsize = n;
|
||||||
osp->rxcnt = 0;
|
osp->rxcnt = 0;
|
||||||
|
@ -456,14 +458,16 @@ void usbStartTransmitI(USBDriver *usbp, usbep_t ep,
|
||||||
USBInEndpointState *isp;
|
USBInEndpointState *isp;
|
||||||
|
|
||||||
osalDbgCheckClassI();
|
osalDbgCheckClassI();
|
||||||
osalDbgCheck((usbp != NULL) && (ep <= USB_MAX_ENDPOINTS));
|
osalDbgCheck((usbp != NULL) && (ep <= (usbep_t)USB_MAX_ENDPOINTS));
|
||||||
osalDbgAssert(!usbGetTransmitStatusI(usbp, ep), "already transmitting");
|
osalDbgAssert(!usbGetTransmitStatusI(usbp, ep), "already transmitting");
|
||||||
|
|
||||||
/* Marking the endpoint as active.*/
|
/* Marking the endpoint as active.*/
|
||||||
usbp->transmitting |= (uint16_t)((unsigned)1U << (unsigned)ep);
|
usbp->transmitting |= (uint16_t)((unsigned)1U << (unsigned)ep);
|
||||||
|
|
||||||
/* Setting up the transfer.*/
|
/* Setting up the transfer.*/
|
||||||
|
/*lint -save -e661 [18.1] pclint is confused by the check on ep.*/
|
||||||
isp = usbp->epc[ep]->in_state;
|
isp = usbp->epc[ep]->in_state;
|
||||||
|
/*lint -restore*/
|
||||||
isp->txbuf = buf;
|
isp->txbuf = buf;
|
||||||
isp->txsize = n;
|
isp->txsize = n;
|
||||||
isp->txcnt = 0;
|
isp->txcnt = 0;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
#if HAL_USE_WDG || defined(__DOXYGEN__)
|
#if (HAL_USE_WDG == TRUE) || defined(__DOXYGEN__)
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver local definitions. */
|
/* Driver local definitions. */
|
||||||
|
@ -115,6 +115,6 @@ void wdgReset(WDGDriver *wdgp) {
|
||||||
osalSysUnlock();
|
osalSysUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAL_USE_WDG */
|
#endif /* HAL_USE_WDG == TRUE */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -42,13 +42,13 @@
|
||||||
/**
|
/**
|
||||||
* @brief Width, in bits, of an I/O port.
|
* @brief Width, in bits, of an I/O port.
|
||||||
*/
|
*/
|
||||||
#define PAL_IOPORTS_WIDTH 16
|
#define PAL_IOPORTS_WIDTH 16U
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Whole port mask.
|
* @brief Whole port mask.
|
||||||
* @details This macro specifies all the valid bits into a port.
|
* @details This macro specifies all the valid bits into a port.
|
||||||
*/
|
*/
|
||||||
#define PAL_WHOLE_PORT ((ioportmask_t)0xFFFF)
|
#define PAL_WHOLE_PORT ((ioportmask_t)0xFFFFU)
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -143,7 +143,7 @@ struct UARTDriver {
|
||||||
* @brief Current configuration data.
|
* @brief Current configuration data.
|
||||||
*/
|
*/
|
||||||
const UARTConfig *config;
|
const UARTConfig *config;
|
||||||
#if UART_USE_WAIT || defined(__DOXYGEN__)
|
#if (UART_USE_WAIT == TRUE) || defined(__DOXYGEN__)
|
||||||
/**
|
/**
|
||||||
* @brief Synchronization flag for transmit operations.
|
* @brief Synchronization flag for transmit operations.
|
||||||
*/
|
*/
|
||||||
|
@ -157,7 +157,7 @@ struct UARTDriver {
|
||||||
*/
|
*/
|
||||||
thread_reference_t threadtx;
|
thread_reference_t threadtx;
|
||||||
#endif /* UART_USE_WAIT */
|
#endif /* UART_USE_WAIT */
|
||||||
#if UART_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
|
#if (UART_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
|
||||||
/**
|
/**
|
||||||
* @brief Mutex protecting the peripheral.
|
* @brief Mutex protecting the peripheral.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#ifndef _WDG_LLD_H_
|
#ifndef _WDG_LLD_H_
|
||||||
#define _WDG_LLD_H_
|
#define _WDG_LLD_H_
|
||||||
|
|
||||||
#if HAL_USE_WDG || defined(__DOXYGEN__)
|
#if (HAL_USE_WDG == TRUE) || defined(__DOXYGEN__)
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver constants. */
|
/* Driver constants. */
|
||||||
|
@ -91,7 +91,7 @@ struct WDGDriver {
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#if PLATFORM_WDG_USE_WDG1 && !defined(__DOXYGEN__)
|
#if (PLATFORM_WDG_USE_WDG1 == TRUE) && !defined(__DOXYGEN__)
|
||||||
extern WDGDriver WDGD1;
|
extern WDGDriver WDGD1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ extern "C" {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* HAL_USE_WDG */
|
#endif /* HAL_USE_WDG == TRUE */
|
||||||
|
|
||||||
#endif /* _WDG_LLD_H_ */
|
#endif /* _WDG_LLD_H_ */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue