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 #endif
void cryInit(void); void cryInit(void);
void cryObjectInit(CRYDriver *cryp); void cryObjectInit(CRYDriver *cryp);
void cryStart(CRYDriver *cryp, const CRYConfig *config); msg_t cryStart(CRYDriver *cryp, const CRYConfig *config);
void cryStop(CRYDriver *cryp); void cryStop(CRYDriver *cryp);
cryerror_t cryLoadAESTransientKey(CRYDriver *cryp, cryerror_t cryLoadAESTransientKey(CRYDriver *cryp,
size_t size, size_t size,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -222,7 +222,7 @@ extern "C" {
#endif #endif
void icuInit(void); void icuInit(void);
void icuObjectInit(ICUDriver *icup); void icuObjectInit(ICUDriver *icup);
void icuStart(ICUDriver *icup, const ICUConfig *config); msg_t icuStart(ICUDriver *icup, const ICUConfig *config);
void icuStop(ICUDriver *icup); void icuStop(ICUDriver *icup);
void icuStartCapture(ICUDriver *icup); void icuStartCapture(ICUDriver *icup);
bool icuWaitCapture(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] cryp pointer to the @p CRYDriver object
* @param[in] config pointer to the @p CRYConfig object. Depending * @param[in] config pointer to the @p CRYConfig object. Depending
* on the implementation the value can be @p NULL. * on the implementation the value can be @p NULL.
* @return The operation status.
* *
* @api * @api
*/ */
void cryStart(CRYDriver *cryp, const CRYConfig *config) { msg_t cryStart(CRYDriver *cryp, const CRYConfig *config) {
msg_t msg;
osalDbgCheck(cryp != NULL); osalDbgCheck(cryp != NULL);
@ -94,10 +96,26 @@ void cryStart(CRYDriver *cryp, const CRYConfig *config) {
"invalid state"); "invalid state");
cryp->config = config; cryp->config = config;
#if HAL_CRY_ENFORCE_FALLBACK == FALSE #if HAL_CRY_ENFORCE_FALLBACK == FALSE
#if defined(CRY_LLD_ENHANCED_API)
msg = cry_lld_start(cryp);
#else
cry_lld_start(cryp); cry_lld_start(cryp);
msg = HAL_START_SUCCESS;
#endif #endif
if (msg == HAL_START_SUCCESS) {
cryp->state = CRY_READY; cryp->state = CRY_READY;
}
else {
cryp->state = CRY_STOP;
}
#else
cryp->state = CRY_READY;
msg = HAL_START_SUCCESS;
#endif
osalSysUnlock(); 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 * @param[in] config pointer to the @p DACConfig object, it can be
* @p NULL if the low level driver implementation * @p NULL if the low level driver implementation
* supports a default configuration * supports a default configuration
* @return The operation status.
* *
* @api * @api
*/ */
void dacStart(DACDriver *dacp, const DACConfig *config) { msg_t dacStart(DACDriver *dacp, const DACConfig *config) {
msg_t msg;
osalDbgCheck(dacp != NULL); osalDbgCheck(dacp != NULL);
@ -100,10 +102,23 @@ void dacStart(DACDriver *dacp, const DACConfig *config) {
"invalid state"); "invalid state");
dacp->config = config; dacp->config = config;
#if defined(DAC_LLD_ENHANCED_API)
msg = dac_lld_start(dacp);
#else
dac_lld_start(dacp); dac_lld_start(dacp);
msg = HAL_START_SUCCESS;
#endif
if (msg == HAL_START_SUCCESS) {
dacp->state = DAC_READY; dacp->state = DAC_READY;
}
else {
dacp->state = DAC_STOP;
}
osalSysUnlock(); osalSysUnlock();
return msg;
} }
/** /**

View File

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

View File

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

View File

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

View File

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

View File

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