Skip to content

Commit 7a0c4e1

Browse files
committed
Certain STM32's dont have programmable CRC registers
1 parent 405e196 commit 7a0c4e1

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

os/hal/include/hal_crc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ extern "C" {
135135
#endif
136136
void crcInit(void);
137137
void crcObjectInit(CRCDriver *crcp);
138+
#if (defined(STM32F1xx) || defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32L1xx)) // Those MCU dont have programmable CRC registers
139+
void crcStart(CRCDriver *crcp);
140+
#else
138141
void crcStart(CRCDriver *crcp, const CRCConfig *config);
142+
#endif
139143
void crcStop(CRCDriver *crcp);
140144
void crcReset(CRCDriver *crcp);
141145
void crcResetI(CRCDriver *crcp);

os/hal/src/hal_crc.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ void crcObjectInit(CRCDriver *crcp) {
8181
*
8282
* @api
8383
*/
84+
85+
#if (defined(STM32F1xx) || defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32L1xx)) // Those MCU dont have programmable CRC registers
86+
void crcStart(CRCDriver *crcp) {
87+
osalDbgCheck(crcp != NULL);
88+
89+
osalSysLock();
90+
osalDbgAssert((crcp->state == CRC_STOP) || (crcp->state == CRC_READY),
91+
"invalid state");
92+
crc_lld_start(crcp);
93+
crcp->state = CRC_READY;
94+
osalSysUnlock();
95+
}
96+
#else
8497
void crcStart(CRCDriver *crcp, const CRCConfig *config) {
8598
osalDbgCheck(crcp != NULL);
8699

@@ -92,6 +105,7 @@ void crcStart(CRCDriver *crcp, const CRCConfig *config) {
92105
crcp->state = CRC_READY;
93106
osalSysUnlock();
94107
}
108+
#endif
95109

96110
/**
97111
* @brief Deactivates the CRC peripheral.

0 commit comments

Comments
 (0)