Move crc16 function to libs
This commit is contained in:
parent
2a96d4e23a
commit
356410dcfc
@ -25,6 +25,8 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "../../libs/crc16.h"
|
||||||
|
|
||||||
class PersistentStore {
|
class PersistentStore {
|
||||||
public:
|
public:
|
||||||
static bool access_start();
|
static bool access_start();
|
||||||
|
@ -35,19 +35,6 @@ void safe_delay(millis_t ms) {
|
|||||||
thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made
|
thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EITHER(EEPROM_SETTINGS, SD_FIRMWARE_UPDATE)
|
|
||||||
|
|
||||||
void crc16(uint16_t *crc, const void * const data, uint16_t cnt) {
|
|
||||||
uint8_t *ptr = (uint8_t *)data;
|
|
||||||
while (cnt--) {
|
|
||||||
*crc = (uint16_t)(*crc ^ (uint16_t)(((uint16_t)*ptr++) << 8));
|
|
||||||
for (uint8_t i = 0; i < 8; i++)
|
|
||||||
*crc = (uint16_t)((*crc & 0x8000) ? ((uint16_t)(*crc << 1) ^ 0x1021) : (*crc << 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // EEPROM_SETTINGS || SD_FIRMWARE_UPDATE
|
|
||||||
|
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
|
|
||||||
#include "../module/probe.h"
|
#include "../module/probe.h"
|
||||||
|
@ -37,21 +37,10 @@ inline void serial_delay(const millis_t ms) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EITHER(EEPROM_SETTINGS, SD_FIRMWARE_UPDATE)
|
// 16x16 bit arrays
|
||||||
void crc16(uint16_t *crc, const void * const data, uint16_t cnt);
|
FORCE_INLINE void bitmap_clear(uint16_t bits[16], const uint8_t x, const uint8_t y) { CBI(bits[y], x); }
|
||||||
#endif
|
FORCE_INLINE void bitmap_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { SBI(bits[y], x); }
|
||||||
|
FORCE_INLINE bool is_bitmap_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { return TEST(bits[y], x); }
|
||||||
#if EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION)
|
|
||||||
/**
|
|
||||||
* These support functions allow the use of large bit arrays of flags that take very
|
|
||||||
* little RAM. Currently they are limited to being 16x16 in size. Changing the declaration
|
|
||||||
* to unsigned long will allow us to go to 32x32 if higher resolution Mesh's are needed
|
|
||||||
* in the future.
|
|
||||||
*/
|
|
||||||
FORCE_INLINE void bitmap_clear(uint16_t bits[16], const uint8_t x, const uint8_t y) { CBI(bits[y], x); }
|
|
||||||
FORCE_INLINE void bitmap_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { SBI(bits[y], x); }
|
|
||||||
FORCE_INLINE bool is_bitmap_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { return TEST(bits[y], x); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
void log_machine_info();
|
void log_machine_info();
|
||||||
@ -76,4 +65,3 @@ public:
|
|||||||
// Converts from an uint8_t in the range of 0-255 to an uint8_t
|
// Converts from an uint8_t in the range of 0-255 to an uint8_t
|
||||||
// in the range 0-100 while avoiding rounding artifacts
|
// in the range 0-100 while avoiding rounding artifacts
|
||||||
constexpr uint8_t ui8_to_percent(const uint8_t i) { return (int(i) * 100 + 127) / 255; }
|
constexpr uint8_t ui8_to_percent(const uint8_t i) { return (int(i) * 100 + 127) / 255; }
|
||||||
constexpr uint8_t all_on = 0xFF, all_off = 0x00;
|
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "../inc/MarlinConfigPre.h"
|
#include "../inc/MarlinConfigPre.h"
|
||||||
#include "../module/planner.h"
|
#include "../module/planner.h"
|
||||||
|
|
||||||
|
constexpr uint8_t all_on = 0xFF, all_off = 0x00;
|
||||||
|
|
||||||
class Backlash {
|
class Backlash {
|
||||||
public:
|
public:
|
||||||
#ifdef BACKLASH_DISTANCE_MM
|
#ifdef BACKLASH_DISTANCE_MM
|
||||||
|
@ -85,16 +85,10 @@ void GcodeSuite::M907() {
|
|||||||
*/
|
*/
|
||||||
void GcodeSuite::M908() {
|
void GcodeSuite::M908() {
|
||||||
#if HAS_DIGIPOTSS
|
#if HAS_DIGIPOTSS
|
||||||
stepper.digitalPotWrite(
|
stepper.digitalPotWrite(parser.intval('P'), parser.intval('S'));
|
||||||
parser.intval('P'),
|
|
||||||
parser.intval('S')
|
|
||||||
);
|
|
||||||
#endif
|
#endif
|
||||||
#if ENABLED(DAC_STEPPER_CURRENT)
|
#if ENABLED(DAC_STEPPER_CURRENT)
|
||||||
dac_current_raw(
|
dac_current_raw(parser.byteval('P', -1), parser.ushortval('S', 0));
|
||||||
parser.byteval('P', -1),
|
|
||||||
parser.ushortval('S', 0)
|
|
||||||
);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
32
Marlin/src/libs/crc16.cpp
Normal file
32
Marlin/src/libs/crc16.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "crc16.h"
|
||||||
|
|
||||||
|
void crc16(uint16_t *crc, const void * const data, uint16_t cnt) {
|
||||||
|
uint8_t *ptr = (uint8_t *)data;
|
||||||
|
while (cnt--) {
|
||||||
|
*crc = (uint16_t)(*crc ^ (uint16_t)(((uint16_t)*ptr++) << 8));
|
||||||
|
for (uint8_t i = 0; i < 8; i++)
|
||||||
|
*crc = (uint16_t)((*crc & 0x8000) ? ((uint16_t)(*crc << 1) ^ 0x1021) : (*crc << 1));
|
||||||
|
}
|
||||||
|
}
|
26
Marlin/src/libs/crc16.h
Normal file
26
Marlin/src/libs/crc16.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
void crc16(uint16_t *crc, const void * const data, uint16_t cnt);
|
@ -46,7 +46,7 @@ void USB::init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t USB::getUsbTaskState(void) {
|
uint8_t USB::getUsbTaskState(void) {
|
||||||
return ( usb_task_state);
|
return usb_task_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void USB::setUsbTaskState(uint8_t state) {
|
void USB::setUsbTaskState(uint8_t state) {
|
||||||
|
Loading…
Reference in New Issue
Block a user