git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@16292 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
960abcdabb
commit
310f748fb4
|
@ -49,7 +49,8 @@
|
|||
/* Module local functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
static void vuart_cb(SIODriver *siop) {
|
||||
static void vuart_cb(void *ip) {
|
||||
hal_sio_driver_c *siop = (hal_sio_driver_c *)ip;
|
||||
const vio_uart_unit_t *unitp = (const vio_uart_unit_t *)drvGetArgumentX(siop);
|
||||
|
||||
sbVRQTriggerFromISR(unitp->vrqsb, unitp->vrqn);
|
||||
|
@ -86,7 +87,7 @@ void sb_sysc_vio_uart(struct port_extctx *ectxp) {
|
|||
|
||||
/* Starting with disabled events, enabling the callback.*/
|
||||
sioWriteEnableFlags(unitp->siop, SIO_EV_NONE);
|
||||
sioSetCallbackX(unitp->siop, vuart_cb);
|
||||
drvSetCallbackX(unitp->siop, vuart_cb);
|
||||
}
|
||||
|
||||
ectxp->r0 = (uint32_t)msg;
|
||||
|
|
|
@ -116,20 +116,13 @@ drv_reg_remove(self);
|
|||
<brief>Low level driver stop.</brief>
|
||||
<notapi />
|
||||
</method>
|
||||
<method name="drvConfigureX" shortname="configure"
|
||||
ctype="msg_t">
|
||||
<brief>Driver configure.</brief>
|
||||
<details><![CDATA[Applies a new configuration to the driver. The
|
||||
configuration structure is architecture-dependent.]]>
|
||||
</details>
|
||||
<note><![CDATA[Applying a configuration should be done while the
|
||||
peripheral is not actively operating, this function can fail
|
||||
depending on the driver implementation and current state.]]>
|
||||
</note>
|
||||
<param ctype="const void *" name="config" dir="in">
|
||||
New driver
|
||||
configuration.
|
||||
</param>
|
||||
<method name="__drv_do_configure" shortname="doconf"
|
||||
ctype="const void *">
|
||||
<brief>Performs driver configuration.</brief>
|
||||
<param ctype="const void *" name="config" dir="in">New driver
|
||||
configuration.</param>
|
||||
<return>The configuration pointer.</return>
|
||||
<retval value="NULL">If the configuration has been rejected.</retval>
|
||||
<api />
|
||||
</method>
|
||||
</virtual>
|
||||
|
@ -216,6 +209,38 @@ if ((self->state != HAL_DRV_STATE_STOP) &&
|
|||
|
||||
osalSysUnlock();]]></implementation>
|
||||
</method>
|
||||
<method name="drvConfigureX" ctype="msg_t">
|
||||
<brief>Driver configure.</brief>
|
||||
<details><![CDATA[Applies a new configuration to the driver. The
|
||||
configuration structure is architecture-dependent.]]>
|
||||
</details>
|
||||
<note><![CDATA[Applying a configuration should be done while the
|
||||
peripheral is not actively operating, this function can fail
|
||||
depending on the driver implementation and current state.]]>
|
||||
</note>
|
||||
<param ctype="const void *" name="config" dir="in">New driver
|
||||
configuration.
|
||||
</param>
|
||||
<api />
|
||||
<implementation><![CDATA[]]>
|
||||
msg_t msg;
|
||||
|
||||
osalSysLock();
|
||||
|
||||
osalDbgAssert(self->state != HAL_DRV_STATE_UNINIT, "invalid state");
|
||||
|
||||
self->config = __drv_do_configure(self, config);
|
||||
if (self->config == NULL) {
|
||||
msg = HAL_RET_CONFIG_ERROR;
|
||||
}
|
||||
else {
|
||||
msg = HAL_RET_SUCCESS;
|
||||
}
|
||||
|
||||
osalSysUnlock();
|
||||
|
||||
return msg;</implementation>
|
||||
</method>
|
||||
</regular>
|
||||
<inline>
|
||||
<method name="drvGetStateX" ctype="driver_state_t">
|
||||
|
@ -228,8 +253,7 @@ return self->state;]]></implementation>
|
|||
</method>
|
||||
<method name="drvSetStateX" ctype="void">
|
||||
<brief>Driver state set.</brief>
|
||||
<param ctype="driver_state_t" name="state" dir="in">
|
||||
New driver
|
||||
<param ctype="driver_state_t" name="state" dir="in">New driver
|
||||
state.
|
||||
</param>
|
||||
<api />
|
||||
|
@ -247,8 +271,7 @@ return self->arg;]]></implementation>
|
|||
</method>
|
||||
<method name="drvSetArgumentX" ctype="void">
|
||||
<brief>Driver argument set.</brief>
|
||||
<param ctype="void *" name="arg" dir="in">
|
||||
New driver argument.
|
||||
<param ctype="void *" name="arg" dir="in">New driver argument.
|
||||
</param>
|
||||
<api />
|
||||
<implementation><![CDATA[
|
||||
|
@ -299,6 +322,7 @@ osalMutexLock(&self->mutex);]]></implementation>
|
|||
osalMutexUnlock(&self->mutex);]]></implementation>
|
||||
</method>
|
||||
</condition>
|
||||
|
||||
</inline>
|
||||
</methods>
|
||||
</class>
|
||||
|
|
|
@ -70,7 +70,7 @@ self->cb = NULL;]]></implementation>
|
|||
<implementation><![CDATA[ ]]></implementation>
|
||||
</dispose>
|
||||
<virtual>
|
||||
<method name="drvSetCallback" ctype="void" shortname="setcb">
|
||||
<method name="drvSetCallbackX" ctype="void" shortname="setcb">
|
||||
<brief>
|
||||
Associates a callback to the driver instance.
|
||||
</brief>
|
||||
|
@ -78,14 +78,16 @@ self->cb = NULL;]]></implementation>
|
|||
Callback function to be associated. Passing @p NULL
|
||||
disables the existing callback, if any.
|
||||
</param>
|
||||
<xclass />
|
||||
<implementation><![CDATA[
|
||||
|
||||
self->cb = cb;]]></implementation>
|
||||
</method>
|
||||
</virtual>
|
||||
<inline>
|
||||
<method name="drvGetCallback" ctype="hal_cb_t">
|
||||
<method name="drvGetCallbackX" ctype="hal_cb_t">
|
||||
<brief>Returns the callback associated to the driver instance.</brief>
|
||||
<xclass />
|
||||
<implementation><![CDATA[
|
||||
|
||||
return self->cb;]]></implementation>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
name="hal_sio" descr="SIO Driver" check="HAL_USE_SIO == TRUE" editcode="false">
|
||||
<brief>SIO Driver macros and structures.</brief>
|
||||
<imports>
|
||||
<import>hal_base_driver.xml</import>
|
||||
<import>hal_cb_driver.xml</import>
|
||||
<import>hal_channels.xml</import>
|
||||
<import>hal_buffered_serial.xml</import>
|
||||
</imports>
|
||||
|
@ -77,15 +77,6 @@
|
|||
</config>
|
||||
</configs>
|
||||
<macros>
|
||||
<macro name="sioSetCallbackX">
|
||||
<brief>Associates a callback to the SIO instance.</brief>
|
||||
<param name="siop" dir="out">pointer to the @p hal_sio_driver_c
|
||||
object
|
||||
</param>
|
||||
<param name="f">callback function to be associated</param>
|
||||
<xclass />
|
||||
<implementation><![CDATA[(siop)->cb = (f)]]></implementation>
|
||||
</macro>
|
||||
<macro name="sioIsRXEmptyX">
|
||||
<brief>Determines the state of the RX FIFO.</brief>
|
||||
<param name="siop" dir="both">pointer to the @p hal_sio_driver_c
|
||||
|
@ -430,10 +421,6 @@ do {
|
|||
<brief>Type of structure representing a SIO driver (legacy).</brief>
|
||||
<basetype ctype="struct hal_sio_driver" />
|
||||
</typedef>
|
||||
<typedef name="siocb_t">
|
||||
<brief>Generic SIO notification callback type.</brief>
|
||||
<basetype ctype="void (*$N)(struct hal_sio_driver *siop)" />
|
||||
</typedef>
|
||||
<verbatim><![CDATA[
|
||||
/* Inclusion of LLD header.*/
|
||||
#include "hal_sio_lld.h"]]></verbatim>
|
||||
|
@ -453,7 +440,7 @@ SIO_CONFIG_EXT_FIELDS]]></verbatim>
|
|||
</fields>
|
||||
</struct>
|
||||
<class type="regular" name="hal_sio_driver" namespace="sio"
|
||||
ancestorname="hal_base_driver" descr="SIO driver">
|
||||
ancestorname="hal_cb_driver" descr="SIO driver">
|
||||
<brief>Class of a SIO (Serial I/O) driver.</brief>
|
||||
<implements>
|
||||
<condition check="SIO_USE_STREAMS_INTERFACE == TRUE">
|
||||
|
@ -559,10 +546,6 @@ return HAL_RET_SUCCESS;]]></implementation>
|
|||
<field name="enabled" ctype="sioevents_t">
|
||||
<brief>Enabled event flags.</brief>
|
||||
</field>
|
||||
<field name="cb" ctype="siocb_t">
|
||||
<brief>Events callback.</brief>
|
||||
<note>Can be @p NULL.</note>
|
||||
</field>
|
||||
<condition check="HAL_USE_MUTUAL_EXCLUSION == TRUE">
|
||||
<field name="sync_rx" ctype="thread_reference_t">
|
||||
<brief>Synchronization point for RX.</brief>
|
||||
|
@ -940,10 +923,10 @@ osalThreadResumeI(&self->sync_txend, MSG_RESET);
|
|||
osalOsRescheduleS();
|
||||
#endif]]></implementation>
|
||||
</method>
|
||||
<method shortname="configure">
|
||||
<method shortname="doconf">
|
||||
<implementation><![CDATA[
|
||||
|
||||
return sio_lld_configure(self, (const hal_sio_config_t *)config);]]></implementation>
|
||||
return (const void *)sio_lld_configure(self, (const hal_sio_config_t *)config);]]></implementation>
|
||||
</method>
|
||||
</override>
|
||||
</methods>
|
||||
|
@ -988,7 +971,7 @@ osalSysUnlock();
|
|||
/* Starting the undelying SIO driver.*/
|
||||
msg = drvStart(self->siop);
|
||||
if (msg == HAL_RET_SUCCESS) {
|
||||
sioSetCallbackX(self->siop, &__bsio_default_cb);
|
||||
drvSetCallbackX(self->siop, &__bsio_default_cb);
|
||||
sioWriteEnableFlagsX(self->siop, SIO_EV_ALL_EVENTS);
|
||||
}
|
||||
|
||||
|
@ -1009,9 +992,11 @@ drvStop(self->siop);
|
|||
/* Back into the critical section and return.*/
|
||||
osalSysLock();]]></implementation>
|
||||
</method>
|
||||
<method shortname="configure">
|
||||
<method shortname="doconf">
|
||||
<implementation><![CDATA[
|
||||
return drvConfigureX(self->siop, config);]]></implementation>
|
||||
|
||||
/* Configuring the underlying SIO driver.*/
|
||||
return __sio_doconf_impl(self->siop, config);]]></implementation>
|
||||
</method>
|
||||
</override>
|
||||
</methods>
|
||||
|
@ -1113,8 +1098,9 @@ while (!sioIsRXEmptyX(bsiop->siop)) {
|
|||
}]]></implementation>
|
||||
</function>
|
||||
<function name="__bsio_default_cb" ctype="void">
|
||||
<param name="siop" ctype="hal_sio_driver_c *"></param>
|
||||
<param name="ip" ctype="void *"></param>
|
||||
<implementation><![CDATA[
|
||||
hal_sio_driver_c *siop = (hal_sio_driver_c *)ip;
|
||||
hal_buffered_sio_c *bsiop = (hal_buffered_sio_c *)siop->arg;
|
||||
sioevents_t events;
|
||||
|
||||
|
@ -1147,4 +1133,4 @@ __bsio_push_data((hal_buffered_sio_c *)qp->q_link);]]></implementation>
|
|||
</condition>
|
||||
</functions>
|
||||
</private>
|
||||
</module>
|
||||
</module>
|
||||
|
|
|
@ -848,11 +848,10 @@ return spi_lld_start(self);]]></implementation>
|
|||
|
||||
spi_lld_stop(self);]]></implementation>
|
||||
</method>
|
||||
<method shortname="configure">
|
||||
<method shortname="doconf">
|
||||
<implementation><![CDATA[
|
||||
|
||||
self->config = config;
|
||||
spi_lld_configure(self);]]></implementation>
|
||||
return (const void *)spi_lld_configure(self, (const hal_spi_config_t *)config);]]></implementation>
|
||||
</method>
|
||||
<method shortname="setcb">
|
||||
<implementation><![CDATA[
|
||||
|
@ -882,4 +881,4 @@ spi_lld_init();]]></implementation>
|
|||
<include style="regular">hal.h</include>
|
||||
</includes_always>
|
||||
</private>
|
||||
</module>
|
||||
</module>
|
||||
|
|
|
@ -144,7 +144,7 @@ struct hal_base_driver_vmt {
|
|||
/* From hal_base_driver_c.*/
|
||||
msg_t (*start)(void *ip);
|
||||
void (*stop)(void *ip);
|
||||
msg_t (*configure)(void *ip, const void *config);
|
||||
const void * (*doconf)(void *ip, const void *config);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -206,6 +206,7 @@ extern "C" {
|
|||
void __drv_dispose_impl(void *ip);
|
||||
msg_t drvStart(void *ip);
|
||||
void drvStop(void *ip);
|
||||
msg_t drvConfigureX(void *ip, const void *config);
|
||||
/* Regular functions.*/
|
||||
void drvInit(void);
|
||||
#if HAL_USE_REGISTRY == TRUE
|
||||
|
@ -264,23 +265,20 @@ static inline void __drv_stop(void *ip) {
|
|||
* @memberof hal_base_driver_c
|
||||
* @public
|
||||
*
|
||||
* @brief Driver configure.
|
||||
* @details Applies a new configuration to the driver. The configuration
|
||||
* structure is architecture-dependent.
|
||||
* @note Applying a configuration should be done while the peripheral is
|
||||
* not actively operating, this function can fail depending on the
|
||||
* driver implementation and current state.
|
||||
* @brief Performs driver configuration.
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p hal_base_driver_c instance.
|
||||
* @param[in] config New driver configuration.
|
||||
* @return The configuration pointer.
|
||||
* @retval NULL If the configuration has been rejected.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
CC_FORCE_INLINE
|
||||
static inline msg_t drvConfigureX(void *ip, const void *config) {
|
||||
static inline const void *__drv_do_configure(void *ip, const void *config) {
|
||||
hal_base_driver_c *self = (hal_base_driver_c *)ip;
|
||||
|
||||
return self->vmt->configure(ip, config);
|
||||
return self->vmt->doconf(ip, config);
|
||||
}
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ struct hal_buffered_serial_vmt {
|
|||
/* From hal_base_driver_c.*/
|
||||
msg_t (*start)(void *ip);
|
||||
void (*stop)(void *ip);
|
||||
msg_t (*configure)(void *ip, const void *config);
|
||||
const void * (*doconf)(void *ip, const void *config);
|
||||
/* From hal_buffered_serial_c.*/
|
||||
};
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ struct hal_cb_driver_vmt {
|
|||
/* From hal_base_driver_c.*/
|
||||
msg_t (*start)(void *ip);
|
||||
void (*stop)(void *ip);
|
||||
msg_t (*configure)(void *ip, const void *config);
|
||||
const void * (*doconf)(void *ip, const void *config);
|
||||
/* From hal_cb_driver_c.*/
|
||||
void (*setcb)(void *ip, hal_cb_t cb);
|
||||
};
|
||||
|
@ -211,9 +211,11 @@ extern "C" {
|
|||
* @param[in,out] ip Pointer to a @p hal_cb_driver_c instance.
|
||||
* @param cb Callback function to be associated. Passing @p
|
||||
* NULL disables the existing callback, if any.
|
||||
*
|
||||
* @xclass
|
||||
*/
|
||||
CC_FORCE_INLINE
|
||||
static inline void drvSetCallback(void *ip, hal_cb_t cb) {
|
||||
static inline void drvSetCallbackX(void *ip, hal_cb_t cb) {
|
||||
hal_cb_driver_c *self = (hal_cb_driver_c *)ip;
|
||||
|
||||
self->vmt->setcb(ip, cb);
|
||||
|
@ -231,9 +233,11 @@ static inline void drvSetCallback(void *ip, hal_cb_t cb) {
|
|||
* @brief Returns the callback associated to the driver instance.
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p hal_cb_driver_c instance.
|
||||
*
|
||||
* @xclass
|
||||
*/
|
||||
CC_FORCE_INLINE
|
||||
static inline hal_cb_t drvGetCallback(void *ip) {
|
||||
static inline hal_cb_t drvGetCallbackX(void *ip) {
|
||||
hal_cb_driver_c *self = (hal_cb_driver_c *)ip;
|
||||
|
||||
return self->cb;
|
||||
|
|
|
@ -140,17 +140,6 @@
|
|||
/* Module macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Associates a callback to the SIO instance.
|
||||
*
|
||||
* @param[out] siop Pointer to the @p hal_sio_driver_c object
|
||||
* @param f Callback function to be associated.
|
||||
*
|
||||
* @xclass
|
||||
*/
|
||||
#define sioSetCallbackX(siop, f) \
|
||||
(siop)->cb = (f)
|
||||
|
||||
/**
|
||||
* @brief Determines the state of the RX FIFO.
|
||||
*
|
||||
|
@ -503,11 +492,6 @@ typedef struct hal_sio_config SIOConfig;
|
|||
*/
|
||||
typedef struct hal_sio_driver SIODriver;
|
||||
|
||||
/**
|
||||
* @brief Generic SIO notification callback type.
|
||||
*/
|
||||
typedef void (*siocb_t)(struct hal_sio_driver *siop);
|
||||
|
||||
/* Inclusion of LLD header.*/
|
||||
#include "hal_sio_lld.h"
|
||||
|
||||
|
@ -526,7 +510,7 @@ struct hal_sio_config {
|
|||
|
||||
/**
|
||||
* @class hal_sio_driver_c
|
||||
* @extends base_object_c, hal_base_driver_c.
|
||||
* @extends base_object_c, hal_base_driver_c, hal_cb_driver_c.
|
||||
* @implements asynchronous_channel_i
|
||||
*
|
||||
* @brief Class of a SIO (Serial I/O) driver.
|
||||
|
@ -549,7 +533,9 @@ struct hal_sio_driver_vmt {
|
|||
/* From hal_base_driver_c.*/
|
||||
msg_t (*start)(void *ip);
|
||||
void (*stop)(void *ip);
|
||||
msg_t (*configure)(void *ip, const void *config);
|
||||
const void * (*doconf)(void *ip, const void *config);
|
||||
/* From hal_cb_driver_c.*/
|
||||
void (*setcb)(void *ip, hal_cb_t cb);
|
||||
/* From hal_sio_driver_c.*/
|
||||
};
|
||||
|
||||
|
@ -593,6 +579,11 @@ struct hal_sio_driver {
|
|||
*/
|
||||
hal_regent_t regent;
|
||||
#endif /* HAL_USE_REGISTRY == TRUE */
|
||||
/**
|
||||
* @brief Driver callback.
|
||||
* @note Can be @p NULL.
|
||||
*/
|
||||
hal_cb_t cb;
|
||||
#if (SIO_USE_STREAMS_INTERFACE == TRUE) || defined (__DOXYGEN__)
|
||||
/**
|
||||
* @brief Implemented interface @p asynchronous_channel_i.
|
||||
|
@ -603,11 +594,6 @@ struct hal_sio_driver {
|
|||
* @brief Enabled event flags.
|
||||
*/
|
||||
sioevents_t enabled;
|
||||
/**
|
||||
* @brief Events callback.
|
||||
* @note Can be @p NULL.
|
||||
*/
|
||||
siocb_t cb;
|
||||
#if (HAL_USE_MUTUAL_EXCLUSION == TRUE) || defined (__DOXYGEN__)
|
||||
/**
|
||||
* @brief Synchronization point for RX.
|
||||
|
@ -659,7 +645,7 @@ struct hal_buffered_sio_vmt {
|
|||
/* From hal_base_driver_c.*/
|
||||
msg_t (*start)(void *ip);
|
||||
void (*stop)(void *ip);
|
||||
msg_t (*configure)(void *ip, const void *config);
|
||||
const void * (*doconf)(void *ip, const void *config);
|
||||
/* From hal_buffered_serial_c.*/
|
||||
/* From hal_buffered_sio_c.*/
|
||||
};
|
||||
|
@ -739,7 +725,7 @@ extern "C" {
|
|||
void __sio_dispose_impl(void *ip);
|
||||
msg_t __sio_start_impl(void *ip);
|
||||
void __sio_stop_impl(void *ip);
|
||||
msg_t __sio_configure_impl(void *ip, const void *config);
|
||||
const void *__sio_doconf_impl(void *ip, const void *config);
|
||||
void sioWriteEnableFlags(void *ip, sioevents_t mask);
|
||||
void sioSetEnableFlags(void *ip, sioevents_t mask);
|
||||
void sioClearEnableFlags(void *ip, sioevents_t mask);
|
||||
|
@ -759,7 +745,7 @@ extern "C" {
|
|||
void __bsio_dispose_impl(void *ip);
|
||||
msg_t __bsio_start_impl(void *ip);
|
||||
void __bsio_stop_impl(void *ip);
|
||||
msg_t __bsio_configure_impl(void *ip, const void *config);
|
||||
const void *__bsio_doconf_impl(void *ip, const void *config);
|
||||
/* Regular functions.*/
|
||||
void sioInit(void);
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -223,7 +223,7 @@ struct hal_spi_driver_vmt {
|
|||
/* From hal_base_driver_c.*/
|
||||
msg_t (*start)(void *ip);
|
||||
void (*stop)(void *ip);
|
||||
msg_t (*configure)(void *ip, const void *config);
|
||||
const void * (*doconf)(void *ip, const void *config);
|
||||
/* From hal_cb_driver_c.*/
|
||||
void (*setcb)(void *ip, hal_cb_t cb);
|
||||
/* From hal_spi_driver_c.*/
|
||||
|
@ -300,7 +300,7 @@ extern "C" {
|
|||
void __spi_dispose_impl(void *ip);
|
||||
msg_t __spi_start_impl(void *ip);
|
||||
void __spi_stop_impl(void *ip);
|
||||
msg_t __spi_configure_impl(void *ip, const void *config);
|
||||
const void *__spi_doconf_impl(void *ip, const void *config);
|
||||
void __spi_setcb_impl(void *ip, hal_cb_t cb);
|
||||
msg_t spiStartIgnoreI(void *ip, size_t n);
|
||||
msg_t spiStartIgnore(void *ip, size_t n);
|
||||
|
|
|
@ -460,10 +460,14 @@ void sio_lld_stop(SIODriver *siop) {
|
|||
}
|
||||
}
|
||||
|
||||
msg_t sio_lld_configure(SIODriver *siop, const SIOConfig *config) {
|
||||
const SIOConfig *sio_lld_configure(SIODriver *siop, const SIOConfig *config) {
|
||||
USART_TypeDef *u = siop->usart;
|
||||
uint32_t presc, brr, clock;
|
||||
|
||||
if (config == NULL) {
|
||||
config = &default_config;
|
||||
}
|
||||
|
||||
/* Prescaler calculation.*/
|
||||
static const uint32_t prescvals[] = {1, 2, 4, 6, 8, 10, 12, 16, 32, 64, 128, 256};
|
||||
clock = siop->clock;
|
||||
|
@ -506,7 +510,7 @@ msg_t sio_lld_configure(SIODriver *siop, const SIOConfig *config) {
|
|||
u->ICR = u->ISR;
|
||||
u->CR1 |= USART_CR1_UE | USART_CR1_TE | USART_CR1_RE;
|
||||
|
||||
return HAL_RET_SUCCESS;
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -473,7 +473,7 @@ extern "C" {
|
|||
void sio_lld_init(void);
|
||||
msg_t sio_lld_start(SIODriver *siop);
|
||||
void sio_lld_stop(SIODriver *siop);
|
||||
msg_t sio_lld_configure(SIODriver *siop, const SIOConfig *config);
|
||||
const SIOConfig *sio_lld_configure(SIODriver *siop, const SIOConfig *config);
|
||||
void sio_lld_update_enable_flags(SIODriver *siop);
|
||||
sioevents_t sio_lld_get_and_clear_errors(SIODriver *siop);
|
||||
sioevents_t sio_lld_get_and_clear_events(SIODriver *siop, sioevents_t events);
|
||||
|
|
|
@ -167,6 +167,7 @@ msg_t sio_lld_start(SIODriver *siop) {
|
|||
}
|
||||
|
||||
/* Configures the peripheral.*/
|
||||
cbdrvSet
|
||||
sio_lld_configure(siop, &default_config);
|
||||
|
||||
return msg;
|
||||
|
|
|
@ -268,7 +268,7 @@ void __drv_dispose_impl(void *ip) {
|
|||
* subsequent calls are ignored.
|
||||
* @note The function can fail with error @p HAL_RET_INV_STATE if called
|
||||
* while the driver is already being started or stopped. In case
|
||||
* you need multiple threads performing start and stop operation
|
||||
* you need multiple threads to perform start and stop operation
|
||||
* on the driver then it is suggested to lock/unlock the driver
|
||||
* during such operations.
|
||||
*
|
||||
|
@ -351,6 +351,43 @@ void drvStop(void *ip) {
|
|||
|
||||
osalSysUnlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof hal_base_driver_c
|
||||
* @public
|
||||
*
|
||||
* @brief Driver configure.
|
||||
* @details Applies a new configuration to the driver. The configuration
|
||||
* structure is architecture-dependent.
|
||||
* @note Applying a configuration should be done while the peripheral is
|
||||
* not actively operating, this function can fail depending on the
|
||||
* driver implementation and current state.
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p hal_base_driver_c instance.
|
||||
* @param[in] config New driver configuration.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
msg_t drvConfigureX(void *ip, const void *config) {
|
||||
hal_base_driver_c *self = (hal_base_driver_c *)ip;
|
||||
msg_t msg;
|
||||
|
||||
osalSysLock();
|
||||
|
||||
osalDbgAssert(self->state != HAL_DRV_STATE_UNINIT, "invalid state");
|
||||
|
||||
self->config = __drv_do_configure(self, config);
|
||||
if (self->config == NULL) {
|
||||
msg = HAL_RET_CONFIG_ERROR;
|
||||
}
|
||||
else {
|
||||
msg = HAL_RET_SUCCESS;
|
||||
}
|
||||
|
||||
osalSysUnlock();
|
||||
|
||||
return msg;
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -109,7 +109,7 @@ void __cbdrv_dispose_impl(void *ip) {
|
|||
* @memberof hal_cb_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Implementation of method @p drvSetCallback().
|
||||
* @brief Implementation of method @p drvSetCallbackX().
|
||||
* @note This function is meant to be used by derived classes.
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p hal_cb_driver_c instance.
|
||||
|
|
|
@ -119,7 +119,8 @@ static void __bsio_pop_data(hal_buffered_sio_c *bsiop) {
|
|||
}
|
||||
}
|
||||
|
||||
static void __bsio_default_cb(hal_sio_driver_c *siop) {
|
||||
static void __bsio_default_cb(void *ip) {
|
||||
hal_sio_driver_c *siop = (hal_sio_driver_c *)ip;
|
||||
hal_buffered_sio_c *bsiop = (hal_buffered_sio_c *)siop->arg;
|
||||
sioevents_t events;
|
||||
|
||||
|
@ -456,7 +457,7 @@ void *__sio_objinit_impl(void *ip, const void *vmt) {
|
|||
hal_sio_driver_c *self = (hal_sio_driver_c *)ip;
|
||||
|
||||
/* Initialization of the ancestors-defined parts.*/
|
||||
__drv_objinit_impl(self, vmt);
|
||||
__cbdrv_objinit_impl(self, vmt);
|
||||
|
||||
#if (SIO_USE_STREAMS_INTERFACE == TRUE) || defined (__DOXYGEN__)
|
||||
/* Initialization of interface asynchronous_channel_i.*/
|
||||
|
@ -514,7 +515,7 @@ void __sio_dispose_impl(void *ip) {
|
|||
(void)self;
|
||||
|
||||
/* Finalization of the ancestors-defined parts.*/
|
||||
__drv_dispose_impl(self);
|
||||
__cbdrv_dispose_impl(self);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -573,15 +574,16 @@ void __sio_stop_impl(void *ip) {
|
|||
* @memberof hal_sio_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p drvConfigureX().
|
||||
* @brief Override of method @p __drv_do_configure().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p hal_sio_driver_c instance.
|
||||
* @param[in] config New driver configuration.
|
||||
* @return The configuration pointer.
|
||||
*/
|
||||
msg_t __sio_configure_impl(void *ip, const void *config) {
|
||||
const void *__sio_doconf_impl(void *ip, const void *config) {
|
||||
hal_sio_driver_c *self = (hal_sio_driver_c *)ip;
|
||||
|
||||
return sio_lld_configure(self, (const hal_sio_config_t *)config);
|
||||
return (const void *)sio_lld_configure(self, (const hal_sio_config_t *)config);
|
||||
}
|
||||
/** @} */
|
||||
|
||||
|
@ -593,7 +595,8 @@ const struct hal_sio_driver_vmt __hal_sio_driver_vmt = {
|
|||
.dispose = __sio_dispose_impl,
|
||||
.start = __sio_start_impl,
|
||||
.stop = __sio_stop_impl,
|
||||
.configure = __sio_configure_impl
|
||||
.doconf = __sio_doconf_impl,
|
||||
.setcb = __cbdrv_setcb_impl
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1015,7 +1018,7 @@ msg_t __bsio_start_impl(void *ip) {
|
|||
/* Starting the undelying SIO driver.*/
|
||||
msg = drvStart(self->siop);
|
||||
if (msg == HAL_RET_SUCCESS) {
|
||||
sioSetCallbackX(self->siop, &__bsio_default_cb);
|
||||
drvSetCallbackX(self->siop, &__bsio_default_cb);
|
||||
sioWriteEnableFlagsX(self->siop, SIO_EV_ALL_EVENTS);
|
||||
}
|
||||
|
||||
|
@ -1050,14 +1053,17 @@ void __bsio_stop_impl(void *ip) {
|
|||
* @memberof hal_buffered_sio_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p drvConfigureX().
|
||||
* @brief Override of method @p __drv_do_configure().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p hal_buffered_sio_c instance.
|
||||
* @param[in] config New driver configuration.
|
||||
* @return The configuration pointer.
|
||||
*/
|
||||
msg_t __bsio_configure_impl(void *ip, const void *config) {
|
||||
const void *__bsio_doconf_impl(void *ip, const void *config) {
|
||||
hal_buffered_sio_c *self = (hal_buffered_sio_c *)ip;
|
||||
return drvConfigureX(self->siop, config);
|
||||
|
||||
/* Configuring the underlying SIO driver.*/
|
||||
return __sio_doconf_impl(self->siop, config);
|
||||
}
|
||||
/** @} */
|
||||
|
||||
|
@ -1069,7 +1075,7 @@ const struct hal_buffered_sio_vmt __hal_buffered_sio_vmt = {
|
|||
.dispose = __bsio_dispose_impl,
|
||||
.start = __bsio_start_impl,
|
||||
.stop = __bsio_stop_impl,
|
||||
.configure = __bsio_configure_impl
|
||||
.doconf = __bsio_doconf_impl
|
||||
};
|
||||
|
||||
#endif /* HAL_USE_SIO == TRUE */
|
||||
|
|
|
@ -156,23 +156,23 @@ void __spi_stop_impl(void *ip) {
|
|||
* @memberof hal_spi_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p drvConfigureX().
|
||||
* @brief Override of method @p __drv_do_configure().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p hal_spi_driver_c instance.
|
||||
* @param[in] config New driver configuration.
|
||||
* @return The configuration pointer.
|
||||
*/
|
||||
msg_t __spi_configure_impl(void *ip, const void *config) {
|
||||
const void *__spi_doconf_impl(void *ip, const void *config) {
|
||||
hal_spi_driver_c *self = (hal_spi_driver_c *)ip;
|
||||
|
||||
self->config = config;
|
||||
spi_lld_configure(self);
|
||||
return (const void *)spi_lld_configure(self, (const hal_spi_config_t *)config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof hal_spi_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p drvSetCallback().
|
||||
* @brief Override of method @p drvSetCallbackX().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p hal_spi_driver_c instance.
|
||||
* @param cb Callback function to be associated. Passing @p
|
||||
|
@ -195,7 +195,7 @@ const struct hal_spi_driver_vmt __hal_spi_driver_vmt = {
|
|||
.dispose = __spi_dispose_impl,
|
||||
.start = __spi_start_impl,
|
||||
.stop = __spi_stop_impl,
|
||||
.configure = __spi_configure_impl,
|
||||
.doconf = __spi_doconf_impl,
|
||||
.setcb = __spi_setcb_impl
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue