2015-12-23 15:13:49 +00:00
|
|
|
#ifndef SPEED_LOOKUPTABLE_H
|
|
|
|
#define SPEED_LOOKUPTABLE_H
|
|
|
|
|
|
|
|
#include "Marlin.h"
|
|
|
|
|
2019-05-05 15:22:27 +00:00
|
|
|
extern const uint16_t speed_lookuptable_fast[256][2] PROGMEM;
|
|
|
|
extern const uint16_t speed_lookuptable_slow[256][2] PROGMEM;
|
2015-12-23 15:13:49 +00:00
|
|
|
|
2019-05-05 15:22:27 +00:00
|
|
|
#ifndef _NO_ASM
|
2015-12-23 15:13:49 +00:00
|
|
|
|
2019-05-05 15:22:27 +00:00
|
|
|
// intRes = intIn1 * intIn2 >> 16
|
|
|
|
// uses:
|
|
|
|
// r26 to store 0
|
|
|
|
// r27 to store the byte 1 of the 24 bit result
|
|
|
|
#define MultiU16X8toH16(intRes, charIn1, intIn2) \
|
|
|
|
asm volatile ( \
|
|
|
|
"clr r26 \n\t" \
|
|
|
|
"mul %A1, %B2 \n\t" \
|
|
|
|
"movw %A0, r0 \n\t" \
|
|
|
|
"mul %A1, %A2 \n\t" \
|
|
|
|
"add %A0, r1 \n\t" \
|
|
|
|
"adc %B0, r26 \n\t" \
|
|
|
|
"lsr r0 \n\t" \
|
|
|
|
"adc %A0, r26 \n\t" \
|
|
|
|
"adc %B0, r26 \n\t" \
|
|
|
|
"clr r1 \n\t" \
|
|
|
|
: \
|
|
|
|
"=&r" (intRes) \
|
|
|
|
: \
|
|
|
|
"d" (charIn1), \
|
|
|
|
"d" (intIn2) \
|
|
|
|
: \
|
|
|
|
"r26" \
|
|
|
|
)
|
2015-12-23 15:13:49 +00:00
|
|
|
|
2019-05-05 15:22:27 +00:00
|
|
|
// intRes = longIn1 * longIn2 >> 24
|
|
|
|
// uses:
|
|
|
|
// r26 to store 0
|
|
|
|
// r27 to store the byte 1 of the 48bit result
|
|
|
|
#define MultiU24X24toH16(intRes, longIn1, longIn2) \
|
|
|
|
asm volatile ( \
|
|
|
|
"clr r26 \n\t" \
|
|
|
|
"mul %A1, %B2 \n\t" \
|
|
|
|
"mov r27, r1 \n\t" \
|
|
|
|
"mul %B1, %C2 \n\t" \
|
|
|
|
"movw %A0, r0 \n\t" \
|
|
|
|
"mul %C1, %C2 \n\t" \
|
|
|
|
"add %B0, r0 \n\t" \
|
|
|
|
"mul %C1, %B2 \n\t" \
|
|
|
|
"add %A0, r0 \n\t" \
|
|
|
|
"adc %B0, r1 \n\t" \
|
|
|
|
"mul %A1, %C2 \n\t" \
|
|
|
|
"add r27, r0 \n\t" \
|
|
|
|
"adc %A0, r1 \n\t" \
|
|
|
|
"adc %B0, r26 \n\t" \
|
|
|
|
"mul %B1, %B2 \n\t" \
|
|
|
|
"add r27, r0 \n\t" \
|
|
|
|
"adc %A0, r1 \n\t" \
|
|
|
|
"adc %B0, r26 \n\t" \
|
|
|
|
"mul %C1, %A2 \n\t" \
|
|
|
|
"add r27, r0 \n\t" \
|
|
|
|
"adc %A0, r1 \n\t" \
|
|
|
|
"adc %B0, r26 \n\t" \
|
|
|
|
"mul %B1, %A2 \n\t" \
|
|
|
|
"add r27, r1 \n\t" \
|
|
|
|
"adc %A0, r26 \n\t" \
|
|
|
|
"adc %B0, r26 \n\t" \
|
|
|
|
"lsr r27 \n\t" \
|
|
|
|
"adc %A0, r26 \n\t" \
|
|
|
|
"adc %B0, r26 \n\t" \
|
|
|
|
"clr r1 \n\t" \
|
|
|
|
: \
|
|
|
|
"=&r" (intRes) \
|
|
|
|
: \
|
|
|
|
"d" (longIn1), \
|
|
|
|
"d" (longIn2) \
|
|
|
|
: \
|
|
|
|
"r26" , "r27" \
|
|
|
|
)
|
2015-12-23 15:13:49 +00:00
|
|
|
|
2019-05-05 15:22:27 +00:00
|
|
|
#else //_NO_ASM
|
2015-12-23 15:13:49 +00:00
|
|
|
|
2019-05-05 15:22:27 +00:00
|
|
|
// NOTE: currently not implemented
|
|
|
|
void MultiU16X8toH16(unsigned short& intRes, unsigned char& charIn1, unsigned short& intIn2);
|
|
|
|
void MultiU24X24toH16(uint16_t& intRes, int32_t& longIn1, long& longIn2);
|
2015-12-23 15:13:49 +00:00
|
|
|
|
2019-05-05 15:22:27 +00:00
|
|
|
#endif //_NO_ASM
|
2015-12-23 15:13:49 +00:00
|
|
|
|
|
|
|
#endif
|