Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MarlinKimbra
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
MarlinKimbra
Commits
a062586b
Commit
a062586b
authored
Jan 31, 2016
by
MagoKimbra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update 4.2.5
parent
b5dc91e1
Changes
14
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
642 additions
and
633 deletions
+642
-633
Configuration_Version.h
MarlinKimbra/Configuration_Version.h
+1
-1
base.h
MarlinKimbra/base.h
+8
-4
HAL.cpp
MarlinKimbra/module/HAL.cpp
+0
-415
HAL.cpp
MarlinKimbra/module/HAL/HAL.cpp
+61
-0
HAL.h
MarlinKimbra/module/HAL/HAL.h
+128
-0
HardwareSerial.cpp
MarlinKimbra/module/HAL/HardwareSerial.cpp
+258
-0
HardwareSerial.h
MarlinKimbra/module/HAL/HardwareSerial.h
+136
-0
fastio.h
MarlinKimbra/module/HAL/fastio.h
+0
-0
MK_Main.cpp
MarlinKimbra/module/MK_Main.cpp
+9
-8
communication.cpp
MarlinKimbra/module/communication/communication.cpp
+0
-151
communication.h
MarlinKimbra/module/communication/communication.h
+34
-46
language.h
MarlinKimbra/module/language/language.h
+5
-5
stepper.cpp
MarlinKimbra/module/motion/stepper.cpp
+1
-1
temperature.cpp
MarlinKimbra/module/temperature/temperature.cpp
+1
-2
No files found.
MarlinKimbra/Configuration_Version.h
View file @
a062586b
#ifndef CONFIGURATION_VERSION_H
#define CONFIGURATION_VERSION_H
#define BUILD_VERSION "MK 4.2.5 dev"
#define SHORT_BUILD_VERSION "4.2.5_dev"
#define BUILD_VERSION "MK_" SHORT_BUILD_VERSION
#define STRING_DISTRIBUTION_DATE __DATE__ " " __TIME__ // build date and time
// It might also be appropriate to define a location where additional information can be found
#define FIRMWARE_URL "https://github.com/MagoKimbra/MarlinKimbra"
...
...
MarlinKimbra/base.h
View file @
a062586b
...
...
@@ -8,9 +8,6 @@
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "module/HAL.h"
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
...
...
@@ -37,12 +34,15 @@
#include "Configuration_Feature.h"
#endif
#include "module/HAL/HAL.h"
#include "module/communication/communication.h"
#include "Configuration_Store.h"
#include "module/language/language.h"
#include "module/conditionals.h"
#include "module/sanitycheck.h"
#include "module/communication/communication.h"
#include "module/MK_Main.h"
#include "module/motion/stepper.h"
#include "module/motion/stepper_indirection.h"
...
...
@@ -88,4 +88,8 @@
#include "module/fwtest/firmware_test.h"
#endif
#if ENABLED(RFID_MODULE)
#include "module/mfrc522/MFRC522_serial.h"
#endif
#endif
MarlinKimbra/module/HAL.cpp
deleted
100644 → 0
View file @
b5dc91e1
This diff is collapsed.
Click to expand it.
MarlinKimbra/module/HAL/HAL.cpp
0 → 100644
View file @
a062586b
/*
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/>.
*/
// **************************************************************************
//
// Description: *** HAL for Arduino ***
//
// **************************************************************************
// --------------------------------------------------------------------------
// Includes
// --------------------------------------------------------------------------
#include "../../base.h"
#include "HAL.h"
HAL
::
HAL
()
{
// ctor
}
HAL
::~
HAL
()
{
// dtor
}
// Print apparent cause of start/restart
void
HAL
::
showStartReason
()
{
byte
mcu
=
MCUSR
;
if
(
mcu
&
1
)
ECHO_EM
(
SERIAL_POWERUP
);
if
(
mcu
&
2
)
ECHO_EM
(
SERIAL_EXTERNAL_RESET
);
if
(
mcu
&
4
)
ECHO_EM
(
SERIAL_BROWNOUT_RESET
);
if
(
mcu
&
8
)
ECHO_EM
(
SERIAL_WATCHDOG_RESET
);
if
(
mcu
&
32
)
ECHO_EM
(
SERIAL_SOFTWARE_RESET
);
MCUSR
=
0
;
}
// Return available memory
int
HAL
::
getFreeRam
()
{
int
freeram
=
0
;
InterruptProtectedBlock
noInts
;
uint8_t
*
heapptr
,
*
stackptr
;
heapptr
=
(
uint8_t
*
)
malloc
(
4
);
// get heap pointer
free
(
heapptr
);
// free up the memory again (sets heapptr to 0)
stackptr
=
(
uint8_t
*
)(
SP
);
// save value of stack pointer
freeram
=
(
int
)
stackptr
-
(
int
)
heapptr
;
return
freeram
;
}
// Reset peripherals and cpu
void
HAL
::
resetHardware
()
{}
MarlinKimbra/module/HAL.h
→
MarlinKimbra/module/HAL
/HAL
.h
View file @
a062586b
...
...
@@ -17,16 +17,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* Description: *** HAL for Arduino
Due
***
* Description: *** HAL for Arduino ***
*
* ARDUINO_ARCH_
SA
M
* ARDUINO_ARCH_
AR
M
*/
#ifndef HAL_H
#define HAL_H
#include <avr/
pgmspace
.h>
//#include <avr/io.h>
#include <avr/
io
.h>
#include "fastio.h"
// Arduino < 1.0.0 does not define this, so we need to do it ourselves
#ifndef analogInputToDigitalPin
...
...
@@ -43,8 +43,6 @@
#define BIT(b) (1<<(b))
#define TEST(n, b) (((n)&BIT(b))!=0)
#define SET_BIT(n, b, value) (n) ^= ((-value)^(n)) & (BIT(b))
#define bit_clear(x, y) x&= ~(1<<y)
#define bit_set(x, y) x|= (1<<y)
// Macros for maths shortcuts
#ifndef M_PI
...
...
@@ -73,42 +71,18 @@
#define CRITICAL_SECTION_END SREG = _sreg;
#endif
#if CPU_ARCH == ARCH_AVR
#include <avr/io.h>
#else
#define PROGMEM
#define PGM_P const char *
#define PSTR(s) s
#define pgm_read_byte_near(x) (*(uint8_t*)x)
#define pgm_read_byte(x) (*(uint8_t*)x)
#endif
#define PACK
#define FSTRINGVALUE(var,value) const char var[] PROGMEM = value;
#define FSTRINGVAR(var) static const char var[] PROGMEM;
#define FSTRINGPARAM(var) PGM_P var
#include <avr/eeprom.h>
#include <avr/wdt.h>
//#define EXTERNALSERIAL // Force using arduino serial
#ifndef EXTERNALSERIAL
#define HardwareSerial_h // Don't use standard serial console
#include "HardwareSerial.h"
#define MKSERIAL MKSerial
#else
#define MKSERIAL Serial
#endif
#include <inttypes.h>
#include "Print.h"
#ifdef EXTERNALSERIAL
#define SERIAL_RX_BUFFER_SIZE 128
#endif
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#define COMPAT_PRE1
#endif
/**
...
...
@@ -116,15 +90,6 @@
*/
typedef
uint32_t
millis_t
;
#if CPU_ARCH == ARCH_AVR
#include "fastio.h"
#else
#define READ(IO) digitalRead(IO)
#define WRITE(IO, v) digitalWrite(IO, v)
#define SET_INPUT(IO) pinMode(IO, INPUT)
#define SET_OUTPUT(IO) pinMode(IO, OUTPUT)
#endif
class
InterruptProtectedBlock
{
uint8_t
sreg
;
public
:
...
...
@@ -146,103 +111,6 @@
}
};
#ifndef EXTERNALSERIAL
// Implement serial communication for one stream only!
/*
* HardwareSerial.h - Hardware serial library for Wiring
* Copyright (c) 2006 Nicholas Zambetti. All right reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Modified 28 September 2010 by Mark Sproul
*
* Modified to use only 1 queue with fixed length by Repetier
*/
#define SERIAL_BUFFER_SIZE 128
#define SERIAL_BUFFER_MASK 127
#undef SERIAL_TX_BUFFER_SIZE
#undef SERIAL_TX_BUFFER_MASK
#ifdef BIG_OUTPUT_BUFFER
#define SERIAL_TX_BUFFER_SIZE 128
#define SERIAL_TX_BUFFER_MASK 127
#else
#define SERIAL_TX_BUFFER_SIZE 64
#define SERIAL_TX_BUFFER_MASK 63
#endif
struct
ring_buffer
{
uint8_t
buffer
[
SERIAL_BUFFER_SIZE
];
volatile
uint8_t
head
;
volatile
uint8_t
tail
;
};
struct
ring_buffer_tx
{
uint8_t
buffer
[
SERIAL_TX_BUFFER_SIZE
];
volatile
uint8_t
head
;
volatile
uint8_t
tail
;
};
class
MKHardwareSerial
:
public
Print
{
public
:
ring_buffer
*
_rx_buffer
;
ring_buffer_tx
*
_tx_buffer
;
volatile
uint8_t
*
_ubrrh
;
volatile
uint8_t
*
_ubrrl
;
volatile
uint8_t
*
_ucsra
;
volatile
uint8_t
*
_ucsrb
;
volatile
uint8_t
*
_udr
;
uint8_t
_rxen
;
uint8_t
_txen
;
uint8_t
_rxcie
;
uint8_t
_udrie
;
uint8_t
_u2x
;
public
:
MKHardwareSerial
(
ring_buffer
*
rx_buffer
,
ring_buffer_tx
*
tx_buffer
,
volatile
uint8_t
*
ubrrh
,
volatile
uint8_t
*
ubrrl
,
volatile
uint8_t
*
ucsra
,
volatile
uint8_t
*
ucsrb
,
volatile
uint8_t
*
udr
,
uint8_t
rxen
,
uint8_t
txen
,
uint8_t
rxcie
,
uint8_t
udrie
,
uint8_t
u2x
);
void
begin
(
unsigned
long
);
void
end
();
virtual
int
available
(
void
);
virtual
int
peek
(
void
);
virtual
int
read
(
void
);
virtual
void
flush
(
void
);
#ifdef COMPAT_PRE1
virtual
void
write
(
uint8_t
);
#else
virtual
size_t
write
(
uint8_t
);
#endif
using
Print
::
write
;
// pull in write(str) and write(buf, size) from Print
operator
bool
();
int
outputUnused
(
void
);
// Used for output in interrupts
};
extern
MKHardwareSerial
MKSerial
;
#define MKSERIAL MKSerial
//extern ring_buffer x_buffer;
#define WAIT_OUT_EMPTY while(tx_buffer.head != tx_buffer.tail) {}
#else
#define MKSERIAL Serial
#endif
class
HAL
{
public
:
...
...
@@ -250,12 +118,6 @@
virtual
~
HAL
();
static
inline
char
readFlashByte
(
PGM_P
ptr
)
{
return
pgm_read_byte
(
ptr
);
}
static
inline
void
serialSetBaudrate
(
long
baud
)
{
MKSERIAL
.
begin
(
baud
);
}
static
inline
bool
serialByteAvailable
()
{
return
MKSERIAL
.
available
()
>
0
;
}
static
inline
uint8_t
serialReadByte
()
{
return
MKSERIAL
.
read
();
}
static
inline
void
serialWriteByte
(
char
b
)
{
MKSERIAL
.
write
(
b
);
}
static
inline
void
serialFlush
()
{
MKSERIAL
.
flush
();
}
static
void
showStartReason
();
static
int
getFreeRam
();
static
void
resetHardware
();
...
...
MarlinKimbra/module/HAL/HardwareSerial.cpp
0 → 100644
View file @
a062586b
/*
HardwareSerial.cpp - Hardware serial library for Wiring
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 23 November 2006 by David A. Mellis
Modified 28 September 2010 by Mark Sproul
*/
#include "../../base.h"
#include "HardwareSerial.h"
#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
#if UART_PRESENT(SERIAL_PORT)
ring_buffer
rx_buffer
=
{
{
0
},
0
,
0
};
#endif
FORCE_INLINE
void
store_char
(
unsigned
char
c
)
{
int
i
=
(
unsigned
int
)(
rx_buffer
.
head
+
1
)
%
RX_BUFFER_SIZE
;
if
(
i
!=
rx_buffer
.
tail
)
{
rx_buffer
.
buffer
[
rx_buffer
.
head
]
=
c
;
rx_buffer
.
head
=
i
;
}
}
#if defined(M_USARTx_RX_vect)
SIGNAL
(
M_USARTx_RX_vect
)
{
unsigned
char
c
=
M_UDRx
;
store_char
(
c
);
}
#endif
// Constructors
MKHardwareSerial
::
MKHardwareSerial
()
{
}
// Public Methods
void
MKHardwareSerial
::
begin
(
long
baud
)
{
uint16_t
baud_setting
;
bool
useU2X
=
true
;
#if F_CPU == 16000000UL && SERIAL_PORT == 0
if
(
baud
==
57600
)
{
useU2X
=
false
;
}
#endif
if
(
useU2X
)
{
M_UCSRxA
=
BIT
(
M_U2Xx
);
baud_setting
=
(
F_CPU
/
4
/
baud
-
1
)
/
2
;
}
else
{
M_UCSRxA
=
0
;
baud_setting
=
(
F_CPU
/
8
/
baud
-
1
)
/
2
;
}
M_UBRRxH
=
baud_setting
>>
8
;
M_UBRRxL
=
baud_setting
;
set_bit
(
M_UCSRxB
,
M_RXENx
);
set_bit
(
M_UCSRxB
,
M_TXENx
);
set_bit
(
M_UCSRxB
,
M_RXCIEx
);
}
void
MKHardwareSerial
::
end
()
{
clear_bit
(
M_UCSRxB
,
M_RXENx
);
clear_bit
(
M_UCSRxB
,
M_TXENx
);
clear_bit
(
M_UCSRxB
,
M_RXCIEx
);
}
int
MKHardwareSerial
::
peek
(
void
)
{
if
(
rx_buffer
.
head
==
rx_buffer
.
tail
)
{
return
-
1
;
}
else
{
return
rx_buffer
.
buffer
[
rx_buffer
.
tail
];
}
}
int
MKHardwareSerial
::
read
(
void
)
{
if
(
rx_buffer
.
head
==
rx_buffer
.
tail
)
{
return
-
1
;
}
else
{
unsigned
char
c
=
rx_buffer
.
buffer
[
rx_buffer
.
tail
];
rx_buffer
.
tail
=
(
unsigned
int
)(
rx_buffer
.
tail
+
1
)
%
RX_BUFFER_SIZE
;
return
c
;
}
}
void
MKHardwareSerial
::
flush
()
{
rx_buffer
.
head
=
rx_buffer
.
tail
;
}
void
MKHardwareSerial
::
print
(
char
c
,
int
base
)
{
print
((
long
)
c
,
base
);
}
void
MKHardwareSerial
::
print
(
unsigned
char
b
,
int
base
)
{
print
((
unsigned
long
)
b
,
base
);
}
void
MKHardwareSerial
::
print
(
int
n
,
int
base
)
{
print
((
long
)
n
,
base
);
}
void
MKHardwareSerial
::
print
(
unsigned
int
n
,
int
base
)
{
print
((
unsigned
long
)
n
,
base
);
}
void
MKHardwareSerial
::
print
(
long
n
,
int
base
)
{
if
(
base
==
0
)
{
write
(
n
);
}
else
if
(
base
==
10
)
{
if
(
n
<
0
)
{
print
(
'-'
);
n
=
-
n
;
}
printNumber
(
n
,
10
);
}
else
{
printNumber
(
n
,
base
);
}
}
void
MKHardwareSerial
::
print
(
unsigned
long
n
,
int
base
)
{
if
(
base
==
0
)
write
(
n
);
else
printNumber
(
n
,
base
);
}
void
MKHardwareSerial
::
print
(
double
n
,
int
digits
)
{
printFloat
(
n
,
digits
);
}
void
MKHardwareSerial
::
println
(
void
)
{
print
(
'\r'
);
print
(
'\n'
);
}
void
MKHardwareSerial
::
println
(
const
String
&
s
)
{
print
(
s
);
println
();
}
void
MKHardwareSerial
::
println
(
const
char
c
[])
{
print
(
c
);
println
();
}
void
MKHardwareSerial
::
println
(
char
c
,
int
base
)
{
print
(
c
,
base
);
println
();
}
void
MKHardwareSerial
::
println
(
unsigned
char
b
,
int
base
)
{
print
(
b
,
base
);
println
();
}
void
MKHardwareSerial
::
println
(
int
n
,
int
base
)
{
print
(
n
,
base
);
println
();
}
void
MKHardwareSerial
::
println
(
unsigned
int
n
,
int
base
)
{
print
(
n
,
base
);
println
();
}
void
MKHardwareSerial
::
println
(
long
n
,
int
base
)
{
print
(
n
,
base
);
println
();
}
void
MKHardwareSerial
::
println
(
unsigned
long
n
,
int
base
)
{
print
(
n
,
base
);
println
();
}
void
MKHardwareSerial
::
println
(
double
n
,
int
digits
)
{
print
(
n
,
digits
);
println
();
}
// Private Methods
void
MKHardwareSerial
::
printNumber
(
unsigned
long
n
,
uint8_t
base
)
{
unsigned
char
buf
[
8
*
sizeof
(
long
)];
// Assumes 8-bit chars.
unsigned
long
i
=
0
;
if
(
n
==
0
)
{
print
(
'0'
);
return
;
}
while
(
n
>
0
)
{
buf
[
i
++
]
=
n
%
base
;
n
/=
base
;
}
for
(;
i
>
0
;
i
--
)
print
((
char
)
(
buf
[
i
-
1
]
<
10
?
'0'
+
buf
[
i
-
1
]
:
'A'
+
buf
[
i
-
1
]
-
10
));
}
void
MKHardwareSerial
::
printFloat
(
double
number
,
uint8_t
digits
)
{
// Handle negative numbers
if
(
number
<
0.0
)
{
print
(
'-'
);
number
=
-
number
;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double
rounding
=
0.5
;
for
(
uint8_t
i
=
0
;
i
<
digits
;
++
i
)
rounding
/=
10.0
;
number
+=
rounding
;
// Extract the integer part of the number and print it
unsigned
long
int_part
=
(
unsigned
long
)
number
;
double
remainder
=
number
-
(
double
)
int_part
;
print
(
int_part
);
// Print the decimal point, but only if there are digits beyond
if
(
digits
>
0
)
print
(
'.'
);
// Extract digits from the remainder one at a time
while
(
digits
--
>
0
)
{
remainder
*=
10.0
;
int
toPrint
=
int
(
remainder
);
print
(
toPrint
);
remainder
-=
toPrint
;
}
}
// Preinstantiate Objects
MKHardwareSerial
MKSerial
;
#endif
MarlinKimbra/module/HAL/HardwareSerial.h
0 → 100644
View file @
a062586b
/*
HardwareSerial.h - Hardware serial library for Wiring
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 28 September 2010 by Mark Sproul
*/
#ifndef HardwareSerial_H
#define HardwareSerial_H
#define clear_bit(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define set_bit(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
// The presence of the UBRRH register is used to detect a UART.
#define UART_PRESENT(port) ((port == 0 && (defined(UBRRH) || defined(UBRR0H))) || \
(port == 1 && defined(UBRR1H)) || (port == 2 && defined(UBRR2H)) || \
(port == 3 && defined(UBRR3H)))
// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor
// requires two levels of indirection to expand macro values properly)
#define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix)
#if SERIAL_PORT == 0 && (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix
#else
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
#endif
// Registers used by MarlinSerial class (these are expanded
// depending on selected serial port
#define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number
#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B)
#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,)
#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,)
#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,)
#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,)
#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,)
#define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H)
#define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L)
#define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,)
#define M_USARTx_RX_vect SERIAL_REGNAME(USART,SERIAL_PORT,_RX_vect)
#define M_U2Xx SERIAL_REGNAME(U2X,SERIAL_PORT,)
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
#define BYTE 0
#define RX_BUFFER_SIZE 128
struct
ring_buffer
{
unsigned
char
buffer
[
RX_BUFFER_SIZE
];
int
head
;
int
tail
;
};
#if UART_PRESENT(SERIAL_PORT)
extern
ring_buffer
rx_buffer
;
#endif
class
MKHardwareSerial
{
public
:
MKHardwareSerial
();
void
begin
(
long
);
void
end
();
int
peek
(
void
);
int
read
(
void
);
void
flush
(
void
);
FORCE_INLINE
int
available
(
void
)
{
return
(
unsigned
int
)(
RX_BUFFER_SIZE
+
rx_buffer
.
head
-
rx_buffer
.
tail
)
%
RX_BUFFER_SIZE
;
}
FORCE_INLINE
void
write
(
uint8_t
c
)
{
while
(
!
TEST
(
M_UCSRxA
,
M_UDREx
));
M_UDRx
=
c
;
}
FORCE_INLINE
void
checkRx
(
void
)
{
if
(
TEST
(
M_UCSRxA
,
M_RXCx
))
{
unsigned
char
c
=
M_UDRx
;
int
i
=
(
unsigned
int
)(
rx_buffer
.
head
+
1
)
%
RX_BUFFER_SIZE
;
if
(
i
!=
rx_buffer
.
tail
)
{
rx_buffer
.
buffer
[
rx_buffer
.
head
]
=
c
;
rx_buffer
.
head
=
i
;
}
}
}
private
:
void
printNumber
(
unsigned
long
,
uint8_t
);
void
printFloat
(
double
,
uint8_t
);
public
:
FORCE_INLINE
void
write
(
const
char
*
str
)
{
while
(
*
str
)
write
(
*
str
++
);
}
FORCE_INLINE
void
write
(
const
uint8_t
*
buffer
,
size_t
size
)
{
while
(
size
--
)
write
(
*
buffer
++
);
}
FORCE_INLINE
void
print
(
const
String
&
s
)
{
for
(
int
i
=
0
;
i
<
(
int
)
s
.
length
();
i
++
)
write
(
s
[
i
]);
}
FORCE_INLINE
void
print
(
const
char
*
str
)
{
write
(
str
);
}
void
print
(
char
,
int
=
BYTE
);
void
print
(
unsigned
char
,
int
=
BYTE
);
void
print
(
int
,
int
=
DEC
);
void
print
(
unsigned
int
,
int
=
DEC
);
void
print
(
long
,
int
=
DEC
);
void
print
(
unsigned
long
,
int
=
DEC
);
void
print
(
double
,
int
=
2
);
void
println
(
const
String
&
s
);
void
println
(
const
char
[]);
void
println
(
char
,
int
=
BYTE
);
void
println
(
unsigned
char
,
int
=
BYTE
);
void
println
(
int
,
int
=
DEC
);
void
println
(
unsigned
int
,
int
=
DEC
);
void
println
(
long
,
int
=
DEC
);
void
println
(
unsigned
long
,
int
=
DEC
);
void
println
(
double
,
int
=
2
);
void
println
(
void
);
};
extern
MKHardwareSerial
MKSerial
;
#endif // HardwareSerial_H
MarlinKimbra/module/fastio.h
→
MarlinKimbra/module/
HAL/
fastio.h
View file @
a062586b
File moved
MarlinKimbra/module/MK_Main.cpp
View file @
a062586b
/**
* MK Firmware
*
* Based on Sprinter and grbl.
* Based on Marlin, Sprinter and grbl
* Copyright (C) 2013 MagoKimbra
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
...
...
@@ -587,7 +588,7 @@ void setup() {
disableStepperDrivers
();
#endif
HAL
::
serialSetBaudrate
(
BAUDRATE
);
SERIAL_INIT
(
BAUDRATE
);
ECHO_EM
(
START
);
HAL
::
showStartReason
();
ECHO_EM
(
BUILD_VERSION
);
...
...
@@ -732,7 +733,7 @@ void get_command() {
static
millis_t
last_command_time
=
0
;
millis_t
ms
=
millis
();
if
(
!
HAL
::
serialByteA
vailable
()
&&
commands_in_queue
==
0
&&
ms
-
last_command_time
>
1000UL
)
{
if
(
!
MKSERIAL
.
a
vailable
()
&&
commands_in_queue
==
0
&&
ms
-
last_command_time
>
1000UL
)
{
ECHO_L
(
WT
);
last_command_time
=
ms
;
}
...
...
@@ -741,13 +742,13 @@ void get_command() {
//
// Loop while serial characters are incoming and the queue is not full
//
while
(
HAL
::
serialByteA
vailable
()
>
0
&&
commands_in_queue
<
BUFSIZE
)
{
while
(
MKSERIAL
.
a
vailable
()
>
0
&&
commands_in_queue
<
BUFSIZE
)
{
#if ENABLED(NO_TIMEOUTS)
last_command_time
=
ms
;
#endif
serial_char
=
HAL
::
serialReadByte
();
serial_char
=
MKSERIAL
.
read
();
//
// If the character ends the line, or the line is full...
...
...
@@ -826,9 +827,9 @@ void get_command() {
serial_count
=
0
;
//clear buffer
}
else
if
(
serial_char
==
'\\'
)
{
// Handle escapes
if
(
HAL
::
serialByteA
vailable
()
>
0
&&
commands_in_queue
<
BUFSIZE
)
{
if
(
MKSERIAL
.
a
vailable
()
>
0
&&
commands_in_queue
<
BUFSIZE
)
{
// if we have one more character, copy it over
serial_char
=
HAL
::
serialReadByte
();
serial_char
=
MKSERIAL
.
read
();
command_queue
[
cmd_queue_index_w
][
serial_count
++
]
=
serial_char
;
}
// otherwise do nothing
...
...
@@ -7384,7 +7385,7 @@ ExitUnknownCommand:
void
FlushSerialRequestResend
()
{
//char command_queue[cmd_queue_index_r][100]="Resend:";
HAL
::
serialF
lush
();
MKSERIAL
.
f
lush
();
ECHO_LV
(
RESEND
,
(
long
)(
gcode_LastN
+
1
));
ECHO_S
(
OK
);
}
...
...
MarlinKimbra/module/communication/communication.cpp
deleted
100644 → 0
View file @
b5dc91e1
/**
* This file is part of MarlinKimbra Firmware.
*
* MarlinKimbra Firmware 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.
*
* MarlinKimbra Firmware 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 MarlinKimbra Firmware. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../../base.h"
void
Com
::
printF
(
FSTRINGPARAM
(
ptr
))
{
char
c
;
while
((
c
=
HAL
::
readFlashByte
(
ptr
++
))
!=
0
)
HAL
::
serialWriteByte
(
c
);
}
void
Com
::
printVal
(
int
value
)
{
print
(
value
);
}
void
Com
::
printVal
(
int8_t
value
)
{
print
(
value
);
}
void
Com
::
printVal
(
uint8_t
value
)
{
print
(
value
);
}
void
Com
::
printVal
(
int32_t
value
)
{
print
(
value
);
}
void
Com
::
printVal
(
uint32_t
value
)
{
printNumber
(
value
);
}
void
Com
::
printVal
(
float
value
,
uint8_t
digits
)
{
printFloat
(
value
,
digits
);
}
void
Com
::
printVal
(
double
value
,
uint8_t
digits
)
{
printFloat
(
value
,
digits
);
}
void
Com
::
print
(
const
char
*
text
)
{
while
(
*
text
)
{
HAL
::
serialWriteByte
(
*
text
++
);
}
}
void
Com
::
print
(
char
c
)
{
HAL
::
serialWriteByte
(
c
);
}
void
Com
::
print
(
float
number
)
{
printFloat
(
number
,
6
);
}
void
Com
::
print
(
int
value
)
{
print
((
int32_t
)
value
);
}
void
Com
::
print
(
long
value
)
{
if
(
value
<
0
)
{
HAL
::
serialWriteByte
(
'-'
);
value
=
-
value
;
}
printNumber
(
value
);
}
void
Com
::
print
(
uint16_t
value
)
{
printNumber
(
value
);
}
void
Com
::
print
(
uint32_t
value
)
{
printNumber
(
value
);
}
void
Com
::
printNumber
(
uint32_t
n
)
{
char
buf
[
11
];
// Assumes 8-bit chars plus zero byte.
char
*
str
=
&
buf
[
10
];
*
str
=
'\0'
;
do
{
unsigned
long
m
=
n
;
n
/=
10
;
*--
str
=
'0'
+
(
m
-
10
*
n
);
}
while
(
n
);
print
(
str
);
}
void
Com
::
printArray
(
float
*
arr
,
uint8_t
n
,
uint8_t
digits
)
{
for
(
uint8_t
i
=
0
;
i
<
n
;
i
++
)
{
print
(
" "
);
printFloat
(
arr
[
i
],
digits
);
}
}
void
Com
::
printArray
(
int32_t
*
arr
,
uint8_t
n
)
{
for
(
uint8_t
i
=
0
;
i
<
n
;
i
++
)
{
print
(
" "
);
printVal
(
arr
[
i
]);
}
}
void
Com
::
printFloat
(
float
number
,
uint8_t
digits
)
{
if
(
isnan
(
number
))
{
print
(
TNAN
);
return
;
}
if
(
isinf
(
number
))
{
print
(
TINF
);
return
;
}
// Handle negative numbers
if
(
number
<
0.0
)
{
print
(
'-'
);
number
=
-
number
;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
float
rounding
=
0.5
;
for
(
uint8_t
i
=
0
;
i
<
digits
;
++
i
)
rounding
/=
10.0
;
number
+=
rounding
;
// Extract the integer part of the number and print it
unsigned
long
int_part
=
(
unsigned
long
)
number
;
float
remainder
=
number
-
(
float
)
int_part
;
printNumber
(
int_part
);
// Print the decimal point, but only if there are digits beyond
if
(
digits
>
0
)
print
(
'.'
);
// Extract digits from the remainder one at a time
while
(
digits
--
>
0
)
{
remainder
*=
10.0
;
int
toPrint
=
int
(
remainder
);
print
(
toPrint
);
remainder
-=
toPrint
;
}
}
MarlinKimbra/module/communication/communication.h
View file @
a062586b
#ifndef COMMUNICATION_H
#define COMMUNICATION_H
class
Com
{
public
:
#define START "start" // start for host
#define OK "ok " // ok answer for host
#define ER "Error: " // error for host
...
...
@@ -18,38 +16,28 @@
#define RESUME "//action:resume" // command for host that support action
#define DISCONNECT "//action:disconnect" // command for host that support action
static
void
printFloat
(
float
number
,
uint8_t
digits
);
static
void
printVal
(
int
value
);
static
void
printVal
(
int8_t
value
);
static
void
printVal
(
uint8_t
value
);
static
void
printVal
(
int32_t
value
);
static
void
printVal
(
uint32_t
value
);
static
void
printVal
(
float
value
,
uint8_t
digits
=
2
);
static
void
printVal
(
double
value
,
uint8_t
digits
=
2
);
static
void
printArray
(
float
*
arr
,
uint8_t
n
=
4
,
uint8_t
digits
=
2
);
static
void
printArray
(
long
*
arr
,
uint8_t
n
=
4
);
static
void
printNumber
(
uint32_t
n
);
static
void
print
(
long
value
);
static
void
print
(
uint16_t
value
);
static
void
print
(
uint32_t
value
);
static
void
print
(
int
value
);
static
void
print
(
float
number
);
static
void
print
(
const
char
*
text
);
static
void
print
(
char
c
);
static
void
println
()
{
HAL
::
serialWriteByte
(
'\r'
);
HAL
::
serialWriteByte
(
'\n'
);
}
static
void
printF
(
FSTRINGPARAM
(
ptr
));
protected
:
private
:
};
#define SERIAL_INIT(baud) MKSERIAL.begin(baud), delay(1)
#define SERIAL_WRITE(x) MKSERIAL.write(x)
#define SERIAL_PRINT(msg, args...) MKSERIAL.print(msg, ##args)
#define SERIAL_ENDL MKSERIAL.println()
#define SERIAL_WRITE(x) HAL::serialWriteByte(x)
FORCE_INLINE
void
PS_PGM
(
const
char
*
str
)
{
char
c
;
while
(
c
=
pgm_read_byte
(
str
))
{
SERIAL_WRITE
(
c
);
str
++
;
}
}
#define ECHO_S(srt) Com::printF(PSTR(srt))
#define ECHO_M(msg) Com::printF(PSTR(msg))
#define ECHO_T(txt) Com::print(txt)
#define ECHO_V(val, args...) Com::printVal(val, ##args)
#define ECHO_C(x) Com::print(x)
#define ECHO_E Com::println()
#define ECHO_ENDL SERIAL_ENDL
#define ECHO_PGM(message) PS_PGM(PSTR(message))
#define ECHO_S(srt) ECHO_PGM(srt)
#define ECHO_M(msg) ECHO_PGM(msg)
#define ECHO_T SERIAL_PRINT
#define ECHO_V SERIAL_PRINT
#define ECHO_C SERIAL_WRITE
#define ECHO_E SERIAL_ENDL
#define ECHO_MV(msg, val, args...) ECHO_M(msg),ECHO_V(val, ##args)
#define ECHO_VM(val, msg, args...) ECHO_V(val, ##args),ECHO_M(msg)
...
...
MarlinKimbra/module/language/language.h
View file @
a062586b
...
...
@@ -61,15 +61,15 @@
// Serial Console Messages (do not translate those!)
#if MECH(CARTESIAN)
#define SERIAL_M115_REPORT "FIRMWARE_NAME:
MK_" SHORT_
BUILD_VERSION " FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:Mendel EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#define SERIAL_M115_REPORT "FIRMWARE_NAME:
"
BUILD_VERSION " FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:Mendel EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#elif MECH(COREXY)
#define SERIAL_M115_REPORT "FIRMWARE_NAME:
MK_" SHORT_
BUILD_VERSION " FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:Core_XY EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#define SERIAL_M115_REPORT "FIRMWARE_NAME:
"
BUILD_VERSION " FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:Core_XY EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#elif MECH(COREXZ)
#define SERIAL_M115_REPORT "FIRMWARE_NAME:
MK_" SHORT_
BUILD_VERSION " FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:Core_XZ EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#define SERIAL_M115_REPORT "FIRMWARE_NAME:
"
BUILD_VERSION " FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:Core_XZ EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#elif MECH(DELTA)
#define SERIAL_M115_REPORT "FIRMWARE_NAME:
MK_" SHORT_
BUILD_VERSION " FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:Delta EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#define SERIAL_M115_REPORT "FIRMWARE_NAME:
"
BUILD_VERSION " FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:Delta EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#elif MECH(SCARA)
#define SERIAL_M115_REPORT "FIRMWARE_NAME:
MK_" SHORT_
BUILD_VERSION " FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:Scara EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#define SERIAL_M115_REPORT "FIRMWARE_NAME:
"
BUILD_VERSION " FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:Scara EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#endif
#define SERIAL_ENQUEUEING "enqueueing \""
...
...
MarlinKimbra/module/motion/stepper.cpp
View file @
a062586b
...
...
@@ -686,7 +686,7 @@ ISR(TIMER1_COMPA_vect) {
// Take multiple steps per interrupt (For high speed moves)
for
(
int8_t
i
=
0
;
i
<
step_loops
;
i
++
)
{
#ifndef USBCON
HAL
::
serialByteAvailable
();
// Check for serial chars.
MKSERIAL
.
checkRx
();
// Check for serial chars.
#endif
#if ENABLED(ADVANCE)
...
...
MarlinKimbra/module/temperature/temperature.cpp
View file @
a062586b
...
...
@@ -468,8 +468,7 @@ void checkExtruderAutoFans() {
inline
void
_temp_error
(
int
h
,
const
char
*
serial_msg
,
const
char
*
lcd_msg
)
{
static
bool
killed
=
false
;
if
(
IsRunning
())
{
ECHO_S
(
ER
);
Com
::
printF
(
serial_msg
);
ECHO_ST
(
ER
,
serial_msg
);
ECHO_M
(
SERIAL_STOPPED_HEATER
);
if
(
h
>=
0
)
ECHO_EV
((
int
)
h
);
else
ECHO_EM
(
SERIAL_HEATER_BED
);
#if ENABLED(ULTRA_LCD)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment