esp_rom: extract common CRC apis into esp_rom_crc.h

This commit is contained in:
morris
2020-06-19 15:08:38 +08:00
parent 26272af3b4
commit a34409cffc
25 changed files with 468 additions and 107 deletions

View File

@@ -18,21 +18,9 @@ extern "C" {
#endif
#include <stdint.h>
#include "sdkconfig.h"
#if defined(CONFIG_IDF_TARGET_ESP32)
#include "esp32/rom/crc.h"
#endif
#if defined(CONFIG_IDF_TARGET_ESP32S2)
#include "esp32s2/rom/crc.h"
#endif
/******************* Polynomials Used in the CRC APIs ****************************
* CRC-8 x8+x2+x1+1 0x07
* CRC16-CCITT x16+x12+x5+1 0x1021
* CRC32 x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x1+1 0x04c11db7
********************************************************************************/
// This header is only a wrapper on ROM CRC API
#include "esp_rom_crc.h"
/**
* @brief CRC32 value in little endian.
@@ -44,10 +32,9 @@ extern "C" {
*/
static inline uint32_t esp_crc32_le(uint32_t crc, uint8_t const *buf, uint32_t len)
{
return crc32_le(crc, buf, len);
return esp_rom_crc32_le(crc, buf, len);
}
#if defined(CONFIG_IDF_TARGET_ESP32)
/**
* @brief CRC32 value in big endian.
*
@@ -58,9 +45,8 @@ static inline uint32_t esp_crc32_le(uint32_t crc, uint8_t const *buf, uint32_t l
*/
static inline uint32_t esp_crc32_be(uint32_t crc, uint8_t const *buf, uint32_t len)
{
return crc32_be(crc, buf, len);
return esp_rom_crc32_be(crc, buf, len);
}
#endif
/**
* @brief CRC16 value in little endian.
@@ -72,10 +58,9 @@ static inline uint32_t esp_crc32_be(uint32_t crc, uint8_t const *buf, uint32_t l
*/
static inline uint16_t esp_crc16_le(uint16_t crc, uint8_t const *buf, uint32_t len)
{
return crc16_le(crc, buf, len);
return esp_rom_crc16_le(crc, buf, len);
}
#if defined(CONFIG_IDF_TARGET_ESP32)
/**
* @brief CRC16 value in big endian.
*
@@ -86,9 +71,8 @@ static inline uint16_t esp_crc16_le(uint16_t crc, uint8_t const *buf, uint32_t l
*/
static inline uint16_t esp_crc16_be(uint16_t crc, uint8_t const *buf, uint32_t len)
{
return crc16_be(crc, buf, len);
return esp_rom_crc16_be(crc, buf, len);
}
#endif
/**
* @brief CRC8 value in little endian.
@@ -100,10 +84,9 @@ static inline uint16_t esp_crc16_be(uint16_t crc, uint8_t const *buf, uint32_t l
*/
static inline uint8_t esp_crc8_le(uint8_t crc, uint8_t const *buf, uint32_t len)
{
return crc8_le(crc, buf, len);
return esp_rom_crc8_le(crc, buf, len);
}
#if defined(CONFIG_IDF_TARGET_ESP32)
/**
* @brief CRC8 value in big endian.
*
@@ -114,9 +97,8 @@ static inline uint8_t esp_crc8_le(uint8_t crc, uint8_t const *buf, uint32_t len)
*/
static inline uint8_t esp_crc8_be(uint8_t crc, uint8_t const *buf, uint32_t len)
{
return crc8_be(crc, buf, len);
return esp_rom_crc8_be(crc, buf, len);
}
#endif
#ifdef __cplusplus
}