Enhanced more drivers.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14829 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-09-24 11:44:44 +00:00
parent 31d15098f9
commit ae436f0df4
14 changed files with 139 additions and 21 deletions

View File

@ -224,7 +224,7 @@ extern "C" {
#endif
void cryInit(void);
void cryObjectInit(CRYDriver *cryp);
void cryStart(CRYDriver *cryp, const CRYConfig *config);
msg_t cryStart(CRYDriver *cryp, const CRYConfig *config);
void cryStop(CRYDriver *cryp);
cryerror_t cryLoadAESTransientKey(CRYDriver *cryp,
size_t size,

View File

@ -349,7 +349,7 @@ extern "C" {
#endif
void dacInit(void);
void dacObjectInit(DACDriver *dacp);
void dacStart(DACDriver *dacp, const DACConfig *config);
msg_t dacStart(DACDriver *dacp, const DACConfig *config);
void dacStop(DACDriver *dacp);
void dacPutChannelX(DACDriver *dacp,
dacchannel_t channel,

View File

@ -117,7 +117,7 @@ extern "C" {
#endif
void eflInit(void);
void eflObjectInit(EFlashDriver *eflp);
void eflStart(EFlashDriver *eflp, const EFlashConfig *config);
msg_t eflStart(EFlashDriver *eflp, const EFlashConfig *config);
void eflStop(EFlashDriver *eflp);
#ifdef __cplusplus
}

View File

@ -137,7 +137,7 @@ extern "C" {
#endif
void gptInit(void);
void gptObjectInit(GPTDriver *gptp);
void gptStart(GPTDriver *gptp, const GPTConfig *config);
msg_t gptStart(GPTDriver *gptp, const GPTConfig *config);
void gptStop(GPTDriver *gptp);
void gptStartContinuous(GPTDriver *gptp, gptcnt_t interval);
void gptStartContinuousI(GPTDriver *gptp, gptcnt_t interval);

View File

@ -138,7 +138,7 @@ extern "C" {
#endif
void i2cInit(void);
void i2cObjectInit(I2CDriver *i2cp);
void i2cStart(I2CDriver *i2cp, const I2CConfig *config);
msg_t i2cStart(I2CDriver *i2cp, const I2CConfig *config);
void i2cStop(I2CDriver *i2cp);
i2cflags_t i2cGetErrors(I2CDriver *i2cp);
msg_t i2cMasterTransmitTimeout(I2CDriver *i2cp,

View File

@ -225,7 +225,7 @@ extern "C" {
#endif
void i2sInit(void);
void i2sObjectInit(I2SDriver *i2sp);
void i2sStart(I2SDriver *i2sp, const I2SConfig *config);
msg_t i2sStart(I2SDriver *i2sp, const I2SConfig *config);
void i2sStop(I2SDriver *i2sp);
void i2sStartExchange(I2SDriver *i2sp);
void i2sStopExchange(I2SDriver *i2sp);

View File

@ -222,7 +222,7 @@ extern "C" {
#endif
void icuInit(void);
void icuObjectInit(ICUDriver *icup);
void icuStart(ICUDriver *icup, const ICUConfig *config);
msg_t icuStart(ICUDriver *icup, const ICUConfig *config);
void icuStop(ICUDriver *icup);
void icuStartCapture(ICUDriver *icup);
bool icuWaitCapture(ICUDriver *icup);

View File

@ -82,10 +82,12 @@ void cryObjectInit(CRYDriver *cryp) {
* @param[in] cryp pointer to the @p CRYDriver object
* @param[in] config pointer to the @p CRYConfig object. Depending
* on the implementation the value can be @p NULL.
* @return The operation status.
*
* @api
*/
void cryStart(CRYDriver *cryp, const CRYConfig *config) {
msg_t cryStart(CRYDriver *cryp, const CRYConfig *config) {
msg_t msg;
osalDbgCheck(cryp != NULL);
@ -94,10 +96,26 @@ void cryStart(CRYDriver *cryp, const CRYConfig *config) {
"invalid state");
cryp->config = config;
#if HAL_CRY_ENFORCE_FALLBACK == FALSE
#if defined(CRY_LLD_ENHANCED_API)
msg = cry_lld_start(cryp);
#else
cry_lld_start(cryp);
msg = HAL_START_SUCCESS;
#endif
if (msg == HAL_START_SUCCESS) {
cryp->state = CRY_READY;
}
else {
cryp->state = CRY_STOP;
}
#else
cryp->state = CRY_READY;
msg = HAL_START_SUCCESS;
#endif
osalSysUnlock();
return msg;
}
/**

View File

@ -87,10 +87,12 @@ void dacObjectInit(DACDriver *dacp) {
* @param[in] config pointer to the @p DACConfig object, it can be
* @p NULL if the low level driver implementation
* supports a default configuration
* @return The operation status.
*
* @api
*/
void dacStart(DACDriver *dacp, const DACConfig *config) {
msg_t dacStart(DACDriver *dacp, const DACConfig *config) {
msg_t msg;
osalDbgCheck(dacp != NULL);
@ -100,10 +102,23 @@ void dacStart(DACDriver *dacp, const DACConfig *config) {
"invalid state");
dacp->config = config;
#if defined(DAC_LLD_ENHANCED_API)
msg = dac_lld_start(dacp);
#else
dac_lld_start(dacp);
dacp->state = DAC_READY;
msg = HAL_START_SUCCESS;
#endif
if (msg == HAL_START_SUCCESS) {
dacp->state = DAC_READY;
}
else {
dacp->state = DAC_STOP;
}
osalSysUnlock();
return msg;
}
/**

View File

@ -89,10 +89,12 @@ void eflObjectInit(EFlashDriver *eflp) {
* @param[in] config pointer to a configuration structure.
* If this parameter is set to @p NULL then a default
* configuration is used.
* @return The operation status.
*
* @api
*/
void eflStart(EFlashDriver *eflp, const EFlashConfig *config) {
msg_t eflStart(EFlashDriver *eflp, const EFlashConfig *config) {
msg_t msg;
osalDbgCheck(eflp != NULL);
@ -100,11 +102,25 @@ void eflStart(EFlashDriver *eflp, const EFlashConfig *config) {
osalDbgAssert((eflp->state == FLASH_STOP) || (eflp->state == FLASH_READY),
"invalid state");
eflp->config = config;
#if defined(EFL_LLD_ENHANCED_API)
msg = efl_lld_start(eflp);
#else
efl_lld_start(eflp);
eflp->state = FLASH_READY;
msg = HAL_START_SUCCESS;
#endif
if (msg == HAL_START_SUCCESS) {
eflp->state = FLASH_READY;
}
else {
eflp->state = FLASH_STOP;
}
osalSysUnlock();
return msg;
}
/**

View File

@ -76,20 +76,38 @@ void gptObjectInit(GPTDriver *gptp) {
*
* @param[in] gptp pointer to the @p GPTDriver object
* @param[in] config pointer to the @p GPTConfig object
* @return The operation status.
*
* @api
*/
void gptStart(GPTDriver *gptp, const GPTConfig *config) {
msg_t gptStart(GPTDriver *gptp, const GPTConfig *config) {
msg_t msg;
osalDbgCheck((gptp != NULL) && (config != NULL));
osalSysLock();
osalDbgAssert((gptp->state == GPT_STOP) || (gptp->state == GPT_READY),
"invalid state");
gptp->config = config;
#if defined(GPT_LLD_ENHANCED_API)
msg = gpt_lld_start(gptp);
#else
gpt_lld_start(gptp);
gptp->state = GPT_READY;
msg = HAL_START_SUCCESS;
#endif
if (msg == HAL_START_SUCCESS) {
gptp->state = GPT_READY;
}
else {
gptp->state = GPT_STOP;
}
osalSysUnlock();
return msg;
}
/**

View File

@ -87,20 +87,37 @@ void i2cObjectInit(I2CDriver *i2cp) {
*
* @param[in] i2cp pointer to the @p I2CDriver object
* @param[in] config pointer to the @p I2CConfig object
* @return The operation status.
*
* @api
*/
void i2cStart(I2CDriver *i2cp, const I2CConfig *config) {
msg_t i2cStart(I2CDriver *i2cp, const I2CConfig *config) {
msg_t msg;
osalDbgCheck((i2cp != NULL) && (config != NULL));
osalSysLock();
osalDbgAssert((i2cp->state == I2C_STOP) || (i2cp->state == I2C_READY) ||
(i2cp->state == I2C_LOCKED), "invalid state");
osalSysLock();
i2cp->config = config;
#if defined(I2C_LLD_ENHANCED_API)
msg = i2c_lld_start(i2cp);
#else
i2c_lld_start(i2cp);
i2cp->state = I2C_READY;
msg = HAL_START_SUCCESS;
#endif
if (msg == HAL_START_SUCCESS) {
i2cp->state = I2C_READY;
}
else {
i2cp->state = I2C_STOP;
}
osalSysUnlock();
return msg;
}
/**

View File

@ -76,20 +76,37 @@ void i2sObjectInit(I2SDriver *i2sp) {
*
* @param[in] i2sp pointer to the @p I2SDriver object
* @param[in] config pointer to the @p I2SConfig object
* @return The operation status.
*
* @api
*/
void i2sStart(I2SDriver *i2sp, const I2SConfig *config) {
msg_t i2sStart(I2SDriver *i2sp, const I2SConfig *config) {
msg_t msg;
osalDbgCheck((i2sp != NULL) && (config != NULL));
osalSysLock();
osalDbgAssert((i2sp->state == I2S_STOP) || (i2sp->state == I2S_READY),
"invalid state");
i2sp->config = config;
#if defined(I2S_LLD_ENHANCED_API)
msg = i2s_lld_start(i2sp);
#else
i2s_lld_start(i2sp);
i2sp->state = I2S_READY;
msg = HAL_START_SUCCESS;
#endif
if (msg == HAL_START_SUCCESS) {
i2sp->state = I2S_READY;
}
else {
i2sp->state = I2S_STOP;
}
osalSysUnlock();
return msg;
}
/**

View File

@ -76,20 +76,37 @@ void icuObjectInit(ICUDriver *icup) {
*
* @param[in] icup pointer to the @p ICUDriver object
* @param[in] config pointer to the @p ICUConfig object
* @return The operation status.
*
* @api
*/
void icuStart(ICUDriver *icup, const ICUConfig *config) {
msg_t icuStart(ICUDriver *icup, const ICUConfig *config) {
msg_t msg;
osalDbgCheck((icup != NULL) && (config != NULL));
osalSysLock();
osalDbgAssert((icup->state == ICU_STOP) || (icup->state == ICU_READY),
"invalid state");
icup->config = config;
#if defined(ICU_LLD_ENHANCED_API)
msg = icu_lld_start(icup);
#else
icu_lld_start(icup);
icup->state = ICU_READY;
msg = HAL_START_SUCCESS;
#endif
if (msg == HAL_START_SUCCESS) {
icup->state = ICU_READY;
}
else {
icup->state = ICU_STOP;
}
osalSysUnlock();
return msg;
}
/**