Added crc8 lib
This commit is contained in:
parent
7960189a32
commit
9631a4816d
@ -31,6 +31,7 @@
|
|||||||
</option>
|
</option>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths.1572529382" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths" valueType="includePath">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths.1572529382" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths" valueType="includePath">
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/sht4x}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/sht4x}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/crc8}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.366934534" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.366934534" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
||||||
</tool>
|
</tool>
|
||||||
@ -59,6 +60,7 @@
|
|||||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L0xx/Include"/>
|
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L0xx/Include"/>
|
||||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/sht4x}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/sht4x}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/crc8}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1544503170" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1544503170" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
||||||
</tool>
|
</tool>
|
||||||
@ -87,6 +89,7 @@
|
|||||||
<sourceEntries>
|
<sourceEntries>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Libs/crc8"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Libs/sht4x"/>
|
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Libs/sht4x"/>
|
||||||
</sourceEntries>
|
</sourceEntries>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -120,6 +123,7 @@
|
|||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.375884652" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g0" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.375884652" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g0" valueType="enumerated"/>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths.700537390" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths" valueType="includePath">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths.700537390" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths" valueType="includePath">
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/sht4x}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/sht4x}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/crc8}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.1707174983" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.1707174983" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
||||||
</tool>
|
</tool>
|
||||||
@ -147,6 +151,7 @@
|
|||||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L0xx/Include"/>
|
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L0xx/Include"/>
|
||||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/sht4x}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/sht4x}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/crc8}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1160143889" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1160143889" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
||||||
</tool>
|
</tool>
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* crc.h
|
|
||||||
*
|
|
||||||
* Created on: Jun 9, 2021
|
|
||||||
* Author: user
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef INC_CRC8_H_
|
|
||||||
#define INC_CRC8_H_
|
|
||||||
|
|
||||||
#include "stdint.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Definitions & macros
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define CRC8_POLYNOMIAL ((uint8_t)0x31)
|
|
||||||
#define CRC8_INIT ((uint8_t)0xFF)
|
|
||||||
|
|
||||||
uint8_t crc8_calculate(const uint8_t *data, uint16_t count);
|
|
||||||
|
|
||||||
#endif /* INC_CRC8_H_ */
|
|
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* crc.c
|
|
||||||
*
|
|
||||||
* Created on: Jun 9, 2021
|
|
||||||
* Author: user
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "crc8.h"
|
|
||||||
|
|
||||||
/* Stolen from Sensirion SCD4x datasheet, section 3.11 */
|
|
||||||
uint8_t crc8_calculate(const uint8_t *data, uint16_t count)
|
|
||||||
{
|
|
||||||
uint16_t current_byte;
|
|
||||||
uint8_t crc = CRC8_INIT;
|
|
||||||
uint8_t crc_bit;
|
|
||||||
/* calculates 8-Bit checksum with given polynomial */
|
|
||||||
for (current_byte = 0; current_byte < count; ++current_byte) {
|
|
||||||
crc ^= (data[current_byte]);
|
|
||||||
for(crc_bit = 8; crc_bit > 0; --crc_bit) {
|
|
||||||
if (crc & 0x80) {
|
|
||||||
crc =(crc << 1) ^ CRC8_POLYNOMIAL;
|
|
||||||
} else {
|
|
||||||
crc = (crc << 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return crc;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user